diff options
author | cmasone@google.com <cmasone@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 17:09:18 +0000 |
---|---|---|
committer | cmasone@google.com <cmasone@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-09 17:09:18 +0000 |
commit | e5307cef6dcdc2ab5d4445cd57938dbf4d5e30c3 (patch) | |
tree | 5ee05f387a75d856d29895f06f0c64156754c9ff /views/screen_gtk.cc | |
parent | e8f962fba800ac454b98fcfb5b44f4b34c62fd53 (diff) | |
download | chromium_src-e5307cef6dcdc2ab5d4445cd57938dbf4d5e30c3.zip chromium_src-e5307cef6dcdc2ab5d4445cd57938dbf4d5e30c3.tar.gz chromium_src-e5307cef6dcdc2ab5d4445cd57938dbf4d5e30c3.tar.bz2 |
Uses X mechanisms to get the screen size in the event that there's no window manager to query.
Review URL: http://codereview.chromium.org/460134
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34159 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/screen_gtk.cc')
-rw-r--r-- | views/screen_gtk.cc | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/views/screen_gtk.cc b/views/screen_gtk.cc index a0daa19..93518b4 100644 --- a/views/screen_gtk.cc +++ b/views/screen_gtk.cc @@ -4,6 +4,7 @@ #include "views/screen.h" +#include <gdk/gdkx.h> #include <gtk/gtk.h> #include "base/logging.h" @@ -25,9 +26,33 @@ gfx::Rect static GetPrimaryMonitorBounds() { gdk_atom_intern("CARDINAL", FALSE), 0, 0xFF, false, NULL, NULL, &data_len, &raw_data); + int top_left_x = 0; + int top_left_y = 0; + int width = 0; + int height = 0; + + if (success) { + glong* data = reinterpret_cast<glong*>(raw_data); + top_left_x = data[0]; + top_left_y = data[1]; + width = data[2]; + height = data[3]; + } else { + // If there's no window manager, we can ask X for Monitor info directly. + XWindowAttributes attributes; + Status status = XGetWindowAttributes(gdk_x11_get_default_xdisplay(), + gdk_x11_get_default_root_xwindow(), + &attributes); + if (status) { + top_left_x = attributes.x; + top_left_y = attributes.y; + width = attributes.width; + height = attributes.height; + success = true; + } + } DCHECK(success); - glong* data = reinterpret_cast<glong*>(raw_data); - return gfx::Rect(data[0], data[1], data[0] + data[2], data[1] + data[3]); + return gfx::Rect(top_left_x, top_left_y, width, height); } // static |