]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkevents.c
x11: Don't store last change serial
[~andy/gtk] / gdk / gdkevents.c
index db37512bc601c51c9a1cfa473e88d479ff00eb5f..4a9d0b965a0e73543985559673c3ea7ac9c9ff9f 100644 (file)
@@ -85,13 +85,27 @@ _gdk_event_emit (GdkEvent *event)
 GList*
 _gdk_event_queue_find_first (GdkDisplay *display)
 {
-  GList *tmp_list = display->queued_events;
+  GList *tmp_list;
+  GList *pending_motion = NULL;
+
+  if (display->event_pause_count > 0)
+    return NULL;
 
+  tmp_list = display->queued_events;
   while (tmp_list)
     {
       GdkEventPrivate *event = tmp_list->data;
-      if (!(event->flags & GDK_EVENT_PENDING))
-       return tmp_list;
+
+      if (event->flags & GDK_EVENT_PENDING)
+        continue;
+
+      if (pending_motion)
+        return pending_motion;
+
+      if (event->event.type == GDK_MOTION_NOTIFY && !display->flushing_events)
+        pending_motion = tmp_list;
+      else
+        return tmp_list;
 
       tmp_list = g_list_next (tmp_list);
     }
@@ -170,15 +184,15 @@ _gdk_event_queue_insert_after (GdkDisplay *display,
 }
 
 /**
- * _gdk_event_queue_insert_after:
+ * _gdk_event_queue_insert_before:
  * @display: a #GdkDisplay
- * @sibling: Append after this event.
- * @event: Event to append.
+ * @sibling: Append before this event
+ * @event: Event to prepend
  *
- * Appends an event before the specified event, or if it isn't in
- * the queue, onto the tail of the event queue.
+ * Prepends an event before the specified event, or if it isn't in
+ * the queue, onto the head of the event queue.
  *
- * Returns: the newly appended list node.
+ * Returns: the newly prepended list node.
  *
  * Since: 2.16
  */
@@ -248,6 +262,61 @@ _gdk_event_unqueue (GdkDisplay *display)
   return event;
 }
 
+void
+_gdk_event_queue_handle_motion_compression (GdkDisplay *display)
+{
+  GList *tmp_list;
+  GList *pending_motions = NULL;
+  GdkWindow *pending_motion_window = NULL;
+  GdkDevice *pending_motion_device = NULL;
+
+  /* If the last N events in the event queue are motion notify
+   * events for the same window, drop all but the last */
+
+  tmp_list = display->queued_tail;
+
+  while (tmp_list)
+    {
+      GdkEventPrivate *event = tmp_list->data;
+
+      if (event->flags & GDK_EVENT_PENDING)
+        break;
+
+      if (event->event.type != GDK_MOTION_NOTIFY)
+        break;
+
+      if (pending_motion_window != NULL &&
+          pending_motion_window != event->event.motion.window)
+        break;
+
+      if (pending_motion_device != NULL &&
+          pending_motion_device != event->event.motion.device)
+        break;
+
+      pending_motion_window = event->event.motion.window;
+      pending_motion_device = event->event.motion.device;
+      pending_motions = tmp_list;
+
+      tmp_list = tmp_list->prev;
+    }
+
+  while (pending_motions && pending_motions->next != NULL)
+    {
+      GList *next = pending_motions->next;
+      display->queued_events = g_list_delete_link (display->queued_events,
+                                                   pending_motions);
+      pending_motions = next;
+    }
+
+  if (pending_motions &&
+      pending_motions == display->queued_events &&
+      pending_motions == display->queued_tail)
+    {
+      GdkFrameClock *clock = gdk_window_get_frame_clock (pending_motion_window);
+      gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
+    }
+}
+
 /**
  * gdk_event_handler_set:
  * @func: the function to call to handle events from GDK.
@@ -1215,8 +1284,8 @@ gdk_event_get_scroll_direction (const GdkEvent *event,
 /**
  * gdk_event_get_scroll_deltas:
  * @event: a #GdkEvent
- * @delta_x: return location for X delta
- * @delta_y: return location for Y delta
+ * @delta_x: (out): return location for X delta
+ * @delta_y: (out): return location for Y delta
  *
  * Retrieves the scroll deltas from a #GdkEvent
  *