diff --git a/TODO b/TODO index 1b09436..8aa6a46 100644 --- a/TODO +++ b/TODO @@ -256,4 +256,7 @@ Webcam resolution list is too long for some people. Fix it by separating resolut Allow settings page to select input capture option/audio, to make sure it doesn't blindly select the default option when the sources aren't temporary available when opening the settings. -Add simple video cutting in the ui. \ No newline at end of file +Add simple video cutting in the ui. + +Keep replay turned on when opening a fullscreen application and alt-tabbing. Only stop replay when closing the application (when closing all fullscreen applications). + When alt-tabbing check if the previously fullscreen window still exists. diff --git a/include/Overlay.hpp b/include/Overlay.hpp index 30dcba6..eeda6c7 100644 --- a/include/Overlay.hpp +++ b/include/Overlay.hpp @@ -252,7 +252,9 @@ namespace gsr { std::unique_ptr global_hotkeys = nullptr; std::unique_ptr global_hotkeys_js = nullptr; Display *x11_dpy = nullptr; - XEvent x11_mapping_xev; + XEvent x11_xev; + Atom net_active_window_atom; + bool update_focused_window = true; struct wl_display *wayland_dpy = nullptr; diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 99840bd..f04eb45 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -518,10 +518,13 @@ namespace gsr { global_hotkeys_js = register_joystick_hotkeys(this); x11_dpy = XOpenDisplay(nullptr); - if(x11_dpy) + if(x11_dpy) { + net_active_window_atom = XInternAtom(x11_dpy, "_NET_ACTIVE_WINDOW", False); + XSelectInput(x11_dpy, DefaultRootWindow(x11_dpy), PropertyChangeMask); XKeysymToKeycode(x11_dpy, XK_F1); // If we dont call we will never get a MappingNotify - else + } else { fprintf(stderr, "Warning: XOpenDisplay failed to mapping notify\n"); + } if(this->gsr_info.system_info.display_server == DisplayServer::X11) { cursor_tracker = std::make_unique((Display*)mgl_get_context()->connection); @@ -732,15 +735,28 @@ namespace gsr { bool mapping_updated = false; while(XPending(x11_dpy)) { - XNextEvent(x11_dpy, &x11_mapping_xev); - if(x11_mapping_xev.type == MappingNotify) { - XRefreshKeyboardMapping(&x11_mapping_xev.xmapping); - mapping_updated = true; + XNextEvent(x11_dpy, &x11_xev); + switch(x11_xev.type) { + case MappingNotify: { + XRefreshKeyboardMapping(&x11_xev.xmapping); + mapping_updated = true; + break; + } + case PropertyNotify: { + if(x11_xev.xproperty.state == PropertyNewValue && x11_xev.xproperty.atom == net_active_window_atom) { + update_focused_window = true; + } + break; + } } } if(mapping_updated) rebind_all_keyboard_hotkeys(); + + if(update_focused_window) { + update_focused_window = false; + } } void Overlay::handle_events() { diff --git a/src/gui/GlobalSettingsPage.cpp b/src/gui/GlobalSettingsPage.cpp index 4de7622..da5e8f0 100644 --- a/src/gui/GlobalSettingsPage.cpp +++ b/src/gui/GlobalSettingsPage.cpp @@ -459,6 +459,7 @@ namespace gsr { list_ptr->add_widget(create_screenshot_hotkey_options()); list_ptr->add_widget(create_screenshot_region_hotkey_options()); list_ptr->add_widget(create_screenshot_window_hotkey_options()); + list_ptr->add_widget(std::make_unique