This is the mail archive of the insight@sourceware.org mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFA: Fix "no event type or button # or keysym" error when starting insight


I request approval for committing the patch below.  Note that the patch
is to tk, not insight proper.  The patch was derived from upstream
(sourceforge) sources.

When attempting to run insight on my Fedora 10 machine, I see the following
error:

no event type or button # or keysym
    while executing
"bind Listbox <MouseWheel> {
    %W yview scroll [expr {- (%D / 120) * 4}] units
}"

[This isn't the entire error message; in the interest of brevity, I
pasted only the important part.]

Xorg release 7.4 introduced a new event, GenericEvent, which was placed
in between MappingNotify and LASTEvent:

#define MappingNotify		34
#define GenericEvent		35
#define LASTEvent		36	

For reasons not entirely clear to me, the addition of this event is
responsible for the the mouse wheel binding error.  More information
regarding this problem may be found here:

http://sourceforge.net/tracker/?func=detail&atid=112997&aid=2010422&group_id=12997

This problem has been fixed in the upstream sources.  I've appended,
below, a patch adapted to the current sourceware Tk sources.  I've
located an upstream ChangeLog entry by the original patch author for
changes to two of the changed files, but not the third.  The change
to tkUnixEvent.c is not critical; I can leave it out if so desired.

Okay?

Kevin

2008-08-05  Joe English	 <jenglish@users.sourceforge.net>

	* generic/tk.h, generic/tkEvent.c: Fix for [Bug 2010422] "no event
	type or button # or keysym while executing "bind Listbox
	<MouseWheel> [...]".

Index: tk/generic/tk.h
===================================================================
RCS file: /cvs/src/src/tk/generic/tk.h,v
retrieving revision 1.5
diff -u -p -r1.5 tk.h
--- tk/generic/tk.h	21 Jan 2003 20:24:42 -0000	1.5
+++ tk/generic/tk.h	26 Feb 2009 17:13:32 -0000
@@ -650,17 +650,15 @@ typedef struct Tk_GeomMgr {
  *
  *---------------------------------------------------------------------------
  */
-#define VirtualEvent	    (LASTEvent)
-#define ActivateNotify	    (LASTEvent + 1)
-#define DeactivateNotify    (LASTEvent + 2)
-#define MouseWheelEvent     (LASTEvent + 3)
-#define TK_LASTEVENT	    (LASTEvent + 4)
+#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)
 
 
 /*
Index: tk/generic/tkEvent.c
===================================================================
RCS file: /cvs/src/src/tk/generic/tkEvent.c,v
retrieving revision 1.5
diff -u -p -r1.5 tkEvent.c
--- tk/generic/tkEvent.c	21 Jan 2003 20:24:43 -0000	1.5
+++ tk/generic/tkEvent.c	26 Feb 2009 17:13:32 -0000
@@ -77,7 +77,7 @@ typedef struct TkWindowEvent {
  * 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 */
@@ -115,7 +115,10 @@ static unsigned long eventMasks[TK_LASTE
     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 */
@@ -734,7 +737,21 @@ Tk_HandleEvent(eventPtr)
      */
 
     handlerWindow = eventPtr->xany.window;
-    mask = eventMasks[eventPtr->xany.type];
+
+    /*
+     * 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];
+    }
+
     if (mask == StructureNotifyMask) {
 	if (eventPtr->xmap.event != eventPtr->xmap.window) {
 	    mask = SubstructureNotifyMask;
Index: tk/unix/tkUnixEvent.c
===================================================================
RCS file: /cvs/src/src/tk/unix/tkUnixEvent.c,v
retrieving revision 1.5
diff -u -p -r1.5 tkUnixEvent.c
--- tk/unix/tkUnixEvent.c	21 Jan 2003 20:24:52 -0000	1.5
+++ tk/unix/tkUnixEvent.c	26 Feb 2009 17:13:32 -0000
@@ -288,6 +288,14 @@ TransferXEventsToTcl(display)
 
     while (numFound > 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
 	Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
 	numFound--;
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]