aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-12-31 12:42:09 +0100
committerdec05eba <dec05eba@protonmail.com>2024-12-31 12:42:09 +0100
commitb6d1f32bfa70244e50c510bf62c81dc7f5127045 (patch)
treefb16d8ea1c148e9d7c70b7cbf9f284508928d1f5
parent6dfa330997f5802d709baa6403b9214fa3823454 (diff)
Fix unable to get game (window title) name for some applications, fix notification config not respected when saving video in game directory
-rw-r--r--src/Overlay.cpp10
-rw-r--r--src/WindowUtils.cpp25
2 files changed, 23 insertions, 12 deletions
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index e897f5a..61fa9c5 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -1306,12 +1306,18 @@ namespace gsr {
truncate_string(focused_window_name, 20);
std::string text;
switch(notification_type) {
- case NotificationType::RECORD:
+ case NotificationType::RECORD: {
+ if(!config.record_config.show_video_saved_notifications)
+ return;
text = "Saved recording to '" + focused_window_name + "/" + video_filename + "'";
break;
- case NotificationType::REPLAY:
+ }
+ case NotificationType::REPLAY: {
+ if(!config.replay_config.show_replay_saved_notifications)
+ return;
text = "Saved replay to '" + focused_window_name + "/" + video_filename + "'";
break;
+ }
case NotificationType::NONE:
case NotificationType::STREAM:
break;
diff --git a/src/WindowUtils.cpp b/src/WindowUtils.cpp
index c033058..9a2c304 100644
--- a/src/WindowUtils.cpp
+++ b/src/WindowUtils.cpp
@@ -45,17 +45,21 @@ namespace gsr {
Window focused_window = None;
if(cap_type == WindowCaptureType::FOCUSED) {
- // Atom type = None;
- // int format = 0;
- // unsigned long num_items = 0;
- // unsigned long bytes_left = 0;
- // unsigned char *data = NULL;
- // XGetWindowProperty(dpy, DefaultRootWindow(dpy), net_active_window_atom, 0, 1, False, XA_WINDOW, &type, &format, &num_items, &bytes_left, &data);
+ Atom type = None;
+ int format = 0;
+ unsigned long num_items = 0;
+ unsigned long bytes_left = 0;
+ unsigned char *data = NULL;
+ XGetWindowProperty(dpy, DefaultRootWindow(dpy), net_active_window_atom, 0, 1, False, XA_WINDOW, &type, &format, &num_items, &bytes_left, &data);
- // fprintf(stderr, "focused window: %p\n", (void*)data);
+ if(type == XA_WINDOW && num_items == 1 && data)
+ focused_window = *(Window*)data;
- // if(type == XA_WINDOW && num_items == 1 && data)
- // return *(Window*)data;
+ if(data)
+ XFree(data);
+
+ if(focused_window)
+ return focused_window;
int revert_to = 0;
XGetInputFocus(dpy, &focused_window, &revert_to);
@@ -72,7 +76,7 @@ namespace gsr {
static char* get_window_title(Display *dpy, Window window) {
const Atom net_wm_name_atom = XInternAtom(dpy, "_NET_WM_NAME", False);
- const Atom wm_name_atom = XInternAtom(dpy, "_NET_WM_NAME", False);
+ const Atom wm_name_atom = XInternAtom(dpy, "WM_NAME", False);
const Atom utf8_string_atom = XInternAtom(dpy, "UTF8_STRING", False);
Atom type = None;
@@ -135,6 +139,7 @@ namespace gsr {
char *window_title = get_window_title(dpy, focused_window);
if(window_title) {
result = string_string(window_title);
+ XFree(window_title);
return result;
}