Tk Source Code

View Ticket
Login
2026-11-13
00:19 • Ticket [2865578f] Changin menu in fullscreen mode messes with geometry status still Open with 4 other changes artifact: 0b45513d user: marc_culler
2026-11-12
22:23 • Ticket [2865578f]: 3 changes artifact: 2907df96 user: serhiy.storchaka
22:04 • Ticket [2865578f]: 4 changes artifact: e30d0a96 user: marc_culler
19:29 • Ticket [2865578f]: 3 changes artifact: e283819d user: serhiy.storchaka
19:05 • Open ticket [2865578f]. artifact: db37789e user: marc_culler
18:09 • Ticket [2865578f]: 3 changes artifact: e2012d30 user: serhiy.storchaka
18:08
Skip test wm-geometry-2.6 on Aqua: the menubar is not in the window there, so the test only checked the size after leaving the fullscreen state, which was not yet restored. See [2865578fff]. check-in: f0013faf user: serhiy.storchaka tags: core-8-6-branch
18:08
Skip test wm-geometry-2.6 on Aqua: the menubar is not in the window there, so the test only checked the size after leaving the fullscreen state, which was not yet restored. See [2865578fff]. check-in: d0bbad37 user: serhiy.storchaka tags: core-9-0-branch
18:07
Skip test wm-geometry-2.6 on Aqua: the menubar is not in the window there, so the test only checked the size after leaving the fullscreen state, which was not yet restored. See [2865578fff]. check-in: 04e870ad user: serhiy.storchaka tags: trunk, main
17:36 • Closed ticket [2865578f]: Changing menu in fullscreen mode messes with geometry plus 8 other changes artifact: 0db855bd user: nemethi
17:23 • Ticket [2865578f]: 4 changes artifact: b0396274 user: marc_culler
16:30 • Ticket [2865578f]: 3 changes artifact: c716ad57 user: serhiy.storchaka
16:02 • Ticket [2865578f]: 4 changes artifact: 79c2d299 user: marc_culler
09:52
Fix for [2865578fff]: Changing menu in fullscreen mode messes with geometry check-in: 2a7f87a9 user: csaba tags: core-8-6-branch
09:47
Fix for [2865578fff]: Changing menu in fullscreen mode messes with geometry check-in: 3a6c7e91 user: csaba tags: core-9-0-branch
09:41
Fix for [2865578fff]: Changing menu in fullscreen mode messes with geometry check-in: 349c3b24 user: csaba tags: trunk, main
2026-11-05
14:49
Fix [2865578fff]: X11: the toplevel shrank when its menubar was set again while it was going fullscreen or zoomed. The size requested for the toplevel was computed before the height of the new menubar was known; the window manager could apply that request after restoring the window, and Tk took it for a resize by the user. Compute the menubar geometry before it is used. Test wm-geometry-2.6. Rebased on main. closed check-in: bd8005bc user: serhiy.storchaka tags: x11-menubar-height
12:01 • Ticket [2865578f] Changin menu in fullscreen mode messes with geometry status still Open with 3 other changes artifact: e29b968a user: serhiy.storchaka
12:00
Fix [2865578fff]: X11: the toplevel shrank when its menubar was set again while it was going fullscreen or zoomed. The size requested for the toplevel was computed before the height of the new menubar was known; the window manager could apply that request after restoring the window, and Tk took it for a resize by the user. Compute the menubar geometry before it is used. Test wm-geometry-2.6, with the helper waitForWm from win-zoomed-geometry. closed check-in: bb1cb9de user: serhiy.storchaka tags: x11-menubar-height
2018-08-29
05:57 • Ticket [2865578f] Changin menu in fullscreen mode messes with geometry status still Open with 4 other changes artifact: f79bc3c8 user: oehhar
05:49 • Ticket [2865578f]: 4 changes artifact: fc77f06e user: oehhar
2018-08-28
19:45 • Ticket [2865578f]: 4 changes artifact: e5b5fb2d user: fvogel
13:39 • Ticket [2865578f]: 4 changes artifact: e9066a5a user: oehhar
12:56 • Ticket [2865578f]: 3 changes artifact: 78519043 user: fvogel
11:59 • Ticket [2865578f]: 3 changes artifact: e9b8bf8b user: fvogel
10:42 • Ticket [2865578f]: 4 changes artifact: 47566f7b user: oehhar
10:40 • Ticket [2865578f]: 4 changes artifact: 2efbf0e7 user: oehhar
2018-08-27
19:33 • Ticket [2865578f]: 6 changes artifact: 2e0496c6 user: fvogel
2009-09-24
21:24 • Ticket [2865578f]: 4 changes artifact: 6ef7bb8a user: kaitzschu
17:35 • Ticket [2865578f]: 4 changes artifact: e5211679 user: ferrieux
15:00 • Add attachment sample.tk to ticket [2865578f] artifact: 86aa280e user: kaitzschu
15:00 • Ticket [2865578f] Changin menu in fullscreen mode messes with geometry status still Open with 4 other changes artifact: 13f4d247 user: kaitzschu
08:00 • New ticket [2865578f]. artifact: 15420479 user: kaitzschu

