summaryrefslogtreecommitdiffstats
path: root/generic/tkBind.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkBind.c')
-rw-r--r--generic/tkBind.c151
1 files changed, 75 insertions, 76 deletions
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 0213111..395fca3 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.55 2009/07/23 22:21:35 dkf Exp $
+ * RCS: @(#) $Id: tkBind.c,v 1.56 2009/08/09 21:20:33 nijtmans Exp $
*/
#include "tkInt.h"
@@ -3253,7 +3253,7 @@ HandleEventGenerate(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- XEvent event;
+ union {XEvent general; XVirtualEvent virtual;} event;
const char *p;
const char *name, *windowName;
int count, flags, synch, i, number, warp;
@@ -3321,18 +3321,18 @@ HandleEventGenerate(
}
memset(&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.
@@ -3342,26 +3342,26 @@ HandleEventGenerate(
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);
+ 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_CROSSING) {
- event.xkey.x_root = -1;
- event.xkey.y_root = -1;
+ event.general.xkey.x_root = -1;
+ event.general.xkey.y_root = -1;
}
- if (event.xany.type == FocusIn || event.xany.type == FocusOut) {
- event.xany.send_event = GENERATED_FOCUS_EVENT_MAGIC;
+ if (event.general.xany.type == FocusIn || event.general.xany.type == FocusOut) {
+ event.general.xany.send_event = GENERATED_FOCUS_EVENT_MAGIC;
}
/*
@@ -3421,7 +3421,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & CONFIG) {
- event.xconfigure.above = Tk_WindowId(tkwin2);
+ event.general.xconfigure.above = Tk_WindowId(tkwin2);
} else {
goto badopt;
}
@@ -3431,7 +3431,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & (CREATE|CONFIG)) {
- event.xcreatewindow.border_width = number;
+ event.general.xcreatewindow.border_width = number;
} else {
goto badopt;
}
@@ -3441,7 +3441,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & BUTTON) {
- event.xbutton.button = number;
+ event.general.xbutton.button = number;
} else {
goto badopt;
}
@@ -3451,7 +3451,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & EXPOSE) {
- event.xexpose.count = number;
+ event.general.xexpose.count = number;
} else {
goto badopt;
}
@@ -3473,8 +3473,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;
}
@@ -3486,9 +3486,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;
}
@@ -3498,7 +3498,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & CROSSING) {
- event.xcrossing.focus = number;
+ event.general.xcrossing.focus = number;
} else {
goto badopt;
}
@@ -3509,9 +3509,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;
}
@@ -3520,8 +3520,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;
}
@@ -3538,13 +3538,13 @@ 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;
@@ -3555,9 +3555,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;
}
@@ -3567,13 +3567,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;
}
@@ -3584,7 +3584,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & CIRC) {
- event.xcirculate.place = number;
+ event.general.xcirculate.place = number;
} else {
goto badopt;
}
@@ -3594,7 +3594,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION_CROSSING) {
- event.xkey.root = Tk_WindowId(tkwin2);
+ event.general.xkey.root = Tk_WindowId(tkwin2);
} else {
goto badopt;
}
@@ -3604,7 +3604,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION_CROSSING) {
- event.xkey.x_root = number;
+ event.general.xkey.x_root = number;
} else {
goto badopt;
}
@@ -3614,7 +3614,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION_CROSSING) {
- event.xkey.y_root = number;
+ event.general.xkey.y_root = number;
} else {
goto badopt;
}
@@ -3637,14 +3637,14 @@ 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_CROSSING) {
@@ -3652,9 +3652,9 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION_VIRTUAL) {
- event.xkey.state = number;
+ event.general.xkey.state = number;
} else {
- event.xcrossing.state = number;
+ event.general.xcrossing.state = number;
}
} else if (flags & VISIBILITY) {
number = TkFindStateNumObj(interp, optionPtr, visNotify,
@@ -3662,7 +3662,7 @@ HandleEventGenerate(
if (number < 0) {
return TCL_ERROR;
}
- event.xvisibility.state = number;
+ event.general.xvisibility.state = number;
} else {
goto badopt;
}
@@ -3672,7 +3672,7 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION_CROSSING) {
- event.xkey.subwindow = Tk_WindowId(tkwin2);
+ event.general.xkey.subwindow = Tk_WindowId(tkwin2);
} else {
goto badopt;
}
@@ -3682,9 +3682,9 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION_CROSSING) {
- event.xkey.time = (Time) number;
+ event.general.xkey.time = (Time) number;
} else if (flags & PROP) {
- event.xproperty.time = (Time) number;
+ event.general.xproperty.time = (Time) number;
} else {
goto badopt;
}
@@ -3694,9 +3694,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;
}
@@ -3706,7 +3706,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;
}
@@ -3716,24 +3716,24 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION_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;
}
@@ -3743,24 +3743,24 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & KEY_BUTTON_MOTION_CROSSING) {
- event.xkey.y = number;
+ 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;
}
@@ -3774,7 +3774,6 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (userDataObj != NULL) {
- XVirtualEvent *vePtr = (XVirtualEvent *) &event;
/*
* Must be virtual event to set that variable to non-NULL. Now we want
@@ -3783,7 +3782,7 @@ HandleEventGenerate(
* refcount will be decremented once the event has been processed.
*/
- vePtr->user_data = userDataObj;
+ event.virtual.user_data = userDataObj;
Tcl_IncrRefCount(userDataObj);
}
@@ -3793,9 +3792,9 @@ HandleEventGenerate(
*/
if (synch != 0) {
- Tk_HandleEvent(&event);
+ Tk_HandleEvent(&event.general);
} else {
- Tk_QueueWindowEvent(&event, pos);
+ Tk_QueueWindowEvent(&event.general, pos);
}
/*
@@ -3803,15 +3802,15 @@ HandleEventGenerate(
*/
if ((warp != 0) && Tk_IsMapped(tkwin)) {
- TkDisplay *dispPtr = TkGetDisplay(event.xmotion.display);
+ TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display);
if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
Tcl_DoWhenIdle(DoWarp, 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;