From e61905d02f5aa4143b507e8a53b98d45a93ba944 Mon Sep 17 00:00:00 2001 From: Myned Date: Thu, 21 May 2020 00:53:47 -0400 Subject: [PATCH] Change window title property on Linux to align with freedesktop spec Freedesktop recommends using _NET_WM_NAME instead of WM_NAME, and on KDE, for example, the difference between them is including the application name for some windows (e.g. "freedesktop - Google Search - Vivaldi" compared to "freedesktop - Google Search") --- src/linux/advanced-scene-switcher-nix.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/linux/advanced-scene-switcher-nix.cpp b/src/linux/advanced-scene-switcher-nix.cpp index af72858e..188494b5 100644 --- a/src/linux/advanced-scene-switcher-nix.cpp +++ b/src/linux/advanced-scene-switcher-nix.cpp @@ -184,9 +184,11 @@ static std::string GetWindowTitle(size_t i) char* name; XTextProperty text; - int status = XGetWMName(disp(), w, &text); + Atom titleProperty = XInternAtom(disp(), "_NET_WM_NAME", true); + int status = XGetTextProperty(disp(), w, &text, titleProperty); name = reinterpret_cast(text.value); - if (status >= Success && name != nullptr) + + if (status != 0 && name != nullptr) { std::string str(name); windowTitle = str; @@ -248,10 +250,11 @@ void GetCurrentWindowTitle(string &title) (uint8_t**)&data); XTextProperty text; - int status = XGetWMName(disp(), data[0], &text); + Atom titleProperty = XInternAtom(disp(), "_NET_WM_NAME", true); + int status = XGetTextProperty(disp(), data[0], &text, titleProperty); name = reinterpret_cast(text.value); - if (status >= Success && name != nullptr) { + if (status != 0 && name != nullptr) { std::string str(name); title = str; }