Ticket UUID: 2865578
Title: Changin menu in fullscreen mode messes with geometry
Type: Bug Version: obsolete: 8.6b1.1
Submitter: kaitzschu Created on: 2009-09-24 08:00:08
Subsystem: 12. Unix Menus Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-11-13 00:19:20
Resolution: None Closed By: nobody
    Closed on: 2026-11-12 17:36:15
Description:
Summary says it all. Running attached script either increases window size by menu height or leaves the window to maximized state. Observed with Fedora 11, Linux 2.6.29.6, KDE 4.3.1.
User Comments: marc_culler (claiming to be Marc Culler) added on 2026-11-13 00:19:20:
No, NSWindowDidEnterFullScreenNotification fires before the animation.
Apple's documentation does not discuss the animation at all.

Here is the expectation, based on the analysis I posted:

The geometry remains unchanged throughout the animation, which can
last for somewhere between 500 and 1200 milliseconds.  The fullscreen
flag is set to 1 when the animation starts and the frame size is set to
the monitor size when the animation starts as well.  So when you run:

    wm attributes .geom -fullscreen 1
    waitForWm .geom {[wm attributes .geom -fullscreen]
            && [winfo width .geom] == [winfo screenwidth .geom]

the call to  waitforWm will return in 100ms, because both conditions
hold as soon as the first call to wm attributes finishes, and the
geometry will have been constant for 100ms.

When you then run:

    wm attributes .geom -fullscreen 0

nothing will happen because the animation has another 400 ms to run,
at least, so toggleFullScreen is ignored.  When you then run:

  waitForWm .geom {![wm attributes .geom -fullscreen]}

it will wait for its full 2 seconds, since the window will remain at
fullscreen for the entire time.  And the window will never end its
fullscreen status until the script ends.

I ran your code, with a definition of waitforWm copied from wm.test, and
that is exactly what happened.  The window became full screen and stayed
fullscreen until the script exited.  I included puts calls before and
after the call to waitForWm and had my terminal on the other monitor.
Those puts calls were two seconds apart.

serhiy.storchaka added on 2026-11-12 22:23:31:

Thank you for the analysis, Marc. So on macOS the sequence of this test cannot work: the second toggleFullScreen is ignored during the animation. On X11 the test intentionally leaves the fullscreen state before any events are processed, because that is what triggered the bug. That is why I made it skipped on Aqua.

A test that the window returns to its size after the fullscreen state would be a separate test, out of scope of this ticket. Note that waitForWm waits up to 2 seconds for its condition, not 100 ms; the 100 ms is how long the geometry must stay unchanged after the condition holds. Something like this might work on macOS (I cannot test it):

    wm geometry .geom 480x200
    ...
    wm attributes .geom -fullscreen 1
    waitForWm .geom {[wm attributes .geom -fullscreen]
            && [winfo width .geom] == [winfo screenwidth .geom]}
    wm attributes .geom -fullscreen 0
    waitForWm .geom {![wm attributes .geom -fullscreen]}
The first wait relies on NSWindowDidEnterFullScreenNotification being posted after the animation, as Apple's documentation says, so that the Tk size becomes the screen size only then. On older macOS the 2 seconds of waitForWm may need to be longer.


marc_culler (claiming to be Marc Culler) added on 2026-11-12 22:04:55:
It does test something useful, namely whether the window returns to its
previous size.  However that will only be true if its previous size was
large enough to show all of the usual window controls in the titlebar.

But this adventure turned up several things, which I did not know about, that
reveal how far from reality the design of the waitForWm function is, at least
for macOS.  Since that function is used 16 times in wm.test, it seems worth
understanding what went wrong here.  So here is the synopsis.
 
The implementation of wm attributes <window> -fullscreen (in query mode)
looks like this:

case WMATT_FULLSCREEN:
    result = Tcl_NewBooleanObj([macWindow styleMask] & NSFullScreenWindowMask);
    break;

The behavior of that styleMask bit and of the window geometry when
transitioning to or from full scteen is as follows:

 * The animation lasts for about 550 ms on macOS 26 but up to 1.2 seconds on
   older versions of macOS.
 * When entering fullscreen mode the styleMask bit is set to 1 and the frame
   size is changed to the screen size before the animation starts.
 * When exiting fullscreen mode the styleMask bit remains 1 and the frame
   size remains at the screen size until the animation ends.
 * If [NSWindow toggleFullScreen] is called during the animation the call
   is ignored.
 * When transitioning into or out of full screen mode the Tk size of a window
   gets set in the handlers for NSWindowDidEnterFullScreenNotification (called
   before the animation) and NSWindowDidExitFullScreenNotification (called
   after the animation).
 * The Tk size is set by querying the size of the NSWindow's contentView.

The test was running these commands:
    wm attributes .geom -fullscreen 1
    .geom configure -menu {}
    .geom configure -menu .m
    wm attributes .geom -fullscreen 0
    waitForWm .geom {![wm attributes .geom -fullscreen]}

The first three commands execute immediately since none of them cause Tk to
enter its event loop.  The waitForWm command spins for up to 100 ms, checking
every 20 ms to see if the stylemask bit is 0 and the window geometry is
unchanged since the previous check with stylemask 0.

So how does this work for macOS?

The first call to `wm attributes .geom -fullscreen 1` calls toggleFullScreen
which sets the stylemask bit to 1 and the window size to the screen size and
then launches the animation, which will run between 550ms and 1200ms, both
of which are longer than the 100ms max that waitForWm will wait.

The menu configuration runs immediately.  The call to 
`wm attributes .geom -fullaxreen 0`
makes a second call to toggleFullScreen which is ignored because the animation
is still in progress.

The call to waitForWm checks 5 times, with 20ms waits in between, to see if
the stylemask bit is 0.  It is not 0, and it will never become 0 because the
second call to toggleFullScreen was ignored.  So waitForWm returns after 100ms.

The test ends in failure because the new size is the full window size, not
the original size of the window.

The window is destroyed (while still in its animation on its way to becoming
fullscreen).

My conclusion is that waitForWm is completely unsuitable for use in any tests
that involve fullscreen windows on macOS.

serhiy.storchaka added on 2026-11-12 19:29:01:

Thank you, Marc. I considered making the test pass on macOS, with a patch like this:

     toplevel .geom -menu .m
     pack [label .geom.l -text Label]
+    # Wide enough for the title bar buttons on macOS.
+    wm geometry .geom 480x200
     waitForWm .geom {[winfo ismapped .geom]}
     regexp {^\d+x\d+} [wm geometry .geom] size
 } -body {
     # No events are processed before the window leaves the fullscreen state.
     wm attributes .geom -fullscreen 1
     .geom configure -menu {}
     .geom configure -menu .m
     wm attributes .geom -fullscreen 0
-    waitForWm .geom {![wm attributes .geom -fullscreen]}
+    # On macOS the window still has the fullscreen size for a while.
+    waitForWm .geom {![wm attributes .geom -fullscreen]
+	    && [winfo width .geom] < [winfo screenwidth .geom]}
But since on macOS the menubar is not a part of the window, this test would not test anything useful there. So I made it skipped on Aqua ([04e870ad6c]).


marc_culler (claiming to be Marc Culler) added on 2026-11-12 19:05:26:
One problem is with the waitForWm function.  It returns if the geometry
of the window has not changed after 100 ms, assuming that means that the
requested geometry change has occurred and the geometry has reached its
stable state.  The macOS animations tend to take around 250 ms.  The one
which accompanies moving a window to or from full screen on macOS 26 (where
I saw the failure) is pretty dramatic.  I am sure it takes at least that long.

I can make the test pass on macOS by making three changes:

1) Set the geometry of the window to 200x100 after packing the label.

