diff options
-rw-r--r-- | generic/tk.decls | 11 | ||||
-rw-r--r-- | generic/tkInt.h | 5 | ||||
-rw-r--r-- | generic/tkPlatDecls.h | 37 | ||||
-rw-r--r-- | generic/tkStubInit.c | 8 | ||||
-rw-r--r-- | generic/tkWindow.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSX.h | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXDialog.c | 10 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 26 | ||||
-rw-r--r-- | macosx/tkMacOSXHLEvents.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXImage.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 16 | ||||
-rw-r--r-- | macosx/tkMacOSXMenu.c | 3 | ||||
-rw-r--r-- | macosx/tkMacOSXMenus.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 44 | ||||
-rw-r--r-- | macosx/tkMacOSXPrivate.h | 16 | ||||
-rw-r--r-- | macosx/tkMacOSXRegion.c | 18 | ||||
-rw-r--r-- | macosx/tkMacOSXScale.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 24 | ||||
-rw-r--r-- | macosx/tkMacOSXSubwindows.c | 54 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 102 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 102 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 2 | ||||
-rw-r--r-- | tests/safe.test | 2 |
23 files changed, 218 insertions, 282 deletions
diff --git a/generic/tk.decls b/generic/tk.decls index cfc0556..b0ad8d5 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -1140,16 +1140,19 @@ declare 10 aqua { int Tk_MacOSXIsAppInFront(void) } declare 11 aqua { - TkWindow* TkMacOSXGetTkWindow(NSWindow *w) + Tk_Window Tk_MacOSXGetTkWindow(void *w) } +# Replaces TkMacOSXGetDrawablePort declare 12 aqua { - struct CGContext *TkMacOSXGetCGContextForDrawable(Drawable drawable) + void *Tk_MacOSXGetCGContextForDrawable(Drawable drawable) } +# Replaces TkMacOSXGetRootControl declare 13 aqua { - NSView* TkMacOSXGetNSViewForDrawable(Drawable drawable) + void *Tk_MacOSXGetNSViewForDrawable(Drawable drawable) } +# Replaces TkMacOSXDrawable declare 14 aqua { - NSWindow* TkMacOSXGetNSWindowForDrawable(Drawable drawable) + void *Tk_MacOSXGetNSWindowForDrawable(Drawable drawable) } declare 16 aqua { void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width, diff --git a/generic/tkInt.h b/generic/tkInt.h index 2f64f99..23605cf 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -84,6 +84,11 @@ # endif #endif + +#ifndef Tcl_GetParent +# define Tcl_GetParent Tcl_GetMaster +#endif + /* * Macros used to cast between pointers and integers (e.g. when storing an int * in ClientData), on 64-bit architectures they avoid gcc warning about "cast diff --git a/generic/tkPlatDecls.h b/generic/tkPlatDecls.h index 97ecb1f..b753237 100644 --- a/generic/tkPlatDecls.h +++ b/generic/tkPlatDecls.h @@ -83,13 +83,13 @@ EXTERN void Tk_MacOSXSetupTkNotifier(void); /* 10 */ EXTERN int Tk_MacOSXIsAppInFront(void); /* 11 */ -EXTERN TkWindow* TkMacOSXGetTkWindow(NSWindow *w); +EXTERN Tk_Window Tk_MacOSXGetTkWindow(void *w); /* 12 */ -EXTERN struct CGContext * TkMacOSXGetCGContextForDrawable(Drawable drawable); +EXTERN void * Tk_MacOSXGetCGContextForDrawable(Drawable drawable); /* 13 */ -EXTERN NSView* TkMacOSXGetNSViewForDrawable(Drawable drawable); +EXTERN void * Tk_MacOSXGetNSViewForDrawable(Drawable drawable); /* 14 */ -EXTERN NSWindow* TkMacOSXGetNSWindowForDrawable(Drawable drawable); +EXTERN void * Tk_MacOSXGetNSWindowForDrawable(Drawable drawable); /* Slot 15 is reserved */ /* 16 */ EXTERN void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, @@ -120,10 +120,10 @@ typedef struct TkPlatStubs { void * (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */ void (*tk_MacOSXSetupTkNotifier) (void); /* 9 */ int (*tk_MacOSXIsAppInFront) (void); /* 10 */ - TkWindow* (*tkMacOSXGetTkWindow) (NSWindow *w); /* 11 */ - struct CGContext * (*tkMacOSXGetCGContextForDrawable) (Drawable drawable); /* 12 */ - NSView* (*tkMacOSXGetNSViewForDrawable) (Drawable drawable); /* 13 */ - NSWindow* (*tkMacOSXGetNSWindowForDrawable) (Drawable drawable); /* 14 */ + Tk_Window (*tk_MacOSXGetTkWindow) (void *w); /* 11 */ + void * (*tk_MacOSXGetCGContextForDrawable) (Drawable drawable); /* 12 */ + void * (*tk_MacOSXGetNSViewForDrawable) (Drawable drawable); /* 13 */ + void * (*tk_MacOSXGetNSWindowForDrawable) (Drawable drawable); /* 14 */ void (*reserved15)(void); void (*tkGenWMConfigureEvent_) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 16 */ #endif /* AQUA */ @@ -178,14 +178,14 @@ extern const TkPlatStubs *tkPlatStubsPtr; (tkPlatStubsPtr->tk_MacOSXSetupTkNotifier) /* 9 */ #define Tk_MacOSXIsAppInFront \ (tkPlatStubsPtr->tk_MacOSXIsAppInFront) /* 10 */ -#define TkMacOSXGetTkWindow \ - (tkPlatStubsPtr->tkMacOSXGetTkWindow) /* 11 */ -#define TkMacOSXGetCGContextForDrawable \ - (tkPlatStubsPtr->tkMacOSXGetCGContextForDrawable) /* 12 */ -#define TkMacOSXGetNSViewForDrawable \ - (tkPlatStubsPtr->tkMacOSXGetNSViewForDrawable) /* 13 */ -#define TkMacOSXGetNSWindowForDrawable \ - (tkPlatStubsPtr->tkMacOSXGetNSWindowForDrawable) /* 14 */ +#define Tk_MacOSXGetTkWindow \ + (tkPlatStubsPtr->tk_MacOSXGetTkWindow) /* 11 */ +#define Tk_MacOSXGetCGContextForDrawable \ + (tkPlatStubsPtr->tk_MacOSXGetCGContextForDrawable) /* 12 */ +#define Tk_MacOSXGetNSViewForDrawable \ + (tkPlatStubsPtr->tk_MacOSXGetNSViewForDrawable) /* 13 */ +#define Tk_MacOSXGetNSWindowForDrawable \ + (tkPlatStubsPtr->tk_MacOSXGetNSWindowForDrawable) /* 14 */ /* Slot 15 is reserved */ #define TkGenWMConfigureEvent_ \ (tkPlatStubsPtr->tkGenWMConfigureEvent_) /* 16 */ @@ -202,11 +202,6 @@ extern const TkPlatStubs *tkPlatStubsPtr; #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT -/* Those cannot be used (yet) in stub-enabled extensions on MacOS */ -#ifdef MAC_OSX_TK /* AQUA */ -#undef TkMacOSXGetTkWindow -#undef TkMacOSXGetCGContextForDrawable -#endif #undef TkGenWMConfigureEvent_ #endif /* _TKPLATDECLS */ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 9c190ef..4a92c50 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -1013,10 +1013,10 @@ static const TkPlatStubs tkPlatStubs = { TkMacOSXGetRootControl, /* 8 */ Tk_MacOSXSetupTkNotifier, /* 9 */ Tk_MacOSXIsAppInFront, /* 10 */ - TkMacOSXGetTkWindow, /* 11 */ - TkMacOSXGetCGContextForDrawable, /* 12 */ - TkMacOSXGetNSViewForDrawable, /* 13 */ - TkMacOSXGetNSWindowForDrawable, /* 14 */ + Tk_MacOSXGetTkWindow, /* 11 */ + Tk_MacOSXGetCGContextForDrawable, /* 12 */ + Tk_MacOSXGetNSViewForDrawable, /* 13 */ + Tk_MacOSXGetNSWindowForDrawable, /* 14 */ 0, /* 15 */ TkGenWMConfigureEvent_, /* 16 */ #endif /* AQUA */ diff --git a/generic/tkWindow.c b/generic/tkWindow.c index a67329c..5e5e836 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -3094,7 +3094,7 @@ Initialize( Tcl_Interp *parent = interp; while (Tcl_IsSafe(parent)) { - parent = Tcl_GetMaster(parent); + parent = Tcl_GetParent(parent); if (parent == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no controlling parent interpreter", -1)); diff --git a/macosx/tkMacOSX.h b/macosx/tkMacOSX.h index 81456f5..3ab0a34 100644 --- a/macosx/tkMacOSX.h +++ b/macosx/tkMacOSX.h @@ -26,15 +26,9 @@ typedef int (Tk_MacOSXEmbedRegisterWinProc) (long winID, Tk_Window window); typedef void* (Tk_MacOSXEmbedGetGrafPortProc) (Tk_Window window); typedef int (Tk_MacOSXEmbedMakeContainerExistProc) (Tk_Window window); -typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, TkRegion rgn); +typedef void (Tk_MacOSXEmbedGetClipProc) (Tk_Window window, void *rgn); typedef void (Tk_MacOSXEmbedGetOffsetInParentProc) (Tk_Window window, void *ulCorner); -/* - * Declare these classes so stubs use them as parameter or return types. - */ - -@class NSWindow; -@class NSView; #include "tkPlatDecls.h" #endif /* _TKMAC */ diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 3cddaea..dd8cf5c 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -815,7 +815,7 @@ Tk_GetOpenFileObjCmd( [openpanel setDirectoryURL:fileURL]; } if (haveParentOption) { - parent = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; @@ -1102,7 +1102,7 @@ Tk_GetSaveFileObjCmd( [savepanel setNameFieldStringValue:@""]; } if (haveParentOption) { - parent = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; @@ -1245,10 +1245,10 @@ Tk_ChooseDirectoryObjCmd( if (!directory) { directory = @"/"; } - parent = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; if (haveParentOption) { - parent = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; @@ -1533,7 +1533,7 @@ Tk_MessageBoxObjCmd( callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->typeIndex = typeIndex; - parent = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (haveParentOption && parent && ![parent attachedSheet]) { parentIsKey = [parent isKeyWindow]; #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 9201855..5ca7dff 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -226,9 +226,10 @@ CreateNSImageFromPixmap( /* *---------------------------------------------------------------------- * - * TkMacOSXGetCGContextForDrawable -- + * TkMacOSXGetCGContextForDrawable / Tk_MacOSXGetCGContextForDrawable -- * - * Get CGContext for given Drawable, creating one if necessary. + * Get CGContext for given Drawable, creating one if necessary. The + * Tk_ version is exported as a stub returning a void *. * * Results: * CGContext. @@ -285,15 +286,23 @@ TkMacOSXGetCGContextForDrawable( return (macDraw ? macDraw->context : NULL); } + +void * +Tk_MacOSXGetCGContextForDrawable( + Drawable drawable) +{ + return TkMacOSXGetCGContextForDrawable(drawable); +} + /* - * An obsolete stub with the same effect but returning a void*. + * An obsolete version of the same stub. */ void * TkMacOSXGetDrawablePort( Drawable drawable) { - return (void *) TkMacOSXGetCGContextForDrawable(drawable); + return TkMacOSXGetCGContextForDrawable(drawable); } /* @@ -1149,9 +1158,8 @@ TkScrollWindow( TkRegion damageRgn) /* Region to accumulate damage in. */ { Drawable drawable = Tk_WindowId(tkwin); - NSView *v = TkMacOSXGetNSViewForDrawable(drawable); MacDrawable *macDraw = (MacDrawable *) drawable; - TKContentView *view = (TKContentView *) v; + TKContentView *view = (TKContentView *) TkMacOSXGetNSViewForDrawable(drawable); CGRect srcRect, dstRect; HIShapeRef dmgRgn = NULL, extraRgn = NULL; NSRect bounds, visRect, scrollSrc, scrollDst; @@ -1282,7 +1290,7 @@ TkMacOSXSetupDrawingContext( */ if (!(macDraw->flags & TK_IS_PIXMAP)) { - view = (TKContentView *) TkMacOSXGetNSViewForDrawable(d); + view = (TKContentView*) TkMacOSXGetNSViewForDrawable(d); if (!view) { Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no NSView to draw into !"); @@ -1456,7 +1464,7 @@ end: #ifdef TK_MAC_DEBUG_DRAWING if (!canDraw && win != NULL) { - TkWindow *winPtr = TkMacOSXGetTkWindow(win); + TkWindow *winPtr = Tk_MacOSXGetTkWindow(win); if (winPtr) { fprintf(stderr, "Cannot draw in %s - postponing.\n", @@ -1534,7 +1542,7 @@ TkMacOSXGetClipRgn( #ifdef TK_MAC_DEBUG_DRAWING TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName); - NSView *view = TkMacOSXGetNSViewForDrawable((Drawable) macDraw); + NSView *view = TkMacOSXGetNSViewForDrawable(drawable); CGContextRef context = GET_CGCONTEXT; CGContextSaveGState(context); diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index 91d7b72..88036ee 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -309,7 +309,7 @@ static const char *scriptTextProc = "::tk::mac::DoScriptText"; if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type, data, actual, NULL)) { - data[actual] = '\0'; + data[actual] = '\0'; AppleEventInfo *AEInfo = ckalloc(sizeof(AppleEventInfo)); Tcl_DString *scriptTextCommand = &AEInfo->command; Tcl_DStringInit(scriptTextCommand); diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 445fc89..7fa875f 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -544,7 +544,7 @@ CreateCGImageFromDrawableRect( result = CGImageCreateWithImageInRect(cg_image, image_rect); CGImageRelease(cg_image); } - } else if (TkMacOSXGetNSViewForDrawable((Drawable) mac_drawable) != NULL) { + } else if (TkMacOSXGetNSViewForDrawable(drawable) != NULL) { /* * Convert Tk top-left to NSView bottom-left coordinates. @@ -767,7 +767,7 @@ XCopyArea( if (srcDraw->flags & TK_IS_PIXMAP) { img = CreateCGImageFromPixmap(src); - } else if (TkMacOSXGetNSWindowForDrawable((Drawable) src)) { + } else if (TkMacOSXGetNSWindowForDrawable(src)) { img = CreateCGImageFromDrawableRect(src, src_x, src_y, width, height); } else { TkMacOSXDbgMsg("Invalid source drawable - neither window nor pixmap."); diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 809fa77..4feb375 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -50,8 +50,8 @@ static NSUInteger textInputModifiers; TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, theEvent); #endif NSWindow *w = [theEvent window]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w), *grabWinPtr, *focusWinPtr; - Tk_Window tkwin = (Tk_Window) winPtr; + Tk_Window tkwin = Tk_MacOSXGetTkWindow(w); + TkWindow *winPtr = (TkWindow *)tkwin, *grabWinPtr, *focusWinPtr; NSEventType type = [theEvent type]; NSUInteger virtual = [theEvent keyCode]; NSUInteger modifiers = ([theEvent modifierFlags] & @@ -285,8 +285,8 @@ static NSUInteger textInputModifiers; int i, len, state; XEvent xEvent; NSString *str, *keystr, *lower; - TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - Tk_Window tkwin = (Tk_Window) winPtr; + Tk_Window tkwin = Tk_MacOSXGetTkWindow([self window]); + TkWindow *winPtr = (TkWindow *)tkwin; Bool sendingIMEText = NO; str = ([aString isKindOfClass: [NSAttributedString class]]) ? @@ -392,7 +392,7 @@ static NSUInteger textInputModifiers; selectedRange: (NSRange)selRange replacementRange: (NSRange)repRange { - TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow([self window]); Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; NSString *temp; NSString *str; @@ -497,7 +497,7 @@ static NSUInteger textInputModifiers; } processingCompose = NO; if (aSelector == @selector (deleteBackward:)) { - TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow([self window]); Tk_Window focusWin = (Tk_Window) winPtr->dispPtr->focusPtr; TkSendVirtualEvent(focusWin, "TkAccentBackspace", NULL); } @@ -687,7 +687,7 @@ XGrabKeyboard( TkWindow *captureWinPtr = (TkWindow *) TkpGetCapture(); if (keyboardGrabWinPtr && captureWinPtr) { - NSWindow *w = TkMacOSXGetNSWindowForDrawable((Drawable) grab_window); + NSWindow *w = TkMacOSXGetNSWindowForDrawable(grab_window); MacDrawable *macWin = (MacDrawable *) grab_window; if (w && macWin->toplevel->winPtr == (TkWindow *) captureWinPtr) { @@ -789,7 +789,7 @@ Tk_SetCaretPos( { TkWindow *winPtr = (TkWindow *) tkwin; TkCaret *caretPtr = &(winPtr->dispPtr->caret); - NSWindow *w = TkMacOSXGetNSWindowForDrawable((Drawable) Tk_WindowId(tkwin)); + NSWindow *w = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin)); /* * Register this widget as being capable of text input, so we know we diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index cafbee3..1ffb555 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -881,8 +881,7 @@ TkpPostMenu( * rather than the appearance of the root window. */ realWinPtr = (TkWindow*) realWin; - realWinView = TkMacOSXGetNSViewForDrawable( - (Drawable) realWinPtr->privatePtr); + realWinView = TkMacOSXGetNSViewForDrawable(realWinPtr->window); if (realWinView != nil) { break; } diff --git a/macosx/tkMacOSXMenus.c b/macosx/tkMacOSXMenus.c index 9b85e7a..0ca9eee 100644 --- a/macosx/tkMacOSXMenus.c +++ b/macosx/tkMacOSXMenus.c @@ -409,7 +409,7 @@ GenerateEditEvent( { XVirtualEvent event; int x, y; - TkWindow *winPtr = TkMacOSXGetTkWindow([NSApp keyWindow]); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow([NSApp keyWindow]); Tk_Window tkwin; if (!winPtr) { diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 04defa3..6a9437c 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -56,10 +56,6 @@ enum { Tk_Window tkwin; NSPoint local, global; NSInteger button = -1; -#if 0 - NSTrackingArea *trackingArea = nil; - NSInteger eventNumber, clickCount, buttonNumber; -#endif [NSEvent stopPeriodicEvents]; #ifdef TK_MAC_DEBUG_EVENTS @@ -115,7 +111,7 @@ enum { tkwin = TkMacOSXGetCapture(); if (tkwin) { winPtr = (TkWindow *) tkwin; - eventWindow = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + eventWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (eventWindow) { local = [eventWindow tkConvertPointFromScreen: global]; } else { @@ -134,7 +130,7 @@ enum { tkwin = TkMacOSXGetCapture(); if (tkwin) { winPtr = (TkWindow *) tkwin; - eventWindow = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + eventWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); } else { eventWindow = [NSApp mainWindow]; } @@ -152,8 +148,8 @@ enum { */ if (!tkwin) { - winPtr = TkMacOSXGetTkWindow(eventWindow); - tkwin = (Tk_Window) winPtr; + tkwin = Tk_MacOSXGetTkWindow(eventWindow); + winPtr = (TkWindow *)tkwin; } if (!tkwin) { @@ -314,34 +310,6 @@ enum { /* *---------------------------------------------------------------------- * - * TkMacOSXKeyModifiers -- - * - * Returns the current state of the modifier keys. - * - * Results: - * An OS Modifier state. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -EventModifiers -TkMacOSXModifierState(void) -{ - UInt32 keyModifiers; - int isFrontProcess = (GetCurrentEvent() && Tk_MacOSXIsAppInFront()); - - keyModifiers = isFrontProcess ? GetCurrentEventKeyModifiers() : - GetCurrentKeyModifiers(); - - return (EventModifiers) (keyModifiers & USHRT_MAX); -} - -/* - *---------------------------------------------------------------------- - * * TkMacOSXButtonKeyState -- * * Returns the current state of the button & modifier keys. @@ -464,7 +432,7 @@ XQueryPointer( if (getLocal) { MacDrawable *macWin = (MacDrawable *) w; - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) w); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(w); if (win) { NSPoint local; @@ -554,7 +522,7 @@ TkGenerateButtonEvent( unsigned int state) /* Button Key state suitable for X event. */ { MacDrawable *macWin = (MacDrawable *) window; - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(window); MouseEventData med; bzero(&med, sizeof(MouseEventData)); diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 6bac8df..e0fe290 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -225,10 +225,6 @@ MODULE_SCOPE HIMutableShapeRef TkMacOSXHIShapeCreateMutableWithRect( MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithShape( HIMutableShapeRef inDestShape, HIShapeRef inSrcShape); -#if 0 -MODULE_SCOPE OSStatus TkMacOSXHIShapeSetWithRect(HIMutableShapeRef inShape, - const CGRect *inRect); -#endif MODULE_SCOPE OSStatus TkMacOSHIShapeDifferenceWithRect( HIMutableShapeRef inShape, const CGRect *inRect); MODULE_SCOPE OSStatus TkMacOSHIShapeUnionWithRect(HIMutableShapeRef inShape, @@ -240,6 +236,9 @@ MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1, * Prototypes of TkAqua internal procs. */ +MODULE_SCOPE NSWindow * TkMacOSXGetNSWindowForDrawable(Drawable drawable); +MODULE_SCOPE NSView * TkMacOSXGetNSViewForDrawable(Drawable drawable); +MODULE_SCOPE CGContextRef TkMacOSXGetCGContextForDrawable(Drawable drawable); MODULE_SCOPE void * TkMacOSXGetNamedSymbol(const char *module, const char *symbol); MODULE_SCOPE void TkMacOSXDisplayChanged(Display *display); @@ -249,12 +248,8 @@ MODULE_SCOPE int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable); MODULE_SCOPE int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias); -MODULE_SCOPE int TkMacOSXGenerateFocusEvent(TkWindow *winPtr, - int activeFlag); -MODULE_SCOPE WindowClass TkMacOSXWindowClass(TkWindow *winPtr); MODULE_SCOPE int TkMacOSXIsWindowZoomed(TkWindow *winPtr); MODULE_SCOPE int TkGenerateButtonEventForXPointer(Window window); -MODULE_SCOPE EventModifiers TkMacOSXModifierState(void); MODULE_SCOPE void TkMacOSXDrawCGImage(Drawable d, GC gc, CGContextRef context, CGImageRef image, unsigned long imageForeground, unsigned long imageBackground, CGRect imageBounds, @@ -265,11 +260,6 @@ MODULE_SCOPE void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel, CGContextRef context); -MODULE_SCOPE int TkMacOSXMakeFullscreen(TkWindow *winPtr, - NSWindow *window, int fullscreen, - Tcl_Interp *interp); -MODULE_SCOPE void TkMacOSXEnterExitFullscreen(TkWindow *winPtr, - int active); MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds); MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable); MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view, diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index 00521e8..6c70a63 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -479,7 +479,7 @@ XOffsetRegion( *---------------------------------------------------------------------- * * TkMacOSXHIShapeCreateEmpty, TkMacOSXHIShapeCreateMutableWithRect, - * TkMacOSXHIShapeSetWithShape, TkMacOSXHIShapeSetWithRect, + * TkMacOSXHIShapeSetWithShape, * TkMacOSHIShapeDifferenceWithRect, TkMacOSHIShapeUnionWithRect, * TkMacOSHIShapeUnion -- * @@ -518,22 +518,6 @@ TkMacOSXHIShapeSetWithShape( return result; } -#if 0 -OSStatus -TkMacOSXHIShapeSetWithRect( - HIMutableShapeRef inShape, - const CGRect *inRect) -{ - OSStatus result; - HIShapeRef rgn = HIShapeCreateWithRect(inRect); - - result = TkMacOSXHIShapeSetWithShape(inShape, rgn); - CFRelease(rgn); - - return result; -} -#endif - OSStatus TkMacOSHIShapeDifferenceWithRect( HIMutableShapeRef inShape, diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index 8a221d5..15286d6 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -214,7 +214,7 @@ TkpDisplayScale( */ macDraw = (MacDrawable *) Tk_WindowId(tkwin); - windowRef = TkMacOSXGetNSWindowForDrawable((Drawable) Tk_WindowId(tkwin)); + windowRef = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin)); /* * Create Macintosh control. diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index f34862e..73ba2ca 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -174,7 +174,7 @@ static void drawMacScrollbar( MacScrollbar *msPtr, CGContextRef context) { - Drawable d = (Drawable)Tk_WindowId(scrollPtr->tkwin); + Drawable d = Tk_WindowId(scrollPtr->tkwin); NSView *view = TkMacOSXGetNSViewForDrawable(d); CGPathRef path; CGPoint inner[2], outer[2], thumbOrigin; @@ -250,6 +250,8 @@ TkpDisplayScrollbar( MacScrollbar *msPtr = (MacScrollbar *) scrollPtr; Tk_Window tkwin = scrollPtr->tkwin; TkWindow *winPtr = (TkWindow *) tkwin; + Pixmap pixmap = winPtr->window; + MacDrawable *macWin = (MacDrawable *) pixmap; TkMacOSXDrawingContext dc; scrollPtr->flags &= ~REDRAW_PENDING; @@ -258,12 +260,11 @@ TkpDisplayScrollbar( return; } - MacDrawable *macWin = (MacDrawable *) winPtr->window; - NSView *view = TkMacOSXGetNSViewForDrawable((Drawable) macWin); + NSView *view = TkMacOSXGetNSViewForDrawable(pixmap); if ((view == NULL) || (macWin->flags & TK_DO_NOT_DRAW) - || !TkMacOSXSetupDrawingContext((Drawable)macWin, NULL, &dc)) { + || !TkMacOSXSetupDrawingContext(winPtr->window, NULL, &dc)) { return; } @@ -287,22 +288,22 @@ TkpDisplayScrollbar( if (scrollPtr->highlightWidth != 0) { GC fgGC, bgGC; - bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, (Pixmap) macWin); + bgGC = Tk_GCForColor(scrollPtr->highlightBgColorPtr, pixmap); if (scrollPtr->flags & GOT_FOCUS) { - fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, (Pixmap) macWin); + fgGC = Tk_GCForColor(scrollPtr->highlightColorPtr, pixmap); } else { fgGC = bgGC; } TkpDrawHighlightBorder(tkwin, fgGC, bgGC, scrollPtr->highlightWidth, - (Pixmap) macWin); + pixmap); } - Tk_Draw3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder, + Tk_Draw3DRectangle(tkwin, pixmap, scrollPtr->bgBorder, scrollPtr->highlightWidth, scrollPtr->highlightWidth, Tk_Width(tkwin) - 2*scrollPtr->highlightWidth, Tk_Height(tkwin) - 2*scrollPtr->highlightWidth, scrollPtr->borderWidth, scrollPtr->relief); - Tk_Fill3DRectangle(tkwin, (Pixmap) macWin, scrollPtr->bgBorder, + Tk_Fill3DRectangle(tkwin, pixmap, scrollPtr->bgBorder, scrollPtr->inset, scrollPtr->inset, Tk_Width(tkwin) - 2*scrollPtr->inset, Tk_Height(tkwin) - 2*scrollPtr->inset, 0, TK_RELIEF_FLAT); @@ -589,12 +590,13 @@ UpdateControlValues( { MacScrollbar *msPtr = (MacScrollbar *) scrollPtr; Tk_Window tkwin = scrollPtr->tkwin; - MacDrawable *macWin = (MacDrawable *) Tk_WindowId(scrollPtr->tkwin); + Drawable drawable = Tk_WindowId(scrollPtr->tkwin); + MacDrawable *macWin = (MacDrawable *)drawable; double dViewSize; HIRect contrlRect; short width, height; - NSView *view = TkMacOSXGetNSViewForDrawable((Drawable) macWin); + NSView *view = TkMacOSXGetNSViewForDrawable(drawable); CGFloat viewHeight = [view bounds].size.height; NSRect frame; diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index a3ef7cc..375aefd 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -141,7 +141,7 @@ XMapWindow( } MacDrawable *macWin = (MacDrawable *)window; TkWindow *winPtr = macWin->winPtr; - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(window); XEvent event; /* @@ -300,7 +300,7 @@ XUnmapWindow( MacDrawable *macWin = (MacDrawable *)window; TkWindow *winPtr = macWin->winPtr; TkWindow *parentPtr = winPtr->parentPtr; - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(window); XEvent event; display->request++; @@ -340,7 +340,7 @@ XUnmapWindow( */ if (parentPtr && parentPtr->privatePtr->visRgn) { - NSView *view = TkMacOSXGetNSViewForDrawable((Drawable) parentPtr->privatePtr); + NSView *view = TkMacOSXGetNSViewForDrawable(parentPtr->window); TkMacOSXInvalidateViewRegion(view, parentPtr->privatePtr->visRgn); } TkMacOSXInvalClipRgns((Tk_Window) parentPtr); @@ -514,7 +514,7 @@ MoveResizeWindow( { int deltaX = 0, deltaY = 0, parentBorderwidth = 0; MacDrawable *macParent = NULL; - NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable((Drawable) (Drawable)macWin); + NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable((Drawable) macWin); /* * Find the Parent window, for an embedded window it will be its container. @@ -713,7 +713,7 @@ XConfigureWindow( */ if (value_mask & CWStackMode) { - NSView *view = TkMacOSXGetNSViewForDrawable((Drawable) macWin); + NSView *view = TkMacOSXGetNSViewForDrawable(w); if (view) { TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr); @@ -1069,10 +1069,10 @@ TkMacOSXInvalidateWindow( /* *---------------------------------------------------------------------- * - * -- TkMacOSXGetNSWindowForDrawable + * -- TkMacOSXGetNSWindowForDrawable / Tk_MacOSXGetNSWindowForDrawable * - * This is a stub function which returns the NSWindow for a given - * X drawable. + * Returns the NSWindow for a given X drawable. The Tk_ version is + * exported as a stub returning a void*. * * Results: * A NSWindow, or nil for off screen pixmaps. @@ -1103,14 +1103,21 @@ TkMacOSXGetNSWindowForDrawable( TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); if (contWinPtr) { - result = TkMacOSXGetNSWindowForDrawable((Drawable) (Drawable)contWinPtr->privatePtr); + result = TkMacOSXGetNSWindowForDrawable(contWinPtr->window); } } return result; } +void * +Tk_MacOSXGetNSWindowForDrawable( + Drawable drawable) +{ + return TkMacOSXGetNSWindowForDrawable(drawable); +} + /* - * An obsolete stub with the same effect, but returning a void* + * The obsolete version of the same stub. */ void * @@ -1123,10 +1130,11 @@ TkMacOSXDrawable( /* *---------------------------------------------------------------------- * - * TkMacOSXGetNSViewForDrawable -- + * TkMacOSXGetNSViewForDrawable / Tk_MacOSXGetNSViewForDrawable -- * - * Returns the TKContentView for a given X drawable in the case that the - * drawable is a window. If the drawable is a pixmap it returns nil. + * Returns the ContentView of the NSWindow for a given X drawable in the + * case that the drawable is a window. If the drawable is a pixmap it + * returns nil. The Tk_version is exported as a stub returning a void*. * * Results: * A NSView* or nil. @@ -1154,15 +1162,21 @@ TkMacOSXGetNSViewForDrawable( TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); if (contWinPtr) { - result = TkMacOSXGetRootControl((Drawable)contWinPtr->privatePtr); + result = TkMacOSXGetNSViewForDrawable(contWinPtr->window); } } return result; } +void * +Tk_MacOSXGetNSViewForDrawable( + Drawable drawable) +{ + return (void *) TkMacOSXGetNSViewForDrawable(drawable); +} + /* - * Obsolete stub which has the same effect but returns a void*. - * Preserved for backwards compatibility. + * The obsolete version of the same stub. */ void * @@ -1430,11 +1444,11 @@ UpdateOffsets( Pixmap Tk_GetPixmap( - Display *display, /* Display for new pixmap (can be null). */ - TCL_UNUSED(Drawable), /* Drawable where pixmap will be used (ignored). */ - int width, /* Dimensions of pixmap. */ + Display *display, /* Display for new pixmap (can be null). */ + TCL_UNUSED(Drawable), + int width, /* Dimensions of pixmap. */ int height, - int depth) /* Bits per pixel for pixmap. */ + int depth) /* Bits per pixel for pixmap. */ { MacDrawable *macPix; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 8378813..de96771 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -55,7 +55,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; BOOL activate = [[notification name] isEqualToString:NSWindowDidBecomeKeyNotification]; NSWindow *w = [notification object]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(w); if (winPtr && Tk_IsMapped(winPtr)) { GenerateActivateEvents(winPtr, activate); @@ -70,7 +70,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; BOOL movedOnly = [[notification name] isEqualToString:NSWindowDidMoveNotification]; NSWindow *w = [notification object]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(w); if (winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; @@ -106,7 +106,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif NSWindow *w = [notification object]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(w); if (winPtr) { winPtr->wmInfoPtr->hints.initial_state = @@ -179,10 +179,10 @@ extern NSString *NSWindowDidOrderOffScreenNotification; TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif NSWindow *w = [notification object]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); + Tk_Window tkwin = Tk_MacOSXGetTkWindow(w); - if (winPtr) { - Tk_UnmapWindow((Tk_Window) winPtr); + if (tkwin) { + Tk_UnmapWindow(tkwin); } } @@ -191,10 +191,10 @@ extern NSString *NSWindowDidOrderOffScreenNotification; #ifdef TK_MAC_DEBUG_NOTIFICATIONS TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, w); #endif - TkWindow *winPtr = TkMacOSXGetTkWindow(w); + Tk_Window tkwin = Tk_MacOSXGetTkWindow(w); - if (winPtr) { - TkGenWMDestroyEvent((Tk_Window) winPtr); + if (tkwin) { + TkGenWMDestroyEvent(tkwin); } /* @@ -202,14 +202,14 @@ extern NSString *NSWindowDidOrderOffScreenNotification; * can always return NO from -windowShouldClose: for a Tk window. */ - return (winPtr ? NO : YES); + return (tkwin ? NO : YES); } - (void) windowBecameVisible: (NSNotification *) notification { NSWindow *window = [notification object]; - TkWindow *winPtr = TkMacOSXGetTkWindow(window); - if (winPtr) { + Tk_Window tkwin = Tk_MacOSXGetTkWindow(window); + if (tkwin) { TKContentView *view = [window contentView]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 if (@available(macOS 10.14, *)) { @@ -225,7 +225,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; - (void) windowMapped: (NSNotification *) notification { NSWindow *w = [notification object]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(w); if (winPtr) { while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} @@ -249,7 +249,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; { TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); NSWindow *w = [notification object]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(w); if (winPtr) { //Tk_UnmapWindow((Tk_Window) winPtr); @@ -310,7 +310,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; */ for (NSWindow *win in [NSApp windows]) { - TkWindow *winPtr = TkMacOSXGetTkWindow(win); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(win); if (!winPtr || !winPtr->wmInfoPtr) { continue; } @@ -536,35 +536,6 @@ GenerateUpdates( /* *---------------------------------------------------------------------- * - * GenerateActivateEvents -- - * - * Given a Macintosh window activate event this function generates all the - * X Activate events needed by Tk. - * - * Results: - * True if event(s) are generated - false otherwise. - * - * Side effects: - * Additional events may be placed on the Tk event queue. - * - *---------------------------------------------------------------------- - */ - -int -GenerateActivateEvents( - TkWindow *winPtr, - int activeFlag) -{ - TkGenerateActivateEvents(winPtr, activeFlag); - if (activeFlag || ![NSApp isActive]) { - TkMacOSXGenerateFocusEvent(winPtr, activeFlag); - } - return true; -} - -/* - *---------------------------------------------------------------------- - * * TkMacOSXGenerateFocusEvent -- * * Given a Macintosh window activate event this function generates all @@ -579,7 +550,7 @@ GenerateActivateEvents( *---------------------------------------------------------------------- */ -MODULE_SCOPE int +static int TkMacOSXGenerateFocusEvent( TkWindow *winPtr, /* Root X window for event. */ int activeFlag) @@ -621,6 +592,35 @@ TkMacOSXGenerateFocusEvent( /* *---------------------------------------------------------------------- * + * GenerateActivateEvents -- + * + * Given a Macintosh window activate event this function generates all the + * X Activate events needed by Tk. + * + * Results: + * True if event(s) are generated - false otherwise. + * + * Side effects: + * Additional events may be placed on the Tk event queue. + * + *---------------------------------------------------------------------- + */ + +int +GenerateActivateEvents( + TkWindow *winPtr, + int activeFlag) +{ + TkGenerateActivateEvents(winPtr, activeFlag); + if (activeFlag || ![NSApp isActive]) { + TkMacOSXGenerateFocusEvent(winPtr, activeFlag); + } + return true; +} + +/* + *---------------------------------------------------------------------- + * * TkGenWMConfigureEvent -- * * Generate a ConfigureNotify event for Tk. Depending on the value of flag @@ -933,7 +933,7 @@ ConfigureRestrictProc( (void)rect; #ifdef TK_MAC_DEBUG_DRAWING - TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow([self window]); if (winPtr) { fprintf(stderr, "drawRect: drawing %s in %s\n", Tk_PathName(winPtr), NSStringFromRect(rect).UTF8String); @@ -966,7 +966,7 @@ ConfigureRestrictProc( { [super setFrameSize: newsize]; NSWindow *w = [self window]; - TkWindow *winPtr = TkMacOSXGetTkWindow(w); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; if (![self inLiveResize] && @@ -1038,7 +1038,7 @@ ConfigureRestrictProc( unsigned long serial; int updatesNeeded; CGRect updateBounds; - TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow([self window]); ClientData oldArg; Tk_RestrictProc *oldProc; if (!winPtr) { @@ -1109,7 +1109,7 @@ static const char *const accentNames[] = { - (void) viewDidChangeEffectiveAppearance { - Tk_Window tkwin = (Tk_Window) TkMacOSXGetTkWindow([self window]); + Tk_Window tkwin = Tk_MacOSXGetTkWindow([self window]); if (!tkwin) { return; } @@ -1178,8 +1178,8 @@ static const char *const accentNames[] = { #endif XVirtualEvent event; int x, y; - TkWindow *winPtr = TkMacOSXGetTkWindow([self window]); - Tk_Window tkwin = (Tk_Window) winPtr; + Tk_Window tkwin = Tk_MacOSXGetTkWindow([self window]); + TkWindow *winPtr = (TkWindow *)tkwin; (void)sender; if (!winPtr){ diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 4798cd8..c5e5e33 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -378,7 +378,7 @@ static void RemoveTransient(TkWindow *winPtr); - (void) tkLayoutChanged { - TkWindow *winPtr = TkMacOSXGetTkWindow(self); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(self); if (winPtr) { NSRect frameRect; @@ -407,7 +407,7 @@ static void RemoveTransient(TkWindow *winPtr); #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101200) - (void)toggleTabBar:(id)sender { - TkWindow *winPtr = TkMacOSXGetTkWindow(self); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(self); if (!winPtr) { return; } @@ -420,7 +420,7 @@ static void RemoveTransient(TkWindow *winPtr); toSize:(NSSize)frameSize { NSRect currentFrame = [sender frame]; - TkWindow *winPtr = TkMacOSXGetTkWindow(sender); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(sender); if (winPtr) { if (winPtr->wmInfoPtr->flags & WM_WIDTH_NOT_RESIZABLE) { frameSize.width = currentFrame.size.width; @@ -434,7 +434,7 @@ static void RemoveTransient(TkWindow *winPtr); - (BOOL) canBecomeKeyWindow { - TkWindow *winPtr = TkMacOSXGetTkWindow(self); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(self); if (!winPtr || !winPtr->wmInfoPtr) { return NO; @@ -523,8 +523,7 @@ static void SetWindowSizeLimits( TkWindow *winPtr) { - NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable( - (Drawable) winPtr->window); + NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); WmInfo *wmPtr = winPtr->wmInfoPtr; int minWidth, minHeight, maxWidth, maxHeight, base; @@ -619,7 +618,7 @@ FrontWindowAtPoint( TkWindow *winPtr = NULL; for (NSWindow *w in windows) { - winPtr = TkMacOSXGetTkWindow(w); + winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(w); if (winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect windowFrame = [w frame]; @@ -1003,7 +1002,7 @@ TkWmDeadWindow( */ for (NSWindow *w in [NSApp orderedWindows]) { - TkWindow *winPtr2 = TkMacOSXGetTkWindow(w); + TkWindow *winPtr2 = (TkWindow *)Tk_MacOSXGetTkWindow(w); BOOL isOnScreen; if (!winPtr2 || !winPtr2->wmInfoPtr) { @@ -1535,7 +1534,7 @@ WmAttributesCmd( if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } - macWindow = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (objc == 3) { /* wm attributes $win */ Tcl_Obj *result = Tcl_NewObj(); @@ -1801,7 +1800,7 @@ WmDeiconifyCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -2041,7 +2040,7 @@ WmGeometryCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); char xSign = '+', ySign = '+'; int width, height, x = wmPtr->x, y= wmPtr->y; char *argv3; @@ -2294,7 +2293,7 @@ WmIconbitmapCmd( TkMacOSXMakeRealWindowExist(winPtr); } if (WmSetAttribute(winPtr, - TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window), interp, + TkMacOSXGetNSWindowForDrawable(winPtr->window), interp, WMATT_TITLEPATH, objv[3]) == TCL_OK) { if (!len) { if (wmPtr->hints.icon_pixmap != None) { @@ -2727,8 +2726,7 @@ WmIconwindowCmd( if (wmPtr->icon != NULL) { TkWindow *oldIcon = (TkWindow *)wmPtr->icon; WmInfo *wmPtr3 = oldIcon->wmInfoPtr; - NSWindow *win = TkMacOSXGetNSWindowForDrawable( - (Drawable) oldIcon->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(oldIcon->window); /* * The old icon should be withdrawn. @@ -2958,8 +2956,7 @@ WmOverrideredirectCmd( { int flag; XSetWindowAttributes atts; - TKWindow *win = (TKWindow *)TkMacOSXGetNSWindowForDrawable( - (Drawable) winPtr->window); + TKWindow *win = (TKWindow *)TkMacOSXGetNSWindowForDrawable(winPtr->window); if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); @@ -4992,7 +4989,7 @@ TkWmRestackToplevel( wmPtr->hints.initial_state == WithdrawnState) { return; } - macWindow = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (macWindow == nil) { return; } @@ -5008,8 +5005,7 @@ TkWmRestackToplevel( otherWmPtr->hints.initial_state == WithdrawnState) { return; } - otherMacWindow = TkMacOSXGetNSWindowForDrawable( - (Drawable) otherPtr->window); + otherMacWindow = TkMacOSXGetNSWindowForDrawable(otherPtr->window); if (otherMacWindow == nil) { return; } @@ -5351,7 +5347,7 @@ TkSetWMName( } NSString *title = [[NSString alloc] initWithUTF8String:titleUid]; - [TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window) setTitle:title]; + [TkMacOSXGetNSWindowForDrawable(winPtr->window) setTitle:title]; [title release]; } @@ -5417,13 +5413,15 @@ TkMacOSXGetXWindow( /* *---------------------------------------------------------------------- * - * TkMacOSXGetTkWindow -- + * Tk_MacOSXGetTkWindow -- * - * Returns the TkWindow* associated with the given NSWindow*. - * This function is available as a stub. + * Returns the Tk_Window associated with the given NSWindow*. This + * function is a stub, so the NSWindow* parameter must be declared as + * void*. * * Results: - * The TkWindow* returned. NULL is returned if not a Tk window. + * A Tk_Window, or NULL if the NSWindow is not associated with + * any Tk window. * * Side effects: * None. @@ -5431,15 +5429,15 @@ TkMacOSXGetXWindow( *---------------------------------------------------------------------- */ -TkWindow * -TkMacOSXGetTkWindow( - NSWindow *w) +Tk_Window +Tk_MacOSXGetTkWindow( + void *w) { Window window = TkMacOSXGetXWindow((NSWindow *)w); TkDisplay *dispPtr = TkGetDisplayList(); return (window != None ? - (TkWindow *)Tk_IdToWindow(dispPtr->display, window) : NULL); + Tk_IdToWindow(dispPtr->display, window) : NULL); } /* @@ -5464,8 +5462,7 @@ MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { - NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable( - (Drawable) winPtr->window); + NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); return [macWindow isZoomed]; } @@ -5494,7 +5491,7 @@ TkMacOSXZoomToplevel( short zoomPart) /* Either inZoomIn or inZoomOut */ { NSWindow *window = whichWindow; - TkWindow *winPtr = TkMacOSXGetTkWindow(window); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(window); WmInfo *wmPtr; if (!winPtr || !winPtr->wmInfoPtr) { @@ -5847,7 +5844,7 @@ WmWinTabbingId( #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101200) Tcl_Obj *result = NULL; NSString *idString; - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (win) { idString = win.tabbingIdentifier; result = Tcl_NewStringObj(idString.UTF8String, [idString length]); @@ -5938,7 +5935,7 @@ WmWinAppearance( #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 const char *resultString = "unrecognized"; - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (win) { appearance = win.appearance.name; if (appearance == nil) { @@ -6199,7 +6196,7 @@ TkpRedrawWidget(Tk_Window tkwin) { if ([NSApp isDrawing]) { return; } - w = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + w = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (w) { TKContentView *view = [w contentView]; TkMacOSXWinBounds(winPtr, &tkBounds); @@ -6408,7 +6405,7 @@ TkpWmSetState( return; } - macWin = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + macWin = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (state == WithdrawnState) { Tk_UnmapWindow((Tk_Window) winPtr); @@ -6461,29 +6458,6 @@ TkpIsWindowFloating( } /* - *---------------------------------------------------------------------- - * - * TkMacOSXWindowClass -- - * - * Returns OS X window class of window - * - * Results: - * 1 or 0 depending on window's floating attribute. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -MODULE_SCOPE WindowClass -TkMacOSXWindowClass( - TkWindow *winPtr) -{ - return winPtr->wmInfoPtr->macClass; -} - -/* *-------------------------------------------------------------- * * TkMacOSXWindowOffset -- @@ -6507,7 +6481,7 @@ TkMacOSXWindowOffset( int *xOffset, int *yOffset) { - TkWindow *winPtr = TkMacOSXGetTkWindow(wRef); + TkWindow *winPtr = (TkWindow *)Tk_MacOSXGetTkWindow(wRef); if (winPtr && winPtr->wmInfoPtr) { *xOffset = winPtr->wmInfoPtr->xInParent; @@ -6607,7 +6581,7 @@ TkpChangeFocus( } if (Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr)) { - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); TkWmRestackToplevel(winPtr, Above, NULL); if (force) { @@ -6662,7 +6636,7 @@ WmStackorderToplevelWrapperMap( if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr) && (winPtr->display == display)) { hPtr = Tcl_CreateHashEntry(table, - (char*) TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window), + (char*) TkMacOSXGetNSWindowForDrawable(winPtr->window), &newEntry); Tcl_SetHashValue(hPtr, winPtr); } @@ -6791,7 +6765,7 @@ ApplyWindowAttributeFlagChanges( } TkMacOSXMakeRealWindowExist(winPtr); } - macWindow = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); } if ((changedAttributes & kWindowCloseBoxAttribute) || initial) { [[macWindow standardWindowButton:NSWindowCloseButton] @@ -6963,7 +6937,7 @@ ApplyContainerOverrideChanges( if (!macWindow && winPtr->window != None && TkMacOSXHostToplevelExists(winPtr)) { - macWindow = TkMacOSXGetNSWindowForDrawable((Drawable) winPtr->window); + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); } styleMask = [macWindow styleMask]; @@ -7040,7 +7014,7 @@ ApplyContainerOverrideChanges( if (containerWinPtr && (containerWinPtr->window != None) && TkMacOSXHostToplevelExists(containerWinPtr)) { NSWindow *containerMacWin = TkMacOSXGetNSWindowForDrawable( - (Drawable) containerWinPtr->window); + containerWinPtr->window); /* * Try to add the transient window as a child window of the diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 10b90dd..95c72c4 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -547,7 +547,7 @@ static void DrawListHeader( * So we have to query the Apple window manager. */ - NSWindow *win = TkMacOSXGetNSWindowForDrawable((Drawable) Tk_WindowId(tkwin)); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin)); CGFloat *bgRGBA = [win isKeyWindow] ? activeBgRGBA : inactiveBgRGBA; CGFloat x = bounds.origin.x, y = bounds.origin.y; CGFloat w = bounds.size.width, h = bounds.size.height; diff --git a/tests/safe.test b/tests/safe.test index 97f6688..64cd64c 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -187,7 +187,7 @@ test safe-5.1 {loading Tk in safe interps without parent's clearance} -body { interp eval $i {load {} Tk} } -cleanup { safe::interpDelete $i -} -returnCodes error -result {not allowed} +} -returnCodes error -result {load of binary library for package Tk failed: not allowed} test safe-5.2 {multi-level Tk loading with clearance} -setup { set safeParent [safe::interpCreate] } -body { |