From 7e25b0dc1e477476303713c748b40ba76890d2b2 Mon Sep 17 00:00:00 2001 From: Devin Neal Date: Sat, 26 Oct 2019 14:16:21 -0700 Subject: [PATCH] UI: Fallback to XGetWMName if XFetchName fails --- .../frontend-tools/auto-scene-switcher-nix.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp b/UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp index 57d507e7e..fd3c3079a 100644 --- a/UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp +++ b/UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp @@ -126,10 +126,17 @@ static std::string GetWindowTitle(size_t i) if (status >= Success && name != nullptr) { std::string str(name); windowTitle = str; + XFree(name); + } else { + XTextProperty xtp_new_name; + if (XGetWMName(disp(), w, &xtp_new_name) != 0 && + xtp_new_name.value != nullptr) { + std::string str((const char *)xtp_new_name.value); + windowTitle = str; + XFree(xtp_new_name.value); + } } - XFree(name); - return windowTitle; }