2) Wait 1 second after setting fullscreen to 1, so the window will actually
be at the fullscreen size before fullscreen is set back to 0.  (The delay
could be 600ms but 500ms is not enough.)

3) Change "after 20" to "after 60" in waitForWm, so that it does not assume
that the geometry has stabilized unless it has been constant for 300ms.

I am in the middle of making an unrelated merge of fixes for aqua memory
leaks.  Is it OK with you if I include that change to wm.test?

serhiy.storchaka added on 2026-11-12 18:09:01:

Test wm-geometry-2.6 is now skipped on Aqua, since the menubar is not in the window there: [04e870ad6c] (main), [d0bbad37b3] (9.0), [f0013faf23] (8.6).


nemethi (claiming to be Csaba Nemethi) added on 2026-11-12 17:36:15:

Serhiy, many thanks! Merged into main, core-9-0-branch, and core-8-6-branch by commits [349c3b24], [3a6c7e91], and [2a7f87a9].


marc_culler (claiming to be Marc Culler) added on 2026-11-12 17:23:50:
There are two reasons for the failure of this test on macOS

The first is that when you pack the label with text "Label" into the
window .geom the width of the window is just barely large enough to show
the text and that is too small to show all three of the window controls
in the titlebar.  When the window exits its fullscreen state it gets
resized to a size which is just wide enough to hold the three buttons.
So the sizes don't match.  This can be fixed by setting the window size
directly, not depending on what happens when a label is packed.

