Re: [PATCH] guarantee that (GdkEventKey.state & GDK_RELEASE_MASK) is 0 in gdk_event_translate() (fwd)



Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.1061.2.289
diff -u -r1.1061.2.289 ChangeLog
--- ChangeLog	2000/12/02 17:58:58	1.1061.2.289
+++ ChangeLog	2000/12/03 16:49:11
@@ -1,3 +1,11 @@
+Sun Dec  3 11:44:07 2000  Owen Taylor  <otaylor redhat com>
+
+	* gdk/gdkevents.c: Strip GDK_RELEASE_MASK out of 
+	the state we get from X as a temporary hack to
+	deal with the fact that GDK_RELEASE_MASK has the
+	same values as bits used by XFree86 to indicate the
+	keyboard group. (After patch from Vlad Harchev)
+
 2000-20-01  Anders Carlsson  <andersca gnu org>
 
 	* gtk/gtktogglebutton.c (gtk_toggle_button_draw): Fix bug when
Index: gdk/gdkevents.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkevents.c,v
retrieving revision 1.20.2.10
diff -u -r1.20.2.10 gdkevents.c
--- gdk/gdkevents.c	2000/01/27 21:10:44	1.20.2.10
+++ gdk/gdkevents.c	2000/12/03 16:49:11
@@ -969,6 +969,16 @@
   client_filters = g_list_prepend (client_filters, filter);
 }
 
+/* Hack because GDK_RELEASE_MASK (a mistake in and of itself) was
+ * accidentally given a value that overlaps with real bits in the
+ * state field.
+ */
+static inline guint
+translate_state (guint xstate)
+{
+  return xstate & ~GDK_RELEASE_MASK;
+}
+
 static gint
 gdk_event_translate (GdkEvent *event,
 		     XEvent   *xevent)
@@ -1152,7 +1162,7 @@
       event->key.type = GDK_KEY_PRESS;
       event->key.window = window;
       event->key.time = xevent->xkey.time;
-      event->key.state = (GdkModifierType) xevent->xkey.state;
+      event->key.state = translate_state (xevent->xkey.state);
       event->key.string = g_strdup (buf);
       event->key.length = charcount;
       
@@ -1184,7 +1194,7 @@
       event->key.type = GDK_KEY_RELEASE;
       event->key.window = window;
       event->key.time = xevent->xkey.time;
-      event->key.state = (GdkModifierType) xevent->xkey.state;
+      event->key.state = translate_state (xevent->xkey.state);
       event->key.length = 0;
       event->key.string = NULL;
       
@@ -1217,7 +1227,7 @@
       event->button.pressure = 0.5;
       event->button.xtilt = 0;
       event->button.ytilt = 0;
-      event->button.state = (GdkModifierType) xevent->xbutton.state;
+      event->button.state = translate_state (xevent->xbutton.state);
       event->button.button = xevent->xbutton.button;
       event->button.source = GDK_SOURCE_MOUSE;
       event->button.deviceid = GDK_CORE_POINTER;
@@ -1287,7 +1297,7 @@
       event->button.pressure = 0.5;
       event->button.xtilt = 0;
       event->button.ytilt = 0;
-      event->button.state = (GdkModifierType) xevent->xbutton.state;
+      event->button.state = translate_state (xevent->xbutton.state);
       event->button.button = xevent->xbutton.button;
       event->button.source = GDK_SOURCE_MOUSE;
       event->button.deviceid = GDK_CORE_POINTER;
@@ -1321,7 +1331,7 @@
       event->motion.pressure = 0.5;
       event->motion.xtilt = 0;
       event->motion.ytilt = 0;
-      event->motion.state = (GdkModifierType) xevent->xmotion.state;
+      event->motion.state = translate_state (xevent->xmotion.state);
       event->motion.is_hint = xevent->xmotion.is_hint;
       event->motion.source = GDK_SOURCE_MOUSE;
       event->motion.deviceid = GDK_CORE_POINTER;
@@ -1401,7 +1411,7 @@
 	}
       
       event->crossing.focus = xevent->xcrossing.focus;
-      event->crossing.state = xevent->xcrossing.state;
+      event->crossing.state = translate_state (xevent->xcrossing.state);
   
       break;
       
@@ -1470,7 +1480,7 @@
 	}
       
       event->crossing.focus = xevent->xcrossing.focus;
-      event->crossing.state = xevent->xcrossing.state;
+      event->crossing.state = translate_state (xevent->xcrossing.state);
       
       break;
       




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