TagStudioDev / TagStudio

A User-Focused Photo & File Management System
https://docs.tagstud.io/
GNU General Public License v3.0
5.18k stars 371 forks source link

[Bug]: Wayland missing menu, application icon and title #415

Open zierf opened 2 months ago

zierf commented 2 months ago

Checklist

TagStudio Version

main #cb4798b AND Alpha v9.4

Operating System & Version

NixOS 24.11 (Vicuna), 24.11.20240818.8a33541 | nixpkgs-unstable#8a33541 | KDE

Description

TagStudio does not display the global menu, appropriate icon or title under Wayland.

The entire menu is also missing if the desktop environment uses global menus (also called appmenu or dbus-menu). The menu is then neither displayed in the window itself nor in the global menu.

This means that the application is not usable at all.

Apart from NixOS, I also verified this on a Debian virtual machine with the pre-built Alpha v9.3.2 release, and it behaves the same there.

Screenshot_20240829_200922


Apparently Wayland needs a suitable .desktop file to display the correct title and icon. Just like someone referenced here with app.setDesktopFileName("myapp") to set a system icon.

See also this C++ example. You could possibly use something similar in the tagstudio/src/qt/ts_qt.py file.

if sys.platform != "darwin":
    icon = QIcon()
    icon.addFile(str(icon_path))
    app.setWindowIcon(icon)

if sys.platform == "linux":
    # app icon must be defined in a .desktop file to be displayed under Wayland
    app.setDesktopFileName("TagStudio");

Just for fun, I tried to use the icon for KDE-Discover, which has a .desktop file on the system. This actually made the icon and title match.

if sys.platform == "linux":
    # app icon must be defined in a .desktop file to be displayed under Wayland
    app.setDesktopFileName("org.kde.discover");

Screenshot_20240829_201108


The global menu should have been supported by QT6 applications by now, and this is also the case with normal KDE applications. Here is an old KDE Bug #448078 (and his sibling KDE Bug #455155) about it that has been marked as resolved.

Interestingly, if you start the application with XWayland instead of directly in Wayland, the icon and global menu suddenly work. This can be overridden with the environment variable QT_QPA_PLATFORM.

So if you start the application with QT_QPA_PLATFORM=xcb tagstudio or alternatively by setting the variable in flake.nix beforehand, the correct icon and the global menu appear. The title is apparently not set correctly, in this case it just says Desktop instead on my system.

Screenshot_20240829_201251

It would therefore make sense to initially move XWayland before Wayland in the flake.nix environment variable, which should then provide a menu for most users.

QT_QPA_PLATFORM = "xcb;wayland";

Alternatively, you would have to explicitly disable the global menu by deactivating the native menu bar in Python. This means that the menu is always displayed directly in the window itself, but is then no longer integrated into the system as desired.

menu_bar.setNativeMenuBar(False)

I hope that someone can find a solution for the missing menu under Wayland that does not require XWayland to be preferred or the native/global menu to be deactivated. Unfortunately, I have no idea whether it is due to a bug in the PySide6 library itself or whether NixOS cannot recognize it correctly due to an extra Python layer in front of the QT6 framework. It wants to register a menu in DBUS, but it's just not visible.

Expected Behavior

Correct title, icon and at least a usable menu, while a global menu is preferred.

Steps to Reproduce

  1. Open TagStudio

Logs

Branch Alpha-v9.4 ```SH $> ./TagStudio.sh [notice] A new release of pip is available: 24.0 -> 24.2 [notice] To update, run: pip install --upgrade pip [ResourceManager] 4 resources registered [QT DRIVER] Config File not specified, defaulting to /home/USERNAME/.config/TagStudio/TagStudio.ini qt.qpa.wayland: EGL not available Calling NavForward with Content:False, Index:0, PageCount:0 [ENTRY PANEL] UPDATE WIDGETS ([]) [LIBRARY] Extension list loaded in 0.000 seconds [LIBRARY] Tags loaded in 0.000 seconds [LIBRARY] Entries loaded in 0.001 seconds [LIBRARY] Collations loaded in 0.000 seconds [ENTRY PANEL] UPDATE WIDGETS ([]) Query:, Frame: 0, Length: 140 Calling NavForward with Content:(, 139), Index:0, PageCount:1 [UPDATE CONTAINER] Setting tags updated slot [ENTRY PANEL] UPDATE WIDGETS ([(, 5)]) Playing /MEDIA_PATH/big_buck_bunny_1080p_h264.mov Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory QRhi* initializeRHI(QRhi*) : No RHI backend. Using CPU conversion. Saving Library... [LIBRARY] Saving Library to Disk... [LIBRARY] Formatting Tags to JSON... [LIBRARY] Formatting Entries to JSON... [LIBRARY] Formatting Collations to JSON... [LIBRARY] Done Formatting to JSON! [LIBRARY] Library saved to disk in 0.002 seconds [SHUTDOWN] Ending Thumbnail Threads... ```
Branch main (Commit #cb4798b) ```SH $> tagstudio [ResourceManager] 4 resources registered [QT DRIVER] Config File not specified, defaulting to /home/USERNAME/.config/TagStudio/TagStudio.ini No QtMultimedia backends found. Only QMediaDevices, QAudioDevice, QSoundEffect, QAudioSink, and QAudioSource are available. Failed to initialize QMediaPlayer "Not available" Failed to create QVideoSink "Not available" Calling NavForward with Content:False, Index:0, PageCount:0 [ENTRY PANEL] UPDATE WIDGETS ([]) [LIBRARY] Extension list loaded in 0.000 seconds [LIBRARY] Tags loaded in 0.000 seconds [LIBRARY] Entries loaded in 0.001 seconds [LIBRARY] Collations loaded in 0.000 seconds [ENTRY PANEL] UPDATE WIDGETS ([]) Query:, Frame: 0, Length: 140 Calling NavForward with Content:(, 139), Index:0, PageCount:1 Saving Library... [LIBRARY] Saving Library to Disk... [LIBRARY] Formatting Tags to JSON... [LIBRARY] Formatting Entries to JSON... [LIBRARY] Formatting Collations to JSON... [LIBRARY] Done Formatting to JSON! [LIBRARY] Library saved to disk in 0.002 seconds [SHUTDOWN] Ending Thumbnail Threads... ```
zierf commented 2 months ago

Quick update, the window title (not application name!) set in Python seems to be adopted.

At least it appears in the window frame when the window is not maximized.

Screenshot_20240830_222348

I've been playing around a bit with the settings of the Application Title Bar, which until recently was set to Application Name for me. This means that, for example, only "Firefox Developer Edition" is displayed instead of the entire window title, which usually contains the title of a website, or only "Dolphin" instead of "/home/USER/path - Dolphin".

Screenshot_20240830_223909

If I were to change the setting to Generic Application Name or Decoration, the title would also be adopted in the system bar.

Screenshot_20240830_224024

This means that the icon and the actual application name are missing, not the window title.

The bigger problem seems to be the missing global menu under Wayland, while at the same time the menu in the window is no longer displayed. I still don't understand why it can be loaded correctly when running under XWayland and not under Wayland itself, even while using KDE, Pyside6 should actually be well supported too.

Takanu commented 1 month ago

I can confirm this also happens with Fedora Workstation 40.

image

emanuelfranklyn commented 1 month ago

image Can confirm this also happens on Arch linux running KDE Plasma 6 (wayland)