flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:
https://flameshot.org
GNU General Public License v3.0
24.22k stars 1.55k forks source link

Broken copy on Wayland (Hyprland) #3329

Open alba4k opened 10 months ago

alba4k commented 10 months ago

Flameshot Version

Flameshot v12.1.0 (a7e0a618)

Installation Type

User repository (AUR)

Operating System type and version

Arch Linux (up-to-date)

Description

When copying big images to the clipboard, they will often get corrupted.

I am branching this off from https://github.com/flameshot-org/flameshot/issues/2978, since I believe having this as a separate, more specific, issue might be more useful.

Also, I'm unable to paste them in most apps (I can, however, in tg desktop). I was only able to paste the images posted here thanks to telegram. I sent them there first, saved those images and posted them here.

Having a daemon running and using flameshot full -c will result in the daemon outputing

flameshot: info: Capture saved to clipboard.
maximum memory limit (134217728) would be exceeded
cannot create matrix
cannot encode main body
jpc_encode failed
jpc_encode failed

Steps to reproduce

flameshot full -c or flameshot gui with a big region Try to paste

Screenshots or screen recordings

I am also getting a lot of artifacts, the preview looks fine, the screenshots however sometimes get weird:

immagine

image_2023-07-20_19-07-50

sample image 2 ![immagine](https://github.com/flameshot-org/flameshot/assets/84153269/5e6342ff-f577-46af-a457-98aea2e4005a)

image_2023-07-20_19-10-43

getting those images took quite a lot of attempts lol (got them using `flameshot full -c)

This is what those images are supposed to look like ![immagine](https://github.com/flameshot-org/flameshot/assets/84153269/0726341c-f86e-4dce-8765-c71a24fe4b87)

System Information

  1. Arch Linux
  2. Not relevant
  3. Hyprland (Wayland)
  4. I am using wl-clip-persist, but that doesn't seem to apply to flameshot as I still need a running daemon
SalamandraDevs commented 10 months ago

I can confirm this on Kubuntu 23.04 with Wyland.

alba4k commented 10 months ago

@SalamandraDevs Mind sharing some samples, just to confirm we're having the same issue?

januszmk commented 10 months ago

I experienced this issue too, when pasting screenshot to slack - the image is not fully rendered. still works with uploading it to imgur. it could be related to #3059

FelixJochems commented 9 months ago

Im currently working on a custom fork. But can confirm this is, at least in part, due to the different code that runs when copying to clipboard (might be wayland/qt specific). I've been looking into it, but it's difficult to debug. Not being able to paste it into certain applications has to do with this + some MIME stuff. With the same clipboard you sometimes can't paste into firefox but pasting into GIMP usually works. Is everyone in this thread running wayland? That might help narrow it down

alba4k commented 9 months ago

@FelixJochems Hyprland only runs on Wayland

alba4k commented 8 months ago

Could this be QT's fault? telegram desktop also has the same issue sometimes when copying an image from within the program

kurkii commented 7 months ago

Im having the same issue using Hyprland. Here, where im pasting it to Schildichat, the image gets cut off. The resolution seems to stay the same, but clearly the entire image doesnt get rendered, resulting in most of the screenshot being blank. What I found interesting is that the image file size always ends up being related to two (dont know how to say it in english, but: 32, 64, 128). In this example the image is 64kb large.

This only happens when copy and pasting images, saving them to a file and then uploading them works fine.

example

alba4k commented 7 months ago

Yeah the issue seems to be completely related to the clipboard

gwstorm commented 7 months ago

I have had the same issue for a while and my "workaround" is using copyq. When I copy something from flameshot, it's guaranteed to be corrupted, however, if I then grab that copy from the immediate history in copyq, it's fine. I can then paste it anywhere.

alba4k commented 7 months ago

would you mind clarifying what you're doing exactly?

edit: actually, same when using cliphist

gwstorm commented 7 months ago

Sure, sorry for the brevity.

  1. Open flameshot and select area

  2. Click on the copy button, or ctrl+c to copy the selected area.

  3. Corrupt screenshot is produced and I can't utilize that copy anywhere.

  4. Click on CopyQ to see clipboard history and double click the copied image I just grabbed to re-add it to my clipboard

  5. Paste anywhere and enjoy.

alba4k commented 7 months ago

yeah sorry I just didn't know what copyq was

cliphist does the same

eliminat commented 5 months ago

Can confirm the same behavior only after moving from i3 to sway. Have followed all recommendations for Wayland in the documentation without improvement. Pasting into an actual image program like Nomacs, geeqie, gwenview, etc pastes normally and I can then copy out of that into the programs where I would only get a partial paste from flameshot such as Discord, Teams, firefox, etc. successfully. I read about the copyq workaround above and confirm that also works for me.

zeykafx commented 2 months ago

Instead of going through cliphist or other tools, you can just use flameshot gui --raw | wl-copy as mentioned in this comment https://github.com/flameshot-org/flameshot/issues/2848#issuecomment-1368644640

IrrerPolterer commented 2 months ago

Based on @zeykafx' comment above, I came up with this workaround that does what I want:

XDG_CURRENT_DESKTOP=Sway \
flameshot gui --raw > /tmp/screenshot.png && \
wl-copy < /tmp/screenshot.png && \
mv /tmp/screenshot.png ~/Pictures/Screenshots/$(date "+%Y-%m-%d_%H-%M-%S").png

In my hyprland configuration:

bind = , Print, exec, XDG_CURRENT_DESKTOP=Sway flameshot gui --raw > /tmp/screenshot.png && wl-copy < /tmp/screenshot.png && mv /tmp/screenshot.png ~/Pictures/Screenshots/$(date "+%Y-%m-%d_%H-%M-%S").png

This solves multiple issues:

GoodMirek commented 2 months ago

Is everyone in this thread running wayland? That might help narrow it down

The issue happens to me only under Wayland (sway). On Xorg (i3wm) it works fine.