Tk Source Code

View Ticket
Login
Ticket UUID: 3b67cf414a2f4fba29ca982276c791a9a7b4062e
Title: Wayland branch: wm overrideredirect is inconsistent across compositors
Type: Bug Version:
Submitter: kevin_walzer Created on: 2026-10-21 01:50:05
Subsystem: 67. Unix Window Operations Assigned To: kevin_walzer
Priority: 5 Medium Severity: Important
Status: Closed Last Modified: 2026-10-21 19:00:30
Resolution: Fixed Closed By: kevin_walzer
    Closed on: 2026-10-21 19:00:30
Description:
On Wayland, wm overrideredirect is not truly supported. The current implementation in the wayland branch returns an undecorated GLFW toplevel, which works on some compositors (mutter) and not on others (Plasma/KWin, where server-side decorations are drawn anyway), and which is subject to Wayland-controlled placement. The most common use case for wm overrideredirect, popup windows, are supported via other API's. Primitives are implemented in tkWaylandPopup.c using wl_subsurface, and window behavior is implemented mainly in tkWaylandMenu.c. This functionality works with the available Wayland API's exposed by GLFW, and allows for the exact placement required by menus, dropdown windows, and tooltips. 

In the end, wm overridredirect does not have much utility on Wayland. Rather than try to make this API work in an incomplete, inconsistent and extremely limited way on Wayland, the wayland_nooverride branch simply renders overrideredirect no-op. Any window assigned this attribute will simply remain a standard toplevel window.
User Comments: kevin_walzer added on 2026-10-21 19:00:30:
Merging and closing. Thank you for the discussion.

serhiy.storchaka added on 2026-10-21 17:45:58:

I think so. Please check before merging that a tooltip positioned with winfo pointerx/pointery (e.g. tklib's tooltip) appears next to the pointer when the pointer has not moved after entering the widget. If it appears at a stale position, it can be fixed in TkWaylandCursorEnterCallback(), as I suggested.


kevin_walzer added on 2026-10-21 17:34:08:
Test script appears to work as expected. Do you think this can be merged back to the main Wayland branch?

serhiy.storchaka added on 2026-10-21 17:10:18:

Yes, with [c27bf703e1] the tooltip is placed where wm geometry says and moves with it, under sway and GNOME Shell. My test script:

wm geometry . 400x300+100+100
pack [frame .f -bg gray -width 400 -height 300]
update
toplevel .tip -bg yellow
pack [label .tip.l -text "Tooltip text" -bg yellow]
wm overrideredirect .tip 1
wm geometry .tip +250+250
update; after 300; update
puts "[winfo rootx .tip],[winfo rooty .tip] [wm geometry .tip]"
wm geometry .tip +120+130
update; after 300; update
puts "[winfo rootx .tip],[winfo rooty .tip] [wm geometry .tip]"


kevin_walzer added on 2026-10-21 15:45:05:
Does the latest commit address the errors you note?

kevin_walzer added on 2026-10-21 15:25:19:
Disregard my question about your proposed solution, let me see what we can do. I would still like to see your sample script.

kevin_walzer added on 2026-10-21 15:23:52:
Please attach your test script. wm geometry +x+y will never work reliably on Wayland because the compositor decides window placement, not the program. Apart from documenting this limitation and saying code changes may be required, what do you suggest as a solution?

serhiy.storchaka added on 2026-10-21 14:52:53:

The requested position is ignored: after wm geometry .tip +250+250 the tooltip appears at the cursor, and moving it later with wm geometry does nothing. TkDiff works because its tooltips are placed at the cursor anyway, but other small override-redirect windows positioned by the script (balloons, dropdowns) are misplaced.

OverridePopupRect() could always use wmPtr->x/y; then ResizeOverridePopup() would also move a mapped window. For a stale winfo pointerx, TkWaylandCursorEnterCallback() could pass the position from glfwGetCursorPos() to TkWaylandUpdatePointerState(), so that it is current as soon as the pointer enters a window.


kevin_walzer added on 2026-10-21 14:35:32:

Tested the wayland_subsurface_override branch against TkDiff 6.0, which uses a pre-ttk combobox megawidget and tooltips implemented on wm overrideredirect, and window placement/behavior is identical to what is seen on X11. I am unable to confirm test suites results because wm.test hangs - that is a separate, serious issue that also needs addressing - but my conclusion is that this new implementation should work just fine as a drop-in replacement for wm overrideredirect on Wayland without requiring any new API's or script-level code changes. Please review. If you agree this is a viable solution, I will merge the new branch back to Wayland.


kevin_walzer added on 2026-10-21 11:37:58:

Trying your suggestion in the wayland_subsurface_override branch.


serhiy.storchaka added on 2026-10-21 10:35:41:

Many wm settings are only requests which a window manager may ignore, but Tk still records and returns them. Returning an empty string makes such a script fail with an error instead of just showing a normal window.

The better approach would be to show an override-redirect toplevel the same way as a menu, with the wl_subsurface code in tkWaylandPopup.c. Then tooltips would work too.


kevin_walzer added on 2026-10-21 09:46:41:
The behavior is still fundamentally broken on Wayland. Scripts that use wm overrideredirect for tooltips won’t get tooltips even if the bool value is still checked correctly and does not throw an error. Isn’t that misleading?  What is the better approach here?

serhiy.storchaka added on 2026-10-21 08:17:51:

In [505cea621a] wm overrideredirect no longer returns the current value and no longer checks the argument: wm overrideredirect .t returns an empty string, also after wm overrideredirect .t 1, and wm overrideredirect .t boo succeeds. This breaks scripts which test [wm overrideredirect $w] ("expected boolean value but got """), and tests wm-overrideredirect-1.3 and 2.1.

It could still check the boolean and remember it (for example in a flag of WmInfo), and return it, without passing it to Tk_ChangeWindowAttributes(), which would make the window undecorated through XChangeWindowAttributes().