summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2022-09-25 06:31:15 (GMT)
committerfvogel <fvogelnew1@free.fr>2022-09-25 06:31:15 (GMT)
commitf6b940b4946a5beda52f781dc96bf04ac206b424 (patch)
tree0121586c884af9d8b341b7bdf88de18716bf8683
parentc4f43cbfd61694402d68b8b956becdfca5e13117 (diff)
parentb4cd4a1bb5b919fb2feb328ca361dfd0dc1cb1bf (diff)
downloadtk-f6b940b4946a5beda52f781dc96bf04ac206b424.zip
tk-f6b940b4946a5beda52f781dc96bf04ac206b424.tar.gz
tk-f6b940b4946a5beda52f781dc96bf04ac206b424.tar.bz2
Merge 8.6 and fix conflicts triggered by [a48b9196] (Fix [bfea11a916]: update idletasks runs timer events on Aqua). We are on our way out of platform-specific update of widgets, yay!
-rw-r--r--macosx/tkMacOSXBitmap.c4
-rw-r--r--macosx/tkMacOSXColor.c25
-rw-r--r--macosx/tkMacOSXDialog.c2
-rw-r--r--macosx/tkMacOSXFileTypes.c38
-rw-r--r--macosx/tkMacOSXFont.c8
-rw-r--r--macosx/tkMacOSXMenu.c36
-rw-r--r--macosx/tkMacOSXPrivate.h22
-rw-r--r--macosx/tkMacOSXXStubs.c18
-rw-r--r--macosx/ttkMacOSXTheme.c6
-rw-r--r--tests/constraints.tcl6
-rw-r--r--tests/textDisp.test20
11 files changed, 97 insertions, 88 deletions
diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c
index 30ed5fe..1951518 100644
--- a/macosx/tkMacOSXBitmap.c
+++ b/macosx/tkMacOSXBitmap.c
@@ -50,8 +50,8 @@ static BuiltInIcon builtInIcons[] = {
#define builtInIconSize 32
-#define OSTYPE_TO_UTI(x) (NSString *)UTTypeCreatePreferredIdentifierForTag( \
- kUTTagClassOSType, UTCreateStringForOSType(x), nil)
+#define OSTYPE_TO_UTI(x) ((NSString *)UTTypeCreatePreferredIdentifierForTag( \
+ kUTTagClassOSType, UTCreateStringForOSType(x), nil))
static Tcl_HashTable iconBitmapTable = {};
typedef struct {
diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c
index 39e443e..dde9df2 100644
--- a/macosx/tkMacOSXColor.c
+++ b/macosx/tkMacOSXColor.c
@@ -7,7 +7,7 @@
*
* Copyright (c) 1990-1994 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
- * Copyright 2001-2009, Apple Inc.
+ * Copyright (c) 2001-2009 Apple Inc.
* Copyright (c) 2006-2009 Daniel A. Steffen <das@users.sourceforge.net>
* Copyright (c) 2020 Marc Culler
*
@@ -462,6 +462,8 @@ TkMacOSXInDarkMode(Tk_Window tkwin)
}
return (name == NSAppearanceNameDarkAqua);
}
+#else
+ (void) tkwin;
#endif
return false;
}
@@ -519,16 +521,19 @@ TkSetMacColor(
NSColor*
TkMacOSXGetNSColor(
- GC gc,
+ TCL_UNUSED(GC),
unsigned long pixel) /* Pixel value to convert. */
{
- CGColorRef cgColor;
+ CGColorRef cgColor = NULL;
NSColor *nsColor = nil;
TkSetMacColor(pixel, &cgColor);
- nsColor = [NSColor colorWithColorSpace:sRGB
- components:CGColorGetComponents(cgColor)
- count:CGColorGetNumberOfComponents(cgColor)];
+ if (cgColor) {
+ nsColor = [NSColor colorWithColorSpace:sRGB
+ components:CGColorGetComponents(cgColor)
+ count:CGColorGetNumberOfComponents(cgColor)];
+ CGColorRelease(cgColor);
+ }
return nsColor;
}
@@ -552,12 +557,12 @@ TkMacOSXGetNSColor(
void
TkMacOSXSetColorInContext(
- GC gc,
+ TCL_UNUSED(GC),
unsigned long pixel,
CGContextRef context)
{
OSStatus err = noErr;
- CGColorRef cgColor = nil;
+ CGColorRef cgColor = NULL;
SystemColorDatum *entry = GetEntryFromPixel(pixel);
CGRect rect;
HIThemeBackgroundDrawInfo info = {0, kThemeStateActive, 0};
@@ -653,7 +658,7 @@ TkpGetColor(
if (hPtr != NULL) {
SystemColorDatum *entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr);
- CGColorRef c;
+ CGColorRef c = NULL;
p.pixel.colortype = entry->type;
p.pixel.value = entry->index;
@@ -674,7 +679,7 @@ TkpGetColor(
colormap = lightColormap;
}
if (@available(macOS 11.0, *)) {
- CGFloat *rgbaPtr = rgba;
+ CGFloat *rgbaPtr = rgba;
[windowAppearance performAsCurrentDrawingAppearance:^{
GetRGBA(entry, p.ulong, rgbaPtr);
}];
diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c
index 8af298b..5170545 100644
--- a/macosx/tkMacOSXDialog.c
+++ b/macosx/tkMacOSXDialog.c
@@ -48,7 +48,7 @@ static void setAllowedFileTypes(
}
#else
[panel setAllowedFileTypes:extensions];
-#endif
+#endif
}
/*
diff --git a/macosx/tkMacOSXFileTypes.c b/macosx/tkMacOSXFileTypes.c
index c89328d..66e4fbb 100644
--- a/macosx/tkMacOSXFileTypes.c
+++ b/macosx/tkMacOSXFileTypes.c
@@ -69,36 +69,46 @@ MODULE_SCOPE NSString *TkMacOSXOSTypeToUTI(OSType ostype) {
* accept an NSString which could be an encoding of an OSType, or a file extension,
* or a Uniform Type Idenfier. This function can serve as a replacement.
*/
-
MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) {
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
if (!initialized) {
initOSTypeTable();
}
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 110000
+// We don't have UTType but iconForFileType is not deprecated, so use it.
+ return [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
+#else
+// We might have UTType but iconForFileType might be deprecated.
if (@available(macOS 11.0, *)) {
+ /* Yes, we do have UTType */
UTType *uttype = [UTType typeWithIdentifier: filetype];
- if (![uttype isDeclared]) {
+ if (uttype == nil || !uttype.isDeclared) {
uttype = [UTType typeWithFilenameExtension: filetype];
}
- if (![uttype isDeclared] && [filetype length] == 4) {
+ if (uttype == nil || (!uttype.isDeclared && filetype.length == 4)) {
OSType ostype = CHARS_TO_OSTYPE(filetype.UTF8String);
NSString *UTI = TkMacOSXOSTypeToUTI(ostype);
- uttype = [UTType typeWithIdentifier:UTI];
+ if (UTI) {
+ uttype = [UTType typeWithIdentifier:UTI];
+ }
}
- if (![uttype isDeclared]) {
+ if (uttype == nil || !uttype.isDeclared) {
return nil;
}
return [[NSWorkspace sharedWorkspace] iconForContentType:uttype];
} else {
-/* Despite Apple's claims, @available does not prevent deprecation warnings. */
-# if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
- return [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
-#else
- return nil; /* Never executed. */
-#endif
- }
-#else /* @available is not available. */
+ /* No, we don't have UTType. */
+ #if MAC_OS_X_VERSION_MIN_REQUIRED < 110000
+ /* but iconForFileType is not deprecated, so we can use it. */
return [[NSWorkspace sharedWorkspace] iconForFileType:filetype];
+ #else
+ /*
+ * Cannot be reached: MIN_REQUIRED >= 110000 yet 11.0 is not available.
+ * But the compiler can't figure that out, so it will warn about an
+ * execution path with no return value unless we put a return here.
+ */
+ return nil;
+ #endif
+ }
#endif
}
diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c
index b33de0a..628782f 100644
--- a/macosx/tkMacOSXFont.c
+++ b/macosx/tkMacOSXFont.c
@@ -1189,7 +1189,7 @@ TkpDrawAngledCharsInContext(
MacDrawable *macWin = (MacDrawable *)drawable;
TkMacOSXDrawingContext drawingContext;
CGContextRef context;
- CGColorRef fg;
+ CGColorRef fg = NULL;
NSFont *nsFont;
CGAffineTransform t;
CGFloat width, height, textX = (CGFloat) x, textY = (CGFloat) y;
@@ -1207,8 +1207,10 @@ TkpDrawAngledCharsInContext(
context = drawingContext.context;
TkSetMacColor(gc->foreground, &fg);
attributes = [fontPtr->nsAttributes mutableCopy];
- [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName];
- CFRelease(fg);
+ if (fg) {
+ [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName];
+ CGColorRelease(fg);
+ }
nsFont = [attributes objectForKey:NSFontAttributeName];
[nsFont setInContext:GET_NSCONTEXT(context, NO)];
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index b690d9d..7e8b854 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -94,7 +94,7 @@ static const struct {
static int gNoTkMenus = 0; /* This is used by Tk_MacOSXTurnOffMenus as
* the flag that Tk is not to draw any
* menus. */
-static Bool inPostMenu = true;
+static Bool inPostMenu = false;
static SInt32 menuMarkColumnWidth = 0, menuIconTrailingEdgeMargin = 0;
static SInt32 menuTextLeadingEdgeMargin = 0, menuTextTrailingEdgeMargin = 0;
static SInt16 menuItemExtraHeight = 0, menuItemExtraWidth = 0;
@@ -364,20 +364,17 @@ static Bool runMenuCommand = true;
TkMenuEntry *mePtr = (TkMenuEntry *) [menuItem tag];
if (menuPtr && mePtr) {
- Tcl_Interp *interp = menuPtr->interp;
-
- Tcl_Preserve(interp);
- Tcl_Preserve(menuPtr);
-
- int result = TkInvokeMenu(interp, menuPtr, mePtr->index);
-
- if (result != TCL_OK && result != TCL_CONTINUE &&
- result != TCL_BREAK) {
- Tcl_AddErrorInfo(interp, "\n (menu invoke)");
- Tcl_BackgroundException(interp, result);
- }
- Tcl_Release(menuPtr);
- Tcl_Release(interp);
+ Tcl_Interp *interp = menuPtr->interp;
+ Tcl_Preserve(interp);
+ Tcl_Preserve(menuPtr);
+ int result = TkInvokeMenu(interp, menuPtr, mePtr->index);
+ if (result != TCL_OK && result != TCL_CONTINUE &&
+ result != TCL_BREAK) {
+ Tcl_AddErrorInfo(interp, "\n (menu invoke)");
+ Tcl_BackgroundException(interp, result);
+ }
+ Tcl_Release(menuPtr);
+ Tcl_Release(interp);
}
}
}
@@ -512,8 +509,13 @@ static Bool runMenuCommand = true;
}
backgroundLoop = [[TKBackgroundLoop alloc] init];
[backgroundLoop start];
- //TkMacOSXClearMenubarActive();
- //TkMacOSXPreprocessMenu();
+
+ /*
+ * Make sure that we can run commands when actually using a menu.
+ * See [412b80fcaf].
+ */
+
+ runMenuCommand = true;
}
- (void) menuEndTracking: (NSNotification *) notification
diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h
index bc6b49c..f51397d 100644
--- a/macosx/tkMacOSXPrivate.h
+++ b/macosx/tkMacOSXPrivate.h
@@ -124,9 +124,10 @@
* Macro abstracting use of TkMacOSXGetNamedSymbol to init named symbols.
*/
+#define UNINITIALISED_SYMBOL ((void*)(-1L))
#define TkMacOSXInitNamedSymbol(module, ret, symbol, ...) \
- static ret (* symbol)(__VA_ARGS__) = (void*)(-1L); \
- if (symbol == (void*)(-1L)) { \
+ static ret (* symbol)(__VA_ARGS__) = UNINITIALISED_SYMBOL; \
+ if (symbol == UNINITIALISED_SYMBOL) { \
symbol = TkMacOSXGetNamedSymbol(STRINGIFY(module), \
STRINGIFY(symbol)); \
}
@@ -210,12 +211,6 @@ typedef struct TkMacOSXDrawingContext {
} TkMacOSXDrawingContext;
/*
- * Variables internal to TkAqua.
- */
-
-MODULE_SCOPE long tkMacOSXMacOSXVersion;
-
-/*
* Prototypes for TkMacOSXRegion.c.
*/
@@ -261,14 +256,14 @@ MODULE_SCOPE void TkMacOSXRestoreDrawingContext(
TkMacOSXDrawingContext *dcPtr);
MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel,
CGContextRef context);
-#define TkMacOSXGetTkWindow(window) (TkWindow *)Tk_MacOSXGetTkWindow(window)
-#define TkMacOSXGetNSWindowForDrawable(drawable) ((NSWindow*)TkMacOSXDrawable(drawable))
-#define TkMacOSXGetNSViewForDrawable(macWin) (NSView *)Tk_MacOSXGetNSViewForDrawable((Drawable)(macWin))
+#define TkMacOSXGetTkWindow(window) ((TkWindow *)Tk_MacOSXGetTkWindow(window))
+#define TkMacOSXGetNSWindowForDrawable(drawable) ((NSWindow *)TkMacOSXDrawable(drawable))
+#define TkMacOSXGetNSViewForDrawable(macWin) ((NSView *)Tk_MacOSXGetNSViewForDrawable((Drawable)(macWin)))
+MODULE_SCOPE CGContextRef TkMacOSXGetCGContextForDrawable(Drawable drawable);
MODULE_SCOPE void TkMacOSXWinCGBounds(TkWindow *winPtr, CGRect *bounds);
MODULE_SCOPE HIShapeRef TkMacOSXGetClipRgn(Drawable drawable);
MODULE_SCOPE void TkMacOSXInvalidateViewRegion(NSView *view,
HIShapeRef rgn);
-MODULE_SCOPE CGContextRef TkMacOSXGetCGContextForDrawable(Drawable drawable);
MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromTkImage(Display *display,
Tk_Image image, int width, int height);
MODULE_SCOPE NSImage* TkMacOSXGetNSImageFromBitmap(Display *display,
@@ -299,7 +294,7 @@ MODULE_SCOPE void TkMacOSXDrawAllViews(ClientData clientData);
MODULE_SCOPE unsigned long TkMacOSXClearPixel(void);
MODULE_SCOPE NSString* TkMacOSXOSTypeToUTI(OSType ostype);
MODULE_SCOPE NSImage* TkMacOSXIconForFileType(NSString *filetype);
-
+
#pragma mark Private Objective-C Classes
#define VISIBILITY_HIDDEN __attribute__((visibility("hidden")))
@@ -330,7 +325,6 @@ VISIBILITY_HIDDEN
NSArray *_defaultHelpMenuItems, *_defaultFileMenuItems;
NSAutoreleasePool *_mainPool;
NSThread *_backgoundLoop;
- Bool _tkLiveResizeEnded;
#ifdef __i386__
/* The Objective C runtime used on i386 requires this. */
diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c
index aa1108e..a860bda 100644
--- a/macosx/tkMacOSXXStubs.c
+++ b/macosx/tkMacOSXXStubs.c
@@ -705,15 +705,17 @@ XSync(
/*
* The main use of XSync is by the update command, which alternates
* between running an event loop to process all events without waiting and
- * calling XSync on all displays until no events are left. There is
- * nothing for the mac to do with respect to syncing its one display but
- * it can (and, during regression testing, frequently does) happen that
- * timer events fire during the event loop. Processing those here seems
- * to make the update command work in a way that is more consistent with
- * its behavior on other platforms.
+ * calling XSync on all displays until no events are left. On X11 the
+ * call to XSync might cause the window manager to generate more events
+ * which would then get processed. Apparently this process stabilizes on
+ * X11, leaving the window manager in a state where all events have been
+ * generated and no additional events can be genereated by updating widgets.
+ *
+ * It is not clear what the Aqua port should do when XSync is called, but
+ * currently the best option seems to be to do nothing. (See ticket
+ * [da5f2266df].)
*/
- while (Tcl_DoOneEvent(TCL_TIMER_EVENTS|TCL_DONT_WAIT)){}
display->request++;
return 0;
}
@@ -726,7 +728,7 @@ XSetClipRectangles(
int clip_y_origin,
XRectangle* rectangles,
int n,
- int ordering)
+ TCL_UNUSED(int))
{
TkRegion clipRgn = TkCreateRegion();
diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c
index 38e6fa3..f2ad636 100644
--- a/macosx/ttkMacOSXTheme.c
+++ b/macosx/ttkMacOSXTheme.c
@@ -131,9 +131,9 @@ static CGFloat pressedPushButtonGradient[8] = {
*/
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080
-#define CGCOLOR(nscolor) nscolor.CGColor
+#define CGCOLOR(nscolor) (nscolor).CGColor
#else
-#define CGCOLOR(nscolor) (0 ? (CGColorRef) nscolor : NULL)
+#define CGCOLOR(nscolor) (0 ? (CGColorRef) (nscolor) : NULL)
#define CGPathCreateWithRoundedRect(w, x, y, z) NULL
#endif
@@ -146,7 +146,7 @@ static CGFloat pressedPushButtonGradient[8] = {
*/
#define CHECK_RADIUS(radius, bounds) \
- if (radius > bounds.size.width / 2 || radius > bounds.size.height / 2) { \
+ if ((radius) > (bounds).size.width / 2 || (radius) > (bounds).size.height / 2) { \
return; \
}
diff --git a/tests/constraints.tcl b/tests/constraints.tcl
index b4bba2b..466914f 100644
--- a/tests/constraints.tcl
+++ b/tests/constraints.tcl
@@ -243,11 +243,13 @@ namespace eval tk {
}
namespace export controlPointerWarpTiming
+ # Procedures for updating all widgets. These are isolated here
+ # to allow for variations between platforms, but are currently the
+ # same for all platforms (see ticket [bfea11a916]).
namespace export updateWidgets
- # Platform specific procedure for updating the display.
if {[tk windowingsystem] == "aqua"} {
proc updateWidgets {} {
- update idletasks
+ update
}
} else {
proc updateWidgets {} {
diff --git a/tests/textDisp.test b/tests/textDisp.test
index 241f36b..4a060a7 100644
--- a/tests/textDisp.test
+++ b/tests/textDisp.test
@@ -11,20 +11,12 @@ eval tcltest::configure $argv
tcltest::loadTestedCommands
namespace import -force tcltest::test
-# Platform specific procedure for updating the text widget twice, with an in-between delay
-
-if {[tk windowingsystem] == "aqua"} {
- proc delay {} {
- update idletasks
- after 100
- update idletasks
- }
-} else {
- proc delay {} {
- update
- after 100
- update
- }
+# The delay procedure needs to wait long enough for the asynchronous updates
+# performed by the text widget to run.
+proc delay {} {
+ updateWidgets
+ after 100
+ updateWidgets
}
# The procedure below is used as the scrolling command for the text;