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: components/constrained_window/constrained_window_views.cc

Issue 2751833004: Reland "Add display::GetDisplayNearestView" (Closed)
Patch Set: Created 3 years, 9 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
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 "components/constrained_window/constrained_window_views.h" 5 #include "components/constrained_window/constrained_window_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 position.set_y(position.y() - border->GetInsets().top()); 110 position.set_y(position.y() - border->GetInsets().top());
111 } 111 }
112 112
113 if (widget->is_top_level()) { 113 if (widget->is_top_level()) {
114 position += host_widget->GetClientAreaBoundsInScreen().OffsetFromOrigin(); 114 position += host_widget->GetClientAreaBoundsInScreen().OffsetFromOrigin();
115 // If the dialog extends partially off any display, clamp its position to 115 // If the dialog extends partially off any display, clamp its position to
116 // be fully visible within that display. If the dialog doesn't intersect 116 // be fully visible within that display. If the dialog doesn't intersect
117 // with any display clamp its position to be fully on the nearest display. 117 // with any display clamp its position to be fully on the nearest display.
118 gfx::Rect display_rect = gfx::Rect(position, size); 118 gfx::Rect display_rect = gfx::Rect(position, size);
119 const display::Display display = 119 const display::Display display =
120 display::Screen::GetScreen()->GetDisplayNearestWindow( 120 display::Screen::GetScreen()->GetDisplayNearestView(
121 dialog_host->GetHostView()); 121 dialog_host->GetHostView());
122 const gfx::Rect work_area = display.work_area(); 122 const gfx::Rect work_area = display.work_area();
123 if (!work_area.Contains(display_rect)) 123 if (!work_area.Contains(display_rect))
124 display_rect.AdjustToFit(work_area); 124 display_rect.AdjustToFit(work_area);
125 position = display_rect.origin(); 125 position = display_rect.origin();
126 } 126 }
127 127
128 widget->SetBounds(gfx::Rect(position, size)); 128 widget->SetBounds(gfx::Rect(position, size));
129 } 129 }
130 130
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 DCHECK_EQ(parent_view, host->GetHostView()); 240 DCHECK_EQ(parent_view, host->GetHostView());
241 ModalDialogHostObserver* dialog_host_observer = 241 ModalDialogHostObserver* dialog_host_observer =
242 new WidgetModalDialogHostObserverViews( 242 new WidgetModalDialogHostObserverViews(
243 host, widget, kWidgetModalDialogHostObserverViewsKey); 243 host, widget, kWidgetModalDialogHostObserverViewsKey);
244 dialog_host_observer->OnPositionRequiresUpdate(); 244 dialog_host_observer->OnPositionRequiresUpdate();
245 } 245 }
246 return widget; 246 return widget;
247 } 247 }
248 248
249 } // namespace constrained window 249 } // namespace constrained window
OLDNEW
« no previous file with comments | « chromecast/graphics/cast_screen.h ('k') | content/browser/renderer_host/render_widget_host_view_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698