Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Unified Diff: ui/base/x/x11_util.cc

Issue 591213004: Improve check for whether _NET_ACTIVE_WINDOW is supported (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/x11_desktop_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/x/x11_util.cc
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 9f56c2c4ae52aac907e688d4b9131fba4eff60ab..8a27fd5fdeb465be48d8c1ccc704aedd0a78e880 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -102,8 +102,46 @@ bool GetProperty(XID window, const std::string& property_name, long max_length,
property);
}
+bool SupportsEWMH() {
+ static bool supports_ewmh = false;
+ static bool supports_ewmh_cached = false;
Daniel Erat 2014/09/23 15:32:41 i was going to say that i'm not sure how i feel ab
+ if (!supports_ewmh_cached) {
+ supports_ewmh_cached = true;
+
+ int wm_window = 0u;
+ if (!GetIntProperty(GetX11RootWindow(),
+ "_NET_SUPPORTING_WM_CHECK",
+ &wm_window)) {
+ supports_ewmh = false;
+ return false;
+ }
+
+ // 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.
+ gfx::X11ErrorTracker err_tracker;
+ int wm_window_property = 0;
+ bool result = GetIntProperty(
+ wm_window, "_NET_SUPPORTING_WM_CHECK", &wm_window_property);
+ supports_ewmh = !err_tracker.FoundNewError() &&
+ result &&
+ wm_window_property == wm_window;
+ }
+
+ return supports_ewmh;
+}
+
bool GetWindowManagerName(std::string* wm_name) {
DCHECK(wm_name);
+ if (!SupportsEWMH())
+ return false;
+
int wm_window = 0;
if (!GetIntProperty(GetX11RootWindow(),
"_NET_SUPPORTING_WM_CHECK",
@@ -111,25 +149,8 @@ bool GetWindowManagerName(std::string* wm_name) {
return false;
}
- // 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.
gfx::X11ErrorTracker err_tracker;
- int wm_window_property = 0;
- bool result = GetIntProperty(
- wm_window, "_NET_SUPPORTING_WM_CHECK", &wm_window_property);
- if (err_tracker.FoundNewError() || !result ||
- wm_window_property != wm_window) {
- return false;
- }
-
- result = GetStringProperty(
+ bool result = GetStringProperty(
static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name);
return !err_tracker.FoundNewError() && result;
}
@@ -1278,6 +1299,9 @@ bool IsX11WindowFullScreen(XID window) {
}
bool WmSupportsHint(XAtom atom) {
+ if (!SupportsEWMH())
+ return false;
+
std::vector<XAtom> supported_atoms;
if (!GetAtomArrayProperty(GetX11RootWindow(),
"_NET_SUPPORTED",
« no previous file with comments | « no previous file | ui/views/widget/desktop_aura/x11_desktop_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698