From 0ad7857f909278fde8603b995d59b86437d5247f Mon Sep 17 00:00:00 2001 From: Denis Doria Date: Wed, 1 Jun 2016 13:37:50 +0200 Subject: [PATCH 1/3] Included option floating_minimum_size Values cannot be negative or 0; if so uses the default 75x50. Uses the same syntax as i3: floating_minimum_size x , although the x can be anything. --- include/config.h | 3 ++- sway/commands.c | 36 ++++++++++++++++++++++++++++++++++++ sway/config.c | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/include/config.h b/include/config.h index 1a6ba19da..9e59cb66e 100644 --- a/include/config.h +++ b/include/config.h @@ -227,11 +227,12 @@ struct sway_config { uint32_t background; } border_colors; - // floating view minimum + // floating view int32_t floating_maximum_width; int32_t floating_maximum_height; int32_t floating_minimum_width; int32_t floating_minimum_height; + char *floating_minimum_size; }; /** diff --git a/sway/commands.c b/sway/commands.c index 628529802..d8f61242a 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -58,6 +58,7 @@ static sway_cmd cmd_exec; static sway_cmd cmd_exec_always; static sway_cmd cmd_exit; static sway_cmd cmd_floating; +static sway_cmd cmd_floating_minimum_size; static sway_cmd cmd_floating_mod; static sway_cmd cmd_floating_scroll; static sway_cmd cmd_focus; @@ -673,6 +674,40 @@ static struct cmd_results *cmd_floating(int argc, char **argv) { return cmd_results_new(CMD_SUCCESS, NULL, NULL); } +static struct cmd_results *cmd_floating_minimum_size(int argc, char **argv) { + struct cmd_results *error = NULL; + int32_t width; + int32_t height; + char *ptr; + + if ((error = checkarg(argc, "floating_minimum_size", EXPECTED_EQUAL_TO, 3))) { + return error; + } + width = strtol(argv[0], &ptr, 10); + height = strtol(argv[2], &ptr, 10); + + if (width <= 0) { + sway_log(L_DEBUG, "floating_minimum_size invalid width value: '%s'", argv[0]); + + } else { + config->floating_minimum_width = width; + + } + + if (height <= 0) { + sway_log(L_DEBUG, "floating_minimum_size invalid height value: '%s'", argv[2]); + } + else { + config->floating_minimum_height = height; + + } + + sway_log(L_DEBUG, "New floating_minimum_size: '%d' x '%d'", config->floating_minimum_width, + config->floating_minimum_height); + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + static struct cmd_results *cmd_floating_mod(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) { @@ -2433,6 +2468,7 @@ static struct cmd_handler handlers[] = { { "exec_always", cmd_exec_always }, { "exit", cmd_exit }, { "floating", cmd_floating }, + { "floating_minimum_size", cmd_floating_minimum_size }, { "floating_modifier", cmd_floating_mod }, { "floating_scroll", cmd_floating_scroll }, { "focus", cmd_focus }, diff --git a/sway/config.c b/sway/config.c index 95285eba6..b4e740f6b 100644 --- a/sway/config.c +++ b/sway/config.c @@ -178,6 +178,8 @@ static void config_defaults(struct sway_config *config) { config->floating_minimum_width = 75; config->floating_minimum_height = 50; + config->floating_minimum_size = strdup(""); + // Flags config->focus_follows_mouse = true; config->mouse_warping = true; From b6685da35b83271276e630dd3981bd8dae407bdf Mon Sep 17 00:00:00 2001 From: Denis Doria Date: Wed, 1 Jun 2016 14:11:49 +0200 Subject: [PATCH 2/3] Update man page with information about floating_maximum_size --- sway/sway.5.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 32ff79d8f..1afcf24f0 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -65,6 +65,11 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( **floating** :: Make focused view floating, non-floating, or the opposite of what it is now. +**floating_minimum_size** x :: + Specifies the minimum dimensions of floating windows. + Default parameters are 75 x 50. + -1 and 0 are invalid parameters, default will be used instead. + **focus** :: Direction may be one of _up_, _down_, _left_, _right_, or _parent_. The directional focus commands will move the focus in that direction. The parent From 009eaccd421cf0640cdebc3bac96d67c599ff616 Mon Sep 17 00:00:00 2001 From: Denis Doria Date: Wed, 1 Jun 2016 14:44:02 +0200 Subject: [PATCH 3/3] Clean up not used variables --- include/config.h | 1 - sway/config.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/include/config.h b/include/config.h index 9e59cb66e..d591daf2a 100644 --- a/include/config.h +++ b/include/config.h @@ -232,7 +232,6 @@ struct sway_config { int32_t floating_maximum_height; int32_t floating_minimum_width; int32_t floating_minimum_height; - char *floating_minimum_size; }; /** diff --git a/sway/config.c b/sway/config.c index b4e740f6b..95285eba6 100644 --- a/sway/config.c +++ b/sway/config.c @@ -178,8 +178,6 @@ static void config_defaults(struct sway_config *config) { config->floating_minimum_width = 75; config->floating_minimum_height = 50; - config->floating_minimum_size = strdup(""); - // Flags config->focus_follows_mouse = true; config->mouse_warping = true;