summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXEmbed.c
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/tkMacOSXEmbed.c')
-rw-r--r--macosx/tkMacOSXEmbed.c494
1 files changed, 231 insertions, 263 deletions
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c
index c5de78d..85bfe05 100644
--- a/macosx/tkMacOSXEmbed.c
+++ b/macosx/tkMacOSXEmbed.c
@@ -3,50 +3,47 @@
*
* This file contains platform-specific procedures for theMac to provide
* basic operations needed for application embedding (where one
- * application can use as its main window an internal window from
- * some other application).
- * Currently only Toplevel embedding within the same Tk application is
- * allowed on the Macintosh.
+ * application can use as its main window an internal window from some
+ * other application). Currently only Toplevel embedding within the same
+ * Tk application is allowed on the Macintosh.
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
* Copyright 2001, Apple Computer, Inc.
* Copyright (c) 2006-2008 Daniel A. Steffen <das@users.sourceforge.net>
*
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tkMacOSXInt.h"
/*
* One of the following structures exists for each container in this
- * application. It keeps track of the container window and its
- * associated embedded window.
+ * application. It keeps track of the container window and its associated
+ * embedded window.
*/
typedef struct Container {
- Window parent; /* The Mac Drawable for the parent of
- * the pair (the container). */
- TkWindow *parentPtr; /* Tk's information about the container,
- * or NULL if the container isn't
+ Window parent; /* The Mac Drawable for the parent of the pair
+ * (the container). */
+ TkWindow *parentPtr; /* Tk's information about the container, or
+ * NULL if the container isn't in this
+ * process. */
+ Window embedded; /* The MacDrawable for the embedded window.
+ * Starts off as None, but gets filled in when
+ * the window is eventually created. */
+ TkWindow *embeddedPtr; /* Tk's information about the embedded window,
+ * or NULL if the embedded application isn't
* in this process. */
- Window embedded; /* The MacDrawable for the embedded
- * window. Starts off as None, but
- * gets filled in when the window is
- * eventually created. */
- TkWindow *embeddedPtr; /* Tk's information about the embedded
- * window, or NULL if the
- * embedded application isn't in
- * this process. */
- struct Container *nextPtr; /* Next in list of all containers in
- * this process. */
+ struct Container *nextPtr; /* Next in list of all containers in this
+ * process. */
} Container;
static Container *firstContainerPtr = NULL;
- /* First in list of all containers
- * managed by this process. */
+ /* First in list of all containers managed by
+ * this process. */
/*
- * Globals defined in this file
+ * Globals defined in this file:
*/
TkMacOSXEmbedHandler *tkMacOSXEmbedHandler = NULL;
@@ -55,25 +52,24 @@ TkMacOSXEmbedHandler *tkMacOSXEmbedHandler = NULL;
* Prototypes for static procedures defined in this file:
*/
-static void ContainerEventProc(ClientData clientData, XEvent *eventPtr);
-static void EmbeddedEventProc(ClientData clientData, XEvent *eventPtr);
-static void EmbedActivateProc(ClientData clientData, XEvent *eventPtr);
-static void EmbedFocusProc(ClientData clientData, XEvent *eventPtr);
-static void EmbedGeometryRequest(Container * containerPtr, int width,
- int height);
-static void EmbedSendConfigure(Container *containerPtr);
-static void EmbedStructureProc(ClientData clientData, XEvent *eventPtr);
-static void EmbedWindowDeleted(TkWindow *winPtr);
-
+static void ContainerEventProc(ClientData clientData, XEvent *eventPtr);
+static void EmbeddedEventProc(ClientData clientData, XEvent *eventPtr);
+static void EmbedActivateProc(ClientData clientData, XEvent *eventPtr);
+static void EmbedFocusProc(ClientData clientData, XEvent *eventPtr);
+static void EmbedGeometryRequest(Container *containerPtr, int width,
+ int height);
+static void EmbedSendConfigure(Container *containerPtr);
+static void EmbedStructureProc(ClientData clientData, XEvent *eventPtr);
+static void EmbedWindowDeleted(TkWindow *winPtr);
/*
*----------------------------------------------------------------------
*
* Tk_MacOSXSetEmbedHandler --
*
- * Registers a handler for an in process form of embedding, like
- * Netscape plugins, where Tk is loaded into the process, but does
- * not control the main window
+ * Registers a handler for an in process form of embedding, like Netscape
+ * plugins, where Tk is loaded into the process, but does not control the
+ * main window
*
* Results:
* None
@@ -93,7 +89,8 @@ Tk_MacOSXSetEmbedHandler(
Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc)
{
if (tkMacOSXEmbedHandler == NULL) {
- tkMacOSXEmbedHandler = (TkMacOSXEmbedHandler *) ckalloc(sizeof(TkMacOSXEmbedHandler));
+ tkMacOSXEmbedHandler = (TkMacOSXEmbedHandler *)
+ ckalloc(sizeof(TkMacOSXEmbedHandler));
}
tkMacOSXEmbedHandler->registerWinProc = registerWinProc;
tkMacOSXEmbedHandler->getPortProc = getPortProc;
@@ -126,9 +123,8 @@ TkpMakeWindow(
MacDrawable *macWin;
/*
- * If this window is marked as embedded then
- * the window structure should have already been
- * created in the TkpUseWindow function.
+ * If this window is marked as embedded then the window structure should
+ * have already been created in the TkpUseWindow function.
*/
if (Tk_IsEmbedded(winPtr)) {
@@ -155,18 +151,19 @@ TkpMakeWindow(
macWin->size = CGSizeZero;
if (Tk_IsTopLevel(macWin->winPtr)) {
/*
- *This will be set when we are mapped.
+ * This will be set when we are mapped.
*/
+
macWin->xOff = 0;
macWin->yOff = 0;
macWin->toplevel = macWin;
} else {
macWin->xOff = winPtr->parentPtr->privatePtr->xOff +
- winPtr->parentPtr->changes.border_width +
- winPtr->changes.x;
+ winPtr->parentPtr->changes.border_width +
+ winPtr->changes.x;
macWin->yOff = winPtr->parentPtr->privatePtr->yOff +
- winPtr->parentPtr->changes.border_width +
- winPtr->changes.y;
+ winPtr->parentPtr->changes.border_width +
+ winPtr->changes.y;
macWin->toplevel = winPtr->parentPtr->privatePtr->toplevel;
}
macWin->toplevel->referenceCount++;
@@ -179,15 +176,15 @@ TkpMakeWindow(
*
* TkpUseWindow --
*
- * This procedure causes a Tk window to use a given X window as
- * its parent window, rather than the root window for the screen.
- * It is invoked by an embedded application to specify the window
- * in which it is embedded.
+ * This procedure causes a Tk window to use a given X window as its
+ * parent window, rather than the root window for the screen. It is
+ * invoked by an embedded application to specify the window in which it
+ * is embedded.
*
* Results:
- * The return value is normally TCL_OK. If an error occurs (such
- * as string not being a valid window spec), then the return value
- * is TCL_ERROR and an error message is left in the interp's result if
+ * The return value is normally TCL_OK. If an error occurs (such as
+ * string not being a valid window spec), then the return value is
+ * TCL_ERROR and an error message is left in the interp's result if
* interp is non-NULL.
*
* Side effects:
@@ -198,12 +195,12 @@ TkpMakeWindow(
int
TkpUseWindow(
- Tcl_Interp *interp, /* If not NULL, used for error reporting
- * if string is bogus. */
+ Tcl_Interp *interp, /* If not NULL, used for error reporting if
+ * 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 tkwin; must be an integer value. */
+ CONST char *string) /* String identifying an X window to use for
+ * tkwin; must be an integer value. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
TkWindow *usePtr;
@@ -217,13 +214,12 @@ TkpUseWindow(
}
/*
- * Decode the container pointer, and look for it among the
- * list of available containers.
+ * Decode the container pointer, and look for it among the list of
+ * available containers.
*
* N.B. For now, we are limiting the containers to be in the same Tk
- * application as tkwin, since otherwise they would not be in our list
- * of containers.
- *
+ * application as tkwin, since otherwise they would not be in our list of
+ * containers.
*/
if (Tcl_GetInt(interp, string, (int*) &parent) != TCL_OK) {
@@ -245,8 +241,8 @@ TkpUseWindow(
*/
/*
- * Save information about the container and the embedded window
- * in a Container structure. Currently, there must already be an existing
+ * Save information about the container and the embedded window in a
+ * Container structure. Currently, there must already be an existing
* Container structure, since we only allow the case where both container
* and embedded app. are in the same process.
*/
@@ -274,11 +270,11 @@ TkpUseWindow(
winPtr->privatePtr = macWin;
/*
- * The grafPtr will be NULL for a Tk in Tk embedded window.
- * It is none of our business what it is for a Tk not in Tk embedded window,
- * but we will initialize it to NULL, and let the registerWinProc
- * set it. In any case, you must always use TkMacOSXGetDrawablePort
- * to get the portPtr. It will correctly find the container's port.
+ * The grafPtr will be NULL for a Tk in Tk embedded window. It is none of
+ * our business what it is for a Tk not in Tk embedded window, but we will
+ * initialize it to NULL, and let the registerWinProc set it. In any case,
+ * you must always use TkMacOSXGetDrawablePort to get the portPtr. It will
+ * correctly find the container's port.
*/
macWin->grafPtr = NULL;
@@ -294,19 +290,17 @@ TkpUseWindow(
winPtr->flags |= TK_EMBEDDED;
-
/*
- * Make a copy of the TK_EMBEDDED flag, since sometimes
- * we need this to get the port after the TkWindow structure
- * has been freed.
+ * Make a copy of the TK_EMBEDDED flag, since sometimes we need this to
+ * get the port after the TkWindow structure has been freed.
*/
macWin->flags |= TK_EMBEDDED;
/*
- * Now check whether it is embedded in another Tk widget. If not (the first
- * case below) we see if there is an in-process embedding handler registered,
- * and if so, let that fill in the rest of the macWin.
+ * Now check whether it is embedded in another Tk widget. If not (the
+ * first case below) we see if there is an in-process embedding handler
+ * registered, and if so, let that fill in the rest of the macWin.
*/
if (containerPtr == NULL) {
@@ -329,10 +323,8 @@ TkpUseWindow(
containerPtr->embeddedPtr = macWin->winPtr;
containerPtr->nextPtr = firstContainerPtr;
firstContainerPtr = containerPtr;
-
}
} else {
-
/*
* The window is embedded in another Tk window.
*/
@@ -344,10 +336,9 @@ TkpUseWindow(
parent->winPtr->changes.border_width +
winPtr->changes.y;
-
/*
- * Finish filling up the container structure with the embedded window's
- * information.
+ * Finish filling up the container structure with the embedded
+ * window's information.
*/
containerPtr->embedded = (Window) macWin;
@@ -359,8 +350,7 @@ TkpUseWindow(
*/
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc,
- (ClientData) winPtr);
-
+ winPtr);
}
return TCL_OK;
@@ -371,10 +361,10 @@ TkpUseWindow(
*
* TkpMakeContainer --
*
- * This procedure is called to indicate that a particular window
- * will be a container for an embedded application. This changes
- * certain aspects of the window's behavior, such as whether it
- * will receive events anymore.
+ * This procedure is called to indicate that a particular window will be
+ * a container for an embedded application. This changes certain aspects
+ * of the window's behavior, such as whether it will receive events
+ * anymore.
*
* Results:
* None.
@@ -387,18 +377,17 @@ TkpUseWindow(
void
TkpMakeContainer(
- Tk_Window tkwin) /* Token for a window that is about to
- * become a container. */
+ Tk_Window tkwin) /* Token for a window that is about to become
+ * a container. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
Container *containerPtr;
/*
- * Register the window as a container so that, for example, we can
- * make sure the argument to -use is valid.
+ * Register the window as a container so that, for example, we can make
+ * sure the argument to -use is valid.
*/
-
Tk_MakeWindowExist(tkwin);
containerPtr = (Container *) ckalloc(sizeof(Container));
containerPtr->parent = Tk_WindowId(tkwin);
@@ -410,23 +399,22 @@ TkpMakeContainer(
winPtr->flags |= TK_CONTAINER;
/*
- * Request SubstructureNotify events so that we can find out when
- * the embedded application creates its window or attempts to
- * resize it. Also watch Configure events on the container so that
- * we can resize the child to match. Also, pass activate events from
- * the container down to the embedded toplevel.
+ * Request SubstructureNotify events so that we can find out when the
+ * embedded application creates its window or attempts to resize it. Also
+ * watch Configure events on the container so that we can resize the child
+ * to match. Also, pass activate events from the container down to the
+ * embedded toplevel.
*/
Tk_CreateEventHandler(tkwin,
SubstructureNotifyMask|SubstructureRedirectMask,
- ContainerEventProc, (ClientData) winPtr);
+ ContainerEventProc, winPtr);
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbedStructureProc,
- (ClientData) containerPtr);
+ containerPtr);
Tk_CreateEventHandler(tkwin, ActivateMask, EmbedActivateProc,
- (ClientData) containerPtr);
+ containerPtr);
Tk_CreateEventHandler(tkwin, FocusChangeMask, EmbedFocusProc,
- (ClientData) containerPtr);
-
+ containerPtr);
}
/*
@@ -438,8 +426,7 @@ TkpMakeContainer(
* identifier for the associated container window.
*
* Results:
- * The return value is the MacDrawable for winPtr's
- * container window.
+ * The return value is the MacDrawable for winPtr's container window.
*
* Side effects:
* None.
@@ -448,8 +435,8 @@ TkpMakeContainer(
*/
MacDrawable *
-TkMacOSXContainerId(winPtr)
- TkWindow *winPtr; /* Tk's structure for an embedded window. */
+TkMacOSXContainerId(
+ TkWindow *winPtr) /* Tk's structure for an embedded window. */
{
Container *containerPtr;
@@ -468,8 +455,8 @@ TkMacOSXContainerId(winPtr)
*
* TkMacOSXGetHostToplevel --
*
- * Given the TkWindow, return the MacDrawable for the outermost
- * toplevel containing it. This will be a real Macintosh window.
+ * Given the TkWindow, return the MacDrawable for the outermost toplevel
+ * containing it. This will be a real Macintosh window.
*
* Results:
* Returns a MacDrawable corresponding to a Macintosh Toplevel
@@ -488,20 +475,18 @@ TkMacOSXGetHostToplevel(
topWinPtr = winPtr->privatePtr->toplevel->winPtr;
if (!Tk_IsEmbedded(topWinPtr)) {
- return winPtr->privatePtr->toplevel;
- } else {
- contWinPtr = TkpGetOtherWindow(topWinPtr);
+ return winPtr->privatePtr->toplevel;
+ }
+ contWinPtr = TkpGetOtherWindow(topWinPtr);
- /*
- * TODO: Here we should handle out of process embedding.
- */
+ /*
+ * TODO: Here we should handle out of process embedding.
+ */
- if (contWinPtr != NULL) {
- return TkMacOSXGetHostToplevel(contWinPtr);
- } else {
- return None;
- }
+ if (contWinPtr == NULL) {
+ return None;
}
+ return TkMacOSXGetHostToplevel(contWinPtr);
}
/*
@@ -509,10 +494,10 @@ TkMacOSXGetHostToplevel(
*
* TkpClaimFocus --
*
- * This procedure is invoked when someone asks for the input focus
- * to be put on a window in an embedded application, but the
- * application doesn't currently have the focus. It requests the
- * input focus from the container application.
+ * This procedure is invoked when someone asks for the input focus to be
+ * put on a window in an embedded application, but the application
+ * doesn't currently have the focus. It requests the input focus from the
+ * container application.
*
* Results:
* None.
@@ -525,11 +510,11 @@ TkMacOSXGetHostToplevel(
void
TkpClaimFocus(
- TkWindow *topLevelPtr, /* Top-level window containing desired
- * focus window; should be embedded. */
- int force) /* One means that the container should
- * claim the focus if it doesn't
- * currently have it. */
+ TkWindow *topLevelPtr, /* Top-level window containing desired focus
+ * window; should be embedded. */
+ int force) /* One means that the container should claim
+ * the focus if it doesn't currently have
+ * it. */
{
XEvent event;
Container *containerPtr;
@@ -544,7 +529,6 @@ TkpClaimFocus(
/* Empty loop body. */
}
-
event.xfocus.type = FocusIn;
event.xfocus.serial = LastKnownRequestProcessed(topLevelPtr->display);
event.xfocus.send_event = 1;
@@ -560,9 +544,8 @@ TkpClaimFocus(
*
* TkpTestembedCmd --
*
- * This procedure implements the "testembed" command. It returns
- * some or all of the information in the list pointed to by
- * firstContainerPtr.
+ * This procedure implements the "testembed" command. It returns some or
+ * all of the information in the list pointed to by firstContainerPtr.
*
* Results:
* A standard Tcl result.
@@ -596,13 +579,11 @@ TkpTestembedCmd(
Tcl_DStringStartSublist(&dString);
if (containerPtr->parent == None) {
Tcl_DStringAppendElement(&dString, "");
+ } else if (all) {
+ sprintf(buffer, "0x%x", (int) containerPtr->parent);
+ Tcl_DStringAppendElement(&dString, buffer);
} else {
- if (all) {
- sprintf(buffer, "0x%x", (int) containerPtr->parent);
- Tcl_DStringAppendElement(&dString, buffer);
- } else {
- Tcl_DStringAppendElement(&dString, "XXX");
- }
+ Tcl_DStringAppendElement(&dString, "XXX");
}
if (containerPtr->parentPtr == NULL) {
Tcl_DStringAppendElement(&dString, "");
@@ -612,13 +593,11 @@ TkpTestembedCmd(
}
if (containerPtr->embedded == None) {
Tcl_DStringAppendElement(&dString, "");
+ } else if (all) {
+ sprintf(buffer, "0x%x", (int) containerPtr->embedded);
+ Tcl_DStringAppendElement(&dString, buffer);
} else {
- if (all) {
- sprintf(buffer, "0x%x", (int) containerPtr->embedded);
- Tcl_DStringAppendElement(&dString, buffer);
- } else {
- Tcl_DStringAppendElement(&dString, "XXX");
- }
+ Tcl_DStringAppendElement(&dString, "XXX");
}
if (containerPtr->embeddedPtr == NULL) {
Tcl_DStringAppendElement(&dString, "");
@@ -637,13 +616,13 @@ TkpTestembedCmd(
*
* TkpRedirectKeyEvent --
*
- * This procedure is invoked when a key press or release event
- * arrives for an application that does not believe it owns the
- * input focus. This can happen because of embedding; for example,
- * X can send an event to an embedded application when the real
- * focus window is in the container application and is an ancestor
- * of the container. This procedure's job is to forward the event
- * back to the application where it really belongs.
+ * This procedure is invoked when a key press or release event arrives
+ * for an application that does not believe it owns the input focus. This
+ * can happen because of embedding; for example, X can send an event to
+ * an embedded application when the real focus window is in the container
+ * application and is an ancestor of the container. This procedure's job
+ * is to forward the event back to the application where it really
+ * belongs.
*
* Results:
* None.
@@ -658,8 +637,8 @@ void
TkpRedirectKeyEvent(
TkWindow *winPtr, /* Window to which the event was originally
* reported. */
- XEvent *eventPtr) /* X event to redirect (should be KeyPress
- * or KeyRelease). */
+ XEvent *eventPtr) /* X event to redirect (should be KeyPress or
+ * KeyRelease). */
{
}
@@ -668,13 +647,13 @@ TkpRedirectKeyEvent(
*
* TkpGetOtherWindow --
*
- * If both the container and embedded window are in the same
- * process, this procedure will return either one, given the other.
+ * If both the container and embedded window are in the same process,
+ * this procedure will return either one, given the other.
*
* Results:
* If winPtr is a container, the return value is the token for the
- * embedded window, and vice versa. If the "other" window isn't in
- * this process, NULL is returned.
+ * embedded window, and vice versa. If the "other" window isn't in this
+ * process, NULL is returned.
*
* Side effects:
* None.
@@ -684,14 +663,14 @@ TkpRedirectKeyEvent(
TkWindow *
TkpGetOtherWindow(
- TkWindow *winPtr) /* Tk's structure for a container or
- * embedded window. */
+ TkWindow *winPtr) /* Tk's structure for a container or embedded
+ * window. */
{
Container *containerPtr;
/*
- * TkpGetOtherWindow returns NULL if both windows are not
- * in the same process...
+ * TkpGetOtherWindow returns NULL if both windows are not in the same
+ * process...
*/
if (!(winPtr->flags & TK_BOTH_HALVES)) {
@@ -733,7 +712,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);
@@ -746,19 +725,19 @@ EmbeddedEventProc(
* ContainerEventProc --
*
* This procedure is invoked by the Tk event dispatcher when various
- * useful events are received for the children of a container
- * window. It forwards relevant information, such as geometry
- * requests, from the events into the container's application.
+ * useful events are received for the children of a container window. It
+ * forwards relevant information, such as geometry requests, from the
+ * events into the container's application.
*
- * NOTE: on the Mac, only the DestroyNotify branch is ever taken.
- * We don't synthesize the other events.
+ * NOTE: on the Mac, only the DestroyNotify branch is ever taken. We
+ * don't synthesize the other events.
*
* Results:
* None.
*
* Side effects:
- * Depends on the event. For example, when ConfigureRequest events
- * occur, geometry information gets set for the container window.
+ * Depends on the event. For example, when ConfigureRequest events occur,
+ * geometry information gets set for the container window.
*
*----------------------------------------------------------------------
*/
@@ -768,18 +747,18 @@ ContainerEventProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- TkWindow *winPtr = (TkWindow *) clientData;
+ TkWindow *winPtr = clientData;
Container *containerPtr;
Tk_ErrorHandler errHandler;
/*
- * Ignore any X protocol errors that happen in this procedure
- * (almost any operation could fail, for example, if the embedded
- * application has deleted its window).
+ * Ignore any X protocol errors that happen in this procedure (almost any
+ * operation could fail, for example, if the embedded application has
+ * deleted its window).
*/
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, (Tk_ErrorProc *) NULL, (ClientData) NULL);
+ -1, -1, NULL, NULL);
/*
* Find the Container structure associated with the parent window.
@@ -795,10 +774,9 @@ ContainerEventProc(
if (eventPtr->type == CreateNotify) {
/*
- * A new child window has been created in the container. Record
- * its id in the Container structure (if more than one child is
- * created, just remember the last one and ignore the earlier
- * ones).
+ * A new child window has been created in the container. Record its id
+ * in the Container structure (if more than one child is created, just
+ * remember the last one and ignore the earlier ones).
*/
containerPtr->embedded = eventPtr->xcreatewindow.window;
@@ -806,14 +784,13 @@ ContainerEventProc(
if ((eventPtr->xconfigurerequest.x != 0)
|| (eventPtr->xconfigurerequest.y != 0)) {
/*
- * The embedded application is trying to move itself, which
- * isn't legal. At this point, the window hasn't actually
- * moved, but we need to send it a ConfigureNotify event to
- * let it know that its request has been denied. If the
- * embedded application was also trying to resize itself, a
- * ConfigureNotify will be sent by the geometry management
- * code below, so we don't need to do anything. Otherwise,
- * generate a synthetic event.
+ * The embedded application is trying to move itself, which isn't
+ * legal. At this point, the window hasn't actually moved, but we
+ * need to send it a ConfigureNotify event to let it know that its
+ * request has been denied. If the embedded application was also
+ * trying to resize itself, a ConfigureNotify will be sent by the
+ * geometry management code below, so we don't need to do
+ * anything. Otherwise, generate a synthetic event.
*/
if ((eventPtr->xconfigurerequest.width == winPtr->changes.width)
@@ -828,8 +805,8 @@ ContainerEventProc(
} else if (eventPtr->type == MapRequest) {
/*
* The embedded application's map request was ignored and simply
- * passed on to us, so we have to map the window for it to appear
- * on the screen.
+ * passed on to us, so we have to map the window for it to appear on
+ * the screen.
*/
XMapWindow(eventPtr->xmaprequest.display,
@@ -849,11 +826,10 @@ ContainerEventProc(
*
* EmbedStructureProc --
*
- * This procedure is invoked by the Tk event dispatcher when
- * a container window owned by this application gets resized
- * (and also at several other times that we don't care about).
- * This procedure reflects the size change in the embedded
- * window that corresponds to the container.
+ * This procedure is invoked by the Tk event dispatcher when a container
+ * window owned by this application gets resized (and also at several
+ * other times that we don't care about). This procedure reflects the
+ * size change in the embedded window that corresponds to the container.
*
* Results:
* None.
@@ -869,7 +845,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) {
@@ -880,12 +856,10 @@ EmbedStructureProc(
*/
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, (Tk_ErrorProc *) NULL, (ClientData) NULL);
+ -1, -1, NULL, NULL);
Tk_MoveResizeWindow((Tk_Window) containerPtr->embeddedPtr, 0, 0,
- (unsigned int) Tk_Width(
- (Tk_Window) containerPtr->parentPtr),
- (unsigned int) Tk_Height(
- (Tk_Window) containerPtr->parentPtr));
+ (unsigned) Tk_Width((Tk_Window) containerPtr->parentPtr),
+ (unsigned) Tk_Height((Tk_Window)containerPtr->parentPtr));
Tk_DeleteErrorHandler(errHandler);
}
} else if (eventPtr->type == DestroyNotify) {
@@ -898,10 +872,10 @@ EmbedStructureProc(
*
* EmbedActivateProc --
*
- * This procedure is invoked by the Tk event dispatcher when
- * Activate and Deactivate events occur for a container window owned
- * by this application. It is responsible for forwarding an activate
- * event down into the embedded toplevel.
+ * This procedure is invoked by the Tk event dispatcher when Activate and
+ * Deactivate events occur for a container window owned by this
+ * application. It is responsible for forwarding an activate event down
+ * into the embedded toplevel.
*
* Results:
* None.
@@ -917,7 +891,7 @@ EmbedActivateProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- Container *containerPtr = (Container *) clientData;
+ Container *containerPtr = clientData;
if (containerPtr->embeddedPtr != NULL) {
if (eventPtr->type == ActivateNotify) {
@@ -933,11 +907,10 @@ EmbedActivateProc(
*
* EmbedFocusProc --
*
- * This procedure is invoked by the Tk event dispatcher when
- * FocusIn and FocusOut events occur for a container window owned
- * by this application. It is responsible for moving the focus
- * back and forth between a container application and an embedded
- * application.
+ * This procedure is invoked by the Tk event dispatcher when FocusIn and
+ * FocusOut events occur for a container window owned by this
+ * application. It is responsible for moving the focus back and forth
+ * between a container application and an embedded application.
*
* Results:
* None.
@@ -953,37 +926,37 @@ EmbedFocusProc(
ClientData clientData, /* Token for container window. */
XEvent *eventPtr) /* ResizeRequest event. */
{
- Container *containerPtr = (Container *) clientData;
+ Container *containerPtr = clientData;
Display *display;
XEvent event;
if (containerPtr->embeddedPtr != NULL) {
- display = Tk_Display(containerPtr->parentPtr);
+ display = Tk_Display(containerPtr->parentPtr);
event.xfocus.serial = LastKnownRequestProcessed(display);
event.xfocus.send_event = false;
event.xfocus.display = display;
event.xfocus.mode = NotifyNormal;
event.xfocus.window = containerPtr->embedded;
- if (eventPtr->type == FocusIn) {
- /*
- * The focus just arrived at the container. Change the X focus
- * to move it to the embedded application, if there is one.
- * Ignore X errors that occur during this operation (it's
- * possible that the new focus window isn't mapped).
- */
+ if (eventPtr->type == FocusIn) {
+ /*
+ * The focus just arrived at the container. Change the X focus to
+ * move it to the embedded application, if there is one. Ignore X
+ * errors that occur during this operation (it's possible that the
+ * new focus window isn't mapped).
+ */
event.xfocus.detail = NotifyNonlinear;
event.xfocus.type = FocusIn;
-
} else if (eventPtr->type == FocusOut) {
- /* When the container gets a FocusOut event, it has to tell the embedded app
- * that it has lost the focus.
- */
+ /*
+ * When the container gets a FocusOut event, it has to tell the
+ * embedded app that it has lost the focus.
+ */
event.xfocus.type = FocusOut;
event.xfocus.detail = NotifyNonlinear;
- }
+ }
Tk_QueueWindowEvent(&event, TCL_QUEUE_MARK);
}
@@ -994,10 +967,10 @@ EmbedFocusProc(
*
* EmbedGeometryRequest --
*
- * This procedure is invoked when an embedded application requests
- * a particular size. It processes the request (which may or may
- * not actually honor the request) and reflects the results back
- * to the embedded application.
+ * This procedure is invoked when an embedded application requests a
+ * particular size. It processes the request (which may or may not
+ * actually honor the request) and reflects the results back to the
+ * embedded application.
*
* NOTE: On the Mac, this is a stub, since we don't synthesize
* ConfigureRequest events.
@@ -1006,10 +979,10 @@ EmbedFocusProc(
* None.
*
* Side effects:
- * If we deny the child's size change request, a Configure event
- * is synthesized to let the child know how big it ought to be.
- * Events get processed while we're waiting for the geometry
- * managers to do their thing.
+ * If we deny the child's size change request, a Configure event is
+ * synthesized to let the child know how big it ought to be. Events get
+ * processed while we're waiting for the geometry managers to do their
+ * thing.
*
*----------------------------------------------------------------------
*/
@@ -1022,13 +995,13 @@ EmbedGeometryRequest(
TkWindow *winPtr = containerPtr->parentPtr;
/*
- * Forward the requested size into our geometry management hierarchy
- * via the container window. We need to send a Configure event back
- * to the embedded application if we decide not to honor its
- * request; to make this happen, process all idle event handlers
- * synchronously here (so that the geometry managers have had a
- * chance to do whatever they want to do), and if the window's size
- * didn't change then generate a configure event.
+ * Forward the requested size into our geometry management hierarchy via
+ * the container window. We need to send a Configure event back to the
+ * embedded application if we decide not to honor its request; to make
+ * this happen, process all idle event handlers synchronously here (so
+ * that the geometry managers have had a chance to do whatever they want
+ * to do), and if the window's size didn't change then generate a
+ * configure event.
*/
Tk_GeometryRequest((Tk_Window) winPtr, width, height);
@@ -1046,13 +1019,12 @@ EmbedGeometryRequest(
*
* EmbedSendConfigure --
*
- * This is currently a stub. It is called to notify an
- * embedded application of its current size and location. This
- * procedure is called when the embedded application made a
- * geometry request that we did not grant, so that the embedded
- * application knows that its geometry didn't change after all.
- * It is a response to ConfigureRequest events, which we do not
- * currently synthesize on the Mac
+ * This is currently a stub. It is called to notify an embedded
+ * application of its current size and location. This procedure is called
+ * when the embedded application made a geometry request that we did not
+ * grant, so that the embedded application knows that its geometry didn't
+ * change after all. It is a response to ConfigureRequest events, which
+ * we do not currently synthesize on the Mac
*
* Results:
* None.
@@ -1074,9 +1046,9 @@ EmbedSendConfigure(
*
* EmbedWindowDeleted --
*
- * This procedure is invoked when a window involved in embedding
- * (as either the container or the embedded application) is
- * destroyed. It cleans up the Container structure for the window.
+ * This procedure is invoked when a window involved in embedding (as
+ * either the container or the embedded application) is destroyed. It
+ * cleans up the Container structure for the window.
*
* Results:
* None.
@@ -1095,16 +1067,14 @@ EmbedWindowDeleted(
Container *containerPtr, *prevPtr;
/*
- * Find the Container structure for this window. Delete the
- * information about the embedded application and free the container's
- * record.
+ * Find the Container structure for this window. Delete the information
+ * about the embedded application and free the container's record.
*/
prevPtr = NULL;
containerPtr = firstContainerPtr;
while (1) {
if (containerPtr->embeddedPtr == winPtr) {
-
/*
* We also have to destroy our parent, to clean up the container.
* Fabricate an event to do this.
@@ -1115,20 +1085,18 @@ EmbedWindowDeleted(
XEvent event;
event.xany.serial =
- Tk_Display(containerPtr->parentPtr)->request;
- event.xany.send_event = False;
- event.xany.display = Tk_Display(containerPtr->parentPtr);
-
- event.xany.type = DestroyNotify;
- event.xany.window = containerPtr->parent;
- event.xdestroywindow.event = containerPtr->parent;
- Tk_QueueWindowEvent(&event, TCL_QUEUE_HEAD);
-
+ Tk_Display(containerPtr->parentPtr)->request;
+ event.xany.send_event = False;
+ event.xany.display = Tk_Display(containerPtr->parentPtr);
+
+ event.xany.type = DestroyNotify;
+ event.xany.window = containerPtr->parent;
+ event.xdestroywindow.event = containerPtr->parent;
+ Tk_QueueWindowEvent(&event, TCL_QUEUE_HEAD);
}
containerPtr->embedded = None;
containerPtr->embeddedPtr = NULL;
-
break;
}
if (containerPtr->parentPtr == winPtr) {