Let xrdp repair stuck keyboard and mouse state on reconnect
An xrdp reconnect can leave a virtual mouse button or key down. A stuck mouse button creates an X11 pointer grab, so every window appears unable to receive clicks even though XFCE and the taskbar are still alive. The old workaround was to click the stuck button once; a reconnect hook can repair both devices automatically without destroying the desktop session.
Keep the session alive in /etc/xrdp/sesman.ini:
KillDisconnected=false
DisconnectedTimeLimit=0
ReconnectScript=reconnectwm.sh
ReconnectScript is the important part. It runs when xrdp-sesman reconnects a client to an existing session. Put the repair command in /etc/xrdp/reconnectwm.sh:
#!/bin/sh
/usr/local/bin/rdp-input-reset >/dev/null 2>&1 || true
The helper only resets a device when X reports a key or button still down:
#!/bin/sh
set -eu
for name in xrdpMouse xrdpKeyboard; do
id=$(xinput list --id-only "$name" 2>/dev/null || true)
[ -n "$id" ] || continue
if xinput query-state "$id" | grep -Eq '(key|button)\[[0-9]+\]=down'; then
xinput disable "$id"
xinput enable "$id"
fi
done
Run the helper manually when the connection has not dropped:
DISPLAY=:10.0 XAUTHORITY="$HOME/.Xauthority" rdp-input-reset
This is safer than restarting xfwm4, the panel, or the whole desktop: it clears the stale XRDP input devices while preserving windows, terminals, and the session. It is not magic—the hook only runs for a reconnect to an existing session. If the connection remains open while input gets stuck, run the helper manually. KillDisconnected=true is a stronger isolation workaround, but it eventually kills the disconnected desktop, so it is the wrong trade-off for a persistent RDP session.