From 9d8233d3a0ad668a13e4458a44573ae6292c8187 Mon Sep 17 00:00:00 2001 From: David96 Date: Thu, 3 Jan 2019 12:29:53 +0100 Subject: [PATCH] Add "tiling_drag_threshold_on_focused" command --- include/sway/commands.h | 1 + include/sway/config.h | 1 + sway/commands.c | 1 + sway/commands/tiling_drag_threshold_on_focused.c | 13 +++++++++++++ sway/config.c | 1 + sway/input/cursor.c | 4 +++- sway/meson.build | 1 + sway/sway.5.scd | 4 ++++ 8 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 sway/commands/tiling_drag_threshold_on_focused.c diff --git a/include/sway/commands.h b/include/sway/commands.h index 7d0ff8388..0a35b0e77 100644 --- a/include/sway/commands.h +++ b/include/sway/commands.h @@ -173,6 +173,7 @@ sway_cmd cmd_swaynag_command; sway_cmd cmd_swap; sway_cmd cmd_tiling_drag; sway_cmd cmd_tiling_drag_threshold; +sway_cmd cmd_tiling_drag_threshold_on_focused; sway_cmd cmd_title_align; sway_cmd cmd_title_format; sway_cmd cmd_titlebar_border_thickness; diff --git a/include/sway/config.h b/include/sway/config.h index ebf16e6a3..1af1358c5 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -429,6 +429,7 @@ struct sway_config { bool tiling_drag; int tiling_drag_threshold; + bool tiling_drag_threshold_on_focused; bool smart_gaps; int gaps_inner; diff --git a/sway/commands.c b/sway/commands.c index 0883b57b1..814b7a789 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -88,6 +88,7 @@ static struct cmd_handler handlers[] = { { "smart_gaps", cmd_smart_gaps }, { "tiling_drag", cmd_tiling_drag }, { "tiling_drag_threshold", cmd_tiling_drag_threshold }, + { "tiling_drag_threshold_on_focused", cmd_tiling_drag_threshold_on_focused }, { "title_align", cmd_title_align }, { "titlebar_border_thickness", cmd_titlebar_border_thickness }, { "titlebar_padding", cmd_titlebar_padding }, diff --git a/sway/commands/tiling_drag_threshold_on_focused.c b/sway/commands/tiling_drag_threshold_on_focused.c new file mode 100644 index 000000000..c634024bf --- /dev/null +++ b/sway/commands/tiling_drag_threshold_on_focused.c @@ -0,0 +1,13 @@ +#include "sway/commands.h" +#include "util.h" + +struct cmd_results *cmd_tiling_drag_threshold_on_focused(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "tiling_drag_threshold_on_focused", EXPECTED_EQUAL_TO, 1))) { + return error; + } + + config->tiling_drag_threshold_on_focused = parse_boolean(argv[0], config->tiling_drag_threshold_on_focused); + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} diff --git a/sway/config.c b/sway/config.c index 5d631b7e3..c302cb810 100644 --- a/sway/config.c +++ b/sway/config.c @@ -234,6 +234,7 @@ static void config_defaults(struct sway_config *config) { config->title_align = ALIGN_LEFT; config->tiling_drag = true; config->tiling_drag_threshold = 9; + config->tiling_drag_threshold_on_focused = false; config->smart_gaps = false; config->gaps_inner = 0; diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 516251f74..f091cce3f 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -1022,7 +1022,9 @@ void dispatch_cursor_button(struct sway_cursor *cursor, // If moving a previously unfocused container by it's title bar, use a // threshold for the drag. - if (!mod_pressed && !focused && config->tiling_drag_threshold > 0) { + if (!mod_pressed && + (!focused || config->tiling_drag_threshold_on_focused) && + config->tiling_drag_threshold > 0) { seat_begin_move_tiling_threshold(seat, cont, button); } else { seat_begin_move_tiling(seat, cont, button); diff --git a/sway/meson.build b/sway/meson.build index 98676ce0f..a167134ae 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -90,6 +90,7 @@ sway_sources = files( 'commands/swap.c', 'commands/tiling_drag.c', 'commands/tiling_drag_threshold.c', + 'commands/tiling_drag_threshold_on_focused.c', 'commands/title_align.c', 'commands/title_format.c', 'commands/titlebar_border_thickness.c', diff --git a/sway/sway.5.scd b/sway/sway.5.scd index 37a9b24ca..dc20eea6b 100644 --- a/sway/sway.5.scd +++ b/sway/sway.5.scd @@ -581,6 +581,10 @@ The default colors are: _threshold_ is multiplied by the scale of the output that the cursor on. The default is 9. +*tiling\_drag\_threshold\_on\_focused* yes|no + If set to yes, the _tiling\_drag\_threshold_ is also applied to focused + containers. The default is _no_. + *title\_align* left|center|right Sets the title alignment. If _right_ is selected and _show\_marks_ is set to _yes_, the marks will be shown on the _left_ side instead of the