Bug 1432414 - Use gtk_get_current_event_time() instead of gdk_x11_display_get_user_time() on Wayland, r=jhorak
authorMartin Stransky <stransky@redhat.com>
Tue, 23 Jan 2018 11:01:11 +0100
changeset 400502 5dd3ea4c9f222c800bfcbb4a4a82d2785a597aa9
parent 400501 756a472ff5f180a583a55260fef974dc75d553dc
child 400503 21e2176ad2b1648521713fa88e5d53a3aead3787
push id58550
push userstransky@redhat.com
push dateWed, 24 Jan 2018 12:40:31 +0000
treeherderautoland@5dd3ea4c9f22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1432414
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1432414 - Use gtk_get_current_event_time() instead of gdk_x11_display_get_user_time() on Wayland, r=jhorak Emulate what gtk+/gtkwindow.c gtk_window_present_with_time() does - use gdk_x11_display_get_user_time() on X11 and gtk_get_current_event_time() on Wayland to get event timestamp. MozReview-Commit-ID: GEU6ZrQxq6v
widget/gtk/mozgtk/mozgtk.c
widget/gtk/nsWindow.cpp
--- a/widget/gtk/mozgtk/mozgtk.c
+++ b/widget/gtk/mozgtk/mozgtk.c
@@ -224,16 +224,17 @@ STUB(gtk_file_chooser_set_preview_widget
 STUB(gtk_file_chooser_set_preview_widget_active)
 STUB(gtk_file_chooser_set_select_multiple)
 STUB(gtk_file_chooser_widget_get_type)
 STUB(gtk_file_filter_add_pattern)
 STUB(gtk_file_filter_new)
 STUB(gtk_file_filter_set_name)
 STUB(gtk_fixed_new)
 STUB(gtk_frame_new)
+STUB(gtk_get_current_event_time)
 STUB(gtk_grab_add)
 STUB(gtk_grab_remove)
 STUB(gtk_handle_box_new)
 STUB(gtk_hbox_new)
 STUB(gtk_icon_info_free)
 STUB(gtk_icon_info_load_icon)
 STUB(gtk_icon_set_add_source)
 STUB(gtk_icon_set_new)
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -1358,23 +1358,27 @@ SetUserTimeAndStartupIDForActivatedWindo
     // we don't want to reuse the timestamp next time we raise the window
     GTKToolkit->SetFocusTimestamp(0);
     GTKToolkit->SetDesktopStartupID(EmptyCString());
 }
 
 /* static */ guint32
 nsWindow::GetLastUserInputTime()
 {
-    // gdk_x11_display_get_user_time tracks button and key presses,
-    // DESKTOP_STARTUP_ID used to start the app, drop events from external
-    // drags, WM_DELETE_WINDOW delete events, but not usually mouse motion nor
+    // gdk_x11_display_get_user_time/gtk_get_current_event_time tracks
+    // button and key presses, DESKTOP_STARTUP_ID used to start the app,
+    // drop events from external drags,
+    // WM_DELETE_WINDOW delete events, but not usually mouse motion nor
     // button and key releases.  Therefore use the most recent of
     // gdk_x11_display_get_user_time and the last time that we have seen.
-    guint32 timestamp =
-            gdk_x11_display_get_user_time(gdk_display_get_default());
+    GdkDisplay* gdkDisplay = gdk_display_get_default();
+    guint32 timestamp = GDK_IS_X11_DISPLAY(gdkDisplay) ?
+            gdk_x11_display_get_user_time(gdkDisplay) :
+            gtk_get_current_event_time();
+
     if (sLastUserInputTime != GDK_CURRENT_TIME &&
         TimestampIsNewerThan(sLastUserInputTime, timestamp)) {
         return sLastUserInputTime;
     }
 
     return timestamp;
 }