diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-06-02 11:46:25 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-06-02 11:46:25 -0400 |
commit | 09670fc1a7485d75774c184fcbf8e907b9481aaa (patch) | |
tree | fad070df6be2bef62346c4a8232d869e3cf41fdc | |
parent | Merge pull request #690 from zandrmartin/smartgap-hide-borders (diff) | |
parent | Sync master (diff) | |
download | sway-09670fc1a7485d75774c184fcbf8e907b9481aaa.tar.gz sway-09670fc1a7485d75774c184fcbf8e907b9481aaa.tar.zst sway-09670fc1a7485d75774c184fcbf8e907b9481aaa.zip |
Merge pull request #691 from thuck/floating_size_conf
floating_maximum_size initial implementation
-rw-r--r-- | sway/commands.c | 36 | ||||
-rw-r--r-- | sway/config.c | 4 | ||||
-rw-r--r-- | sway/container.c | 25 | ||||
-rw-r--r-- | sway/sway.5.txt | 7 |
4 files changed, 65 insertions, 7 deletions
diff --git a/sway/commands.c b/sway/commands.c index d8f61242..3befee13 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -58,6 +58,7 @@ static sway_cmd cmd_exec; | |||
58 | static sway_cmd cmd_exec_always; | 58 | static sway_cmd cmd_exec_always; |
59 | static sway_cmd cmd_exit; | 59 | static sway_cmd cmd_exit; |
60 | static sway_cmd cmd_floating; | 60 | static sway_cmd cmd_floating; |
61 | static sway_cmd cmd_floating_maximum_size; | ||
61 | static sway_cmd cmd_floating_minimum_size; | 62 | static sway_cmd cmd_floating_minimum_size; |
62 | static sway_cmd cmd_floating_mod; | 63 | static sway_cmd cmd_floating_mod; |
63 | static sway_cmd cmd_floating_scroll; | 64 | static sway_cmd cmd_floating_scroll; |
@@ -674,6 +675,40 @@ static struct cmd_results *cmd_floating(int argc, char **argv) { | |||
674 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 675 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
675 | } | 676 | } |
676 | 677 | ||
678 | static struct cmd_results *cmd_floating_maximum_size(int argc, char **argv) { | ||
679 | struct cmd_results *error = NULL; | ||
680 | int32_t width; | ||
681 | int32_t height; | ||
682 | char *ptr; | ||
683 | |||
684 | if ((error = checkarg(argc, "floating_maximum_size", EXPECTED_EQUAL_TO, 3))) { | ||
685 | return error; | ||
686 | } | ||
687 | width = strtol(argv[0], &ptr, 10); | ||
688 | height = strtol(argv[2], &ptr, 10); | ||
689 | |||
690 | if (width < -1) { | ||
691 | sway_log(L_DEBUG, "floating_maximum_size invalid width value: '%s'", argv[0]); | ||
692 | |||
693 | } else { | ||
694 | config->floating_maximum_width = width; | ||
695 | |||
696 | } | ||
697 | |||
698 | if (height < -1) { | ||
699 | sway_log(L_DEBUG, "floating_maximum_size invalid height value: '%s'", argv[2]); | ||
700 | } | ||
701 | else { | ||
702 | config->floating_maximum_height = height; | ||
703 | |||
704 | } | ||
705 | |||
706 | sway_log(L_DEBUG, "New floating_maximum_size: '%d' x '%d'", config->floating_maximum_width, | ||
707 | config->floating_maximum_height); | ||
708 | |||
709 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
710 | } | ||
711 | |||
677 | static struct cmd_results *cmd_floating_minimum_size(int argc, char **argv) { | 712 | static struct cmd_results *cmd_floating_minimum_size(int argc, char **argv) { |
678 | struct cmd_results *error = NULL; | 713 | struct cmd_results *error = NULL; |
679 | int32_t width; | 714 | int32_t width; |
@@ -2468,6 +2503,7 @@ static struct cmd_handler handlers[] = { | |||
2468 | { "exec_always", cmd_exec_always }, | 2503 | { "exec_always", cmd_exec_always }, |
2469 | { "exit", cmd_exit }, | 2504 | { "exit", cmd_exit }, |
2470 | { "floating", cmd_floating }, | 2505 | { "floating", cmd_floating }, |
2506 | { "floating_maximum_size", cmd_floating_maximum_size }, | ||
2471 | { "floating_minimum_size", cmd_floating_minimum_size }, | 2507 | { "floating_minimum_size", cmd_floating_minimum_size }, |
2472 | { "floating_modifier", cmd_floating_mod }, | 2508 | { "floating_modifier", cmd_floating_mod }, |
2473 | { "floating_scroll", cmd_floating_scroll }, | 2509 | { "floating_scroll", cmd_floating_scroll }, |
diff --git a/sway/config.c b/sway/config.c index 95285eba..15108123 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -173,8 +173,8 @@ static void config_defaults(struct sway_config *config) { | |||
173 | config->font_height = get_font_text_height(config->font); | 173 | config->font_height = get_font_text_height(config->font); |
174 | 174 | ||
175 | // floating view | 175 | // floating view |
176 | config->floating_maximum_width = -1; | 176 | config->floating_maximum_width = 0; |
177 | config->floating_maximum_height = -1; | 177 | config->floating_maximum_height = 0; |
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 | ||
diff --git a/sway/container.c b/sway/container.c index e00d2d7e..15975064 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -329,6 +329,9 @@ swayc_t *new_floating_view(wlc_handle handle) { | |||
329 | } | 329 | } |
330 | 330 | ||
331 | void floating_view_sane_size(swayc_t *view) { | 331 | void floating_view_sane_size(swayc_t *view) { |
332 | // floating_minimum is used as sane value. | ||
333 | // floating_maximum has priority in case of conflict | ||
334 | // TODO: implement total_outputs_dimensions() | ||
332 | if (config->floating_minimum_height != -1 && | 335 | if (config->floating_minimum_height != -1 && |
333 | view->desired_height < config->floating_minimum_height) { | 336 | view->desired_height < config->floating_minimum_height) { |
334 | view->desired_height = config->floating_minimum_height; | 337 | view->desired_height = config->floating_minimum_height; |
@@ -338,14 +341,26 @@ void floating_view_sane_size(swayc_t *view) { | |||
338 | view->desired_width = config->floating_minimum_width; | 341 | view->desired_width = config->floating_minimum_width; |
339 | } | 342 | } |
340 | 343 | ||
341 | if (config->floating_maximum_height != -1 && | 344 | // if 0 do not resize, only enforce max value |
342 | view->desired_height > config->floating_maximum_height) { | 345 | if (config->floating_maximum_height == 0) { |
343 | view->desired_height = config->floating_maximum_height; | 346 | // Missing total_outputs_dimensions() using swayc_active_workspace() |
344 | } | 347 | config->floating_maximum_height = swayc_active_workspace()->height; |
345 | if (config->floating_maximum_width != -1 && | 348 | |
349 | } else if (config->floating_maximum_height != -1 && | ||
350 | view->desired_height > config->floating_maximum_height) { | ||
351 | view->desired_height = config->floating_maximum_height; | ||
352 | } | ||
353 | |||
354 | // if 0 do not resize, only enforce max value | ||
355 | if (config->floating_maximum_width == 0) { | ||
356 | // Missing total_outputs_dimensions() using swayc_active_workspace() | ||
357 | config->floating_maximum_width = swayc_active_workspace()->width; | ||
358 | |||
359 | } else if (config->floating_maximum_width != -1 && | ||
346 | view->desired_width > config->floating_maximum_width) { | 360 | view->desired_width > config->floating_maximum_width) { |
347 | view->desired_width = config->floating_maximum_width; | 361 | view->desired_width = config->floating_maximum_width; |
348 | } | 362 | } |
363 | |||
349 | sway_log(L_DEBUG, "Sane values for view to %d x %d @ %.f, %.f", | 364 | sway_log(L_DEBUG, "Sane values for view to %d x %d @ %.f, %.f", |
350 | view->desired_width, view->desired_height, view->x, view->y); | 365 | view->desired_width, view->desired_height, view->x, view->y); |
351 | 366 | ||
diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 1afcf24f..8faa5345 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt | |||
@@ -65,6 +65,13 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( | |||
65 | **floating** <enable|disable|toggle>:: | 65 | **floating** <enable|disable|toggle>:: |
66 | Make focused view floating, non-floating, or the opposite of what it is now. | 66 | Make focused view floating, non-floating, or the opposite of what it is now. |
67 | 67 | ||
68 | **floating_maximum_size** <width> x <height>:: | ||
69 | Specifies the maximum dimensions of floating windows. | ||
70 | Uses the container dimensions as default. | ||
71 | -1 x -1 will remove any restriction on dimentions. | ||
72 | 0 x 0 has the same behavior as not setting any value. | ||
73 | If in conflict this option has precedence over floating_minimum_size. | ||
74 | |||
68 | **floating_minimum_size** <width> x <height>:: | 75 | **floating_minimum_size** <width> x <height>:: |
69 | Specifies the minimum dimensions of floating windows. | 76 | Specifies the minimum dimensions of floating windows. |
70 | Default parameters are 75 x 50. | 77 | Default parameters are 75 x 50. |