diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-09-25 02:20:05 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-09-25 02:20:05 +0200 |
commit | 1e9796838899302213de3fae7457a7c1aaea5be6 (patch) | |
tree | d22010c20ab765cc0cc9c15758c05dde49bd495f /src | |
parent | 697369f2b4cca6700e2b6ca10f309bd51bacccee (diff) |
Use NET_ACTIVE_WINDOW instead of getinputfocus
Diffstat (limited to 'src')
-rw-r--r-- | src/QuickMedia.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index c9e52c1..54a85de 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3005,10 +3005,33 @@ namespace QuickMedia { || is_soundcloud(url); } - void Program::redirect_focus_to_video_player_window(mgl::WindowHandle video_player_window) { + static Window get_input_focus(Display *display) { Window focused_window = None; - int dummy; - XGetInputFocus(disp, &focused_window, &dummy); + + Atom net_active_window_atom = XInternAtom(display, "_NET_ACTIVE_WINDOW", False); + Atom type; + unsigned long len, bytes_left; + int format; + unsigned char *properties = NULL; + if(XGetWindowProperty(display, DefaultRootWindow(display), net_active_window_atom, 0, 1024, False, XA_WINDOW, &type, &format, &len, &bytes_left, &properties) == Success) { + if(properties) { + if(len > 0) + focused_window = *(Window*)properties; + XFree(properties); + } + } + + if(!focused_window) { + int rev; + if(!XGetInputFocus(display, &focused_window, &rev)) + focused_window = None; + } + + return focused_window; + } + + void Program::redirect_focus_to_video_player_window(mgl::WindowHandle video_player_window) { + Window focused_window = get_input_focus(disp); if(focused_window != window.get_system_handle()) return; |