Repository navigation
fix(launcher): end the RemoteApp session when the application window closes - #993
Open
X-IOT-study wants to merge 1 commit into
Open
X-IOT-study wants to merge 1 commit into
X-IOT-study wants to merge 1 commit into
Conversation
… closes Environment ----------- - WinApps (winapps-org/winapps, main at 0b950dc) driving xfreerdp 3.33.0 - Ubuntu 22.04, GNOME Shell on X11, Windows 11 in a libvirt VM - RemoteApp launch: /app:program:...,hidef:on,/wm-class:"<application name>" Problem ------- Closing a RemoteApp window (e.g. Microsoft Word) does not end the RemoteApp session. Windows keeps the session alive, so the xfreerdp process stays connected and the RAIL windows the server created for helper windows stay mapped. With a Windows input method active these include "Microsoft Text Input Application" windows; one of them is a 170x59 override-redirect floating toolbar that remains visible on the Linux desktop after the application is gone. Being override-redirect, it has no decorations, so the window manager cannot close it, and it only disappears when the FreeRDP process exits. Fix --- While waiting for FreeRDP to exit, watch the managed windows of the application's WM_CLASS (the value passed to /wm-class). Once the window has been gone for 10 seconds (five 2-second polls, which also covers save dialogs and windows that are re-created), terminate the FreeRDP process; that destroys all of its X windows, helper windows included. - New configuration option EXIT_WITH_APP (default 'on'). Set it to 'off' for applications that are expected to keep running without a window. - Only applies to application launches that pass /wm-class. Full desktop ('windows') and 'manual' launches keep the previous behaviour. - If wmctrl is unavailable, or the window list cannot be read (e.g. on a Wayland session), the previous plain wait is used and nothing is killed. Verified on the setup above: with four "Microsoft Text Input Application" windows present, clicking Word's own close button left them on screen for the grace period, then the session terminated and no RAIL windows remained. Signed-off-by: X-IOT-study <2453395023@qq.com>
Member
|
Personally I dislike the idea of using wmctrl as it is x11 specific. X11 is end of life and even freerdp starts adding rails to wayland. I therefore don't like to add x11 features only, since it is expected that most users will use wayland in the future (especially with big distros/wms dropping x11). I would highly prefer a solution that works on Wayland and x11. At first glance this seems pretty much possible since it shouldn't have to need WM specific code. |
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.
Problem
Closing a RemoteApp window does not end the RemoteApp session. Windows keeps the session alive, so
xfreerdpstays connected and the RAIL windows the server created for helper windows stay mapped.With a Windows input method active this is visible as floating windows left behind after the application is gone — on this setup four
Microsoft Text Input Applicationwindows, one of them a 170×59 override-redirect toolbar that stays on the Linux desktop. Since it is override-redirect it has no decorations, so the window manager cannot close it, and it only goes away when the FreeRDP process exits. Restarting the application afterwards then piles up more of them.Fix
While waiting for FreeRDP to exit, watch the managed windows belonging to the application's
WM_CLASS(the same value that is passed to/wm-class). Once the window has been gone for 10 seconds — five 2-second polls, which also covers save dialogs and windows that are re-created — terminate the FreeRDP process. That destroys all of its X windows, helper windows included.EXIT_WITH_APP, defaulton. Set it toofffor applications that are expected to keep running without a window; that restores the previous behaviour exactly./wm-class.winapps windows(full desktop) and themanualflavour are untouched.wmctrlis unavailable, or the window list cannot be read (e.g. a Wayland session), the previous plainwait "$FREERDP_PID"is used and nothing is killed.HIDEF.Tested configuration
WAFLAVOR="libvirt"/app:.../hidef:on,/wm-class:"Microsoft Word"), WinAppsmainat 0b950dcWith four
Microsoft Text Input Applicationwindows present, clicking Word's own close button left them on screen for the grace period; the session then terminated and no RAIL windows remained. Also verified with Alt+F4, and thatwinapps windowsstill waits on FreeRDP as before.Notes
AI assistance disclosure
Per
CONTRIBUTING.md: this change was developed with Claude Code assistance. The author reviewed the resulting code, understands the shell logic, and can answer questions about it; the change is small and was verified end-to-end on the configuration above.