Index: ui/base/x/x11_util.cc |
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc |
index 108ae30655849b3789699e5b763e01fd79888ef6..6daf1686c5cdc84da9b43e5e7954c3e0b30d1025 100644 |
--- a/ui/base/x/x11_util.cc |
+++ b/ui/base/x/x11_util.cc |
@@ -102,6 +102,38 @@ bool GetProperty(XID window, const std::string& property_name, long max_length, |
property); |
} |
+bool GetWindowManagerName(std::string* wm_name) { |
+ DCHECK(wm_name); |
+ int wm_window = 0; |
+ if (!GetIntProperty(GetX11RootWindow(), |
+ "_NET_SUPPORTING_WM_CHECK", |
+ &wm_window)) { |
+ 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( |
+ static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name); |
+ return !err_tracker.FoundNewError() && result; |
+} |
+ |
// A process wide singleton that manages the usage of X cursors. |
class XCursorCache { |
public: |
@@ -1155,38 +1187,6 @@ bool CopyAreaToCanvas(XID drawable, |
return true; |
} |
-bool GetWindowManagerName(std::string* wm_name) { |
- DCHECK(wm_name); |
- int wm_window = 0; |
- if (!GetIntProperty(GetX11RootWindow(), |
- "_NET_SUPPORTING_WM_CHECK", |
- &wm_window)) { |
- 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( |
- static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name); |
- return !err_tracker.FoundNewError() && result; |
-} |
- |
WindowManagerName GuessWindowManager() { |
std::string name; |
if (GetWindowManagerName(&name)) { |
@@ -1219,6 +1219,13 @@ WindowManagerName GuessWindowManager() { |
return WM_UNKNOWN; |
} |
+std::string GuessWindowManagerName() { |
+ std::string name; |
+ if (GetWindowManagerName(&name)) |
+ return name; |
+ return "Unknown"; |
+} |
+ |
void SetDefaultX11ErrorHandlers() { |
SetX11ErrorHandlers(NULL, NULL); |
} |