Add "tiling_drag_threshold_on_focused" command

This commit is contained in:
David96 2019-01-03 12:29:53 +01:00
parent 1450a9e9f9
commit 9d8233d3a0
No known key found for this signature in database
GPG key ID: 5ACECCD881CF2621
8 changed files with 25 additions and 1 deletions

View file

@ -173,6 +173,7 @@ sway_cmd cmd_swaynag_command;
sway_cmd cmd_swap; sway_cmd cmd_swap;
sway_cmd cmd_tiling_drag; sway_cmd cmd_tiling_drag;
sway_cmd cmd_tiling_drag_threshold; sway_cmd cmd_tiling_drag_threshold;
sway_cmd cmd_tiling_drag_threshold_on_focused;
sway_cmd cmd_title_align; sway_cmd cmd_title_align;
sway_cmd cmd_title_format; sway_cmd cmd_title_format;
sway_cmd cmd_titlebar_border_thickness; sway_cmd cmd_titlebar_border_thickness;

View file

@ -429,6 +429,7 @@ struct sway_config {
bool tiling_drag; bool tiling_drag;
int tiling_drag_threshold; int tiling_drag_threshold;
bool tiling_drag_threshold_on_focused;
bool smart_gaps; bool smart_gaps;
int gaps_inner; int gaps_inner;

View file

@ -88,6 +88,7 @@ static struct cmd_handler handlers[] = {
{ "smart_gaps", cmd_smart_gaps }, { "smart_gaps", cmd_smart_gaps },
{ "tiling_drag", cmd_tiling_drag }, { "tiling_drag", cmd_tiling_drag },
{ "tiling_drag_threshold", cmd_tiling_drag_threshold }, { "tiling_drag_threshold", cmd_tiling_drag_threshold },
{ "tiling_drag_threshold_on_focused", cmd_tiling_drag_threshold_on_focused },
{ "title_align", cmd_title_align }, { "title_align", cmd_title_align },
{ "titlebar_border_thickness", cmd_titlebar_border_thickness }, { "titlebar_border_thickness", cmd_titlebar_border_thickness },
{ "titlebar_padding", cmd_titlebar_padding }, { "titlebar_padding", cmd_titlebar_padding },

View file

@ -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);
}

View file

@ -234,6 +234,7 @@ static void config_defaults(struct sway_config *config) {
config->title_align = ALIGN_LEFT; config->title_align = ALIGN_LEFT;
config->tiling_drag = true; config->tiling_drag = true;
config->tiling_drag_threshold = 9; config->tiling_drag_threshold = 9;
config->tiling_drag_threshold_on_focused = false;
config->smart_gaps = false; config->smart_gaps = false;
config->gaps_inner = 0; config->gaps_inner = 0;

View file

@ -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 // If moving a previously unfocused container by it's title bar, use a
// threshold for the drag. // 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); seat_begin_move_tiling_threshold(seat, cont, button);
} else { } else {
seat_begin_move_tiling(seat, cont, button); seat_begin_move_tiling(seat, cont, button);

View file

@ -90,6 +90,7 @@ sway_sources = files(
'commands/swap.c', 'commands/swap.c',
'commands/tiling_drag.c', 'commands/tiling_drag.c',
'commands/tiling_drag_threshold.c', 'commands/tiling_drag_threshold.c',
'commands/tiling_drag_threshold_on_focused.c',
'commands/title_align.c', 'commands/title_align.c',
'commands/title_format.c', 'commands/title_format.c',
'commands/titlebar_border_thickness.c', 'commands/titlebar_border_thickness.c',

View file

@ -581,6 +581,10 @@ The default colors are:
_threshold_ is multiplied by the scale of the output that the cursor on. _threshold_ is multiplied by the scale of the output that the cursor on.
The default is 9. 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 *title\_align* left|center|right
Sets the title alignment. If _right_ is selected and _show\_marks_ is set 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 to _yes_, the marks will be shown on the _left_ side instead of the