summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-07-24 19:41:30 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-07-24 19:41:30 (GMT)
commita161a378971b948143b658e432ce13b723c25f89 (patch)
tree27a19c720909b8a4b9391764f0bf7e7598f9df24 /unix
parenta7cecb5c00243f374eaf3d64c5905042633e888b (diff)
downloadtk-a161a378971b948143b658e432ce13b723c25f89.zip
tk-a161a378971b948143b658e432ce13b723c25f89.tar.gz
tk-a161a378971b948143b658e432ce13b723c25f89.tar.bz2
a few more places
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixCursor.c37
-rw-r--r--unix/tkUnixEmbed.c76
2 files changed, 56 insertions, 57 deletions
diff --git a/unix/tkUnixCursor.c b/unix/tkUnixCursor.c
index 145530a..3103cc1 100644
--- a/unix/tkUnixCursor.c
+++ b/unix/tkUnixCursor.c
@@ -182,7 +182,7 @@ static const struct TkCursorName {
static Cursor CreateCursorFromTableOrFile(Tcl_Interp *interp,
Tk_Window tkwin, int argc, const char **argv,
const struct TkCursorName *tkCursorPtr);
-
+
/*
*----------------------------------------------------------------------
*
@@ -357,7 +357,7 @@ TkGetCursorByName(
Tcl_SetErrorCode(interp, "TK", "VALUE", "CURSOR", NULL);
return NULL;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -426,8 +426,9 @@ CreateCursorFromTableOrFile(
data = TkGetBitmapData(NULL, tkCursorPtr->data, NULL,
&width, &height, &xHot, &yHot);
if (data == NULL) {
- Tcl_AppendResult(interp, "error reading bitmap data for \"",
- argv[0], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "error reading bitmap data for \"%s\"", argv[0]));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "BITMAPDATA", NULL);
goto cleanup;
}
@@ -437,19 +438,20 @@ CreateCursorFromTableOrFile(
if (TkReadBitmapFile(display, drawable, &argv[0][1],
(unsigned *) &width, (unsigned *) &height,
&source, &xHot, &yHot) != BitmapSuccess) {
- Tcl_AppendResult(interp, "cleanup reading bitmap file \"",
- &argv[0][1], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "cleanup reading bitmap file \"%s\"", &argv[0][1]));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "BITMAPFILE", NULL);
goto cleanup;
}
}
if ((xHot < 0) || (yHot < 0) || (xHot >= width) || (yHot >= height)) {
if (inTkTable) {
- Tcl_AppendResult(interp, "bad hot spot in bitmap data for \"",
- argv[0], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad hot spot in bitmap data for \"%s\"", argv[0]));
} else {
- Tcl_AppendResult(interp, "bad hot spot in bitmap file \"",
- &argv[0][1], "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad hot spot in bitmap file \"%s\"", &argv[0][1]));
}
Tcl_SetErrorCode(interp, "TK", "CURSOR", "HOTSPOT", NULL);
goto cleanup;
@@ -465,8 +467,9 @@ CreateCursorFromTableOrFile(
} else if (argc == 2) {
fgColor = argv[1];
if (TkParseColor(display, Tk_Colormap(tkwin), fgColor, &fg) == 0) {
- Tcl_AppendResult(interp, "invalid color name \"",
- fgColor, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid color name \"%s\"", fgColor));
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "FGCOL", NULL);
goto cleanup;
}
if (inTkTable) {
@@ -523,7 +526,7 @@ CreateCursorFromTableOrFile(
if (data == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error reading bitmap mask data for \"%s\"", argv[0]));
- Tcl_SetErrorCode(interp, "TK", "CURSOR", "READ", -1);
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "MASKDATA", -1);
goto cleanup;
}
@@ -537,7 +540,7 @@ CreateCursorFromTableOrFile(
&mask, &dummy1, &dummy2) != BitmapSuccess) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cleanup reading bitmap file \"%s\"", argv[1]));
- Tcl_SetErrorCode(interp, "TK", "CURSOR", "READ", -1);
+ Tcl_SetErrorCode(interp, "TK", "CURSOR", "MASKFILE", -1);
goto cleanup;
}
}
@@ -561,7 +564,7 @@ CreateCursorFromTableOrFile(
}
return cursor;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -611,7 +614,7 @@ TkCreateCursorFromData(
}
return (TkCursor *) cursorPtr;
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -638,7 +641,7 @@ TkpFreeCursor(
XFreeCursor(unixCursorPtr->display, (Cursor) unixCursorPtr->info.cursor);
Tk_FreeXId(unixCursorPtr->display, (XID) unixCursorPtr->info.cursor);
}
-
+
/*
* Local Variables:
* mode: c
diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c
index bd5c512..d94157c 100644
--- a/unix/tkUnixEmbed.c
+++ b/unix/tkUnixEmbed.c
@@ -106,12 +106,13 @@ TkpUseWindow(
Tk_ErrorHandler handler;
Container *containerPtr;
XWindowAttributes parentAtts;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->window != None) {
- Tcl_AppendResult(interp,
- "can't modify container after widget is created", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "can't modify container after widget is created", -1));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "POST_CREATE", NULL);
return TCL_ERROR;
}
if (Tcl_GetInt(interp, string, &id) != TCL_OK) {
@@ -122,8 +123,10 @@ TkpUseWindow(
usePtr = (TkWindow *) Tk_IdToWindow(winPtr->display, parent);
if (usePtr != NULL) {
if (!(usePtr->flags & TK_CONTAINER)) {
- Tcl_AppendResult(interp, "window \"", usePtr->pathName,
- "\" doesn't have -container option set", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "window \"%s\" doesn't have -container option set",
+ usePtr->pathName));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "CONTAINER", NULL);
return TCL_ERROR;
}
}
@@ -145,8 +148,9 @@ TkpUseWindow(
Tk_DeleteErrorHandler(handler);
if (anyError) {
if (interp != NULL) {
- Tcl_AppendResult(interp, "couldn't create child of window \"",
- string, "\"", NULL);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "couldn't create child of window \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "EMBED", "CHILD", NULL);
}
return TCL_ERROR;
}
@@ -215,7 +219,7 @@ TkpMakeWindow(
* the window is to be created. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->flags & TK_EMBEDDED) {
@@ -271,7 +275,7 @@ TkpMakeContainer(
{
TkWindow *winPtr = (TkWindow *) tkwin;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -331,7 +335,7 @@ EmbedErrorProc(
XErrorEvent *errEventPtr) /* Points to information about error (not
* used). */
{
- int *iPtr = (int *) clientData;
+ int *iPtr = clientData;
*iPtr = 1;
return 0;
@@ -361,7 +365,7 @@ EmbeddedEventProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- TkWindow *winPtr = (TkWindow *) clientData;
+ TkWindow *winPtr = clientData;
if (eventPtr->type == DestroyNotify) {
EmbedWindowDeleted(winPtr);
@@ -393,10 +397,10 @@ ContainerEventProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- TkWindow *winPtr = (TkWindow *) clientData;
+ TkWindow *winPtr = clientData;
Container *containerPtr;
Tk_ErrorHandler errHandler;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -498,7 +502,7 @@ EmbedStructureProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- Container *containerPtr = (Container *) clientData;
+ Container *containerPtr = clientData;
Tk_ErrorHandler errHandler;
if (eventPtr->type == ConfigureNotify) {
@@ -545,7 +549,7 @@ EmbedFocusProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- Container *containerPtr = (Container *) clientData;
+ Container *containerPtr = clientData;
Tk_ErrorHandler errHandler;
Display *display;
@@ -703,7 +707,7 @@ TkpGetOtherWindow(
* window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr;
@@ -749,7 +753,7 @@ TkpRedirectKeyEvent(
{
Container *containerPtr;
Window saved;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -821,7 +825,7 @@ TkpClaimFocus(
{
XEvent event;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!(topLevelPtr->flags & TK_EMBEDDED)) {
@@ -872,7 +876,7 @@ TkpTestembedCmd(
Container *containerPtr;
Tcl_DString dString;
char buffer[50];
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if ((argc > 1) && (strcmp(argv[1], "all") == 0)) {
@@ -942,7 +946,7 @@ EmbedWindowDeleted(
* deleted. */
{
Container *containerPtr, *prevPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1000,7 +1004,7 @@ TkUnixContainerId(
TkWindow *winPtr) /* Tk's structure for an embedded window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr =
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (containerPtr = tsdPtr->firstContainerPtr;
@@ -1132,8 +1136,7 @@ TkpMakeTransparentWindowExist(
* TkpCreateBusy --
*
* Construct the platform-specific parts of a busy window. Note that this
- * postpones the actual creation of the window resource until later. The
- * GetParent() function is a helper for this.
+ * postpones the actual creation of the window resource until later.
*
* Results:
* None.
@@ -1144,22 +1147,6 @@ TkpMakeTransparentWindowExist(
*----------------------------------------------------------------------
*/
-static inline Window
-GetParent(
- Display *display,
- Window window)
-{
- Window root, parent;
- Window *dummy;
- unsigned int count;
-
- if (XQueryTree(display, window, &root, &parent, &dummy, &count) > 0) {
- XFree(dummy);
- return parent;
- }
- return None;
-}
-
void
TkpCreateBusy(
Tk_FakeWin *winPtr,
@@ -1168,6 +1155,9 @@ TkpCreateBusy(
Tk_Window tkParent,
TkBusy busy)
{
+ Window root, parent, *dummy;
+ unsigned int count;
+
if (winPtr->flags & TK_REPARENTED) {
/*
* This works around a bug in the implementation of menubars for
@@ -1177,7 +1167,13 @@ TkpCreateBusy(
* by determining the parent via the native API calls.
*/
- *parentPtr = GetParent(Tk_Display(tkRef), Tk_WindowId(tkRef));
+ if (XQueryTree(Tk_Display(tkRef), Tk_WindowId(tkRef), &root,
+ &parent, &dummy, &count) > 0) {
+ XFree(dummy);
+ *parentPtr = parent;
+ } else {
+ *parentPtr = None;
+ }
} else {
*parentPtr = Tk_WindowId(tkParent);
}