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")
This commit is contained in:
Myned 2020-05-21 00:53:47 -04:00
parent f00c244bfa
commit e61905d02f
No known key found for this signature in database
GPG Key ID: 24318A323F309244

View File

@ -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<char*>(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<char*>(text.value);
if (status >= Success && name != nullptr) {
if (status != 0 && name != nullptr) {
std::string str(name);
title = str;
}