Skip to content

Enable selection and window capture on Wayland via interactive XDG portal#817

Open
luigimassa wants to merge 2 commits into
shutter-project:masterfrom
luigimassa:feature/wayland-interactive-selection
Open

Enable selection and window capture on Wayland via interactive XDG portal#817
luigimassa wants to merge 2 commits into
shutter-project:masterfrom
luigimassa:feature/wayland-interactive-selection

Conversation

@luigimassa
Copy link
Copy Markdown

Summary

On Wayland, Shutter could only capture the full screen through the XDG desktop portal. The Selection, Window and Active Window modes were disabled because they rely on X11 (Wnck/GdkX11), which cannot enumerate or grab other windows under Wayland's security model (#187).

This PR routes those modes to the portal's interactive mode instead: the compositor (e.g. GNOME) shows its own native picker (area / window / screen) and returns an already-cropped image into Shutter's existing post-capture flow.

Changes

  • Wayland.pm: xdg_portal() takes an $interactive flag and adds the interactive boolean option to the Screenshot portal request (typed via Net::DBus::dbus_boolean). The full-screen request is byte-for-byte unchanged. A portal Response of 1 (user cancelled) now maps to error code 5 (aborted by user) instead of 9, so cancelling the picker shows no error dialog.
  • bin/shutter:
    • the Wayland guard now lets full/select/window/awindow through;
    • the capture dispatch routes select/window/awindow to xdg_portal($s, 1) on Wayland;
    • the Selection and Window buttons/menu items (toolbar and tray) are enabled on Wayland.

Out of scope (Wayland limitations)

  • Menu and tooltip capture stay disabled (not supported by the portal).
  • Window-by-name/regex (--window=PATTERN) and fixed-geometry selection (-s=X,Y,W,H): the portal accepts neither a target nor coordinates.
  • The workspace/window dropdown menus still require X11 to enumerate.

Testing

  • perl -c passes on both modified files.
  • Manually verified on a GNOME Wayland session: Selection and Window buttons open GNOME's native picker, the captured image lands in Shutter's normal flow, and cancelling the picker produces no error dialog.
  • Xorg and full-screen Wayland behaviour unchanged.

Refs #187

luigimassa and others added 2 commits May 21, 2026 10:49
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…G portal

On Wayland, Shutter could only capture the full screen through the XDG
desktop portal; the Selection, Window and Active Window buttons were
disabled because they rely on X11 (Wnck/GdkX11), which cannot enumerate
or grab other windows under Wayland's security model (issue shutter-project#187).

This routes those modes to the portal's interactive mode instead, where
the compositor (e.g. GNOME) shows its own native picker (area/window/
screen) and returns an already-cropped image into Shutter's existing
post-capture flow.

Changes:
- Wayland.pm: xdg_portal() takes an $interactive flag and adds the
  `interactive` boolean option to the Screenshot portal request (typed
  via Net::DBus::dbus_boolean). The full-screen request is unchanged.
  A portal Response of 1 (user cancelled) now maps to error code 5
  (aborted by user) instead of 9, so cancelling the picker shows no
  error dialog.
- bin/shutter: the Wayland guard now lets full/select/window/awindow
  through; the capture dispatch routes select/window/awindow to
  xdg_portal($s, 1) on Wayland; the Selection and Window buttons/menu
  items (toolbar and tray) are enabled on Wayland. Menu and tooltip
  capture stay disabled (not supported by the portal); the workspace/
  window dropdown menus still require X11 to enumerate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant