Send a synthetic UnmapNotify when hiding an X11 window - #22135
Merged
Conversation
ICCCM 4.1.4 requires a client withdrawing a top-level window to also send a synthetic UnmapNotify to the root window. XUnmapWindow alone generates no event when the window manager has already unmapped the window, leaving a minimized window listed as managed and iconic after Hide().
|
You can test this PR using the following package version. |
Collaborator
|
Contributor
Author
|
@cla-avalonia agree |
MrJul
approved these changes
Sep 4, 2026
MrJul
left a comment
Member
There was a problem hiding this comment.
Good catch on ICCCM §4.1.4 not being respected.
Minimizing then hiding the window now works correctly with this PR.
LGTM!
Member
Thank you! The AI disclaimer and manual testing are rare enough these days :) |
Contributor
Author
|
Thanks for the quick review and for testing it! |
3 tasks
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.
What does the pull request do?
DefaultWindowMode.Hide()callsXUnmapWindowonly. ICCCM 4.1.4 requires a client withdrawing a top-level window to also send a syntheticUnmapNotifyto the root window, which this PR now does.What is the current behavior?
When the window manager has already unmapped the window because it is minimized,
XUnmapWindowon an already-unmapped window generates no event, so the window manager never learns that the client withdrew the window and keeps it listed as managed and iconic.For an application that hides to a tray icon, calling
Hide()on a minimized window therefore leaves a stale taskbar entry. Activating that entry maps the window again, butWindow.Hide()has already calledStopRendering()andMapNotifydoes not restart it, so the frame comes back empty. Closing it again does nothing either, sinceWindow.Hide()returns early on!_shown. OnlyShow()from the tray icon restores the content.What is the updated/expected behavior with this PR?
Hide()withdraws the window in that case:WM_STATEis removed and the window leaves_NET_CLIENT_LIST, so no stale entry remains.Tested on KDE Plasma 6.6.6 under XWayland, with a minimal window whose
Closinghandler callsHide(), and with an unmodified v2rayN 7.24.7 build with onlyAvalonia.X11.dllreplaced. Hiding a mapped window still withdraws it correctly: the real and the syntheticUnmapNotifyboth arrive, which is the sequence ICCCM describes. mutter and native X11 sessions were not tested.How was the solution implemented (if it's not obvious)?
The event is built and sent the same way
SendNetWMMessagedoes. Override-redirect windows are skipped, since the window manager does not manage them.No unit test: the behavior depends on the window manager's response, which the X11 test setup does not cover.
Fixed issues
Related to #18148. That report also covers rendering not restarting when the system maps a hidden window, which is not addressed here.
The patch, the testing described above and this description were produced with AI assistance (Claude Code) on my machine. I have reviewed the change and reproduced both the original problem and the fix myself.