From 7433837df6c936ffaadd6af689a83ba4e9c4f64a Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Fri, 29 Aug 2025 13:45:48 -0400 Subject: keybindings: Add area screenshot keyboard shortcut Add Shift+Print keybinding to trigger 'mate-screenshot --area' for interactive area selection. This gives users a dedicated keybinding for area screenshots in addition to the existing Print (screen) and Alt+Print (window) shortcuts. Fixes mate-desktop/marco#157 --- src/50-marco-desktop-key.xml.in | 2 ++ src/core/keybindings.c | 2 +- src/core/prefs.c | 7 +++++++ src/include/all-keybindings.h | 1 + src/include/prefs.h | 7 ++++--- src/org.mate.marco.gschema.xml | 10 ++++++++++ 6 files changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/50-marco-desktop-key.xml.in b/src/50-marco-desktop-key.xml.in index 61f2ff4f..661476cc 100644 --- a/src/50-marco-desktop-key.xml.in +++ b/src/50-marco-desktop-key.xml.in @@ -9,6 +9,8 @@ + + diff --git a/src/core/keybindings.c b/src/core/keybindings.c index b1b1780a..45be2353 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -2514,7 +2514,7 @@ handle_run_command (MetaDisplay *display, * input grabbing. This prevents race conditions with applications like * mate-screenshot that need to grab input for area selection. */ - if (which >= SCREENSHOT_COMMAND_IDX && which <= WIN_SCREENSHOT_COMMAND_IDX) + if (which >= SCREENSHOT_COMMAND_IDX && which <= AREA_SCREENSHOT_COMMAND_IDX) { ungrab_keyboard (display, event->xkey.time); } diff --git a/src/core/prefs.c b/src/core/prefs.c index 5299cf81..e1e09153 100644 --- a/src/core/prefs.c +++ b/src/core/prefs.c @@ -2065,6 +2065,10 @@ update_command (const char *name, { i = WIN_SCREENSHOT_COMMAND_IDX; } + else if (strcmp (name, "command-area-screenshot") == 0) + { + i = AREA_SCREENSHOT_COMMAND_IDX; + } else { meta_topic (META_DEBUG_KEYBINDINGS, @@ -2119,6 +2123,9 @@ meta_prefs_get_settings_key_for_command (int i) case WIN_SCREENSHOT_COMMAND_IDX: key = g_strdup (KEY_COMMAND_PREFIX "window-screenshot"); break; + case AREA_SCREENSHOT_COMMAND_IDX: + key = g_strdup (KEY_COMMAND_PREFIX "area-screenshot"); + break; default: key = g_strdup_printf (KEY_COMMAND_PREFIX"%d", i + 1); break; diff --git a/src/include/all-keybindings.h b/src/include/all-keybindings.h index 992d077f..02452878 100644 --- a/src/include/all-keybindings.h +++ b/src/include/all-keybindings.h @@ -194,6 +194,7 @@ keybind (run-command-32, handle_run_command, 31, 0) keybind (run-command-screenshot, handle_run_command, 32, 0) keybind (run-command-window-screenshot, handle_run_command, 33, 0) +keybind (run-command-area-screenshot, handle_run_command, 34, 0) keybind (run-command-terminal, handle_run_terminal, 0, 0) keybind (rename-workspace, handle_rename_workspace, 0, 0) diff --git a/src/include/prefs.h b/src/include/prefs.h index ebfd2c55..1170e8e8 100644 --- a/src/include/prefs.h +++ b/src/include/prefs.h @@ -30,9 +30,10 @@ #include #define MAX_COMMANDS (32 + NUM_EXTRA_COMMANDS) -#define NUM_EXTRA_COMMANDS 2 -#define SCREENSHOT_COMMAND_IDX (MAX_COMMANDS - 2) -#define WIN_SCREENSHOT_COMMAND_IDX (MAX_COMMANDS - 1) +#define NUM_EXTRA_COMMANDS 3 +#define SCREENSHOT_COMMAND_IDX (MAX_COMMANDS - 3) +#define WIN_SCREENSHOT_COMMAND_IDX (MAX_COMMANDS - 2) +#define AREA_SCREENSHOT_COMMAND_IDX (MAX_COMMANDS - 1) typedef enum { diff --git a/src/org.mate.marco.gschema.xml b/src/org.mate.marco.gschema.xml index 178e4207..ec80cf40 100644 --- a/src/org.mate.marco.gschema.xml +++ b/src/org.mate.marco.gschema.xml @@ -670,6 +670,11 @@ Take a screenshot of a window The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + + '<Shift>Print' + Take a screenshot of an area + The format looks like "<Control>a" or "<Shift><Alt>F1". The parser is fairly liberal and allows lower or upper case, and also abbreviations such as "<Ctl>" and "<Ctrl>". If you set the option to the special string "disabled", then there will be no keybinding for this action. + 'disabled' Run a terminal @@ -753,6 +758,11 @@ The window screenshot command The /apps/marco/global_keybindings/run_command_window_screenshot key defines a keybinding which causes the command specified by this setting to be invoked. + + 'mate-screenshot --area' + The area screenshot command + The /apps/marco/global_keybindings/run_command_area_screenshot key defines a keybinding which causes the command specified by this setting to be invoked. + -- cgit v1.2.1