The second reason is a timing issue.  The reported size after setting
fullscreen back to 0 is the size of the fullscreen window.  The window has
not been fully configured to its (adjusted) original size yet.

This test has nothing to do with menubars in the case of macOS, since
the menubar is not in the window at all - it is at the top of the screen.
So what the test is really checking is that the window returns to its
original size after exiting fullscreen.  In fact it does, as long as the
original size was large enough to hold the titlebar buttons.  But the test
fails to detect that.

serhiy.storchaka added on 2026-11-12 16:30:32:

Sorry, Marc. The fix itself is in the X11 code, but the new test wm-geometry-2.6 also runs on Aqua, so it shows that the same sequence changes the size there too. What size does wm geometry report before entering the fullscreen state and after leaving it? And does it also fail without the menubar changes in the middle? Then we can see whether this can be fixed on Aqua.


marc_culler (claiming to be Marc Culler) added on 2026-11-12 16:02:38:
I am now seeing a failure of wm-geometry-2.6 on macOS.  Since Serhiy said
that this fix was not tested on macOS, I don't understand why the fix was
merged before anyone had tested it on macOS.

The failure is:

==== wm-geometry-2.6 the menubar set again in fullscreen - bug 2865578fff FAILED
==== Contents of test case:

    # No events are processed before the window leaves the fullscreen state.
    wm attributes .geom -fullscreen 1
    .geom configure -menu {}
    .geom configure -menu .m
    wm attributes .geom -fullscreen 0
    waitForWm .geom {![wm attributes .geom -fullscreen]}
    regexp {^\d+x\d+} [wm geometry .geom] newSize
    expr {$newSize eq $size}

---- Result was:
0
---- Result should have been (exact matching):
1

serhiy.storchaka added on 2026-11-05 12:01:49:

Still reproducible on X11 under Openbox: after the four commands of sample.tk the toplevel shrinks to 1 pixel high. The same happens with wm attributes . -zoomed instead of -fullscreen.

When the menubar is set again, Tk requested the size of the toplevel before the height of the new menubar was computed. Openbox applied that request after restoring the window from fullscreen, and Tk took it for a resize by the user, with a negative height for the contents.

Fixed on branch x11-menubar-height: the menubar geometry is computed before it is used. Not tested on macOS.


oehhar added on 2018-08-29 05:57:31:

I have made additional tries on CentOS 6.5 64 bit.

