summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-14 22:46:14 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-14 22:46:14 +0000
commita3049c9c454f9f8dccdcc2a8f72da50541ace0ee (patch)
tree076d38cdfbb0670d3a503d2ab7b5a025916da3c4
parent7a7c16784f23f3edd92e6504b39ed4b92b3f9ea2 (diff)
downloadchromium_src-a3049c9c454f9f8dccdcc2a8f72da50541ace0ee.zip
chromium_src-a3049c9c454f9f8dccdcc2a8f72da50541ace0ee.tar.gz
chromium_src-a3049c9c454f9f8dccdcc2a8f72da50541ace0ee.tar.bz2
linux aura: Fix window activation in some X11 window managers.
Some X11 window managers do not support extended window manager hints (EWMH) like _NET_ACTIVE_WINDOW. In such cases, instead of trying to set the _NET_ACTIVE_WINDOW atom on the X11 RootWindow, use XRaiseWindow() to activate a window. BUG=317856 R=erg@chromium.org Review URL: https://codereview.chromium.org/68063003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235245 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/widget/desktop_aura/x11_desktop_handler.cc58
-rw-r--r--ui/views/widget/desktop_aura/x11_desktop_handler.h2
2 files changed, 42 insertions, 18 deletions
diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.cc b/ui/views/widget/desktop_aura/x11_desktop_handler.cc
index 1a91833..2eeb0db 100644
--- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc
+++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc
@@ -4,6 +4,9 @@
#include "ui/views/widget/desktop_aura/x11_desktop_handler.h"
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+
#include "base/message_loop/message_loop.h"
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
@@ -18,6 +21,7 @@ namespace {
const char* kAtomsToCache[] = {
"_NET_ACTIVE_WINDOW",
+ "_NET_SUPPORTED",
NULL
};
@@ -40,7 +44,8 @@ X11DesktopHandler::X11DesktopHandler()
: xdisplay_(gfx::GetXDisplay()),
x_root_window_(DefaultRootWindow(xdisplay_)),
current_window_(None),
- atom_cache_(xdisplay_, kAtomsToCache) {
+ atom_cache_(xdisplay_, kAtomsToCache),
+ wm_supports_active_window_(false) {
base::MessagePumpX11::Current()->AddDispatcherForRootWindow(this);
aura::Env::GetInstance()->AddObserver(this);
@@ -49,6 +54,18 @@ X11DesktopHandler::X11DesktopHandler()
XSelectInput(xdisplay_, x_root_window_,
attr.your_event_mask | PropertyChangeMask |
StructureNotifyMask | SubstructureNotifyMask);
+
+ std::vector<Atom> atoms;
+ if (ui::GetAtomArrayProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &atoms)) {
+ Atom active_window = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW");
+ for (std::vector<Atom>::iterator iter = atoms.begin(); iter != atoms.end();
+ ++iter) {
+ if (*(iter) == active_window) {
+ wm_supports_active_window_ = true;
+ break;
+ }
+ }
+ }
}
X11DesktopHandler::~X11DesktopHandler() {
@@ -57,23 +74,28 @@ X11DesktopHandler::~X11DesktopHandler() {
}
void X11DesktopHandler::ActivateWindow(::Window window) {
- DCHECK_EQ(gfx::GetXDisplay(), xdisplay_);
-
- XEvent xclient;
- memset(&xclient, 0, sizeof(xclient));
- xclient.type = ClientMessage;
- xclient.xclient.window = window;
- xclient.xclient.message_type = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW");
- xclient.xclient.format = 32;
- xclient.xclient.data.l[0] = 1; // Specified we are an app.
- xclient.xclient.data.l[1] = CurrentTime;
- xclient.xclient.data.l[2] = None;
- xclient.xclient.data.l[3] = 0;
- xclient.xclient.data.l[4] = 0;
-
- XSendEvent(xdisplay_, x_root_window_, False,
- SubstructureRedirectMask | SubstructureNotifyMask,
- &xclient);
+ if (wm_supports_active_window_) {
+ DCHECK_EQ(gfx::GetXDisplay(), xdisplay_);
+
+ XEvent xclient;
+ memset(&xclient, 0, sizeof(xclient));
+ xclient.type = ClientMessage;
+ xclient.xclient.window = window;
+ xclient.xclient.message_type = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW");
+ xclient.xclient.format = 32;
+ xclient.xclient.data.l[0] = 1; // Specified we are an app.
+ xclient.xclient.data.l[1] = CurrentTime;
+ xclient.xclient.data.l[2] = None;
+ xclient.xclient.data.l[3] = 0;
+ xclient.xclient.data.l[4] = 0;
+
+ XSendEvent(xdisplay_, x_root_window_, False,
+ SubstructureRedirectMask | SubstructureNotifyMask,
+ &xclient);
+ } else {
+ XRaiseWindow(xdisplay_, window);
+ OnActiveWindowChanged(window);
+ }
}
bool X11DesktopHandler::IsActiveWindow(::Window window) const {
diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.h b/ui/views/widget/desktop_aura/x11_desktop_handler.h
index ed12ec4..3399b40 100644
--- a/ui/views/widget/desktop_aura/x11_desktop_handler.h
+++ b/ui/views/widget/desktop_aura/x11_desktop_handler.h
@@ -64,6 +64,8 @@ class VIEWS_EXPORT X11DesktopHandler : public base::MessageLoop::Dispatcher,
ui::X11AtomCache atom_cache_;
+ bool wm_supports_active_window_;
+
DISALLOW_COPY_AND_ASSIGN(X11DesktopHandler);
};