Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: ash/launcher/overflow_bubble.cc

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win fix Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/launcher/overflow_bubble.h" 5 #include "ash/launcher/overflow_bubble.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/launcher/launcher_types.h" 9 #include "ash/launcher/launcher_types.h"
10 #include "ash/launcher/launcher_view.h" 10 #include "ash/launcher/launcher_view.h"
11 #include "ash/shell.h"
11 #include "ui/gfx/insets.h" 12 #include "ui/gfx/insets.h"
12 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
13 #include "ui/views/bubble/bubble_delegate.h" 14 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/bubble/bubble_frame_view.h" 15 #include "ui/views/bubble/bubble_frame_view.h"
15 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
16 17
17 namespace ash { 18 namespace ash {
18 namespace internal { 19 namespace internal {
19 20
20 namespace { 21 namespace {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 const gfx::Size contents_size(GetContentsSize()); 139 const gfx::Size contents_size(GetContentsSize());
139 140
140 int y = std::min(contents_size.height() - visible_bounds.height(), 141 int y = std::min(contents_size.height() - visible_bounds.height(),
141 std::max(0, scroll_offset_.y() + y_offset)); 142 std::max(0, scroll_offset_.y() + y_offset));
142 scroll_offset_.set_y(y); 143 scroll_offset_.set_y(y);
143 } 144 }
144 145
145 gfx::Size OverflowBubbleView::GetPreferredSize() { 146 gfx::Size OverflowBubbleView::GetPreferredSize() {
146 gfx::Size preferred_size = GetContentsSize(); 147 gfx::Size preferred_size = GetContentsSize();
147 148
148 const gfx::Rect monitor_rect = gfx::Screen::GetDisplayNearestPoint( 149 const gfx::Rect monitor_rect =
149 GetAnchorRect().CenterPoint()).work_area(); 150 ash::Shell::GetAshScreen()->GetDisplayNearestPoint(
151 GetAnchorRect().CenterPoint()).work_area();
150 if (!monitor_rect.IsEmpty()) { 152 if (!monitor_rect.IsEmpty()) {
151 if (is_horizontal_alignment()) { 153 if (is_horizontal_alignment()) {
152 preferred_size.set_width(std::min( 154 preferred_size.set_width(std::min(
153 preferred_size.width(), 155 preferred_size.width(),
154 static_cast<int>(monitor_rect.width() * 156 static_cast<int>(monitor_rect.width() *
155 kMaxBubbleSizeToScreenRatio))); 157 kMaxBubbleSizeToScreenRatio)));
156 } else { 158 } else {
157 preferred_size.set_height(std::min( 159 preferred_size.set_height(std::min(
158 preferred_size.height(), 160 preferred_size.height(),
159 static_cast<int>(monitor_rect.height() * 161 static_cast<int>(monitor_rect.height() *
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 210
209 const gfx::Size content_size = GetPreferredSize(); 211 const gfx::Size content_size = GetPreferredSize();
210 border->set_arrow_offset(arrow_offset); 212 border->set_arrow_offset(arrow_offset);
211 213
212 const gfx::Rect anchor_rect = GetAnchorRect(); 214 const gfx::Rect anchor_rect = GetAnchorRect();
213 gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds( 215 gfx::Rect bubble_rect = GetBubbleFrameView()->GetUpdatedWindowBounds(
214 anchor_rect, 216 anchor_rect,
215 content_size, 217 content_size,
216 false); 218 false);
217 219
218 gfx::Rect monitor_rect = gfx::Screen::GetDisplayNearestPoint( 220 gfx::Rect monitor_rect = ash::Shell::GetAshScreen()->GetDisplayNearestPoint(
219 anchor_rect.CenterPoint()).work_area(); 221 anchor_rect.CenterPoint()).work_area();
220 222
221 int offset = 0; 223 int offset = 0;
222 if (views::BubbleBorder::is_arrow_on_horizontal(arrow_location())) { 224 if (views::BubbleBorder::is_arrow_on_horizontal(arrow_location())) {
223 if (bubble_rect.x() < monitor_rect.x()) 225 if (bubble_rect.x() < monitor_rect.x())
224 offset = monitor_rect.x() - bubble_rect.x(); 226 offset = monitor_rect.x() - bubble_rect.x();
225 else if (bubble_rect.right() > monitor_rect.right()) 227 else if (bubble_rect.right() > monitor_rect.right())
226 offset = monitor_rect.right() - bubble_rect.right(); 228 offset = monitor_rect.right() - bubble_rect.right();
227 229
228 bubble_rect.Offset(offset, 0); 230 bubble_rect.Offset(offset, 0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 bubble_ = NULL; 281 bubble_ = NULL;
280 } 282 }
281 283
282 void OverflowBubble::OnWidgetClosing(views::Widget* widget) { 284 void OverflowBubble::OnWidgetClosing(views::Widget* widget) {
283 DCHECK(widget == bubble_->GetWidget()); 285 DCHECK(widget == bubble_->GetWidget());
284 bubble_ = NULL; 286 bubble_ = NULL;
285 } 287 }
286 288
287 } // namespace internal 289 } // namespace internal
288 } // namespace ash 290 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698