Skip to content

Added Wayland support via interactive or non-interactive call - #818

Open
Photon89 wants to merge 15 commits into
masterfrom
wayland-support
Open

Added Wayland support via interactive or non-interactive call#818
Photon89 wants to merge 15 commits into
masterfrom
wayland-support

Conversation

@Photon89

@Photon89 Photon89 commented May 25, 2026

Copy link
Copy Markdown
Member

This PR is based on #817. However, it now tries to use an non-interactive target as defined in flatpak/xdg-desktop-portal#1981. If a target is not yet implemented by a DE, it falls back to an interactive call which shows the DE's interactive mode chooser. As soon as a DE implements the non-interactive targets, Shutter should pick them up and not call the interactive mode chooser any more. Also, the full screen capture is unaffected.

Tested for various DEs:

  • For Gnome the interactive mode chooser works quite well. Limitations: The user needs to choose the capture mode again (after having chosen it in Shutter). Filenames are still set to "unknown".
  • For KDE the interactive mode chooser seems to offer no selection mode. Also there seems to be no window selection mode, only capturing the active window is possible, which is the mode chooser dialog itself though. So in KDE this PR is basically useless.
  • For Cinnamon the interactive mode chooser is not really implemented and always falls back to full screen capture.

Tested non-interactive targets:

@Photon89
Photon89 requested a review from DarthGandalf May 25, 2026 15:23
Comment thread bin/shutter Outdated
@mvivarelli

Copy link
Copy Markdown

Hi Michael,

I'm Maurizio. I wrote the gnome-screenshot hack for Ubuntu 24.04.

I was looking for a solution to extend Shutter's life on Ubuntu 26.04, where gnome-screenshot no longer works.

I tested your PR just now, and it seems to be a temporary but nevertheless pretty usable solution.

Thanks,

Maurizio

@Photon89

Copy link
Copy Markdown
Member Author

Hi Maurizio,

great, thanks for testing! As Gnome hasn't implemented non-interactive targets so far, Shutter has to fall back to the interactive mode chooser. That's actually worse than what you have implemented in your PR. And the sad news is that the non-interactive calls will be supposedly forwarded to gnome-screenshot once they have been implemented, so yeah... At least that's what happens in Cinnamon so far.

Let's hope that this will be good enough for potential users. I guess, we've lost many of them due to lacking Wayland support...

@Photon89 Photon89 linked an issue Aug 9, 2026 that may be closed by this pull request
Comment thread bin/shutter Outdated
$supported_targets{'1'} = 1 if ($targets_raw & 1);
$supported_targets{'2'} = 1 if ($targets_raw & 2);
$supported_targets{'4'} = 1 if ($targets_raw & 4);
$supported_targets{'8'} = 1 if ($targets_raw & 8);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the non-raw version use names instead of digits? Or reverse, even keep it as raw number and check & directly?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I'll rework it to use names!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in latest commit!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the names cannot be directly passed to xdg-portal, so we need to convert them back to numbers in Wayland.pm before they are passed to xdg-portal. Maybe it's actually better to keep the numbers?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with numbers, but then you don't need distinguishing between "raw" numbers and "non-raw" numbers

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the latest commit, is this better now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that looks simpler. Added a comment about a comment

