Tk Source Code

View Ticket
Login
Ticket UUID: 2817531
Title: "wm manage" is deficient and flickering
Type: Bug Version: obsolete: 8.5.7
Submitter: gcramer Created on: 2009-07-06 16:46:50
Subsystem: 08. [(label)frame] and [toplevel] Assigned To: pspjuth
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2026-10-27 17:46:46
Resolution: None Closed By: nobody
    Closed on:
Description:
NOTE:
I tried the following with x11 windowing system. I don't know
the behaviour with win32 and aqua.

Please try the following code:
----------------------------------------------------------------------------------------
wm withdraw .
frame .f1 -width 800 -height 800
frame .f2 -width 800 -height 800
button .f1.l -text Undock -command { Undock .f2 }
pack .f1.l
pack .f1 .f2
::tk::PlaceWindow . center
wm deiconify .
proc Undock {w} {
   pack forget $w
   wm manage $w
   wm overrideredirect $w
   wm protocol $w WM_DELETE_WINDOW [list Dock $w]
   ::tk::PlaceWindow $w center [winfo parent $w]
}
proc Dock {w} {
   wm forget $w
   pack $w
}
----------------------------------------------------------------------------------------

1. I'm using large windows too make it easier too see the problem.
2. "wm overrideredirect" is not working. It comes too late because
   the (managed)  window is already mapped. But I cannot use this
   before managing.
3. The popup is flickering a lot. This has two reasons:
   a) In function WmManageCmd (unix/tkUnixWm.c) you see:
          2675: TkWmMapWindow(winPtr);
          2676: Tk_UnmapWindow(frameWin);
       This must flicker. These statements are superfluous.
       I tried this without these two lines and the function
       is working! But it flickers still a bit because:
   b) ::tk::PlaceWindow comes too late because the
       (managed) window is already mapped (normally 
      in the upper left corner). It should help if
      "wm manage" has an option like -unmapped.
      Without such an option the window cannot be placed
      flicker-free. And without such an option you
     cannot use "wm overrideredirect".
User Comments: nemethi (claiming to be Csaba Nemethi) added on 2026-10-27 17:46:46:

Serhiy, many thanks! Merged into main, core-9-0-branch, and core-8-6-branch by commits [5e0e41ad], [e03850a3], and [0f26cf41].

Note that the macOS case is still open. Simply removing the TkWmMapWindow invocation causes troubles (tested on macOS). For this reason I added the notAqua constraint to the new wm-manage-1.9 test, and left the ticket open.


serhiy.storchaka added on 2026-10-02 17:24:23:

Still present. On X11, WmManageCmd created the wrapper by mapping it (TkWmMapWindow) and unmapping it at once, so the window flashed at +0+0 even if wm withdraw followed. These calls are needed to create the wrapper, which is why removing them did not work.

Proposed fix in branch x11-wm-manage-no-flicker: only create the wrapper and leave mapping to the idle handler. Then wm manage, wm withdraw, wm overrideredirect 1, wm geometry and wm deiconify map the window once, without flicker. New test wm-manage-1.9.

Windows does not map the window in wm manage, and the test passes there. macOS calls TkWmMapWindow in wm manage too and may have the same problem; the test is not limited to X11, so CI will show it.

Note that wm overrideredirect $w without a value in the example only queries the flag.


gcramer added on 2009-07-07 00:19:18:
I have to make a correction:
I tried a more complex example after I removed the two lines 2675 and 2676 in
function WmManageCmd(), and it didn't work. This means these two lines are
NOT superfluous! But the flickering is still the problem. (Note: the simple example
above works without these two lines of code).