flameshot-org / flameshot

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

Flameshot itself running on XWayland instead of native Wayland #2107

Open oxalica opened 2 years ago

oxalica commented 2 years ago

Flameshot Version

Current master b8c0b74ea22b14c97a9f25c4e34d1b6d640ebaac

Installation Type

Compiled from source

Operating System type and version

NixOS unstable

Description

Flameshot itself is running on XWayland instead of native Wayland, making GUI blurred when using fractional DPI. Checked with xeyes: xeyes animates when moving the cursor under XWayland windows, but stops when the cursor is under native Wayland windows. Setting QT_QPA_PLATFORM=wayland still doesn't work.

Note that the screenshot functionality works, just the GUI, including the rectangle selection window, the config window, and the file saving dialog, are blurred.

Steps to reproduce

  1. export QT_QPA_PLATFORM=wayland
  2. /path/to/flameshot &
  3. /path/to/flameshot config or /path/to/flameshot gui

Screenshots or screen recordings

I'm using 1.25x scaling. Konsole's content and menu texts are sharp, while flameshot config's are blurred.

Screenshot_20211124_084741

System Information

Operating System: NixOS unstable Desktop environment: KDE KDE Plasma Version: 5.23.3 KDE Frameworks Version: 5.87.0 Qt Version: 5.15.3 Kernel Version: 5.10.80 (64-bit) Graphics Platform: Wayland Monitor: Dell 2560x1440, with 1.25x scaling Flameshot: b8c0b74ea22b14c97a9f25c4e34d1b6d640ebaac

Flameshot v0.10.1 (-)
Compiled with Qt 5.15.3
borgmanJeremy commented 2 years ago

Even if we resolve the menu issue flameshot will not properly display a screenshot if you use fractional scaling. We have a long running issue on this with no current ideas.

oxalica commented 2 years ago

Even if we resolve the menu issue flameshot will not properly display a screenshot if you use fractional scaling. We have a long running issue on this with no current ideas.

That's another issue. I created this issue only about flameshot itself running on XWayland. You can assume that I'm only concerning the config window.

borgmanJeremy commented 2 years ago

What's the concern with running on xwayland? (Not confrontational, just dont understand why it's a problem)

xiayesuifeng commented 2 years ago

What's the concern with running on xwayland? (Not confrontational, just dont understand why it's a problem)

When flameshot is run as xwayland on kde wayland, copying to clipboard does not work

C0rn3j commented 2 years ago

It seems the current git makes it worse.

With 0.10.2 it at least copies to clipboard in a way where XWayland apps can access it, but native can't.

On current master it just doesn't work at all.

thep0y commented 2 years ago

Same here. The screenshot is very blurry.

mmahmoudian commented 2 years ago

@thep0y that's not what others wrote in this thread, they said that the Flameshot buttons and other UI elements are blurry whereas you are saying that the screenshot is blurry. Would you press confirm if your Flameshot buttons are OK and only your screenshot is blurry?

@C0rn3j would you please confirm if your screenshot has good quality and only the UI is blurry?

C0rn3j commented 2 years ago

I didn't notice anything being blurry while I was testing, my issue is being able to take screenshots at all.

thep0y commented 2 years ago

@thep0y that's not what others wrote in this thread, they said that the Flameshot buttons and other UI elements are blurry whereas you are saying that the screenshot is blurry. Would you press confirm if your Flameshot buttons are OK and only your screenshot is blurry?

flameshot: 2021-12-14_20-32

actually: Screenshot_20211214_203408

It seems that flameshot cannot correctly identify screen scaling.

mmahmoudian commented 2 years ago

@thep0y From what I see both pictures have the same quality and neither of them are blurry. Am I missing anything?

thep0y commented 2 years ago

@thep0y From what I see both pictures have the same quality and neither of them are blurry. Am I missing anything?

The second picture is not a real-resolution screenshot (from KDE's Spectacle), but it is much clearer than the first picture. You can open the two pictures in a new tab respectively, and you will see the obvious difference in size.

cmidkiff87 commented 2 years ago

Update: It fixes the issue for XWayland applications only (I was testing this in discord, initially. But the solution doesn't work on pinta)


Adding XDG_CURRENT_DESKTOP=sway to your environ list fixes the "copy to clipboard" issue. It works on KDE Plasma at least. It still runs on XWayland though.

I have this script set to launch on login, which takes care of setting the env variables. (I swap between plasma on Wayland and XWayland, which is why the is_wayland() check is there)

import os 
import subprocess

from pathlib import Path

USR_BIN = Path('/usr/bin')

def main():
    if is_wayland():
        env = {
            **os.environ,
            "QT_QPA_PLATFORM": 'wayland',
            "XDG_SESSION_DESKTOP": 'sway'
        }
    else:
        env = os.environ

    subprocess.run(USR_BIN / 'flameshot', env=env)

def is_wayland():
    return os.environ['XDG_SESSION_TYPE'] == 'wayland'

if __name__ == '__main__':
    main()