diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 21:52:44 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-31 21:52:44 +0000 |
commit | fc7611b38ad901cc9babc4defc7214ca601883e2 (patch) | |
tree | 14e572b2aee6c487c13962b9386f8d629ca46590 /chrome/common/x11_util.cc | |
parent | 0170caac6453b9d0a946fea8e22d3e48a82119f1 (diff) | |
download | chromium_src-fc7611b38ad901cc9babc4defc7214ca601883e2.zip chromium_src-fc7611b38ad901cc9babc4defc7214ca601883e2.tar.gz chromium_src-fc7611b38ad901cc9babc4defc7214ca601883e2.tar.bz2 |
Linux: Autodetect whether the custom frame should be used.
Listing a bunch of strings from WMs' source sucks,
but I can't think of any way to detect tiling WMs that
don't support the EWMH (see the bug and the comment in
this CL), so this seems safer.
Tested with the following:
- wiped out related prefs and started chrome under ion3;
custom frame not used
- quit and started under metacity; custom frame *was* used
- toggled custom frame pref off and restarted under
metacity again; custom frame not used
- toggled it back on and restarted under ion3; custom frame
was used
BUG=15861
TEST=see above
Review URL: http://codereview.chromium.org/160374
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/x11_util.cc')
-rw-r--r-- | chrome/common/x11_util.cc | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc index 5e8efd8..3af0115 100644 --- a/chrome/common/x11_util.cc +++ b/chrome/common/x11_util.cc @@ -163,6 +163,75 @@ bool GetWindowRect(XID window, gfx::Rect* rect) { return true; } +bool GetIntProperty(XID window, const std::string& property_name, int* value) { + Atom property_atom = gdk_x11_get_xatom_by_name_for_display( + gdk_display_get_default(), property_name.c_str()); + + Atom type = None; + int format = 0; // size in bits of each item in 'property' + long unsigned int num_items = 0, remaining_bytes = 0; + unsigned char* property = NULL; + + int result = XGetWindowProperty(GetXDisplay(), + window, + property_atom, + 0, // offset into property data to read + 1, // max length to get + False, // deleted + AnyPropertyType, + &type, + &format, + &num_items, + &remaining_bytes, + &property); + if (result != Success) + return false; + + if (format != 32 || num_items != 1) { + XFree(property); + return false; + } + + *value = *(reinterpret_cast<int*>(property)); + XFree(property); + return true; +} + +bool GetStringProperty( + XID window, const std::string& property_name, std::string* value) { + Atom property_atom = gdk_x11_get_xatom_by_name_for_display( + gdk_display_get_default(), property_name.c_str()); + + Atom type = None; + int format = 0; // size in bits of each item in 'property' + long unsigned int num_items = 0, remaining_bytes = 0; + unsigned char* property = NULL; + + int result = XGetWindowProperty(GetXDisplay(), + window, + property_atom, + 0, // offset into property data to read + 1024, // max length to get + False, // deleted + AnyPropertyType, + &type, + &format, + &num_items, + &remaining_bytes, + &property); + if (result != Success) + return false; + + if (format != 8) { + XFree(property); + return false; + } + + value->assign(reinterpret_cast<char*>(property), num_items); + XFree(property); + return true; +} + // Returns true if |window| is a named window. bool IsWindowNamed(XID window) { XTextProperty prop; |