summaryrefslogtreecommitdiffstats
path: root/generic/tkGrab.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkGrab.c')
-rw-r--r--generic/tkGrab.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index 2232ba5..5a25dea 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -3,8 +3,8 @@
*
* This file provides functions that implement grabs for Tk.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -170,7 +170,7 @@ static void ReleaseButtonGrab(TkDisplay *dispPtr);
int
Tk_GrabObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -180,7 +180,7 @@ Tk_GrabObjCmd(
TkDisplay *dispPtr;
const char *arg;
int index;
- int len;
+ Tcl_Size len;
static const char *const optionStrings[] = {
"current", "release", "set", "status", NULL
};
@@ -272,7 +272,7 @@ Tk_GrabObjCmd(
}
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window)
+ Tcl_SetObjResult(interp, Tk_NewWindowObj((Tk_Window)
dispPtr->eventualGrabWinPtr));
}
} else {
@@ -281,7 +281,7 @@ Tk_GrabObjCmd(
for (dispPtr = TkGetDisplayList(); dispPtr != NULL;
dispPtr = dispPtr->nextPtr) {
if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj(
+ Tcl_ListObjAppendElement(NULL, resultObj, Tk_NewWindowObj(
(Tk_Window) dispPtr->eventualGrabWinPtr));
}
}
@@ -357,7 +357,7 @@ Tk_GrabObjCmd(
} else {
statusString = "local";
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(statusString, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(statusString, TCL_INDEX_NONE));
break;
}
}
@@ -523,20 +523,20 @@ Tk_Grab(
grabError:
if (grabResult == GrabNotViewable) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "grab failed: window not viewable", -1));
+ "grab failed: window not viewable", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRAB", "UNVIEWABLE", NULL);
} else if (grabResult == AlreadyGrabbed) {
alreadyGrabbed:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "grab failed: another application has grab", -1));
+ "grab failed: another application has grab", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRAB", "GRABBED", NULL);
} else if (grabResult == GrabFrozen) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "grab failed: keyboard or pointer frozen", -1));
+ "grab failed: keyboard or pointer frozen", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRAB", "FROZEN", NULL);
} else if (grabResult == GrabInvalidTime) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "grab failed: invalid time", -1));
+ "grab failed: invalid time", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRAB", "BAD_TIME", NULL);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -668,6 +668,9 @@ ReleaseButtonGrab(
* This function is called for each pointer-related event, before the
* event has been processed. It does various things to make grabs work
* correctly.
+ * Also, this function takes care of warping the mouse pointer with
+ * respect to a given window, both when there is a grab in effect and
+ * when there is none.
*
* Results:
* If the return value is 1 it means the event should be processed (event
@@ -679,6 +682,7 @@ ReleaseButtonGrab(
* Grab state information may be updated. New events may also be pushed
* back onto the event queue to replace or augment the one passed in
* here.
+ * The mouse pointer may be moved.
*
*----------------------------------------------------------------------
*/
@@ -775,10 +779,24 @@ TkPointerEvent(
return 1;
}
+ if ((eventPtr->type == MotionNotify) && !appGrabbed) {
+
+ /*
+ * Warp the mouse pointer with respect to window dispPtr->warpWindow
+ * if such a window was set in HandleEventGenerate.
+ */
+
+ TkDoWarpWrtWin(dispPtr);
+ }
+
if (!appGrabbed) {
return 1;
}
+ /*
+ * From this point on, there is a grab in effect.
+ */
+
if (eventPtr->type == MotionNotify) {
/*
* When grabs are active, X reports motion events relative to the
@@ -801,6 +819,13 @@ TkPointerEvent(
Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD);
return 0;
}
+
+ /*
+ * Warp the mouse pointer with respect to window dispPtr->warpWindow
+ * if such a window was set in HandleEventGenerate.
+ */
+
+ TkDoWarpWrtWin(dispPtr);
return 1;
}
@@ -873,7 +898,7 @@ TkPointerEvent(
} else {
if (eventPtr->xbutton.button != AnyButton &&
((eventPtr->xbutton.state & ALL_BUTTONS)
- == TkGetButtonMask(eventPtr->xbutton.button))) {
+ == Tk_GetButtonMask(eventPtr->xbutton.button))) {
ReleaseButtonGrab(dispPtr); /* Note 4. */
}
}
@@ -1243,7 +1268,7 @@ EatGrabEvents(
{
Tk_RestrictProc *prevProc;
GrabInfo info;
- ClientData prevArg;
+ void *prevArg;
info.display = dispPtr->display;
info.serial = serial;
@@ -1276,7 +1301,7 @@ EatGrabEvents(
static Tk_RestrictAction
GrabRestrictProc(
- ClientData arg,
+ void *arg,
XEvent *eventPtr)
{
GrabInfo *info = (GrabInfo *)arg;