Chromium Code Reviews| 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..e29ce9c03c1d273d23c1fa2c31d6155eb045b1c5 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,28 @@ X11DesktopHandler::X11DesktopHandler() |
| XSelectInput(xdisplay_, x_root_window_, |
| attr.your_event_mask | PropertyChangeMask | |
| StructureNotifyMask | SubstructureNotifyMask); |
| + |
| + const int kMaxWMAtoms = 64; |
| + size_t atoms_count = 0; |
| + Atom* atoms = NULL; |
| + Atom type; |
| + int format; |
| + size_t bytes; |
| + XGetWindowProperty(xdisplay_, x_root_window_, |
| + atom_cache_.GetAtom("_NET_SUPPORTED"), |
| + 0, kMaxWMAtoms, |
| + False, XA_ATOM, |
| + &type, &format, &atoms_count, &bytes, |
| + reinterpret_cast<unsigned char**>(&atoms)); |
|
Elliot Glaysher
2013/11/14 18:37:38
ui::GetAtomArrayProperty()?
sadrul
2013/11/14 19:06:41
Done.
|
| + if (type == XA_ATOM) { |
| + Atom active_window = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); |
| + for (size_t i = 0; i < atoms_count; ++i) { |
| + if (atoms[i] == active_window) { |
| + wm_supports_active_window_ = true; |
| + break; |
| + } |
| + } |
| + } |
| } |
| X11DesktopHandler::~X11DesktopHandler() { |
| @@ -57,23 +84,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_); |
| + |
| + XClientMessageEvent xclient; |
|
Elliot Glaysher
2013/11/14 18:37:38
piman would disprove. He's told me several times t
sadrul
2013/11/14 19:06:41
Reverted (I hadn't meant to include this in the CL
|
| + memset(&xclient, 0, sizeof(xclient)); |
| + xclient.type = ClientMessage; |
| + xclient.window = window; |
| + xclient.message_type = atom_cache_.GetAtom("_NET_ACTIVE_WINDOW"); |
| + xclient.format = 32; |
| + xclient.data.l[0] = 1; // Specified we are an app. |
| + xclient.data.l[1] = CurrentTime; |
| + xclient.data.l[2] = None; |
| + xclient.data.l[3] = 0; |
| + xclient.data.l[4] = 0; |
| + |
| + XSendEvent(xdisplay_, x_root_window_, False, |
| + SubstructureRedirectMask | SubstructureNotifyMask, |
| + (XEvent*)&xclient); |
| + } else { |
| + XRaiseWindow(xdisplay_, window); |
| + OnActiveWindowChanged(window); |
| + } |
| } |
| bool X11DesktopHandler::IsActiveWindow(::Window window) const { |