Browse Source

Merge pull request #2148 from eulertour/master

UI: Fall back to XGetWMName if XFetchName fails
Jim 6 years ago
parent
commit
cbfb779876
1 changed files with 9 additions and 2 deletions
  1. 9 2
      UI/frontend-plugins/frontend-tools/auto-scene-switcher-nix.cpp

+ 9 - 2
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;
 }