diff options
author | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-10 19:30:58 +0000 |
---|---|---|
committer | dcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-10 19:30:58 +0000 |
commit | ca595c8f7a5213fc146ef578f5e49f9316d0ee90 (patch) | |
tree | 12358febef35da74ba1f8428082e3463657fb62b /ui/base/x | |
parent | 9cf12c316c486bccd4680a2366f00707917771d8 (diff) | |
download | chromium_src-ca595c8f7a5213fc146ef578f5e49f9316d0ee90.zip chromium_src-ca595c8f7a5213fc146ef578f5e49f9316d0ee90.tar.gz chromium_src-ca595c8f7a5213fc146ef578f5e49f9316d0ee90.tar.bz2 |
Create utility functions for helping determine the X window manager.
Since a couple places check for the current window manager, consolidate the
logic into utility functions so it's checked consistently. Also re-enables
Panel on Mutter, GNOME 3's window manager.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8508023
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109477 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/x')
-rw-r--r-- | ui/base/x/x11_util.cc | 31 | ||||
-rw-r--r-- | ui/base/x/x11_util.h | 18 |
2 files changed, 46 insertions, 3 deletions
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index d901a72..dada148 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -19,8 +19,9 @@ #include "base/command_line.h" #include "base/logging.h" #include "base/message_loop.h" -#include "base/stringprintf.h" #include "base/string_number_conversions.h" +#include "base/string_util.h" +#include "base/stringprintf.h" #include "base/threading/thread.h" #include "ui/base/x/x11_util_internal.h" #include "ui/gfx/rect.h" @@ -711,6 +712,34 @@ bool GetWindowManagerName(std::string* wm_name) { return !got_error && result; } +WindowManagerName GuessWindowManager() { + std::string name; + if (GetWindowManagerName(&name)) { + // These names are taken from the WMs' source code. + if (name == "Compiz" || name == "compiz") + return WM_COMPIZ; + if (name == "KWin") + return WM_KWIN; + if (name == "Metacity") + return WM_METACITY; + if (name == "Mutter") + return WM_MUTTER; + if (name == "Xfwm4") + return WM_XFWM4; + if (name == "chromeos-wm") + return WM_CHROME_OS; + if (name == "Blackbox") + return WM_BLACKBOX; + if (name == "e16") + return WM_ENLIGHTENMENT; + if (StartsWithASCII(name, "IceWM", true)) + return WM_ICE_WM; + if (name == "Openbox") + return WM_OPENBOX; + } + return WM_UNKNOWN; +} + bool ChangeWindowDesktop(XID window, XID destination) { int desktop; if (!GetWindowDesktop(destination, &desktop)) diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index 519e235..f9e979c 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -178,8 +178,22 @@ UI_EXPORT void PutARGBImage(Display* display, void* visual, int depth, void FreePicture(Display* display, XID picture); void FreePixmap(Display* display, XID pixmap); -// Get the window manager name. -UI_EXPORT bool GetWindowManagerName(std::string* name); +enum WindowManagerName { + WM_UNKNOWN, + WM_BLACKBOX, + WM_CHROME_OS, + WM_COMPIZ, + WM_ENLIGHTENMENT, + WM_ICE_WM, + WM_KWIN, + WM_METACITY, + WM_MUTTER, + WM_OPENBOX, + WM_XFWM4, +}; +// Attempts to guess the window maager. Returns WM_UNKNOWN if we can't +// determine it for one reason or another. +UI_EXPORT WindowManagerName GuessWindowManager(); // Change desktop for |window| to the desktop of |destination| window. UI_EXPORT bool ChangeWindowDesktop(XID window, XID destination); |