aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp29
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;