[gnome-shell/wip/wayland: 375/376] "Fix" X11 timestamp brokenness



commit 7531da80c1bab70a14e5897edf79f0f3a88828c6
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Fri Aug 16 11:54:23 2013 +0200

    "Fix" X11 timestamp brokenness
    
    When running as a wayland compositor, X11 times and clutter times
    cannot be compared, so make sure we only use X11 times from
    MetaDisplay, until all mutter code is converted to use the
    monotonic clock (ditching both clutter times and X11 times)

 js/ui/dnd.js                |   12 ++++++------
 js/ui/panel.js              |    2 +-
 js/ui/switcherPopup.js      |    2 +-
 js/ui/workspaceThumbnail.js |    4 ++--
 src/shell-global.c          |   10 +++++++++-
 5 files changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 411a1d6..ddbb10d 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -193,7 +193,7 @@ const _Draggable = new Lang.Class({
         } else if (event.type() == Clutter.EventType.KEY_PRESS && this._dragInProgress) {
             let symbol = event.get_key_symbol();
             if (symbol == Clutter.Escape) {
-                this._cancelDrag(event.get_time());
+                this._cancelDrag(global.get_current_time());
                 return true;
             }
         } else if (event.type() == Clutter.EventType.LEAVE) {
@@ -352,7 +352,7 @@ const _Draggable = new Lang.Class({
         let threshold = Gtk.Settings.get_default().gtk_dnd_drag_threshold;
         if ((Math.abs(stageX - this._dragStartX) > threshold ||
              Math.abs(stageY - this._dragStartY) > threshold)) {
-                this.startDrag(stageX, stageY, event.get_time());
+                this.startDrag(stageX, stageY, global.get_current_time());
                 this._updateDragPosition(event);
         }
 
@@ -458,12 +458,12 @@ const _Draggable = new Lang.Class({
                                                 this._dragActor,
                                                 targX,
                                                 targY,
-                                                event.get_time())) {
+                                                global.get_current_time())) {
                     // If it accepted the drop without taking the actor,
                     // handle it ourselves.
                     if (this._dragActor.get_parent() == Main.uiGroup) {
                         if (this._restoreOnSuccess) {
-                            this._restoreDragActor(event.get_time());
+                            this._restoreDragActor(global.get_current_time());
                             return true;
                         } else
                             this._dragActor.destroy();
@@ -471,7 +471,7 @@ const _Draggable = new Lang.Class({
 
                     this._dragInProgress = false;
                     global.unset_cursor();
-                    this.emit('drag-end', event.get_time(), true);
+                    this.emit('drag-end', global.get_current_time(), true);
                     this._dragComplete();
                     return true;
                 }
@@ -479,7 +479,7 @@ const _Draggable = new Lang.Class({
             target = target.get_parent();
         }
 
-        this._cancelDrag(event.get_time());
+        this._cancelDrag(global.get_current_time());
 
         return true;
     },
diff --git a/js/ui/panel.js b/js/ui/panel.js
index aaabad1..e637425 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -1009,7 +1009,7 @@ const Panel = new Lang.Class({
                                      true, /* frame action */
                                      button,
                                      event.get_state(),
-                                     event.get_time(),
+                                     global.get_current_time(),
                                      stageX, stageY);
 
         return true;
diff --git a/js/ui/switcherPopup.js b/js/ui/switcherPopup.js
index e6036b0..9c533fb 100644
--- a/js/ui/switcherPopup.js
+++ b/js/ui/switcherPopup.js
@@ -200,7 +200,7 @@ const SwitcherPopup = new Lang.Class({
         let state = mods & this._modifierMask;
 
         if (state == 0)
-            this._finish(event.get_time());
+            this._finish(global.get_current_time());
 
         return true;
     },
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index fa53568..9ca1089 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -128,7 +128,7 @@ const WindowClone = new Lang.Class({
     },
 
     _onButtonRelease : function (actor, event) {
-        this.emit('selected', event.get_time());
+        this.emit('selected', global.get_current_time());
 
         return true;
     },
@@ -617,7 +617,7 @@ const ThumbnailsBox = new Lang.Class({
             let thumbnail = this._thumbnails[i]
             let [w, h] = thumbnail.actor.get_transformed_size();
             if (y >= thumbnail.actor.y && y <= thumbnail.actor.y + h) {
-                thumbnail.activate(event.get_time());
+                thumbnail.activate(global.get_current_time());
                 break;
             }
         }
diff --git a/src/shell-global.c b/src/shell-global.c
index b775489..5162965 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -1475,7 +1475,15 @@ shell_global_get_current_time (ShellGlobal *global)
   if (time != CLUTTER_CURRENT_TIME)
     return time;
 
-  return clutter_get_current_event_time ();
+  /* Can't use clutter timestamps when running on wayland, because
+     they have nothing to do with X11 timestamps
+  */
+#ifdef HAVE_WAYLAND
+  if (meta_is_wayland_compositor ())
+    return meta_display_get_current_time_roundtrip (global->meta_display);
+  else
+#endif
+    return clutter_get_current_event_time ();
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]