Skip to content

Copy image bytes to clipboard to survive application exit#222

Closed
kjozsa wants to merge 2 commits intoAlexanderVanhee:masterfrom
kjozsa:master
Closed

Copy image bytes to clipboard to survive application exit#222
kjozsa wants to merge 2 commits intoAlexanderVanhee:masterfrom
kjozsa:master

Conversation

@kjozsa
Copy link
Contributor

@kjozsa kjozsa commented Sep 18, 2025

Hi Alexander, I see that the "copy to clipboard" function stops working once I exit Gradia. I fixed that, according to my local testing now the copied screenshot remains in the buffer even after exiting Gradia..

Hope you like that changes and it gets into the next release!

@kjozsa
Copy link
Contributor Author

kjozsa commented Sep 18, 2025

@AlexanderVanhee I consider this the most important improvement of my PRs, because this allows the workflow like ctrl+C, ctrl+Q (exit Gradia), ctrl+V (paste in target app), and helps avoiding the unnecessary switching back-and-forth between target app and Gradia.

@AlexanderVanhee
Copy link
Owner

Thank you for your patch submission,

Your changes don’t seem to fix this on my end. I think the issue is probably just that the app is closing before it finishes copying the image to the clipboard.

The actual fix might be to delay closing the app window until the copying is done, similar to how it works with the “Copy and Close” exit preference.

For now, I think your best option for your specific workflow is to switch to the aforementioned “Copy and Close” exit method in the preferences menu.

@kjozsa
Copy link
Contributor Author

kjozsa commented Sep 19, 2025

Can you check your logs while trying out this branch? Does it fall to any of the 2 fallback cases for you? On my setup (GNOME over Wayland on Arch linux) the primary case runs successfully, copying the image bytes to the system clipboard buffer, and it does the trick..

Honestly, I did not discover the Copy and Close preference. It's actually the ideal way to handle my scenario, but unfortunately it does not work for me with the stable released Gradia - clipboard remains empty after close.. Is it the same issue? Are you testing on Wayland?

@AlexanderVanhee
Copy link
Owner

I'm on Fedora Wayland, it never reaches the fall-backs on my end. Does copying work without you closing? Could you also try the latest patch from the master branch?

@kjozsa
Copy link
Contributor Author

kjozsa commented Sep 19, 2025

Copying and keeping Gradia open makes it work, I can paste it to Slack for example.

I believe closing the app after copying does not work, because the ContentProvider gets dismissed on app close, while pushing the actual pixbuf bytes to the clipboard remains there.

@kjozsa
Copy link
Contributor Author

kjozsa commented Sep 29, 2025

With 1.11.1 both copy after close and copy-on-close works for me with the upstream code - closing this PR.

@kjozsa kjozsa closed this Sep 29, 2025
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