aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Denis Doria <denisdoria@gmail.com>2016-06-01 13:37:50 +0200
committerLibravatar Denis Doria <denisdoria@gmail.com>2016-06-01 13:37:50 +0200
commit0ad7857f909278fde8603b995d59b86437d5247f (patch)
tree25364b13d60ef443fc09f66d3886c477c46868b6
parentMerge pull request #686 from zandrmartin/fix-swaybar-in-08bef67 (diff)
downloadsway-0ad7857f909278fde8603b995d59b86437d5247f.tar.gz
sway-0ad7857f909278fde8603b995d59b86437d5247f.tar.zst
sway-0ad7857f909278fde8603b995d59b86437d5247f.zip
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 <width> x <height>, although the x can be anything.
-rw-r--r--include/config.h3
-rw-r--r--sway/commands.c36
-rw-r--r--sway/config.c2
3 files changed, 40 insertions, 1 deletions
diff --git a/include/config.h b/include/config.h
index 1a6ba19d..9e59cb66 100644
--- a/include/config.h
+++ b/include/config.h
@@ -227,11 +227,12 @@ struct sway_config {
227 uint32_t background; 227 uint32_t background;
228 } border_colors; 228 } border_colors;
229 229
230 // floating view minimum 230 // floating view
231 int32_t floating_maximum_width; 231 int32_t floating_maximum_width;
232 int32_t floating_maximum_height; 232 int32_t floating_maximum_height;
233 int32_t floating_minimum_width; 233 int32_t floating_minimum_width;
234 int32_t floating_minimum_height; 234 int32_t floating_minimum_height;
235 char *floating_minimum_size;
235}; 236};
236 237
237/** 238/**
diff --git a/sway/commands.c b/sway/commands.c
index 62852980..d8f61242 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -58,6 +58,7 @@ static sway_cmd cmd_exec;
58static sway_cmd cmd_exec_always; 58static sway_cmd cmd_exec_always;
59static sway_cmd cmd_exit; 59static sway_cmd cmd_exit;
60static sway_cmd cmd_floating; 60static sway_cmd cmd_floating;
61static sway_cmd cmd_floating_minimum_size;
61static sway_cmd cmd_floating_mod; 62static sway_cmd cmd_floating_mod;
62static sway_cmd cmd_floating_scroll; 63static sway_cmd cmd_floating_scroll;
63static sway_cmd cmd_focus; 64static sway_cmd cmd_focus;
@@ -673,6 +674,40 @@ static struct cmd_results *cmd_floating(int argc, char **argv) {
673 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 674 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
674} 675}
675 676
677static struct cmd_results *cmd_floating_minimum_size(int argc, char **argv) {
678 struct cmd_results *error = NULL;
679 int32_t width;
680 int32_t height;
681 char *ptr;
682
683 if ((error = checkarg(argc, "floating_minimum_size", EXPECTED_EQUAL_TO, 3))) {
684 return error;
685 }
686 width = strtol(argv[0], &ptr, 10);
687 height = strtol(argv[2], &ptr, 10);
688
689 if (width <= 0) {
690 sway_log(L_DEBUG, "floating_minimum_size invalid width value: '%s'", argv[0]);
691
692 } else {
693 config->floating_minimum_width = width;
694
695 }
696
697 if (height <= 0) {
698 sway_log(L_DEBUG, "floating_minimum_size invalid height value: '%s'", argv[2]);
699 }
700 else {
701 config->floating_minimum_height = height;
702
703 }
704
705 sway_log(L_DEBUG, "New floating_minimum_size: '%d' x '%d'", config->floating_minimum_width,
706 config->floating_minimum_height);
707
708 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
709}
710
676static struct cmd_results *cmd_floating_mod(int argc, char **argv) { 711static struct cmd_results *cmd_floating_mod(int argc, char **argv) {
677 struct cmd_results *error = NULL; 712 struct cmd_results *error = NULL;
678 if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) { 713 if ((error = checkarg(argc, "floating_modifier", EXPECTED_AT_LEAST, 1))) {
@@ -2433,6 +2468,7 @@ static struct cmd_handler handlers[] = {
2433 { "exec_always", cmd_exec_always }, 2468 { "exec_always", cmd_exec_always },
2434 { "exit", cmd_exit }, 2469 { "exit", cmd_exit },
2435 { "floating", cmd_floating }, 2470 { "floating", cmd_floating },
2471 { "floating_minimum_size", cmd_floating_minimum_size },
2436 { "floating_modifier", cmd_floating_mod }, 2472 { "floating_modifier", cmd_floating_mod },
2437 { "floating_scroll", cmd_floating_scroll }, 2473 { "floating_scroll", cmd_floating_scroll },
2438 { "focus", cmd_focus }, 2474 { "focus", cmd_focus },
diff --git a/sway/config.c b/sway/config.c
index 95285eba..b4e740f6 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -178,6 +178,8 @@ static void config_defaults(struct sway_config *config) {
178 config->floating_minimum_width = 75; 178 config->floating_minimum_width = 75;
179 config->floating_minimum_height = 50; 179 config->floating_minimum_height = 50;
180 180
181 config->floating_minimum_size = strdup("");
182
181 // Flags 183 // Flags
182 config->focus_follows_mouse = true; 184 config->focus_follows_mouse = true;
183 config->mouse_warping = true; 185 config->mouse_warping = true;