summaryrefslogtreecommitdiffstats
path: root/src/bltGrBind.C
diff options
context:
space:
mode:
authorjoye <joye>2013-09-04 20:46:48 (GMT)
committerjoye <joye>2013-09-04 20:46:48 (GMT)
commitaf269cb12600825b84ed061d9d7ef45dd367e155 (patch)
tree9aeb01b9c5df3d07606c60b68bb6daf7345bdb21 /src/bltGrBind.C
parentdea297e10928d20d47a48e2fba1aed96161961bd (diff)
downloadblt-af269cb12600825b84ed061d9d7ef45dd367e155.zip
blt-af269cb12600825b84ed061d9d7ef45dd367e155.tar.gz
blt-af269cb12600825b84ed061d9d7ef45dd367e155.tar.bz2
*** empty log message ***
Diffstat (limited to 'src/bltGrBind.C')
-rw-r--r--src/bltGrBind.C1027
1 files changed, 0 insertions, 1027 deletions
diff --git a/src/bltGrBind.C b/src/bltGrBind.C
index d4d189c..fbdbc22 100644
--- a/src/bltGrBind.C
+++ b/src/bltGrBind.C
@@ -34,9 +34,6 @@ static Tk_EventProc BindProc;
typedef struct _Blt_BindTable BindTable;
-/* Make button presses on objects have implicit grab. */
-#define FULLY_SIMULATE_GRAB 1
-
/*
* Binding table procedures.
*/
@@ -748,41 +745,6 @@ typedef struct {
#define META_MASK (AnyModifier<<1)
#define ALT_MASK (AnyModifier<<2)
-static EventModifier eventModifiers[] = {
- {"Alt", ALT_MASK, 0},
- {"Any", 0, 0}, /* Ignored: historical relic. */
- {"B1", Button1Mask, 0},
- {"B2", Button2Mask, 0},
- {"B3", Button3Mask, 0},
- {"B4", Button4Mask, 0},
- {"B5", Button5Mask, 0},
- {"Button1", Button1Mask, 0},
- {"Button2", Button2Mask, 0},
- {"Button3", Button3Mask, 0},
- {"Button4", Button4Mask, 0},
- {"Button5", Button5Mask, 0},
- {"Command", Mod1Mask, 0},
- {"Control", ControlMask, 0},
- {"Double", 0, DOUBLE},
- {"Lock", LockMask, 0},
- {"M", META_MASK, 0},
- {"M1", Mod1Mask, 0},
- {"M2", Mod2Mask, 0},
- {"M3", Mod3Mask, 0},
- {"M4", Mod4Mask, 0},
- {"M5", Mod5Mask, 0},
- {"Meta", META_MASK, 0},
- {"Mod1", Mod1Mask, 0},
- {"Mod2", Mod2Mask, 0},
- {"Mod3", Mod3Mask, 0},
- {"Mod4", Mod4Mask, 0},
- {"Mod5", Mod5Mask, 0},
- {"Option", Mod2Mask, 0},
- {"Quadruple", 0, QUADRUPLE},
- {"Shift", ShiftMask, 0},
- {"Triple", 0, TRIPLE},
-};
-
typedef struct {
const char *name; /* Name of event. */
int type; /* Event type for X, such as
@@ -799,39 +761,6 @@ typedef struct {
* asked about button events.
*/
-static EventInfo events[] = {
- {"Activate", ActivateNotify, ActivateMask},
- {"Button", ButtonPress, ButtonPressMask},
- {"ButtonPress", ButtonPress, ButtonPressMask},
- {"ButtonRelease", ButtonRelease, ButtonPressMask|ButtonReleaseMask},
- {"Circulate", CirculateNotify, StructureNotifyMask},
- {"CirculateRequest", CirculateRequest, SubstructureRedirectMask},
- {"Colormap", ColormapNotify, ColormapChangeMask},
- {"Configure", ConfigureNotify, StructureNotifyMask},
- {"ConfigureRequest", ConfigureRequest, SubstructureRedirectMask},
- {"Create", CreateNotify, SubstructureNotifyMask},
- {"Deactivate", DeactivateNotify, ActivateMask},
- {"Destroy", DestroyNotify, StructureNotifyMask},
- {"Enter", EnterNotify, EnterWindowMask},
- {"Expose", Expose, ExposureMask},
- {"FocusIn", FocusIn, FocusChangeMask},
- {"FocusOut", FocusOut, FocusChangeMask},
- {"Gravity", GravityNotify, StructureNotifyMask},
- {"Key", KeyPress, KeyPressMask},
- {"KeyPress", KeyPress, KeyPressMask},
- {"KeyRelease", KeyRelease, KeyPressMask|KeyReleaseMask},
- {"Leave", LeaveNotify, LeaveWindowMask},
- {"Map", MapNotify, StructureNotifyMask},
- {"MapRequest", MapRequest, SubstructureRedirectMask},
- {"Motion", MotionNotify, ButtonPressMask|PointerMotionMask},
- {"MouseWheel", MouseWheelEvent, MouseWheelMask},
- {"Property", PropertyNotify, PropertyChangeMask},
- {"Reparent", ReparentNotify, StructureNotifyMask},
- {"ResizeRequest", ResizeRequest, ResizeRedirectMask},
- {"Unmap", UnmapNotify, StructureNotifyMask},
- {"Visibility", VisibilityNotify, VisibilityChangeMask},
-};
-
/*
* The defines and table below are used to classify events into
* various groups. The reason for this is that logically identical
@@ -867,960 +796,4 @@ static EventInfo events[] = {
#define KEY_BUTTON_MOTION_VIRTUAL (KEY|BUTTON|MOTION|VIRTUAL)
#define KEY_BUTTON_MOTION_CROSSING (KEY|BUTTON|MOTION|CROSSING|VIRTUAL)
-static int flagArray[TK_LASTEVENT+1] = {
- /* Not used */ 0,
- /* Not used */ 0,
- /* KeyPress */ KEY,
- /* KeyRelease */ KEY,
- /* ButtonPress */ BUTTON,
- /* ButtonRelease */ BUTTON,
- /* MotionNotify */ MOTION,
- /* EnterNotify */ CROSSING,
- /* LeaveNotify */ CROSSING,
- /* FocusIn */ FOCUS,
- /* FocusOut */ FOCUS,
- /* KeymapNotify */ 0,
- /* Expose */ EXPOSE,
- /* GraphicsExpose */ EXPOSE,
- /* NoExpose */ 0,
- /* VisibilityNotify */ VISIBILITY,
- /* CreateNotify */ CREATE,
- /* DestroyNotify */ DESTROY,
- /* UnmapNotify */ UNMAP,
- /* MapNotify */ MAP,
- /* MapRequest */ MAPREQ,
- /* ReparentNotify */ REPARENT,
- /* ConfigureNotify */ CONFIG,
- /* ConfigureRequest */ CONFIGREQ,
- /* GravityNotify */ GRAVITY,
- /* ResizeRequest */ RESIZEREQ,
- /* CirculateNotify */ CIRC,
- /* CirculateRequest */ 0,
- /* PropertyNotify */ PROP,
- /* SelectionClear */ 0,
- /* SelectionRequest */ 0,
- /* SelectionNotify */ 0,
- /* ColormapNotify */ COLORMAP,
- /* ClientMessage */ 0,
- /* MappingNotify */ 0,
-#ifdef GenericEvent
- /* GenericEvent */ 0,
-#endif
- /* VirtualEvent */ VIRTUAL,
- /* Activate */ ACTIVATE,
- /* Deactivate */ ACTIVATE,
- /* MouseWheel */ KEY
-};
-
-static EventModifier *
-FindModifier(const char *string)
-{
- int high, low;
- char c;
-
- low = 0;
- high = (sizeof(eventModifiers) / sizeof(EventModifier)) - 1;
- c = string[0];
- while (low <= high) {
- EventModifier *modPtr;
- int compare;
- int median;
-
- median = (low + high) >> 1;
- modPtr = eventModifiers + median;
-
- /* Test the first character */
- compare = c - modPtr->name[0];
- if (compare == 0) {
- compare = strcmp(string, modPtr->name);
- }
- if (compare < 0) {
- high = median - 1;
- } else if (compare > 0) {
- low = median + 1;
- } else {
- return modPtr; /* Modifier found. */
- }
- }
- return NULL; /* Can't find modifier */
-}
-
-static EventInfo *
-FindEvent(const char *string)
-{
- int high, low;
- char c;
-
- low = 0;
- high = (sizeof(events) / sizeof(EventInfo)) - 1;
- c = string[0];
- while (low <= high) {
- EventInfo *infoPtr;
- int compare;
- int median;
-
- median = (low + high) >> 1;
- infoPtr = events + median;
-
- /* Test the first character */
- compare = c - infoPtr->name[0];
- if (compare == 0) {
- compare = strcmp(string, infoPtr->name);
- }
- if (compare < 0) {
- high = median - 1;
- } else if (compare > 0) {
- low = median + 1;
- } else {
- return infoPtr; /* Event found. */
- }
- }
- return NULL; /* Can't find event. */
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * GetField --
- *
- * Used to parse pattern descriptions. Copies up to
- * size characters from p to copy, stopping at end of
- * string, space, "-", ">", or whenever size is
- * exceeded.
- *
- * Results:
- * The return value is a pointer to the character just
- * after the last one copied (usually "-" or space or
- * ">", but could be anything if size was exceeded).
- * Also places NULL-terminated string (up to size
- * character, including NULL), at copy.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static char *
-GetField(p, copy, size)
- char *p; /* Pointer to part of pattern. */
- char *copy; /* Place to copy field. */
- int size; /* Maximum number of characters to
- * copy. */
-{
- while ((*p != '\0') && !isspace(UCHAR(*p)) && (*p != '>')
- && (*p != '-') && (size > 1)) {
- *copy = *p;
- p++;
- copy++;
- size--;
- }
- *copy = '\0';
- return p;
-}
-
-static int
-ParseEventDescription(Tcl_Interp *interp, const char **eventStringPtr,
- Pattern *patPtr, unsigned long *eventMaskPtr)
-{
- char *p;
- unsigned long eventMask;
- int count, eventFlags;
-#define FIELD_SIZE 48
- char field[FIELD_SIZE];
- EventInfo *infoPtr;
-
- Tcl_DString copy;
- Tcl_DStringInit(&copy);
- p = Tcl_DStringAppend(&copy, *eventStringPtr, -1);
-
- patPtr->eventType = -1;
- patPtr->needMods = 0;
- patPtr->detail.clientData = 0;
-
- eventMask = 0;
- count = 1;
-
- /*
- * Handle simple ASCII characters.
- */
-
- if (*p != '<') {
- char string[2];
-
- patPtr->eventType = KeyPress;
- eventMask = KeyPressMask;
- string[0] = *p;
- string[1] = 0;
- patPtr->detail.keySym = XStringToKeysym(string);
- if (patPtr->detail.keySym == NoSymbol) {
- if (isprint(UCHAR(*p))) {
- patPtr->detail.keySym = *p;
- } else {
- char buf[64];
-
- sprintf(buf, "bad ASCII character 0x%x", (unsigned char) *p);
- Tcl_SetResult(interp, buf, TCL_VOLATILE);
- count = 0;
- goto done;
- }
- }
- p++;
- goto end;
- }
-
- /*
- * A physical event description consists of:
- *
- * 1. open angle bracket.
- * 2. any number of modifiers, each followed by spaces
- * or dashes.
- * 3. an optional event name.
- * 4. an option button or keysym name. Either this or
- * item 3 *must* be present; if both are present
- * then they are separated by spaces or dashes.
- * 5. a close angle bracket.
- */
-
- p++;
-
- while (1) {
- EventModifier *modPtr;
- p = GetField(p, field, FIELD_SIZE);
- if (*p == '>') {
- /*
- * This solves the problem of, e.g., <Control-M> being
- * misinterpreted as Control + Meta + missing keysym
- * instead of Control + KeyPress + M.
- */
- break;
- }
- modPtr = FindModifier(field);
- if (modPtr == NULL) {
- break;
- }
- patPtr->needMods |= modPtr->mask;
- if (modPtr->flags & (MULT_CLICKS)) {
- int i = modPtr->flags & MULT_CLICKS;
- count = 2;
- while (i >>= 1) count++;
- }
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- }
-
- eventFlags = 0;
- infoPtr = FindEvent(field);
- if (infoPtr != NULL) {
- patPtr->eventType = infoPtr->type;
- eventFlags = flagArray[infoPtr->type];
- eventMask = infoPtr->eventMask;
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- p = GetField(p, field, FIELD_SIZE);
- }
- if (*field != '\0') {
- if ((*field >= '1') && (*field <= '5') && (field[1] == '\0')) {
- if (eventFlags == 0) {
- patPtr->eventType = ButtonPress;
- eventMask = ButtonPressMask;
- } else if (eventFlags & KEY) {
- goto getKeysym;
- } else if ((eventFlags & BUTTON) == 0) {
- Tcl_AppendResult(interp, "specified button \"", field,
- "\" for non-button event", (char *) NULL);
- count = 0;
- goto done;
- }
- patPtr->detail.button = (*field - '0');
- } else {
- getKeysym:
- patPtr->detail.keySym = XStringToKeysym(field);
- if (patPtr->detail.keySym == NoSymbol) {
- Tcl_AppendResult(interp, "bad event type or keysym \"",
- field, "\"", (char *)NULL);
- count = 0;
- goto done;
- }
- if (eventFlags == 0) {
- patPtr->eventType = KeyPress;
- eventMask = KeyPressMask;
- } else if ((eventFlags & KEY) == 0) {
- Tcl_AppendResult(interp, "specified keysym \"", field,
- "\" for non-key event", (char *)NULL);
- count = 0;
- goto done;
- }
- }
- } else if (eventFlags == 0) {
- Tcl_AppendResult(interp, "no event type or button # or keysym",
- (char *)NULL);
- count = 0;
- goto done;
- }
-
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- if (*p != '>') {
- while (*p != '\0') {
- p++;
- if (*p == '>') {
- Tcl_AppendResult(interp,
- "extra characters after detail in binding",
- (char *)NULL);
- count = 0;
- goto done;
- }
- }
- Tcl_AppendResult(interp, "missing \">\" in binding", (char *)NULL);
- count = 0;
- goto done;
- }
- p++;
-
-end:
- *eventStringPtr += (p - Tcl_DStringValue(&copy));
- *eventMaskPtr |= eventMask;
-done:
- Tcl_DStringFree(&copy);
- return count;
-}
-
-typedef struct {
- int numKey; /* Integer representation of a value. */
- const char *strKey; /* String representation of a value. */
-} TkStateMap;
-
-static TkStateMap notifyMode[] = {
- {NotifyNormal, "NotifyNormal"},
- {NotifyGrab, "NotifyGrab"},
- {NotifyUngrab, "NotifyUngrab"},
- {NotifyWhileGrabbed, "NotifyWhileGrabbed"},
- {-1, NULL}
-};
-
-static TkStateMap notifyDetail[] = {
- {NotifyAncestor, "NotifyAncestor"},
- {NotifyVirtual, "NotifyVirtual"},
- {NotifyInferior, "NotifyInferior"},
- {NotifyNonlinear, "NotifyNonlinear"},
- {NotifyNonlinearVirtual, "NotifyNonlinearVirtual"},
- {NotifyPointer, "NotifyPointer"},
- {NotifyPointerRoot, "NotifyPointerRoot"},
- {NotifyDetailNone, "NotifyDetailNone"},
- {-1, NULL}
-};
-
-static TkStateMap circPlace[] = {
- {PlaceOnTop, "PlaceOnTop"},
- {PlaceOnBottom, "PlaceOnBottom"},
- {-1, NULL}
-};
-
-static TkStateMap visNotify[] = {
- {VisibilityUnobscured, "VisibilityUnobscured"},
- {VisibilityPartiallyObscured, "VisibilityPartiallyObscured"},
- {VisibilityFullyObscured, "VisibilityFullyObscured"},
- {-1, NULL}
-};
-
-static TkStateMap configureRequestDetail[] = {
- {None, "None"},
- {Above, "Above"},
- {Below, "Below"},
- {BottomIf, "BottomIf"},
- {TopIf, "TopIf"},
- {Opposite, "Opposite"},
- {-1, NULL}
-};
-
-static TkStateMap propNotify[] = {
- {PropertyNewValue, "NewValue"},
- {PropertyDelete, "Delete"},
- {-1, NULL}
-};
-
-/*
- *---------------------------------------------------------------------------
- *
- * HandleEventGenerate --
- *
- * Helper function for the "event generate" command. Generate and
- * process an XEvent, constructed from information parsed from the
- * event description string and its optional arguments.
- *
- * argv[0] contains name of the target window.
- * argv[1] contains pattern string for one event (e.g, <Control-v>).
- * argv[2..argc-1] contains -field/option pairs for specifying
- * additional detail in the generated event.
- *
- * Either virtual or physical events can be generated this way.
- * The event description string must contain the specification
- * for only one event.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When constructing the event,
- * event.xany.serial is filled with the current X serial number.
- * event.xany.window is filled with the target window.
- * event.xany.display is filled with the target window's display.
- * Any other fields in eventPtr which are not specified by the pattern
- * string or the optional arguments, are set to 0.
- *
- * The event may be handled sychronously or asynchronously, depending
- * on the value specified by the optional "-when" option. The
- * default setting is synchronous.
- *
- *---------------------------------------------------------------------------
- */
-static int
-SendEventCmd(ClientData clientData, Tcl_Interp *interp, int objc,
- Tcl_Obj *const *objv)
-{
- XEvent event;
- CONST char *p;
- char *name;
- Window window;
- Display *display;
- Tk_Window tkwin;
- int count, flags, synch, i, number, warp;
- Tcl_QueuePosition pos;
- Pattern pat;
- unsigned long eventMask;
- static CONST char *fieldStrings[] = {
- "-when", "-above", "-borderwidth", "-button",
- "-count", "-delta", "-detail", "-focus",
- "-height",
- "-keycode", "-keysym", "-mode", "-override",
- "-place", "-root", "-rootx", "-rooty",
- "-sendevent", "-serial", "-state", "-subwindow",
- "-time", "-warp", "-width", "-window",
- "-x", "-y", NULL
- };
- enum field {
- EVENT_WHEN, EVENT_ABOVE, EVENT_BORDER, EVENT_BUTTON,
- EVENT_COUNT, EVENT_DELTA, EVENT_DETAIL, EVENT_FOCUS,
- EVENT_HEIGHT,
- EVENT_KEYCODE, EVENT_KEYSYM, EVENT_MODE, EVENT_OVERRIDE,
- EVENT_PLACE, EVENT_ROOT, EVENT_ROOTX, EVENT_ROOTY,
- EVENT_SEND, EVENT_SERIAL, EVENT_STATE, EVENT_SUBWINDOW,
- EVENT_TIME, EVENT_WARP, EVENT_WIDTH, EVENT_WINDOW,
- EVENT_X, EVENT_Y
- };
- tkwin = Tk_MainWindow(interp);
- if (Blt_GetWindowFromObj(interp, objv[1], &window) != TCL_OK) {
- return TCL_ERROR;
- }
- name = Tcl_GetStringFromObj(objv[2], NULL);
-
- display = Tk_Display(tkwin);
- p = name;
- eventMask = 0;
- count = ParseEventDescription(interp, &p, &pat, &eventMask);
- if (count == 0) {
- return TCL_ERROR;
- }
- if (count != 1) {
- Tcl_AppendResult(interp, "Double or Triple modifier not allowed",
- (char *)NULL);
- return TCL_ERROR;
- }
- if (*p != '\0') {
- Tcl_AppendResult(interp, "only one event specification allowed",
- (char *)NULL);
- return TCL_ERROR;
- }
-
- memset((VOID *) &event, 0, sizeof(event));
- event.xany.type = pat.eventType;
- event.xany.serial = NextRequest(display);
- event.xany.send_event = False;
- event.xany.window = window;
- event.xany.display = display;
-
- flags = flagArray[event.xany.type];
- if (flags & DESTROY) {
- /*
- * Event DestroyNotify should be generated by destroying
- * the window.
- */
- XDestroyWindow(display, window);
- 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);
- } else if (flags & BUTTON) {
- event.xbutton.button = pat.detail.button;
- } else if (flags & VIRTUAL) {
- ((XVirtualEvent *) &event)->name = pat.detail.name;
- }
- }
- if (flags & (CREATE|UNMAP|MAP|REPARENT|CONFIG|GRAVITY|CIRC)) {
- event.xcreatewindow.window = event.xany.window;
- }
-
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.x_root = -1;
- event.xkey.y_root = -1;
- }
-
- /*
- * Process the remaining arguments to fill in additional fields
- * of the event.
- */
-
- synch = 1;
- warp = 0;
- pos = TCL_QUEUE_TAIL;
- for (i = 3; i < objc; i += 2) {
- Tcl_Obj *optionPtr, *valuePtr;
- int index;
-
- optionPtr = objv[i];
- valuePtr = objv[i + 1];
-
- if (Tcl_GetIndexFromObj(interp, optionPtr, fieldStrings, "option",
- TCL_EXACT, &index) != TCL_OK) {
- return TCL_ERROR;
- }
- if ((objc & 1) == 0) {
- /*
- * This test occurs after Tcl_GetIndexFromObj() so that
- * "event generate <Button> -xyz" will return the error message
- * that "-xyz" is a bad option, rather than that the value
- * for "-xyz" is missing.
- */
-
- Tcl_AppendResult(interp, "value for \"",
- Tcl_GetStringFromObj(optionPtr, NULL), "\" missing",
- (char *)NULL);
- return TCL_ERROR;
- }
-
- switch ((enum field) index) {
- case EVENT_WARP: {
- if (Tcl_GetBooleanFromObj(interp, valuePtr, &warp) != TCL_OK) {
- return TCL_ERROR;
- }
- if (!(flags & (KEY_BUTTON_MOTION_VIRTUAL))) {
- goto badopt;
- }
- break;
- }
- case EVENT_WHEN: {
-#ifdef notdef
- pos = (Tcl_QueuePosition) TkFindStateNumObj(interp, optionPtr,
- queuePosition, valuePtr);
- if ((int) pos < -1) {
- return TCL_ERROR;
- }
- synch = 0;
- if ((int) pos == -1) {
- synch = 1;
- }
-#endif
- break;
- }
- case EVENT_ABOVE: {
- Window window2;
-
- if (Blt_GetWindowFromObj(interp, valuePtr, &window2) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & CONFIG) {
- event.xconfigure.above = window2;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_BORDER: {
- if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number)!=TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (CREATE|CONFIG)) {
- event.xcreatewindow.border_width = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_BUTTON: {
- if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & BUTTON) {
- event.xbutton.button = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_COUNT: {
- if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & EXPOSE) {
- event.xexpose.count = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_DELTA: {
- if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if ((flags & KEY) && (event.xkey.type == MouseWheelEvent)) {
- event.xkey.keycode = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_DETAIL: {
- number = TkFindStateNumObj(interp, optionPtr, notifyDetail,
- valuePtr);
- if (number < 0) {
- return TCL_ERROR;
- }
- if (flags & FOCUS) {
- event.xfocus.detail = number;
- } else if (flags & CROSSING) {
- event.xcrossing.detail = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_FOCUS: {
- if (Tcl_GetBooleanFromObj(interp, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & CROSSING) {
- event.xcrossing.focus = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_HEIGHT: {
- if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & EXPOSE) {
- event.xexpose.height = number;
- } else if (flags & CONFIG) {
- event.xconfigure.height = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_KEYCODE: {
- if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if ((flags & KEY) && (event.xkey.type != MouseWheelEvent)) {
- event.xkey.keycode = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_KEYSYM: {
- KeySym keysym;
- char *value;
-
- value = Tcl_GetStringFromObj(valuePtr, NULL);
- keysym = TkStringToKeysym(value);
- if (keysym == NoSymbol) {
- Tcl_AppendResult(interp, "unknown keysym \"", value, "\"",
- (char *)NULL);
- return TCL_ERROR;
- }
-
- TkpSetKeycodeAndState(tkwin, keysym, &event);
- if (event.xkey.keycode == 0) {
- Tcl_AppendResult(interp, "no keycode for keysym \"", value,
- "\"", (char *)NULL);
- return TCL_ERROR;
- }
- if (!(flags & KEY) || (event.xkey.type == MouseWheelEvent)) {
- goto badopt;
- }
- break;
- }
- case EVENT_MODE: {
- number = TkFindStateNumObj(interp, optionPtr, notifyMode,
- valuePtr);
- if (number < 0) {
- return TCL_ERROR;
- }
- if (flags & CROSSING) {
- event.xcrossing.mode = number;
- } else if (flags & FOCUS) {
- event.xfocus.mode = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_OVERRIDE: {
- if (Tcl_GetBooleanFromObj(interp, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & CREATE) {
- event.xcreatewindow.override_redirect = number;
- } else if (flags & MAP) {
- event.xmap.override_redirect = number;
- } else if (flags & REPARENT) {
- event.xreparent.override_redirect = number;
- } else if (flags & CONFIG) {
- event.xconfigure.override_redirect = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_PLACE: {
- number = TkFindStateNumObj(interp, optionPtr, circPlace,
- valuePtr);
- if (number < 0) {
- return TCL_ERROR;
- }
- if (flags & CIRC) {
- event.xcirculate.place = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_ROOT: {
- Window window2;
-
- if (Blt_GetWindowFromObj(interp, valuePtr, &window2) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.root = window2;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_ROOTX: {
- if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.x_root = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_ROOTY: {
- if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.y_root = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_SEND: {
- CONST char *value;
-
- value = Tcl_GetStringFromObj(valuePtr, NULL);
- if (isdigit(UCHAR(value[0]))) {
- /*
- * Allow arbitrary integer values for the field; they
- * are needed by a few of the tests in the Tk test suite.
- */
-
- if (Tcl_GetIntFromObj(interp, valuePtr, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- if (Tcl_GetBooleanFromObj(interp, valuePtr, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- }
- event.xany.send_event = number;
- break;
- }
- case EVENT_SERIAL: {
- if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- event.xany.serial = number;
- break;
- }
- case EVENT_STATE: {
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- if (Tcl_GetIntFromObj(interp, valuePtr, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- event.xkey.state = number;
- } else {
- event.xcrossing.state = number;
- }
- } else if (flags & VISIBILITY) {
- number = TkFindStateNumObj(interp, optionPtr, visNotify,
- valuePtr);
- if (number < 0) {
- return TCL_ERROR;
- }
- event.xvisibility.state = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_SUBWINDOW: {
- Window window2;
-
- if (Blt_GetWindowFromObj(interp, valuePtr, &window2) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.subwindow = window2;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_TIME: {
- if (Tcl_GetIntFromObj(interp, valuePtr, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.time = (Time) number;
- } else if (flags & PROP) {
- event.xproperty.time = (Time) number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_WIDTH: {
- if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & EXPOSE) {
- event.xexpose.width = number;
- } else if (flags & (CREATE|CONFIG)) {
- event.xcreatewindow.width = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_WINDOW: {
- Window window2;
-
- if (Blt_GetWindowFromObj(interp, valuePtr, &window2) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (CREATE|UNMAP|MAP|REPARENT|CONFIG
- |GRAVITY|CIRC)) {
- event.xcreatewindow.window = window2;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_X: {
- if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.x = number;
- /*
- * Only modify rootx as well if it hasn't been changed.
- */
- if (event.xkey.x_root == -1) {
- int rootX, rootY;
-
- Tk_GetRootCoords(tkwin, &rootX, &rootY);
- event.xkey.x_root = rootX + number;
- }
- } else if (flags & EXPOSE) {
- event.xexpose.x = number;
- } else if (flags & (CREATE|CONFIG|GRAVITY)) {
- event.xcreatewindow.x = number;
- } else if (flags & REPARENT) {
- event.xreparent.x = number;
- } else {
- goto badopt;
- }
- break;
- }
- case EVENT_Y: {
- if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.y = number;
- /*
- * Only modify rooty as well if it hasn't been changed.
- */
- if (event.xkey.y_root == -1) {
- int rootX, rootY;
-
- Tk_GetRootCoords(tkwin, &rootX, &rootY);
- event.xkey.y_root = rootY + number;
- }
- } else if (flags & EXPOSE) {
- event.xexpose.y = number;
- } else if (flags & (CREATE|CONFIG|GRAVITY)) {
- event.xcreatewindow.y = number;
- } else if (flags & REPARENT) {
- event.xreparent.y = number;
- } else {
- goto badopt;
- }
- break;
- }
- }
- continue;
-
- badopt:
- Tcl_AppendResult(interp, name, " event doesn't accept \"",
- Tcl_GetStringFromObj(optionPtr, NULL), "\" option",
- (char *)NULL);
- return TCL_ERROR;
- }
- if (!XSendEvent(display, window, False, pat.eventType, &event)) {
- fprintf(stderr, "synthethic event failed\n");
- }
- return TCL_OK;
-}
-
-int
-Blt_SendEventCmdInitProc(Tcl_Interp *interp)
-{
- static Blt_InitCmdSpec cmdSpec = {
- "sendevent", SendEventCmd,
- };
- return Blt_InitCmd(interp, "::blt", &cmdSpec);
-}