summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixEmbed.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tkUnixEmbed.c')
-rw-r--r--unix/tkUnixEmbed.c199
1 files changed, 185 insertions, 14 deletions
diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c
index 5b5f486..bd5c512 100644
--- a/unix/tkUnixEmbed.c
+++ b/unix/tkUnixEmbed.c
@@ -4,7 +4,7 @@
* This file contains platform-specific functions for UNIX to provide
* basic operations needed for application embedding (where one
* application can use as its main window an internal window from some
- * other application).
+ * other application). Also includes code to support busy windows.
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
*
@@ -13,6 +13,7 @@
*/
#include "tkUnixInt.h"
+#include "tkBusy.h"
/*
* One of the following structures exists for each container in this
@@ -95,7 +96,7 @@ TkpUseWindow(
* string is bogus. */
Tk_Window tkwin, /* Tk window that does not yet have an
* associated X window. */
- CONST char *string) /* String identifying an X window to use for
+ const char *string) /* String identifying an X window to use for
* tkwin; must be an integer value. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
@@ -136,7 +137,7 @@ TkpUseWindow(
anyError = 0;
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1,
- EmbedErrorProc, (ClientData) &anyError);
+ EmbedErrorProc, &anyError);
if (!XGetWindowAttributes(winPtr->display, parent, &parentAtts)) {
anyError = 1;
}
@@ -158,7 +159,7 @@ TkpUseWindow(
*/
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc,
- (ClientData) winPtr);
+ winPtr);
/*
* Save information about the container and the embedded window in a
@@ -176,7 +177,7 @@ TkpUseWindow(
}
}
if (containerPtr == NULL) {
- containerPtr = (Container *) ckalloc(sizeof(Container));
+ containerPtr = ckalloc(sizeof(Container));
containerPtr->parent = parent;
containerPtr->parentRoot = parentAtts.root;
containerPtr->parentPtr = NULL;
@@ -279,7 +280,7 @@ TkpMakeContainer(
*/
Tk_MakeWindowExist(tkwin);
- containerPtr = (Container *) ckalloc(sizeof(Container));
+ containerPtr = ckalloc(sizeof(Container));
containerPtr->parent = Tk_WindowId(tkwin);
containerPtr->parentRoot = RootWindowOfScreen(Tk_Screen(tkwin));
containerPtr->parentPtr = winPtr;
@@ -300,11 +301,11 @@ TkpMakeContainer(
XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask);
Tk_CreateEventHandler(tkwin,
SubstructureNotifyMask|SubstructureRedirectMask,
- ContainerEventProc, (ClientData) winPtr);
+ ContainerEventProc, winPtr);
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbedStructureProc,
- (ClientData) containerPtr);
+ containerPtr);
Tk_CreateEventHandler(tkwin, FocusChangeMask, EmbedFocusProc,
- (ClientData) containerPtr);
+ containerPtr);
}
/*
@@ -405,7 +406,7 @@ ContainerEventProc(
*/
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, NULL, (ClientData) NULL);
+ -1, -1, NULL, NULL);
/*
* Find the Container structure associated with the parent window.
@@ -508,7 +509,7 @@ EmbedStructureProc(
*/
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, NULL, (ClientData) NULL);
+ -1, -1, NULL, NULL);
XMoveResizeWindow(eventPtr->xconfigure.display,
containerPtr->wrapper, 0, 0,
(unsigned) Tk_Width((Tk_Window) containerPtr->parentPtr),
@@ -559,7 +560,7 @@ EmbedFocusProc(
if (containerPtr->wrapper != None) {
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, NULL, (ClientData) NULL);
+ -1, -1, NULL, NULL);
XSetInputFocus(display, containerPtr->wrapper, RevertToParent,
CurrentTime);
Tk_DeleteErrorHandler(errHandler);
@@ -865,7 +866,7 @@ TkpTestembedCmd(
ClientData clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int argc, /* Number of arguments. */
- CONST char **argv) /* Argument strings. */
+ const char **argv) /* Argument strings. */
{
int all;
Container *containerPtr;
@@ -972,7 +973,7 @@ EmbedWindowDeleted(
} else {
prevPtr->nextPtr = containerPtr->nextPtr;
}
- ckfree((char *) containerPtr);
+ ckfree(containerPtr);
}
}
@@ -1013,6 +1014,176 @@ TkUnixContainerId(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * TkpShowBusyWindow --
+ *
+ * Makes a busy window "appear".
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Arranges for the busy window to start intercepting events and the
+ * cursor to change to the configured "hey, I'm busy!" setting.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpShowBusyWindow(
+ TkBusy busy)
+{
+ Busy *busyPtr = (Busy *) busy;
+
+ if (busyPtr->tkBusy != NULL) {
+ Tk_MapWindow(busyPtr->tkBusy);
+
+ /*
+ * Always raise the busy window just in case new sibling windows have
+ * been created in the meantime. Can't use Tk_RestackWindow because it
+ * doesn't work under Win32.
+ */
+
+ XRaiseWindow(Tk_Display(busyPtr->tkBusy),
+ Tk_WindowId(busyPtr->tkBusy));
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpHideBusyWindow --
+ *
+ * Makes a busy window "disappear".
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Arranges for the busy window to stop intercepting events, and the
+ * cursor to change back to its normal setting.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpHideBusyWindow(
+ TkBusy busy)
+{
+ Busy *busyPtr = (Busy *) busy;
+
+ if (busyPtr->tkBusy != NULL) {
+ Tk_UnmapWindow(busyPtr->tkBusy);
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpMakeTransparentWindowExist --
+ *
+ * Construct the platform-specific resources for a transparent window.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Moves the specified window in the stacking order.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpMakeTransparentWindowExist(
+ Tk_Window tkwin, /* Token for window. */
+ Window parent) /* Parent window. */
+{
+ TkWindow *winPtr = (TkWindow *) tkwin;
+ long int mask = CWDontPropagate | CWEventMask;
+
+ /*
+ * Ignore the important events while the window is mapped.
+ */
+
+#define USER_EVENTS \
+ (EnterWindowMask | LeaveWindowMask | KeyPressMask | KeyReleaseMask | \
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
+#define PROP_EVENTS \
+ (KeyPressMask | KeyReleaseMask | ButtonPressMask | \
+ ButtonReleaseMask | PointerMotionMask)
+
+ winPtr->atts.do_not_propagate_mask = PROP_EVENTS;
+ winPtr->atts.event_mask = USER_EVENTS;
+ winPtr->changes.border_width = 0;
+ winPtr->depth = 0;
+
+ winPtr->window = XCreateWindow(winPtr->display, parent,
+ winPtr->changes.x, winPtr->changes.y,
+ (unsigned) winPtr->changes.width, /* width */
+ (unsigned) winPtr->changes.height, /* height */
+ (unsigned) winPtr->changes.border_width, /* border_width */
+ winPtr->depth, InputOnly, winPtr->visual, mask, &winPtr->atts);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * 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.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Sets up part of the busy window structure.
+ *
+ *----------------------------------------------------------------------
+ */
+
+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,
+ Tk_Window tkRef,
+ Window *parentPtr,
+ Tk_Window tkParent,
+ TkBusy busy)
+{
+ if (winPtr->flags & TK_REPARENTED) {
+ /*
+ * This works around a bug in the implementation of menubars for
+ * non-MacIntosh window systems (Win32 and X11). Tk doesn't reset the
+ * pointers to the parent window when the menu is reparented (since
+ * winPtr->parentPtr points to the wrong window). We get around this
+ * by determining the parent via the native API calls.
+ */
+
+ *parentPtr = GetParent(Tk_Display(tkRef), Tk_WindowId(tkRef));
+ } else {
+ *parentPtr = Tk_WindowId(tkParent);
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4