aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2025-02-10 19:40:22 +0100
committerdec05eba <dec05eba@protonmail.com>2025-02-10 19:41:56 +0100
commit1734d48af6edd1b115910a61e132713459b1d8f1 (patch)
treef4fdc3c8c89a59508a179cc07bb38d0ff6cf3494 /src
parentfc2f6f4c500d0364d5dd5cf366be2fa8592f8469 (diff)
window get title: cleanup dataHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/AudioPlayer.cpp9
-rw-r--r--src/Overlay.cpp14
-rw-r--r--src/WindowUtils.cpp21
3 files changed, 20 insertions, 24 deletions
diff --git a/src/AudioPlayer.cpp b/src/AudioPlayer.cpp
index 8d30ee6..cb6d1c7 100644
--- a/src/AudioPlayer.cpp
+++ b/src/AudioPlayer.cpp
@@ -33,11 +33,10 @@ namespace gsr {
return false;
thread = std::thread([this]() {
- const pa_sample_spec ss = {
- .format = PA_SAMPLE_S16LE,
- .rate = 48000,
- .channels = 2
- };
+ pa_sample_spec ss;
+ ss.format = PA_SAMPLE_S16LE;
+ ss.rate = 48000;
+ ss.channels = 2;
pa_simple *s = NULL;
int error;
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index feb4e6f..919117d 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -229,15 +229,6 @@ namespace gsr {
return is_fullscreen;
}
- static void set_focused_window(Display *dpy, Window window) {
- XSetInputFocus(dpy, window, RevertToPointerRoot, CurrentTime);
-
- const Atom net_active_window_atom = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
- XChangeProperty(dpy, DefaultRootWindow(dpy), net_active_window_atom, XA_WINDOW, 32, PropModeReplace, (const unsigned char*)&window, 1);
-
- XFlush(dpy);
- }
-
#define _NET_WM_STATE_REMOVE 0
#define _NET_WM_STATE_ADD 1
#define _NET_WM_STATE_TOGGLE 2
@@ -1171,11 +1162,6 @@ namespace gsr {
// Owlboy seems to use xi events and XGrabPointer doesn't prevent owlboy from receiving events.
xi_grab_all_mouse_devices();
- // if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) {
- // set_focused_window(display, window->get_system_handle());
- // XFlush(display);
- // }
-
if(!is_wlroots)
window->set_fullscreen(true);
diff --git a/src/WindowUtils.cpp b/src/WindowUtils.cpp
index c8bb859..ec01e26 100644
--- a/src/WindowUtils.cpp
+++ b/src/WindowUtils.cpp
@@ -171,6 +171,7 @@ namespace gsr {
}
std::optional<std::string> get_window_title(Display *dpy, Window window) {
+ std::optional<std::string> result;
const Atom net_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);
@@ -182,8 +183,13 @@ namespace gsr {
unsigned char *data = NULL;
XGetWindowProperty(dpy, window, net_wm_name_atom, 0, 1024, False, utf8_string_atom, &type, &format, &num_items, &bytes_left, &data);
- if(type == utf8_string_atom && format == 8 && data)
- return utf8_sanitize(data, num_items);
+ if(type == utf8_string_atom && format == 8 && data) {
+ result = utf8_sanitize(data, num_items);
+ goto done;
+ }
+
+ if(data)
+ XFree(data);
type = None;
format = 0;
@@ -192,10 +198,15 @@ namespace gsr {
data = NULL;
XGetWindowProperty(dpy, window, wm_name_atom, 0, 1024, False, 0, &type, &format, &num_items, &bytes_left, &data);
- if((type == XA_STRING || type == utf8_string_atom) && data)
- return utf8_sanitize(data, num_items);
+ if((type == XA_STRING || type == utf8_string_atom) && data) {
+ result = utf8_sanitize(data, num_items);
+ goto done;
+ }
- return std::nullopt;
+ done:
+ if(data)
+ XFree(data);
+ return result;
}
static std::string strip(const std::string &str) {