Chromium Code Reviews| Index: ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc |
| diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc |
| index d87f9164438b8230b64f3679914046d44368b3cc..0ec85351dcd6a9fc75e28d8688405fa25c270325 100644 |
| --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc |
| +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc |
| @@ -1192,6 +1192,29 @@ void DesktopWindowTreeHostX11::OnFrameExtentsUpdated() { |
| } |
| } |
| +void DesktopWindowTreeHostX11::UpdateWMUserTime( |
| + const ui::PlatformEvent& event) { |
| + if (!IsActive()) |
| + return; |
| + |
| + ui::EventType type = ui::EventTypeFromNative(event); |
| + if (type == ui::ET_MOUSE_PRESSED || |
| + type == ui::ET_KEY_PRESSED || |
| + type == ui::ET_TOUCH_PRESSED) { |
|
Elliot Glaysher
2014/06/05 20:46:33
I'm pretty sure you want the released versions of
|
| + unsigned long wm_user_time_ms = static_cast<unsigned long>( |
| + ui::EventTimeFromNative(event).InMilliseconds()); |
| + XChangeProperty(xdisplay_, |
| + xwindow_, |
| + atom_cache_.GetAtom("_NET_WM_USER_TIME"), |
| + XA_CARDINAL, |
| + 32, |
| + PropModeReplace, |
| + reinterpret_cast<const unsigned char *>(&wm_user_time_ms), |
| + 1); |
| + X11DesktopHandler::get()->set_wm_user_time_ms(wm_user_time_ms); |
| + } |
| +} |
| + |
| void DesktopWindowTreeHostX11::SetWMSpecState(bool enabled, |
| ::Atom state1, |
| ::Atom state2) { |
| @@ -1405,22 +1428,17 @@ void DesktopWindowTreeHostX11::MapWindow(ui::WindowShowState show_state) { |
| // If SHOW_STATE_INACTIVE, tell the window manager not to focus the window |
| // when mapping. This is done by setting the _NET_WM_USER_TIME to 0. See e.g. |
| // http://standards.freedesktop.org/wm-spec/latest/ar01s05.html |
| - if (show_state == ui::SHOW_STATE_INACTIVE) { |
| - unsigned long value = 0; |
| + unsigned long wm_user_time_ms = (show_state == ui::SHOW_STATE_INACTIVE) ? |
| + 0 : X11DesktopHandler::get()->wm_user_time_ms(); |
| + if (show_state == ui::SHOW_STATE_INACTIVE || wm_user_time_ms != 0) { |
| XChangeProperty(xdisplay_, |
| xwindow_, |
| atom_cache_.GetAtom("_NET_WM_USER_TIME"), |
| XA_CARDINAL, |
| 32, |
| PropModeReplace, |
| - reinterpret_cast<const unsigned char *>(&value), |
| + reinterpret_cast<const unsigned char *>(&wm_user_time_ms), |
| 1); |
| - } else { |
| - // TODO(piman): if this window was created in response to an X event, we |
| - // should set the time to the server time of the event that caused this. |
| - // https://crbug.com/355667 |
| - XDeleteProperty( |
| - xdisplay_, xwindow_, atom_cache_.GetAtom("_NET_WM_USER_TIME")); |
| } |
| XMapWindow(xdisplay_, xwindow_); |
| @@ -1456,6 +1474,8 @@ uint32_t DesktopWindowTreeHostX11::DispatchEvent( |
| TRACE_EVENT1("views", "DesktopWindowTreeHostX11::Dispatch", |
| "event->type", event->type); |
| + UpdateWMUserTime(event); |
| + |
| // May want to factor CheckXEventForConsistency(xev); into a common location |
| // since it is called here. |
| switch (xev->type) { |