diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-12-31 12:42:09 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-12-31 12:42:09 +0100 |
commit | b6d1f32bfa70244e50c510bf62c81dc7f5127045 (patch) | |
tree | fb16d8ea1c148e9d7c70b7cbf9f284508928d1f5 /src/WindowUtils.cpp | |
parent | 6dfa330997f5802d709baa6403b9214fa3823454 (diff) |
Fix unable to get game (window title) name for some applications, fix notification config not respected when saving video in game directory
Diffstat (limited to 'src/WindowUtils.cpp')
-rw-r--r-- | src/WindowUtils.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
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; } |