Tk Source Code

View Ticket
Login
2026-11-05
12:07 • Closed ticket [354fbe9f]: Windows: -appearance set with wm attributes is lost when the wrapper is recreated plus 8 other changes artifact: d65499fe user: nemethi
11:56
Fix for [354fbe9fe6]: Windows: -appearance set with wm attributes is lost when the wrapper is recreated check-in: ca38b646 user: csaba tags: trunk, main
2026-10-22
22:49 • Ticket [354fbe9f] Windows: -appearance set with wm attributes is lost when the wrapper is recreated status still Open with 4 other changes artifact: 16a0b5ff user: serhiy.storchaka
2026-10-21
15:56 • Ticket [354fbe9f]: 3 changes artifact: 67552556 user: nab
15:56
Reference ticket [354fbe9fe6] in tests winWm-10.5 and 10.6. closed check-in: 075ec1ae user: nab tags: nab-win-appearance-rebuild
15:55 • New ticket [354fbe9f] Windows: -appearance set with wm attributes is lost when the wrapper is recreated. artifact: 8e208d3a user: nab

Ticket UUID: 354fbe9fe63c8cb7d8c8c644737251287ec06057
Title: Windows: -appearance set with wm attributes is lost when the wrapper is recreated
Type: Bug Version: 9.1.0
Submitter: nab Created on: 2026-10-21 15:55:56
Subsystem: 68. Win Window Operations Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-11-05 12:07:11
Resolution: Fixed Closed By: nemethi
    Closed on: 2026-11-05 12:07:11
Description:

On Windows, wm attributes $w -appearance dark (or light) sets DWMWA_USE_IMMERSIVE_DARK_MODE on the current wrapper and marks the appearance as forced. A later command that recreates the wrapper with UpdateWrapper gives a new HWND without that attribute, so the title bar turns light again: wm resizable, wm transient on a mapped window, wm overrideredirect, wm attributes -toolwindow or -fullscreen, and the implicit recreations (transients of a recreated container, first map through WmWaitVisibilityOrMapProc).

UpdateWrapper schedules AppearanceIdleProc, but SynchronizeAppearance returns at once when the appearance is forced, so the forced mode is never applied to the new wrapper.

toplevel .t
update idletasks
wm attributes .t -appearance dark
wm resizable .t 0 1
update idletasks
winfo isdark .t   ;# 0, expected 1

Fix: SynchronizeAppearance applies the forced mode to the current wrapper instead of returning early (no <<AppearanceChanged>> is sent on success in that case, the appearance did not change for the application). Tests winWm-10.5 and winWm-10.6.

User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-11-05 12:07:11:

Many thanks to Nicolas for the fix and to Serhiy for the review! Merged into main by commit [ca38b646]. No merge into core-9-0-branch or core-8-6-branch is planned.


serhiy.storchaka added on 2026-10-22 22:49:16:

Confirmed on Windows 11: on main, a dark appearance forced with wm attributes -appearance dark is lost after wm resizable, wm overrideredirect, -toolwindow, -fullscreen on/off and wm transient on a mapped window. On nab-win-appearance-rebuild it is kept in all five cases, and wm.test and winWm.test pass.


nab added on 2026-10-21 15:56:37:

Fix proposed on branch [nab-win-appearance-rebuild]: [d89119f114], tests winWm-10.5 and 10.6 ([075ec1ae00]). Verified on Windows 11: both tests fail without the fix and pass with it.