Commit 2e8962b0 authored by zmo's avatar zmo Committed by Commit bot

Add WindowManager to about:gpu page on Linux/X11

BUG=410560
TEST=about:gpu page
R=piman@chromium.org,davemoore@chromium.org,sadrul@chromium.org,derat@chromium.org

Review URL: https://codereview.chromium.org/540643002

Cr-Commit-Position: refs/heads/master@{#293322}
parent 5d7197f5
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
#include "ui/base/win/shell.h" #include "ui/base/win/shell.h"
#endif #endif
#if defined(OS_LINUX) && defined(USE_X11)
#include "ui/base/x/x11_util.h"
#endif
namespace content { namespace content {
namespace { namespace {
...@@ -161,6 +165,10 @@ base::DictionaryValue* GpuInfoAsDictionaryValue() { ...@@ -161,6 +165,10 @@ base::DictionaryValue* GpuInfoAsDictionaryValue() {
gpu_info.gl_ws_version)); gpu_info.gl_ws_version));
basic_info->Append(NewDescriptionValuePair("Window system binding extensions", basic_info->Append(NewDescriptionValuePair("Window system binding extensions",
gpu_info.gl_ws_extensions)); gpu_info.gl_ws_extensions));
#if defined(OS_LINUX) && defined(USE_X11)
basic_info->Append(NewDescriptionValuePair("Window manager",
ui::GuessWindowManagerName()));
#endif
std::string direct_rendering = gpu_info.direct_rendering ? "Yes" : "No"; std::string direct_rendering = gpu_info.direct_rendering ? "Yes" : "No";
basic_info->Append( basic_info->Append(
NewDescriptionValuePair("Direct rendering", direct_rendering)); NewDescriptionValuePair("Direct rendering", direct_rendering));
......
...@@ -102,6 +102,38 @@ bool GetProperty(XID window, const std::string& property_name, long max_length, ...@@ -102,6 +102,38 @@ bool GetProperty(XID window, const std::string& property_name, long max_length,
property); 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. // A process wide singleton that manages the usage of X cursors.
class XCursorCache { class XCursorCache {
public: public:
...@@ -1155,38 +1187,6 @@ bool CopyAreaToCanvas(XID drawable, ...@@ -1155,38 +1187,6 @@ bool CopyAreaToCanvas(XID drawable,
return true; 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() { WindowManagerName GuessWindowManager() {
std::string name; std::string name;
if (GetWindowManagerName(&name)) { if (GetWindowManagerName(&name)) {
...@@ -1219,6 +1219,13 @@ WindowManagerName GuessWindowManager() { ...@@ -1219,6 +1219,13 @@ WindowManagerName GuessWindowManager() {
return WM_UNKNOWN; return WM_UNKNOWN;
} }
std::string GuessWindowManagerName() {
std::string name;
if (GetWindowManagerName(&name))
return name;
return "Unknown";
}
void SetDefaultX11ErrorHandlers() { void SetDefaultX11ErrorHandlers() {
SetX11ErrorHandlers(NULL, NULL); SetX11ErrorHandlers(NULL, NULL);
} }
......
...@@ -262,6 +262,10 @@ enum WindowManagerName { ...@@ -262,6 +262,10 @@ enum WindowManagerName {
// determine it for one reason or another. // determine it for one reason or another.
UI_BASE_EXPORT WindowManagerName GuessWindowManager(); UI_BASE_EXPORT WindowManagerName GuessWindowManager();
// The same as GuessWindowManager(), but returns the raw string. If we
// can't determine it, return "Unknown".
UI_BASE_EXPORT std::string GuessWindowManagerName();
// Enable the default X error handlers. These will log the error and abort // Enable the default X error handlers. These will log the error and abort
// the process if called. Use SetX11ErrorHandlers() from x11_util_internal.h // the process if called. Use SetX11ErrorHandlers() from x11_util_internal.h
// to set your own error handlers. // to set your own error handlers.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment