diff options
author | fvogel <fvogelnew1@free.fr> | 2022-04-03 10:43:56 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2022-04-03 10:43:56 (GMT) |
commit | b1f5acd445e52aadf8ad909c78535aeaab0f60fe (patch) | |
tree | 02ff54d16a18a86049984d6ae5ed1f4c30c16725 /macosx | |
parent | 4d7dd5c1d1a545bed4de7e4b6627e1302796b0f0 (diff) | |
parent | febcba8fc330403fb595f58acc3570f3d29fe1ed (diff) | |
download | tk-b1f5acd445e52aadf8ad909c78535aeaab0f60fe.zip tk-b1f5acd445e52aadf8ad909c78535aeaab0f60fe.tar.gz tk-b1f5acd445e52aadf8ad909c78535aeaab0f60fe.tar.bz2 |
merge 8.6
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/tkMacOSXImage.c | 41 | ||||
-rw-r--r-- | macosx/tkMacOSXKeyboard.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXMenu.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXMenubutton.c | 4 | ||||
-rw-r--r-- | macosx/tkMacOSXMouseEvent.c | 38 | ||||
-rw-r--r-- | macosx/tkMacOSXScrlbr.c | 3 | ||||
-rw-r--r-- | macosx/tkMacOSXWm.c | 14 | ||||
-rw-r--r-- | macosx/ttkMacOSXTheme.c | 1 |
8 files changed, 70 insertions, 39 deletions
diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 9a1ea45..fc0ffdf 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -144,25 +144,28 @@ TkMacOSXCreateCGImageWithXImage( bitsPerComponent = 1; bitsPerPixel = 1; - if (image->bitmap_bit_order != MSBFirst) { - char *srcPtr = image->data + image->xoffset; - char *endPtr = srcPtr + len; - char *destPtr = (data = (char *)ckalloc(len)); + data = (char *)ckalloc(len); + if (data) { + if (image->bitmap_bit_order != MSBFirst) { + char *srcPtr = image->data + image->xoffset; + char *endPtr = srcPtr + len; + char *destPtr = data; - while (srcPtr < endPtr) { - *destPtr++ = xBitReverseTable[(unsigned char)(*(srcPtr++))]; + while (srcPtr < endPtr) { + *destPtr++ = xBitReverseTable[(unsigned char)(*(srcPtr++))]; + } + } else { + memcpy(data, image->data + image->xoffset, len); } - } else { - data = (char *)memcpy(ckalloc(len), image->data + image->xoffset, len); - } - if (data) { provider = CGDataProviderCreateWithData(data, data, len, releaseData); - } - if (provider) { + if (!provider) { + ckfree(data); + } img = CGImageMaskCreate(image->width, image->height, bitsPerComponent, bitsPerPixel, image->bytes_per_line, provider, decode, 0); + CGDataProviderRelease(provider); } } else if ((image->format == ZPixmap) && (image->bits_per_pixel == 32)) { @@ -170,8 +173,6 @@ TkMacOSXCreateCGImageWithXImage( * Color image */ - CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); - if (image->width == 0 && image->height == 0) { /* @@ -180,19 +181,22 @@ TkMacOSXCreateCGImageWithXImage( return NULL; } + CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); bitsPerComponent = 8; bitsPerPixel = 32; bitmapInfo = kCGBitmapByteOrder32Big | alphaInfo; - data = (char *)memcpy(ckalloc(len), image->data + image->xoffset, len); + data = (char *)ckalloc(len); if (data) { + memcpy(data, image->data + image->xoffset, len); provider = CGDataProviderCreateWithData(data, data, len, releaseData); - } - if (provider) { + if (!provider) { + ckfree(data); + } img = CGImageCreate(image->width, image->height, bitsPerComponent, bitsPerPixel, image->bytes_per_line, colorspace, bitmapInfo, provider, decode, 0, kCGRenderingIntentDefault); - CFRelease(provider); + CGDataProviderRelease(provider); } if (colorspace) { CFRelease(colorspace); @@ -650,6 +654,7 @@ CreateCGImageFromDrawableRect( CGImageRef cg_image = NULL, result = NULL; if (mac_drawable->flags & TK_IS_PIXMAP) { cg_context = TkMacOSXGetCGContextForDrawable(drawable); + CGContextRetain(cg_context); } else { NSView *view = TkMacOSXGetNSViewForDrawable(mac_drawable); if (view == nil) { diff --git a/macosx/tkMacOSXKeyboard.c b/macosx/tkMacOSXKeyboard.c index 9aca9e1..fe2991e 100644 --- a/macosx/tkMacOSXKeyboard.c +++ b/macosx/tkMacOSXKeyboard.c @@ -273,9 +273,9 @@ UpdateKeymaps() for (virt = 0; virt < 128; virt++) { MacKeycode macKC; macKC.v = (keycode_v) {.virt = virt, .o_s = index, .keychar = 0}; - int modifiers = INDEX2CARBON(index), result; + int modifiers = INDEX2CARBON(index); UniChar keychar = 0; - result = KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, virt, + KeyDataToUnicode(&keychar, 1, kUCKeyActionDown, virt, modifiers, NULL); if (keychar == 0x10) { diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 09d91f0..89ca315 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -1369,7 +1369,7 @@ TkpComputeStandardMenuGeometry( { NSSize menuSize; Tk_Font tkfont, menuFont; - Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr; + Tk_FontMetrics menuMetrics, entryMetrics; int modifierCharWidth, menuModifierCharWidth; int x, y, modifierWidth, labelWidth, indicatorSpace; int windowWidth, windowHeight, accelWidth; @@ -1424,12 +1424,10 @@ TkpComputeStandardMenuGeometry( } if (mePtr->fontPtr == NULL) { tkfont = menuFont; - fmPtr = &menuMetrics; modifierCharWidth = menuModifierCharWidth; } else { tkfont = Tk_GetFontFromObj(menuPtr->tkwin, mePtr->fontPtr); Tk_GetFontMetrics(tkfont, &entryMetrics); - fmPtr = &entryMetrics; modifierCharWidth = ModifierCharWidth(tkfont); } accelWidth = modifierWidth = indicatorSpace = 0; diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 6291596..03709ce 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -375,7 +375,6 @@ DrawMenuButtonImageAndText( Tk_Window tkwin = butPtr->tkwin; Pixmap pixmap; int haveImage = 0, haveText = 0; - int imageWidth = 0, imageHeight = 0; int imageXOffset = 0, imageYOffset = 0; int textXOffset = 0, textYOffset = 0; int width = 0, height = 0; @@ -396,9 +395,6 @@ DrawMenuButtonImageAndText( haveImage = 1; } - imageWidth = width; - imageHeight = height; - haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { int x = 0, y = 0; diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 83edca3..fd9bbc1 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -4,7 +4,7 @@ * This file implements functions that decode & handle mouse events on * MacOS X. * - * Copyright 2001-2009, Apple Inc. + * Copyright (c) 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net> * * See the file "license.terms" for information on usage and redistribution of @@ -396,12 +396,15 @@ enum { target = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y); } + + grabWinPtr = winPtr->dispPtr->grabWinPtr; + /* * Ignore the event if a local grab is in effect and the Tk window is * not in the grabber's subtree. */ - grabWinPtr = winPtr->dispPtr->grabWinPtr; + if (grabWinPtr && /* There is a grab in effect ... */ !winPtr->dispPtr->grabFlags && /* and it is a local grab ... */ grabWinPtr->mainPtr == winPtr->mainPtr){ /* in the same application. */ @@ -420,6 +423,29 @@ enum { } /* + * Ignore the event if a global grab is in effect and the Tk window is + * not in the grabber's subtree. + */ + + if (grabWinPtr && /* There is a grab in effect ... */ + winPtr->dispPtr->grabFlags && /* and it is a global grab ... */ + grabWinPtr->mainPtr == winPtr->mainPtr) { /* in the same application. */ + Tk_Window w; + if (!target) { + return theEvent; + } + for (w = target; !Tk_IsTopLevel(w); w = Tk_Parent(w)) { + if (w == (Tk_Window)grabWinPtr) { + break; + } + } + if (w != (Tk_Window)grabWinPtr) { + /* Force the focus back to the grab window. */ + TkpChangeFocus(grabWinPtr, 1); + } + } + + /* * Translate the current button state into Tk's format. */ @@ -608,10 +634,10 @@ TkMacOSXButtonKeyState(void) Bool XQueryPointer( - Display *display, + TCL_UNUSED(Display *), Window w, - Window *root_return, - Window *child_return, + TCL_UNUSED(Window *), + TCL_UNUSED(Window *), int *root_x_return, int *root_y_return, int *win_x_return, @@ -768,7 +794,7 @@ GenerateButtonEvent( int dummy; TkDisplay *dispPtr; -#if UNUSED +#ifdef UNUSED /* * ButtonDown events will always occur in the front window. ButtonUp diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index b6e3298..5cb8e03 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -592,7 +592,7 @@ UpdateControlValues( MacDrawable *macWin = (MacDrawable *)Tk_WindowId(scrollPtr->tkwin); double dViewSize; HIRect contrlRect; - short width, height; + short height; NSView *view = TkMacOSXGetNSViewForDrawable(macWin); CGFloat viewHeight = [view bounds].size.height; @@ -606,7 +606,6 @@ UpdateControlValues( contrlRect = NSRectToCGRect(frame); msPtr->info.bounds = contrlRect; - width = contrlRect.size.width; height = contrlRect.size.height - scrollPtr->arrowLength; /* diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 7b06200..1bf62d9 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1122,6 +1122,13 @@ TkWmDeadWindow( * preventing zombies is to set the key window to nil. */ + + /* + * Fix bug 5692042764: + * set tkEventTarget to NULL when there is no window to send Tk events to. + */ + TkWindow *newTkEventTarget = NULL; + for (NSWindow *w in [NSApp orderedWindows]) { TkWindow *winPtr2 = TkMacOSXGetTkWindow(w); BOOL isOnScreen; @@ -1134,11 +1141,13 @@ TkWmDeadWindow( wmPtr2->hints.initial_state != WithdrawnState); if (w != deadNSWindow && isOnScreen && [w canBecomeKeyWindow]) { [w makeKeyAndOrderFront:NSApp]; - [NSApp setTkEventTarget:TkMacOSXGetTkWindow(w)]; + newTkEventTarget = TkMacOSXGetTkWindow(w); break; } } + [NSApp setTkEventTarget:newTkEventTarget]; + /* * Prevent zombies on systems with a TouchBar. */ @@ -1149,7 +1158,6 @@ TkWmDeadWindow( } [deadNSWindow close]; [deadNSWindow release]; - [NSApp _resetAutoreleasePool]; #if DEBUG_ZOMBIES > 1 fprintf(stderr, "================= Pool dump ===================\n"); @@ -4848,14 +4856,12 @@ Tk_TopCoordsToWindow( TkWindow *nextPtr; /* Coordinates of highest child found so far * that contains point. */ int x, y; /* Coordinates in winPtr. */ - Window *children; /* Children of winPtr, or NULL. */ winPtr = (TkWindow *)tkwin; x = rootX; y = rootY; while (1) { nextPtr = NULL; - children = NULL; /* * Container windows cannot have children. So if it is a container, diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 52880ef..ddaa226 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -1188,6 +1188,7 @@ static void DrawDarkFocusRing( CGPathRef path = CGPathCreateWithRoundedRect(insetBounds, 4, 4, NULL); CGContextBeginPath(context); CGContextAddPath(context, path); + CGPathRelease(path); CGContextAddRect(context, bounds); CGContextEOFillPath(context); CGContextRestoreGState(context); |