From ccf96030da52bf344b21b349812792961dfd0fc7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 3 Oct 2025 18:00:16 +0200 Subject: [PATCH] Force no cursor in capture when using region/window screenshot hotkey --- src/Overlay.cpp | 9 ++++----- src/main.cpp | 20 +------------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 19e5941..4633221 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -3091,7 +3091,6 @@ namespace gsr { return; } - bool hotkey_window_capture = false; std::string record_area_option; switch(force_type) { case ScreenshotForceType::NONE: @@ -3102,7 +3101,6 @@ namespace gsr { break; case ScreenshotForceType::WINDOW: record_area_option = gsr_info.system_info.display_server == DisplayServer::X11 ? "window" : "portal"; - hotkey_window_capture = true; break; } @@ -3133,10 +3131,11 @@ namespace gsr { // TODO: Validate input, fallback to valid values const std::string output_file = config.screenshot_config.save_directory + "/Screenshot_" + get_date_str() + "." + config.screenshot_config.image_format; // TODO: Validate image format + const bool capture_cursor = force_type == ScreenshotForceType::NONE && config.screenshot_config.record_cursor; std::vector args = { "gpu-screen-recorder", "-w", screenshot_capture_target.c_str(), - "-cursor", config.screenshot_config.record_cursor ? "yes" : "no", + "-cursor", capture_cursor ? "yes" : "no", "-v", "no", "-q", config.screenshot_config.image_quality.c_str(), "-o", output_file.c_str() @@ -3150,7 +3149,7 @@ namespace gsr { args.push_back(size); } - if(config.screenshot_config.restore_portal_session && !hotkey_window_capture) { + if(config.screenshot_config.restore_portal_session && force_type != ScreenshotForceType::WINDOW) { args.push_back("-restore-portal-session"); args.push_back("yes"); } @@ -3158,7 +3157,7 @@ namespace gsr { const std::string hotkey_window_capture_portal_session_token_filepath = get_config_dir() + "/gpu-screen-recorder/gsr-ui-window-capture-token"; if(record_area_option == "portal") { hide_ui = true; - if(hotkey_window_capture) { + if(force_type == ScreenshotForceType::WINDOW) { args.push_back("-portal-session-token-filepath"); args.push_back(hotkey_window_capture_portal_session_token_filepath.c_str()); } diff --git a/src/main.cpp b/src/main.cpp index 446f85b..030077c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,24 +102,6 @@ static void rpc_add_commands(gsr::Rpc *rpc, gsr::Overlay *overlay) { }); } -static bool is_gsr_ui_virtual_keyboard_running() { - FILE *f = fopen("/proc/bus/input/devices", "rb"); - if(!f) - return false; - - bool virtual_keyboard_running = false; - char line[1024]; - while(fgets(line, sizeof(line), f)) { - if(strstr(line, "gsr-ui virtual keyboard")) { - virtual_keyboard_running = true; - break; - } - } - - fclose(f); - return virtual_keyboard_running; -} - static void install_flatpak_systemd_service() { const bool systemd_service_exists = system( "data_home=$(flatpak-spawn --host -- /bin/sh -c 'echo \"${XDG_DATA_HOME:-$HOME/.local/share}\"') && " @@ -228,7 +210,7 @@ int main(int argc, char **argv) { auto rpc = std::make_unique(); const gsr::RpcOpenResult rpc_open_result = rpc->open("gsr-ui"); - if(is_gsr_ui_virtual_keyboard_running() || rpc_open_result == gsr::RpcOpenResult::OK) { + if(rpc_open_result == gsr::RpcOpenResult::OK) { if(launch_action == LaunchAction::LAUNCH_DAEMON) return 1;