diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2008-04-27 22:38:54 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2008-04-27 22:38:54 (GMT) |
commit | 4513cb9f431ea8c6b151913a016ec6c75bcac559 (patch) | |
tree | 681f7c2354a3726da3ab7da646d316c1275f540d /macosx/tkMacOSXEmbed.c | |
parent | 1876f5f7ee429456ad89540bcf659c092245bf1b (diff) | |
download | tk-4513cb9f431ea8c6b151913a016ec6c75bcac559.zip tk-4513cb9f431ea8c6b151913a016ec6c75bcac559.tar.gz tk-4513cb9f431ea8c6b151913a016ec6c75bcac559.tar.bz2 |
Get rid of pre-C89-isms (esp. CONST vs const).
Diffstat (limited to 'macosx/tkMacOSXEmbed.c')
-rw-r--r-- | macosx/tkMacOSXEmbed.c | 500 |
1 files changed, 235 insertions, 265 deletions
diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index a971c0d..47a9ed7 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -3,52 +3,49 @@ * * 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-2007 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. * - * RCS: @(#) $Id: tkMacOSXEmbed.c,v 1.16 2007/12/13 15:27:09 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXEmbed.c,v 1.17 2008/04/27 22:39:12 dkf Exp $ */ #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; @@ -57,25 +54,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 @@ -95,7 +91,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; @@ -129,9 +126,8 @@ TkpMakeWindow( XEvent event; /* - * 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)) { @@ -158,22 +154,24 @@ 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++; } + /* * TODO: need general solution for visibility events. */ @@ -195,15 +193,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: @@ -214,12 +212,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; @@ -233,13 +231,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) { @@ -261,8 +258,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. */ @@ -290,11 +287,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; @@ -310,19 +307,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) { @@ -345,10 +340,8 @@ TkpUseWindow( containerPtr->embeddedPtr = macWin->winPtr; containerPtr->nextPtr = firstContainerPtr; firstContainerPtr = containerPtr; - } } else { - /* * The window is embedded in another Tk window. */ @@ -360,10 +353,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; @@ -375,8 +367,7 @@ TkpUseWindow( */ Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc, - (ClientData) winPtr); - + winPtr); } return TCL_OK; @@ -387,10 +378,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. @@ -403,18 +394,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); @@ -426,23 +416,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); } /* @@ -454,8 +443,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. @@ -464,8 +452,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; @@ -484,8 +472,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 @@ -504,20 +492,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); } /* @@ -525,10 +511,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. @@ -541,11 +527,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; @@ -560,7 +546,6 @@ TkpClaimFocus( /* Empty loop body. */ } - event.xfocus.type = FocusIn; event.xfocus.serial = LastKnownRequestProcessed(topLevelPtr->display); event.xfocus.send_event = 1; @@ -576,9 +561,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. @@ -594,7 +578,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; @@ -612,13 +596,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, ""); @@ -628,13 +610,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, ""); @@ -653,13 +633,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. @@ -674,9 +654,10 @@ 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). */ { + /* TODO: Implement this or decide it definitely needs no implementation */ } /* @@ -684,13 +665,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. @@ -700,14 +681,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)) { @@ -749,7 +730,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); @@ -762,19 +743,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. * *---------------------------------------------------------------------- */ @@ -784,18 +765,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. @@ -811,10 +792,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; @@ -822,14 +802,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) @@ -844,8 +823,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, @@ -865,11 +844,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. @@ -885,7 +863,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) { @@ -896,12 +874,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) { @@ -914,10 +890,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. @@ -933,7 +909,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) { @@ -949,11 +925,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. @@ -969,37 +944,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); } @@ -1010,10 +985,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. @@ -1022,10 +997,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. * *---------------------------------------------------------------------- */ @@ -1038,13 +1013,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); @@ -1062,13 +1037,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. @@ -1090,9 +1064,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. @@ -1111,16 +1085,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. @@ -1131,20 +1103,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) { |