phase1geo / Annotator

Image annotation for Elementary OS
GNU General Public License v3.0
209 stars 22 forks source link

Clipboard not fully working for Wayland #62

Closed cmprmsd closed 2 years ago

cmprmsd commented 2 years ago

Hey, great tool!

There is com.github.phase1geo.annotator --use-clipboard in order to get an image from clipboard and edit it directly. This method does not work on Wayland. Also wl-paste | com.github.phase1geo.annotator won't work as there is no flag for stdin.

When you open Annotator and paste an image it will be opened in the editor. However, this is one step that could be skipped.

Also the way how image pasting works, while working on an annotation is quite disturbing. E.g. I annotate an image with 20+ elements and accidentally press ctrl+v. All work is gone, as the revert button does not revert paste but the changes within the editor. This might be worth another issue though.

Keep up the good work!

phase1geo commented 2 years ago

I don't have an immediate answers as to why clipboard pasting via CLI in Wayland does not work. I'm not sure how to go about triaging that issue, but I'll try.

I have gone ahead and created a new issue for the undo pasting issue -- that would be a bug/oversight on my part. #66

phase1geo commented 2 years ago

I have committed a change to the master branch that adds support for reading an image to annotate from standard input.

phase1geo commented 2 years ago

As for the --use-clipboard issue, what is the image filetype that is being copied to the clipboard? I think that on X systems, the default filetype for images is image/png. I see that Annotator is specifically looking for image/png filetypes for images. I'm wondering if that is not sufficient for Wayland.

phase1geo commented 2 years ago

One more thing, in regards to the Control-V issue. I'm wondering how to best deal with this from a UX perspective. I'm proposing a couple of options in regards to how to fix the issue:

  1. Just add full undo support which includes adding back annotation items that were removed when the image was changed.
  2. Add a prompt if the user attempts to change the image being annotated and confirm that they want to do this.
  3. Only support Control-V when no image is shown in the application (i.e., when the application is launched without command-line options).

Your thoughts?

phase1geo commented 2 years ago

I have come up with an implementation for the Control-V issue. See #66 for details.

cmprmsd commented 2 years ago

Thanks I'll test it asap!

cmprmsd commented 2 years ago

Ctrl+V is fixed, great :+1:

The clipboard image type is: image/png according to CopyQ.

Both ways that I would expect to work currently fail.

  1. wl-paste | com.github.phase1geo.annotator
  2. com.github.phase1geo.annotator --use-clipboard

Opening Annotator and then ctrl+v works. Annotator is started with Wayland.

Edit: I missed the parameter -i. No 1. actually works now!

phase1geo commented 2 years ago

The --use-clipboard option should work if the image type copied to the clipboard is image/png (that is what the Annotator clipboard is looking for and that is what Control-V uses as well). Not sure why that doesn't work. On elementary (which still uses X), the --use-clipboard option works as expected. I'll need to do some investigation in that regard. I believe that Fedora uses Wayland these days, so I'll use that for a test environment.

cmprmsd commented 2 years ago

@phase1geo I just noticed, that the buttons to export the image are greyed out, when you pipe to annotator with -i.

Workaround is currently to press ctrl+c and ctrl+v which seems to activate the buttons.

phase1geo commented 2 years ago

I will take a look at that and get it fixed. Thanks!

phase1geo commented 2 years ago

The latest master branch has this UI issue fixed when loading from standard input. Good catch!

cmprmsd commented 2 years ago

Nice! Thank you 👍👍👍