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

Unified Diff: ui/views/widget/desktop_aura/x11_desktop_handler.cc

Issue 68063003: linux aura: Fix window activation in some X11 window managers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 1 month 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 | « ui/views/widget/desktop_aura/x11_desktop_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/desktop_aura/x11_desktop_handler.cc
diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.cc b/ui/views/widget/desktop_aura/x11_desktop_handler.cc
index 179bc759a171c2f4c0cf5cd0b0e9bf1062286be9..9340237a659b663670f16def223fde1fe8e12b45 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 {
« no previous file with comments | « ui/views/widget/desktop_aura/x11_desktop_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698