diff options
author | das <das> | 2002-08-31 06:12:19 (GMT) |
---|---|---|
committer | das <das> | 2002-08-31 06:12:19 (GMT) |
commit | e947c1d0d386b229818958dc12ea0cc20e4ec582 (patch) | |
tree | 303845583d22d9e5e5f3f53edf451167cb5847e6 /macosx/tkMacOSXWindowEvent.c | |
parent | 62d94160aed093a9505d60181a1509e69bd02bb6 (diff) | |
download | tk-e947c1d0d386b229818958dc12ea0cc20e4ec582.zip tk-e947c1d0d386b229818958dc12ea0cc20e4ec582.tar.gz tk-e947c1d0d386b229818958dc12ea0cc20e4ec582.tar.bz2 |
*** macosx-8-4-branch merged into the mainline [tcl patch #602770] ***macosx_8_4_merge_2002_08_31_trunk
* generic/tk.decls:
* generic/tkInt.decls: added new "aqua" specific entries to the
stubs tables. Changed all "unix" entries to "x11" to allow us to
distinguish and build both "aqua" on MacOSX and "x11" on MacOSX.
* generic/tk.h: added a #ifnded RESOURCE_INCLUDED so that tk.h can
be passed to the resource compiler.
* generic/tkCmds.c (Tk_TkObjCmd): added [tk windowingsystem]
subcommand: returns "x11" when running on X11, "win32" on Windows,
"classic" on MacOS9 and "aqua" on MacOSX Aqua (i.e. Carbon)
* generic/tkFont.c (TkFontGetFirstTextLayout): new private function
returning the first chunk of a Tk_TextLayout, i.e. until the first
font change on the first line (or the whole first line if there is
no such font change).
* generic/tkMain.c: made Tcl_ThreadDataKey static
* library/demos/puzzle.tcl: fixed button metrics for aqua
* tests/cursor.test: check for presence of arrow cursor instead of
heart cursor
* xlib/xcolors.c: changed xColors static initialization to more
standard C
* macosx/Wish.pbproj/jingham.pbxuser (new):
* macosx/Wish.pbproj/project.pbxproj (new): project for Apple's
ProjectBuilder IDE.
* macosx/Makefile (new): simple makefile for building the project
from the command line via the ProjectBuilder tool 'pbxbuild'.
* macosx/tkMacOSXAppInit.c (new): macosx specific AppInit looking
for a AppMain.tcl file in its bundled Resources/Scripts folder. If
present, argv[1] is set to that file and the Scripts folder is
added to the auto_path. This allows tk apps to embed scripts within
their bundle directory structure.
* macosx/tkMacOSXInit.c (new): macosx adapted version of
tkUnixInit.c: we initialize & cache the Carbon native encoding
(e.g. 'macRoman') and try to find the tk script library files
inside Tk packaged as a framework.
* macosx/tkMacOSXNotify.c (new): new macosx specific merged
Carbon/select-based notifier.
* macosx/tkMacOSXEvent.c (new):
* macosx/tkMacOSXEvent.h (new):
* macosx/tkMacOSXKeyEvent.c (new):
* macosx/tkMacOSXMouseEvent.c (new):
* macosx/tkMacOSXWindowEvent.c (new): new macosx specific event
handling functionality.
* macosx/tkMacOSX.h (new):
* macosx/tkMacOSXBitmap.c (new):
* macosx/tkMacOSXButton.c (new):
* macosx/tkMacOSXClipboard.c (new):
* macosx/tkMacOSXColor.c (new):
* macosx/tkMacOSXConfig.c (new):
* macosx/tkMacOSXCursor.c (new):
* macosx/tkMacOSXDefault.h (new):
* macosx/tkMacOSXDialog.c (new):
* macosx/tkMacOSXDraw.c (new):
* macosx/tkMacOSXEmbed.c (new):
* macosx/tkMacOSXFont.c (new):
* macosx/tkMacOSXHLEvents.c (new):
* macosx/tkMacOSXInt.h (new):
* macosx/tkMacOSXKeyboard.c (new):
* macosx/tkMacOSXMenu.c (new):
* macosx/tkMacOSXMenubutton.c (new):
* macosx/tkMacOSXMenus.c (new):
* macosx/tkMacOSXPort.h (new):
* macosx/tkMacOSXRegion.c (new):
* macosx/tkMacOSXScale.c (new):
* macosx/tkMacOSXScrlbr.c (new):
* macosx/tkMacOSXSubwindows.c (new):
* macosx/tkMacOSXTest.c (new):
* macosx/tkMacOSXUtil.c (new):
* macosx/tkMacOSXUtil.h (new):
* macosx/tkMacOSXWm.c (new):
* macosx/tkMacOSXWm.h (new):
* macosx/tkMacOSXXStubs.c (new): macosx ports of classic mac Tk
implementation in tk/mac.
* macosx/tkMacOSXSend.c (new): only send to local interp
implemented currently.
* macosx/tkMacOSXDebug.h (new):
* macosx/tkMacOSXDebug.c (new): new macosx specific functions for
debugging MacOS events, regions, etc.
* macosx/tkAboutDlg.r (new):
* macosx/tkMacOSXApplication.r (new):
* macosx/tkMacOSXCursors.r (new):
* macosx/tkMacOSXLibrary.r (new):
* macosx/tkMacOSXMenu.r (new):
* macosx/tkMacOSXResource.r (new):
* macosx/tkMacOSXXCursors.r (new):
* macosx/tclets.r (new): sources for Rez resource compiler.
* macosx/Wish.icns (new): Wish application icon.
* generic/tk.h:
* generic/default.h:
* generic/tkBind.c:
* generic/tkCmds.c:
* generic/tkGrab.c:
* generic/tkPointer.c:
* generic/tkPort.h:
* generic/tkSelect.c:
* generic/tkStubLib.c:
* generic/tkTest.c:
* generic/tkText.c:
* generic/tkWindow.c:
* unix/tkUnix3d.c:
* xlib/xgc.c:
* xlib/X11/X.h:
* xlib/X11/Xlib.h:
* xlib/X11/Xutil.h: added #includes and #ifdefs for macosx
* library/bgerror.tcl:
* library/button.tcl:
* library/console.tcl:
* library/dialog.tcl:
* library/entry.tcl:
* library/listbox.tcl:
* library/menu.tcl:
* library/msgbox.tcl:
* library/scrlbar.tcl:
* library/spinbox.tcl:
* library/text.tcl:
* library/tk.tcl:
* library/demos/menu.tcl:
* library/demos/menubu.tcl:
* library/demos/widget: check [tk windowingsystem] instead of
and/or in addition to $tcl_platform(platform).
* generic/tkInt.h:
* mac/tkMacBitmap.c:
* mac/tkMacWm.c: added missing CONSTification
* generic/tkIntDecls.h:
* generic/tkIntPlatDecls.h:
* generic/tkIntXlibDecls.h:
* generic/tkPlatDecls.h:
* generic/tkStubInit.c: regen
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 693 |
1 files changed, 693 insertions, 0 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c new file mode 100644 index 0000000..d21d1f1 --- /dev/null +++ b/macosx/tkMacOSXWindowEvent.c @@ -0,0 +1,693 @@ +/* + * tkMacOSXWindowEvent.c -- + * + * This file defines the routines for both creating and handling + * Window Manager class events for Tk. + * + * Copyright 2001, Apple Computer, Inc. + * + * The following terms apply to all files originating from Apple + * Computer, Inc. ("Apple") and associated with the software + * unless explicitly disclaimed in individual files. + * + * + * Apple hereby grants permission to use, copy, modify, + * distribute, and license this software and its documentation + * for any purpose, provided that existing copyright notices are + * retained in all copies and that this notice is included + * verbatim in any distributions. No written agreement, license, + * or royalty fee is required for any of the authorized + * uses. Modifications to this software may be copyrighted by + * their authors and need not follow the licensing terms + * described here, provided that the new terms are clearly + * indicated on the first page of each file where they apply. + * + * + * IN NO EVENT SHALL APPLE, THE AUTHORS OR DISTRIBUTORS OF THE + * SOFTWARE BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, + * INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF + * THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, + * EVEN IF APPLE OR THE AUTHORS HAVE BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. APPLE, THE AUTHORS AND + * DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS + * SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND APPLE,THE + * AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE + * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * GOVERNMENT USE: If you are acquiring this software on behalf + * of the U.S. government, the Government shall have only + * "Restricted Rights" in the software and related documentation + * as defined in the Federal Acquisition Regulations (FARs) in + * Clause 52.227.19 (c) (2). If you are acquiring the software + * on behalf of the Department of Defense, the software shall be + * classified as "Commercial Computer Software" and the + * Government shall have only "Restricted Rights" as defined in + * Clause 252.227-7013 (c) (1) of DFARs. Notwithstanding the + * foregoing, the authors grant the U.S. Government and others + * acting in its behalf permission to use and distribute the + * software in accordance with the terms specified in this + * license. + */ + +#include "tkMacOSXInt.h" +#include "tkPort.h" +#include "tkMacOSXWm.h" +#include "tkMacOSXEvent.h" +#include "tkMacOSXDebug.h" + +/* + * Declarations of global variables defined in this file. + */ + +int tkMacOSXAppInFront = true; /* Boolean variable for determining if + * we are the frontmost app. Only set + * in TkMacOSXProcessApplicationEvent + */ +static RgnHandle gDamageRgn; +static RgnHandle visRgn; + +/* + * Declaration of functions used only in this file + */ + +static int GenerateUpdateEvent( Window window); +static void GenerateUpdates( RgnHandle updateRgn, TkWindow *winPtr); +static int GenerateActivateEvents( Window window, int activeFlag); +static int GenerateFocusEvent( Window window, int activeFlag); + + + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXProcessApplicationEvent -- + * + * This processes Application level events, mainly activate + * and deactivate. + * + * Results: + * o. + * + * Side effects: + * Hide or reveal floating windows, and set tkMacOSXAppInFront. + * + *---------------------------------------------------------------------- + */ + +int +TkMacOSXProcessApplicationEvent( + TkMacOSXEvent *eventPtr, + MacEventStatus *statusPtr) +{ + statusPtr->handledByTk = 1; + switch (eventPtr->eKind) { + case kEventAppActivated: + tkMacOSXAppInFront = true; + ShowFloatingWindows(); + break; + case kEventAppDeactivated: + TkSuspendClipboard(); + tkMacOSXAppInFront = false; + HideFloatingWindows(); + break; + case kEventAppQuit: + case kEventAppLaunchNotification: + case kEventAppLaunched: + case kEventAppTerminated: + case kEventAppFrontSwitched: + break; + } + return 0; +} +/* + *---------------------------------------------------------------------- + * + * TkMacOSXProcessWindowEvent -- + * + * This processes Window level events, mainly activate + * and deactivate. + * + * Results: + * 0. + * + * Side effects: + * Cause Windows to be moved forward or backward in the + * window stack. + * + *---------------------------------------------------------------------- + */ + +int +TkMacOSXProcessWindowEvent( + TkMacOSXEvent * eventPtr, + MacEventStatus * statusPtr) +{ + OSStatus status; + WindowRef whichWindow; + Window window; + int eventFound; + + switch (eventPtr->eKind) { + case kEventWindowActivated: + case kEventWindowDeactivated: + case kEventWindowUpdate: + break; + default: + statusPtr->handledByTk = 1; + return 0; + break; + } + statusPtr->handledByTk = 1; + status = GetEventParameter(eventPtr->eventRef, + kEventParamDirectObject, + typeWindowRef, NULL, + sizeof(whichWindow), NULL, + &whichWindow); + if (status != noErr) { + fprintf ( stderr, "TkMacOSXHandleWindowEvent:Failed to retrieve window" ); + return 0; + } + + window = TkMacOSXGetXWindow(whichWindow); + + switch (eventPtr->eKind) { + case kEventWindowActivated: + eventFound |= GenerateActivateEvents(window, 1); + eventFound |= GenerateFocusEvent(window, 1); + break; + case kEventWindowDeactivated: + eventFound |= GenerateActivateEvents(window, 0); + eventFound |= GenerateFocusEvent(window, 0); + break; + case kEventWindowUpdate: + if (GenerateUpdateEvent(window)) { + eventFound = true; + } else { + statusPtr->handledByTk = 0; + } + break; + } + return 0; +} + +/* + *---------------------------------------------------------------------- + * + * GenerateUpdateEvent -- + * + * Given a Macintosh window update event this function generates all the + * X update events needed by Tk. + * + * Results: + * True if event(s) are generated - false otherwise. + * + * Side effects: + * Additional events may be place on the Tk event queue. + * + *---------------------------------------------------------------------- + */ +static int +GenerateUpdateEvent(Window window) +{ + WindowRef macWindow; + TkDisplay * dispPtr; + TkWindow * winPtr; + Rect bounds; + + dispPtr = TkGetDisplayList(); + winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window); + + if (winPtr ==NULL ){ + return false; + } + if (gDamageRgn == NULL) { + gDamageRgn = NewRgn(); + } + if (visRgn == NULL) { + visRgn = NewRgn(); + } + macWindow = GetWindowFromPort(TkMacOSXGetDrawablePort(window)); + BeginUpdate(macWindow); + /* + * In the Classic version of the code, this was the "visRgn" field of the WindowRec + * This no longer exists in OS X, so retrieve the content region instead + * Note that this is in screen coordinates + * We therefore convert it to window relative coordinates + */ + GetWindowRegion (macWindow, kWindowContentRgn, visRgn ); + GetRegionBounds(visRgn,&bounds); + bounds.right -= bounds.left; + bounds.bottom -= bounds.top; + bounds.left= + bounds.top=0; + RectRgn(visRgn, &bounds); + GenerateUpdates(visRgn, winPtr); + EndUpdate(macWindow); + return true; + } + +/* + *---------------------------------------------------------------------- + * + * GenerateUpdates -- + * + * Given a Macintosh update region and a Tk window this function + * geneates a X damage event for the window if it is within the + * update region. The function will then recursivly have each + * damaged window generate damage events for its child windows. + * + * Results: + * None. + * + * Side effects: + * Additional events may be place on the Tk event queue. + * + *---------------------------------------------------------------------- + */ + +static void +GenerateUpdates( + RgnHandle updateRgn, + TkWindow *winPtr) +{ + TkWindow *childPtr; + XEvent event; + Rect bounds, updateBounds, damageBounds; + + TkMacOSXWinBounds(winPtr, &bounds); + GetRegionBounds(updateRgn,&updateBounds); + + if (bounds.top > updateBounds.bottom || + updateBounds.top > bounds.bottom || + bounds.left > updateBounds.right || + updateBounds.left > bounds.right || + !RectInRgn(&bounds, updateRgn)) { + return; + } + if (!RectInRgn(&bounds, updateRgn)) { + return; + } + + event.xany.serial = Tk_Display(winPtr)->request; + event.xany.send_event = false; + event.xany.window = Tk_WindowId(winPtr); + event.xany.display = Tk_Display(winPtr); + + event.type = Expose; + + /* + * Compute the bounding box of the area that the damage occured in. + */ + + /* + * CopyRgn(TkMacOSXVisableClipRgn(winPtr), rgn); + * TODO: this call doesn't work doing resizes!!! + */ + RectRgn(gDamageRgn, &bounds); + SectRgn(gDamageRgn, updateRgn, gDamageRgn); + OffsetRgn(gDamageRgn, -bounds.left, -bounds.top); + GetRegionBounds(gDamageRgn,&damageBounds); + event.xexpose.x = damageBounds.left; + event.xexpose.y = damageBounds.top; + event.xexpose.width = damageBounds.right-damageBounds.left; + event.xexpose.height = damageBounds.bottom-damageBounds.top; + event.xexpose.count = 0; + + Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + + /* + * Generate updates for the children of this window + */ + + for (childPtr = winPtr->childList; childPtr != NULL; + childPtr = childPtr->nextPtr) { + if (!Tk_IsMapped(childPtr) || Tk_IsTopLevel(childPtr)) { + continue; + } + + GenerateUpdates(updateRgn, childPtr); + } + + /* + * Generate updates for any contained windows + */ + + if (Tk_IsContainer(winPtr)) { + childPtr = TkpGetOtherWindow(winPtr); + if (childPtr != NULL && Tk_IsMapped(childPtr)) { + GenerateUpdates(updateRgn, childPtr); + } + + /* + * NOTE: Here we should handle out of process embedding. + */ + + } + + return; +} + +/* + *---------------------------------------------------------------------- + * + * GenerateActivateEvents -- + * + * Given a Macintosh window activate event this function generates all the + * X Activate events needed by Tk. + * + * Results: + * True if event(s) are generated - false otherwise. + * + * Side effects: + * Additional events may be place on the Tk event queue. + * + *---------------------------------------------------------------------- + */ + +int +GenerateActivateEvents( + Window window, /* Root X window for event. */ + int activeFlag ) +{ + TkWindow *winPtr; + TkDisplay *dispPtr; + + dispPtr = TkGetDisplayList(); + winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window); + if (winPtr == NULL || winPtr->window == None) { + return false; + } + + TkGenerateActivateEvents(winPtr,activeFlag); + return true; +} + +/* + *---------------------------------------------------------------------- + * + * GenerateFocusEvent -- + * + * Given a Macintosh window activate event this function generates all the + * X Focus events needed by Tk. + * + * Results: + * True if event(s) are generated - false otherwise. + * + * Side effects: + * Additional events may be place on the Tk event queue. + * + *---------------------------------------------------------------------- + */ + +int +GenerateFocusEvent( + Window window, /* Root X window for event. */ + int activeFlag ) +{ + XEvent event; + Tk_Window tkwin; + TkDisplay *dispPtr; + + dispPtr = TkGetDisplayList(); + tkwin = Tk_IdToWindow(dispPtr->display, window); + if (tkwin == NULL) { + return false; + } + + /* + * Generate FocusIn and FocusOut events. This event + * is only sent to the toplevel window. + */ + + if (activeFlag) { + event.xany.type = FocusIn; + } else { + event.xany.type = FocusOut; + } + + event.xany.serial = dispPtr->display->request; + event.xany.send_event = False; + event.xfocus.display = dispPtr->display; + event.xfocus.window = window; + event.xfocus.mode = NotifyNormal; + event.xfocus.detail = NotifyDetailNone; + + Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + return true; +} + +/* + *---------------------------------------------------------------------- + * + * TkGenWMConfigureEvent -- + * + * Generate a ConfigureNotify event for Tk. Depending on the + * value of flag the values of width/height, x/y, or both may + * be changed. + * + * Results: + * None. + * + * Side effects: + * A ConfigureNotify event is sent to Tk. + * + *---------------------------------------------------------------------- + */ + +void +TkGenWMConfigureEvent( + Tk_Window tkwin, + int x, + int y, + int width, + int height, + int flags) +{ + XEvent event; + WmInfo *wmPtr; + TkWindow *winPtr = (TkWindow *) tkwin; + + if (tkwin == NULL) { + return; + } + + event.type = ConfigureNotify; + event.xconfigure.serial = Tk_Display(tkwin)->request; + event.xconfigure.send_event = False; + event.xconfigure.display = Tk_Display(tkwin); + event.xconfigure.event = Tk_WindowId(tkwin); + event.xconfigure.window = Tk_WindowId(tkwin); + event.xconfigure.border_width = winPtr->changes.border_width; + event.xconfigure.override_redirect = winPtr->atts.override_redirect; + if (winPtr->changes.stack_mode == Above) { + event.xconfigure.above = winPtr->changes.sibling; + } else { + event.xconfigure.above = None; + } + + if (flags & TK_LOCATION_CHANGED) { + event.xconfigure.x = x; + event.xconfigure.y = y; + } else { + event.xconfigure.x = Tk_X(tkwin); + event.xconfigure.y = Tk_Y(tkwin); + x = Tk_X(tkwin); + y = Tk_Y(tkwin); + } + if (flags & TK_SIZE_CHANGED) { + event.xconfigure.width = width; + event.xconfigure.height = height; + } else { + event.xconfigure.width = Tk_Width(tkwin); + event.xconfigure.height = Tk_Height(tkwin); + width = Tk_Width(tkwin); + height = Tk_Height(tkwin); + } + + Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + + /* + * Update window manager information. + */ + if (Tk_IsTopLevel(winPtr)) { + wmPtr = winPtr->wmInfoPtr; + if (flags & TK_LOCATION_CHANGED) { + wmPtr->x = x; + wmPtr->y = y; + wmPtr->flags &= ~(WM_NEGATIVE_X | WM_NEGATIVE_Y); + } + if ((flags & TK_SIZE_CHANGED) && + ((width != Tk_Width(tkwin)) || (height != Tk_Height(tkwin)))) { + if ((wmPtr->width == -1) && (width == winPtr->reqWidth)) { + /* + * Don't set external width, since the user didn't change it + * from what the widgets asked for. + */ + } else { + if (wmPtr->gridWin != NULL) { + wmPtr->width = wmPtr->reqGridWidth + + (width - winPtr->reqWidth)/wmPtr->widthInc; + if (wmPtr->width < 0) { + wmPtr->width = 0; + } + } else { + wmPtr->width = width; + } + } + if ((wmPtr->height == -1) && (height == winPtr->reqHeight)) { + /* + * Don't set external height, since the user didn't change it + * from what the widgets asked for. + */ + } else { + if (wmPtr->gridWin != NULL) { + wmPtr->height = wmPtr->reqGridHeight + + (height - winPtr->reqHeight)/wmPtr->heightInc; + if (wmPtr->height < 0) { + wmPtr->height = 0; + } + } else { + wmPtr->height = height; + } + } + wmPtr->configWidth = width; + wmPtr->configHeight = height; + } + } + + /* + * Now set up the changes structure. Under X we wait for the + * ConfigureNotify to set these values. On the Mac we know imediatly that + * this is what we want - so we just set them. However, we need to + * make sure the windows clipping region is marked invalid so the + * change is visable to the subwindow. + */ + winPtr->changes.x = x; + winPtr->changes.y = y; + winPtr->changes.width = width; + winPtr->changes.height = height; + TkMacOSXInvalClipRgns(winPtr); +} + +/* + *---------------------------------------------------------------------- + * + * TkGenWMDestroyEvent -- + * + * Generate a WM Destroy event for Tk. * + * Results: + * None. + * + * Side effects: + * A WM_PROTOCOL/WM_DELETE_WINDOW event is sent to Tk. + * + *---------------------------------------------------------------------- + */ + +void +TkGenWMDestroyEvent( + Tk_Window tkwin) +{ + XEvent event; + + event.xany.serial = Tk_Display(tkwin)->request; + event.xany.send_event = False; + event.xany.display = Tk_Display(tkwin); + + event.xclient.window = Tk_WindowId(tkwin); + event.xclient.type = ClientMessage; + event.xclient.message_type = Tk_InternAtom(tkwin, "WM_PROTOCOLS"); + event.xclient.format = 32; + event.xclient.data.l[0] = Tk_InternAtom(tkwin, "WM_DELETE_WINDOW"); + Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); +} + +/* + *---------------------------------------------------------------------- + * + * TkWmProtocolEventProc -- + * + * This procedure is called by the Tk_HandleEvent whenever a + * ClientMessage event arrives whose type is "WM_PROTOCOLS". + * This procedure handles the message from the window manager + * in an appropriate fashion. + * + * Results: + * None. + * + * Side effects: + * Depends on what sort of handler, if any, was set up for the + * protocol. + * + *---------------------------------------------------------------------- + */ + +void +TkWmProtocolEventProc( + TkWindow *winPtr, /* Window to which the event was sent. */ + XEvent *eventPtr) /* X event. */ +{ + WmInfo *wmPtr; + ProtocolHandler *protPtr; + Tcl_Interp *interp; + Atom protocol; + int result; + + wmPtr = winPtr->wmInfoPtr; + if (wmPtr == NULL) { + return; + } + protocol = (Atom) eventPtr->xclient.data.l[0]; + for (protPtr = wmPtr->protPtr; protPtr != NULL; + protPtr = protPtr->nextPtr) { + if (protocol == protPtr->protocol) { + Tcl_Preserve((ClientData) protPtr); + interp = protPtr->interp; + Tcl_Preserve((ClientData) interp); + result = Tcl_GlobalEval(interp, protPtr->command); + if (result != TCL_OK) { + Tcl_AddErrorInfo(interp, "\n (command for \""); + Tcl_AddErrorInfo(interp, + Tk_GetAtomName((Tk_Window) winPtr, protocol)); + Tcl_AddErrorInfo(interp, "\" window manager protocol)"); + Tk_BackgroundError(interp); + } + Tcl_Release((ClientData) interp); + Tcl_Release((ClientData) protPtr); + return; + } + } + + /* + * No handler was present for this protocol. If this is a + * WM_DELETE_WINDOW message then just destroy the window. + */ + + if (protocol == Tk_InternAtom((Tk_Window) winPtr, "WM_DELETE_WINDOW")) { + Tk_DestroyWindow((Tk_Window) winPtr); + } +} + +/* + *---------------------------------------------------------------------- + * + * Tk_MacOSXIsAppInFront -- + * + * Returns 1 if this app is the foreground app. + * + * Results: + * 1 if app is in front, 0 otherwise. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +int +Tk_MacOSXIsAppInFront (void) +{ + return tkMacOSXAppInFront; +}
\ No newline at end of file |