summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 17:39:40 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 17:39:40 +0000
commita6eb6c02c42b32cbd363ef599f805e18565f4f6b (patch)
treed2a1e73d8422728ed41b4fe59cf09de6d365bace /views
parent2fba276d4c3f693b87e0df88e6ea0f8dcb1a5e8e (diff)
downloadchromium_src-a6eb6c02c42b32cbd363ef599f805e18565f4f6b.zip
chromium_src-a6eb6c02c42b32cbd363ef599f805e18565f4f6b.tar.gz
chromium_src-a6eb6c02c42b32cbd363ef599f805e18565f4f6b.tar.bz2
Lands http://codereview.chromium.org/6380007/ for jamiewalch
Don't allow new windows to be created outside the monitor's work area. BUG=281 TEST=Drag a tab down to the bottom of the screen. Check that the new window is created with its border accessible. Review URL: http://codereview.chromium.org/6335019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/screen.h3
-rw-r--r--views/screen_gtk.cc6
-rw-r--r--views/screen_win.cc22
3 files changed, 24 insertions, 7 deletions
diff --git a/views/screen.h b/views/screen.h
index 6d6bc89..494f126 100644
--- a/views/screen.h
+++ b/views/screen.h
@@ -25,6 +25,9 @@ class Screen {
// Returns the bounds of the monitor nearest the specified window.
static gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view);
+ // Returns the work area of the monitor nearest the specified point.
+ static gfx::Rect GetMonitorWorkAreaNearestPoint(const gfx::Point& point);
+
// Returns the monitor area (not the work area, but the complete bounds) of
// the monitor nearest the specified point.
static gfx::Rect GetMonitorAreaNearestPoint(const gfx::Point& point);
diff --git a/views/screen_gtk.cc b/views/screen_gtk.cc
index 05076d7..0a01c6c 100644
--- a/views/screen_gtk.cc
+++ b/views/screen_gtk.cc
@@ -76,6 +76,12 @@ gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) {
}
// static
+gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
+ // TODO(jamiewalch): Restrict this to the work area of the monitor.
+ return GetMonitorAreaNearestPoint(point);
+}
+
+// static
gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
GdkScreen* screen = gdk_screen_get_default();
gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y());
diff --git a/views/screen_win.cc b/views/screen_win.cc
index 4ddb7c1..b24a55c 100644
--- a/views/screen_win.cc
+++ b/views/screen_win.cc
@@ -33,17 +33,25 @@ gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeWindow window) {
return gfx::Rect(monitor_info.rcMonitor);
}
-// static
-gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
+static gfx::Rect GetMonitorAreaOrWorkAreaNearestPoint(const gfx::Point& point,
+ bool work_area) {
POINT initial_loc = { point.x(), point.y() };
HMONITOR monitor = MonitorFromPoint(initial_loc, MONITOR_DEFAULTTONEAREST);
- if (!monitor)
- return gfx::Rect();
-
MONITORINFO mi = {0};
mi.cbSize = sizeof(mi);
- GetMonitorInfo(monitor, &mi);
- return gfx::Rect(mi.rcMonitor);
+ if (monitor && GetMonitorInfo(monitor, &mi))
+ return gfx::Rect(work_area ? mi.rcWork : mi.rcMonitor);
+ return gfx::Rect();
+}
+
+// static
+gfx::Rect Screen::GetMonitorWorkAreaNearestPoint(const gfx::Point& point) {
+ return GetMonitorAreaOrWorkAreaNearestPoint(point, true);
+}
+
+// static
+gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) {
+ return GetMonitorAreaOrWorkAreaNearestPoint(point, false);
}
gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {