From 31aad46c4f1e87f0a2de9883cb34932d7b1d984b Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Sat, 12 Aug 2023 11:37:30 -0500 Subject: [PATCH 1/2] Make floating modifier adhere to shortcuts_inhibitor floating_modifier is currently triggered when the modifier is pressed, and when a mouse's left or right button is pressed even if there is an existing shortcuts_inhibitor. This changes the default behavior to only change the current seatop when there is no active shortcuts_inhibitor. I've added an additional optional `--inhibited` option to the `floating_modifier` command. When `--inhibited` is passed, the seatop is changed regardless of if there is an active shortcuts_inhibitor. --- include/sway/config.h | 1 + sway/commands/floating_modifier.c | 23 ++++++++++++++++------- sway/config.c | 1 + sway/input/seatop_default.c | 7 ++++++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index dfa3c1b7b..1d8c8992b 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -507,6 +507,7 @@ struct sway_config { struct bar_config *current_bar; uint32_t floating_mod; bool floating_mod_inverse; + bool floating_mod_inhibited; uint32_t dragging_key; uint32_t resizing_key; char *floating_scroll_up_cmd; diff --git a/sway/commands/floating_modifier.c b/sway/commands/floating_modifier.c index c02bce978..d809851d0 100644 --- a/sway/commands/floating_modifier.c +++ b/sway/commands/floating_modifier.c @@ -19,13 +19,22 @@ struct cmd_results *cmd_floating_modifier(int argc, char **argv) { return cmd_results_new(CMD_INVALID, "Invalid modifier"); } - if (argc == 1 || strcasecmp(argv[1], "normal") == 0) { - config->floating_mod_inverse = false; - } else if (strcasecmp(argv[1], "inverse") == 0) { - config->floating_mod_inverse = true; - } else { - return cmd_results_new(CMD_INVALID, - "Usage: floating_modifier [inverse|normal]"); + argv++; + argc--; + while (argc > 0) + { + if (strcasecmp(argv[0], "normal") == 0) { + config->floating_mod_inverse = false; + } else if (strcasecmp(argv[0], "inverse") == 0) { + config->floating_mod_inverse = true; + } else if (strcasecmp(argv[0], "--inhibited") == 0){ + config->floating_mod_inhibited = true; + } else { + return cmd_results_new(CMD_INVALID, + "Usage: floating_modifier [inverse|normal [--inhibited]"); + } + argv++; + argc--; } config->floating_mod = mod; diff --git a/sway/config.c b/sway/config.c index 5058efcc0..d61d3f813 100644 --- a/sway/config.c +++ b/sway/config.c @@ -242,6 +242,7 @@ static void config_defaults(struct sway_config *config) { config->floating_mod = 0; config->floating_mod_inverse = false; + config->floating_mod_inhibited = false; config->dragging_key = BTN_LEFT; config->resizing_key = BTN_RIGHT; diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 42ce333b8..7fd00d718 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -403,7 +403,12 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, } // Handle tiling resize via mod - bool mod_pressed = modifiers & config->floating_mod; + struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor = + keyboard_shortcuts_inhibitor_get_for_focused_surface(seat); + bool shortcuts_inhibited = sway_inhibitor && sway_inhibitor->inhibitor->active; + bool mod_pressed = modifiers & config->floating_mod && (!shortcuts_inhibited + || config->floating_mod_inhibited); + if (cont && !is_floating_or_child && mod_pressed && state == WL_POINTER_BUTTON_STATE_PRESSED) { uint32_t btn_resize = config->floating_mod_inverse ? From 94cf26d3b707cda46b0376645c6ccd27ec537416 Mon Sep 17 00:00:00 2001 From: Alex Maese Date: Sat, 12 Aug 2023 11:50:03 -0500 Subject: [PATCH 2/2] Inhibit floating modifier for tablet tool tip --- sway/input/seatop_default.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 7fd00d718..d407b48f0 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c @@ -247,8 +247,12 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, bool is_floating_or_child = container_is_floating_or_child(cont); bool is_fullscreen_or_child = container_is_fullscreen_or_child(cont); struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); + struct sway_keyboard_shortcuts_inhibitor *sway_inhibitor = + keyboard_shortcuts_inhibitor_get_for_focused_surface(seat); + bool shortcuts_inhibited = sway_inhibitor && sway_inhibitor->inhibitor->active; bool mod_pressed = keyboard && - (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod); + (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod) + && (!shortcuts_inhibited || config->floating_mod_inhibited); // Handle beginning floating move if (is_floating_or_child && !is_fullscreen_or_child && mod_pressed) {