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 33b6347958efd04a654db25e6edc6ef636047394..b772d24b3b604c01cfdc79ffc28ce1a2c97a4c54 100644 |
--- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc |
+++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc |
@@ -74,7 +74,8 @@ X11DesktopHandler::~X11DesktopHandler() { |
ui::PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); |
} |
-void X11DesktopHandler::ActivateWindow(::Window window) { |
+void X11DesktopHandler::ActivateWindow(::Window window, |
+ bool for_user_gesture) { |
if ((current_window_ == None || current_window_ == window) && |
current_window_active_state_ == NOT_ACTIVE) { |
// |window| is most likely still active wrt to the X server. Undo the |
@@ -91,13 +92,29 @@ void X11DesktopHandler::ActivateWindow(::Window window) { |
if (wm_supports_active_window_) { |
DCHECK_EQ(gfx::GetXDisplay(), xdisplay_); |
+ // According to |
+ // http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#sourceindication |
+ // "Some requests from Clients include type of the Client, for example the |
+ // _NET_ACTIVE_WINDOW message. Currently the types can be 1 for normal |
+ // applications, and 2 for pagers and other Clients that represent direct |
+ // user actions (the Window Manager may decide to treat requests from |
+ // applications differently than requests that are result of direct user |
+ // actions)." |
+ // |
+ // Normally we set the source indication to 1 (normal application), but when |
+ // we know activation is being triggered from a user gesture, then we set it |
+ // to 2 so the WM properly prioritizes our request. Without this, Unity on |
+ // Ubuntu 14.04 ignores requests to activate a window unless some other |
+ // Chrome window is already the active window (see issues 470830 & 411702). |
+ long source_indication = for_user_gesture ? 2 : 1; |
+ |
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[0] = source_indication; |
xclient.xclient.data.l[1] = wm_user_time_ms_; |
xclient.xclient.data.l[2] = None; |
xclient.xclient.data.l[3] = 0; |