From 4ee705ca4fcff7b47368e67b2b54bf9f5b6f3d5b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Mar 2023 16:05:31 +1100 Subject: [PATCH] Cleanup: use a system method to access the APP_ID Move the app-id out window initialization code. Make it possible for other methods to access the APP_ID. --- intern/ghost/intern/GHOST_SystemWayland.cpp | 20 ++++++++++++++++++++ intern/ghost/intern/GHOST_SystemWayland.h | 2 ++ intern/ghost/intern/GHOST_WindowWayland.cpp | 15 +-------------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 77f1086348c..b9bc4cb464b 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -6821,6 +6821,26 @@ struct zwp_pointer_gestures_v1 *GHOST_SystemWayland::wp_pointer_gestures() return display_->wp_pointer_gestures; } +/* This value is expected to match the base name of the `.desktop` file. see #101805. + * + * NOTE: the XDG desktop-entry-spec defines that this should follow the "reverse DNS" convention. + * For e.g. `org.blender.Blender` - however the `.desktop` file distributed with Blender is + * simply called `blender.desktop`, so the it's important to follow that name. + * Other distributions such as SNAP & FLATPAK may need to change this value #101779. + * Currently there isn't a way to configure this, we may want to support that. */ +static const char *ghost_wl_app_id = ( +#ifdef WITH_GHOST_WAYLAND_APP_ID + STRINGIFY(WITH_GHOST_WAYLAND_APP_ID) +#else + "blender" +#endif +); + +const char *GHOST_SystemWayland::xdg_app_id() +{ + return ghost_wl_app_id; +} + #ifdef WITH_GHOST_WAYLAND_LIBDECOR libdecor *GHOST_SystemWayland::libdecor_context() diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h index 5bc555051a2..c4bab3ae8e3 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.h +++ b/intern/ghost/intern/GHOST_SystemWayland.h @@ -192,6 +192,8 @@ class GHOST_SystemWayland : public GHOST_System { struct wl_shm *wl_shm() const; + static const char *xdg_app_id(); + /* WAYLAND utility functions. */ /** diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp index 293443d93a3..4b71d25a9b2 100644 --- a/intern/ghost/intern/GHOST_WindowWayland.cpp +++ b/intern/ghost/intern/GHOST_WindowWayland.cpp @@ -823,20 +823,7 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system, * when the `window_->scale` changed. */ const int32_t size_min[2] = {320, 240}; - /* This value is expected to match the base name of the `.desktop` file. see #101805. - * - * NOTE: the XDG desktop-entry-spec defines that this should follow the "reverse DNS" convention. - * For e.g. `org.blender.Blender` - however the `.desktop` file distributed with Blender is - * simply called `blender.desktop`, so the it's important to follow that name. - * Other distributions such as SNAP & FLATPAK may need to change this value #101779. - * Currently there isn't a way to configure this, we may want to support that. */ - const char *xdg_app_id = ( -#ifdef WITH_GHOST_WAYLAND_APP_ID - STRINGIFY(WITH_GHOST_WAYLAND_APP_ID) -#else - "blender" -#endif - ); + const char *xdg_app_id = GHOST_SystemWayland::xdg_app_id(); #ifdef WITH_GHOST_WAYLAND_LIBDECOR if (use_libdecor) {