Repository navigation
Fix copy failure on GNOME via GUI - #4363
Conversation
My suspicion is that GNOME and specifically Mutter requires specific trusted context for the QtClipboard (from 'kf.guiaddons: Could not init WaylandClipboard, falling back to QtClipboard.') clipboard operation. This means that a visible window must provide the clipboard data. Since the daemon has no visible window, this is a workaround that makes the 'flameshot gui' window handle the copying with a slight delay using QTimer to ensure that GNOME has requested the clipboard data and saved it. This seems like a better solution flameshot-org#4355 as no helper windows are needed, since we already have the 'flameshot gui' window and can use it. I've limited it to GNOME only as I cannot easily test in other environments. Fixes flameshot-org#4116, flameshot-org#4298
|
Thanks for the PR. This looks like a much cleaner approach. I wonder if 150 nanoseconds in QTimer is arbitrary, based on trial and error, or it has some connections with mutter's interal logic? |
|
I tried to compile and install it, but clipboard copy still does not work. I have Fedora 42 |
It is arbitrary. Unfortunately I couldn't find a more precise method for this, so I just arrived at this 150ms delay. I'd be happy if someone comes with something more deterministic, maybe I can look into it further too in the following days.
I just tested this on a freshly installed Fedora 42 Workstation and clipboard copy worked as expected after the patch. Could you confirm you've fully rebuilt after applying the patch, and also ensure that you're using the newly-built binary? |
|
Thanks for this, it at least can put us on the right track. I'm a bit hesitant to merge it since its a somewhat arbitrary delay. Is there a reason the full screen capture widget cannot act as the visible window before its closed? For example have the clipboard data saved while the UI is fullscreen, before its closed? Do you have any references from Gnome that explains this behavior we could link to to keep track of it? |
|
Thanks @borgmanJeremy for the feedback, I took another shot at this. The arbitrary 150ms delay is now gone. The GUI capture widget now provides the clipboard data directly and stays alive only until the compositor actually requests it. For this deterministic behavior, I introduced a small helper class,
That’s exactly what happens now: the capture window itself calls
The behaviour comes from Mutter’s Wayland clipboard implementation: src/wayland/meta-wayland-data-device.c, the key method is Once GNOME has accepted the selection, its clipboard manager copies the data into its own buffer so it can keep serving it after the original client goes away. That logic is defined in src/core/meta-clipboard-manager.c, primarily in Just a heads up that I’m by no means deeply familiar with Mutter. But with the current patch the copy succeeds on GNOME 48. |
borgmanJeremy
left a comment
There was a problem hiding this comment.
Thanks! This approach makes much more sense to me in the long run. I want to test on gnome before merging but can do that in the next couple of days. Thanks again.
|
|
||
| // Safety net: force close after 500ms if compositor never fetches | ||
| QTimer::singleShot(500, keepAlive, [keepAlive]() { | ||
| if (keepAlive) |
There was a problem hiding this comment.
Can you add a warning to the log if this happens? If we get bug reports of the clipboard not working it would be good to know if it was due to this timeout.
Just to give an additional data point: I tested your changes on Fedora 43 (gnome-shell 49.1, mutter 49.1.1) and copying to the clipboard worked flawlessly 🎉 |
|
Sorry about the clang-format, I'm ready to merge this once thats resolved (assuming the rest of the CI passes). |
|
Of course, applied clang-format, hopefully it is good now. |
|
This works on NixOS 25.11 under Gnome with Wayland too, where the stock v13.3.0 was broken. Here is the nix overlay file I used to build it: flameshot-on-gnome-wayland.nix (I had to rename it to a |
|
Does anyone know when we can expect a new release? I would love to have this fix available without building from source, but I couldn't find anything regarding a release schedule ^^ |
|
@B4T3S no stable release is planned yet. There are few Wayland issues that we are trying to fix before a release. Stay tuned, and until then , building from source is super easy and straightforward: |
Alright! Thanks for the reply ^^ Just would've been nice to be able to rely on my package manager to update for me, instead of having to check in every now and then to see when the new release is out and I can switch back |
Haha, same for me 😉 |
|
This is a serious enough bug that it deserves a bug-fix release at least.
Can we not let the perfect be the enemy of the good? New releases don't need to wait for everything known to be fixed. You will never do a new release if you follow that philosophy. New releases should be made any time there is any bugfix available, IMO. Anyone wanting a new package on Fedora could go vote on the Fedora Bugzilla issue I just opened to have this patch landed to their package while we wait here for a new release. While you wait for that, I have rebuilt the current Fedora flameshot with this patch included in my copr repo for Fedora 42, 43 and rawhide. |
* Fix copy failure on GNOME My suspicion is that GNOME and specifically Mutter requires specific trusted context for the QtClipboard (from 'kf.guiaddons: Could not init WaylandClipboard, falling back to QtClipboard.') clipboard operation. This means that a visible window must provide the clipboard data. Since the daemon has no visible window, this is a workaround that makes the 'flameshot gui' window handle the copying with a slight delay using QTimer to ensure that GNOME has requested the clipboard data and saved it. This seems like a better solution flameshot-org#4355 as no helper windows are needed, since we already have the 'flameshot gui' window and can use it. I've limited it to GNOME only as I cannot easily test in other environments. Fixes flameshot-org#4116, flameshot-org#4298 * Keep capture window alive until GNOME fetches clipboard data * Move the GNOME clipboard workaround in screenshotsaver.cpp * Log GNOME clipboard timeout and restore success notification * Apply linter fixes
Upstream release candidate (tag v14.0.rc1, internal FLAMESHOT_VERSION 14.0.0). Follow Fedora pre-release convention: Version: 14.0~rc1 with %autorelease -p, yielding Release 0.1.fc44. - Drop 0001-fix-copy-failures.patch; flameshot-org/flameshot#4363 is merged into v14.0.rc1. - Bump bundled Qt-Color-Widgets to 5d52e907e5 (tracks upstream FetchContent pin; library version still 2.2.0, Provides unchanged). - Pass -DDISABLE_UPDATE_CHECKER:BOOL=ON (new upstream option; Fedora disables auto-update checks per packaging guidelines). - Introduce %global src_tag so Source0 can reference the literal GitHub tag "v14.0.rc1" while %{version} uses the Fedora ~rc1 form. - %autosetup -n %{name}-%{src_tag}, matching the tarball top dir. Verified via fedpkg --release f44 mockbuild --enable-network; all four RPMs build cleanly, %check (appstream + desktop-file-validate) passes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upstream release candidate (tag v14.0.rc1, internal FLAMESHOT_VERSION 14.0.0). Follow Fedora pre-release convention: Version: 14.0~rc1 with %autorelease -p, yielding Release 0.1.fc44. - Drop 0001-fix-copy-failures.patch; flameshot-org/flameshot#4363 is merged into v14.0.rc1. - Bump bundled Qt-Color-Widgets to 5d52e907e5 (tracks upstream FetchContent pin; library version still 2.2.0, Provides unchanged). - Pass -DDISABLE_UPDATE_CHECKER:BOOL=ON (new upstream option; Fedora disables auto-update checks per packaging guidelines). - Introduce %global src_tag so Source0 can reference the literal GitHub tag "v14.0.rc1" while %{version} uses the Fedora ~rc1 form. - %autosetup -n %{name}-%{src_tag}, matching the tarball top dir. Verified via fedpkg --release f44 mockbuild --enable-network; all four RPMs build cleanly, %check (appstream + desktop-file-validate) passes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>


My suspicion is that GNOME and specifically Mutter requires specific trusted context for the QtClipboard (from 'kf.guiaddons: Could not init WaylandClipboard, falling back to QtClipboard.') clipboard operation. This means that a visible window must provide the clipboard data. Since the daemon has no visible window, this is a workaround that makes the 'flameshot gui' window handle the copying with a slight delay using QTimer to ensure that GNOME has requested the clipboard data and saved it.
This seems like a better solution to #4355 as no helper windows are needed, since we already have the 'flameshot gui' window and can use it. I've limited it to GNOME only as I cannot easily test in other environments.
Fixes #4116, #4298