wish8.6.7 and wish 8.5.7 behave the same way.

  • the resulting window is always a normal window with a menu and a toolbar
  • sometimes, it stays in a size, where only the label is shown
  • sometimes it jumps to a size which is equal to fullscreen, but the decoration says, that it is in normal mode with fullscreen size

Conclusion:

  • The windows bug (no decoration) does not show up
  • at the end of the script, the window is in the right mode, but size is "surprising".

I am sorry for the quick test yesterday with the wrong conclusion. The small size of the window has suggested me that only the label is shown.


oehhar added on 2018-08-29 05:49:09:

Maybe some more words about CentOS 6.5 64 bit:

wish 8.5.7

An undecorated window with only the text "Label" is shown

wish 8.6.7

A normal decorated toplevel with a menu and a label is shown.

The size of this toplevel is:

  • in one try smaller than the Label text
  • in another try nearly as large as a fullscreen window

The size may be changed using the decoration.


fvogel added on 2018-08-28 19:45:15:
Confirmed that I don't see a problem on Windows with core-8-6-branch.

Tests results however on Debian 8: pasting your code below in wish fails for Tcl/Tk 8.5.7, Tcl/Tk core-8-6-branch, and Tcl core-8-branch with Tk trunk. The window stays in fullscreen state for me. Strange that you saw this fixed on CentOS 6.5 with Tk 8.6.7.

oehhar added on 2018-08-28 13:39:08:

The original ticket speaks about Linux. Windows is fixed, but was only subject of a comment.

I have made tests on my CentOS 6.5 which has, by chance, a tk 8.5.7 by default.

So:

wish < error.csv

With the file contents as in my former post.

On Tk 8.5.7, only an undecorated label is shown. On Tk 8.6.7, the issue is fixed and the fullscreen window is shown.

So, I can confirm, that:

  • The issue exists on Linux the same way as on Windows
  • It is fixed for Tk 8.6.7

IMHO the ticket may be closed, even if a test on a recent Tk 8.5 is pending. 8.5 is end of life.


fvogel added on 2018-08-28 11:59:28:
So is there something that remains to be fixed for this ticket and, if so, what is it?

oehhar added on 2018-08-28 10:42:17:

Grrrrr. Correction to the last post. It is correct for tk 8.5.19 and 8.6.8, not 8.5.8.

Sorry, Harald


oehhar added on 2018-08-28 10:40:11:

In a follow-up, tested on Win 10 64 bit with tk 8.5.7 build as described in [2797260fff].

  • Start wish85t.exe
  • Paste the following in the console:
menu .menu
.menu add command -label Entry
. configure -menu .menu
pack [label .l -text Label]
update
after 1000

wm attributes . -fullscreen 1
. configure -menu {}
. configure -menu .menu
wm attributes . -fullscreen 0

This test leaves a Window without decoration with only the text "Label" in the upper-left corner.

The same test procedure for tk 8.5.19 and 8.5.8 shows a normal decorated window with the label "Label" and a menu at the appropriate place. It looks, like this (part of the) bug is fixed.


fvogel added on 2018-08-27 19:33:17:

Looks very much like a duplicate of [2797260fff]


kaitzschu added on 2009-09-24 21:24:00:
8.6b1.1 seems to have fixed this on Windows, but with Tclkit 8.5.7 (available from http://code.google.com/p/tclkit/wiki/TclkitDownloads) sample.tk leaves main window to overrideredirected state, although [wm overrideredirect .] reports 0, but setting mode on and again off restores normal window.

Probably doesn't have anything to do with this, or at least not with Unix Menus :)

ferrieux added on 2009-09-24 17:35:52:
Confirmed with icewm+CentOS4.

Dunno if it helps, but the bug also manifests itself in the presence of a geometry manager: just add [pack [label .l -text Label]] before the [update]. The result is that after the fullscreen roundtrip, the label is misplaced (it stats at y=0 instead of being below the menu).

 The reason I tried that, is that the initial report is about the "unmanaged" geometry, which is only of interest for unit tests with an interactive wish, not for real app. Knowing that it also hits [pack] raises its interest ;-)

kaitzschu added on 2009-09-24 15:00:08:

File Added - 344133: sample.tk

Attachments: