summaryrefslogtreecommitdiffstats
path: root/generic/tkGrab.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkGrab.c')
-rw-r--r--generic/tkGrab.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index 9e9daae..e825c7b 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -211,11 +211,15 @@ Tk_GrabObjCmd(
* is "grab", but if it has been aliased, the message will be
* incorrect.
*/
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tcl_GetString(objv[0]), " ?-global? window\" or \"",
- Tcl_GetString(objv[0]), " option ?arg ...?\"", NULL);
- Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
+
+ Tcl_WrongNumArgs(interp, 1, objv, "?-global? window");
+ Tcl_AppendResult(interp, " or \"", Tcl_GetString(objv[0]),
+ " option ?arg ...?\"", NULL);
+ /* This API not exposed:
+ *
+ ((Interp *) interp)->flags |= INTERP_ALTERNATE_WRONG_ARGS;
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
+ */
return TCL_ERROR;
}
@@ -278,17 +282,20 @@ Tk_GrabObjCmd(
}
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_SetResult(interp, dispPtr->eventualGrabWinPtr->pathName,
- TCL_STATIC);
+ Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window)
+ dispPtr->eventualGrabWinPtr));
}
} else {
+ Tcl_Obj *resultObj = Tcl_NewObj();
+
for (dispPtr = TkGetDisplayList(); dispPtr != NULL;
dispPtr = dispPtr->nextPtr) {
if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_AppendElement(interp,
- dispPtr->eventualGrabWinPtr->pathName);
+ Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj(
+ (Tk_Window) dispPtr->eventualGrabWinPtr));
}
}
+ Tcl_SetObjResult(interp, resultObj);
}
return TCL_OK;
@@ -341,6 +348,7 @@ Tk_GrabObjCmd(
case GRABCMD_STATUS: {
/* [grab status window] */
TkWindow *winPtr;
+ const char *statusString;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "status window");
@@ -353,12 +361,13 @@ Tk_GrabObjCmd(
}
dispPtr = winPtr->dispPtr;
if (dispPtr->eventualGrabWinPtr != winPtr) {
- Tcl_SetResult(interp, "none", TCL_STATIC);
+ statusString = "none";
} else if (dispPtr->grabFlags & GRAB_GLOBAL) {
- Tcl_SetResult(interp, "global", TCL_STATIC);
+ statusString = "global";
} else {
- Tcl_SetResult(interp, "local", TCL_STATIC);
+ statusString = "local";
}
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(statusString, -1));
break;
}
}
@@ -528,19 +537,21 @@ Tk_Grab(
grabError:
if (grabResult == GrabNotViewable) {
- Tcl_SetResult(interp, "grab failed: window not viewable", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "grab failed: window not viewable", -1));
Tcl_SetErrorCode(interp, "TK", "GRAB", "UNVIEWABLE", NULL);
} else if (grabResult == AlreadyGrabbed) {
alreadyGrabbed:
- Tcl_SetResult(interp, "grab failed: another application has grab",
- TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "grab failed: another application has grab", -1));
Tcl_SetErrorCode(interp, "TK", "GRAB", "GRABBED", NULL);
} else if (grabResult == GrabFrozen) {
- Tcl_SetResult(interp,
- "grab failed: keyboard or pointer frozen", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "grab failed: keyboard or pointer frozen", -1));
Tcl_SetErrorCode(interp, "TK", "GRAB", "FROZEN", NULL);
} else if (grabResult == GrabInvalidTime) {
- Tcl_SetResult(interp, "grab failed: invalid time", TCL_STATIC);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "grab failed: invalid time", -1));
Tcl_SetErrorCode(interp, "TK", "GRAB", "BADTIME", NULL);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(