Add lshift + printscreen hotkey to take a screenshot of a window (or desktop portal on wayland)

This commit is contained in:
dec05eba
2025-07-20 01:55:02 +02:00
parent b64cb6a3fd
commit ad94cff59e
9 changed files with 107 additions and 18 deletions

View File

@@ -145,6 +145,7 @@ namespace gsr {
std::string save_directory;
ConfigHotkey take_screenshot_hotkey;
ConfigHotkey take_screenshot_region_hotkey;
ConfigHotkey take_screenshot_window_hotkey; // Or desktop portal, on wayland
};
struct Config {

View File

@@ -41,6 +41,12 @@ namespace gsr {
SCREENSHOT
};
enum class ScreenshotForceType {
NONE,
REGION,
WINDOW
};
class Overlay {
public:
Overlay(std::string resources_path, GsrInfo gsr_info, SupportedCaptureOptions capture_options, egl_functions egl_funcs);
@@ -64,6 +70,7 @@ namespace gsr {
void save_replay_10_min();
void take_screenshot();
void take_screenshot_region();
void take_screenshot_window();
void show_notification(const char *str, double timeout_seconds, mgl::Color icon_color, mgl::Color bg_color, NotificationType notification_type, const char *capture_target = nullptr);
bool is_open() const;
bool should_exit(std::string &reason) const;
@@ -121,7 +128,7 @@ namespace gsr {
bool on_press_start_replay(bool disable_notification, bool finished_selection);
void on_press_start_record(bool finished_selection);
void on_press_start_stream(bool finished_selection);
void on_press_take_screenshot(bool finished_selection, bool force_region_capture);
void on_press_take_screenshot(bool finished_selection, ScreenshotForceType force_type);
bool update_compositor_texture(const Monitor &monitor);
std::string get_capture_target(const std::string &capture_target, const SupportedCaptureOptions &capture_options);

View File

@@ -29,6 +29,7 @@ namespace gsr {
STREAM_START_STOP,
TAKE_SCREENSHOT,
TAKE_SCREENSHOT_REGION,
TAKE_SCREENSHOT_WINDOW,
SHOW_HIDE
};
@@ -63,6 +64,7 @@ namespace gsr {
std::unique_ptr<List> create_stream_hotkey_options();
std::unique_ptr<List> create_screenshot_hotkey_options();
std::unique_ptr<List> create_screenshot_region_hotkey_options();
std::unique_ptr<List> create_screenshot_window_hotkey_options();
std::unique_ptr<List> create_hotkey_control_buttons();
std::unique_ptr<Subsection> create_keyboard_hotkey_subsection(ScrollablePage *parent_page);
std::unique_ptr<Subsection> create_controller_hotkey_subsection(ScrollablePage *parent_page);
@@ -99,6 +101,7 @@ namespace gsr {
Button *start_stop_streaming_button_ptr = nullptr;
Button *take_screenshot_button_ptr = nullptr;
Button *take_screenshot_region_button_ptr = nullptr;
Button *take_screenshot_window_button_ptr = nullptr;
Button *show_hide_button_ptr = nullptr;
ConfigHotkey configure_config_hotkey;