diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-02 18:23:34 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-02 18:23:34 +0000 |
commit | 528a17d27e2c8b76c07f192b7f97262478c48629 (patch) | |
tree | c2e7b2a9f9e03f28a86d7d8f7cd3c69407f4a4da /chrome/common/x11_util.cc | |
parent | 1811062fc4c0aa1e16024e90512644b597ba7199 (diff) | |
download | chromium_src-528a17d27e2c8b76c07f192b7f97262478c48629.zip chromium_src-528a17d27e2c8b76c07f192b7f97262478c48629.tar.gz chromium_src-528a17d27e2c8b76c07f192b7f97262478c48629.tar.bz2 |
gtk: Handle stale _NET_SUPPORTING_WM_CHECK properties.
We'd crash at startup if a window manager that supports
EWMH had been replaced during the current X session by
one that didn't, leaving behind a property on the root
window referring to an old window.
BUG=23860
TEST=checked that the old code crashes at startup and the new code doesn't after replacing openbox with xmonad
Review URL: http://codereview.chromium.org/568002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/x11_util.cc')
-rw-r--r-- | chrome/common/x11_util.cc | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc index 0b29716..12c9c6c 100644 --- a/chrome/common/x11_util.cc +++ b/chrome/common/x11_util.cc @@ -557,12 +557,31 @@ bool GetWindowManagerName(std::string* wm_name) { &wm_window)) { return false; } - if (!x11_util::GetStringProperty(static_cast<XID>(wm_window), - "_NET_WM_NAME", - wm_name)) { + + // It's possible that a window manager started earlier in this X session left + // a stale _NET_SUPPORTING_WM_CHECK property when it was replaced by a + // non-EWMH window manager, so we trap errors in the following requests to + // avoid crashes (issue 23860). + + // EWMH requires the supporting-WM window to also have a + // _NET_SUPPORTING_WM_CHECK property pointing to itself (to avoid a stale + // property referencing an ID that's been recycled for another window), so we + // check that too. + gdk_error_trap_push(); + int wm_window_property = 0; + bool result = x11_util::GetIntProperty( + wm_window, "_NET_SUPPORTING_WM_CHECK", &wm_window_property); + gdk_flush(); + bool got_error = gdk_error_trap_pop(); + if (got_error || !result || wm_window_property != wm_window) return false; - } - return true; + + gdk_error_trap_push(); + result = x11_util::GetStringProperty( + static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name); + gdk_flush(); + got_error = gdk_error_trap_pop(); + return !got_error && result; } static cairo_status_t SnapshotCallback( |