Pointer hooks



This look like what you want for '56914 Add virtualization of XQueryPointer'?

I haven't actually tried running it yet, but it compiles, and I
don't think there is a whole lot I could have gotten wrong here.

Regards,
                                        Owen

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.2102
diff -u -r1.2102 ChangeLog
--- ChangeLog	2001/07/02 05:03:17	1.2102
+++ ChangeLog	2001/07/02 05:13:46
@@ -1,3 +1,10 @@
+Mon Jul  2 01:09:37 2001  Owen Taylor  <otaylor redhat com>
+
+	* gdk/gdkwindow.[ch] gdk/gdkinternals.h gdk/x11/gdkwindow-x11.c
+	gdk/linux-fb/gdkwindow-fb.c gdk/x11/gdkwindow-x11.c gdk/gdk:
+	Add gdk_set_pointer_hooks() to allow pointer-querying to
+	be hooked by an event record/playback system like GERD.
+	
 Mon Jul  2 06:35:10 2001  Tim Janik  <timj gtk org>
 
 	* gdk/gdkkeys.c (gdk_keymap_class_init): s/signal_newc/signal_new/
Index: gdk/gdkinternals.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkinternals.h,v
retrieving revision 1.8
diff -u -r1.8 gdkinternals.h
--- gdk/gdkinternals.h	2001/03/09 20:28:16	1.8
+++ gdk/gdkinternals.h	2001/07/02 05:13:47
@@ -159,6 +159,13 @@
 						 gint        width,
 						 gint        height);
 
+GdkWindow* _gdk_windowing_window_at_pointer  (gint            *win_x,
+					      gint            *win_y);
+GdkWindow* _gdk_windowing_window_get_pointer (GdkWindow       *window,
+					      gint            *x,
+					      gint            *y,
+					      GdkModifierType *mask);
+
 #define GDK_WINDOW_IS_MAPPED(window) ((((GdkWindowObject*)window)->state & GDK_WINDOW_STATE_WITHDRAWN) == 0)
 
 /* Called before processing updates for a window. This gives the windowing
Index: gdk/gdkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.c,v
retrieving revision 1.117
diff -u -r1.117 gdkwindow.c
--- gdk/gdkwindow.c	2001/06/29 01:58:59	1.117
+++ gdk/gdkwindow.c	2001/07/02 05:13:47
@@ -42,6 +42,14 @@
   gint x_offset;
   gint y_offset;
 };
+
+static const GdkPointerHooks default_pointer_hooks = {
+  _gdk_windowing_window_get_pointer,
+  _gdk_windowing_window_at_pointer
+};
+
+const GdkPointerHooks *current_pointer_hooks = &default_pointer_hooks;
+
 static GdkGC *gdk_window_create_gc      (GdkDrawable     *drawable,
                                          GdkGCValues     *values,
                                          GdkGCValuesMask  mask);
@@ -2278,4 +2286,49 @@
   
   *new_width = width;
   *new_height = height;
+}
+
+/**
+ * gdk_set_pointer_hooks:
+ * @new_hooks: a table of pointer to functions for getting
+ *   quantities related to the current pointer position,
+ *   or %NULL to restore the default table.
+ * 
+ * This function allows for hooking into the operation
+ * of getting the current location of the pointer. This
+ * is only useful for such low-level tools as an
+ * event recorder. Applications should never have any
+ * reason to use this facility
+ * 
+ * Return value: the previous pointer hook table
+ **/
+GdkPointerHooks *
+gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks)
+{
+  const GdkPointerHooks *result = current_pointer_hooks;
+
+  if (new_hooks)
+    current_pointer_hooks = new_hooks;
+  else
+    current_pointer_hooks = &default_pointer_hooks;
+
+  return (GdkPointerHooks *)result;
+}
+
+GdkWindow*
+gdk_window_get_pointer (GdkWindow	  *window,
+			gint		  *x,
+			gint		  *y,
+			GdkModifierType *mask)
+{
+  g_return_val_if_fail (window == NULL || GDK_IS_WINDOW (window), NULL);
+  
+  return current_pointer_hooks->get_pointer (window, x, y, mask); 
+}
+
+GdkWindow*
+gdk_window_at_pointer (gint *win_x,
+		       gint *win_y)
+{
+  return current_pointer_hooks->window_at_pointer (win_x, win_y);
 }
Index: gdk/gdkwindow.h
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkwindow.h,v
retrieving revision 1.25
diff -u -r1.25 gdkwindow.h
--- gdk/gdkwindow.h	2001/06/28 05:24:00	1.25
+++ gdk/gdkwindow.h	2001/07/02 05:13:47
@@ -12,6 +12,7 @@
 
 typedef struct _GdkGeometry           GdkGeometry;
 typedef struct _GdkWindowAttr	      GdkWindowAttr;
