summaryrefslogtreecommitdiffstats
path: root/sway/commands/resize.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/resize.c')
-rw-r--r--sway/commands/resize.c45
1 files changed, 4 insertions, 41 deletions
diff --git a/sway/commands/resize.c b/sway/commands/resize.c
index c9261535..440937f0 100644
--- a/sway/commands/resize.c
+++ b/sway/commands/resize.c
@@ -66,45 +66,6 @@ static int parse_resize_amount(int argc, char **argv,
66 return 2; 66 return 2;
67} 67}
68 68
69static void calculate_constraints(int *min_width, int *max_width,
70 int *min_height, int *max_height) {
71 struct sway_container *con = config->handler_context.container;
72
73 if (config->floating_minimum_width == -1) { // no minimum
74 *min_width = 0;
75 } else if (config->floating_minimum_width == 0) { // automatic
76 *min_width = 75;
77 } else {
78 *min_width = config->floating_minimum_width;
79 }
80
81 if (config->floating_minimum_height == -1) { // no minimum
82 *min_height = 0;
83 } else if (config->floating_minimum_height == 0) { // automatic
84 *min_height = 50;
85 } else {
86 *min_height = config->floating_minimum_height;
87 }
88
89 if (config->floating_maximum_width == -1 ||
90 container_is_scratchpad_hidden(con)) { // no max
91 *max_width = INT_MAX;
92 } else if (config->floating_maximum_width == 0) { // automatic
93 *max_width = con->workspace->width;
94 } else {
95 *max_width = config->floating_maximum_width;
96 }
97
98 if (config->floating_maximum_height == -1 ||
99 container_is_scratchpad_hidden(con)) { // no max
100 *max_height = INT_MAX;
101 } else if (config->floating_maximum_height == 0) { // automatic
102 *max_height = con->workspace->height;
103 } else {
104 *max_height = config->floating_maximum_height;
105 }
106}
107
108static uint32_t parse_resize_axis(const char *axis) { 69static uint32_t parse_resize_axis(const char *axis) {
109 if (strcasecmp(axis, "width") == 0 || strcasecmp(axis, "horizontal") == 0) { 70 if (strcasecmp(axis, "width") == 0 || strcasecmp(axis, "horizontal") == 0) {
110 return AXIS_HORIZONTAL; 71 return AXIS_HORIZONTAL;
@@ -258,7 +219,8 @@ static struct cmd_results *resize_adjust_floating(uint32_t axis,
258 219
259 // Make sure we're not adjusting beyond floating min/max size 220 // Make sure we're not adjusting beyond floating min/max size
260 int min_width, max_width, min_height, max_height; 221 int min_width, max_width, min_height, max_height;
261 calculate_constraints(&min_width, &max_width, &min_height, &max_height); 222 floating_calculate_constraints(&min_width, &max_width,
223 &min_height, &max_height);
262 if (con->width + grow_width < min_width) { 224 if (con->width + grow_width < min_width) {
263 grow_width = min_width - con->width; 225 grow_width = min_width - con->width;
264 } else if (con->width + grow_width > max_width) { 226 } else if (con->width + grow_width > max_width) {
@@ -383,7 +345,8 @@ static struct cmd_results *resize_set_tiled(struct sway_container *con,
383static struct cmd_results *resize_set_floating(struct sway_container *con, 345static struct cmd_results *resize_set_floating(struct sway_container *con,
384 struct resize_amount *width, struct resize_amount *height) { 346 struct resize_amount *width, struct resize_amount *height) {
385 int min_width, max_width, min_height, max_height, grow_width = 0, grow_height = 0; 347 int min_width, max_width, min_height, max_height, grow_width = 0, grow_height = 0;
386 calculate_constraints(&min_width, &max_width, &min_height, &max_height); 348 floating_calculate_constraints(&min_width, &max_width,
349 &min_height, &max_height);
387 350
388 if (width->amount) { 351 if (width->amount) {
389 switch (width->unit) { 352 switch (width->unit) {