diff options
-rw-r--r-- | macosx/tkMacOSXClipboard.c | 73 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 631 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 445 |
3 files changed, 598 insertions, 551 deletions
diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 79d98ff..7daffea 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -7,29 +7,28 @@ * Copyright 2001, Apple Computer, Inc. * Copyright (c) 2006-2007 Daniel A. Steffen <das@users.sourceforge.net> * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXClipboard.c,v 1.12 2007/12/13 15:27:08 dgp Exp $ + * RCS: @(#) $Id: tkMacOSXClipboard.c,v 1.13 2008/10/05 21:26:11 dkf Exp $ */ #include "tkMacOSXPrivate.h" #include "tkSelect.h" - /* *---------------------------------------------------------------------- * * TkSelGetSelection -- * - * Retrieve the specified selection from another process. For - * now, only fetching XA_STRING from CLIPBOARD is supported. - * Eventually other types should be allowed. + * Retrieve the specified selection from another process. For now, only + * fetching XA_STRING from CLIPBOARD is supported. Eventually other types + * should be allowed. * * Results: - * The return value is a standard Tcl return value. - * If an error occurs (such as no selection exists) - * then an error message is left in the interp's result. + * The return value is a standard Tcl return value. If an error occurs + * (such as no selection exists) then an error message is left in the + * interp's result. * * Side effects: * None. @@ -72,27 +71,28 @@ TkSelGetSelection( /* * Try UNICODE first */ + err = ChkErr(GetScrapFlavorSize, scrapRef, kScrapFlavorTypeUnicode, &length); if (err == noErr && length > 0) { Tcl_DString ds; char *data; - buf = (char *) ckalloc(length + 2); + buf = ckalloc(length + 2); buf[length] = 0; buf[length+1] = 0; /* 2-byte unicode null */ err = ChkErr(GetScrapFlavorData, scrapRef, kScrapFlavorTypeUnicode, &length, buf); if (err == noErr) { Tcl_DStringInit(&ds); - Tcl_UniCharToUtfDString((Tcl_UniChar *)buf, - Tcl_UniCharLen((Tcl_UniChar *)buf), &ds); + Tcl_UniCharToUtfDString((Tcl_UniChar *) buf, + Tcl_UniCharLen((Tcl_UniChar *) buf), &ds); for (data = Tcl_DStringValue(&ds); *data != '\0'; data++) { if (*data == '\r') { *data = '\n'; } } - result = (*proc)(clientData, interp, Tcl_DStringValue(&ds)); + result = proc(clientData, interp, Tcl_DStringValue(&ds)); Tcl_DStringFree(&ds); ckfree(buf); return result; @@ -109,7 +109,7 @@ TkSelGetSelection( Tcl_DString encodedText; char *data; - buf = (char *) ckalloc(length + 1); + buf = ckalloc(length + 1); buf[length] = 0; err = ChkErr(GetScrapFlavorData, scrapRef, 'TEXT', &length, buf); if (err != noErr) { @@ -150,9 +150,8 @@ TkSelGetSelection( * * TkSetSelectionOwner -- * - * This function claims ownership of the specified selection. - * If the selection is CLIPBOARD, then we empty the system - * clipboard. + * This function claims ownership of the specified selection. If the + * selection is CLIPBOARD, then we empty the system clipboard. * * Results: * None. @@ -174,16 +173,16 @@ XSetSelectionOwner( TkDisplay *dispPtr; /* - * This is a gross hack because the Tk_InternAtom interface is broken. - * It expects a Tk_Window, even though it only needs a Tk_Display. + * This is a gross hack because the Tk_InternAtom interface is broken. It + * expects a Tk_Window, even though it only needs a Tk_Display. */ tkwin = (Tk_Window) TkGetMainInfoList()->winPtr; if (selection == Tk_InternAtom(tkwin, "CLIPBOARD")) { /* - * Only claim and empty the clipboard if we aren't already the - * owner of the clipboard. + * Only claim and empty the clipboard if we aren't already the owner + * of the clipboard. */ dispPtr = TkGetMainInfoList()->winPtr->dispPtr; @@ -199,9 +198,8 @@ XSetSelectionOwner( * * TkSelUpdateClipboard -- * - * This function is called to force the clipboard to be updated - * after new data is added. On the Mac we don't need to do - * anything. + * This function is called to force the clipboard to be updated after new + * data is added. On the Mac we don't need to do anything. * * Results: * None. @@ -225,8 +223,7 @@ TkSelUpdateClipboard( * * TkSelEventProc -- * - * This procedure is invoked whenever a selection-related - * event occurs. + * This procedure is invoked whenever a selection-related event occurs. * * Results: * None. @@ -253,9 +250,8 @@ TkSelEventProc( * * TkSelPropProc -- * - * This procedure is invoked when property-change events - * occur on windows not known to the toolkit. This is a stub - * function under Windows. + * This procedure is invoked when property-change events occur on windows + * not known to the toolkit. This is a stub function under Windows. * * Results: * None. @@ -277,8 +273,8 @@ TkSelPropProc( * * TkSuspendClipboard -- * - * Handle clipboard conversion as required by the suppend event. - * This function is also called on exit. + * Handle clipboard conversion as required by the suppend event. This + * function is also called on exit. * * Results: * None. @@ -356,9 +352,9 @@ TkSuspendClipboard(void) } /* - * The system now owns the scrap. We tell Tk that it has - * lost the selection so that it will look for it the next time - * it needs it. (Window list NULL if quiting.) + * The system now owns the scrap. We tell Tk that it has lost the + * selection so that it will look for it the next time it needs it. + * (Window list NULL if quiting.) */ if (TkGetMainInfoList() != NULL) { @@ -369,3 +365,10 @@ TkSuspendClipboard(void) return; } + +/* + * Local Variables: + * fill-column: 78 + * c-basic-offset: 4 + * End: + */ diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 57bd33b..093e842 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -1,8 +1,8 @@ /* * tkMacOSXWindowEvent.c -- * - * This file defines the routines for both creating and handling - * Window Manager class events for Tk. + * This file defines the routines for both creating and handling Window + * Manager class events for Tk. * * Copyright 2001, Apple Computer, Inc. * Copyright (c) 2005-2007 Daniel A. Steffen <das@users.sourceforge.net> @@ -11,50 +11,44 @@ * 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 + * 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.32 2008/06/19 00:11:08 das Exp $ + * 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.33 2008/10/05 21:26:11 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -72,20 +66,19 @@ * Declaration of functions used only in this file */ -static int GenerateUpdateEvent(Window window); -static int GenerateUpdates(HIMutableShapeRef updateRgn, CGRect *updateBounds, - TkWindow *winPtr); -static int GenerateActivateEvents(Window window, int activeFlag); -static void ClearPort(CGrafPtr port, HIShapeRef updateRgn); - +static int GenerateUpdateEvent(Window window); +static int GenerateUpdates(HIMutableShapeRef updateRgn, + CGRect *updateBounds, TkWindow *winPtr); +static int GenerateActivateEvents(Window window, int activeFlag); +static void ClearPort(CGrafPtr port, HIShapeRef updateRgn); /* *---------------------------------------------------------------------- * * TkMacOSXProcessApplicationEvent -- * - * This processes Application level events, mainly activate - * and deactivate. + * This processes Application level events, mainly activate and + * deactivate. * * Results: * 0. @@ -98,8 +91,8 @@ static void ClearPort(CGrafPtr port, HIShapeRef updateRgn); MODULE_SCOPE int TkMacOSXProcessApplicationEvent( - TkMacOSXEvent *eventPtr, - MacEventStatus *statusPtr) + TkMacOSXEvent *eventPtr, + MacEventStatus *statusPtr) { Tcl_CmdInfo dummy; @@ -109,60 +102,61 @@ TkMacOSXProcessApplicationEvent( * the "show" proc when we have been hidden already, not as a substitute * for <Activate>. So I use this toggle... */ + static int toggleHide = 0; switch (eventPtr->eKind) { - case kEventAppActivated: - ShowFloatingWindows(); - break; - case kEventAppDeactivated: - TkSuspendClipboard(); - 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"); - } + case kEventAppActivated: + ShowFloatingWindows(); + break; + case kEventAppDeactivated: + TkSuspendClipboard(); + 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 kEventAppAvailableWindowBoundsChanged: { - 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); + } + 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"); } - /* - * Should we call ::tk::mac::OnDisplayChanged? - */ - break; } - default: - break; + statusPtr->stopProcessing = 1; + break; + case kEventAppAvailableWindowBoundsChanged: { + 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; } return 0; } @@ -185,15 +179,15 @@ TkMacOSXProcessApplicationEvent( MODULE_SCOPE int TkMacOSXProcessAppearanceEvent( - TkMacOSXEvent *eventPtr, - MacEventStatus *statusPtr) + TkMacOSXEvent *eventPtr, + MacEventStatus *statusPtr) { switch (eventPtr->eKind) { - case kEventAppearanceScrollBarVariantChanged: - TkMacOSXInitScrollbarMetrics(); - break; - default: - break; + case kEventAppearanceScrollBarVariantChanged: + TkMacOSXInitScrollbarMetrics(); + break; + default: + break; } return 0; } @@ -203,23 +197,21 @@ TkMacOSXProcessAppearanceEvent( * * TkMacOSXProcessWindowEvent -- * - * This processes Window level events, mainly activate - * and deactivate. + * 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. + * Cause Windows to be moved forward or backward in the window stack. * *---------------------------------------------------------------------- */ MODULE_SCOPE int TkMacOSXProcessWindowEvent( - TkMacOSXEvent * eventPtr, - MacEventStatus * statusPtr) + TkMacOSXEvent *eventPtr, + MacEventStatus *statusPtr) { OSStatus err; WindowRef whichWindow; @@ -229,20 +221,20 @@ TkMacOSXProcessWindowEvent( TkWindow *winPtr; switch (eventPtr->eKind) { - case kEventWindowActivated: - case kEventWindowDeactivated: - case kEventWindowUpdate: - case kEventWindowExpanding: - case kEventWindowBoundsChanged: - case kEventWindowDragStarted: - case kEventWindowDragCompleted: - case kEventWindowConstrain: - case kEventWindowGetRegion: - case kEventWindowDrawContent: - break; - default: - return 0; - break; + case kEventWindowActivated: + case kEventWindowDeactivated: + case kEventWindowUpdate: + case kEventWindowExpanding: + case kEventWindowBoundsChanged: + case kEventWindowDragStarted: + case kEventWindowDragCompleted: + case kEventWindowConstrain: + case kEventWindowGetRegion: + case kEventWindowDrawContent: + break; + default: + return 0; + break; } err = ChkErr(GetEventParameter, eventPtr->eventRef, kEventParamDirectObject, typeWindowRef, NULL, sizeof(whichWindow), @@ -253,169 +245,160 @@ TkMacOSXProcessWindowEvent( window = TkMacOSXGetXWindow(whichWindow); dispPtr = TkGetDisplayList(); - winPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, window); + winPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, window); switch (eventPtr->eKind) { - case kEventWindowActivated: - case kEventWindowDeactivated: - if (window != None) { - 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 (window != None && GenerateUpdateEvent(window)) { - eventFound = true; - statusPtr->stopProcessing = 1; - } - break; - case kEventWindowExpanding: + case kEventWindowActivated: + case kEventWindowDeactivated: + if (window != None) { + int activate = (eventPtr->eKind == kEventWindowActivated); + + eventFound |= GenerateActivateEvents(window, activate); + eventFound |= TkMacOSXGenerateFocusEvent(window, activate); if (winPtr) { - winPtr->wmInfoPtr->hints.initial_state = - TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : - NormalState; - Tk_MapWindow((Tk_Window) winPtr); - /* - * Need to process all Tk events generated by Tk_MapWindow() - * before returning to ensure all children are mapped, as - * otherwise the Activate event that follows Expanding would - * not be processed by any unmapped children. - */ - while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {}; - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {}; + TkMacOSXEnterExitFullscreen(winPtr, activate); } - 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; - } - TkMacOSXInvalClipRgns((Tk_Window) winPtr); - TkMacOSXInvalidateWindow((MacDrawable *) window, - TK_PARENT_WINDOW); - TkGenWMConfigureEvent((Tk_Window)winPtr, x, y, width, - height, flags); - if (attr & kWindowBoundsChangeUserResize || - attr & kWindowBoundsChangeUserDrag) { - TkMacOSXRunTclEventLoop(); - } - if (wmPtr->attributes & kWindowResizableAttribute) { - HIViewRef growBoxView; + statusPtr->stopProcessing = 1; + } + break; + case kEventWindowUpdate: + if (window != None && GenerateUpdateEvent(window)) { + eventFound = true; + statusPtr->stopProcessing = 1; + } + break; + case kEventWindowExpanding: + if (winPtr) { + winPtr->wmInfoPtr->hints.initial_state = + TkMacOSXIsWindowZoomed(winPtr) ? ZoomState : NormalState; + Tk_MapWindow((Tk_Window) winPtr); - err = HIViewFindByID(HIViewGetRoot(whichWindow), - kHIViewWindowGrowBoxID, &growBoxView); - if (err == noErr) { - ChkErr(HIViewSetNeedsDisplay, growBoxView, true); - } - } - } - break; - case kEventWindowDragStarted: - if (!(TkMacOSXModifierState() & cmdKey)) { - TkMacOSXBringWindowForward(whichWindow); + /* + * Need to process all Tk events generated by Tk_MapWindow() + * before returning to ensure all children are mapped, as + * otherwise the Activate event that follows Expanding would not + * be processed by any unmapped children. + */ + + while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {/*empty body*/}; + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {/*empty body*/}; + } + 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; } - TkMacOSXTrackingLoop(1); - break; - case kEventWindowDragCompleted: { - 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 (attr & kWindowBoundsChangeSizeChanged) { + width = bounds.right - bounds.left; + height = bounds.bottom - bounds.top; + flags |= TK_SIZE_CHANGED; } - 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; + TkMacOSXInvalClipRgns((Tk_Window) winPtr); + TkMacOSXInvalidateWindow((MacDrawable*) window, TK_PARENT_WINDOW); + TkGenWMConfigureEvent((Tk_Window)winPtr, x, y, width, height, + flags); + if (attr & kWindowBoundsChangeUserResize || + attr & kWindowBoundsChangeUserDrag) { + TkMacOSXRunTclEventLoop(); } - if (h || v) { - OffsetRect(&bounds, h, v); - ChkErr(SetWindowBounds, whichWindow, - kWindowStructureRgn, &bounds); + if (wmPtr->attributes & kWindowResizableAttribute) { + HIViewRef growBoxView; + + err = HIViewFindByID(HIViewGetRoot(whichWindow), + kHIViewWindowGrowBoxID, &growBoxView); + if (err == noErr) { + ChkErr(HIViewSetNeedsDisplay, growBoxView, true); + } } - break; } - case kEventWindowConstrain: - if (winPtr && (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; + break; + case kEventWindowDragStarted: + if (!(TkMacOSXModifierState() & cmdKey)) { + TkMacOSXBringWindowForward(whichWindow); + } + TkMacOSXTrackingLoop(1); + break; + case kEventWindowDragCompleted: { + 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 && (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; - 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; - } + 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; + } + break; + case kEventWindowDrawContent: + if (winPtr && (winPtr->wmInfoPtr->flags & WM_TRANSPARENT)) { + CGrafPtr port; - GetPort(&port); - ClearPort(port, NULL); - } - break; + GetPort(&port); + ClearPort(port, NULL); + } + break; } return eventFound; @@ -426,8 +409,8 @@ 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. @@ -437,8 +420,10 @@ TkMacOSXProcessWindowEvent( * *---------------------------------------------------------------------- */ + static int -GenerateUpdateEvent(Window window) +GenerateUpdateEvent( + Window window) { WindowRef macWindow; TkDisplay *dispPtr; @@ -471,7 +456,8 @@ GenerateUpdateEvent(Window window) ChkErr(GetWindowBounds, macWindow, kWindowContentRgn, &bounds); dx = -bounds.left; dy = -bounds.top; - ) TK_ENDIF + ) TK_ENDIF; + updateRgn = HIShapeCreateMutableCopy(rgn); CFRelease(rgn); ChkErr(HIShapeOffset, updateRgn, dx, dy); @@ -502,10 +488,10 @@ 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. @@ -595,14 +581,14 @@ GenerateUpdates( return 1; } - + /* *---------------------------------------------------------------------- * * GenerateActivateEvents -- * - * Given a Macintosh window activate event this function generates all the - * X Activate events needed by Tk. + * 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. @@ -615,8 +601,8 @@ GenerateUpdates( int GenerateActivateEvents( - Window window, /* Root X window for event. */ - int activeFlag ) + Window window, /* Root X window for event. */ + int activeFlag) { TkWindow *winPtr; TkDisplay *dispPtr; @@ -630,14 +616,14 @@ GenerateActivateEvents( TkGenerateActivateEvents(winPtr,activeFlag); return true; } - + /* *---------------------------------------------------------------------- * * TkMacOSXGenerateFocusEvent -- * - * Given a Macintosh window activate event this function generates all the - * X Focus events needed by Tk. + * 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. @@ -651,7 +637,7 @@ GenerateActivateEvents( MODULE_SCOPE int TkMacOSXGenerateFocusEvent( Window window, /* Root X window for event. */ - int activeFlag ) + int activeFlag) { XEvent event; Tk_Window tkwin; @@ -664,9 +650,10 @@ TkMacOSXGenerateFocusEvent( } /* - * Don't send focus events to windows of class help or to - * windows with the kWindowNoActivatesAttribute. + * Don't send focus events to windows of class help or to windows with the + * kWindowNoActivatesAttribute. */ + if (((TkWindow *)tkwin)->wmInfoPtr->macClass == kHelpWindowClass || ((TkWindow *)tkwin)->wmInfoPtr->attributes & kWindowNoActivatesAttribute) { @@ -674,8 +661,8 @@ TkMacOSXGenerateFocusEvent( } /* - * Generate FocusIn and FocusOut events. This event - * is only sent to the toplevel window. + * Generate FocusIn and FocusOut events. This event is only sent to the + * toplevel window. */ if (activeFlag) { @@ -700,9 +687,8 @@ TkMacOSXGenerateFocusEvent( * * 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. + * 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. @@ -762,6 +748,7 @@ TkGenWMConfigureEvent( /* * Update window manager information. */ + if (Tk_IsTopLevel(winPtr)) { wmPtr = winPtr->wmInfoPtr; if (flags & TK_LOCATION_CHANGED) { @@ -779,7 +766,7 @@ TkGenWMConfigureEvent( } else { if (wmPtr->gridWin != NULL) { wmPtr->width = wmPtr->reqGridWidth - + (width - winPtr->reqWidth)/wmPtr->widthInc; + + (width - winPtr->reqWidth)/wmPtr->widthInc; if (wmPtr->width < 0) { wmPtr->width = 0; } @@ -795,7 +782,7 @@ TkGenWMConfigureEvent( } else { if (wmPtr->gridWin != NULL) { wmPtr->height = wmPtr->reqGridHeight - + (height - winPtr->reqHeight)/wmPtr->heightInc; + + (height - winPtr->reqHeight)/wmPtr->heightInc; if (wmPtr->height < 0) { wmPtr->height = 0; } @@ -811,10 +798,11 @@ TkGenWMConfigureEvent( /* * 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. + * 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. */ + winPtr->changes.x = x; winPtr->changes.y = y; winPtr->changes.width = width; @@ -862,16 +850,15 @@ TkGenWMDestroyEvent( * 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. + * 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. + * Depends on what sort of handler, if any, was set up for the protocol. * *---------------------------------------------------------------------- */ @@ -893,11 +880,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); + Tcl_Preserve(protPtr); interp = protPtr->interp; - Tcl_Preserve((ClientData) interp); + Tcl_Preserve(interp); result = Tcl_GlobalEval(interp, protPtr->command); if (result != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (command for \""); @@ -906,15 +893,15 @@ TkWmProtocolEventProc( Tcl_AddErrorInfo(interp, "\" window manager protocol)"); Tk_BackgroundError(interp); } - Tcl_Release((ClientData) interp); - Tcl_Release((ClientData) protPtr); + Tcl_Release(interp); + Tcl_Release(protPtr); return; } } /* - * No handler was present for this protocol. If this is a - * WM_DELETE_WINDOW message then just destroy the window. + * 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")) { @@ -968,6 +955,7 @@ Tk_MacOSXIsAppInFront(void) * *---------------------------------------------------------------------- */ + static void ClearPort( CGrafPtr port, @@ -990,3 +978,10 @@ ClearPort( CGContextClearRect(context, rect); QDEndCGContext(port, &context); } + +/* + * Local Variables: + * fill-column: 78 + * c-basic-offset: 4 + * End: + */ diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 11519f3..8bbb701 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.67 2008/10/05 18:22:21 dkf Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.68 2008/10/05 21:26:12 dkf Exp $ */ #include "tkMacOSXPrivate.h" @@ -89,90 +89,128 @@ static int windowHashInit = false; * Forward declarations for procedures defined in this file: */ -static void InitialWindowBounds(TkWindow *winPtr, WindowRef macWindow, - Rect *geometry); -static int ParseGeometry(Tcl_Interp *interp, char *string, TkWindow *winPtr); -static void TopLevelEventProc(ClientData clientData, XEvent *eventPtr); -static void WmStackorderToplevelWrapperMap(TkWindow *winPtr, Display *display, - Tcl_HashTable *table); -static void UpdateGeometryInfo(ClientData clientData); -static void UpdateSizeHints(TkWindow *winPtr); -static void UpdateVRootGeometry(WmInfo *wmPtr); -static int WmAspectCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmAttributesCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmClientCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmColormapwindowsCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmCommandCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmDeiconifyCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmFocusmodelCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmForgetCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmFrameCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmGeometryCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmGridCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmGroupCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmIconbitmapCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmIconifyCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmIconmaskCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmIconnameCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmIconphotoCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmIconpositionCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmIconwindowCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmManageCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmMaxsizeCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmMinsizeCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmOverrideredirectCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmPositionfromCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmProtocolCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmResizableCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmSizefromCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmStackorderCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmStateCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmTitleCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static int WmTransientCmd(Tk_Window tkwin, TkWindow *winPtr, - Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); -static int WmWithdrawCmd(Tk_Window tkwin, TkWindow *winPtr, Tcl_Interp *interp, - int objc, Tcl_Obj *const objv[]); -static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr); -static int WmWinStyle(Tcl_Interp *interp, TkWindow *winPtr, int objc, - Tcl_Obj * const objv[]); -static void ApplyWindowClassAttributeChanges(TkWindow *winPtr, - WindowRef macWindow, WindowClass oldClass, - WindowAttributes oldAttributes, int create); -static void ApplyMasterOverrideChanges(TkWindow *winPtr, WindowRef macWindow); -static WindowGroupRef WmGetWindowGroup(TkWindow *winPtr); -static void GetMinSize(TkWindow *winPtr, int *minWidthPtr, int *minHeightPtr); -static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, int *maxHeightPtr); -static void RemapWindows(TkWindow *winPtr, MacDrawable *parentWin); +static void InitialWindowBounds(TkWindow *winPtr, + WindowRef macWindow, Rect *geometry); +static int ParseGeometry(Tcl_Interp *interp, char *string, + TkWindow *winPtr); +static void TopLevelEventProc(ClientData clientData, + XEvent *eventPtr); +static void WmStackorderToplevelWrapperMap(TkWindow *winPtr, + Display *display, Tcl_HashTable *table); +static void UpdateGeometryInfo(ClientData clientData); +static void UpdateSizeHints(TkWindow *winPtr); +static void UpdateVRootGeometry(WmInfo *wmPtr); +static int WmAspectCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmAttributesCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmClientCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmColormapwindowsCmd(Tk_Window tkwin, + TkWindow *winPtr, Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmCommandCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmDeiconifyCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmFocusmodelCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmForgetCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmFrameCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmGeometryCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmGridCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmGroupCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmIconbitmapCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmIconifyCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmIconmaskCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmIconnameCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmIconphotoCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmIconpositionCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmIconwindowCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmManageCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmMaxsizeCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmMinsizeCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmOverrideredirectCmd(Tk_Window tkwin, + TkWindow *winPtr, Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmPositionfromCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmProtocolCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmResizableCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmSizefromCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmStackorderCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmStateCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmTitleCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmTransientCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static int WmWithdrawCmd(Tk_Window tkwin, TkWindow *winPtr, + Tcl_Interp *interp, int objc, + Tcl_Obj *const objv[]); +static void WmUpdateGeom(WmInfo *wmPtr, TkWindow *winPtr); +static int WmWinStyle(Tcl_Interp *interp, TkWindow *winPtr, + int objc, Tcl_Obj *const objv[]); +static void ApplyWindowClassAttributeChanges(TkWindow *winPtr, + WindowRef macWindow, WindowClass oldClass, + WindowAttributes oldAttributes, int create); +static void ApplyMasterOverrideChanges(TkWindow *winPtr, + WindowRef macWindow); +static WindowGroupRef WmGetWindowGroup(TkWindow *winPtr); +static void GetMinSize(TkWindow *winPtr, int *minWidthPtr, + int *minHeightPtr); +static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, + int *maxHeightPtr); +static void RemapWindows(TkWindow *winPtr, + MacDrawable *parentWin); /* *---------------------------------------------------------------------- @@ -314,6 +352,7 @@ TkWmMapWindow( /* * Generate configure event when we first map the window. */ + TkGenWMConfigureEvent((Tk_Window) winPtr, wmPtr->x, wmPtr->y, -1, -1, TK_LOCATION_CHANGED); @@ -1146,7 +1185,7 @@ WmColormapwindowsCmd( return TCL_ERROR; } cmapList = (TkWindow **) ckalloc((unsigned) - ((windowObjc+1) * sizeof(TkWindow*))); + ((windowObjc+1) * sizeof(TkWindow*))); for (i = 0; i < windowObjc; i++) { if (TkGetWindowFromObj(interp, tkwin, windowObjv[i], (Tk_Window *) &winPtr2) != TCL_OK) { @@ -1170,7 +1209,7 @@ WmColormapwindowsCmd( } wmPtr->flags |= WM_COLORMAPS_EXPLICIT; if (wmPtr->cmapList != NULL) { - ckfree((char *)wmPtr->cmapList); + ckfree((char *) wmPtr->cmapList); } wmPtr->cmapList = cmapList; wmPtr->cmapCount = windowObjc; @@ -1188,8 +1227,8 @@ WmColormapwindowsCmd( * * WmCommandCmd -- * - * This procedure is invoked to process the "wm command" Tcl command. - * See the user documentation for details on what it does. + * This procedure is invoked to process the "wm command" Tcl command. See + * the user documentation for details on what it does. * * Results: * A standard Tcl result. @@ -1442,7 +1481,7 @@ WmFrameCmd( if (window == None) { window = Tk_WindowId((Tk_Window) winPtr); } - sprintf(buf, "0x%x", (unsigned int) window); + sprintf(buf, "0x%x", (unsigned) window); Tcl_SetResult(interp, buf, TCL_VOLATILE); return TCL_OK; } @@ -1736,8 +1775,8 @@ WmIconbitmapCmd( * * WmIconifyCmd -- * - * This procedure is invoked to process the "wm iconify" Tcl command. - * See the user documentation for details on what it does. + * This procedure is invoked to process the "wm iconify" Tcl command. See + * the user documentation for details on what it does. * * Results: * A standard Tcl result. @@ -1876,19 +1915,20 @@ WmIconnameCmd( return TCL_ERROR; } if (objc == 3) { - Tcl_SetResult(interp, (char *) ((wmPtr->iconName != NULL) ? - wmPtr->iconName : ""), TCL_STATIC); - return TCL_OK; - } else { if (wmPtr->iconName != NULL) { - ckfree((char *) wmPtr->iconName); - } - argv3 = Tcl_GetStringFromObj(objv[3], &length); - wmPtr->iconName = ckalloc((unsigned) length + 1); - strcpy(wmPtr->iconName, argv3); - if (!(wmPtr->flags & WM_NEVER_MAPPED)) { - XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); + Tcl_SetObjResult(interp, Tcl_NewStringObj(wmPtr->iconName, -1)); } + return TCL_OK; + } + + if (wmPtr->iconName != NULL) { + ckfree((char *) wmPtr->iconName); + } + argv3 = Tcl_GetStringFromObj(objv[3], &length); + wmPtr->iconName = ckalloc((unsigned) length + 1); + strcpy(wmPtr->iconName, argv3); + if (!(wmPtr->flags & WM_NEVER_MAPPED)) { + XSetIconName(winPtr->display, winPtr->window, wmPtr->iconName); } return TCL_OK; } @@ -1899,7 +1939,7 @@ WmIconnameCmd( * WmIconphotoCmd -- * * This procedure is invoked to process the "wm iconphoto" Tcl command. - * See the user documentation for details on what it does. Not yet + * See the user documentation for details on what it does. Not yet * implemented for OS X. * * Results: @@ -2165,8 +2205,8 @@ WmManageCmd( * * WmMaxsizeCmd -- * - * This procedure is invoked to process the "wm maxsize" Tcl command. - * See the user documentation for details on what it does. + * This procedure is invoked to process the "wm maxsize" Tcl command. See + * the user documentation for details on what it does. * * Results: * A standard Tcl result. @@ -2216,8 +2256,8 @@ WmMaxsizeCmd( * * WmMinsizeCmd -- * - * This procedure is invoked to process the "wm minsize" Tcl command. - * See the user documentation for details on what it does. + * This procedure is invoked to process the "wm minsize" Tcl command. See + * the user documentation for details on what it does. * * Results: * A standard Tcl result. @@ -2313,9 +2353,8 @@ WmOverrideredirectCmd( * * WmPositionfromCmd -- * - * This procedure is invoked to process the "wm positionfrom" - * Tcl command. - * See the user documentation for details on what it does. + * This procedure is invoked to process the "wm positionfrom" Tcl + * command. See the user documentation for details on what it does. * * Results: * A standard Tcl result. @@ -2687,28 +2726,27 @@ WmStackorderCmd( */ windows = TkWmStackorderToplevel(winPtr->mainPtr->winPtr); - if (windows == NULL) { Tcl_AppendResult(interp, "TkWmStackorderToplevel failed", NULL); return TCL_ERROR; - } else { - for (window_ptr = windows; *window_ptr ; window_ptr++) { - if (*window_ptr == winPtr) { - index1 = (window_ptr - windows); - } - if (*window_ptr == winPtr2) { - index2 = (window_ptr - windows); - } - } - if (index1 == -1) { - Tcl_Panic("winPtr window not found"); + } + + for (window_ptr = windows; *window_ptr ; window_ptr++) { + if (*window_ptr == winPtr) { + index1 = (window_ptr - windows); } - if (index2 == -1) { - Tcl_Panic("winPtr2 window not found"); + if (*window_ptr == winPtr2) { + index2 = (window_ptr - windows); } - - ckfree((char *) windows); } + if (index1 == -1) { + Tcl_Panic("winPtr window not found"); + } + if (index2 == -1) { + Tcl_Panic("winPtr2 window not found"); + } + + ckfree((char *) windows); if (Tcl_GetIndexFromObj(interp, objv[3], optionStrings, "argument", 0, &index) != TCL_OK) { @@ -2781,9 +2819,10 @@ WmStateCmd( if (index == OPT_NORMAL) { TkpWmSetState(winPtr, NormalState); + /* - * This varies from 'wm deiconify' because it does not - * force the window to be raised and receive focus + * This varies from 'wm deiconify' because it does not force the + * window to be raised and receive focus */ } else if (index == OPT_ICONIC) { if (Tk_Attributes((Tk_Window) winPtr)->override_redirect) { @@ -2802,29 +2841,27 @@ WmStateCmd( } else { /* OPT_ZOOMED */ TkpWmSetState(winPtr, ZoomState); } + } else if (wmPtr->iconFor != NULL) { + Tcl_SetResult(interp, "icon", TCL_STATIC); } else { - if (wmPtr->iconFor != NULL) { - Tcl_SetResult(interp, "icon", TCL_STATIC); - } else { - if (wmPtr->hints.initial_state == NormalState || - wmPtr->hints.initial_state == ZoomState) { - wmPtr->hints.initial_state = (TkMacOSXIsWindowZoomed(winPtr) ? - ZoomState : NormalState); - } - switch (wmPtr->hints.initial_state) { - case NormalState: - Tcl_SetResult(interp, "normal", TCL_STATIC); - break; - case IconicState: - Tcl_SetResult(interp, "iconic", TCL_STATIC); - break; - case WithdrawnState: - Tcl_SetResult(interp, "withdrawn", TCL_STATIC); - break; - case ZoomState: - Tcl_SetResult(interp, "zoomed", TCL_STATIC); - break; - } + if (wmPtr->hints.initial_state == NormalState || + wmPtr->hints.initial_state == ZoomState) { + wmPtr->hints.initial_state = (TkMacOSXIsWindowZoomed(winPtr) ? + ZoomState : NormalState); + } + switch (wmPtr->hints.initial_state) { + case NormalState: + Tcl_SetResult(interp, "normal", TCL_STATIC); + break; + case IconicState: + Tcl_SetResult(interp, "iconic", TCL_STATIC); + break; + case WithdrawnState: + Tcl_SetResult(interp, "withdrawn", TCL_STATIC); + break; + case ZoomState: + Tcl_SetResult(interp, "zoomed", TCL_STATIC); + break; } } return TCL_OK; @@ -3005,10 +3042,11 @@ WmWithdrawCmd( * Invoked by those wm subcommands that affect geometry. * Schedules a geometry update. */ + static void -WmUpdateGeom(wmPtr, winPtr) -WmInfo *wmPtr; -TkWindow *winPtr; +WmUpdateGeom( + WmInfo *wmPtr, + TkWindow *winPtr) { if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) { Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr); @@ -3217,6 +3255,7 @@ TopLevelEventProc( Tk_ErrorHandler handler = Tk_CreateErrorHandler(winPtr->display, -1, -1, -1, NULL, NULL); + Tk_DestroyWindow((Tk_Window) winPtr); Tk_DeleteErrorHandler(handler); } @@ -3689,55 +3728,55 @@ Tk_GetRootCoords( x += winPtr->changes.x + winPtr->changes.border_width; y += winPtr->changes.y + winPtr->changes.border_width; if (winPtr->flags & TK_TOP_LEVEL) { + TkWindow *otherPtr; + if (!(Tk_IsEmbedded(winPtr))) { x += winPtr->wmInfoPtr->xInParent; y += winPtr->wmInfoPtr->yInParent; break; - } else { - TkWindow *otherPtr = TkpGetOtherWindow(winPtr); - - if (otherPtr != NULL) { - /* - * The container window is in the same application. Query - * its coordinates. - */ + } - winPtr = otherPtr; + otherPtr = TkpGetOtherWindow(winPtr); + if (otherPtr == NULL) { + if (tkMacOSXEmbedHandler->getOffsetProc != NULL) { + Point theOffset; /* - * Remember to offset by the container window here, since - * at the end of this if branch, we will pop out to the - * container's parent... + * We do not require that the changes.x & changes.y for a + * non-Tk master window be kept up to date. So we first + * subtract off the possibly bogus values that have been + * added on at the top of this pass through the loop, and + * then call out to the getOffsetProc to give us the + * correct offset. */ - x += winPtr->changes.x + winPtr->changes.border_width; - y += winPtr->changes.y + winPtr->changes.border_width; + x -= winPtr->changes.x + winPtr->changes.border_width; + y -= winPtr->changes.y + winPtr->changes.border_width; - } else { - Point theOffset; + tkMacOSXEmbedHandler->getOffsetProc((Tk_Window) winPtr, + &theOffset); - if (tkMacOSXEmbedHandler->getOffsetProc != NULL) { - /* - * We do not require that the changes.x & changes.y - * for a non-Tk master window be kept up to date. So - * we first subtract off the possibly bogus values - * that have been added on at the top of this pass - * through the loop, and then call out to the - * getOffsetProc to give us the correct offset. - */ + x += theOffset.h; + y += theOffset.v; + } + break; + } - x -= winPtr->changes.x + winPtr->changes.border_width; - y -= winPtr->changes.y + winPtr->changes.border_width; + /* + * The container window is in the same application. Query its + * coordinates. + */ - tkMacOSXEmbedHandler->getOffsetProc((Tk_Window) winPtr, - &theOffset); + winPtr = otherPtr; - x += theOffset.h; - y += theOffset.v; - } - break; - } - } + /* + * Remember to offset by the container window here, since at the + * end of this if branch, we will pop out to the container's + * parent... + */ + + x += winPtr->changes.x + winPtr->changes.border_width; + y += winPtr->changes.y + winPtr->changes.border_width; } winPtr = winPtr->parentPtr; } @@ -3830,8 +3869,8 @@ Tk_CoordsToWindow( bd = childPtr->changes.border_width; if ((tmpx >= -bd) && (tmpy >= -bd) - && (tmpx < (childPtr->changes.width + bd)) - && (tmpy < (childPtr->changes.height + bd))) { + && (tmpx < (childPtr->changes.width + bd)) + && (tmpy < (childPtr->changes.height + bd))) { nextPtr = childPtr; } } @@ -4881,7 +4920,10 @@ TkMacOSXZoomToplevel( idealSize.v = maxHeight; } - /* Do nothing if already in desired zoom state */ + /* + * Do nothing if already in desired zoom state. + */ + if (!IsWindowInStandardState(whichWindow, &idealSize, NULL) == (zoomPart == inZoomIn)) { return false; @@ -4949,8 +4991,8 @@ TkUnsupported1ObjCmd( return TCL_ERROR; } - if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option", - 0, &index) != TCL_OK) { + if (Tcl_GetIndexFromObj(interp, objv[1], subcmds, "option", 0, + &index) != TCL_OK) { return TCL_ERROR; } if (((enum SubCmds) index) == TKMWS_STYLE) { @@ -5259,8 +5301,8 @@ TkMacOSXMakeRealWindowExist( Tcl_Panic("TkMacOSXMakeRealWindowExist could not find container"); } if (tkMacOSXEmbedHandler->containerExistProc && - tkMacOSXEmbedHandler->containerExistProc((Tk_Window) winPtr) != - TCL_OK) { + tkMacOSXEmbedHandler->containerExistProc((Tk_Window) winPtr) + != TCL_OK) { Tcl_Panic("ContainerExistProc could not make container"); } return; @@ -5878,7 +5920,7 @@ TkWmStackorderToplevel( while (frontWindow != NULL) { hPtr = Tcl_FindHashEntry(&table, (char *) frontWindow); if (hPtr != NULL) { - childWinPtr = (TkWindow *) Tcl_GetHashValue(hPtr); + childWinPtr = Tcl_GetHashValue(hPtr); *window_ptr-- = childWinPtr; } frontWindow = GetNextWindow(frontWindow); @@ -6432,7 +6474,14 @@ RemapWindows( /* Repeat for all the children */ for (childPtr = winPtr->childList; childPtr != NULL; - childPtr = childPtr->nextPtr) { + childPtr = childPtr->nextPtr) { RemapWindows(childPtr, (MacDrawable *) winPtr->window); } } + +/* + * Local Variables: + * fill-column: 78 + * c-basic-offset: 4 + * End: + */ |