OpenBoard-org / OpenBoard

OpenBoard is a cross-platform interactive whiteboard application intended for use in a classroom setting.
https://openboard.ch/
GNU General Public License v3.0
2.24k stars 412 forks source link

[Bug] When launching OpenBoard on KDE Plasma in a Wayland, its icon from the .desktop file gets replaced by the default Wayland icon #1003

Open maehne opened 3 weeks ago

maehne commented 3 weeks ago

Describe the bug

When launching OpenBoard on KDE Plasma in a Wayland, its icon from the .desktop file gets replaced by the default Wayland icon

To Reproduce

  1. Add the following to $HOME/.local/share/OpenBoard/OpenBoardUser.config
    [App]
    RunInWindow=true
  2. Launch OpenBoard in windowed mode
  3. Check the window's icons in the task, task switcher, of the OpenBoard's window itself

Expected behavior

OpenBoard's icon should be correctly associated to all its windows in the task bar, task switcher, window icon, etc.

Actual behavior

The default Wayland icon is used.

Screenshots

grafik

Additional resources

This is a common problem, as can be seen from this reddit discussion. The suggested fix of editing the desktop file to add a StartupWMClass= field is a workaround for X11 and only fixes the issue for the taskbar, but not the window icons. However, the correct fix according KDE Bug 460403 needs to be done by the application. It needs to set the app_id so that it matches the desktop file name. Currently, the .desktop file is called ch.openboard.OpenBoard.desktop, but the app_id is reported as org.oe-f.openboard. Changing the name of the .desktop file helps:

cp /usr/share/applications/ch.openboard.OpenBoard.desktop ~/.local/share/applications/org.oe-f.openboard.desktop

grafik

The source code contains still a number of references to that not anymore existing oe-f.org domain:

[...]OpenBoard/$  grep -rHn oe-f
resources/macx/Save PDF to OpenBoard.workflow/Contents/document.wflow:58:                                       <string>open -b org.oe-f.openboard "$1"</string>
resources/macx/Save PDF to OpenBoard.workflow/Contents/Info.plist:6:    <string>org.oe-f.pdfworkflow.savepdftoopenboard</string>
resources/macx/Info.plist:11:                   <string>org.oe-f.OpenBoard.document</string>
resources/macx/Info.plist:18:                           <string>org.oe-f.OpenBoard.document</string>
resources/macx/Info.plist:58:   <string>org.oe-f.OpenBoard</string>
resources/macx/Info.plist:79:                   <string>org.oe-f.OpenBoard.document</string>
release_scripts/osx/build.sh:113:trap "defaults write org.oe-f.OpenBoard.release Running -bool NO" EXIT
release_scripts/osx/build.sh:119:script_is_running=`defaults read org.oe-f.OpenBoard.release Running 2>/dev/null`
release_scripts/osx/build.sh:124:defaults write org.oe-f.OpenBoard.release Running -bool YES
release_scripts/osx/package.sh:67:trap "defaults write org.oe-f.OpenBoard.release Running -bool NO" EXIT
release_scripts/osx/package.sh:73:script_is_running=`defaults read org.oe-f.OpenBoard.release Running 2>/dev/null`
release_scripts/osx/package.sh:78:defaults write org.oe-f.OpenBoard.release Running -bool YES
release_scripts/windows/OpenBoard.iss:19:AppPublisherURL=http://www.oe-f.org
src/core/UBApplication.cpp:104:    setOrganizationDomain("oe-f.org");

IMHO, the better way to fix this issue is to change all these references to openboard.ch. However, the app_id will then still be ch.openboard.openboard. To get the app_id to use mixed case for the last part, QGuiApplication::setDesktopFileName(const QString &name) should be used, see, e.g., the discussion in QTBUG-77182 and https://github.com/bit-team/backintime/issues/1244.

Context

Additional context

maehne commented 3 weeks ago

Also related: The importance of window to desktop file mapping

Vekhir commented 2 weeks ago

W.r.t. the desktop file having the wrong casing: Qt has a plugin for XCB which defaults to the executable name if the desktop filename is empty (qt/qtbase:src/plugins/platforms/xcb/qxcbwindow.cpp#L396).

There is no such plugin for Wayland, maybe it has similar behaviour. What happens if you change the name?

maehne commented 2 weeks ago

@Vekhir: Thanks for your feedback! Regarding your question:

What happens if you change the name?

I don't fully understand, what name you want me to change for testing? Only if I change the desktop file name to org.oe-f.openboard.desktop, the application gets assigned the right icons in a Wayland session. Otherwise, the generic Wayland icon gets used. Other variations of the casing don't fix the issue. Note that this might be specific for platforms with case-sensitive file systems. Windows and macOS have case-insensitive file systems by default.

Vekhir commented 2 weeks ago

@maehne

what name you want me to change for testing?

The binary name in /usr/bin/, e.g. /usr/bin/openboard -> /usr/bin/openboard2, and then see if the app_id changes accordingly when you run it. IMO, Qt should default to the application name if set (which itself defaults to binary name) for the .desktop file, but it seems that it just directly jumps to binary name. This test would confirm this, though the (currently best) fix would be to use setDesktopFileName as you noted.

maehne commented 2 weeks ago

@Vekhir: Thanks for the clarification! Indeed, renaming /usr/bin/openboard to /usr/bin/openboard2 causes that the Wayland default icons get assigned to the application with QT_QPA_PLATFORM=wayland. The correct icons are used for QT_QPA_PLATFORM=xcb. Therefore, the desktop file name should be explicitly set using QGuiApplication::setDesktopFileName(const QString &name).