flameshot-org / flameshot

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

Allow to run in native wayland for GNOME #3473

Open darkblaze69 opened 5 months ago

darkblaze69 commented 5 months ago

Flameshot Version

3d21e496

Installation Type

Compiled from source

Operating System type and version

GNOME 45

Description

As of now flameshot explicitly doesn't allow to run in GNOME, native wayland mode (DISPLAY=) or in wayland-only session (gnome-shell --no-x11). Please allow us to run in native Wayland (no XWayland). It should be up to user to specify QT_QPA_PLATFORM. https://github.com/flameshot-org/flameshot/blob/3d21e4967b68e9ce80fb2238857aa1bf12c7b905/src/main.cpp#L38-L45

On launching it crashes and says:

Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

And manually overriding doesn't help QT_QPA_PLATFORM=wayland flameshot

For me this patch works by removing "wayland_hacks":

diff --git a/src/main.cpp b/src/main.cpp
index d631b476..68725107 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -33,18 +33,6 @@
 #include <desktopinfo.h>
 #endif

-#ifdef Q_OS_LINUX
-// source: https://github.com/ksnip/ksnip/issues/416
-void wayland_hacks()
-{
-    // Workaround to https://github.com/ksnip/ksnip/issues/416
-    DesktopInfo info;
-    if (info.windowManager() == DesktopInfo::GNOME) {
-        qputenv("QT_QPA_PLATFORM", "xcb");
-    }
-}
-#endif
-
 void requestCaptureAndWait(const CaptureRequest& req)
 {
     Flameshot* flameshot = Flameshot::instance();
@@ -87,10 +75,6 @@ QSharedMemory* guiMutexLock()

 int main(int argc, char* argv[])
 {
-#ifdef Q_OS_LINUX
-    wayland_hacks();
-#endif
-
     // required for the button serialization
     // TODO: change to QVector in v1.0
     qRegisterMetaTypeStreamOperators<QList<int>>("QList<int>");

Steps to reproduce

Run GNOME in wayland-only with gnome-shell --no-x11 run flameshot. It crashes

Screenshots or screen recordings

No response

System Information

Arch Linux, GNOME 45