diff options
-rw-r--r-- | generic/tk.decls | 10 | ||||
-rw-r--r-- | generic/tkPlatDecls.h | 16 | ||||
-rw-r--r-- | generic/tkStubInit.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXColor.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXDialog.c | 14 | ||||
-rw-r--r-- | macosx/tkMacOSXDraw.c | 39 | ||||
-rw-r--r-- | macosx/tkMacOSXImage.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXInt.h | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXMenu.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 8 | ||||
-rw-r--r-- | macosx/tkMacOSXPrivate.h | 12 | ||||
-rw-r--r-- | macosx/tkMacOSXScale.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 26 | ||||
-rw-r--r-- | macosx/tkMacOSXSubwindows.c | 105 | ||||
-rw-r--r-- | macosx/tkMacOSXWindowEvent.c | 2 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 56 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 2 |
18 files changed, 183 insertions, 135 deletions
diff --git a/generic/tk.decls b/generic/tk.decls index 8d13223..b0ad8d5 100644 --- a/generic/tk.decls +++ b/generic/tk.decls @@ -1142,10 +1142,18 @@ declare 10 aqua { declare 11 aqua { Tk_Window Tk_MacOSXGetTkWindow(void *w) } +# Replaces TkMacOSXGetDrawablePort declare 12 aqua { void *Tk_MacOSXGetCGContextForDrawable(Drawable drawable) } - +# Replaces TkMacOSXGetRootControl +declare 13 aqua { + void *Tk_MacOSXGetNSViewForDrawable(Drawable drawable) +} +# Replaces TkMacOSXDrawable +declare 14 aqua { + void *Tk_MacOSXGetNSWindowForDrawable(Drawable drawable) +} declare 16 aqua { void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width, int height, int flags) diff --git a/generic/tkPlatDecls.h b/generic/tkPlatDecls.h index 7bf3d7e..b753237 100644 --- a/generic/tkPlatDecls.h +++ b/generic/tkPlatDecls.h @@ -86,8 +86,10 @@ EXTERN int Tk_MacOSXIsAppInFront(void); EXTERN Tk_Window Tk_MacOSXGetTkWindow(void *w); /* 12 */ EXTERN void * Tk_MacOSXGetCGContextForDrawable(Drawable drawable); -/* Slot 13 is reserved */ -/* Slot 14 is reserved */ +/* 13 */ +EXTERN void * Tk_MacOSXGetNSViewForDrawable(Drawable drawable); +/* 14 */ +EXTERN void * Tk_MacOSXGetNSWindowForDrawable(Drawable drawable); /* Slot 15 is reserved */ /* 16 */ EXTERN void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, @@ -120,8 +122,8 @@ typedef struct TkPlatStubs { int (*tk_MacOSXIsAppInFront) (void); /* 10 */ Tk_Window (*tk_MacOSXGetTkWindow) (void *w); /* 11 */ void * (*tk_MacOSXGetCGContextForDrawable) (Drawable drawable); /* 12 */ - void (*reserved13)(void); - void (*reserved14)(void); + 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 */ @@ -180,8 +182,10 @@ extern const TkPlatStubs *tkPlatStubsPtr; (tkPlatStubsPtr->tk_MacOSXGetTkWindow) /* 11 */ #define Tk_MacOSXGetCGContextForDrawable \ (tkPlatStubsPtr->tk_MacOSXGetCGContextForDrawable) /* 12 */ -/* Slot 13 is reserved */ -/* Slot 14 is reserved */ +#define Tk_MacOSXGetNSViewForDrawable \ + (tkPlatStubsPtr->tk_MacOSXGetNSViewForDrawable) /* 13 */ +#define Tk_MacOSXGetNSWindowForDrawable \ + (tkPlatStubsPtr->tk_MacOSXGetNSWindowForDrawable) /* 14 */ /* Slot 15 is reserved */ #define TkGenWMConfigureEvent_ \ (tkPlatStubsPtr->tkGenWMConfigureEvent_) /* 16 */ diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index f3107b9..4a92c50 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -1015,8 +1015,8 @@ static const TkPlatStubs tkPlatStubs = { Tk_MacOSXIsAppInFront, /* 10 */ Tk_MacOSXGetTkWindow, /* 11 */ Tk_MacOSXGetCGContextForDrawable, /* 12 */ - 0, /* 13 */ - 0, /* 14 */ + Tk_MacOSXGetNSViewForDrawable, /* 13 */ + Tk_MacOSXGetNSWindowForDrawable, /* 14 */ 0, /* 15 */ TkGenWMConfigureEvent_, /* 16 */ #endif /* AQUA */ diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index fd39197..695c654 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -438,7 +438,7 @@ TkMacOSXInDarkMode(Tk_Window tkwin) NSAppearanceName name; NSView *view = nil; if (winPtr && winPtr->privatePtr) { - view = TkMacOSXDrawableView((Drawable)winPtr->privatePtr); + view = TkMacOSXGetNSViewForDrawable((Drawable)winPtr->privatePtr); } if (view) { name = [[view effectiveAppearance] name]; @@ -748,7 +748,7 @@ TkpGetColor( if (tkwin) { display = Tk_Display(tkwin); Drawable d = (Drawable)Tk_WindowId(tkwin); - view = TkMacOSXDrawableView(d); + view = TkMacOSXGetNSViewForDrawable(d); } /* diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index 026439f..dd8cf5c 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -643,6 +643,7 @@ Tk_GetOpenFileObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; + TkWindow *winPtr = clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, len, multiple = 0; @@ -814,7 +815,7 @@ Tk_GetOpenFileObjCmd( [openpanel setDirectoryURL:fileURL]; } if (haveParentOption) { - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; @@ -914,6 +915,7 @@ Tk_GetSaveFileObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; + TkWindow *winPtr = clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int confirmOverwrite = 1; @@ -1100,7 +1102,7 @@ Tk_GetSaveFileObjCmd( [savepanel setNameFieldStringValue:@""]; } if (haveParentOption) { - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; @@ -1156,6 +1158,7 @@ Tk_ChooseDirectoryObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; + TkWindow *winPtr = clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, len, mustexist = 0; @@ -1242,10 +1245,10 @@ Tk_ChooseDirectoryObjCmd( if (!directory) { directory = @"/"; } - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; if (haveParentOption) { - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->window); + parent = TkMacOSXGetNSWindowForDrawable(winPtr->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; @@ -1392,6 +1395,7 @@ Tk_MessageBoxObjCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = clientData; + TkWindow *winPtr = (TkWindow *)clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, typeIndex, iconIndex, indexDefaultOption = 0; @@ -1529,7 +1533,7 @@ Tk_MessageBoxObjCmd( callbackInfo->cmdObj = cmdObj; callbackInfo->interp = interp; callbackInfo->typeIndex = typeIndex; - parent = TkMacOSXDrawableWindow(((TkWindow *) tkwin)->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 12c10ae..5ca7dff 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -207,7 +207,7 @@ CreateNSImageFromPixmap( CGImageRef cgImage; NSImage *nsImage; NSBitmapImageRep *bitmapImageRep; - CGContextRef context = TkMacOSXCGContext(pixmap); + CGContextRef context = TkMacOSXGetCGContextForDrawable(pixmap); if (context) { cgImage = CGBitmapContextCreateImage(context); @@ -226,9 +226,10 @@ CreateNSImageFromPixmap( /* *---------------------------------------------------------------------- * - * Tk_MacOSXGetCGContextForDrawable -- + * 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. @@ -239,8 +240,8 @@ CreateNSImageFromPixmap( *---------------------------------------------------------------------- */ -void * -Tk_MacOSXGetCGContextForDrawable( +CGContextRef +TkMacOSXGetCGContextForDrawable( Drawable drawable) { MacDrawable *macDraw = (MacDrawable *)drawable; @@ -285,6 +286,24 @@ Tk_MacOSXGetCGContextForDrawable( return (macDraw ? macDraw->context : NULL); } + +void * +Tk_MacOSXGetCGContextForDrawable( + Drawable drawable) +{ + return TkMacOSXGetCGContextForDrawable(drawable); +} + +/* + * An obsolete version of the same stub. + */ + +void * +TkMacOSXGetDrawablePort( + Drawable drawable) +{ + return TkMacOSXGetCGContextForDrawable(drawable); +} /* *---------------------------------------------------------------------- @@ -1139,8 +1158,8 @@ TkScrollWindow( TkRegion damageRgn) /* Region to accumulate damage in. */ { Drawable drawable = Tk_WindowId(tkwin); - MacDrawable *macDraw = (MacDrawable *)drawable; - TKContentView *view = TkMacOSXDrawableView(macDraw); + MacDrawable *macDraw = (MacDrawable *) drawable; + TKContentView *view = (TKContentView *) TkMacOSXGetNSViewForDrawable(drawable); CGRect srcRect, dstRect; HIShapeRef dmgRgn = NULL, extraRgn = NULL; NSRect bounds, visRect, scrollSrc, scrollDst; @@ -1271,7 +1290,7 @@ TkMacOSXSetupDrawingContext( */ if (!(macDraw->flags & TK_IS_PIXMAP)) { - view = TkMacOSXDrawableView(d); + view = (TKContentView*) TkMacOSXGetNSViewForDrawable(d); if (!view) { Tcl_Panic("TkMacOSXSetupDrawingContext(): " "no NSView to draw into !"); @@ -1295,7 +1314,7 @@ TkMacOSXSetupDrawingContext( * drawing to a window and we use the current context of its ContentView. */ - dc.context = TkMacOSXCGContext(d); + dc.context = TkMacOSXGetCGContextForDrawable(d); if (dc.context) { dc.portBounds = CGContextGetClipBoundingBox(dc.context); } else { @@ -1523,7 +1542,7 @@ TkMacOSXGetClipRgn( #ifdef TK_MAC_DEBUG_DRAWING TkMacOSXDbgMsg("%s", macDraw->winPtr->pathName); - NSView *view = TkMacOSXDrawableView(macDraw); + NSView *view = TkMacOSXGetNSViewForDrawable(drawable); CGContextRef context = GET_CGCONTEXT; CGContextSaveGState(context); diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index c757bb6..7fa875f 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -538,13 +538,13 @@ CreateCGImageFromDrawableRect( CGRect image_rect = CGRectMake(x, y, width, height); - cg_context = TkMacOSXCGContext(drawable); + cg_context = TkMacOSXGetCGContextForDrawable(drawable); cg_image = CGBitmapContextCreateImage((CGContextRef) cg_context); if (cg_image) { result = CGImageCreateWithImageInRect(cg_image, image_rect); CGImageRelease(cg_image); } - } else if (TkMacOSXDrawableView(mac_drawable) != NULL) { + } else if (TkMacOSXGetNSViewForDrawable(drawable) != NULL) { /* * Convert Tk top-left to NSView bottom-left coordinates. @@ -597,7 +597,7 @@ CreateCGImageFromPixmap( Drawable pixmap) { CGImageRef img = NULL; - CGContextRef context = TkMacOSXCGContext(pixmap); + CGContextRef context = TkMacOSXGetCGContextForDrawable(pixmap); if (context) { img = CGBitmapContextCreateImage(context); @@ -767,7 +767,7 @@ XCopyArea( if (srcDraw->flags & TK_IS_PIXMAP) { img = CreateCGImageFromPixmap(src); - } else if (TkMacOSXDrawableWindow(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/tkMacOSXInt.h b/macosx/tkMacOSXInt.h index 2c2be0c..475a6d2 100644 --- a/macosx/tkMacOSXInt.h +++ b/macosx/tkMacOSXInt.h @@ -187,7 +187,8 @@ MODULE_SCOPE void TkpFreeGCCache(GC gc); #define TK_DRAW_IN_CONTEXT 1 /* - * Prototypes of internal procs not in the stubs table. + * Prototypes of internal procs that are called from generic or test + * code but are not in the stubs table. */ MODULE_SCOPE void TkMacOSXDefaultStartupScript(void); @@ -195,7 +196,6 @@ MODULE_SCOPE void TkpClipDrawableToRect(Display *display, Drawable d, int x, int y, int width, int height); MODULE_SCOPE void TkpShiftButton(NSButton *button, NSPoint delta); MODULE_SCOPE Bool TkTestLogDisplay(Drawable drawable); -MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin); /* * Include the stubbed internal platform-specific API. diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index a8f0eb0..4feb375 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -687,7 +687,7 @@ XGrabKeyboard( TkWindow *captureWinPtr = (TkWindow *) TkpGetCapture(); if (keyboardGrabWinPtr && captureWinPtr) { - NSWindow *w = TkMacOSXDrawableWindow(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 = TkMacOSXDrawableWindow(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 321b4f8..1ffb555 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -881,7 +881,7 @@ TkpPostMenu( * rather than the appearance of the root window. */ realWinPtr = (TkWindow*) realWin; - realWinView = TkMacOSXDrawableView(realWinPtr->privatePtr); + realWinView = TkMacOSXGetNSViewForDrawable(realWinPtr->window); if (realWinView != nil) { break; } diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 2153d06..6a9437c 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -111,7 +111,7 @@ enum { tkwin = TkMacOSXGetCapture(); if (tkwin) { winPtr = (TkWindow *) tkwin; - eventWindow = TkMacOSXDrawableWindow(winPtr->window); + eventWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (eventWindow) { local = [eventWindow tkConvertPointFromScreen: global]; } else { @@ -130,7 +130,7 @@ enum { tkwin = TkMacOSXGetCapture(); if (tkwin) { winPtr = (TkWindow *) tkwin; - eventWindow = TkMacOSXDrawableWindow(winPtr->window); + eventWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); } else { eventWindow = [NSApp mainWindow]; } @@ -432,7 +432,7 @@ XQueryPointer( if (getLocal) { MacDrawable *macWin = (MacDrawable *) w; - NSWindow *win = TkMacOSXDrawableWindow(w); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(w); if (win) { NSPoint local; @@ -522,7 +522,7 @@ TkGenerateButtonEvent( unsigned int state) /* Button Key state suitable for X event. */ { MacDrawable *macWin = (MacDrawable *) window; - NSWindow *win = TkMacOSXDrawableWindow(window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(window); MouseEventData med; bzero(&med, sizeof(MouseEventData)); diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 5938a00..e0fe290 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -236,13 +236,9 @@ MODULE_SCOPE OSStatus TkMacOSHIShapeUnion(HIShapeRef inShape1, * Prototypes of TkAqua internal procs. */ -#define TkMacOSXDrawableWindow(drawable) \ - (NSWindow *)TkMacOSXDrawable(drawable) -#define TkMacOSXContentView(drawable) \ - (TKContentView *)TkMacOSXGetRootControl(drawable) -#define TkMacOSXCGContext(drawable) \ - (CGContextRef)Tk_MacOSXGetCGContextForDrawable(drawable) - +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); @@ -264,7 +260,6 @@ MODULE_SCOPE void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel, CGContextRef context); -#define TkMacOSXDrawableView(macWin) (TKContentView *)TkMacOSXGetRootControl((Drawable)(macWin)) MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds); MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable); MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view, @@ -295,6 +290,7 @@ MODULE_SCOPE int TkMacOSXRegisterServiceWidgetObjCmd(ClientData clientData, MODULE_SCOPE unsigned TkMacOSXAddVirtual(unsigned int keycode); MODULE_SCOPE void TkMacOSXWinNSBounds(TkWindow *winPtr, NSView *view, NSRect *bounds); +MODULE_SCOPE Bool TkMacOSXInDarkMode(Tk_Window tkwin); MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData); MODULE_SCOPE unsigned long TkMacOSXClearPixel(void); diff --git a/macosx/tkMacOSXScale.c b/macosx/tkMacOSXScale.c index b1e918b..15286d6 100644 --- a/macosx/tkMacOSXScale.c +++ b/macosx/tkMacOSXScale.c @@ -214,7 +214,7 @@ TkpDisplayScale( */ macDraw = (MacDrawable *) Tk_WindowId(tkwin); - windowRef = TkMacOSXDrawableWindow(Tk_WindowId(tkwin)); + windowRef = TkMacOSXGetNSWindowForDrawable(Tk_WindowId(tkwin)); /* * Create Macintosh control. diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index e70867d..73ba2ca 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -174,8 +174,8 @@ static void drawMacScrollbar( MacScrollbar *msPtr, CGContextRef context) { - Drawable d = (Drawable)Tk_WindowId(scrollPtr->tkwin); - NSView *view = TkMacOSXDrawableView(d); + Drawable d = Tk_WindowId(scrollPtr->tkwin); + NSView *view = TkMacOSXGetNSViewForDrawable(d); CGPathRef path; CGPoint inner[2], outer[2], thumbOrigin; CGSize thumbSize; @@ -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 = TkMacOSXDrawableView(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 = TkMacOSXDrawableView(macWin); + NSView *view = TkMacOSXGetNSViewForDrawable(drawable); CGFloat viewHeight = [view bounds].size.height; NSRect frame; diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 05b3b01..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 = TkMacOSXDrawableWindow(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 = TkMacOSXDrawableWindow(window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(window); XEvent event; display->request++; @@ -340,9 +340,8 @@ XUnmapWindow( */ if (parentPtr && parentPtr->privatePtr->visRgn) { - TkMacOSXInvalidateViewRegion( - TkMacOSXDrawableView(parentPtr->privatePtr), - parentPtr->privatePtr->visRgn); + NSView *view = TkMacOSXGetNSViewForDrawable(parentPtr->window); + TkMacOSXInvalidateViewRegion(view, parentPtr->privatePtr->visRgn); } TkMacOSXInvalClipRgns((Tk_Window) parentPtr); TkMacOSXUpdateClipRgn(parentPtr); @@ -515,7 +514,7 @@ MoveResizeWindow( { int deltaX = 0, deltaY = 0, parentBorderwidth = 0; MacDrawable *macParent = NULL; - NSWindow *macWindow = TkMacOSXDrawableWindow((Drawable)macWin); + NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable((Drawable) macWin); /* * Find the Parent window, for an embedded window it will be its container. @@ -714,7 +713,7 @@ XConfigureWindow( */ if (value_mask & CWStackMode) { - NSView *view = TkMacOSXDrawableView(macWin); + NSView *view = TkMacOSXGetNSViewForDrawable(w); if (view) { TkMacOSXInvalClipRgns((Tk_Window) winPtr->parentPtr); @@ -1062,16 +1061,18 @@ TkMacOSXInvalidateWindow( if (macWin->flags & TK_CLIP_INVALID) { TkMacOSXUpdateClipRgn(macWin->winPtr); } - TkMacOSXInvalidateViewRegion(TkMacOSXDrawableView(macWin), - (flag == TK_WINDOW_ONLY) ? macWin->visRgn : macWin->aboveVisRgn); + TkMacOSXInvalidateViewRegion( + TkMacOSXGetNSViewForDrawable((Drawable) macWin), + (flag == TK_WINDOW_ONLY) ? macWin->visRgn : macWin->aboveVisRgn); } /* *---------------------------------------------------------------------- * - * TkMacOSXDrawable -- + * -- TkMacOSXGetNSWindowForDrawable / Tk_MacOSXGetNSWindowForDrawable * - * This function 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. @@ -1082,8 +1083,8 @@ TkMacOSXInvalidateWindow( *---------------------------------------------------------------------- */ -void * -TkMacOSXDrawable( +NSWindow * +TkMacOSXGetNSWindowForDrawable( Drawable drawable) { MacDrawable *macWin = (MacDrawable *)drawable; @@ -1102,49 +1103,38 @@ TkMacOSXDrawable( TkWindow *contWinPtr = TkpGetOtherWindow(macWin->toplevel->winPtr); if (contWinPtr) { - result = TkMacOSXDrawableWindow((Drawable)contWinPtr->privatePtr); + result = TkMacOSXGetNSWindowForDrawable(contWinPtr->window); } } return result; } - + +void * +Tk_MacOSXGetNSWindowForDrawable( + Drawable drawable) +{ + return TkMacOSXGetNSWindowForDrawable(drawable); +} + /* - *---------------------------------------------------------------------- - * - * TkMacOSXGetDrawablePort -- - * - * This function only exists because it is listed in the stubs table. - * It is useless. - * - * Results: - * NULL. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- + * The obsolete version of the same stub. */ void * -TkMacOSXGetDrawablePort( - TCL_UNUSED(Drawable)) +TkMacOSXDrawable( + Drawable drawable) { - return NULL; + return TkMacOSXGetNSWindowForDrawable(drawable); } /* *---------------------------------------------------------------------- * - * TkMacOSXDrawableView/TkMacOSXGetRootControl -- - * - * The function name TkMacOSXGetRootControl is being preserved only - * because it exists in a stubs table. Nobody knows what it means to - * get a "RootControl". The macro TkMacOSXDrawableView calls this - * function and should always be used rather than directly using the - * obscure official name of this function. + * TkMacOSXGetNSViewForDrawable / Tk_MacOSXGetNSViewForDrawable -- * - * It 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. @@ -1155,8 +1145,8 @@ TkMacOSXGetDrawablePort( *---------------------------------------------------------------------- */ -void * -TkMacOSXGetRootControl( +NSView * +TkMacOSXGetNSViewForDrawable( Drawable drawable) { void *result = NULL; @@ -1172,11 +1162,30 @@ TkMacOSXGetRootControl( 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); +} + +/* + * The obsolete version of the same stub. + */ + +void * +TkMacOSXGetRootControl( + Drawable drawable) +{ + return (void *) TkMacOSXGetNSViewForDrawable(drawable); +} + /* *---------------------------------------------------------------------- @@ -1435,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 e8c59b4..de96771 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -427,7 +427,7 @@ TkpWillDrawWidget(Tk_Window tkwin) { int result; if (tkwin) { TkWindow *winPtr = (TkWindow *)tkwin; - TKContentView *view = TkMacOSXDrawableView( + TKContentView *view = (TKContentView *)TkMacOSXGetNSViewForDrawable( (Drawable)winPtr->privatePtr); result = ([NSApp isDrawing] && view == [NSView focusView]); #if 0 diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index d7152bd..c5e5e33 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -523,7 +523,7 @@ static void SetWindowSizeLimits( TkWindow *winPtr) { - NSWindow *macWindow = TkMacOSXDrawableWindow(winPtr->window); + NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); WmInfo *wmPtr = winPtr->wmInfoPtr; int minWidth, minHeight, maxWidth, maxHeight, base; @@ -1534,7 +1534,7 @@ WmAttributesCmd( if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } - macWindow = TkMacOSXDrawableWindow(winPtr->window); + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (objc == 3) { /* wm attributes $win */ Tcl_Obj *result = Tcl_NewObj(); @@ -1800,7 +1800,7 @@ WmDeiconifyCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -2040,7 +2040,7 @@ WmGeometryCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { WmInfo *wmPtr = winPtr->wmInfoPtr; - NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); char xSign = '+', ySign = '+'; int width, height, x = wmPtr->x, y= wmPtr->y; char *argv3; @@ -2292,8 +2292,9 @@ WmIconbitmapCmd( if (!TkMacOSXHostToplevelExists(winPtr)) { TkMacOSXMakeRealWindowExist(winPtr); } - if (WmSetAttribute(winPtr, TkMacOSXDrawableWindow(winPtr->window), interp, - WMATT_TITLEPATH, objv[3]) == TCL_OK) { + if (WmSetAttribute(winPtr, + TkMacOSXGetNSWindowForDrawable(winPtr->window), interp, + WMATT_TITLEPATH, objv[3]) == TCL_OK) { if (!len) { if (wmPtr->hints.icon_pixmap != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); @@ -2725,7 +2726,7 @@ WmIconwindowCmd( if (wmPtr->icon != NULL) { TkWindow *oldIcon = (TkWindow *)wmPtr->icon; WmInfo *wmPtr3 = oldIcon->wmInfoPtr; - NSWindow *win = TkMacOSXDrawableWindow(oldIcon->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(oldIcon->window); /* * The old icon should be withdrawn. @@ -2955,7 +2956,7 @@ WmOverrideredirectCmd( { int flag; XSetWindowAttributes atts; - TKWindow *win = (TKWindow *)TkMacOSXDrawableWindow(winPtr->window); + TKWindow *win = (TKWindow *)TkMacOSXGetNSWindowForDrawable(winPtr->window); if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?boolean?"); @@ -4988,7 +4989,7 @@ TkWmRestackToplevel( wmPtr->hints.initial_state == WithdrawnState) { return; } - macWindow = TkMacOSXDrawableWindow(winPtr->window); + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (macWindow == nil) { return; } @@ -5004,7 +5005,7 @@ TkWmRestackToplevel( otherWmPtr->hints.initial_state == WithdrawnState) { return; } - otherMacWindow = TkMacOSXDrawableWindow(otherPtr->window); + otherMacWindow = TkMacOSXGetNSWindowForDrawable(otherPtr->window); if (otherMacWindow == nil) { return; } @@ -5346,7 +5347,7 @@ TkSetWMName( } NSString *title = [[NSString alloc] initWithUTF8String:titleUid]; - [TkMacOSXDrawableWindow(winPtr->window) setTitle:title]; + [TkMacOSXGetNSWindowForDrawable(winPtr->window) setTitle:title]; [title release]; } @@ -5414,10 +5415,13 @@ TkMacOSXGetXWindow( * * Tk_MacOSXGetTkWindow -- * - * Returns the TkWindow* associated with the given NSWindow*. + * 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. @@ -5458,7 +5462,7 @@ MODULE_SCOPE int TkMacOSXIsWindowZoomed( TkWindow *winPtr) { - NSWindow *macWindow = TkMacOSXDrawableWindow(winPtr->window); + NSWindow *macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); return [macWindow isZoomed]; } @@ -5840,13 +5844,14 @@ WmWinTabbingId( #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 101200) Tcl_Obj *result = NULL; NSString *idString; - NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (win) { idString = win.tabbingIdentifier; result = Tcl_NewStringObj(idString.UTF8String, [idString length]); } if (result == NULL) { - NSLog(@"Failed to read tabbing identifier; try calling update idletasks before getting/setting the tabbing identifier of the window."); + NSLog(@"Failed to read tabbing identifier; try calling update idletasks" + " before getting/setting the tabbing identifier of the window."); return TCL_OK; } Tcl_SetObjResult(interp, result); @@ -5930,7 +5935,7 @@ WmWinAppearance( #endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 const char *resultString = "unrecognized"; - NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (win) { appearance = win.appearance.name; if (appearance == nil) { @@ -6191,7 +6196,7 @@ TkpRedrawWidget(Tk_Window tkwin) { if ([NSApp isDrawing]) { return; } - w = TkMacOSXDrawableWindow(winPtr->window); + w = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (w) { TKContentView *view = [w contentView]; TkMacOSXWinBounds(winPtr, &tkBounds); @@ -6400,7 +6405,7 @@ TkpWmSetState( return; } - macWin = TkMacOSXDrawableWindow(winPtr->window); + macWin = TkMacOSXGetNSWindowForDrawable(winPtr->window); if (state == WithdrawnState) { Tk_UnmapWindow((Tk_Window) winPtr); @@ -6576,7 +6581,7 @@ TkpChangeFocus( } if (Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr)) { - NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + NSWindow *win = TkMacOSXGetNSWindowForDrawable(winPtr->window); TkWmRestackToplevel(winPtr, Above, NULL); if (force) { @@ -6631,7 +6636,8 @@ WmStackorderToplevelWrapperMap( if (Tk_IsMapped(winPtr) && Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr) && (winPtr->display == display)) { hPtr = Tcl_CreateHashEntry(table, - (char*) TkMacOSXDrawableWindow(winPtr->window), &newEntry); + (char*) TkMacOSXGetNSWindowForDrawable(winPtr->window), + &newEntry); Tcl_SetHashValue(hPtr, winPtr); } @@ -6759,7 +6765,7 @@ ApplyWindowAttributeFlagChanges( } TkMacOSXMakeRealWindowExist(winPtr); } - macWindow = TkMacOSXDrawableWindow(winPtr->window); + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); } if ((changedAttributes & kWindowCloseBoxAttribute) || initial) { [[macWindow standardWindowButton:NSWindowCloseButton] @@ -6931,7 +6937,7 @@ ApplyContainerOverrideChanges( if (!macWindow && winPtr->window != None && TkMacOSXHostToplevelExists(winPtr)) { - macWindow = TkMacOSXDrawableWindow(winPtr->window); + macWindow = TkMacOSXGetNSWindowForDrawable(winPtr->window); } styleMask = [macWindow styleMask]; @@ -7007,8 +7013,8 @@ ApplyContainerOverrideChanges( if (containerWinPtr && (containerWinPtr->window != None) && TkMacOSXHostToplevelExists(containerWinPtr)) { - NSWindow *containerMacWin = TkMacOSXDrawableWindow( - containerWinPtr->window); + NSWindow *containerMacWin = TkMacOSXGetNSWindowForDrawable( + 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 37d3631..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 = TkMacOSXDrawableWindow(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; |