sub xdg_portal {
my $screenshooter = shift;
my $interactive = shift;
my $target = shift;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does target mean? some comments would help

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments!

Comment thread bin/shutter Outdated
# For some period of time desktops won't support non-interactive targets, we need to deal with it.
my $target;
my $interactive;
# For fullscreen capture just use plain xdg_portal

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't that show the interactive prompt even on supporting compositors?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the full screen case? I'm not sure, that's the very early Wayland.pm which you wrote, I haven't looked inside tbh. For the moment, I didn't want to change anything with full screen capture because I assumed that it works well already. Do you know what the status actually is with full screen capture?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I did is a horrible hack :)

the problem with "my" method is that depending on compositor it will either show the prompt, or it won't, and shutter cannot detect that. This spawned the discussion in the first place.

I randomly put it to "fullscreen" button of shutter just because I needed to put it somewhere. It could as well be a new button which invokes the compositor-specific prompt (or even does screenshot without prompt, we never know); but depending on what users selects in that prompt in may not in fact be fullscreen.

If the specific implementation of the portal reports that it supports promptless fullscreen target, we should use that

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the specific implementation of the portal reports that it supports promptless fullscreen target, we should use that

I see, will do! :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@DarthGandalf

Copy link
Copy Markdown
Member

I cannot find where you commented about #828 but yes, these PRs do conflict. But adding non-interactive fullscreen screenshot should help with per-monitor screenshot of that PR too. And non-interactive screenshot should be repeatable too, not just ones which happen to be interactive (or not) depending on DE

@Photon89

Copy link
Copy Markdown
Member Author

I cannot find where you commented about #828 but yes, these PRs do conflict. But adding non-interactive fullscreen screenshot should help with per-monitor screenshot of that PR too. And non-interactive screenshot should be repeatable too, not just ones which happen to be interactive (or not) depending on DE

Yeah, my comment was wrong so I deleted it, but the conflict is nevertheless there. I will try to figure out how to solve it.

@Photon89

Copy link
Copy Markdown
Member Author

Is there anything to improve here besides of compatibility with #828?

@DarthGandalf

Copy link
Copy Markdown
Member

I can't easily test it, as I don't use wayland, but if you tested it, fine. Yeah, #828 is probably the only thing

@Photon89

Copy link
Copy Markdown
Member Author

I did some testing in VMs before the latest changes. Will now also test full screen and report back.

@DarthGandalf

Copy link
Copy Markdown
Member

btw, we need to get some way to test all the wayland stuff in CI

no clue if somethig like Xvfb exists

@Photon89

Copy link
Copy Markdown
Member Author

Absolutely, could you look into it when time permits?

I also noticed that the file name in Wayland is still just unknown_%nn.png, we can at least make it depend on the chosen mode if Wayland refuses to pass the window's name.

@vadi2

vadi2 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

xvfb does work in CI, I use it. Just using xvfb-run in a script works.

@DarthGandalf

Copy link
Copy Markdown
Member

@vadi2 That's what unit tests are doing here now. But it's X, not wayland. Or can wayland work on top of xvfb?

@vadi2

vadi2 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Ahh, my bad. I haven't tried xvfb, but Claude was able to spin up a new gnome shell in Wayland for testing for me previously.

@Photon89

Photon89 commented Aug 15, 2026

Copy link
Copy Markdown
Member Author

So I implemented generic file names for Wayland capture. Since they cannot be acquired from xdg-portal, they are taken directly from the capture mode and can be "Workspaces", "Window" or "Selection w x h". Of course, specific window names won't work, and also no workspace numbers.

I'm not sure why it is called "Workspaces" instead of just "Workspace", but it was this way in X11 already (what happens when you just choose the "full" capture mode. On my machine using Compiz, you just get the currently active workspace when using "full", so it is weird to be called "Workspaces". But this is the string which gettext knows, so I kept it this way.

I now tested in Gnome and KDE. In both cases there is currently only the interactive API available.

In Gnome (Fedora latest, should be Gnome 50) you have once more choose the mode that you actually intend to use, but at least all three modes are supported (full screen, window, selection) and work well.

In KDE (tested in 6.2.5 and 6.6.5) you also have to once more choose the mode but, making things worse, there is no selection mode, not even interactively.

I think, currently it is a better UX to fall back to the "hackish" full screen capture, because most DEs don't support it via non-interactive capture so far. What do you think?

@DarthGandalf

Copy link
Copy Markdown
Member

I think, currently it is a better UX to fall back to the "hackish" full screen capture, because most DEs don't support it via non-interactive capture so far. What do you think?

as fallback, sure.

@Photon89

Copy link
Copy Markdown
Member Author

Okay, done, so we at least don't get a downgrade by this PR.

Ready to merge once the merge conflicts are sorted out. Question is, which PR we merge first. I looked into the conflicts and they are actually not so bad. One conflict in Wayland.pm and three one line conflicts in the main shutter file.

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.

Selection button inactive (was: Shutter does not work in Wayland)

4 participants