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

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

Issue 1949393007: X11: Better timestamp handling for _NET_ACTIVE_WINDOW (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: C++ style casts and remove dummy_data_ Created 4 years, 7 months 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
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 5ab84f9928e6d0f6305ee1642d3c4bf18c9bdfb5..8ec4b1e7b9aceada7c3a5562ee9c3b3fd966acb5 100644
--- a/ui/views/widget/desktop_aura/x11_desktop_handler.cc
+++ b/ui/views/widget/desktop_aura/x11_desktop_handler.cc
@@ -43,7 +43,7 @@ X11DesktopHandler::X11DesktopHandler()
: xdisplay_(gfx::GetXDisplay()),
x_root_window_(DefaultRootWindow(xdisplay_)),
x_active_window_(None),
- wm_user_time_ms_(0),
+ wm_user_time_ms_(CurrentTime),
current_window_(None),
current_window_active_state_(NOT_ACTIVE),
atom_cache_(xdisplay_, kAtomsToCache),
@@ -91,6 +91,10 @@ void X11DesktopHandler::ActivateWindow(::Window window) {
// If the window is not already active, send a hint to activate it
if (x_active_window_ != window) {
+ if (wm_user_time_ms_ == CurrentTime) {
+ set_wm_user_time_ms(
+ ui::X11EventSource::GetInstance()->UpdateLastSeenServerTime());
+ }
XEvent xclient;
memset(&xclient, 0, sizeof(xclient));
xclient.type = ClientMessage;
@@ -120,6 +124,18 @@ void X11DesktopHandler::ActivateWindow(::Window window) {
}
}
+void X11DesktopHandler::set_wm_user_time_ms(Time time_ms) {
+ if (time_ms != CurrentTime) {
+ int64_t event_time_64 = time_ms;
+ int64_t time_difference = wm_user_time_ms_ - event_time_64;
+ // Ignore timestamps that go backwards. However, X server time is a 32-bit
+ // millisecond counter, so if the time goes backwards by more than half the
+ // range of the 32-bit counter, treat it as a rollover.
+ if (time_difference < 0 || time_difference > (UINT32_MAX >> 1))
+ wm_user_time_ms_ = time_ms;
+ }
+}
+
void X11DesktopHandler::DeactivateWindow(::Window window) {
if (!IsActiveWindow(window))
return;

Powered by Google App Engine
This is Rietveld 408576698