Skip to content

Support menu and tooltip captures on Wayland - #840

Open
yeager wants to merge 4 commits into
shutter-project:masterfrom
yeager:fix-wayland-portal-cancellation
Open

yeager wants to merge 4 commits into
shutter-project:masterfrom
yeager:fix-wayland-portal-cancellation

Conversation

@yeager

@yeager yeager commented Sep 11, 2026 •

Copy link
Copy Markdown

Menu and tooltip capture are disabled on Wayland even though the screenshot portal can capture the desktop with these popups visible. Enable both actions in the toolbar, menus, tray, and CLI. Re-enable their existing configurable countdown, request a non-interactive desktop screenshot, then let the user select the popup from the frozen image. Moving the pointer to select a region therefore cannot dismiss the captured popup.

Wayland does not expose X11's popup enumeration through this portal, so these modes require manual region selection after capture. The selector uses source-image coordinates at any preview zoom, rejects empty selections, and treats Cancel/Escape as an abort. Repeating a successful popup capture waits for the configured delay again. Portal authorization remains handled by the desktop; a first-use permission prompt can require reopening the popup and retrying. The legacy portal request omits the version-3 target option, while target-aware portals receive the desktop target.

Also fixes portal cancellation falling through an eval block into image processing: area cancellation could call get_width() on an undefined pixbuf, and failures could create history. Errors and cancellation now return before postprocessing; cancelling a repeat preserves the previous successful history. Keep a concise Wayland notice explaining that available capture modes depend on the desktop environment and some modes require manual selection. This replaces the blanket recommendation to switch to Xorg without implying that every portal backend supports every mode.

Validation:

  • Full CI test command under Xvfb passes: 10 files, 211 top-level tests.
  • Regression coverage includes all four ordinary targets, menu/tooltip and tray variants, legacy and target-aware options, portal and crop cancellation, errors, recovery, and repeat capture.
  • Actual GTK selector tests cover confirm/cancel/window close, source-pixel accuracy at scaled zoom, bounds, and independent cropped buffers. The 4K preview test also passes with G_DEBUG=fatal-criticals.
  • Local GNOME/Wayland tests on Ubuntu 26.04 exercised real portal capture and manual cropping in both popup modes. Separate native GTK Wayland fixtures visually confirmed that an open menu and a popup with the tooltip type hint are present in the captured pixels.
  • The cancellation regression reproduces the crash on the unmodified base. Real-portal cancellation remains covered by mocked response tests rather than a confirmed manual cancellation.
  • git diff --check passes.

@yeager yeager changed the title Fix Wayland portal cancellation before screenshot postprocessing Fix Wayland cancellation and remove the outdated Xorg warning Sep 11, 2026
@Photon89

Copy link
Copy Markdown
Member

I don't think, we should remove the warning because even with the non-interactive targets being supported by Shutter now, most DEs still don't support them on their backend, so for the user the functionality won't be there.

@yeager yeager changed the title Fix Wayland cancellation and remove the outdated Xorg warning Support menu and tooltip captures on Wayland Sep 11, 2026
@yeager

yeager commented Sep 11, 2026

Copy link
Copy Markdown
Author

@Photon89 Agreed. Restored the notice in c385f39 with this wording:

“Available capture modes on Wayland depend on your desktop environment. Some modes require manual selection.”

It keeps the backend limitation visible without recommending a switch to Xorg. The PR description now states that limitation too. Local testing was on GNOME/Wayland; I haven't verified other desktop environments.

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.

2 participants