diff options
author | das <das> | 2006-04-28 06:02:57 (GMT) |
---|---|---|
committer | das <das> | 2006-04-28 06:02:57 (GMT) |
commit | a5b92093185c667fa3159a2ee58b5682290af6b1 (patch) | |
tree | 5b3992c68a12ca95ff81a211d111286d7c82c2e0 | |
parent | 29fd0ac98c568926da12b00ea63d88c6d98985f7 (diff) | |
download | tk-a5b92093185c667fa3159a2ee58b5682290af6b1.zip tk-a5b92093185c667fa3159a2ee58b5682290af6b1.tar.gz tk-a5b92093185c667fa3159a2ee58b5682290af6b1.tar.bz2 |
* macosx/tkMacOSXWm.c (TkWmMapWindow, InitialWindowBounds): fix use of
potentially stale window position in initial configure event on first
map of a window. [Bug 1476443]
(TkMacOSXWindowOffset): use modern GetWindowStructureWidths API.
* macosx/tkMacOSXInt.h:
* macosx/tkMacOSXMouseEvent.c (TkGenerateButtonEventForXPointer): new
internal function to generate button events for current pointer
directly, without requiring prior call to XQueryPointer().
* macosx/tkMacOSXMouseEvent.c (XQueryPointer): implement return of
window-local pointer position.
* macosx/tkMacOSXInt.h: use improvements above to avoid calls to
* macosx/tkMacOSXKeyEvent.c: GlobalToLocal() when the current port might
* macosx/tkMacOSXMenu.c: not be set correctly. May fix [Bug 1243318]
* macosx/tkMacOSXMenus.c:
* macosx/tkMacOSXScale.c:
* macosx/tkMacOSXScrlbr.c:
* tkAboutDlg.r: update copyright.
* macosx/tkMacOSXCarbonEvents.c: sync with HEAD
* macosx/tkMacOSXDebug.c:
* macosx/tkMacOSXDebug.h:
* macosx/tkMacOSXDraw.c:
* macosx/tkMacOSXEvent.c:
* macosx/tkMacOSXEvent.h:
* macosx/tkMacOSXFont.h:
* macosx/tkMacOSXInit.c:
* macosx/tkMacOSXInt.h:
* macosx/tkMacOSXKeyEvent.c:
* macosx/tkMacOSXMenu.c:
* macosx/tkMacOSXMenubutton.c:
* macosx/tkMacOSXMouseEvent.c:
* macosx/tkMacOSXSend.c:
* macosx/tkMacOSXTest.c:
* macosx/tkMacOSXWindowEvent.c:
* macosx/tkMacOSXWm.c:
-rw-r--r-- | ChangeLog | 42 | ||||
-rw-r--r-- | macosx/tkAboutDlg.r | 11 | ||||
-rw-r--r-- | macosx/tkMacOSXCarbonEvents.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXDebug.c | 22 | ||||
-rw-r--r-- | macosx/tkMacOSXDebug.h | 26 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXEvent.c | 12 | ||||
-rw-r--r-- | macosx/tkMacOSXEvent.h | 30 | ||||
-rw-r--r-- | macosx/tkMacOSXFont.h | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXInit.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXInt.h | 44 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 29 | ||||
-rw-r--r-- | macosx/tkMacOSXMenu.c | 13 | ||||
-rw-r--r-- | macosx/tkMacOSXMenubutton.c | 6 | ||||
-rw-r--r-- | macosx/tkMacOSXMenus.c | 12 | ||||
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 115 | ||||
-rw-r--r-- | macosx/tkMacOSXScale.c | 10 | ||||
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 9 | ||||
-rw-r--r-- | macosx/tkMacOSXSend.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXTest.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 72 |
22 files changed, 287 insertions, 206 deletions
@@ -1,3 +1,45 @@ +2006-04-28 Daniel Steffen <das@users.sourceforge.net> + + * macosx/tkMacOSXWm.c (TkWmMapWindow, InitialWindowBounds): fix use of + potentially stale window position in initial configure event on first + map of a window. [Bug 1476443] + (TkMacOSXWindowOffset): use modern GetWindowStructureWidths API. + + * macosx/tkMacOSXInt.h: + * macosx/tkMacOSXMouseEvent.c (TkGenerateButtonEventForXPointer): new + internal function to generate button events for current pointer + directly, without requiring prior call to XQueryPointer(). + + * macosx/tkMacOSXMouseEvent.c (XQueryPointer): implement return of + window-local pointer position. + + * macosx/tkMacOSXInt.h: use improvements above to avoid calls to + * macosx/tkMacOSXKeyEvent.c: GlobalToLocal() when the current port might + * macosx/tkMacOSXMenu.c: not be set correctly. May fix [Bug 1243318] + * macosx/tkMacOSXMenus.c: + * macosx/tkMacOSXScale.c: + * macosx/tkMacOSXScrlbr.c: + + * tkAboutDlg.r: update copyright. + + * macosx/tkMacOSXCarbonEvents.c: sync with HEAD + * macosx/tkMacOSXDebug.c: + * macosx/tkMacOSXDebug.h: + * macosx/tkMacOSXDraw.c: + * macosx/tkMacOSXEvent.c: + * macosx/tkMacOSXEvent.h: + * macosx/tkMacOSXFont.h: + * macosx/tkMacOSXInit.c: + * macosx/tkMacOSXInt.h: + * macosx/tkMacOSXKeyEvent.c: + * macosx/tkMacOSXMenu.c: + * macosx/tkMacOSXMenubutton.c: + * macosx/tkMacOSXMouseEvent.c: + * macosx/tkMacOSXSend.c: + * macosx/tkMacOSXTest.c: + * macosx/tkMacOSXWindowEvent.c: + * macosx/tkMacOSXWm.c: + 2006-04-25 Donal K. Fellows <donal.k.fellows@man.ac.uk> * unix/tkUnixFont.c (TkpGetFontFamilies): Fix crash caused when the diff --git a/macosx/tkAboutDlg.r b/macosx/tkAboutDlg.r index 9a0798a..d606220 100644 --- a/macosx/tkAboutDlg.r +++ b/macosx/tkAboutDlg.r @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkAboutDlg.r,v 1.3.2.3 2005/05/24 04:20:42 das Exp $ + * RCS: @(#) $Id: tkAboutDlg.r,v 1.3.2.4 2006/04/28 06:02:58 das Exp $ */ /* @@ -33,7 +33,7 @@ */ resource 'DLOG' (128, "About Box", purgeable) { - {60, 40, 300, 404}, + {60, 40, 332, 404}, movableDBoxProc, visible, noGoAway, @@ -45,10 +45,11 @@ resource 'DLOG' (128, "About Box", purgeable) { resource 'DITL' (128, "About Box", purgeable) { { - {200, 147, 220, 217}, Button {enabled, "Ok"}, - { 20, 108, 180, 344}, StaticText {disabled, + {232, 147, 252, 217}, Button {enabled, "Ok"}, + { 20, 108, 212, 344}, StaticText {disabled, "Tcl " TCL_PATCH_LEVEL " & Tk " TK_PATCH_LEVEL "\n\n" - "© 2005 Tcl Core Team." "\n\n" + "© 2002-2006 Tcl Core Team." "\n\n" + "© 2002-2006 Daniel A. Steffen." "\n\n" "Jim Ingham & Ian Reid" "\n" "© 2001-2002 Apple Computer, Inc." "\n\n" "Jim Ingham & Ray Johnson" "\n" diff --git a/macosx/tkMacOSXCarbonEvents.c b/macosx/tkMacOSXCarbonEvents.c index f6aa695..d155725 100644 --- a/macosx/tkMacOSXCarbonEvents.c +++ b/macosx/tkMacOSXCarbonEvents.c @@ -60,7 +60,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.3.2.12 2006/04/11 10:22:57 das Exp $ + * RCS: @(#) $Id: tkMacOSXCarbonEvents.c,v 1.3.2.13 2006/04/28 06:02:58 das Exp $ */ #include "tkMacOSXInt.h" @@ -165,7 +165,7 @@ CarbonEventHandlerProc ( *---------------------------------------------------------------------- */ -void +MODULE_SCOPE void TkMacOSXInitCarbonEvents ( Tcl_Interp *interp) { @@ -407,7 +407,7 @@ CarbonTimerProc ( *---------------------------------------------------------------------- */ -OSStatus +MODULE_SCOPE OSStatus TkMacOSXStartTclEventLoopCarbonTimer() { OSStatus err; @@ -451,7 +451,7 @@ TkMacOSXStartTclEventLoopCarbonTimer() *---------------------------------------------------------------------- */ -OSStatus +MODULE_SCOPE OSStatus TkMacOSXStopTclEventLoopCarbonTimer() { OSStatus err = noErr; diff --git a/macosx/tkMacOSXDebug.c b/macosx/tkMacOSXDebug.c index 37d2750..4c96326 100644 --- a/macosx/tkMacOSXDebug.c +++ b/macosx/tkMacOSXDebug.c @@ -50,7 +50,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.2.2.5 2006/01/10 05:38:20 das Exp $ + * RCS: @(#) $Id: tkMacOSXDebug.c,v 1.2.2.6 2006/04/28 06:02:59 das Exp $ */ #include "tkMacOSXInt.h" @@ -249,7 +249,7 @@ static MyEventName classicEventNames [] = { { 0, NULL } }; -char * +MODULE_SCOPE char * CarbonEventToAscii(EventRef eventRef, char * buf) { EventClass eventClass; @@ -293,7 +293,7 @@ CarbonEventToAscii(EventRef eventRef, char * buf) return iBuf; } -char * +MODULE_SCOPE char * CarbonEventKindToAscii(EventRef eventRef, char * buf ) { EventClass eventClass; @@ -329,7 +329,7 @@ CarbonEventKindToAscii(EventRef eventRef, char * buf ) return buf; } -char * +MODULE_SCOPE char * ClassicEventToAscii(EventRecord * eventPtr, char * buf ) { MyEventName * names = NULL; @@ -359,14 +359,14 @@ ClassicEventToAscii(EventRecord * eventPtr, char * buf ) } -void +MODULE_SCOPE void printPoint(char * tag, Point * p ) { fprintf(stderr,"%s %4d %4d\n", tag,p->h,p->v ); } -void +MODULE_SCOPE void printRect(char * tag, Rect * r ) { fprintf(stderr,"%s %4d %4d %4d %4d (%dx%d)\n", @@ -374,7 +374,7 @@ printRect(char * tag, Rect * r ) r->right - r->left + 1, r->bottom - r->top + 1); } -void +MODULE_SCOPE void printRegion(char * tag, RgnHandle rgn ) { Rect r; @@ -382,7 +382,7 @@ printRegion(char * tag, RgnHandle rgn ) printRect(tag,&r); } -void +MODULE_SCOPE void printWindowTitle(char * tag, WindowRef window ) { Str255 title; @@ -410,7 +410,7 @@ static MsgName msgNames [] = { { -1, NULL } }; -char * +MODULE_SCOPE char * TkMacOSXMenuMessageToAscii(int msg, char * s) { MsgName * msgNamePtr; @@ -438,7 +438,7 @@ static MsgName trackingNames [] = { { -1, NULL } }; -char * +MODULE_SCOPE char * MouseTrackingResultToAscii(MouseTrackingResult r, char * buf) { MsgName * namePtr; @@ -480,7 +480,7 @@ MouseTrackingResultToAscii(MouseTrackingResult r, char * buf) *---------------------------------------------------------------------- */ -void * +MODULE_SCOPE void * TkMacOSXGetNamedDebugSymbol(const char* module, const char* symbol) { void* addr = TkMacOSXGetNamedSymbol(module, symbol); diff --git a/macosx/tkMacOSXDebug.h b/macosx/tkMacOSXDebug.h index df3c00c..d3d0d67 100644 --- a/macosx/tkMacOSXDebug.h +++ b/macosx/tkMacOSXDebug.h @@ -50,36 +50,34 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.2.2.5 2006/01/10 05:38:20 das Exp $ + * RCS: @(#) $Id: tkMacOSXDebug.h,v 1.2.2.6 2006/04/28 06:02:59 das Exp $ */ #ifndef _TKMACDEBUG #define _TKMACDEBUG -#ifndef _TKINT -#include "tkInt.h" +#ifndef _TKMACINT +#include "tkMacOSXInt.h" #endif -#include <Carbon/Carbon.h> - /* The following define enables printing of debug messages to stderr: */ /* #define TK_MAC_DEBUG 1 */ #ifdef TK_MAC_DEBUG -char * CarbonEventToAscii(EventRef eventRef, char * buf ); -char * ClassicEventToAscii(EventRecord * eventPtr, char * buf ); +MODULE_SCOPE char * CarbonEventToAscii(EventRef eventRef, char * buf ); +MODULE_SCOPE char * ClassicEventToAscii(EventRecord * eventPtr, char * buf ); -void printRect(char * tag, Rect * r ); -void printPoint(char * tag, Point * p ); +MODULE_SCOPE void printRect(char * tag, Rect * r ); +MODULE_SCOPE void printPoint(char * tag, Point * p ); -void printRegion(char * tag, RgnHandle rgn ); -void printWindowTitle(char * tag, WindowRef window ); -char * TkMacOSXMenuMessageToAscii(int msg, char * s); +MODULE_SCOPE void printRegion(char * tag, RgnHandle rgn ); +MODULE_SCOPE void printWindowTitle(char * tag, WindowRef window ); +MODULE_SCOPE char * TkMacOSXMenuMessageToAscii(int msg, char * s); -char * MouseTrackingResultToAscii(MouseTrackingResult r, char * buf ); +MODULE_SCOPE char * MouseTrackingResultToAscii(MouseTrackingResult r, char * buf ); -void * TkMacOSXGetNamedDebugSymbol(const char* module, const char* symbol); +MODULE_SCOPE void* TkMacOSXGetNamedDebugSymbol(const char* module, const char* symbol); /* Macro to abstract common use of TkMacOSXGetNamedDebugSymbol to initialize named symbols */ #define TkMacOSXInitNamedDebugSymbol(module, ret, symbol, ...) \ diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index f63f2d8..c46f68a 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.13 2006/04/11 10:20:37 das Exp $ + * RCS: @(#) $Id: tkMacOSXDraw.c,v 1.2.2.14 2006/04/28 06:02:59 das Exp $ */ #include "tkMacOSXInt.h" @@ -52,7 +52,7 @@ static void TkMacOSXReleaseCGContext(MacDrawable *macWin, CGrafPtr destPort, CGContextRef *context); static inline double radians(double degrees) { return degrees * PI / 180.0f; } -int +MODULE_SCOPE int TkMacOSXInitCGDrawing(interp, enable, limit) Tcl_Interp *interp; int enable; diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index fb5869e..c800754 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.6 2006/04/11 10:22:57 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.c,v 1.3.2.7 2006/04/28 06:02:59 das Exp $ */ #include "tkMacOSXInt.h" @@ -33,7 +33,7 @@ *---------------------------------------------------------------------- */ -void +MODULE_SCOPE void TkMacOSXFlushWindows () { WindowRef wRef = GetWindowList(); @@ -70,7 +70,7 @@ TkMacOSXFlushWindows () *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) { switch (eventPtr->eClass) { @@ -123,7 +123,7 @@ TkMacOSXProcessEvent(TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXProcessMenuEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) { int menuContext; @@ -177,7 +177,7 @@ TkMacOSXProcessMenuEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXProcessCommandEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) { HICommand command; @@ -253,7 +253,7 @@ TkMacOSXProcessCommandEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) *---------------------------------------------------------------------- */ -OSStatus +MODULE_SCOPE OSStatus TkMacOSXReceiveAndProcessEvent() { static EventTargetRef targetRef = NULL; diff --git a/macosx/tkMacOSXEvent.h b/macosx/tkMacOSXEvent.h index 524d93e..6787f97 100644 --- a/macosx/tkMacOSXEvent.h +++ b/macosx/tkMacOSXEvent.h @@ -50,14 +50,14 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.3.2.5 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXEvent.h,v 1.3.2.6 2006/04/28 06:02:59 das Exp $ */ #ifndef _TKMACEVENT #define _TKMACEVENT -#ifndef _TK -#include "tk.h" +#ifndef _TKMACINT +#include "tkMacOSXInt.h" #endif typedef struct { @@ -76,29 +76,29 @@ typedef struct { Tcl_Interp *interp; /* Interp to handle events in */ } TkMacOSXEvent; -OSStatus TkMacOSXReceiveAndProcessEvent(); -void TkMacOSXFlushWindows(); -int TkMacOSXProcessEvent(TkMacOSXEvent *eventPtr, +MODULE_SCOPE OSStatus TkMacOSXReceiveAndProcessEvent(); +MODULE_SCOPE void TkMacOSXFlushWindows(); +MODULE_SCOPE int TkMacOSXProcessEvent(TkMacOSXEvent *eventPtr, MacEventStatus *statusPtr); -int TkMacOSXProcessMouseEvent(TkMacOSXEvent *e, +MODULE_SCOPE int TkMacOSXProcessMouseEvent(TkMacOSXEvent *e, MacEventStatus *statusPtr); -int TkMacOSXProcessWindowEvent(TkMacOSXEvent *e, +MODULE_SCOPE int TkMacOSXProcessWindowEvent(TkMacOSXEvent *e, MacEventStatus *statusPtr); -int TkMacOSXProcessKeyboardEvent(TkMacOSXEvent *e, +MODULE_SCOPE int TkMacOSXProcessKeyboardEvent(TkMacOSXEvent *e, MacEventStatus *statusPtr); -int TkMacOSXProcessApplicationEvent(TkMacOSXEvent *e, +MODULE_SCOPE int TkMacOSXProcessApplicationEvent(TkMacOSXEvent *e, MacEventStatus *statusPtr); -int TkMacOSXProcessMenuEvent(TkMacOSXEvent *e, +MODULE_SCOPE int TkMacOSXProcessMenuEvent(TkMacOSXEvent *e, MacEventStatus *statusPtr); -int TkMacOSXProcessCommandEvent(TkMacOSXEvent *e, +MODULE_SCOPE int TkMacOSXProcessCommandEvent(TkMacOSXEvent *e, MacEventStatus *statusPtr); -int TkMacOSXKeycodeToUnicode( +MODULE_SCOPE int TkMacOSXKeycodeToUnicode( UniChar * uniChars, int maxChars, EventKind eKind, UInt32 keycode, UInt32 modifiers, UInt32 * deadKeyStatePtr); -OSStatus TkMacOSXStartTclEventLoopCarbonTimer(); -OSStatus TkMacOSXStopTclEventLoopCarbonTimer(); +MODULE_SCOPE OSStatus TkMacOSXStartTclEventLoopCarbonTimer(); +MODULE_SCOPE OSStatus TkMacOSXStopTclEventLoopCarbonTimer(); #if !defined(MAC_OS_X_VERSION_10_3) || \ (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3) diff --git a/macosx/tkMacOSXFont.h b/macosx/tkMacOSXFont.h index aeba273..9709cd1 100644 --- a/macosx/tkMacOSXFont.h +++ b/macosx/tkMacOSXFont.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXFont.h,v 1.3.2.2 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXFont.h,v 1.3.2.3 2006/04/28 06:02:59 das Exp $ */ #ifndef TKMACOSXFONT_H @@ -19,13 +19,15 @@ #include "tkFont.h" -#include <Carbon/Carbon.h> +#ifndef _TKMACINT +#include "tkMacOSXInt.h" +#endif /* * Function prototypes */ -extern void TkMacOSXInitControlFontStyle(Tk_Font tkfont, +MODULE_SCOPE void TkMacOSXInitControlFontStyle(Tk_Font tkfont, ControlFontStylePtr fsPtr); #endif /*TKMACOSXFONT_H*/ diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index d790893..93ebd50 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.14 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXInit.c,v 1.3.2.15 2006/04/28 06:02:59 das Exp $ */ #include "tkMacOSXInt.h" @@ -405,7 +405,7 @@ TkpDisplayWarning(msg, title) *---------------------------------------------------------------------- */ -void +MODULE_SCOPE void TkMacOSXDefaultStartupScript(void) { CFBundleRef bundleRef; diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index d9f0ddd..87f5832 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.10 2006/04/11 07:36:40 das Exp $ + * RCS: @(#) $Id: tkMacOSXInt.h,v 1.3.2.11 2006/04/28 06:02:59 das Exp $ */ #ifndef _TKMACINT @@ -31,6 +31,11 @@ #include "tkMacOSX.h" #endif +/* for source code parity with tk HEAD */ +#ifndef MODULE_SCOPE +#define MODULE_SCOPE extern +#endif + struct TkWindowPrivate { TkWindow *winPtr; /* Ptr to tk window or NULL if Pixmap */ CGrafPtr grafPtr; @@ -93,7 +98,7 @@ typedef struct { Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc; } TkMacOSXEmbedHandler; -extern TkMacOSXEmbedHandler *gMacEmbedHandler; +MODULE_SCOPE TkMacOSXEmbedHandler *gMacEmbedHandler; /* * Defines used for TkMacOSXInvalidateWindow @@ -126,17 +131,17 @@ extern TkMacOSXEmbedHandler *gMacEmbedHandler; * Globals shared among Macintosh Tk */ -extern MenuHandle tkAppleMenu; /* Handle to the Apple Menu */ -extern MenuHandle tkFileMenu; /* Handles to menus */ -extern MenuHandle tkEditMenu; /* Handles to menus */ -extern RgnHandle tkMenuCascadeRgn; /* A region to clip with. */ -extern int tkUseMenuCascadeRgn; /* If this is 1, clipping code +MODULE_SCOPE MenuHandle tkAppleMenu; /* Handle to the Apple Menu */ +MODULE_SCOPE MenuHandle tkFileMenu; /* Handles to menus */ +MODULE_SCOPE MenuHandle tkEditMenu; /* Handles to menus */ +MODULE_SCOPE RgnHandle tkMenuCascadeRgn;/* A region to clip with. */ +MODULE_SCOPE int tkUseMenuCascadeRgn; /* If this is 1, clipping code * should intersect tkMenuCascadeRgn * before drawing occurs. * tkMenuCascadeRgn will only * be valid when the value of this * variable is 1. */ -extern int tkPictureIsOpen; /* If this is 1, we are drawing to a +MODULE_SCOPE int tkPictureIsOpen; /* If this is 1, we are drawing to a * picture The clipping should then be * done relative to the bounds of the * picture rather than the window. As @@ -147,21 +152,22 @@ extern int tkPictureIsOpen; /* If this is 1, we are drawing to a * for CopyBits should also have * top,left values of 0,0 */ -extern TkMacOSXWindowList *tkMacOSXWindowListPtr; +MODULE_SCOPE TkMacOSXWindowList *tkMacOSXWindowListPtr; /* The list of toplevels */ -extern Tcl_Encoding TkMacOSXCarbonEncoding; +MODULE_SCOPE Tcl_Encoding TkMacOSXCarbonEncoding; -extern void TkMacOSXDisplayChanged(Display *display); -extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); -extern void TkMacOSXInitCarbonEvents(Tcl_Interp *interp); -extern int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias); -extern void TkMacOSXDefaultStartupScript(void); -extern int TkMacOSXGenerateFocusEvent( Window window, int activeFlag); -extern WindowClass TkMacOSXWindowClass(TkWindow *winPtr); -extern int TkMacOSXIsWindowZoomed(TkWindow *winPtr); +MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display); +MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); +MODULE_SCOPE void TkMacOSXInitCarbonEvents(Tcl_Interp *interp); +MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias); +MODULE_SCOPE void TkMacOSXDefaultStartupScript(void); +MODULE_SCOPE int TkMacOSXGenerateFocusEvent( Window window, int activeFlag); +MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr); +MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr); +MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); -extern void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol); +MODULE_SCOPE void* TkMacOSXGetNamedSymbol(const char* module, const char* symbol); /* Macro to abstract common use of TkMacOSXGetNamedSymbol to initialize named symbols */ #define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \ static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \ diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index f45da28..020206c 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -50,7 +50,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.6.2.7 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXKeyEvent.c,v 1.6.2.8 2006/04/28 06:02:59 das Exp $ */ #include "tkMacOSXInt.h" @@ -58,8 +58,8 @@ typedef struct { WindowRef whichWindow; - Point global; - Point local; + int global_x, global_y; + int local_x, local_y; unsigned int state; unsigned char ch; UInt32 keyCode; @@ -132,7 +132,7 @@ static int KeycodeToUnicodeViaKCHRResource( *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXProcessKeyboardEvent( TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) @@ -435,19 +435,18 @@ GenerateKeyEvent( static int InitKeyData(KeyEventData * keyEventDataPtr) { - int x, y; memset (keyEventDataPtr, 0, sizeof(*keyEventDataPtr)); keyEventDataPtr->whichWindow = ActiveNonFloatingWindow(); if (keyEventDataPtr->whichWindow == NULL) { return false; } - XQueryPointer(NULL, None, NULL, NULL, &x, &y, - NULL, NULL, &keyEventDataPtr->state); - keyEventDataPtr->global.v = x; - keyEventDataPtr->global.v = y; - keyEventDataPtr->local = keyEventDataPtr->global; - GlobalToLocal(&keyEventDataPtr->local); + XQueryPointer(NULL, None, NULL, NULL, + &keyEventDataPtr->global_x, + &keyEventDataPtr->global_y, + &keyEventDataPtr->local_x, + &keyEventDataPtr->local_y, + &keyEventDataPtr->state); return true; } @@ -534,8 +533,8 @@ InitKeyEvent( eventPtr->xkey.same_screen = true; eventPtr->xkey.subwindow = None; eventPtr->xkey.time = TkpGetMS(); - eventPtr->xkey.x_root = e->global.h; - eventPtr->xkey.y_root = e->global.v; + eventPtr->xkey.x_root = e->global_x; + eventPtr->xkey.y_root = e->global_y; eventPtr->xkey.window = Tk_WindowId(tkwin); eventPtr->xkey.display = Tk_Display(tkwin); eventPtr->xkey.root = XRootWindow(Tk_Display(tkwin), 0); @@ -543,7 +542,7 @@ InitKeyEvent( eventPtr->xkey.trans_chars[0] = 0; Tk_TopCoordsToWindow( - tkwin, e->local.h, e->local.v, + tkwin, e->local_x, e->local_y, &eventPtr->xkey.x, &eventPtr->xkey.y); eventPtr->xkey.keycode = e->ch | @@ -1109,7 +1108,7 @@ KeycodeToUnicodeViaKCHRResource( *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXKeycodeToUnicode( UniChar * uniChars, int maxChars, EventKind eKind, diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index b871c4a..fb01632 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.6.2.17 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.6.2.18 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -226,11 +226,11 @@ static Tcl_Obj *useMDEFVar; * Forward declarations for procedures defined later in this file: */ -int TkMacOSXGetNewMenuID _ANSI_ARGS_((Tcl_Interp *interp, +MODULE_SCOPE int TkMacOSXGetNewMenuID _ANSI_ARGS_((Tcl_Interp *interp, TkMenu *menuInstPtr, int cascade, short *menuIDPtr)); -void TkMacOSXFreeMenuID _ANSI_ARGS_((short menuID)); +MODULE_SCOPE void TkMacOSXFreeMenuID _ANSI_ARGS_((short menuID)); static void CompleteIdlers _ANSI_ARGS_((TkMenu *menuPtr)); static void DrawMenuBarWhenIdle _ANSI_ARGS_(( @@ -1409,9 +1409,6 @@ TkpPostMenu( (char *) NULL); result = TCL_ERROR; } else { - Window dummyWin; - unsigned int state; - int dummy, mouseX, mouseY; short menuID; Window window; int oldWidth = menuPtr->totalWidth; @@ -1480,10 +1477,8 @@ TkpPostMenu( * Simulate the mouse up. */ - XQueryPointer(NULL, None, &dummyWin, &dummyWin, &mouseX, - &mouseY, &dummy, &dummy, &state); window = Tk_WindowId(menuPtr->tkwin); - TkGenerateButtonEvent(mouseX, mouseY, window, state); + TkGenerateButtonEventForXPointer(window); /* * Dispatch the command. diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 50c9591..511354f 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.2.2.7 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenubutton.c,v 1.2.2.8 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -32,8 +32,8 @@ #define TK_POPUP_OFFSET 32 /* size of popup marker */ -int TkMacOSXGetNewMenuID _ANSI_ARGS_((Tcl_Interp *interp, TkMenu *menuInstPtr, int cascade, short *menuIDPtr)); -void TkMacOSXFreeMenuID _ANSI_ARGS_((short menuID)); +MODULE_SCOPE int TkMacOSXGetNewMenuID _ANSI_ARGS_((Tcl_Interp *interp, TkMenu *menuInstPtr, int cascade, short *menuIDPtr)); +MODULE_SCOPE void TkMacOSXFreeMenuID _ANSI_ARGS_((short menuID)); typedef struct { SInt16 initialValue; diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index 69151f1..cfd8a30 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.2.2.7 2006/03/28 02:44:13 das Exp $ + * RCS: @(#) $Id: tkMacOSXMenus.c,v 1.2.2.8 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -219,7 +219,7 @@ GenerateEditEvent( int flag) { XVirtualEvent event; - Point where; + int x, y; Tk_Window tkwin; Window window; TkDisplay *dispPtr; @@ -242,12 +242,8 @@ GenerateEditEvent( event.time = TkpGetMS(); XQueryPointer(NULL, None, NULL, NULL, - &event.x_root, &event.y_root, NULL, NULL, &event.state); - where.h = event.x_root; - where.v = event.y_root; - GlobalToLocal(&where); - tkwin = Tk_TopCoordsToWindow(tkwin, where.h, where.v, - &event.x, &event.y); + &event.x_root, &event.y_root, &x, &y, &event.state); + tkwin = Tk_TopCoordsToWindow(tkwin, x, y, &event.x, &event.y); event.same_screen = true; switch (flag) { diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 9d0d735..b716a41 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -5,7 +5,7 @@ * on MacOS X. * * Copyright 2001, Apple Computer, Inc. - * Copyright (c) 2005 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright (c) 2005-2006 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. @@ -54,7 +54,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.13 2006/04/11 05:42:11 das Exp $ + * RCS: @(#) $Id: tkMacOSXMouseEvent.c,v 1.6.2.14 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -117,7 +117,7 @@ static void TkMacOSXSetEatButtonUp(int f); *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXProcessMouseEvent(TkMacOSXEvent *eventPtr, MacEventStatus * statusPtr) { Tk_Window tkwin; @@ -775,24 +775,69 @@ XQueryPointer( int* win_y_return, unsigned int* mask_return) { - if (root_x_return && root_y_return) { - Point where; - EventRef ev; + int getGlobal = (root_x_return && root_y_return); + int getLocal = (win_x_return && win_y_return); + + if (getGlobal || getLocal) { + Point where, local; OSStatus status; + int gotMouseLoc = 0; + EventRef ev = GetCurrentEvent(); - if ((ev = GetCurrentEvent())) { + if (ev && getLocal) { status = GetEventParameter(ev, - kEventParamMouseLocation, + kEventParamWindowMouseLocation, typeQDPoint, NULL, - sizeof(where), NULL, - &where); + sizeof(Point), NULL, + &local); + gotMouseLoc = (status == noErr); } - if (!ev || status != noErr) { - GetGlobalMouse(&where); + if (getGlobal || !gotMouseLoc) { + if (ev) { + status = GetEventParameter(ev, + kEventParamMouseLocation, + typeQDPoint, NULL, + sizeof(Point), NULL, + &where); + } + if (!ev || status != noErr) { + GetGlobalMouse(&where); + } + } + if (getLocal) { + WindowRef whichWin; + if (ev) { + status = GetEventParameter(ev, + kEventParamWindowRef, + typeWindowRef, NULL, + sizeof(WindowRef), NULL, + &whichWin); + } + if (!ev || status != noErr) { + FindWindow(where, &whichWin); + } + if (gotMouseLoc) { + if (whichWin) { + Rect widths; + GetWindowStructureWidths(whichWin, &widths); + local.h -= widths.left; + local.v -= widths.top; + } + } else { + local = where; + if (whichWin) { + QDGlobalToLocalPoint(GetWindowPort(whichWin), &local); + } + } + } + if (getGlobal) { + *root_x_return = where.h; + *root_y_return = where.v; + } + if (getLocal) { + *win_x_return = local.h; + *win_y_return = local.v; } - - *root_x_return = where.h; - *root_y_return = where.v; } if (mask_return) { *mask_return = TkMacOSXButtonKeyState(); @@ -803,6 +848,44 @@ XQueryPointer( /* *---------------------------------------------------------------------- * + * TkGenerateButtonEventForXPointer -- + * + * This procedure generates an X button event for the current + * pointer state as reported by XQueryPointer(). + * + * Results: + * True if event(s) are generated - false otherwise. + * + * Side effects: + * Additional events may be place on the Tk event queue. + * Grab state may also change. + * + *---------------------------------------------------------------------- + */ + +MODULE_SCOPE int +TkGenerateButtonEventForXPointer( + Window window) /* X Window containing button event. */ +{ + MouseEventData med; + int global_x, global_y, local_x, local_y; + + bzero(&med, sizeof(MouseEventData)); + XQueryPointer(NULL, None, NULL, NULL, &global_x, &global_y, + &local_x, &local_y, &med.state); + med.global.h = global_x; + med.global.v = global_y; + med.local.h = local_x; + med.local.v = local_y; + med.window = window; + med.activeNonFloating = ActiveNonFloatingWindow(); + + return GenerateButtonEvent(&med); +} + +/* + *---------------------------------------------------------------------- + * * TkGenerateButtonEvent -- * * Given a global x & y position and the button key status this @@ -859,7 +942,7 @@ TkGenerateButtonEvent( *---------------------------------------------------------------------- */ -static int +static int GenerateButtonEvent(MouseEventData * medPtr) { Tk_Window tkwin; diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index 5c32969..a94b499 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXScale.c,v 1.2.2.4 2006/03/28 02:44:14 das Exp $ + * RCS: @(#) $Id: tkMacOSXScale.c,v 1.2.2.5 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -395,12 +395,10 @@ MacScaleEventProc(clientData, eventPtr) MacScale *macScalePtr = (MacScale *) clientData; Point where; Rect bounds; - int part, x, y, dummy; - unsigned int state; + int part; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; - Window dummyWin; #ifdef TK_MAC_DEBUG fprintf(stderr,"MacScaleEventProc\n" ); @@ -438,9 +436,7 @@ MacScaleEventProc(clientData, eventPtr) * The TrackControl call will "eat" the ButtonUp event. We now * generate a ButtonUp event so Tk will unset implicit grabs etc. */ - XQueryPointer(NULL, None, &dummyWin, &dummyWin, &x, - &y, &dummy, &dummy, &state); - TkGenerateButtonEvent(x, y, Tk_WindowId(macScalePtr->info.tkwin), state); + TkGenerateButtonEventForXPointer(Tk_WindowId(macScalePtr->info.tkwin)); SetGWorld(saveWorld, saveDevice); } diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index ec7bed7..0fd3ffa 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.5.2.8 2006/03/28 02:44:14 das Exp $ + * RCS: @(#) $Id: tkMacOSXScrlbr.c,v 1.5.2.9 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -790,8 +790,7 @@ ScrollbarBindProc( if (eventPtr->type == ButtonPress) { Point where; Rect bounds; - int part, x, y, dummy; - unsigned int state; + int part; CGrafPtr saveWorld; GDHandle saveDevice; GWorldPtr destPort; @@ -876,10 +875,8 @@ ScrollbarBindProc( * The TrackControl call will "eat" the ButtonUp event. We now * generate a ButtonUp event so Tk will unset implicit grabs etc. */ - XQueryPointer(NULL, None, &window, &window, &x, - &y, &dummy, &dummy, &state); window = Tk_WindowId(scrollPtr->tkwin); - TkGenerateButtonEvent(x, y, window, state); + TkGenerateButtonEventForXPointer(window); SetGWorld(saveWorld, saveDevice); } diff --git a/macosx/tkMacOSXSend.c b/macosx/tkMacOSXSend.c index 2159619..09a5829 100644 --- a/macosx/tkMacOSXSend.c +++ b/macosx/tkMacOSXSend.c @@ -32,12 +32,12 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXSend.c,v 1.2.2.1 2006/03/28 02:44:14 das Exp $ + * RCS: @(#) $Id: tkMacOSXSend.c,v 1.2.2.2 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" -EXTERN int Tk_SendObjCmd _ANSI_ARGS_((ClientData clientData, +MODULE_SCOPE int Tk_SendObjCmd _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])); /* diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c index 02b7a61..271e895 100644 --- a/macosx/tkMacOSXTest.c +++ b/macosx/tkMacOSXTest.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXTest.c,v 1.2.2.3 2006/03/28 02:44:14 das Exp $ + * RCS: @(#) $Id: tkMacOSXTest.c,v 1.2.2.4 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -21,7 +21,7 @@ static int DebuggerCmd (ClientData dummy, Tcl_Interp *interp, int argc, CONST char **argv); -int TkplatformtestInit (Tcl_Interp *interp); +MODULE_SCOPE int TkplatformtestInit(Tcl_Interp *interp); /* *---------------------------------------------------------------------- diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index d34bcf1..1c414d3 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -54,7 +54,7 @@ * software in accordance with the terms specified in this * license. * - * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.11 2006/04/11 10:21:53 das Exp $ + * RCS: @(#) $Id: tkMacOSXWindowEvent.c,v 1.3.2.12 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -99,7 +99,7 @@ static int GenerateActivateEvents( Window window, int activeFlag); *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXProcessApplicationEvent( TkMacOSXEvent *eventPtr, MacEventStatus *statusPtr) @@ -178,7 +178,7 @@ TkMacOSXProcessApplicationEvent( *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXProcessWindowEvent( TkMacOSXEvent * eventPtr, MacEventStatus * statusPtr) @@ -450,7 +450,7 @@ GenerateActivateEvents( *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXGenerateFocusEvent( Window window, /* Root X window for event. */ int activeFlag ) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 19376f3..f9cd855 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -8,11 +8,12 @@ * * Copyright (c) 1994-1997 Sun Microsystems, Inc. * Copyright 2001, Apple Computer, Inc. + * Copyright (c) 2006 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. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.24 2006/04/22 04:12:25 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.7.2.25 2006/04/28 06:03:00 das Exp $ */ #include "tkMacOSXInt.h" @@ -309,14 +310,9 @@ TkWmMapWindow( * be mapped. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - Point where = {0, 0}; - int xOffset, yOffset; - int firstMap = false; - MacDrawable *macWin; if (wmPtr->flags & WM_NEVER_MAPPED) { wmPtr->flags &= ~WM_NEVER_MAPPED; - firstMap = true; /* * Create the underlying Mac window for this Tk window. @@ -324,18 +320,12 @@ TkWmMapWindow( if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } - macWin = (MacDrawable *) winPtr->window; /* * Generate configure event when we first map the window. */ - LocalToGlobal(&where); - TkMacOSXWindowOffset( GetWindowFromPort(TkMacOSXGetDrawablePort((Drawable) macWin)), - &xOffset, &yOffset); - where.h -= xOffset; - where.v -= yOffset; - TkGenWMConfigureEvent((Tk_Window) winPtr, - where.h, where.v, -1, -1, TK_LOCATION_CHANGED); + TkGenWMConfigureEvent((Tk_Window) winPtr, wmPtr->x, wmPtr->y, -1, -1, + TK_LOCATION_CHANGED); /* * This is the first time this window has ever been mapped. @@ -4367,11 +4357,11 @@ InitialWindowBounds( TkWindow *winPtr, /* Window to get initial bounds for. */ Rect *geometry) /* On return the initial bounds. */ { - int x, y; + WmInfo *wmPtr = winPtr->wmInfoPtr; static int defaultX = 5; static int defaultY = 45; - if (!(winPtr->wmInfoPtr->sizeHintsFlags & (USPosition | PPosition))) { + if (!(wmPtr->sizeHintsFlags & (USPosition | PPosition))) { /* * We will override the program & hopefully place the * window in a "better" location. @@ -4383,19 +4373,16 @@ InitialWindowBounds( defaultX = 5; defaultY = 45; } - x = defaultX; - y = defaultY; + wmPtr->x = defaultX; + wmPtr->y = defaultY; defaultX += 20; defaultY += 20; - } else { - x = winPtr->wmInfoPtr->x; - y = winPtr->wmInfoPtr->y; } - geometry->left = x; - geometry->top = y; - geometry->right = x + winPtr->changes.width; - geometry->bottom = y + winPtr->changes.height; + geometry->left = wmPtr->x; + geometry->top = wmPtr->y; + geometry->right = wmPtr->x + winPtr->changes.width; + geometry->bottom = wmPtr->y + winPtr->changes.height; } /* @@ -4634,7 +4621,7 @@ TkMacOSXGetXWindow( *---------------------------------------------------------------------- */ -int +MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { @@ -5453,7 +5440,7 @@ TkpIsWindowFloating(WindowRef wRef) *---------------------------------------------------------------------- */ -WindowClass +MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr) { WindowRef wRef; @@ -5495,32 +5482,11 @@ TkMacOSXWindowOffset( int *xOffset, int *yOffset) { - OSErr err = noErr; - static RgnHandle strucRgn = NULL; - static RgnHandle contRgn = NULL; - Rect strucRect, contRect; - - if (!strucRgn) { - if(!(strucRgn = NewRgn())) { - err = MemError(); - } - } - if (!contRgn) { - if(!(contRgn = NewRgn())) { - err = MemError(); - } - } - if (err == noErr) { - GetWindowRegion(wRef, kWindowStructureRgn, strucRgn); - GetWindowRegion(wRef, kWindowContentRgn, contRgn); - GetRegionBounds(strucRgn,&strucRect); - GetRegionBounds(contRgn,&contRect); - *xOffset = contRect.left - strucRect.left; - *yOffset = contRect.top - strucRect.top; - } else { - *xOffset = 0; - *yOffset = 0; - } + Rect widths; + + GetWindowStructureWidths(wRef, &widths); + *xOffset = widths.left; + *yOffset = widths.top; return; } |