summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixEmbed.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2005-11-14 11:54:21 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2005-11-14 11:54:21 (GMT)
commit1f3d41930a33bf010c0159ee6409e1ac74d81d61 (patch)
tree00291dcacfd5759e37d31a967906ccc3e3514e27 /unix/tkUnixEmbed.c
parent019c6df65f5e989c826a7bc71e8b03e7a0592f7b (diff)
downloadtk-1f3d41930a33bf010c0159ee6409e1ac74d81d61.zip
tk-1f3d41930a33bf010c0159ee6409e1ac74d81d61.tar.gz
tk-1f3d41930a33bf010c0159ee6409e1ac74d81d61.tar.bz2
ANSIfy
Diffstat (limited to 'unix/tkUnixEmbed.c')
-rw-r--r--unix/tkUnixEmbed.c562
1 files changed, 276 insertions, 286 deletions
diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c
index 40d54ad..a74ed83 100644
--- a/unix/tkUnixEmbed.c
+++ b/unix/tkUnixEmbed.c
@@ -1,17 +1,17 @@
-/*
+/*
* tkUnixEmbed.c --
*
- * This file contains platform-specific procedures for UNIX to provide
+ * 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).
+ * application can use as its main window an internal window from some
+ * other application).
*
* Copyright (c) 1996-1997 Sun Microsystems, Inc.
*
- * 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: tkUnixEmbed.c,v 1.8 2005/01/09 18:28:06 chengyemao Exp $
+ * RCS: @(#) $Id: tkUnixEmbed.c,v 1.9 2005/11/14 11:54:21 dkf Exp $
*/
#include "tkInt.h"
@@ -19,90 +19,87 @@
/*
* 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; /* X's window id for the parent of
- * the pair (the container). */
- Window parentRoot; /* Id for the root window of parent's
- * screen. */
- TkWindow *parentPtr; /* Tk's information about the container,
- * or NULL if the container isn't
- * in this process. */
- Window wrapper; /* X's window id for the wrapper
- * window 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.
- * Note that this is *not* the
- * same window as wrapper: wrapper is
- * the parent of embeddedPtr. */
- struct Container *nextPtr; /* Next in list of all containers in
- * this process. */
+ Window parent; /* X's window id for the parent of the pair
+ * (the container). */
+ Window parentRoot; /* Id for the root window of parent's
+ * screen. */
+ TkWindow *parentPtr; /* Tk's information about the container, or
+ * NULL if the container isn't in this
+ * process. */
+ Window wrapper; /* X's window id for the wrapper window 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. Note that this is *not*
+ * the same window as wrapper: wrapper is the
+ * parent of embeddedPtr. */
+ struct Container *nextPtr; /* Next in list of all containers in this
+ * process. */
} Container;
typedef struct ThreadSpecificData {
- Container *firstContainerPtr; /* First in list of all containers
- * managed by this process. */
+ Container *firstContainerPtr;
+ /* First in list of all containers managed by
+ * this process. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
/*
- * Prototypes for static procedures defined in this file:
+ * Prototypes for static functions defined in this file:
*/
-static void ContainerEventProc _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-static void EmbeddedEventProc _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-static int EmbedErrorProc _ANSI_ARGS_((ClientData clientData,
- XErrorEvent *errEventPtr));
-static void EmbedFocusProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void EmbedGeometryRequest _ANSI_ARGS_((
- Container * containerPtr, int width, int height));
-static void EmbedSendConfigure _ANSI_ARGS_((
- Container *containerPtr));
-static void EmbedStructureProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void EmbedWindowDeleted _ANSI_ARGS_((TkWindow *winPtr));
+static void ContainerEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static void EmbeddedEventProc(ClientData clientData,
+ XEvent *eventPtr);
+static int EmbedErrorProc(ClientData clientData,
+ XErrorEvent *errEventPtr);
+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);
/*
*----------------------------------------------------------------------
*
* 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 function 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:
- * Changes the colormap and other visual information to match that
- * of the parent window given by "string".
+ * Changes the colormap and other visual information to match that of the
+ * parent window given by "string".
*
*----------------------------------------------------------------------
*/
int
-TkpUseWindow(interp, tkwin, string)
- 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
+TkpUseWindow(
+ 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;
@@ -111,11 +108,12 @@ TkpUseWindow(interp, tkwin, string)
Tk_ErrorHandler handler;
Container *containerPtr;
XWindowAttributes parentAtts;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->window != None) {
- Tcl_AppendResult(interp, "can't modify container after widget is created", (char *) NULL);
+ Tcl_AppendResult(interp,
+ "can't modify container after widget is created", NULL);
return TCL_ERROR;
}
if (Tcl_GetInt(interp, string, &id) != TCL_OK) {
@@ -127,30 +125,30 @@ TkpUseWindow(interp, tkwin, string)
if (usePtr != NULL) {
if (!(usePtr->flags & TK_CONTAINER)) {
Tcl_AppendResult(interp, "window \"", usePtr->pathName,
- "\" doesn't have -container option set", (char *) NULL);
+ "\" doesn't have -container option set", NULL);
return TCL_ERROR;
}
}
/*
* Tk sets the window colormap to the screen default colormap in
- * tkWindow.c:AllocWindow. This doesn't work well for embedded
- * windows. So we override the colormap and visual settings to be
- * the same as the parent window (which is in the container app).
+ * tkWindow.c:AllocWindow. This doesn't work well for embedded windows. So
+ * we override the colormap and visual settings to be the same as the
+ * parent window (which is in the container app).
*/
anyError = 0;
handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1,
EmbedErrorProc, (ClientData) &anyError);
if (!XGetWindowAttributes(winPtr->display, parent, &parentAtts)) {
- anyError = 1;
+ anyError = 1;
}
XSync(winPtr->display, False);
Tk_DeleteErrorHandler(handler);
if (anyError) {
if (interp != NULL) {
Tcl_AppendResult(interp, "couldn't create child of window \"",
- string, "\"", (char *) NULL);
+ string, "\"", NULL);
}
return TCL_ERROR;
}
@@ -158,18 +156,18 @@ TkpUseWindow(interp, tkwin, string)
parentAtts.colormap);
/*
- * Create an event handler to clean up the Container structure when
- * tkwin is eventually deleted.
+ * Create an event handler to clean up the Container structure when tkwin
+ * is eventually deleted.
*/
Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc,
(ClientData) winPtr);
/*
- * Save information about the container and the embedded window
- * in a Container structure. If there is already an existing
- * Container structure, it means that both container and embedded
- * app. are in the same process.
+ * Save information about the container and the embedded window in a
+ * Container structure. If there is already an existing Container
+ * structure, it means that both container and embedded app. are in the
+ * same process.
*/
for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL;
@@ -199,8 +197,8 @@ TkpUseWindow(interp, tkwin, string)
*
* TkpMakeWindow --
*
- * Create an actual window system window object based on the
- * current attributes of the specified TkWindow.
+ * Create an actual window system window object based on the current
+ * attributes of the specified TkWindow.
*
* Results:
* Returns the handle to the new window, or None on failure.
@@ -212,22 +210,22 @@ TkpUseWindow(interp, tkwin, string)
*/
Window
-TkpMakeWindow(winPtr, parent)
- TkWindow *winPtr; /* Tk's information about the window that
- * is to be instantiated. */
- Window parent; /* Window system token for the parent in
- * which the window is to be created. */
+TkpMakeWindow(
+ TkWindow *winPtr, /* Tk's information about the window that is
+ * to be instantiated. */
+ Window parent) /* Window system token for the parent in which
+ * the window is to be created. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->flags & TK_EMBEDDED) {
/*
- * This window is embedded. Don't create the new window in the
- * given parent; instead, create it as a child of the root window
- * of the container's screen. The window will get reparented
- * into a wrapper window later.
+ * This window is embedded. Don't create the new window in the given
+ * parent; instead, create it as a child of the root window of the
+ * container's screen. The window will get reparented into a wrapper
+ * window later.
*/
for (containerPtr = tsdPtr->firstContainerPtr; ;
@@ -255,10 +253,9 @@ TkpMakeWindow(winPtr, parent)
*
* 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 function 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.
@@ -270,18 +267,18 @@ TkpMakeWindow(winPtr, parent)
*/
void
-TkpMakeContainer(tkwin)
- Tk_Window tkwin; /* Token for a window that is about to
- * become a container. */
+TkpMakeContainer(
+ Tk_Window tkwin) /* Token for a window that is about to become
+ * a container. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
- * Register the window as a container so that, for example, we can
- * find out later if the embedded app. is in the same process.
+ * Register the window as a container so that, for example, we can find
+ * out later if the embedded app. is in the same process.
*/
Tk_MakeWindowExist(tkwin);
@@ -296,10 +293,10 @@ TkpMakeContainer(tkwin)
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.
+ * 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.
*/
winPtr->atts.event_mask |= SubstructureRedirectMask|SubstructureNotifyMask;
@@ -318,12 +315,11 @@ TkpMakeContainer(tkwin)
*
* EmbedErrorProc --
*
- * This procedure is invoked if an error occurs while creating
- * an embedded window.
+ * This function is invoked if an error occurs while creating an embedded
+ * window.
*
* Results:
- * Always returns 0 to indicate that the error has been properly
- * handled.
+ * Always returns 0 to indicate that the error has been properly handled.
*
* Side effects:
* The integer pointed to by the clientData argument is set to 1.
@@ -332,10 +328,10 @@ TkpMakeContainer(tkwin)
*/
static int
-EmbedErrorProc(clientData, errEventPtr)
- ClientData clientData; /* Points to integer to set. */
- XErrorEvent *errEventPtr; /* Points to information about error
- * (not used). */
+EmbedErrorProc(
+ ClientData clientData, /* Points to integer to set. */
+ XErrorEvent *errEventPtr) /* Points to information about error (not
+ * used). */
{
int *iPtr = (int *) clientData;
@@ -348,9 +344,9 @@ EmbedErrorProc(clientData, errEventPtr)
*
* EmbeddedEventProc --
*
- * This procedure is invoked by the Tk event dispatcher when various
- * useful events are received for a window that is embedded in
- * another application.
+ * This function is invoked by the Tk event dispatcher when various
+ * useful events are received for a window that is embedded in another
+ * application.
*
* Results:
* None.
@@ -363,9 +359,9 @@ EmbedErrorProc(clientData, errEventPtr)
*/
static void
-EmbeddedEventProc(clientData, eventPtr)
- ClientData clientData; /* Token for container window. */
- XEvent *eventPtr; /* ResizeRequest event. */
+EmbeddedEventProc(
+ ClientData clientData, /* Token for container window. */
+ XEvent *eventPtr) /* ResizeRequest event. */
{
TkWindow *winPtr = (TkWindow *) clientData;
@@ -379,40 +375,40 @@ EmbeddedEventProc(clientData, eventPtr)
*
* 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.
+ * This function 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.
*
* 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.
*
*----------------------------------------------------------------------
*/
static void
-ContainerEventProc(clientData, eventPtr)
- ClientData clientData; /* Token for container window. */
- XEvent *eventPtr; /* ResizeRequest event. */
+ContainerEventProc(
+ ClientData clientData, /* Token for container window. */
+ XEvent *eventPtr) /* ResizeRequest event. */
{
TkWindow *winPtr = (TkWindow *) clientData;
Container *containerPtr;
Tk_ErrorHandler errHandler;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
- * 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 function (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, (ClientData) NULL);
/*
* Find the Container structure associated with the parent window.
@@ -428,31 +424,28 @@ ContainerEventProc(clientData, eventPtr)
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). Also set the child's size to match the container.
+ * 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). Also set the
+ * child's size to match the container.
*/
containerPtr->wrapper = eventPtr->xcreatewindow.window;
XMoveResizeWindow(eventPtr->xcreatewindow.display,
containerPtr->wrapper, 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));
} else if (eventPtr->type == ConfigureRequest) {
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)
@@ -467,15 +460,15 @@ ContainerEventProc(clientData, eventPtr)
} 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,
eventPtr->xmaprequest.window);
} else if (eventPtr->type == DestroyNotify) {
/*
- * The embedded application is gone. Destroy the container window.
+ * The embedded application is gone. Destroy the container window.
*/
Tk_DestroyWindow((Tk_Window) winPtr);
@@ -488,11 +481,10 @@ ContainerEventProc(clientData, eventPtr)
*
* 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 function 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 function reflects the size
+ * change in the embedded window that corresponds to the container.
*
* Results:
* None.
@@ -504,9 +496,9 @@ ContainerEventProc(clientData, eventPtr)
*/
static void
-EmbedStructureProc(clientData, eventPtr)
- ClientData clientData; /* Token for container window. */
- XEvent *eventPtr; /* ResizeRequest event. */
+EmbedStructureProc(
+ ClientData clientData, /* Token for container window. */
+ XEvent *eventPtr) /* ResizeRequest event. */
{
Container *containerPtr = (Container *) clientData;
Tk_ErrorHandler errHandler;
@@ -519,13 +511,11 @@ EmbedStructureProc(clientData, eventPtr)
*/
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, (Tk_ErrorProc *) NULL, (ClientData) NULL);
+ -1, -1, NULL, (ClientData) NULL);
XMoveResizeWindow(eventPtr->xconfigure.display,
containerPtr->wrapper, 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) {
@@ -538,11 +528,10 @@ EmbedStructureProc(clientData, eventPtr)
*
* 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 function 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.
@@ -554,9 +543,9 @@ EmbedStructureProc(clientData, eventPtr)
*/
static void
-EmbedFocusProc(clientData, eventPtr)
- ClientData clientData; /* Token for container window. */
- XEvent *eventPtr; /* ResizeRequest event. */
+EmbedFocusProc(
+ ClientData clientData, /* Token for container window. */
+ XEvent *eventPtr) /* ResizeRequest event. */
{
Container *containerPtr = (Container *) clientData;
Tk_ErrorHandler errHandler;
@@ -565,15 +554,15 @@ EmbedFocusProc(clientData, eventPtr)
display = Tk_Display(containerPtr->parentPtr);
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).
+ * 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 (containerPtr->wrapper != None) {
errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
- -1, -1, (Tk_ErrorProc *) NULL, (ClientData) NULL);
+ -1, -1, NULL, (ClientData) NULL);
XSetInputFocus(display, containerPtr->wrapper, RevertToParent,
CurrentTime);
Tk_DeleteErrorHandler(errHandler);
@@ -586,38 +575,38 @@ EmbedFocusProc(clientData, eventPtr)
*
* 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 function 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.
*
* Results:
* 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.
*
*----------------------------------------------------------------------
*/
static void
-EmbedGeometryRequest(containerPtr, width, height)
- Container *containerPtr; /* Information about the embedding. */
- int width, height; /* Size that the child has requested. */
+EmbedGeometryRequest(
+ Container *containerPtr, /* Information about the embedding. */
+ int width, int height) /* Size that the child has requested. */
{
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);
@@ -635,11 +624,11 @@ EmbedGeometryRequest(containerPtr, width, height)
*
* EmbedSendConfigure --
*
- * This procedure synthesizes a ConfigureNotify event 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.
+ * This function synthesizes a ConfigureNotify event to notify an
+ * embedded application of its current size and location. This function
+ * 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.
*
* Results:
* None.
@@ -651,15 +640,14 @@ EmbedGeometryRequest(containerPtr, width, height)
*/
static void
-EmbedSendConfigure(containerPtr)
- Container *containerPtr; /* Information about the embedding. */
+EmbedSendConfigure(
+ Container *containerPtr) /* Information about the embedding. */
{
TkWindow *winPtr = containerPtr->parentPtr;
XEvent event;
event.xconfigure.type = ConfigureNotify;
- event.xconfigure.serial =
- LastKnownRequestProcessed(winPtr->display);
+ event.xconfigure.serial = LastKnownRequestProcessed(winPtr->display);
event.xconfigure.send_event = True;
event.xconfigure.display = winPtr->display;
event.xconfigure.event = containerPtr->wrapper;
@@ -672,24 +660,23 @@ EmbedSendConfigure(containerPtr)
event.xconfigure.override_redirect = False;
/*
- * Note: when sending the event below, the ButtonPressMask
- * causes the event to be sent only to applications that have
- * selected for ButtonPress events, which should be just the
- * embedded application.
+ * Note: when sending the event below, the ButtonPressMask causes the
+ * event to be sent only to applications that have selected for
+ * ButtonPress events, which should be just the embedded application.
*/
XSendEvent(winPtr->display, containerPtr->wrapper, False,
0, &event);
/*
- * The following needs to be done if the embedded window is
- * not in the same application as the container window.
+ * The following needs to be done if the embedded window is not in the
+ * same application as the container window.
*/
if (containerPtr->embeddedPtr == NULL) {
XMoveResizeWindow(winPtr->display, containerPtr->wrapper, 0, 0,
- (unsigned int) winPtr->changes.width,
- (unsigned int) winPtr->changes.height);
+ (unsigned) winPtr->changes.width,
+ (unsigned) winPtr->changes.height);
}
}
@@ -698,13 +685,13 @@ EmbedSendConfigure(containerPtr)
*
* 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 function 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.
@@ -713,15 +700,15 @@ EmbedSendConfigure(containerPtr)
*/
TkWindow *
-TkpGetOtherWindow(winPtr)
- TkWindow *winPtr; /* Tk's structure for a container or
- * embedded window. */
+TkpGetOtherWindow(
+ TkWindow *winPtr) /* Tk's structure for a container or embedded
+ * window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- for (containerPtr = tsdPtr->firstContainerPtr;
+ for (containerPtr = tsdPtr->firstContainerPtr;
containerPtr != NULL;
containerPtr = containerPtr->nextPtr) {
if (containerPtr->embeddedPtr == winPtr) {
@@ -739,13 +726,13 @@ TkpGetOtherWindow(winPtr)
*
* 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 function 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 function's job
+ * is to forward the event back to the application where it really
+ * belongs.
*
* Results:
* None.
@@ -757,15 +744,15 @@ TkpGetOtherWindow(winPtr)
*/
void
-TkpRedirectKeyEvent(winPtr, eventPtr)
- TkWindow *winPtr; /* Window to which the event was originally
+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). */
{
Container *containerPtr;
Window saved;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -775,8 +762,8 @@ TkpRedirectKeyEvent(winPtr, eventPtr)
while (1) {
if (winPtr == NULL) {
/*
- * This window is being deleted. This is too confusing a
- * case to handle so discard the event.
+ * This window is being deleted. This is too confusing a case to
+ * handle so discard the event.
*/
return;
@@ -789,10 +776,10 @@ TkpRedirectKeyEvent(winPtr, eventPtr)
if (winPtr->flags & TK_EMBEDDED) {
/*
- * This application is embedded. If we got a key event without
- * officially having the focus, it means that the focus is
- * really in the container, but the mouse was over the embedded
- * application. Send the event back to the container.
+ * This application is embedded. If we got a key event without
+ * officially having the focus, it means that the focus is really in
+ * the container, but the mouse was over the embedded application.
+ * Send the event back to the container.
*/
for (containerPtr = tsdPtr->firstContainerPtr;
@@ -803,7 +790,7 @@ TkpRedirectKeyEvent(winPtr, eventPtr)
saved = eventPtr->xkey.window;
eventPtr->xkey.window = containerPtr->parent;
XSendEvent(eventPtr->xkey.display, eventPtr->xkey.window, False,
- KeyPressMask|KeyReleaseMask, eventPtr);
+ KeyPressMask|KeyReleaseMask, eventPtr);
eventPtr->xkey.window = saved;
}
}
@@ -813,10 +800,10 @@ TkpRedirectKeyEvent(winPtr, eventPtr)
*
* TkpClaimFocus --
*
- * This procedure is invoked when someone asks or 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 function is invoked when someone asks or 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.
@@ -828,16 +815,16 @@ TkpRedirectKeyEvent(winPtr, eventPtr)
*/
void
-TkpClaimFocus(topLevelPtr, force)
- 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. */
+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. */
{
XEvent event;
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!(topLevelPtr->flags & TK_EMBEDDED)) {
@@ -865,9 +852,8 @@ TkpClaimFocus(topLevelPtr, force)
*
* TkpTestembedCmd --
*
- * This procedure implements the "testembed" command. It returns
- * some or all of the information in the list pointed to by
- * firstContainerPtr.
+ * This function implements the "testembed" command. It returns some or
+ * all of the information in the list pointed to by firstContainerPtr.
*
* Results:
* A standard Tcl result.
@@ -879,17 +865,17 @@ TkpClaimFocus(topLevelPtr, force)
*/
int
-TkpTestembedCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window for application. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- CONST char **argv; /* Argument strings. */
+TkpTestembedCmd(
+ ClientData clientData, /* Main window for application. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int argc, /* Number of arguments. */
+ CONST char **argv) /* Argument strings. */
{
int all;
Container *containerPtr;
Tcl_DString dString;
char buffer[50];
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if ((argc > 1) && (strcmp(argv[1], "all") == 0)) {
@@ -903,13 +889,11 @@ TkpTestembedCmd(clientData, interp, argc, argv)
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, "");
@@ -919,13 +903,11 @@ TkpTestembedCmd(clientData, interp, argc, argv)
}
if (containerPtr->wrapper == None) {
Tcl_DStringAppendElement(&dString, "");
+ } else if (all) {
+ sprintf(buffer, "0x%x", (int) containerPtr->wrapper);
+ Tcl_DStringAppendElement(&dString, buffer);
} else {
- if (all) {
- sprintf(buffer, "0x%x", (int) containerPtr->wrapper);
- Tcl_DStringAppendElement(&dString, buffer);
- } else {
- Tcl_DStringAppendElement(&dString, "XXX");
- }
+ Tcl_DStringAppendElement(&dString, "XXX");
}
if (containerPtr->embeddedPtr == NULL) {
Tcl_DStringAppendElement(&dString, "");
@@ -944,9 +926,9 @@ TkpTestembedCmd(clientData, interp, argc, argv)
*
* 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 function 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.
@@ -958,16 +940,16 @@ TkpTestembedCmd(clientData, interp, argc, argv)
*/
static void
-EmbedWindowDeleted(winPtr)
- TkWindow *winPtr; /* Tk's information about window that
- * was deleted. */
+EmbedWindowDeleted(
+ TkWindow *winPtr) /* Tk's information about window that was
+ * deleted. */
{
Container *containerPtr, *prevPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
- * Find the Container structure for this window work. Delete the
+ * Find the Container structure for this window work. Delete the
* information about the embedded application and free the container's
* record.
*/
@@ -1003,12 +985,12 @@ EmbedWindowDeleted(winPtr)
*
* TkUnixContainerId --
*
- * Given an embedded window, this procedure returns the X window
+ * Given an embedded window, this function returns the X window
* identifier for the associated container window.
*
* Results:
- * The return value is the X window identifier for winPtr's
- * container window.
+ * The return value is the X window identifier for winPtr's container
+ * window.
*
* Side effects:
* None.
@@ -1017,14 +999,14 @@ EmbedWindowDeleted(winPtr)
*/
Window
-TkUnixContainerId(winPtr)
- TkWindow *winPtr; /* Tk's structure for an embedded window. */
+TkUnixContainerId(
+ TkWindow *winPtr) /* Tk's structure for an embedded window. */
{
Container *containerPtr;
- ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- for (containerPtr = tsdPtr->firstContainerPtr;
+ for (containerPtr = tsdPtr->firstContainerPtr;
containerPtr != NULL; containerPtr = containerPtr->nextPtr) {
if (containerPtr->embeddedPtr == winPtr) {
return containerPtr->parent;
@@ -1033,3 +1015,11 @@ TkUnixContainerId(winPtr)
Tcl_Panic("TkUnixContainerId couldn't find window");
return None;
}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */