OSDN Git Service

Backport upstream fix for "no event type or button # or keysym"
authorkevinb <kevinb>
Thu, 26 Feb 2009 20:26:10 +0000 (20:26 +0000)
committerkevinb <kevinb>
Thu, 26 Feb 2009 20:26:10 +0000 (20:26 +0000)
error when starting a tk application.

tk/ChangeLog
tk/generic/tk.h
tk/generic/tkEvent.c
tk/unix/tkUnixEvent.c

index 9afbffd..0ac59b2 100644 (file)
@@ -1,3 +1,9 @@
+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> [...].
+
 2006-11-30  Christopher Faylor  <cgf@timesys.com>
 
        * tk/win/tcl.m4 (LIB_AC_PROG_CC): Upgrade to avoid use of obsolete
index 3347d94..9825623 100644 (file)
@@ -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 602b044..614dc24 100644 (file)
@@ -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_LASTEVENT] = {
     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 bb87c4a..c3a0d2a 100644 (file)
@@ -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--;
     }