| Index: ui/gfx/screen_gtk.cc
|
| diff --git a/ui/gfx/screen_gtk.cc b/ui/gfx/screen_gtk.cc
|
| index 1607cc8ea8f1ce2db4ff3e18883ccb5b9872ff70..8ce6fd20008a176b35c98b02a24b8146b5b56985 100644
|
| --- a/ui/gfx/screen_gtk.cc
|
| +++ b/ui/gfx/screen_gtk.cc
|
| @@ -8,6 +8,7 @@
|
| #include <gtk/gtk.h>
|
|
|
| #include "base/logging.h"
|
| +#include "ui/gfx/monitor.h"
|
|
|
| namespace {
|
|
|
| @@ -46,33 +47,14 @@ bool GetScreenWorkArea(gfx::Rect* out_rect) {
|
| return true;
|
| }
|
|
|
| -} // namespace
|
| -
|
| -namespace gfx {
|
| -
|
| -// static
|
| -gfx::Point Screen::GetCursorScreenPoint() {
|
| - gint x, y;
|
| - gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL);
|
| - return gfx::Point(x, y);
|
| -}
|
| -
|
| -// static
|
| -gfx::Rect Screen::GetMonitorWorkAreaNearestWindow(gfx::NativeView view) {
|
| - // Do not use the _NET_WORKAREA here, this is supposed to be an area on a
|
| - // specific monitor, and _NET_WORKAREA is a hint from the WM that generally
|
| - // spans across all monitors. This would make the work area larger than the
|
| - // monitor.
|
| - // TODO(danakj) This is a work-around as there is no standard way to get this
|
| - // area, but it is a rect that we should be computing. The standard means
|
| - // to compute this rect would be to watch all windows with
|
| - // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the physical
|
| - // area of the monitor to construct a work area.
|
| - return GetMonitorAreaNearestWindow(view);
|
| +gfx::Rect NativePrimaryMonitorBounds() {
|
| + GdkScreen* screen = gdk_screen_get_default();
|
| + GdkRectangle rect;
|
| + gdk_screen_get_monitor_geometry(screen, 0, &rect);
|
| + return gfx::Rect(rect);
|
| }
|
|
|
| -// static
|
| -gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) {
|
| +gfx::Rect GetMonitorAreaNearestWindow(gfx::NativeView view) {
|
| GdkScreen* screen = gdk_screen_get_default();
|
| gint monitor_num = 0;
|
| if (view) {
|
| @@ -89,43 +71,15 @@ gfx::Rect Screen::GetMonitorAreaNearestWindow(gfx::NativeView view) {
|
| return gfx::Rect(bounds);
|
| }
|
|
|
| -// 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());
|
| - GdkRectangle bounds;
|
| - gdk_screen_get_monitor_geometry(screen, monitor, &bounds);
|
| - return gfx::Rect(bounds);
|
| -}
|
| -
|
| -// static
|
| -gfx::Rect Screen::GetPrimaryMonitorWorkArea() {
|
| - gfx::Rect rect;
|
| - if (GetScreenWorkArea(&rect))
|
| - return rect.Intersect(GetPrimaryMonitorBounds());
|
| -
|
| - // Return the best we've got.
|
| - return GetPrimaryMonitorBounds();
|
| -}
|
| +} // namespace
|
|
|
| -// static
|
| -gfx::Rect Screen::GetPrimaryMonitorBounds() {
|
| - GdkScreen* screen = gdk_screen_get_default();
|
| - GdkRectangle rect;
|
| - gdk_screen_get_monitor_geometry(screen, 0, &rect);
|
| - return gfx::Rect(rect);
|
| -}
|
| +namespace gfx {
|
|
|
| // static
|
| -gfx::Rect Screen::GetMonitorWorkAreaMatching(const gfx::Rect& match_rect) {
|
| - // TODO(thestig) Implement multi-monitor support.
|
| - return GetPrimaryMonitorWorkArea();
|
| +gfx::Point Screen::GetCursorScreenPoint() {
|
| + gint x, y;
|
| + gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL);
|
| + return gfx::Point(x, y);
|
| }
|
|
|
| // static
|
| @@ -144,9 +98,53 @@ gfx::NativeWindow Screen::GetWindowAtCursorScreenPoint() {
|
| }
|
|
|
| // static
|
| -gfx::Size Screen::GetPrimaryMonitorSize() {
|
| +void Screen::GetMonitorNearestWindow(gfx::NativeView view,
|
| + gfx::Monitor* monitor_out) {
|
| + gfx::Rect bounds = GetMonitorAreaNearestWindow(view);
|
| + monitor_out->set_bounds(bounds);
|
| + // Do not use the _NET_WORKAREA here, this is supposed to be an area on a
|
| + // specific monitor, and _NET_WORKAREA is a hint from the WM that generally
|
| + // spans across all monitors. This would make the work area larger than the
|
| + // monitor.
|
| + // TODO(danakj) This is a work-around as there is no standard way to get this
|
| + // area, but it is a rect that we should be computing. The standard means
|
| + // to compute this rect would be to watch all windows with
|
| + // _NET_WM_STRUT(_PARTIAL) hints, and subtract their space from the physical
|
| + // area of the monitor to construct a work area.
|
| + monitor_out->set_work_area(bounds);
|
| +}
|
| +
|
| +// static
|
| +void Screen::GetMonitorNearestPoint(const gfx::Point& point,
|
| + gfx::Monitor* monitor_out) {
|
| GdkScreen* screen = gdk_screen_get_default();
|
| - return gfx::Size(gdk_screen_get_width(screen), gdk_screen_get_height(screen));
|
| + gint monitor = gdk_screen_get_monitor_at_point(screen, point.x(), point.y());
|
| + GdkRectangle bounds;
|
| + gdk_screen_get_monitor_geometry(screen, monitor, &bounds);
|
| +
|
| + monitor_out->set_bounds(gfx::Rect(bounds));
|
| + // TODO(jamiewalch): Restrict this to the work area of the monitor.
|
| + monitor_out->set_work_area(gfx::Rect(bounds));
|
| +}
|
| +
|
| +// static
|
| +void Screen::GetPrimaryMonitor(gfx::Monitor* monitor_out) {
|
| + gfx::Rect bounds = NativePrimaryMonitorBounds();
|
| + monitor_out->set_bounds(bounds);
|
| + gfx::Rect rect;
|
| + if (GetScreenWorkArea(&rect)) {
|
| + monitor_out->set_work_area(rect.Intersect(bounds));
|
| + } else {
|
| + // Return the best we've got.
|
| + monitor_out->set_work_area(bounds);
|
| + }
|
| +}
|
| +
|
| +// static
|
| +void Screen::GetMonitorMatching(const gfx::Rect& match_rect,
|
| + gfx::Monitor* monitor_out) {
|
| + // TODO(thestig) Implement multi-monitor support.
|
| + GetPrimaryMonitor(monitor_out);
|
| }
|
|
|
| // static
|
|
|