summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWindowEvent.c
diff options
context:
space:
mode:
authordas <das>2007-04-29 02:26:47 (GMT)
committerdas <das>2007-04-29 02:26:47 (GMT)
commit0537d1c70efd92c5bd39a4047c02524d70ad7a58 (patch)
treed8296fa62af852c5f2e743159973d854366b69fa /macosx/tkMacOSXWindowEvent.c
parent9025e3c799817de9b380db2644dd47a61924c5eb (diff)
downloadtk-0537d1c70efd92c5bd39a4047c02524d70ad7a58.zip
tk-0537d1c70efd92c5bd39a4047c02524d70ad7a58.tar.gz
tk-0537d1c70efd92c5bd39a4047c02524d70ad7a58.tar.bz2
* macosx/tkMacOSXCarbonEvents.c: add window event target carbon event
* macosx/tkMacOSXEvent.c: handler for all kEventClassWindow and * macosx/tkMacOSXEvent.h: kEventClassMouse events; move all * macosx/tkMacOSXNotify.c: remaining events except for * macosx/tkMacOSXWindowEvent.c: kEventClassKeyboard from dispatcher to application event handler; pass event handler callRef downstream; fix debug event tracing; process all tcl event types in carbon event timer; delay carbon event timer first fire; add TkMacOSXTrackingLoop() to mark enter/exit of event tracking loop during which all tcl events but only carbon update events should be processed by the timer (replaces various calls to Tcl_SetServiceMode()); rename TkMacOSXReceiveAndProcessEvent() to TkMacOSXReceiveAndDispatchEvent(), move it from tkMacOSXEvent.c to tkMacOSXCarbonEvents.c and modify it to dequeue only update events during a tracking loop; add TkMacOSXRunTclEventLoop() to standardize the various ways in use to run the tcl event loop; add handling of kEventClassAppearance events (for ScrollBarVariantChanged event). * macosx/tkMacOSXDialog.c: use new TkMacOSXTrackingLoop() around * macosx/tkMacOSXEvent.c: blocking API that puts up modal dialogs * macosx/tkMacOSXMenu.c: or when entering/exiting menu/control * macosx/tkMacOSXMouseEvent.c: tracking, window dragging and other * macosx/tkMacOSXScale.c: mouse tracking loops. * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXDialog.c: use new TkMacOSXRunTclEventLoop() * macosx/tkMacOSXScale.c: instead of Tcl_DoOneEvent(), * macosx/tkMacOSXScrlbr.c: Tcl_ServiceAll(), TclServiceIdle() * macosx/tkMacOSXWindowEvent.c: and Tcl_GlobalEval("update idletasks"). * macosx/tkMacOSXColor.c: make available as Tk system colors all * macosx/tkMacOSXPort.h: appearance manager brushes, text colors and backgrounds with new and legacy names, as well as the fully transparent color "systemTransparent"; add TkMacOSXSetColorIn{Port,Context}() to directly set an X pixel color value in the current QD port resp. the given CG context without requiring passage through rgb representation (lossy for most system colors); modernize/remove Classic-era code; replace crufty strcmp() elseifs by Tcl_GetIndexFromObjStruct(). * macosx/tkMacOSXButton.c: use new TkMacOSXSetColorInPort() * macosx/tkMacOSXDraw.c: instead of setting rgb color directly * macosx/tkMacOSXMenubutton.c: to allow for non-rgb system colors. * macosx/tkMacOSXCursor.c: implement "none" cursor as on other platforms [Patch 1615427]; add all missing appearance manager cursors. * macosx/tkMacOSXDefault.h: set SELECT_FG_COLORs to None to match aqua L&F; use standard system color names; use new 'menu' system font; correct default scrollbar width. * macosx/tkMacOSXDraw.c: standardize initialization, use and * macosx/tkMacOSXInt.h: emptying of various static temp rgns * macosx/tkMacOSXRegion.c: onto two global RgnHandles; in debug * macosx/tkMacOSXSubwindows.c: builds, verify emptiness of these temp * macosx/tkMacOSXWindowEvent.c: rgns before use. * macosx/tkMacOSXDraw.c: add TkMacOSX{Setup,Restore}DrawingContext() to * macosx/tkMacOSXInt.h: abstract common setup & teardown of drawing environment (for both CG and QD); save/restore QD theme drawing state; handle GC clip region; add TkpClipDrawableToRect() to allow clipped drawing into drawable regardless of GC used; use new system color "systemWindowHeaderBackground" to setup background in themed toplevels; correct implementation of TkMacOSXMakeStippleMap(). * macosx/tkMacOSXEntry.c: use new TkMacOSXSetupDrawingContext() and * macosx/tkMacOSXFont.c: TkMacOSXRestoreDrawingContext() instead of various setup/teardown procs like TkMacOSX{SetUp,Release}CGContext(), TkMacOSXQuarz{Start,End}Draw(), TkMacOSXSetUpGraphicsPort() etc. * macosx/tkMacOSXEmbed.c: add CG context and drawable clip rgn fields * macosx/tkMacOSXInt.h: to MacDrawable struct. * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXDialog.c: make -parent option of tk_getOpenFile et al. use the sheet version of NavServices dialogs; ensure native parent win exists before using StandardSheet API for tk_messageBox [Bug 1677611]; force sheets to behave like app-modal dialogs via WindowModality() API; use more modern ColorPicker API. * macosx/tkAboutDlg.r: use themed movable modal dialog, fix (c) year. * macosx/tkMacOSXEntry.c: take xOff/yOff of MacDrawable into account when computing locations/bounds to ensure correct posititioning when not drawing into intermediate pixmap. * macosx/tkMacOSXFont.c: use appearance manager API to map system font * macosx/tkMacOSXFont.h: names to TkFonts; add "menu" system font for menu item text drawing from MDEF; disable broken QD stippling. * macosx/tkMacOSXMenu.c: large-scale rewrite of custom * macosx/tkMacOSXMenu.r (removed): MDEF and related code that * unix/Makefile.in: restores many longtime-MIA features to working order (e.g. images, custom colors & fonts in menus etc); implement compound menu items; use Appearance Mgr and ThemeText APIs to mimic native MDEF as closely as possible when default "menu" system font is used; remove now obsolete SICN drawing code and resources. * macosx/tkMacOSXCarbonEvents.c: handle additional menu carbon events * macosx/tkMacOSXEvent.c: in order to support <<MenuSelect>> in * macosx/tkMacOSXMenu.c: the menubar and in menus that are not * macosx/tkMacOSXMenus.c: using the custom MDEF [Bug 1620826]; fix early and missing clearing of current Tk active menu entry; fix extraneous sending of <<MenuSelect>> during active menu entry clearing. * macosx/tkMacOSXMouseEvent.c: add support for async window dragging by the window server; set the corresponding window attribute by default. * macosx/tkMacOSXMouseEvent.c: rationalized handling order of non-mousedown events; add TkMacOSXModifierState() to retrieve the current key modifiers in carbon format. * macosx/tkMacOSXScrlbr.c: use appearance manager API to retrieve scrollbar component metrics; add awareness of multiple possibilites for scrollbar arrow position in aqua and handle user changes to arrow position pref; handle difference in metrics of small & large scrollbar variants; handle aqua "jump to here" scrollbar behaviour; correct computation of scroll view size and position; enforce min scrollbar height to avoid scrollbar component overlap; erase scrollbar area outside of standard width; remove broken auto-adjust code; account for window class when leaving space for grow box; remove code to manually draw grow box; use modern API for thumb scroll proc; replace HiliteControl() by modern API; replace control mgr constants with appearance mgr equivalents. * macosx/tkMacOSXSubwindows.c: use SetWindowBounds() API instead of SizeWindow(); invalidate clip regions after X{Map,Unmap}Window as fix for [Bug 940117] made them dependent on mapping state; remove unneeded calls to TkMacOSXInvalClipRgns() and unnecessary setting of QD port; use native-endian pixmap on intel; remove obsolete pixmap pix locking. * macosx/tkMacOSXWindowEvent.c: handle only the first of a batch of kEventAppAvailableWindowBoundsChanged events sent per transaction; handle kEventWindowBoundsChanged event to support live window resizing and centralized sending of location/size changed ConfigureNotify events; ensure HIGrowBox is redrawn after bounds change; constrain window after dragging to ensure titlebar is not inacessible offscreen or under dock/menubar; handle kEventWindowGetRegion and kEventWindowDrawContent for transparent windows to mark resp. paint content region as transparent; handle kEventWindowConstrain for fullscreen windows to ensure bounds match new screen size; enter/exit fullscreen UIMode upon activation/deactivation of fullscreen window. * macosx/tkMacOSXWm.c: use live-resize and async-drag carbon window * macosx/tkMacOSXWm.h: attributes for toplevels by default; implement new [wm attributes] -topmost, -transparent and -fullscreen; refactor WmAttributesCmd() parallelling the tkUnixWm.c implementation, use thus factored proc to set proxy icon from [wm iconbitmap]; dynamically determine default values for toplevel min and max sizes (similar to tkWinWm.c impl): min sizes depend on window class & attributes to ensure visibility of all titlebar widgets and grow box, max sizes depend on maximal window bounds for all active displays; factor out code that puts into effect changes to master or override_redirect; use RepositionWindow() API to determine staggered initial window bounds; correct resize limit calculations, handle gridding and use modern resize API in TkMacOSXGrowToplevel(); remove sending of ConfigureNotify after resize or zoom (now handled by BoundsChanged handler); correct composite carbon window attribute handling, remove currently unusable attributes and add new attributes in [tk::unsupported::MacWindowStyle]; ensure validity of window class and attributes before use; apply changes to window class when handling carbon window attribute changes (if HIWindowChangeClass() API available); add debug build warning message when deprecated window style is used instead of window class; use transparent HIGrowBox for resizable windows; avoid unnecessary calls to window structure width API; use tcl time API in TkpGetMS(); add TkMacOSXEnterExitFullscreen() to enter/exit UIMode with dock and menubar hidden; restrict wmTracing output to debug builds; remove unneeded calls to TkMacOSXInvalClipRgns() and unnecessary setting of QD port; workaround GetWindowStructureWidths() Carbon bug (bogus results for never-mapped floating windows). * macosx/tkMacOSXXStubs.c (TkMacOSXDisplayChanged): add maximal window bounds field to Screen record (in ext_data), computed as the union of available window positioning bounds of all graphics devices (displays). * macosx/tkMacOSXBitmap.c: fix macRoman encoding leak. * macosx/tkMacOSXCursor.c: * macosx/tkMacOSXDebug.c (TkMacOSXCarbonEventToAscii): use static * macosx/tkMacOSXDebug.h: buffer to simplify callers; const fixes. * macosx/tkMacOSXBitmap.c: use more efficient QDSwapPort() instead of * macosx/tkMacOSXButton.c: GetPort()/SetPort()/GetGWorld()/SetGWorld(). * macosx/tkMacOSXDraw.c: * macosx/tkMacOSXFont.c: * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXScale.c: * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXXStubs.c: * macosx/tkMacOSXColor.c: use kHIToolboxVersionNumber for runtime OS * macosx/tkMacOSXEntry.c: version check rather than Gestalt() etc. * macosx/tkMacOSXInt.h: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXDraw.c: remove obsolete and now incorrect * macosx/tkMacOSXInt.h: tkMenuCascadeRgn clipping code. * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXHLEvents.c: replace Tcl_GlobalEval() resp. Tcl_Eval() * macosx/tkMacOSXScrlbr.c: by Tcl_EvalEx(). * macosx/tkMacOSXInit.c: * macosx/tkMacOSXInit.c (TkpInit): reorder initialization steps. * macosx/tkMacOSXKeyEvent.c: remove pre-10.2 support. * macosx/tkMacOSXMenus.c: remove now useless call to TkMacOSXHandleTearoffMenu(); use \x.. quoting for non-latin1 macroman literar chars to allow file to be edited as utf-8. * macosx/tkMacOSXScale.c: replace TrackControl() by modern * macosx/tkMacOSXScrlbr.c: HandleControlClick() API (using new TkMacOSXModifierState()). * macosx/tkMacOSXInt.h: move all constant #defines needed to * macosx/tkMacOSXColor.c: support building on older OS X releases * macosx/tkMacOSXEvent.h: to a central location in tkMacOSXInt.h. * macosx/tkMacOSXFont.c: * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXInt.h: add ChkErr() macro to factor out * macosx/tkMacOSXButton.c: Carbon OSStatus return value checking * macosx/tkMacOSXCarbonEvents.c: and TkMacOSXDbgMsg() macro to factour * macosx/tkMacOSXClipboard.c: out debug message output; use these * macosx/tkMacOSXColor.c: macros to replace #ifdef TK_MAC_DEBUG * macosx/tkMacOSXCursor.c: blocks & direct printing to stderr, * macosx/tkMacOSXDebug.c: and to do additional OSStatus return * macosx/tkMacOSXDialog.c: checking, and to standardize OSStatus * macosx/tkMacOSXDraw.c: usage. * macosx/tkMacOSXEntry.c: * macosx/tkMacOSXEvent.c: * macosx/tkMacOSXFont.c: * macosx/tkMacOSXHLEvents.c: * macosx/tkMacOSXInit.c: * macosx/tkMacOSXKeyEvent.c: * macosx/tkMacOSXMenu.c: * macosx/tkMacOSXMenubutton.c: * macosx/tkMacOSXMenus.c: * macosx/tkMacOSXMouseEvent.c: * macosx/tkMacOSXScrlbr.c: * macosx/tkMacOSXSubwindows.c: * macosx/tkMacOSXWindowEvent.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXXStubs.c: * macosx/tkMacOSXSend.c: remove duplicate/unused declarations. * macosx/tkMacOSXXStubs.c: * macosx/tkMacOSXDebug.c: const fixes. * macosx/tkMacOSXInit.c: * macosx/tkMacOSXTest.c: * macosx/tkMacOSXWm.c: * macosx/tkMacOSXXStubs.c: * macosx/Wish-Info.plist.in: add tcl document extensions/mime types and LSMinimumSystemVersion, LSRequiresCarbon & NSAppleScriptEnabled keys. * macosx/tkMacOSXAETE.r: fix whitespace. * macosx/tkMacOSXConfig.c: * macosx/tkMacOSXCursors.r: * macosx/tkMacOSXKeyboard.c: * macosx/tkMacOSXSend.c: * macosx/tkMacOSXXCursors.r: * macosx/README: * macosx/Makefile: fix/add copyright and license refs. * macosx/Tk-Info.plist.in: * macosx/Wish-Info.plist.in: * macosx/tkMacOSX.h:
Diffstat (limited to 'macosx/tkMacOSXWindowEvent.c')
-rw-r--r--macosx/tkMacOSXWindowEvent.c766
1 files changed, 483 insertions, 283 deletions
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index b4a7845..86fc381 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -2,59 +2,59 @@
* tkMacOSXWindowEvent.c --
*
* This file defines the routines for both creating and handling
- * Window Manager class events for Tk.
+ * Window Manager class events for Tk.
*
* Copyright 2001, Apple Computer, Inc.
- * Copyright (c) 2005 Daniel A. Steffen <das@users.sourceforge.net>
+ * Copyright (c) 2005-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.
*
- * 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.
- *
- * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.17 2006/11/02 15:18:26 das Exp $
+ * 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.
+ *
+ * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.18 2007/04/29 02:26:50 das Exp $
*/
#include "tkMacOSXInt.h"
@@ -63,11 +63,17 @@
#include "tkMacOSXDebug.h"
/*
+#ifdef TK_MAC_DEBUG
+#define TK_MAC_DEBUG_CLIP_REGIONS
+#endif
+*/
+
+/*
* Declarations of global variables defined in this file.
*/
-static int tkMacOSXAppInFront = true; /* Boolean variable for determining if
- * we are the frontmost app. Only set
+static int tkMacOSXAppInFront = true; /* Boolean variable for determining if
+ * we are the frontmost app. Only set
* in TkMacOSXProcessApplicationEvent
*/
static RgnHandle gDamageRgn = NULL;
@@ -75,167 +81,342 @@ static RgnHandle gDamageRgn = NULL;
/*
* Declaration of functions used only in this file
*/
-
+
static int GenerateUpdateEvent( Window window);
static int GenerateUpdates( RgnHandle updateRgn, TkWindow *winPtr);
static int GenerateActivateEvents( Window window, int activeFlag);
+static void ClearPort(CGrafPtr port);
-
+
/*
*----------------------------------------------------------------------
*
* TkMacOSXProcessApplicationEvent --
*
- * This processes Application level events, mainly activate
- * and deactivate.
+ * This processes Application level events, mainly activate
+ * and deactivate.
*
* Results:
- * o.
+ * 0.
*
* Side effects:
- * Hide or reveal floating windows, and set tkMacOSXAppInFront.
+ * Hide or reveal floating windows, and set tkMacOSXAppInFront.
*
*----------------------------------------------------------------------
*/
-
+
MODULE_SCOPE int
TkMacOSXProcessApplicationEvent(
- TkMacOSXEvent *eventPtr,
- MacEventStatus *statusPtr)
+ TkMacOSXEvent *eventPtr,
+ MacEventStatus *statusPtr)
{
Tcl_CmdInfo dummy;
/*
- * This is a bit of a hack. We get "show" events both when we come back
- * from being hidden, and whenever we are activated. I only want to run
+ * This is a bit of a hack. We get "show" events both when we come back
+ * from being hidden, and whenever we are activated. I only want to run
* the "show" proc when we have been hidden already, not as a substitute
- * for <Activate>. So I use this toggle...
+ * for <Activate>. So I use this toggle...
*/
static int toggleHide = 0;
switch (eventPtr->eKind) {
- case kEventAppActivated:
- tkMacOSXAppInFront = true;
- ShowFloatingWindows();
- break;
- case kEventAppDeactivated:
- TkSuspendClipboard();
- tkMacOSXAppInFront = false;
- HideFloatingWindows();
- break;
- case kEventAppQuit:
- statusPtr->stopProcessing = 1;
- break;
- case kEventAppHidden:
- if (toggleHide == 0) {
- toggleHide = 1;
- if (eventPtr->interp && Tcl_GetCommandInfo(eventPtr->interp,
- "::tk::mac::OnHide", &dummy)) {
- Tcl_GlobalEval(eventPtr->interp, "::tk::mac::OnHide");
- }
- }
- statusPtr->stopProcessing = 1;
- break;
- case kEventAppShown:
- if (toggleHide == 1) {
- toggleHide = 0;
- if (eventPtr->interp && Tcl_GetCommandInfo(eventPtr->interp,
- "::tk::mac::OnShow", &dummy)) {
- Tcl_GlobalEval(eventPtr->interp, "::tk::mac::OnShow");
- }
- }
- statusPtr->stopProcessing = 1;
- break;
+ case kEventAppActivated:
+ tkMacOSXAppInFront = true;
+ ShowFloatingWindows();
+ break;
+ case kEventAppDeactivated:
+ TkSuspendClipboard();
+ tkMacOSXAppInFront = false;
+ HideFloatingWindows();
+ break;
+ case kEventAppQuit:
+ statusPtr->stopProcessing = 1;
+ break;
+ case kEventAppHidden:
+ if (toggleHide == 0) {
+ toggleHide = 1;
+ if (eventPtr->interp && Tcl_GetCommandInfo(eventPtr->interp,
+ "::tk::mac::OnHide", &dummy)) {
+ Tcl_GlobalEval(eventPtr->interp, "::tk::mac::OnHide");
+ }
+ }
+ statusPtr->stopProcessing = 1;
+ break;
+ case kEventAppShown:
+ if (toggleHide == 1) {
+ toggleHide = 0;
+ if (eventPtr->interp && Tcl_GetCommandInfo(eventPtr->interp,
+ "::tk::mac::OnShow", &dummy)) {
+ Tcl_GlobalEval(eventPtr->interp, "::tk::mac::OnShow");
+ }
+ }
+ statusPtr->stopProcessing = 1;
+ break;
case kEventAppAvailableWindowBoundsChanged: {
- TkDisplay *dispPtr = TkGetDisplayList();
- TkMacOSXDisplayChanged(dispPtr->display);
+ static UInt32 prevId = 0;
+ UInt32 id;
+ OSStatus err;
+
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamTransactionID, typeUInt32,
+ NULL, sizeof(id), NULL, &id);
+ if (err != noErr || id != prevId) {
+ TkDisplay *dispPtr = TkGetDisplayList();
+
+ prevId = id;
+ TkMacOSXDisplayChanged(dispPtr->display);
+ }
/*
* Should we call ::tk::mac::OnDisplayChanged?
*/
break;
}
- default:
- break;
+ default:
+ break;
}
return 0;
}
- /*
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkMacOSXProcessAppearanceEvent --
+ *
+ * This processes Appearance events.
+ *
+ * Results:
+ * 0.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+MODULE_SCOPE int
+TkMacOSXProcessAppearanceEvent(
+ TkMacOSXEvent *eventPtr,
+ MacEventStatus *statusPtr)
+{
+ switch (eventPtr->eKind) {
+ case kEventAppearanceScrollBarVariantChanged:
+ TkMacOSXInitScrollbarMetrics();
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+
+/*
*----------------------------------------------------------------------
*
* TkMacOSXProcessWindowEvent --
*
- * This processes Window level events, mainly activate
- * and deactivate.
+ * This processes Window level events, mainly activate
+ * and deactivate.
*
* Results:
- * 0.
+ * 0.
*
* Side effects:
- * Cause Windows to be moved forward or backward in the
- * window stack.
+ * Cause Windows to be moved forward or backward in the
+ * window stack.
*
*----------------------------------------------------------------------
*/
MODULE_SCOPE int
TkMacOSXProcessWindowEvent(
- TkMacOSXEvent * eventPtr,
- MacEventStatus * statusPtr)
-{
- OSStatus status;
+ TkMacOSXEvent * eventPtr,
+ MacEventStatus * statusPtr)
+{
+ OSStatus err;
WindowRef whichWindow;
- Window window;
- int eventFound = false;
-
- switch (eventPtr->eKind) {
- case kEventWindowActivated:
- case kEventWindowDeactivated:
- case kEventWindowUpdate:
- case kEventWindowExpanded:
- break;
- default:
- return 0;
- break;
+ Window window;
+ int eventFound = false;
+ TkDisplay *dispPtr;
+ TkWindow *winPtr;
+
+ switch (eventPtr->eKind) {
+ case kEventWindowActivated:
+ case kEventWindowDeactivated:
+ case kEventWindowUpdate:
+ case kEventWindowExpanded:
+ case kEventWindowBoundsChanged:
+ case kEventWindowDragStarted:
+ case kEventWindowDragCompleted:
+ case kEventWindowConstrain:
+ case kEventWindowGetRegion:
+ case kEventWindowDrawContent:
+ break;
+ default:
+ return 0;
+ break;
}
- status = GetEventParameter(eventPtr->eventRef,
- kEventParamDirectObject,
- typeWindowRef, NULL,
- sizeof(whichWindow), NULL,
- &whichWindow);
- if (status != noErr) {
-#ifdef TK_MAC_DEBUG
- fprintf ( stderr, "TkMacOSXHandleWindowEvent:Failed to retrieve window" );
-#endif
- return 0;
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamDirectObject, typeWindowRef, NULL, sizeof(whichWindow),
+ NULL, &whichWindow);
+ if (err != noErr) {
+ return 0;
}
-
+
window = TkMacOSXGetXWindow(whichWindow);
+ dispPtr = TkGetDisplayList();
+ winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window);
- switch (eventPtr->eKind) {
- case kEventWindowActivated:
- eventFound |= GenerateActivateEvents(window, 1);
- eventFound |= TkMacOSXGenerateFocusEvent(window, 1);
- break;
- case kEventWindowDeactivated:
- eventFound |= GenerateActivateEvents(window, 0);
- eventFound |= TkMacOSXGenerateFocusEvent(window, 0);
- break;
- case kEventWindowUpdate:
- if (GenerateUpdateEvent(window)) {
- eventFound = true;
- }
- break;
- case kEventWindowExpanded: {
- TkDisplay *dispPtr;
- TkWindow *winPtr;
- dispPtr = TkGetDisplayList();
- winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window);
- if (winPtr) {
- TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ?
- ZoomState : NormalState);
- }
- break;
- }
+ if (window != None) {
+ switch (eventPtr->eKind) {
+ case kEventWindowActivated:
+ case kEventWindowDeactivated: {
+ int activate = (eventPtr->eKind == kEventWindowActivated);
+
+ eventFound |= GenerateActivateEvents(window, activate);
+ eventFound |= TkMacOSXGenerateFocusEvent(window, activate);
+ if (winPtr) {
+ TkMacOSXEnterExitFullscreen(winPtr, activate);
+ }
+ statusPtr->stopProcessing = 1;
+ break;
+ }
+ case kEventWindowUpdate:
+ if (GenerateUpdateEvent(window)) {
+ eventFound = true;
+ statusPtr->stopProcessing = 1;
+ }
+ break;
+ case kEventWindowExpanded:
+ if (winPtr) {
+ TkpWmSetState(winPtr, TkMacOSXIsWindowZoomed(winPtr) ?
+ ZoomState : NormalState);
+ }
+ break;
+ case kEventWindowBoundsChanged:
+ if (winPtr) {
+ WmInfo *wmPtr = winPtr->wmInfoPtr;
+ UInt32 attr;
+ Rect bounds;
+ int x = -1, y = -1, width = -1, height = -1, flags = 0;
+
+ ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamAttributes, typeUInt32,
+ NULL, sizeof(attr), NULL, &attr);
+ ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamCurrentBounds, typeQDRectangle,
+ NULL, sizeof(bounds), NULL, &bounds);
+ if (attr & kWindowBoundsChangeOriginChanged) {
+ x = bounds.left - wmPtr->xInParent;
+ y = bounds.top - wmPtr->yInParent;
+ flags |= TK_LOCATION_CHANGED;
+ }
+ if (attr & kWindowBoundsChangeSizeChanged) {
+ width = bounds.right - bounds.left;
+ height = bounds.bottom - bounds.top;
+ flags |= TK_SIZE_CHANGED;
+ }
+ TkGenWMConfigureEvent((Tk_Window)winPtr, x, y, width,
+ height, flags);
+ if (attr & kWindowBoundsChangeUserResize ||
+ attr & kWindowBoundsChangeUserDrag) {
+ TkMacOSXRunTclEventLoop();
+ }
+ if (wmPtr->attributes & kWindowResizableAttribute) {
+ HIViewRef growBoxView;
+
+ err = HIViewFindByID(HIViewGetRoot(whichWindow),
+ kHIViewWindowGrowBoxID, &growBoxView);
+ if (err == noErr) {
+ ChkErr(HIViewSetNeedsDisplay, growBoxView, true);
+ }
+ }
+ }
+ break;
+ case kEventWindowDragStarted:
+ if (winPtr) {
+ TkMacOSXTrackingLoop(1);
+ }
+ break;
+ case kEventWindowDragCompleted:
+ if (winPtr) {
+ Rect maxBounds, bounds, strWidths;
+ int h = 0, v = 0;
+
+ TkMacOSXTrackingLoop(0);
+ ChkErr(GetWindowGreatestAreaDevice, whichWindow,
+ kWindowDragRgn, NULL, &maxBounds);
+ ChkErr(GetWindowBounds, whichWindow, kWindowStructureRgn,
+ &bounds);
+ ChkErr(GetWindowStructureWidths, whichWindow, &strWidths);
+ if (bounds.left > maxBounds.right - strWidths.left) {
+ h = maxBounds.right
+ - (strWidths.left ? strWidths.left : 40)
+ - bounds.left;
+ } else if (bounds.right < maxBounds.left
+ + strWidths.right) {
+ h = maxBounds.left
+ + (strWidths.right ? strWidths.right : 40)
+ - bounds.right;
+ }
+ if (bounds.top > maxBounds.bottom - strWidths.top) {
+ v = maxBounds.bottom
+ - (strWidths.top ? strWidths.top : 40)
+ - bounds.top;
+ } else if (bounds.bottom < maxBounds.top
+ + strWidths.bottom) {
+ v = maxBounds.top
+ + (strWidths.bottom ? strWidths.bottom : 40)
+ - bounds.bottom;
+ } else if (strWidths.top && bounds.top < maxBounds.top) {
+ v = maxBounds.top - bounds.top;
+ }
+ if (h || v) {
+ OffsetRect(&bounds, h, v);
+ ChkErr(SetWindowBounds, whichWindow,
+ kWindowStructureRgn, &bounds);
+ }
+ }
+ break;
+ case kEventWindowConstrain:
+ if (winPtr) {
+ if (winPtr->wmInfoPtr->flags & WM_FULLSCREEN &&
+ TkMacOSXMakeFullscreen(winPtr, whichWindow, 1,
+ NULL) == TCL_OK) {
+ statusPtr->stopProcessing = 1;
+ }
+ }
+ break;
+ case kEventWindowGetRegion:
+ if (winPtr && (winPtr->wmInfoPtr->flags & WM_TRANSPARENT)) {
+ WindowRegionCode code;
+
+ statusPtr->stopProcessing = (CallNextEventHandler(
+ eventPtr->callRef, eventPtr->eventRef) == noErr);
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamWindowRegionCode, typeWindowRegionCode,
+ NULL, sizeof(code), NULL, &code);
+ if (err == noErr && code == kWindowOpaqueRgn) {
+ RgnHandle rgn;
+
+ err = ChkErr(GetEventParameter, eventPtr->eventRef,
+ kEventParamRgnHandle, typeQDRgnHandle, NULL,
+ sizeof(rgn), NULL, &rgn);
+ if (err == noErr) {
+ SetEmptyRgn(rgn);
+ statusPtr->stopProcessing = 1;
+ }
+ }
+ }
+ break;
+ case kEventWindowDrawContent:
+ if (winPtr && (winPtr->wmInfoPtr->flags & WM_TRANSPARENT)) {
+ CGrafPtr port;
+
+ GetPort(&port);
+ ClearPort(port);
+ }
+ break;
+ }
}
return 0;
}
@@ -245,60 +426,56 @@ TkMacOSXProcessWindowEvent(
*
* GenerateUpdateEvent --
*
- * Given a Macintosh window update event this function generates
- * all the Expose XEvents needed by Tk.
+ * Given a Macintosh window update event this function generates
+ * all the Expose XEvents needed by Tk.
*
- * Results:
- * True if event(s) are generated - false otherwise.
+ * Results:
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
- *
+ * Additional events may be place on the Tk event queue.
+ *
*----------------------------------------------------------------------
- */
+ */
static int
GenerateUpdateEvent(Window window)
{
- CGrafPtr destPort;
- WindowRef macWindow;
+ CGrafPtr destPort;
+ WindowRef macWindow;
TkDisplay * dispPtr;
TkWindow * winPtr;
- int result = 0;
- static RgnHandle updtRgn = NULL, visRgn = NULL;
-
+ int result = 0;
+
dispPtr = TkGetDisplayList();
winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window);
-
+
if (winPtr ==NULL ){
- return result;
+ return result;
}
if (gDamageRgn == NULL) {
- gDamageRgn = NewRgn();
- }
- if (updtRgn == NULL) {
- updtRgn = NewRgn();
- }
- if (visRgn == NULL) {
- visRgn = NewRgn();
+ gDamageRgn = NewRgn();
}
+ TkMacOSXCheckTmpRgnEmpty(1);
destPort = TkMacOSXGetDrawablePort(window);
macWindow = GetWindowFromPort(destPort);
- GetWindowRegion(macWindow, kWindowUpdateRgn, updtRgn);
- visRgn = QDGlobalToLocalRegion(destPort, updtRgn);
- SectRegionWithPortVisibleRegion(destPort, visRgn);
-#if defined(TK_MAC_DEBUG) && defined(TK_MAC_DEBUG_CLIP_REGIONS)
+ GetWindowRegion(macWindow, kWindowUpdateRgn, tkMacOSXtmpRgn1);
+ QDGlobalToLocalRegion(destPort, tkMacOSXtmpRgn1);
+ SectRegionWithPortVisibleRegion(destPort, tkMacOSXtmpRgn1);
+#ifdef TK_MAC_DEBUG_CLIP_REGIONS
TkMacOSXInitNamedDebugSymbol(HIToolbox, int, QDDebugFlashRegion,
- CGrafPtr port, RgnHandle region);
+ CGrafPtr port, RgnHandle region);
if (QDDebugFlashRegion) {
/* Carbon-internal region flashing SPI (c.f. Technote 2124) */
- QDDebugFlashRegion(destPort, visRgn);
+ QDDebugFlashRegion(destPort, tkMacOSXtmpRgn1);
}
#endif /* TK_MAC_DEBUG_CLIP_REGIONS */
BeginUpdate(macWindow);
- result = GenerateUpdates(visRgn, winPtr);
+ if (winPtr->wmInfoPtr->flags & WM_TRANSPARENT) {
+ ClearPort(destPort);
+ }
+ result = GenerateUpdates(tkMacOSXtmpRgn1, winPtr);
EndUpdate(macWindow);
- SetEmptyRgn(visRgn);
- SetEmptyRgn(updtRgn);
+ SetEmptyRgn(tkMacOSXtmpRgn1);
SetEmptyRgn(gDamageRgn);
return result;
}
@@ -308,16 +485,16 @@ GenerateUpdateEvent(Window window)
*
* GenerateUpdates --
*
- * Given a Macintosh update region and a Tk window this function
- * geneates a X Expose event for the window if it is within the
- * update region. The function will then recursivly have each
- * damaged window generate Expose events for its child windows.
+ * Given a Macintosh update region and a Tk window this function
+ * geneates a X Expose event for the window if it is within the
+ * update region. The function will then recursivly have each
+ * damaged window generate Expose events for its child windows.
*
* Results:
- * True if event(s) are generated - false otherwise.
+ * True if event(s) are generated - false otherwise.
*
* Side effects:
- * Additional events may be place on the Tk event queue.
+ * Additional events may be place on the Tk event queue.
*
*----------------------------------------------------------------------
*/
@@ -333,26 +510,26 @@ GenerateUpdates(
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 0;
+ updateBounds.top > bounds.bottom ||
+ bounds.left > updateBounds.right ||
+ updateBounds.left > bounds.right ||
+ !RectInRgn(&bounds, updateRgn)) {
+ return 0;
}
if (!RectInRgn(&bounds, updateRgn)) {
- return 0;
+ return 0;
}
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.
*/
@@ -369,97 +546,97 @@ GenerateUpdates(
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;
- }
+ childPtr = childPtr->nextPtr) {
+ if (!Tk_IsMapped(childPtr) || Tk_IsTopLevel(childPtr)) {
+ continue;
+ }
- GenerateUpdates(updateRgn, childPtr);
+ 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.
- */
-
- }
+ childPtr = TkpGetOtherWindow(winPtr);
+ if (childPtr != NULL && Tk_IsMapped(childPtr)) {
+ GenerateUpdates(updateRgn, childPtr);
+ }
+
+ /*
+ * NOTE: Here we should handle out of process embedding.
+ */
+
+ }
return 1;
}
-/*
+/*
*----------------------------------------------------------------------
- *
+ *
* 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.
+ * 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.
- *
+ * Additional events may be place on the Tk event queue.
+ *
*----------------------------------------------------------------------
*/
-
+
int
GenerateActivateEvents(
- Window window, /* Root X window for event. */
- int activeFlag )
+ 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;
+ return false;
}
TkGenerateActivateEvents(winPtr,activeFlag);
return true;
}
-/*
+/*
*----------------------------------------------------------------------
- *
+ *
* TkMacOSXGenerateFocusEvent --
- *
- * 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.
+ * 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.
- *
+ * Additional events may be place on the Tk event queue.
+ *
*----------------------------------------------------------------------
- */
+ */
MODULE_SCOPE int
TkMacOSXGenerateFocusEvent(
- Window window, /* Root X window for event. */
- int activeFlag )
+ Window window, /* Root X window for event. */
+ int activeFlag )
{
XEvent event;
Tk_Window tkwin;
@@ -468,7 +645,7 @@ TkMacOSXGenerateFocusEvent(
dispPtr = TkGetDisplayList();
tkwin = Tk_IdToWindow(dispPtr->display, window);
if (tkwin == NULL) {
- return false;
+ return false;
}
/*
@@ -482,14 +659,14 @@ TkMacOSXGenerateFocusEvent(
}
/*
- * Generate FocusIn and FocusOut events. This event
+ * Generate FocusIn and FocusOut events. This event
* is only sent to the toplevel window.
*/
if (activeFlag) {
- event.xany.type = FocusIn;
+ event.xany.type = FocusIn;
} else {
- event.xany.type = FocusOut;
+ event.xany.type = FocusOut;
}
event.xany.serial = dispPtr->display->request;
@@ -502,13 +679,13 @@ TkMacOSXGenerateFocusEvent(
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
return true;
}
-
+
/*
*----------------------------------------------------------------------
*
* TkGenWMConfigureEvent --
*
- * Generate a ConfigureNotify event for Tk. Depending on the
+ * Generate a ConfigureNotify event for Tk. Depending on the
* value of flag the values of width/height, x/y, or both may
* be changed.
*
@@ -533,11 +710,11 @@ TkGenWMConfigureEvent(
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;
@@ -552,27 +729,21 @@ TkGenWMConfigureEvent(
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);
+ if (!(flags & TK_LOCATION_CHANGED)) {
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);
+ if (!(flags & TK_SIZE_CHANGED)) {
width = Tk_Width(tkwin);
height = Tk_Height(tkwin);
}
-
+ event.xconfigure.x = x;
+ event.xconfigure.y = y;
+ event.xconfigure.width = width;
+ event.xconfigure.height = height;
+
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
-
+
/*
* Update window manager information.
*/
@@ -583,7 +754,7 @@ TkGenWMConfigureEvent(
wmPtr->y = y;
wmPtr->flags &= ~(WM_NEGATIVE_X | WM_NEGATIVE_Y);
}
- if ((flags & TK_SIZE_CHANGED) &&
+ if ((flags & TK_SIZE_CHANGED) && !(wmPtr->flags & WM_SYNC_PENDING) &&
((width != Tk_Width(tkwin)) || (height != Tk_Height(tkwin)))) {
if ((wmPtr->width == -1) && (width == winPtr->reqWidth)) {
/*
@@ -621,11 +792,11 @@ TkGenWMConfigureEvent(
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
+ * 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 visible to the subwindow.
*/
@@ -635,13 +806,14 @@ TkGenWMConfigureEvent(
winPtr->changes.height = height;
TkMacOSXInvalClipRgns(tkwin);
}
-
+
/*
*----------------------------------------------------------------------
*
* TkGenWMDestroyEvent --
*
- * Generate a WM Destroy event for Tk. *
+ * Generate a WM Destroy event for Tk.
+ *
* Results:
* None.
*
@@ -656,11 +828,11 @@ 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");
@@ -668,7 +840,7 @@ TkGenWMDestroyEvent(
event.xclient.data.l[0] = Tk_InternAtom(tkwin, "WM_DELETE_WINDOW");
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
}
-
+
/*
*----------------------------------------------------------------------
*
@@ -706,11 +878,11 @@ TkWmProtocolEventProc(
}
protocol = (Atom) eventPtr->xclient.data.l[0];
for (protPtr = wmPtr->protPtr; protPtr != NULL;
- protPtr = protPtr->nextPtr) {
+ protPtr = protPtr->nextPtr) {
if (protocol == protPtr->protocol) {
Tcl_Preserve((ClientData) protPtr);
- interp = protPtr->interp;
- Tcl_Preserve((ClientData) interp);
+ interp = protPtr->interp;
+ Tcl_Preserve((ClientData) interp);
result = Tcl_GlobalEval(interp, protPtr->command);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp, "\n (command for \"");
@@ -719,14 +891,14 @@ TkWmProtocolEventProc(
Tcl_AddErrorInfo(interp, "\" window manager protocol)");
Tk_BackgroundError(interp);
}
- Tcl_Release((ClientData) interp);
+ Tcl_Release((ClientData) interp);
Tcl_Release((ClientData) protPtr);
return;
}
}
/*
- * No handler was present for this protocol. If this is a
+ * No handler was present for this protocol. If this is a
* WM_DELETE_WINDOW message then just destroy the window.
*/
@@ -734,13 +906,13 @@ TkWmProtocolEventProc(
Tk_DestroyWindow((Tk_Window) winPtr);
}
}
-
+
/*
*----------------------------------------------------------------------
*
* Tk_MacOSXIsAppInFront --
*
- * Returns 1 if this app is the foreground app.
+ * Returns 1 if this app is the foreground app.
*
* Results:
* 1 if app is in front, 0 otherwise.
@@ -756,3 +928,31 @@ Tk_MacOSXIsAppInFront (void)
{
return tkMacOSXAppInFront;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ClearPort --
+ *
+ * Clear (i.e. fill with transparent color) the given port.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+static void
+ClearPort(CGrafPtr port) {
+ CGContextRef context;
+ Rect bounds;
+ CGRect rect;
+
+ GetPortBounds(port, &bounds);
+ QDBeginCGContext(port, &context);
+ rect = CGRectMake(0, 0, bounds.right, bounds.bottom);
+ CGContextClearRect(context, rect);
+ QDEndCGContext(port, &context);
+}