[gtk+/client-side-windows: 171/284] Switch motion hint emulation to be serial based.



commit e24c9e291d62c658e0c31c161abc0080169da430
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Jan 23 21:07:53 2009 +0100

    Switch motion hint emulation to be serial based.
    
    For backends not supporting serials, just have
    _gdk_windowing_window_get_next_serial return zero.
---
 gdk/gdkdisplay.c         |   13 +++++++++++++
 gdk/gdkdisplay.h         |    2 +-
 gdk/gdkevents.c          |    2 +-
 gdk/gdkinternals.h       |    6 +++++-
 gdk/gdkwindow.c          |   25 +++++++++++++------------
 gdk/x11/gdkdisplay-x11.c |    7 +++++++
 gdk/x11/gdkevents-x11.c  |    2 +-
 7 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 0092b5b..a8f027e 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -444,6 +444,19 @@ _gdk_get_sm_client_id (void)
   return gdk_sm_client_id;
 }
 
+void
+_gdk_display_enable_motion_hints (GdkDisplay *display)
+{
+  gulong next_serial;
+  
+  if (display->pointer_info.motion_hint_serial != 0)
+    {
+      next_serial = _gdk_windowing_window_get_next_serial (display);
+      if (next_serial < display->pointer_info.motion_hint_serial)
+	display->pointer_info.motion_hint_serial = next_serial;
+    }
+}
+
 /**
  * gdk_display_get_pointer:
  * @display: a #GdkDisplay
diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h
index 4e1e7a3..c3a7d62 100644
--- a/gdk/gdkdisplay.h
+++ b/gdk/gdkdisplay.h
@@ -83,7 +83,7 @@ typedef struct
   gdouble toplevel_x, toplevel_y; 
   guint32 state;
   guint32 button;
-  gboolean motion_hint_paused; /* TRUE if we've sent a motion to a window with motion hints enabled */
+  gulong motion_hint_serial; /* 0 == didn't deliver hinted motion event */
 } GdkPointerWindowInfo;
 
 struct _GdkDisplay
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 08e47ac..af94ecb 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -950,7 +950,7 @@ gdk_event_request_motions (const GdkEventMotion *event)
       gdk_device_get_state (event->device, event->window, NULL, NULL);
       
       display = gdk_drawable_get_display (event->window);
-      display->pointer_info.motion_hint_paused = FALSE;
+      _gdk_display_enable_motion_hints (display);
     }
 }
 
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index e70f82c..4bb5253 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -333,6 +333,7 @@ void     _gdk_windowing_set_default_display     (GdkDisplay *display);
 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
 					        gint         screen_number);
 
+gulong   _gdk_windowing_window_get_next_serial  (GdkDisplay *display);
 void     _gdk_windowing_window_get_offsets      (GdkWindow  *window,
 						 gint       *x_offset,
 						 gint       *y_offset);
@@ -357,7 +358,8 @@ GdkWindow* _gdk_windowing_window_at_pointer  (GdkDisplay       *display,
 					      GdkModifierType  *mask);
 void _gdk_windowing_got_event                (GdkDisplay       *display,
 					      GList            *event_link,
-					      GdkEvent         *event);
+					      GdkEvent         *event,
+					      gulong            serial);
 
 
 /* Return the number of bits-per-pixel for images of the specified depth. */
@@ -486,6 +488,8 @@ void _gdk_display_set_has_keyboard_grab (GdkDisplay *display,
 					 guint32 time);
 void _gdk_display_unset_has_keyboard_grab (GdkDisplay *display,
 					   gboolean implicit);
+void _gdk_display_enable_motion_hints     (GdkDisplay *display);
+
 
 void _gdk_window_invalidate_for_expose (GdkWindow       *window,
 					const GdkRegion *region);
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 2ce4e0a..69fd9b8 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -5272,7 +5272,7 @@ gdk_window_get_pointer (GdkWindow	  *window,
   if (mask)
     *mask = tmp_mask;
 
-  display->pointer_info.motion_hint_paused = FALSE;
+  _gdk_display_enable_motion_hints (display);
   
   return child;
 }
