[gtk+/client-side-windows: 167/284] Move keyboard grab state tracking code to common code



commit 290de401a5918cf37b37488a9557f6cc260dbd16
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Jan 23 15:23:19 2009 +0100

    Move keyboard grab state tracking code to common code
---
 gdk/gdk.symbols          |    2 +-
 gdk/gdkdisplay.c         |   65 ++++++++++++++++++++++++++++++++++++--
 gdk/gdkinternals.h       |    8 +++-
 gdk/x11/gdkdisplay-x11.c |    2 +-
 gdk/x11/gdkmain-x11.c    |   79 +++------------------------------------------
 5 files changed, 76 insertions(+), 80 deletions(-)

diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 0bd9500..25de774 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -69,7 +69,6 @@ gdk_get_use_xshm
 gdk_set_use_xshm
 #endif
 gdk_keyboard_grab
-gdk_keyboard_grab_info_libgtk_only
 gdk_pointer_grab
 #endif
 #endif
@@ -84,6 +83,7 @@ gdk_pointer_is_grabbed
 gdk_pointer_ungrab
 gdk_event_send_client_message
 gdk_event_send_clientmessage_toall
+gdk_keyboard_grab_info_libgtk_only
 gdk_pointer_grab_info_libgtk_only
 gdk_display_pointer_is_grabbed
 #endif
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index 44b8b88..0092b5b 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -747,7 +747,7 @@ _gdk_display_set_has_pointer_grab (GdkDisplay *display,
 				   guint32 time,
 				   gboolean implicit)
 {
-  GdkWindow *pointer_window, *src_toplevel, *dest_toplevel, *src_window;
+  GdkWindow *src_toplevel, *dest_toplevel, *src_window;
   
   if (display->pointer_grab.window != NULL &&
       display->pointer_grab.window != window)
@@ -763,8 +763,6 @@ _gdk_display_set_has_pointer_grab (GdkDisplay *display,
    */
   if (!implicit)
     {
-      GdkScreen *screen;
-      GdkWindowObject *w;
       int x, y;
       GdkModifierType state;
 
@@ -961,9 +959,70 @@ _gdk_display_unset_has_pointer_grab (GdkDisplay *display,
     generate_grab_broken_event (old_grab_window,
 				FALSE, implicit, 
 				NULL);
+}
+
+void
+_gdk_display_set_has_keyboard_grab (GdkDisplay *display,
+				    GdkWindow *window,
+				    GdkWindow *native_window,
+				    gboolean owner_events,
+				    unsigned long serial,
+				    guint32 time)
+{
+  if (display->keyboard_grab.window != NULL &&
+      display->keyboard_grab.window != window)
+    generate_grab_broken_event (display->keyboard_grab.window,
+				TRUE, FALSE, window);
   
+  display->keyboard_grab.window = window;
+  display->keyboard_grab.native_window = native_window;
+  display->keyboard_grab.owner_events = owner_events;
+  display->keyboard_grab.serial = serial;
+  display->keyboard_grab.time = time;      
 }
 
+void
+_gdk_display_unset_has_keyboard_grab (GdkDisplay *display,
+				      gboolean implicit)
+{
+  if (implicit)
+    generate_grab_broken_event (display->keyboard_grab.window,
+				TRUE, FALSE, NULL);
+  display->keyboard_grab.window = NULL;  
+}
+
+/**
+ * gdk_keyboard_grab_info_libgtk_only:
+ * @display: the display for which to get the grab information
+ * @grab_window: location to store current grab window
+ * @owner_events: location to store boolean indicating whether
+ *   the @owner_events flag to gdk_keyboard_grab() was %TRUE.
+ * 
+ * Determines information about the current keyboard grab.
+ * This is not public API and must not be used by applications.
+ * 
+ * Return value: %TRUE if this application currently has the
+ *  keyboard grabbed.
+ **/
+gboolean
+gdk_keyboard_grab_info_libgtk_only (GdkDisplay *display,
+				    GdkWindow **grab_window,
+				    gboolean   *owner_events)
+{
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+  if (display->keyboard_grab.window)
+    {
+      if (grab_window)
+        *grab_window = display->keyboard_grab.window;
+      if (owner_events)
+        *owner_events = display->keyboard_grab.owner_events;
+
+      return TRUE;
+    }
+  else
+    return FALSE;
+}
 
 /**
  * gdk_pointer_grab_info_libgtk_only:
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 3841885..a878e05 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -466,8 +466,6 @@ char *_gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
 void  _gdk_windowing_launch_failed         (GAppLaunchContext *context, 
 				            const char        *startup_notify_id);
 
-void _gdk_windowing_grab_broken          (GdkDisplay *display);
-
 void _gdk_display_set_has_pointer_grab (GdkDisplay *display,
 					GdkWindow *window,
 					GdkWindow *native_window,
@@ -480,6 +478,12 @@ void _gdk_display_unset_has_pointer_grab (GdkDisplay *display,
 					  gboolean implicit,
 					  gboolean do_grab_one_pointer_release_event,
 					  guint32 time);
+void _gdk_display_set_has_keyboard_grab (GdkDisplay *display,
+					 GdkWindow *window,
+					 GdkWindow *native_window,
+					 gboolean owner_events,
+					 unsigned long serial,
+					 guint32 time);
 
 void _gdk_window_invalidate_for_expose (GdkWindow       *window,
 					const GdkRegion *region);
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index cbda734..4559fab 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -652,7 +652,7 @@ gdk_display_keyboard_ungrab (GdkDisplay *display,
   if (time == GDK_CURRENT_TIME || 
       display->keyboard_grab.time == GDK_CURRENT_TIME ||
       !XSERVER_TIME_IS_LATER (display->keyboard_grab.time, time))
-    display->keyboard_grab.window = NULL;
+    _gdk_display_unset_has_keyboard_grab (display, FALSE);
 }
 
 /**
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index e516f86..e17abc5 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -355,73 +355,14 @@ gdk_keyboard_grab (GdkWindow *	   window,
     return_val = AlreadyGrabbed;
 
   if (return_val == GrabSuccess)
-    {
-      if (display->keyboard_grab.window != NULL &&
-	  display->keyboard_grab.window != window)
-	generate_grab_broken_event (GDK_WINDOW (display->keyboard_grab.window),
-				    TRUE, FALSE, window);
-      
-      display->keyboard_grab.window = window;
-      display->keyboard_grab.native_window = native;
-      display->keyboard_grab.serial = serial;
-      display->keyboard_grab.owner_events = owner_events;
-      display->keyboard_grab.time = time;      
-    }
+    _gdk_display_set_has_keyboard_grab (display,
+					window,	native,
+					owner_events,
+					serial, time);
 
   return gdk_x11_convert_grab_status (return_val);
 }
 
-void
-_gdk_windowing_grab_broken (GdkDisplay *display)
-{
-  /* TODO: Move to common code */
-#if 0
-  GdkDisplayX11 *display_x11;
-
-  g_return_if_fail (display != NULL);
-
-  display_x11 = GDK_DISPLAY_X11 (display);
-  generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_grab.window),
-                              FALSE,
-                              display_x11->pointer_grab.implicit,
-                              NULL);
-  display_x11->pointer_grab.window = NULL;
-#endif
-}
-
-/**
- * gdk_keyboard_grab_info_libgtk_only:
- * @display: the display for which to get the grab information
- * @grab_window: location to store current grab window
- * @owner_events: location to store boolean indicating whether
- *   the @owner_events flag to gdk_keyboard_grab() was %TRUE.
- * 
- * Determines information about the current keyboard grab.
- * This is not public API and must not be used by applications.
- * 
- * Return value: %TRUE if this application currently has the
- *  keyboard grabbed.
- **/
-gboolean
-gdk_keyboard_grab_info_libgtk_only (GdkDisplay *display,
-				    GdkWindow **grab_window,
-				    gboolean   *owner_events)
-{
-  g_return_val_if_fail (GDK_IS_DISPLAY (display), False);
-
-  if (display->keyboard_grab.window)
-    {
-      if (grab_window)
-        *grab_window = display->keyboard_grab.window;
-      if (owner_events)
-        *owner_events = display->keyboard_grab.owner_events;
-
-      return TRUE;
-    }
-  else
-    return FALSE;
-}
-
 /**
  * _gdk_xgrab_check_unmap:
  * @window: a #GdkWindow
@@ -461,11 +402,7 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
 	tmp = tmp->parent;
 
       if (tmp)
-	{
-	  generate_grab_broken_event (GDK_WINDOW (display->keyboard_grab.window),
-				      TRUE, FALSE, NULL);
-	  display->keyboard_grab.window = NULL;  
-	}
+	_gdk_display_unset_has_keyboard_grab (display, TRUE);
     }
 }
 
@@ -488,11 +425,7 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
 
   if (window == display->keyboard_grab.native_window &&
       display->keyboard_grab.window != NULL)
-    {
-      generate_grab_broken_event (GDK_WINDOW (display->keyboard_grab.window),
-				  TRUE, FALSE, NULL);
-      display->keyboard_grab.window = NULL;
-    }
+    _gdk_display_unset_has_keyboard_grab (display, TRUE);
 }
 
 #define GDK_ANY_BUTTON_MASK (GDK_BUTTON1_MASK | \



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