[mutter] Export methods interact with user_time



commit edcb351107b2a8abffa8c082fb0c3389792e7b13
Author: Colin Walters <walters verbum org>
Date:   Sat Apr 17 14:43:08 2010 -0400

    Export methods interact with user_time
    
    This is useful when calling some of the lower level mutter functions,
    e.g. controlling window stacking.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=616050

 src/core/display-private.h |   17 +++++------------
 src/core/display.c         |   37 +++++++++++++++++++++++++++++++++++++
 src/include/display.h      |    6 ++++++
 3 files changed, 48 insertions(+), 12 deletions(-)
---
diff --git a/src/core/display-private.h b/src/core/display-private.h
index 7373a5c..fa0676a 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -303,22 +303,15 @@ struct _MetaDisplayClass
   GObjectClass parent_class;
 };
 
-/* Xserver time can wraparound, thus comparing two timestamps needs to take
- * this into account.  Here's a little macro to help out.  If no wraparound
- * has occurred, this is equivalent to
- *   time1 < time2
- * Of course, the rest of the ugliness of this macro comes from accounting
- * for the fact that wraparound can occur and the fact that a timestamp of
- * 0 must be special-cased since it means older than anything else. 
- *
- * Note that this is NOT an equivalent for time1 <= time2; if that's what
- * you need then you'll need to swap the order of the arguments and negate
- * the result.
- */
 #define XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) \
   ( (( (time1) < (time2) ) && ( (time2) - (time1) < ((guint32)-1)/2 )) ||     \
     (( (time1) > (time2) ) && ( (time1) - (time2) > ((guint32)-1)/2 ))        \
   )
+/**
+ * XSERVER_TIME_IS_BEFORE:
+ *
+ * See the docs for meta_display_xserver_time_is_before().
+ */
 #define XSERVER_TIME_IS_BEFORE(time1, time2)                          \
   ( (time1) == 0 ||                                                     \
     (XSERVER_TIME_IS_BEFORE_ASSUMING_REAL_TIMESTAMPS(time1, time2) && \
diff --git a/src/core/display.c b/src/core/display.c
index 6d074d1..47935ff 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -1320,6 +1320,43 @@ meta_grab_op_is_moving (MetaGrabOp op)
     }
 }
 
+/**
+ * meta_display_xserver_time_is_before:
+ * @display: a #MetaDisplay
+ * @time1: An event timestamp
+ * @time2: An event timestamp
+ *
+ * Xserver time can wraparound, thus comparing two timestamps needs to take
+ * this into account. If no wraparound has occurred, this is equivalent to
+ *   time1 < time2
+ * Otherwise, we need to account for the fact that wraparound can occur
+ * and the fact that a timestamp of 0 must be special-cased since it
+ * means "older than anything else".
+ *
+ * Note that this is NOT an equivalent for time1 <= time2; if that's what
+ * you need then you'll need to swap the order of the arguments and negate
+ * the result.
+ */
+gboolean
+meta_display_xserver_time_is_before (MetaDisplay   *display,
+                                     guint32        time1,
+                                     guint32        time2)
+{
+  return XSERVER_TIME_IS_BEFORE(time1, time2);
+}
+
+/**
+ * meta_display_get_last_user_time:
+ * @display: a #MetaDisplay
+ *
+ * Returns: Timestamp of the last user interaction event with a window
+ */
+guint32
+meta_display_get_last_user_time (MetaDisplay *display)
+{
+  return display->last_user_time;
+}
+
 /* Get time of current event, or CurrentTime if none. */
 guint32
 meta_display_get_current_time (MetaDisplay *display)
diff --git a/src/include/display.h b/src/include/display.h
index c30e6ae..38386ca 100644
--- a/src/include/display.h
+++ b/src/include/display.h
@@ -82,6 +82,12 @@ gboolean  meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display,
 int meta_display_get_damage_event_base (MetaDisplay *display);
 int meta_display_get_shape_event_base (MetaDisplay *display);
 Atom meta_display_get_atom (MetaDisplay *display, MetaAtom meta_atom);
+
+gboolean meta_display_xserver_time_is_before (MetaDisplay *display,
+                                              guint32      time1,
+                                              guint32      time2);
+
+guint32 meta_display_get_last_user_time (MetaDisplay *display);
 guint32 meta_display_get_current_time (MetaDisplay *display);
 guint32 meta_display_get_current_time_roundtrip (MetaDisplay *display);
 



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