diff options
-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 |