RajSolai / TextSnatcher

How to Copy Text from Images ? Answer is TextSnatcher !. Perform OCR operations in seconds on Linux Desktop.
https://textsnatcher.rf.gd/
GNU General Public License v3.0
1.26k stars 45 forks source link

Clipboard empty when using "Take Screenshot" option #25

Open Lucas-Steinmann opened 2 years ago

Lucas-Steinmann commented 2 years ago

As the title says, the clipboard is not filled when using the "Take Screenshot" option. The other options ("Choose File" and "Get from Clipboard") work fine.

For debugging purposes, I've compiled the app myself and added instructions to print the result when taking a screenshot. The text was printed successfully. That means the OCR works, but writing to the clipboard does not work.

I'm using Wayland with Gnome. I installed the app via flatpak. I suspect a security feature of Wayland is preventing the app to write to the clipboard. In Wayland, regular apps can only write/read to clipboard when they are focused. Since directly after taking a screenshot, TextSnatcher is not focused, it is not able to write to the clipboard.

I've tested this hypothesis by making a large screenshot and clicking into the TextSnatcher window. This sets the focus back to TextSnatcher. While the app seems to be frozen (maybe worth another issue), it appears to get focus, since now it successfully writes to the clipboard.

But this is not a solution, since for small screenshots, the user will not be able to change the window quickly enough (and it would be user-friendly anyway).

My only idea to solve this issue is to add a button to copy to the clipboard manually.

But other features, such as printing the result into a text label UI element, could possibly also improve usability. E.g. users could then quickly decide to retake the screenshot or copy the text, with the button. The button could also be implemented first, to fix this issue, and the text label could be added later as a UI improvement.

I also wonder why nobody else has this issue. Am I missing something?

RajSolai commented 2 years ago

Thanks a lot for letting me know this issue of clipboard r/w on Wayland, the idea of having a button for manual clipboard is great. About the app freezing on OCR I will find a solution and patch it on next release.

geometry1 commented 2 years ago

I am having the exact same issue. I am on Fedora 36 (Silverblue), so GNOME 42 and Wayland. I have TextSnatcher installed as a Flatpak. After seeing this issue I made some tests with focused/non-focused TextSnatcher window and can confirm exactly the findings of @Lucas-Steinmann .