tk/genericevent.patch
Marcela Mašláňová 0a229a9bd9 - previous bug - remove my patch, add upstream patch
- Problem is updated xorg, which changed behaviour of GenericEvent
2008-08-04 12:33:10 +00:00

116 lines
4.0 KiB
Diff

Index: generic/tk.h
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tk.h,v
retrieving revision 1.112
diff -u -r1.112 tk.h
--- tk8.5.3/generic/tk.h 19 Jun 2008 19:48:26 -0000 1.112
+++ tk8.5.3/ generic/tk.h 28 Jul 2008 12:38:26 -0000
@@ -627,17 +627,18 @@
*---------------------------------------------------------------------------
*/
-#define VirtualEvent (LASTEvent)
-#define ActivateNotify (LASTEvent + 1)
-#define DeactivateNotify (LASTEvent + 2)
-#define MouseWheelEvent (LASTEvent + 3)
-#define TK_LASTEVENT (LASTEvent + 4)
+#if (TK_MAJOR_VERSION > 8)
+#error Maintenance todo: Fix GenericEvent/VirtualEvent clash. [Bug 2010422]
+#endif
+#define VirtualEvent (MappingNotify + 1)
+#define ActivateNotify (MappingNotify + 2)
+#define DeactivateNotify (MappingNotify + 3)
+#define MouseWheelEvent (MappingNotify + 4)
+#define TK_LASTEVENT (MappingNotify + 5)
#define MouseWheelMask (1L << 28)
-
#define ActivateMask (1L << 29)
#define VirtualEventMask (1L << 30)
-#define TK_LASTEVENT (LASTEvent + 4)
/*
* A virtual event shares most of its fields with the XKeyEvent and
Index: generic/tkEvent.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/generic/tkEvent.c,v
retrieving revision 1.35
diff -u -r1.35 tkEvent.c
--- tk8.5.3/generic/tkEvent.c 26 Mar 2008 19:04:09 -0000 1.35
+++ tk8.5.3/ generic/tkEvent.c 28 Jul 2008 12:38:27 -0000
@@ -75,7 +75,7 @@
* Array of event masks corresponding to each X event:
*/
-static unsigned long eventMasks[TK_LASTEVENT] = {
+static unsigned long realEventMasks[MappingNotify+1] = {
0,
0,
KeyPressMask, /* KeyPress */
@@ -113,7 +113,10 @@
0, /* SelectionNotify */
ColormapChangeMask, /* ColormapNotify */
0, /* ClientMessage */
- 0, /* Mapping Notify */
+ 0 /* Mapping Notify */
+};
+
+static unsigned long virtualEventMasks[TK_LASTEVENT-VirtualEvent] = {
VirtualEventMask, /* VirtualEvents */
ActivateMask, /* ActivateNotify */
ActivateMask, /* DeactivateNotify */
@@ -489,7 +492,7 @@
*
* GetEventMaskFromXEvent --
*
- * The event type is looked up in our eventMasks table, and may be
+ * The event type is looked up in our eventMasks tables, and may be
* changed to a different mask depending on the state of the event and
* window members.
*
@@ -506,7 +509,21 @@
GetEventMaskFromXEvent(
XEvent *eventPtr)
{
- unsigned long mask = eventMasks[eventPtr->xany.type];
+ unsigned long mask;
+
+ /*
+ * Get the event mask from the correct table. Note that there are two
+ * tables here because that means we no longer need this code to rely on
+ * the exact value of VirtualEvent, which has caused us problems in the
+ * past when X11 changed the value of LASTEvent. [Bug ???]
+ */
+
+ if (eventPtr->xany.type <= MappingNotify) {
+ mask = realEventMasks[eventPtr->xany.type];
+ } else if (eventPtr->xany.type >= VirtualEvent
+ && eventPtr->xany.type<TK_LASTEVENT) {
+ mask = virtualEventMasks[eventPtr->xany.type - VirtualEvent];
+ }
/*
* Events selected by StructureNotify require special handling. They look
Index: unix/tkUnixEvent.c
===================================================================
RCS file: /cvsroot/tktoolkit/tk/unix/tkUnixEvent.c,v
retrieving revision 1.28
diff -u -r1.28 tkUnixEvent.c
--- tk8.5.3/unix/tkUnixEvent.c 27 Apr 2008 22:39:13 -0000 1.28
+++ tk8.5.3/ unix/tkUnixEvent.c 28 Jul 2008 12:38:28 -0000
@@ -289,6 +289,14 @@
while (QLength(display) > 0) {
XNextEvent(display, &event);
+#ifdef GenericEvent
+ if (event.type == GenericEvent) {
+ xGenericEvent *xgePtr = (xGenericEvent *) &event;
+
+ Tcl_Panic("Wild GenericEvent; panic! (extension=%d,evtype=%d)",
+ xgePtr->extension, xgePtr->evtype);
+ }
+#endif
if (event.type != KeyPress && event.type != KeyRelease) {
if (XFilterEvent(&event, None)) {
continue;