Skip to content

Fix window decorations under Wayland - #10

Open
fagg wants to merge 1 commit into
cdacamar:mainfrom
fagg:ajf/fix-window-borders
Open

Fix window decorations under Wayland#10
fagg wants to merge 1 commit into
cdacamar:mainfrom
fagg:ajf/fix-window-borders

Conversation

@fagg

@fagg fagg commented Aug 21, 2026

Copy link
Copy Markdown

So I'll preface this by saying that I suspect this isn't entirely correct. It does work on my machine, but I cannot test it under regular X11. It's also beyond my knowledge of the area to say whether this is a Wayland, xwayland or GNOME specific quirk (assuming this works elsewhere without this change).

On my machine - Opensuse Tumbleweed running GNOME with Wayland - exactly 50% of the time the app would start with no window decorations. Some goofing around revealed the cause was actually busted window geometry state getting written to disk, which would mean the window would get drawn on top of the title bar at next start.

The ultimate cause is the WM reparenting the window into its own frame.

  • window_rect() returned XGetWIndowAttribures, which after reparenting is no longer relative to the root. Rather, it's relative to the frame. Effectively it's a border offset rather than a screen position. The remedy was to use XTranslateCoordinates to do the proper transform. This should be OK even in configurations where the reparenting doesn't occur - as the transform will be an identity.
  • The saved position was applied to the frame's outer edge, rather than client area. We now set WM_NORMAL_HINTS with StaticGravity so the WM interprets the coordinates in the correct frame. The ordering matters here as this hints must be in place piror to the map request. Additionally, if the user has a stored position we pass that in as USPosition when setting the hints. PPosition seems to be treated as a hint, whereas USPosition is not a hint (at least this is what I observed with GNOME).

This also fixes set_min_window_size() clobbering the other hints - it now masks rather than overwriting.

The position save now works as intended even with multiple monitors, and window decorations always show up.

After some hunting around I found this out by reading the code in mutter that does the reparenting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant