Ticket UUID: | 159aa5eba2a84132bf53ebfcb8c19f0c1d4678cc | ||||||||||||||||||||||||||||||||||||||||||||||||
Title: | MS-Win: Incorrect system menu entries for transient toplevels | ||||||||||||||||||||||||||||||||||||||||||||||||
Type: | Bug | Version: | 9.0.1 | ||||||||||||||||||||||||||||||||||||||||||||||
Submitter: | cjmcdonald | Created on: | 2025-03-05 17:00:39 | ||||||||||||||||||||||||||||||||||||||||||||||
Subsystem: | 68. Win Window Operations | Assigned To: | nobody | ||||||||||||||||||||||||||||||||||||||||||||||
Priority: | 5 Medium | Severity: | Minor | ||||||||||||||||||||||||||||||||||||||||||||||
Status: | Closed | Last Modified: | 2025-03-17 09:57:46 | ||||||||||||||||||||||||||||||||||||||||||||||
Resolution: | Fixed | Closed By: | oehhar | ||||||||||||||||||||||||||||||||||||||||||||||
Closed on: | 2025-03-17 09:57:46 | ||||||||||||||||||||||||||||||||||||||||||||||||
Description: |
The Windows system menu invoked by right clicking on the titlebar has incorrect entries enabled for Tk transient windows, i.e. toplevel windows with wm transient specified. The attached transient.tcl and screenshot1.png illustrate the problem. The transient.tcl main window is resizable, but the .popup window isn't: toplevel .popup wm withdraw .popup wm title .popup "Pop-Up Dialog" wm transient .popup . wm resizable .popup 0 0screenshot1.png shows that the Windows system menu for .popup has Size, Minimize and Maximize all enabled, which they shouldn't be for a non-resizable window. The Minimize option should never be enabled for a transient, whether or not it is resizable, because transients shouldn't be separately iconized down to the taskbar - they are hidden when the parent window is minimized. Trying to invoke the Minimize or Maximize options on the .popup system menu gets into funny states which it is difficult to get out of. I think that this problem has been there since the very beginning of the Tk Windows port. It only affects transient windows, not normal toplevels. The problem appears to be the Windows Extended Style WS_EX_DLGMODALFRAME which is specified for transient windows in win/tkWinWm.c. Removing it from the Tk 9.0.1 version of tkWinWm.c fixes the problem: --- tkWinWm.c-tk9.0.1 2024-12-12 18:15:01.000000000 +0000 +++ tkWinWm.c-patched 2025-03-05 16:18:05.193087800 +0000 @@ -304,5 +304,5 @@ #define WM_TRANSIENT_STYLE \ (WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_CLIPSIBLINGS|CS_DBLCLKS) -#define EX_TRANSIENT_STYLE (WS_EX_DLGMODALFRAME) +#define EX_TRANSIENT_STYLE (0) The system menu for .popup is now ok, as shown in screenshot2.png. Modifying transient.tcl to test other combinations of resizable/non-resizable main window and .popup window, they all have correct system menus. I can't see any difference in the visual appearance of .popup without WS_EX_DLGMODALFRAME. I haven't found much info on WS_EX_DLGMODALFRAME, but examples of its use on the web don't appear to be in combination with the "transient" style options that Tk specifiies: WM_POPUP style and a parent window. It may be that particular combination which isn't working. I'm testing on Windows 10, with Tcl/Tk 9.0.1. | ||||||||||||||||||||||||||||||||||||||||||||||||
User Comments: |
oehhar added on 2025-03-17 09:57:46:
Merged to:
I want to thank cjmcdonald for the great patch, tests and support ! Harald fvogel added on 2025-03-15 11:16:14: Sorry for the noise. I hwve understood what was wrong with my setup. Everything is OK for me. I believe this can be merged now. fvogel added on 2025-03-15 10:19:59: I was about to suggest we can merge this but despite some effort I can't see the effect of the fix any longer... Running the attached transient.tcl, I just can't reproduce screenshot2.png, instead I keep getting screenshot1.png. How weird, I have no explanation for this. Win11, Tk branch 159aa5eb-win-transient-system-menu. Am I alone? cjmcdonald added on 2025-03-10 19:12:58: I have tested the patched version on Windows 7, and it works correctly there. oehhar added on 2025-03-10 15:15:05: Great, thanks ! May one of you verify, if the patch is also effective on Windows 7? Side note: I like the comment by Francois. I can not find any notice in the Win32 API documentation, that the removal of the windows flag "WS_EX_DLGMODALFRAME" will have any consequence on the system menu. The "normal" way to manipulate the system menu is to open it and to disable the items manually. emiliano added on 2025-03-10 14:53:59: Harald: no, I just tested the main branch. Since everyone else is using windows10+, I tested on Windows7 to see whether this is a regression or not. oehhar added on 2025-03-10 14:33:25: Dear Emiliano, I have retested with Windows 11 with the original test script (resizable no) and the line "wm resizable .popup 0 0" commented out (resizable yes). Here are the active system menu items in dependency of the branch and if resizing is allowed:
The bugfix branch looks perfect. Emiliano, as I see your result in the main branch - are you sure to have used the bugfix branch ? emiliano added on 2025-03-10 13:47:25: By trying out with some of my scripts, the problem seem to be the combination of [wm resizable $popup 0 0] and [wm transient]. Attached an image with [wm transient] only on the left, [wm transient]+[wm resizable] on the right, (Old) Windows7 32bits. oehhar added on 2025-03-10 10:08:43: Thanks Francois, may this branch be merged to main and back-ported to 9.0 and 8.6 ? Thanks for all, Harald fvogel added on 2025-03-09 16:26:09: I'm in agreement with the report. I have tried the patch and I think it is OK. There is not much documentation on this however... oehhar added on 2025-03-07 09:15:49: The patch is now in checkin [99a27136] starting branch [159aa5eb-win-transient-system-menu]. I tested it, it is an improvement. Thanks for all, Harald |
Attachments:
- transient-transient_nr.png [download] added by emiliano on 2025-03-10 13:47:52. [details]
- screenshot2.png [download] added by cjmcdonald on 2025-03-05 17:04:09. [details]
- screenshot1.png [download] added by cjmcdonald on 2025-03-05 17:03:41. [details]
- transient.tcl [download] added by cjmcdonald on 2025-03-05 17:03:10. [details]