diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 18:04:14 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 18:04:14 +0000 |
commit | a65808d30e438a889aac5a97227ca5a0704bc471 (patch) | |
tree | 353d270c3f80f7097580d486f53163c66d3626a1 /views | |
parent | 3fe92d85a949ff4b7b58405d1a91ba9752e4f477 (diff) | |
download | chromium_src-a65808d30e438a889aac5a97227ca5a0704bc471.zip chromium_src-a65808d30e438a889aac5a97227ca5a0704bc471.tar.gz chromium_src-a65808d30e438a889aac5a97227ca5a0704bc471.tar.bz2 |
Adds views::Screen::GetMonitorAreaNearestPoint.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/199023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/screen.h | 4 | ||||
-rw-r--r-- | views/screen_gtk.cc | 16 | ||||
-rw-r--r-- | views/screen_win.cc | 13 |
3 files changed, 30 insertions, 3 deletions
diff --git a/views/screen.h b/views/screen.h index c4e5bd6..013cb06 100644 --- a/views/screen.h +++ b/views/screen.h @@ -20,6 +20,10 @@ class Screen { // Returns the work area of the monitor nearest the specified window. static gfx::Rect GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window); + + // 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); }; } // namespace views diff --git a/views/screen_gtk.cc b/views/screen_gtk.cc index 22aaa44..2a30d90 100644 --- a/views/screen_gtk.cc +++ b/views/screen_gtk.cc @@ -17,9 +17,7 @@ gfx::Point Screen::GetCursorScreenPoint() { return gfx::Point(x, y); } -// static -gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { - // TODO(beng): use |window|. +gfx::Rect static GetPrimaryMonitorBounds() { guchar* raw_data = NULL; gint data_len = 0; gboolean success = gdk_property_get(gdk_get_default_root_window(), @@ -32,5 +30,17 @@ gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { return gfx::Rect(data[0], data[1], data[0] + data[2], data[1] + data[3]); } +// static +gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { + // TODO(beng): use |window|. + return GetPrimaryMonitorBounds(); +} + +// static +gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { + // TODO: use |point|. + return GetPrimaryMonitorBounds(); +} + } // namespace diff --git a/views/screen_win.cc b/views/screen_win.cc index b6e7a15..7bfeada 100644 --- a/views/screen_win.cc +++ b/views/screen_win.cc @@ -24,5 +24,18 @@ gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeWindow window) { return gfx::Rect(monitor_info.rcWork); } +// static +gfx::Rect Screen::GetMonitorAreaNearestPoint(const gfx::Point& point) { + 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); +} + } // namespace |