From 07c2c39972121eab8809778e496404ee9d573985 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 26 Sep 2025 10:10:42 +0200 Subject: [PATCH] [client,sdl] set metadata after command line parsing This allows to apply a user provided /wm-class setting. --- client/SDL/SDL3/sdl_freerdp.cpp | 25 +++++++++++++++++-------- client/SDL/SDL3/sdl_freerdp.hpp | 2 ++ client/SDL/SDL3/sdl_window.cpp | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/client/SDL/SDL3/sdl_freerdp.cpp b/client/SDL/SDL3/sdl_freerdp.cpp index aa6166d72..7efbdfeba 100644 --- a/client/SDL/SDL3/sdl_freerdp.cpp +++ b/client/SDL/SDL3/sdl_freerdp.cpp @@ -1678,6 +1678,7 @@ int main(int argc, char* argv[]) WINPR_ASSERT(settings); status = freerdp_client_settings_parse_command_line(settings, argc, argv, FALSE); + sdl_rdp->sdl->setMetadata(); if (status) { rc = freerdp_client_settings_command_line_status_print(settings, status, argc, argv); @@ -1762,14 +1763,7 @@ SdlContext::SdlContext(rdpContext* context) primary(nullptr, SDL_DestroySurface), rdp_thread_running(false), dialog(log) { WINPR_ASSERT(context); - - SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING, SDL_CLIENT_NAME); - SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_VERSION_STRING, SDL_CLIENT_VERSION); - SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING, SDL_CLIENT_UUID); - SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_CREATOR_STRING, SDL_CLIENT_VENDOR); - SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_COPYRIGHT_STRING, SDL_CLIENT_COPYRIGHT); - SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_URL_STRING, SDL_CLIENT_URL); - SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_TYPE_STRING, SDL_CLIENT_TYPE); + setMetadata(); } void SdlContext::setHasCursor(bool val) @@ -1782,6 +1776,21 @@ bool SdlContext::hasCursor() const return _cursor_visible; } +void SdlContext::setMetadata() +{ + auto wmclass = freerdp_settings_get_string(_context->settings, FreeRDP_WmClass); + if (!wmclass || (strlen(wmclass) == 0)) + wmclass = SDL_CLIENT_UUID; + + SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING, wmclass); + SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING, SDL_CLIENT_NAME); + SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_VERSION_STRING, SDL_CLIENT_VERSION); + SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_CREATOR_STRING, SDL_CLIENT_VENDOR); + SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_COPYRIGHT_STRING, SDL_CLIENT_COPYRIGHT); + SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_URL_STRING, SDL_CLIENT_URL); + SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_TYPE_STRING, SDL_CLIENT_TYPE); +} + bool SdlContext::redraw(bool suppress) const { if (!_connected) diff --git a/client/SDL/SDL3/sdl_freerdp.hpp b/client/SDL/SDL3/sdl_freerdp.hpp index 52f32e2e9..0c2e14544 100644 --- a/client/SDL/SDL3/sdl_freerdp.hpp +++ b/client/SDL/SDL3/sdl_freerdp.hpp @@ -81,6 +81,8 @@ class SdlContext void setHasCursor(bool val); [[nodiscard]] bool hasCursor() const; + void setMetadata(); + private: rdpContext* _context; std::atomic _connected = false; diff --git a/client/SDL/SDL3/sdl_window.cpp b/client/SDL/SDL3/sdl_window.cpp index 609c3986e..7b8bd9001 100644 --- a/client/SDL/SDL3/sdl_window.cpp +++ b/client/SDL/SDL3/sdl_window.cpp @@ -47,6 +47,7 @@ SdlWindow::SdlWindow(const std::string& title, Sint32 startupX, Sint32 startupY, auto w = 100 * width / iscale; auto h = 100 * height / iscale; (void)SDL_SetWindowSize(_window, w, h); + SDL_SetHint(SDL_HINT_APP_NAME, ""); (void)SDL_SyncWindow(_window); }