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

Unified Diff: ui/display/screen.cc

Issue 2549543002: Clamp dialog bounds to be fully visible on the nearest display (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/screen.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/screen.cc
diff --git a/ui/display/screen.cc b/ui/display/screen.cc
index 9f0f1dce5beb08516291ad379ec94fd7d37057fa..cfcb4321869172413af4e532c25a72e6eeb5c1e4 100644
--- a/ui/display/screen.cc
+++ b/ui/display/screen.cc
@@ -5,6 +5,7 @@
#include "ui/display/screen.h"
#include "ui/display/display.h"
+#include "ui/display/display_finder.h"
#include "ui/gfx/geometry/rect.h"
namespace display {
@@ -34,6 +35,28 @@ void Screen::SetScreenInstance(Screen* instance) {
g_screen = instance;
}
+//static
msw 2016/12/12 23:04:35 nit: space after slashes
msw 2016/12/13 22:52:43 Ping
kylix_rd 2016/12/14 17:35:10 Done.
+gfx::Rect Screen::MoveScreenRectToNearestDisplay(
msw 2016/12/12 23:04:35 Will this be used elsewhere? Might it make sense t
kylix_rd 2016/12/13 14:17:44 I'd originally put this code in that file but this
msw 2016/12/13 22:52:43 I'm also a little surprised that I can't find a si
kylix_rd 2016/12/14 17:35:10 My point was that should this be put elsewhere, it
msw 2016/12/14 18:22:06 Finding code to reuse later isn't too hard. I sear
+ const gfx::Rect& screen_rect) {
+ gfx::Rect display_rect = screen_rect;
+ const display::Display* display =
+ display::FindDisplayNearestPoint(GetScreen()->GetAllDisplays(),
+ display_rect.CenterPoint());
msw 2016/12/14 18:45:11 It might make sense to use the display closest to
+ DCHECK(display);
+ const gfx::Rect work_area = display->work_area();
+ if (!work_area.Contains(display_rect)) {
msw 2016/12/12 23:04:35 q: do we care about making minimal changes to the
kylix_rd 2016/12/13 14:17:44 If the rect were partially visible, it would be so
msw 2016/12/13 22:52:44 Hopefully this positioning fixup is applied before
kylix_rd 2016/12/14 17:35:10 Yes, this is done prior to the dialog is initially
msw 2016/12/14 18:22:06 I'm saying that if a window were larger than the d
msw 2016/12/14 18:45:12 Perhaps the right function for this job is gfx::Re
+ if (display_rect.x() < work_area.x())
+ display_rect.set_x(work_area.x());
+ if (display_rect.right() > work_area.right())
msw 2016/12/13 22:52:44 else if? (or handle rects larger than the work are
kylix_rd 2016/12/14 17:35:10 See above comment.
+ display_rect.set_x(work_area.right() - display_rect.width());
+ if (display_rect.y() < work_area.y())
+ display_rect.set_y(work_area.y());
+ if (display_rect.bottom() > work_area.bottom())
msw 2016/12/13 22:52:44 else if? (or handle rects larger than the work are
+ display_rect.set_y(work_area.bottom() - display_rect.height());
+ }
+ return display_rect;
+}
+
gfx::Rect Screen::ScreenToDIPRectInWindow(gfx::NativeView view,
const gfx::Rect& screen_rect) const {
float scale = GetDisplayNearestWindow(view).device_scale_factor();
« no previous file with comments | « ui/display/screen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698