summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--ui/views/widget/desktop_aura/x11_desktop_handler.cc43
-rw-r--r--ui/views/widget/desktop_aura/x11_desktop_handler.h3
3 files changed, 32 insertions, 15 deletions
diff --git a/AUTHORS b/AUTHORS
index 6d9d1fa..cbe7fe3 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -118,6 +118,7 @@ Craig Schlenter <craig.schlenter@gmail.com>
Daegyu Lee <na7jun8gi@gmail.com>
Dai Chunyang <chunyang.dai@intel.com>
Daiwei Li <daiweili@suitabletech.com>
+Dan McCombs <overridex@gmail.com>
Daniel Bomar <dbdaniel42@gmail.com>
Daniel Carvalho Liedke <dliedke@gmail.com>
Daniel Imms <daniimms@amazon.com>
diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.cc b/ui/views/widget/desktop_aura/x11_desktop_handler.cc
index 70aa47d..5ab84f9 100644
--- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc
+++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc
@@ -42,6 +42,7 @@ X11DesktopHandler* X11DesktopHandler::get() {
X11DesktopHandler::X11DesktopHandler()
: xdisplay_(gfx::GetXDisplay()),
x_root_window_(DefaultRootWindow(xdisplay_)),
+ x_active_window_(None),
wm_user_time_ms_(0),
current_window_(None),
current_window_active_state_(NOT_ACTIVE),
@@ -88,21 +89,26 @@ void X11DesktopHandler::ActivateWindow(::Window window) {
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] = wm_user_time_ms_;
- 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 the window is not already active, send a hint to activate it
+ if (x_active_window_ != window) {
+ 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] = wm_user_time_ms_;
+ 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 {
+ OnActiveWindowChanged(window, ACTIVE);
+ }
} else {
XRaiseWindow(xdisplay_, window);
// Directly ask the X server to give focus to the window. Note
@@ -169,7 +175,10 @@ uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) {
::Window window;
if (ui::GetXIDProperty(x_root_window_, "_NET_ACTIVE_WINDOW", &window) &&
window) {
+ x_active_window_ = window;
OnActiveWindowChanged(window, ACTIVE);
+ } else {
+ x_active_window_ = None;
}
}
break;
@@ -180,6 +189,10 @@ uint32_t X11DesktopHandler::DispatchEvent(const ui::PlatformEvent& event) {
break;
case DestroyNotify:
OnWindowCreatedOrDestroyed(event->type, event->xdestroywindow.window);
+ // If the current active window is being destroyed, reset our tracker.
+ if (x_active_window_ == event->xdestroywindow.window) {
+ x_active_window_ = None;
+ }
break;
default:
NOTREACHED();
diff --git a/ui/views/widget/desktop_aura/x11_desktop_handler.h b/ui/views/widget/desktop_aura/x11_desktop_handler.h
index c704bba..f0acc70 100644
--- a/ui/views/widget/desktop_aura/x11_desktop_handler.h
+++ b/ui/views/widget/desktop_aura/x11_desktop_handler.h
@@ -86,6 +86,9 @@ class VIEWS_EXPORT X11DesktopHandler : public ui::PlatformEventDispatcher,
// The native root window.
::Window x_root_window_;
+ // The last known active X window
+ ::Window x_active_window_;
+
// The X11 server time of the most recent mouse click, touch, or key press
// on a Chrome window.
unsigned long wm_user_time_ms_;