summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixEmbed.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tkUnixEmbed.c')
-rw-r--r--unix/tkUnixEmbed.c76
1 files changed, 36 insertions, 40 deletions
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);
}