Fix window decorations under Wayland - #10
Open
fagg wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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()returnedXGetWIndowAttribures, 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.WM_NORMAL_HINTSwithStaticGravityso 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 asUSPositionwhen setting the hints.PPositionseems to be treated as a hint, whereasUSPositionis 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
mutterthat does the reparenting.