summaryrefslogtreecommitdiffstats
path: root/generic/tkBind.c
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-01-29 12:41:11 (GMT)
committernijtmans <nijtmans>2010-01-29 12:41:11 (GMT)
commit72a2e7f509b932f6409e5e2e2e39dfde6da89897 (patch)
tree77377fb3841d63142de26c8498d841817d531636 /generic/tkBind.c
parent8653f8ec25290721bc6fac2a9c68bbff0a4c4eb3 (diff)
downloadtk-72a2e7f509b932f6409e5e2e2e39dfde6da89897.zip
tk-72a2e7f509b932f6409e5e2e2e39dfde6da89897.tar.gz
tk-72a2e7f509b932f6409e5e2e2e39dfde6da89897.tar.bz2
Fix various gcc-4.4 warnings and formatting, all
backported from HEAD.
Diffstat (limited to 'generic/tkBind.c')
-rw-r--r--generic/tkBind.c307
1 files changed, 144 insertions, 163 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c
index a83c6ad..ccffd9b 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkBind.c,v 1.45.2.2 2009/04/11 04:26:59 das Exp $
+ * RCS: @(#) $Id: tkBind.c,v 1.45.2.3 2010/01/29 12:41:11 nijtmans Exp $
*/
#include "tkInt.h"
@@ -230,8 +230,7 @@ typedef struct PatSeq {
* enough space will be allocated for
* "numPats" patterns. To match, pats[0] must
* match event n, pats[1] must match event
- * n-1, etc.
- */
+ * n-1, etc. */
} PatSeq;
/*
@@ -536,7 +535,7 @@ static Tcl_HashTable eventTable;
#define CIRCREQ 0x400000
#define KEY_BUTTON_MOTION_VIRTUAL (KEY|BUTTON|MOTION|VIRTUAL)
-#define KEY_BUTTON_MOTION_CROSSING (KEY|BUTTON|MOTION|CROSSING|VIRTUAL)
+#define KEY_BUTTON_MOTION_CROSSING (KEY|BUTTON|MOTION|VIRTUAL|CROSSING)
static int flagArray[TK_LASTEVENT] = {
/* Not used */ 0,
@@ -699,7 +698,6 @@ static void DoWarp(ClientData clientData);
*/
#define EvalTclBinding ((TkBindEvalProc *) 1)
-
/*
*---------------------------------------------------------------------------
@@ -741,7 +739,6 @@ TkBindInit(
ModInfo *modPtr;
EventInfo *eiPtr;
int newEntry;
-
#ifdef REDO_KEYSYM_LOOKUP
KeySymInfo *kPtr;
@@ -1087,7 +1084,6 @@ TkCreateBindingProcedure(
}
Tcl_SetHashValue(hPtr, psPtr);
} else {
-
/*
* Free existing callback.
*/
@@ -1326,7 +1322,7 @@ Tk_DeleteAllBindings(
}
for (psPtr = (PatSeq *) Tcl_GetHashValue(hPtr); psPtr != NULL;
psPtr = nextPtr) {
- nextPtr = psPtr->nextObjPtr;
+ nextPtr = psPtr->nextObjPtr;
/*
* Be sure to remove each binding from its hash chain in the pattern
@@ -1421,9 +1417,8 @@ Tk_BindEvent(
Tcl_DString scripts, savedResult;
Detail detail;
char *p, *end;
- PendingBinding *pendingPtr;
- PendingBinding staticPending;
- TkWindow *winPtr = (TkWindow *)tkwin;
+ PendingBinding staticPending, *pendingPtr;
+ TkWindow *winPtr = (TkWindow *) tkwin;
PatternTableKey key;
Tk_ClassModalProc *modalProc;
@@ -1445,12 +1440,12 @@ Tk_BindEvent(
* mega-widget isn't supposed to be visible to people watching the parent.
*/
- if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) {
+ if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) {
if (eventPtr->xcrossing.detail == NotifyInferior) {
return;
}
}
- if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) {
+ if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) {
if (eventPtr->xfocus.detail == NotifyInferior) {
return;
}
@@ -1543,11 +1538,9 @@ Tk_BindEvent(
memset(&key, 0, sizeof(key));
if (ringPtr->type != VirtualEvent) {
- Tcl_HashTable *veptPtr;
+ Tcl_HashTable *veptPtr = &bindInfoPtr->virtualEventTable.patternTable;
Tcl_HashEntry *hPtr;
- veptPtr = &bindInfoPtr->virtualEventTable.patternTable;
-
key.object = NULL;
key.type = ringPtr->type;
key.detail = detail;
@@ -1580,12 +1573,9 @@ Tk_BindEvent(
Tcl_DStringInit(&scripts);
for ( ; numObjects > 0; numObjects--, objectPtr++) {
- PatSeq *matchPtr, *sourcePtr;
+ PatSeq *matchPtr = NULL, *sourcePtr = NULL;
Tcl_HashEntry *hPtr;
- matchPtr = NULL;
- sourcePtr = NULL;
-
/*
* Match the new event against those recorded in the pattern table,
* saving the longest matching pattern. For events with details
@@ -1770,6 +1760,7 @@ Tk_BindEvent(
}
} else {
int len = (int) strlen(p);
+
code = Tcl_EvalEx(interp, p, len, TCL_EVAL_GLOBAL);
p += len;
}
@@ -1962,22 +1953,17 @@ MatchPatterns(
*/
for ( ; psPtr != NULL; psPtr = psPtr->nextSeqPtr) {
- XEvent *eventPtr;
- Pattern *patPtr;
- Window window;
- Detail *detailPtr;
- int patCount, ringCount, flags, state;
- int modMask;
+ XEvent *eventPtr = &bindPtr->eventRing[bindPtr->curEvent];
+ Detail *detailPtr = &bindPtr->detailRing[bindPtr->curEvent];
+ Pattern *patPtr = psPtr->pats;
+ Window window = eventPtr->xany.window;
+ int patCount, ringCount, flags, state, modMask, i;
/*
* Iterate over all the patterns in a sequence to be sure that they
* all match.
*/
- eventPtr = &bindPtr->eventRing[bindPtr->curEvent];
- detailPtr = &bindPtr->detailRing[bindPtr->curEvent];
- window = eventPtr->xany.window;
- patPtr = psPtr->pats;
patCount = psPtr->numPats;
ringCount = EVENT_BUFFER_SIZE;
while (patCount > 0) {
@@ -2013,8 +1999,6 @@ MatchPatterns(
|| (patPtr->eventType == ButtonRelease)) {
if ((eventPtr->xany.type == KeyPress)
|| (eventPtr->xany.type == KeyRelease)) {
- int i;
-
/*
* Ignore key events if they are modifier keys.
*/
@@ -2025,6 +2009,7 @@ MatchPatterns(
/*
* This key is a modifier key, so ignore it.
*/
+
goto nextEvent;
}
}
@@ -2056,8 +2041,6 @@ MatchPatterns(
*/
if (eventPtr->xany.type == KeyPress) {
- int i;
-
for (i = 0; i < dispPtr->numModKeyCodes; i++) {
if (dispPtr->modKeyCodes[i] == eventPtr->xkey.keycode) {
goto nextEvent;
@@ -2067,7 +2050,7 @@ MatchPatterns(
goto nextSequence;
}
flags = flagArray[eventPtr->type];
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
+ if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
state = eventPtr->xkey.state;
} else if (flags & CROSSING) {
state = eventPtr->xcrossing.state;
@@ -2095,10 +2078,9 @@ MatchPatterns(
}
}
if (psPtr->flags & PAT_NEARBY) {
- XEvent *firstPtr;
+ XEvent *firstPtr = &bindPtr->eventRing[bindPtr->curEvent];
int timeDiff;
- firstPtr = &bindPtr->eventRing[bindPtr->curEvent];
timeDiff = (Time) firstPtr->xkey.time - eventPtr->xkey.time;
if ((firstPtr->xkey.x_root
< (eventPtr->xkey.x_root - NEARBY_PIXELS))
@@ -2154,16 +2136,14 @@ MatchPatterns(
hPtr = Tcl_FindHashEntry(&bindPtr->patternTable,
(char *) &key);
if (hPtr != NULL) {
-
/*
* This tag is interested in this virtual event and its
* corresponding physical event is a good match with the
* virtual event's definition.
*/
- PatSeq *virtMatchPtr;
+ PatSeq *virtMatchPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
- virtMatchPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
if ((virtMatchPtr->numPats != 1)
|| (virtMatchPtr->nextSeqPtr != NULL)) {
Tcl_Panic("MatchPattern: badly constructed virtual event");
@@ -2190,7 +2170,6 @@ MatchPatterns(
if (bestPtr != NULL) {
Pattern *patPtr2;
- int i;
if (matchPtr->numPats != bestPtr->numPats) {
if (bestPtr->numPats > matchPtr->numPats) {
@@ -2218,6 +2197,7 @@ MatchPatterns(
}
}
}
+
/*
* Tie goes to current best pattern.
*
@@ -2248,7 +2228,6 @@ MatchPatterns(
*sourcePtrPtr = bestSourcePtr;
return bestPtr;
}
-
/*
*--------------------------------------------------------------
@@ -2376,14 +2355,14 @@ ExpandPercents(
case 'h':
if (flags & EXPOSE) {
number = eventPtr->xexpose.height;
- } else if (flags & (CONFIG)) {
+ } else if (flags & CONFIG) {
number = eventPtr->xconfigure.height;
} else if (flags & CREATE) {
number = eventPtr->xcreatewindow.height;
} else if (flags & CONFIGREQ) {
- number = eventPtr->xconfigurerequest.height;
+ number = eventPtr->xconfigurerequest.height;
} else if (flags & RESIZEREQ) {
- number = eventPtr->xresizerequest.height;
+ number = eventPtr->xresizerequest.height;
} else {
goto doString;
}
@@ -2439,24 +2418,22 @@ ExpandPercents(
}
goto doString;
case 's':
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
+ if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
number = eventPtr->xkey.state;
+ goto doNumber;
} else if (flags & CROSSING) {
number = eventPtr->xcrossing.state;
+ goto doNumber;
} else if (flags & PROP) {
string = TkFindStateString(propNotify,
eventPtr->xproperty.state);
- goto doString;
} else if (flags & VISIBILITY) {
string = TkFindStateString(visNotify,
eventPtr->xvisibility.state);
- goto doString;
- } else {
- goto doString;
}
- goto doNumber;
+ goto doString;
case 't':
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
+ if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
number = (int) eventPtr->xkey.time;
} else if (flags & CROSSING) {
number = (int) eventPtr->xcrossing.time;
@@ -2477,15 +2454,15 @@ ExpandPercents(
} else if (flags & CREATE) {
number = eventPtr->xcreatewindow.width;
} else if (flags & CONFIGREQ) {
- number = eventPtr->xconfigurerequest.width;
+ number = eventPtr->xconfigurerequest.width;
} else if (flags & RESIZEREQ) {
- number = eventPtr->xresizerequest.width;
+ number = eventPtr->xresizerequest.width;
} else {
goto doString;
}
goto doNumber;
case 'x':
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
+ if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
number = eventPtr->xkey.x;
} else if (flags & CROSSING) {
number = eventPtr->xcrossing.x;
@@ -2498,13 +2475,13 @@ ExpandPercents(
} else if (flags & CREATE) {
number = eventPtr->xcreatewindow.x;
} else if (flags & CONFIGREQ) {
- number = eventPtr->xconfigurerequest.x;
+ number = eventPtr->xconfigurerequest.x;
} else {
goto doString;
}
goto doNumber;
case 'y':
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
+ if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
number = eventPtr->xkey.y;
} else if (flags & EXPOSE) {
number = eventPtr->xexpose.y;
@@ -2554,9 +2531,8 @@ ExpandPercents(
goto doNumber;
case 'K':
if (flags & KEY) {
- char *name;
+ char *name = TkKeysymToString(keySym);
- name = TkKeysymToString(keySym);
if (name != NULL) {
string = name;
}
@@ -2663,7 +2639,7 @@ ExpandPercents(
* ChangeScreen --
*
* This function is invoked whenever the current screen changes in an
- * application. It invokes a Tcl function named "tk::ScreenChanged",
+ * application. It invokes a Tcl command named "tk::ScreenChanged",
* passing it the screen name as argument. tk::ScreenChanged does things
* like making the tk::Priv variable point to an array for the current
* display.
@@ -2672,7 +2648,7 @@ ExpandPercents(
* None.
*
* Side effects:
- * Depends on what tk::ScreenChanged does. If an error occurs them
+ * Depends on what tk::ScreenChanged does. If an error occurs then
* bgerror will be invoked.
*
*----------------------------------------------------------------------
@@ -3050,15 +3026,15 @@ DeleteVirtualEvent(
eventPSPtr = FindSequence(interp, &vetPtr->patternTable, NULL,
eventString, 0, 0, &eventMask);
if (eventPSPtr == NULL) {
- const char *string;
+ const char *string = Tcl_GetStringResult(interp);
- string = Tcl_GetStringResult(interp);
return (string[0] != '\0') ? TCL_ERROR : TCL_OK;
}
}
for (iPhys = poPtr->numOwned; --iPhys >= 0; ) {
PatSeq *psPtr = poPtr->patSeqs[iPhys];
+
if ((eventPSPtr == NULL) || (psPtr == eventPSPtr)) {
int iVirt;
VirtualOwners *voPtr;
@@ -3288,7 +3264,7 @@ HandleEventGenerate(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- XEvent event;
+ union {XEvent general; XVirtualEvent virtual;} event;
const char *p;
char *name, *windowName;
int count, flags, synch, i, number, warp;
@@ -3355,43 +3331,43 @@ HandleEventGenerate(
}
memset((void *) &event, 0, sizeof(event));
- event.xany.type = pat.eventType;
- event.xany.serial = NextRequest(Tk_Display(tkwin));
- event.xany.send_event = False;
+ event.general.xany.type = pat.eventType;
+ event.general.xany.serial = NextRequest(Tk_Display(tkwin));
+ event.general.xany.send_event = False;
if (windowName[0]) {
- event.xany.window = Tk_WindowId(tkwin);
+ event.general.xany.window = Tk_WindowId(tkwin);
} else {
- event.xany.window =
+ event.general.xany.window =
RootWindow(Tk_Display(tkwin), Tk_ScreenNumber(tkwin));
}
- event.xany.display = Tk_Display(tkwin);
+ event.general.xany.display = Tk_Display(tkwin);
- flags = flagArray[event.xany.type];
+ flags = flagArray[event.general.xany.type];
if (flags & DESTROY) {
/*
- * Event DesotryNotify should be generated by destroying the window.
+ * Event DestroyNotify should be generated by destroying the window.
*/
Tk_DestroyWindow(tkwin);
return TCL_OK;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- event.xkey.state = pat.needMods;
- if ((flags & KEY) && (event.xany.type != MouseWheelEvent)) {
- TkpSetKeycodeAndState(tkwin, pat.detail.keySym, &event);
+ if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
+ event.general.xkey.state = pat.needMods;
+ if ((flags & KEY) && (event.general.xany.type != MouseWheelEvent)) {
+ TkpSetKeycodeAndState(tkwin, pat.detail.keySym, &event.general);
} else if (flags & BUTTON) {
- event.xbutton.button = pat.detail.button;
+ event.general.xbutton.button = pat.detail.button;
} else if (flags & VIRTUAL) {
- ((XVirtualEvent *) &event)->name = pat.detail.name;
+ event.virtual.name = pat.detail.name;
}
}
if (flags & (CREATE|UNMAP|MAP|REPARENT|CONFIG|GRAVITY|CIRC)) {
- event.xcreatewindow.window = event.xany.window;
+ event.general.xcreatewindow.window = event.general.xany.window;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.x_root = -1;
- event.xkey.y_root = -1;
+ if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ event.general.xkey.x_root = -1;
+ event.general.xkey.y_root = -1;
}
/*
@@ -3431,7 +3407,7 @@ HandleEventGenerate(
if (Tcl_GetBooleanFromObj(interp, valuePtr, &warp) != TCL_OK) {
return TCL_ERROR;
}
- if (!(flags & (KEY_BUTTON_MOTION_VIRTUAL))) {
+ if (!(flags & KEY_BUTTON_MOTION_VIRTUAL)) {
goto badopt;
}
break;
@@ -3451,7 +3427,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & CONFIG) {
- event.xconfigure.above = Tk_WindowId(tkwin2);
+ event.general.xconfigure.above = Tk_WindowId(tkwin2);
} else {
goto badopt;
}
@@ -3461,7 +3437,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & (CREATE|CONFIG)) {
- event.xcreatewindow.border_width = number;
+ event.general.xcreatewindow.border_width = number;
} else {
goto badopt;
}
@@ -3471,7 +3447,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & BUTTON) {
- event.xbutton.button = number;
+ event.general.xbutton.button = number;
} else {
goto badopt;
}
@@ -3481,7 +3457,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & EXPOSE) {
- event.xexpose.count = number;
+ event.general.xexpose.count = number;
} else {
goto badopt;
}
@@ -3503,8 +3479,8 @@ HandleEventGenerate(
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if ((flags & KEY) && (event.xkey.type == MouseWheelEvent)) {
- event.xkey.keycode = number;
+ if ((flags & KEY) && (event.general.xkey.type == MouseWheelEvent)) {
+ event.general.xkey.keycode = number;
} else {
goto badopt;
}
@@ -3516,9 +3492,9 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & FOCUS) {
- event.xfocus.detail = number;
+ event.general.xfocus.detail = number;
} else if (flags & CROSSING) {
- event.xcrossing.detail = number;
+ event.general.xcrossing.detail = number;
} else {
goto badopt;
}
@@ -3528,7 +3504,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & CROSSING) {
- event.xcrossing.focus = number;
+ event.general.xcrossing.focus = number;
} else {
goto badopt;
}
@@ -3539,9 +3515,9 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & EXPOSE) {
- event.xexpose.height = number;
+ event.general.xexpose.height = number;
} else if (flags & CONFIG) {
- event.xconfigure.height = number;
+ event.general.xconfigure.height = number;
} else {
goto badopt;
}
@@ -3550,8 +3526,8 @@ HandleEventGenerate(
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if ((flags & KEY) && (event.xkey.type != MouseWheelEvent)) {
- event.xkey.keycode = number;
+ if ((flags & KEY) && (event.general.xkey.type != MouseWheelEvent)) {
+ event.general.xkey.keycode = number;
} else {
goto badopt;
}
@@ -3568,13 +3544,14 @@ HandleEventGenerate(
return TCL_ERROR;
}
- TkpSetKeycodeAndState(tkwin, keysym, &event);
- if (event.xkey.keycode == 0) {
+ TkpSetKeycodeAndState(tkwin, keysym, &event.general);
+ if (event.general.xkey.keycode == 0) {
Tcl_AppendResult(interp, "no keycode for keysym \"", value,
"\"", NULL);
return TCL_ERROR;
}
- if (!(flags & KEY) || (event.xkey.type == MouseWheelEvent)) {
+ if (!(flags & KEY)
+ || (event.general.xkey.type == MouseWheelEvent)) {
goto badopt;
}
break;
@@ -3585,9 +3562,9 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & CROSSING) {
- event.xcrossing.mode = number;
+ event.general.xcrossing.mode = number;
} else if (flags & FOCUS) {
- event.xfocus.mode = number;
+ event.general.xfocus.mode = number;
} else {
goto badopt;
}
@@ -3597,13 +3574,13 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & CREATE) {
- event.xcreatewindow.override_redirect = number;
+ event.general.xcreatewindow.override_redirect = number;
} else if (flags & MAP) {
- event.xmap.override_redirect = number;
+ event.general.xmap.override_redirect = number;
} else if (flags & REPARENT) {
- event.xreparent.override_redirect = number;
+ event.general.xreparent.override_redirect = number;
} else if (flags & CONFIG) {
- event.xconfigure.override_redirect = number;
+ event.general.xconfigure.override_redirect = number;
} else {
goto badopt;
}
@@ -3614,7 +3591,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & CIRC) {
- event.xcirculate.place = number;
+ event.general.xcirculate.place = number;
} else {
goto badopt;
}
@@ -3623,8 +3600,8 @@ HandleEventGenerate(
if (NameToWindow(interp, tkwin, valuePtr, &tkwin2) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.root = Tk_WindowId(tkwin2);
+ if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ event.general.xkey.root = Tk_WindowId(tkwin2);
} else {
goto badopt;
}
@@ -3633,8 +3610,8 @@ HandleEventGenerate(
if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.x_root = number;
+ if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ event.general.xkey.x_root = number;
} else {
goto badopt;
}
@@ -3643,8 +3620,8 @@ HandleEventGenerate(
if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.y_root = number;
+ if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ event.general.xkey.y_root = number;
} else {
goto badopt;
}
@@ -3667,24 +3644,24 @@ HandleEventGenerate(
return TCL_ERROR;
}
}
- event.xany.send_event = number;
+ event.general.xany.send_event = number;
break;
}
case EVENT_SERIAL:
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- event.xany.serial = number;
+ event.general.xany.serial = number;
break;
case EVENT_STATE:
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
+ if (flags & KEY_BUTTON_MOTION_CROSSING) {
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- event.xkey.state = number;
+ if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
+ event.general.xkey.state = number;
} else {
- event.xcrossing.state = number;
+ event.general.xcrossing.state = number;
}
} else if (flags & VISIBILITY) {
number = TkFindStateNumObj(interp, optionPtr, visNotify,
@@ -3692,7 +3669,7 @@ HandleEventGenerate(
if (number < 0) {
return TCL_ERROR;
}
- event.xvisibility.state = number;
+ event.general.xvisibility.state = number;
} else {
goto badopt;
}
@@ -3701,8 +3678,8 @@ HandleEventGenerate(
if (NameToWindow(interp, tkwin, valuePtr, &tkwin2) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.subwindow = Tk_WindowId(tkwin2);
+ if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ event.general.xkey.subwindow = Tk_WindowId(tkwin2);
} else {
goto badopt;
}
@@ -3711,10 +3688,10 @@ HandleEventGenerate(
if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.time = (Time) number;
+ if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ event.general.xkey.time = (Time) number;
} else if (flags & PROP) {
- event.xproperty.time = (Time) number;
+ event.general.xproperty.time = (Time) number;
} else {
goto badopt;
}
@@ -3724,9 +3701,9 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & EXPOSE) {
- event.xexpose.width = number;
+ event.general.xexpose.width = number;
} else if (flags & (CREATE|CONFIG)) {
- event.xcreatewindow.width = number;
+ event.general.xcreatewindow.width = number;
} else {
goto badopt;
}
@@ -3736,7 +3713,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & (CREATE|UNMAP|MAP|REPARENT|CONFIG|GRAVITY|CIRC)) {
- event.xcreatewindow.window = Tk_WindowId(tkwin2);
+ event.general.xcreatewindow.window = Tk_WindowId(tkwin2);
} else {
goto badopt;
}
@@ -3746,24 +3723,24 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.x = number;
+ event.general.xkey.x = number;
/*
* Only modify rootx as well if it hasn't been changed.
*/
- if (event.xkey.x_root == -1) {
+ if (event.general.xkey.x_root == -1) {
int rootX, rootY;
Tk_GetRootCoords(tkwin, &rootX, &rootY);
- event.xkey.x_root = rootX + number;
+ event.general.xkey.x_root = rootX + number;
}
} else if (flags & EXPOSE) {
- event.xexpose.x = number;
+ event.general.xexpose.x = number;
} else if (flags & (CREATE|CONFIG|GRAVITY)) {
- event.xcreatewindow.x = number;
+ event.general.xcreatewindow.x = number;
} else if (flags & REPARENT) {
- event.xreparent.x = number;
+ event.general.xreparent.x = number;
} else {
goto badopt;
}
@@ -3772,25 +3749,25 @@ HandleEventGenerate(
if (Tk_GetPixelsFromObj(interp,tkwin,valuePtr,&number) != TCL_OK) {
return TCL_ERROR;
}
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.y = number;
+ if (flags & KEY_BUTTON_MOTION_CROSSING) {
+ event.general.xkey.y = number;
/*
* Only modify rooty as well if it hasn't been changed.
*/
- if (event.xkey.y_root == -1) {
+ if (event.general.xkey.y_root == -1) {
int rootX, rootY;
Tk_GetRootCoords(tkwin, &rootX, &rootY);
- event.xkey.y_root = rootY + number;
+ event.general.xkey.y_root = rootY + number;
}
} else if (flags & EXPOSE) {
- event.xexpose.y = number;
+ event.general.xexpose.y = number;
} else if (flags & (CREATE|CONFIG|GRAVITY)) {
- event.xcreatewindow.y = number;
+ event.general.xcreatewindow.y = number;
} else if (flags & REPARENT) {
- event.xreparent.y = number;
+ event.general.xreparent.y = number;
} else {
goto badopt;
}
@@ -3823,9 +3800,9 @@ HandleEventGenerate(
*/
if (synch != 0) {
- Tk_HandleEvent(&event);
+ Tk_HandleEvent(&event.general);
} else {
- Tk_QueueWindowEvent(&event, pos);
+ Tk_QueueWindowEvent(&event.general, pos);
}
/*
@@ -3833,15 +3810,15 @@ HandleEventGenerate(
*/
if ((warp != 0) && Tk_IsMapped(tkwin)) {
- TkDisplay *dispPtr;
- dispPtr = TkGetDisplay(event.xmotion.display);
+ TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);
+
if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
Tcl_DoWhenIdle(DoWarp, (ClientData) dispPtr);
dispPtr->flags |= TK_DISPLAY_IN_WARP;
}
- dispPtr->warpWindow = event.xany.window;
- dispPtr->warpX = event.xkey.x;
- dispPtr->warpY = event.xkey.y;
+ dispPtr->warpWindow = event.general.xany.window;
+ dispPtr->warpX = event.general.xkey.x;
+ dispPtr->warpY = event.general.xkey.y;
}
Tcl_ResetResult(interp);
return TCL_OK;
@@ -4231,6 +4208,7 @@ ParseEventDescription(
*/
char *field = p + 1;
+
p = strchr(field, '>');
if (p == field) {
Tcl_SetResult(interp, "virtual event \"<<>>\" is badly formed",
@@ -4256,6 +4234,7 @@ ParseEventDescription(
while (1) {
ModInfo *modPtr;
+
p = GetField(p, field, FIELD_SIZE);
if (*p == '>') {
/*
@@ -4272,10 +4251,13 @@ ParseEventDescription(
}
modPtr = (ModInfo *) Tcl_GetHashValue(hPtr);
patPtr->needMods |= modPtr->mask;
- if (modPtr->flags & (MULT_CLICKS)) {
+ if (modPtr->flags & MULT_CLICKS) {
int i = modPtr->flags & MULT_CLICKS;
+
count = 2;
- while (i >>= 1) count++;
+ while (i >>= 1) {
+ count++;
+ }
}
while ((*p == '-') || isspace(UCHAR(*p))) {
p++;
@@ -4285,8 +4267,7 @@ ParseEventDescription(
eventFlags = 0;
hPtr = Tcl_FindHashEntry(&eventTable, field);
if (hPtr != NULL) {
- EventInfo *eiPtr;
- eiPtr = (EventInfo *) Tcl_GetHashValue(hPtr);
+ EventInfo *eiPtr = (EventInfo *) Tcl_GetHashValue(hPtr);
patPtr->eventType = eiPtr->type;
eventFlags = flagArray[eiPtr->type];
@@ -4439,7 +4420,6 @@ GetPatternString(
for (patsLeft = psPtr->numPats, patPtr = &psPtr->pats[psPtr->numPats - 1];
patsLeft > 0; patsLeft--, patPtr--) {
-
/*
* Check for simple case of an ASCII character.
*/
@@ -4451,7 +4431,6 @@ GetPatternString(
&& isprint(UCHAR(patPtr->detail.keySym))
&& (patPtr->detail.keySym != '<')
&& (patPtr->detail.keySym != ' ')) {
-
c = (char) patPtr->detail.keySym;
Tcl_DStringAppend(dsPtr, &c, 1);
continue;
@@ -4475,6 +4454,7 @@ GetPatternString(
*/
Tcl_DStringAppend(dsPtr, "<", 1);
+
if ((psPtr->flags & PAT_NEARBY) && (patsLeft > 1)
&& (memcmp((char *) patPtr, (char *) (patPtr-1),
sizeof(Pattern)) == 0)) {
@@ -4496,6 +4476,7 @@ GetPatternString(
Tcl_DStringAppend(dsPtr, "Double-", 7);
}
}
+
for (needMods = patPtr->needMods, modPtr = modArray;
needMods != 0; modPtr++) {
if (modPtr->mask & needMods) {
@@ -4504,6 +4485,7 @@ GetPatternString(
Tcl_DStringAppend(dsPtr, "-", 1);
}
}
+
for (eiPtr = eventArray; eiPtr->name != NULL; eiPtr++) {
if (eiPtr->type == patPtr->eventType) {
Tcl_DStringAppend(dsPtr, eiPtr->name, -1);
@@ -4517,9 +4499,7 @@ GetPatternString(
if (patPtr->detail.clientData != 0) {
if ((patPtr->eventType == KeyPress)
|| (patPtr->eventType == KeyRelease)) {
- char *string;
-
- string = TkKeysymToString(patPtr->detail.keySym);
+ char *string = TkKeysymToString(patPtr->detail.keySym);
if (string != NULL) {
Tcl_DStringAppend(dsPtr, string, -1);
}
@@ -4528,6 +4508,7 @@ GetPatternString(
Tcl_DStringAppend(dsPtr, buffer, -1);
}
}
+
Tcl_DStringAppend(dsPtr, ">", 1);
}
}
@@ -4579,15 +4560,14 @@ TkStringToKeysym(
char *name) /* Name of a keysym. */
{
#ifdef REDO_KEYSYM_LOOKUP
- Tcl_HashEntry *hPtr;
- KeySym keysym;
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&keySymTable, name);
- hPtr = Tcl_FindHashEntry(&keySymTable, name);
if (hPtr != NULL) {
return (KeySym) Tcl_GetHashValue(hPtr);
}
if (strlen(name) == 1) {
- keysym = (KeySym) (unsigned char) name[0];
+ KeySym keysym = (KeySym) (unsigned char) name[0];
+
if (TkKeysymToString(keysym) != NULL) {
return keysym;
}
@@ -4618,13 +4598,13 @@ TkKeysymToString(
KeySym keysym)
{
#ifdef REDO_KEYSYM_LOOKUP
- Tcl_HashEntry *hPtr;
+ Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym);
- hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym);
if (hPtr != NULL) {
return (char *) Tcl_GetHashValue(hPtr);
}
#endif /* REDO_KEYSYM_LOOKUP */
+
return XKeysymToString(keysym);
}
@@ -4642,7 +4622,7 @@ TkKeysymToString(
* completion code and a string in the interp's result.
*
* Side effects:
- * None.
+ * Any; depends on script.
*
*----------------------------------------------------------------------
*/
@@ -4688,6 +4668,7 @@ TkpGetBindingXEvent(
{
TkWindow *winPtr = (TkWindow *) Tk_MainWindow(interp);
BindingTable *bindPtr = (BindingTable *) winPtr->mainPtr->bindingTable;
+
return &(bindPtr->eventRing[bindPtr->curEvent]);
}