From 66a0174e321b7bb4d34c4dcd58d83588c7cd673d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 3 Jan 2025 23:30:30 +0000 Subject: [PATCH] (cherry-pick): Fix [13ac26b35d]: wm iconbitmap does not correctly set the icon pixmap hint on macOS. Thanks to Serhiy Storchaka --- changes | 3 +++ macosx/tkMacOSXWm.c | 15 ++++++++------- tests/unixWm.test | 10 ++-------- tests/wm.test | 4 ++-- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/changes b/changes index 2d1290d49..9a917db45 100644 --- a/changes +++ b/changes @@ -8253,3 +8253,6 @@ Tk Cocoa 2.0: More drawing internals refinements (culler,walzer) (emiliano) - Released 8.6.16, Dec 11, 2024 - https://core.tcl-lang.org/tk/ for details + +2025-01-03 (bug) [13ac26] wm iconbitmap does not correctly set the icon + pixmap hint on macOS (serhiy.storchaka) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 23268f9ba..3865299dc 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -2363,14 +2363,15 @@ WmIconbitmapCmd( TkMacOSXMakeRealWindowExist(winPtr); } 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); - wmPtr->hints.icon_pixmap = None; - } - wmPtr->hints.flags &= ~IconPixmapHint; + WMATT_TITLEPATH, objv[3]) != TCL_OK) { + return TCL_ERROR; + } + if (!len) { + if (wmPtr->hints.icon_pixmap != None) { + Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); + wmPtr->hints.icon_pixmap = None; } + wmPtr->hints.flags &= ~IconPixmapHint; } else { pixmap = Tk_GetBitmap(interp, (Tk_Window)winPtr, Tk_GetUid(str)); if (pixmap == None) { diff --git a/tests/unixWm.test b/tests/unixWm.test index fe0057d52..38178345d 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -826,15 +826,9 @@ test unixWm-22.2 {Tk_WmCmd procedure, "iconbitmap" option} {unix testwrapper} { WM_HINTS] 0]]] lappend result [wm iconbitmap .t] $bit } {{} questhead 0x4 {} 0x0} -if {[tk windowingsystem] eq "aqua"} { - set result_22_3 {0 {}} -} else { - set result_22_3 {1 {bitmap "bad-bitmap" not defined}} -} -test unixWm-22.3 {Tk_WmCmd procedure, "iconbitmap" option for unix only} \ -unix { +test unixWm-22.3 {Tk_WmCmd procedure, "iconbitmap" option} unix { list [catch {wm iconbitmap .t bad-bitmap} msg] $msg -} $result_22_3 +} {1 {bitmap "bad-bitmap" not defined}} test unixWm-23.1 {Tk_WmCmd procedure, "iconify" option} unix { list [catch {wm iconify .t 12} msg] $msg diff --git a/tests/wm.test b/tests/wm.test index 736a266b3..4eb0be776 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -738,11 +738,11 @@ test wm-iconbitmap-1.2.2 {usage} -constraints win -returnCodes error -body { test wm-iconbitmap-1.3 {usage} -constraints win -returnCodes error -body { wm iconbitmap .t 12 13 } -result {illegal option "12" must be "-default"} -test wm-iconbitmap-1.4 {usage} -constraints notAqua -returnCodes error -body { +test wm-iconbitmap-1.4 {usage} -returnCodes error -body { wm iconbitmap .t bad-bitmap } -result {bitmap "bad-bitmap" not defined} -test wm-iconbitmap-2.1 {setting and reading values} -constraints notAqua -setup { +test wm-iconbitmap-2.1 {setting and reading values} -setup { set result {} } -body { lappend result [wm iconbitmap .t]