+typedef struct _GdkPointerHooks	      GdkPointerHooks;
 
 /* Classes of windows.
  *   InputOutput: Almost every window should be of this type. Such windows
@@ -195,6 +196,16 @@
   GdkGravity win_gravity;
 };
 
+struct _GdkPointerHooks 
+{
+  GdkWindow* (*get_pointer)       (GdkWindow	   *window,
+			           gint	           *x,
+			           gint   	   *y,
+			           GdkModifierType *mask);
+  GdkWindow* (*window_at_pointer) (gint            *win_x,
+                                   gint            *win_y);
+};
+
 typedef struct _GdkWindowObject GdkWindowObject;
 typedef struct _GdkWindowObjectClass GdkWindowObjectClass;
 
@@ -495,6 +506,8 @@
                                            gint          height,
                                            gint         *new_width,
                                            gint         *new_height);
+
+GdkPointerHooks *gdk_set_pointer_hooks (const GdkPointerHooks *new_hooks);   
 
 #ifdef __cplusplus
 }
Index: gdk/linux-fb/gdkwindow-fb.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/linux-fb/gdkwindow-fb.c,v
retrieving revision 1.36
diff -u -r1.36 gdkwindow-fb.c
--- gdk/linux-fb/gdkwindow-fb.c	2001/06/13 21:40:37	1.36
+++ gdk/linux-fb/gdkwindow-fb.c	2001/07/02 05:13:48
@@ -1602,10 +1602,10 @@
 }
 
 GdkWindow *
-gdk_window_get_pointer (GdkWindow       *window,
-			gint            *x,
-			gint            *y,
-			GdkModifierType *mask)
+_gdk_windowing_window_get_pointer (GdkWindow       *window,
+				   gint            *x,
+				   gint            *y,
+				   GdkModifierType *mask)
 {
   GdkWindow *return_val;
   int winx = 0;
@@ -1686,8 +1686,8 @@
 }
 
 GdkWindow*
-gdk_window_at_pointer (gint *win_x,
-		       gint *win_y)
+_gdk_windowing_window_at_pointer (gint *win_x,
+				  gint *win_y)
 {
   gint rx, ry;
   GdkWindow *retval = gdk_window_get_pointer (NULL, win_x, win_y, NULL);
Index: gdk/win32/gdkwindow-win32.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/win32/gdkwindow-win32.c,v
retrieving revision 1.53
diff -u -r1.53 gdkwindow-win32.c
--- gdk/win32/gdkwindow-win32.c	2001/05/25 15:43:52	1.53
+++ gdk/win32/gdkwindow-win32.c	2001/07/02 05:13:48
@@ -1739,10 +1739,10 @@
 }
 
 GdkWindow*
-gdk_window_get_pointer (GdkWindow       *window,
-			gint            *x,
-			gint            *y,
-			GdkModifierType *mask)
+_gdk_windowing_window_get_pointer (GdkWindow       *window,
+				   gint            *x,
+				   gint            *y,
+				   GdkModifierType *mask)
 {
   GdkWindow *return_val;
   POINT pointc, point;
@@ -1801,8 +1801,8 @@
 }
 
 GdkWindow*
-gdk_window_at_pointer (gint *win_x,
-		       gint *win_y)
+_gdk_windowing_window_at_pointer (gint *win_x,
+				  gint *win_y)
 {
   GdkWindow *window;
   POINT point, pointc;
@@ -2505,4 +2505,4 @@
     return;
 
   /* XXX: isn't all this default on win32 ... */  
-}
\ No newline at end of file
+}
Index: gdk/x11/gdkwindow-x11.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/x11/gdkwindow-x11.c,v
retrieving revision 1.118
diff -u -r1.118 gdkwindow-x11.c
--- gdk/x11/gdkwindow-x11.c	2001/06/29 01:59:00	1.118
+++ gdk/x11/gdkwindow-x11.c	2001/07/02 05:13:49
@@ -1953,10 +1953,10 @@
 }
 
 GdkWindow*
-gdk_window_get_pointer (GdkWindow       *window,
-			gint            *x,
-			gint            *y,
-			GdkModifierType *mask)
+_gdk_windowing_window_get_pointer (GdkWindow       *window,
+				   gint            *x,
+				   gint            *y,
+				   GdkModifierType *mask)
 {
   GdkWindow *return_val;
   Window root;
@@ -1995,8 +1995,8 @@
 }
 
 GdkWindow*
-gdk_window_at_pointer (gint *win_x,
-		       gint *win_y)
+_gdk_windowing_window_at_pointer (gint *win_x,
+				  gint *win_y)
 {
   GdkWindow *window;
   Window root;




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