diff --git a/TODO b/TODO index 6178951..410aaa1 100644 --- a/TODO +++ b/TODO @@ -247,3 +247,9 @@ Remove all mgl::Clock usage in Overlay. We only need to get the time once per up Handle stopping replay/stream when recording is running (show notification that the video is saved and move the video to folder with game name). Support translations. + +Sometimes when opening gpu screen recorder ui gsr-global-hotkeys incorrectly detects that keyboard input is locked. + +When running replay for a long time and then stopping it it takes a while. Improve this. + +When adding webcamera make replay auto start wait for camera to be available (when /dev/video device exists and can be initialized), just like audio device. diff --git a/depends/mglpp b/depends/mglpp index b569045..f69ab7f 160000 --- a/depends/mglpp +++ b/depends/mglpp @@ -1 +1 @@ -Subproject commit b569045831381f1ecbcdebd9cb2767f97b868394 +Subproject commit f69ab7f0056fdfc722185551365aaf2aeb69cbf7 diff --git a/include/WindowUtils.hpp b/include/WindowUtils.hpp index 5c4d39a..08a0f33 100644 --- a/include/WindowUtils.hpp +++ b/include/WindowUtils.hpp @@ -19,8 +19,8 @@ namespace gsr { }; std::optional get_window_title(Display *dpy, Window window); - Window get_focused_window(Display *dpy, WindowCaptureType cap_type); - std::string get_focused_window_name(Display *dpy, WindowCaptureType window_capture_type); + Window get_focused_window(Display *dpy, WindowCaptureType cap_type, bool fallback_cursor_focused = true); + std::string get_focused_window_name(Display *dpy, WindowCaptureType window_capture_type, bool fallback_cursor_focused = true); std::string get_window_name_at_position(Display *dpy, mgl::vec2i position, Window ignore_window); std::string get_window_name_at_cursor_position(Display *dpy, Window ignore_window); void set_window_size_not_resizable(Display *dpy, Window window, int width, int height); diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 48f3967..b438ee4 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -17,6 +17,7 @@ #include "../include/CursorTracker/CursorTrackerX11.hpp" #include "../include/CursorTracker/CursorTrackerWayland.hpp" +#include #include #include #include @@ -1022,7 +1023,10 @@ namespace gsr { // Wayland doesn't allow XGrabPointer/XGrabKeyboard when a wayland application is focused. // If the focused window is a wayland application then don't use override redirect and instead create // a fullscreen window for the ui. - const bool prevent_game_minimizing = gsr_info.system_info.display_server != DisplayServer::WAYLAND || (x11_cursor_window && is_window_fullscreen_on_monitor(display, x11_cursor_window, *focused_monitor)) || is_wlroots || is_hyprland; + const bool prevent_game_minimizing = gsr_info.system_info.display_server != DisplayServer::WAYLAND + || (x11_cursor_window && is_window_fullscreen_on_monitor(display, x11_cursor_window, *focused_monitor) && get_focused_window(display, WindowCaptureType::FOCUSED, false) == x11_cursor_window) + || is_wlroots + || is_hyprland; if(prevent_game_minimizing) { window_pos = focused_monitor->position; @@ -1917,7 +1921,7 @@ namespace gsr { const Window gsr_ui_window = window ? (Window)window->get_system_handle() : None; std::string focused_window_name = get_window_name_at_cursor_position(display, gsr_ui_window); if(focused_window_name.empty()) - focused_window_name = get_focused_window_name(display, WindowCaptureType::FOCUSED); + focused_window_name = get_focused_window_name(display, WindowCaptureType::FOCUSED, false); if(focused_window_name.empty()) focused_window_name = "Game"; @@ -2178,7 +2182,10 @@ namespace gsr { led_indicator->blink(); if(!strip(config.screenshot_config.custom_script).empty()) { - const char *args[] = { config.screenshot_config.custom_script.c_str(), screenshot_filepath.c_str(), nullptr }; + std::stringstream ss; + ss << config.screenshot_config.custom_script << " " << std::quoted(screenshot_filepath); + const std::string command = ss.str(); + const char *args[] = { "/bin/sh", "-c", command.c_str(), nullptr }; exec_program_on_host_daemonized(args); } } else { @@ -2230,7 +2237,7 @@ namespace gsr { mgl_context *context = mgl_get_context(); Display *display = (Display*)context->connection; - const Window focused_window = get_focused_window(display, WindowCaptureType::FOCUSED); + const Window focused_window = get_focused_window(display, WindowCaptureType::FOCUSED, false); if(window && focused_window == (Window)window->get_system_handle()) return; diff --git a/src/WindowUtils.cpp b/src/WindowUtils.cpp index c6b278b..bb407f5 100644 --- a/src/WindowUtils.cpp +++ b/src/WindowUtils.cpp @@ -121,7 +121,7 @@ namespace gsr { return root_pos; } - Window get_focused_window(Display *dpy, WindowCaptureType cap_type) { + Window get_focused_window(Display *dpy, WindowCaptureType cap_type, bool fallback_cursor_focused) { //const Atom net_active_window_atom = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); Window focused_window = None; @@ -146,6 +146,9 @@ namespace gsr { XGetInputFocus(dpy, &focused_window, &revert_to); if(focused_window && focused_window != DefaultRootWindow(dpy) && window_is_user_program(dpy, focused_window)) return focused_window; + + if(!fallback_cursor_focused) + return None; } get_cursor_position(dpy, &focused_window); @@ -213,9 +216,9 @@ namespace gsr { return result; } - std::string get_focused_window_name(Display *dpy, WindowCaptureType window_capture_type) { + std::string get_focused_window_name(Display *dpy, WindowCaptureType window_capture_type, bool fallback_cursor_focused) { std::string result; - const Window focused_window = get_focused_window(dpy, window_capture_type); + const Window focused_window = get_focused_window(dpy, window_capture_type, fallback_cursor_focused); if(focused_window == None) return result; diff --git a/src/gui/ScreenshotSettingsPage.cpp b/src/gui/ScreenshotSettingsPage.cpp index a2c8f42..61061ab 100644 --- a/src/gui/ScreenshotSettingsPage.cpp +++ b/src/gui/ScreenshotSettingsPage.cpp @@ -261,7 +261,7 @@ namespace gsr { std::unique_ptr ScreenshotSettingsPage::create_custom_script_screenshot() { auto custom_script_screenshot_list = std::make_unique(List::Orientation::VERTICAL); - custom_script_screenshot_list->add_widget(std::make_unique