Skip to content

Commit dc0dbac

Browse files
committed
Announce the desktop file name as the window identity
A window is matched to its desktop file, and so to its icon, by the identity it advertises: app_id on Wayland, WM_CLASS on X11. GTK derives both from the program name, which defaults to the executable, so the window announced slic3r-app-launcher while the desktop file installed for it is com.prusa3d.PrusaSlicer. Nothing matched and the window was drawn with a generic icon. Set the program name to the desktop file name, and take both it and StartupWMClass from one CMake variable so they cannot drift apart. This only showed up once the application started running on Wayland directly instead of through XWayland.
1 parent 35123f1 commit dc0dbac

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ include(GNUInstallDirs)
9696
include(CMakeDependentOption)
9797
include(Utils)
9898

99+
# Also the app id the window announces, see g_set_prgname() in DesktopApp.cpp.
100+
set(SLIC3R_DESKTOP_FILE_NAME "com.prusa3d.PrusaSlicer")
101+
99102
if (UNIX AND NOT APPLE)
100103
configure_file(
101-
${CMAKE_SOURCE_DIR}/src/platform/unix/com.prusa3d.PrusaSlicer.desktop.in
102-
${CMAKE_BINARY_DIR}/com.prusa3d.PrusaSlicer.desktop
104+
${CMAKE_SOURCE_DIR}/src/platform/unix/${SLIC3R_DESKTOP_FILE_NAME}.desktop.in
105+
${CMAKE_BINARY_DIR}/${SLIC3R_DESKTOP_FILE_NAME}.desktop
103106
@ONLY
104107
)
105108
endif ()

src/platform/unix/com.prusa3d.PrusaSlicer.desktop.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ MimeType=model/stl;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;
99
Categories=Graphics;3DGraphics;Engineering;
1010
Keywords=3D;Printing;Slicer;slice;3D;printer;convert;gcode;stl;obj;amf;SLA
1111
StartupNotify=false
12-
StartupWMClass=prusa-slicer
12+
StartupWMClass=@SLIC3R_DESKTOP_FILE_NAME@

src/slic3r-app-desktop/src/Slic3r/App/Desktop/DesktopApp.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#include "DesktopApp.hpp"
22

3+
#ifdef __WXGTK__
4+
#include <glib.h>
5+
6+
#include "Slic3r/Version.hpp"
7+
#endif
8+
39
#include "MainFrame.hpp"
410
#include "Slic3r/App/Undo/Store.hpp"
511
#include "SplashScreen.hpp"
@@ -169,6 +175,11 @@ int run(const Slic3r::App::InitParams& init_params, AppServices& app_services)
169175
::setenv("GDK_BACKEND", "x11", /* replace */ false);
170176
}
171177

178+
// A compositor finds a window's icon through the desktop file named after
179+
// the app id the window announces. GTK takes that from the program name,
180+
// which defaults to the executable, so it has to be set before GTK starts.
181+
::g_set_prgname(SLIC3R_DESKTOP_FILE_NAME);
182+
172183
if (app_services.app_config().get<Theme::Style>("theme") == Theme::Style::Light) {
173184
setenv("GTK_THEME", "Adwaita:light", 1);
174185
} else {

src/slic3r-base/include/Slic3r/Version.hpp.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
#define SLIC3R_APP_KEY "@SLIC3R_APP_KEY@"
55
#define SLIC3R_VERSION "@SLIC3R_VERSION@"
66
#define SLIC3R_BUILD_ID "@SLIC3R_BUILD_ID@"
7+
#define SLIC3R_DESKTOP_FILE_NAME "@SLIC3R_DESKTOP_FILE_NAME@"
78

89
namespace Slic3r {
910
constexpr const char* APP_NAME = SLIC3R_APP_NAME;
1011
constexpr const char* APP_KEY = SLIC3R_APP_KEY;
1112
constexpr const char* VERSION = SLIC3R_VERSION;
1213
constexpr const char* BUILD_ID = SLIC3R_BUILD_ID;
14+
constexpr const char* DESKTOP_FILE_NAME = SLIC3R_DESKTOP_FILE_NAME;
1315
}

0 commit comments

Comments
 (0)