@@ -5847,7 +5847,7 @@ gdk_window_set_events (GdkWindow       *window,
   display = gdk_drawable_get_display (window);
   if ((private->event_mask & GDK_POINTER_MOTION_HINT_MASK) &&
       !(event_mask & GDK_POINTER_MOTION_HINT_MASK))
-    display->pointer_info.motion_hint_paused = FALSE;
+    _gdk_display_enable_motion_hints (display);
   
   private->event_mask = event_mask;
 }
@@ -8104,7 +8104,7 @@ _gdk_display_set_window_under_pointer (GdkDisplay *display,
   if (window)
     update_cursor (display);
 
-  display->pointer_info.motion_hint_paused = FALSE;
+  _gdk_display_enable_motion_hints (display);
 }
 
 void
@@ -8215,7 +8215,8 @@ get_event_window (GdkDisplay                 *display,
 
 static gboolean
 proxy_pointer_event (GdkDisplay                 *display,
-		     GdkEvent                   *source_event)
+		     GdkEvent                   *source_event,
+		     gulong                      serial)
 {
   GdkWindow *toplevel_window;
   GdkWindow *pointer_window;
@@ -8264,12 +8265,13 @@ proxy_pointer_event (GdkDisplay                 *display,
       if (event_win &&
 	  (evmask & GDK_POINTER_MOTION_HINT_MASK))
 	{
-	  if (display->pointer_info.motion_hint_paused)
+	  if (display->pointer_info.motion_hint_serial != 0 &&
+	      serial < display->pointer_info.motion_hint_serial)
 	    event_win = NULL; /* Ignore event */
 	  else
 	    {
 	      is_hint = TRUE;
-	      display->pointer_info.motion_hint_paused = TRUE;
+	      display->pointer_info.motion_hint_serial = G_MAXULONG;
 	    }
 	}
       
@@ -8468,7 +8470,8 @@ gdk_window_print_tree (GdkWindow *window,
 void
 _gdk_windowing_got_event (GdkDisplay *display,
 			  GList      *event_link,
-			  GdkEvent   *event)
+			  GdkEvent   *event,
+			  gulong      serial)
 {
   GdkWindow *event_window;
   GdkWindowObject *event_private;
@@ -8569,15 +8572,13 @@ _gdk_windowing_got_event (GdkDisplay *display,
 
   if (display->pointer_info.state != old_state ||
       display->pointer_info.button != old_button)
-    {
-      /* Enable motions for the window */
-      display->pointer_info.motion_hint_paused = FALSE;
-    }
+    _gdk_display_enable_motion_hints (display);
  
   unlink_event = FALSE;
   if (is_motion_type (event->type))
     unlink_event = proxy_pointer_event (display,
-                                        event);
+                                        event,
+					serial);
   else if (is_button_type (event->type))
     unlink_event = proxy_button_event (event);
 
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 4559fab..a7f57aa 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -444,6 +444,13 @@ process_internal_connection (GIOChannel  *gioc,
   return TRUE;
 }
 
+gulong
+_gdk_windowing_window_get_next_serial (GdkDisplay *display)
+{
+  return NextRequest (GDK_DISPLAY_XDISPLAY (display));
+}
+
+
 static GdkInternalConnection *
 gdk_add_connection_handler (Display *display,
 			    guint    fd)
diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c
index 41de19c..3b61e83 100644
--- a/gdk/x11/gdkevents-x11.c
+++ b/gdk/x11/gdkevents-x11.c
@@ -2352,7 +2352,7 @@ _gdk_events_queue (GdkDisplay *display)
       if (gdk_event_translate (display, event, &xevent, FALSE))
 	{
 	  ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
-          _gdk_windowing_got_event (display, node, event);
+          _gdk_windowing_got_event (display, node, event, xevent.xany.serial);
 	}
       else
 	{



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