Draft: xfce4-screenshooter cannot capture open popup menus, dropdowns, or combo boxes
Problem
When attempting to screenshot an open popup menu, dropdown, or combo box, the screenshot fails to capture the menu — it either closes before the screenshot is taken, or the screenshot captures the desktop behind it.
This happens because xfce4-screenshooter uses XGrabKeyboard / XGrabKey to listen for the Print key. When a popup menu is open, the menu owns an active X11 keyboard grab. The screenshooter's grab request is rejected, so the shortcut never fires — or the menu dismisses itself when focus changes.
This is a long-standing issue. A related report exists from 2019.
Steps to reproduce
- Open any popup menu (Whisker Menu, right-click context menu, dropdown in a dialog)
- Press
Print - The menu closes and/or the screenshot does not capture the menu
Expected behavior
Pressing Print with a popup menu open should capture the screen including the open menu, without dismissing it.
Proposed solution
XInput2 raw key events (XI_RawKeyPress) bypass all active X11 keyboard grabs. A persistent daemon listening via XI2 receives the Print keypress regardless of what currently owns the keyboard grab.
I have implemented this as --listen mode:
xfce4-screenshooter --listen
The daemon:
- Listens for raw key events via XI2 on a private X display connection
- Reads configurable keybindings from the
xfce4-screenshooterxfconf channel under/listen/bindings/N/{key,region} - Falls back to built-in defaults (
Print→ fullscreen,Shift+Print→ select,Alt+Print→ window) on fresh install — zero configuration needed - Seeds defaults to xfconf on first run so users can customize via
xfconf-query - Registers a DBus service (
org.xfce.Screenshooter) so normal shortcut invocations (xfce4-screenshooter -f) hand off to the daemon instead of double-firing - Reloads bindings live when xfconf changes — no restart needed
- Installs an autostart
.desktopfile to/etc/xdg/autostart/so the daemon starts automatically on login - Handles
SIGTERM/SIGHUPcleanly for session manager shutdown
Files changed
| File | Change |
|---|---|
lib/screenshooter-capture-x11.c |
XI2 listener thread, DBus service, xfconf bindings |
lib/screenshooter-capture-x11.h |
Expose screenshooter_xi2_listen() and screenshooter_xi2_reset_capture()
|
lib/screenshooter-global.h |
Add listen_mode field to ScreenshotData
|
lib/screenshooter-actions.c |
NULL-guard g_object_unref(sd->screenshot), handle Back button in listen mode |
src/main.c |
Add --listen/-l CLI option, DBus handoff, cb_finalize_listen
|
meson.build |
Enable HAVE_XI2 when X11 backend is built |
data/ |
System autostart .desktop file |
Testing
Tested on Linux Mint 22.3 XFCE with xfwm4 compositor:
-
Print→ fullscreen screenshot ✓ -
Shift+Print→ region selector ✓ -
Alt+Print→ active window ✓ - Whisker menu open →
Print→ captures menu ✓ - Daemon dead →
Print→ fallback to normal capture ✓ - Live binding reload via xfconf ✓
- Clean exit on
SIGTERM✓
Branch
feature/xi2-listen-mode on my fork: https://gitlab.xfce.org/newman2x/xfce4-screenshooter
Questions for maintainers
- Is
--listenmode the right approach, or would you prefer a different mechanism? - Should the DBus service name be
org.xfce.Screenshooteror something else? - Should bindings live in the
xfce4-screenshooterxfconf channel or inxfce4-keyboard-shortcuts? - Is
/etc/xdg/autostart/the right place for the daemon autostart entry?