Skip to content

Commit f62775f

Browse files
committed
feat: add respect_tiled_min_size option, disable by default
1 parent d7dafd2 commit f62775f

7 files changed

Lines changed: 35 additions & 17 deletions

File tree

TODO.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
# Misc
1515
- Rework the docs to be easier to use
16-
- Minimum sizes are currently always respected, clipping may be preferred in most cases
1716
- Improve the README (include video, images, better info)
1817

1918
# Potential

examples/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ doorsctl config left_padding <pixels>
343343

344344
Sets the left padding for all desktops.
345345

346+
```
347+
doorsctl config respect_tiled_min_size <true|false>
348+
```
349+
350+
When true, tiled windows will not go below their configured minimum size no matter what.
351+
346352
```
347353
doorsctl config normal_border_color <color>
348354
```

include/types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ extern int border_width;
266266
extern int window_gap;
267267
extern bool smart_gaps;
268268
extern bool smart_borders;
269+
extern bool respect_tiled_min_size;
269270
extern bool focus_wrapping;
270271
extern int focus_on_activate; // focus_on_activate_mode_t
271272
extern double split_ratio;

src/ipc_cmd/config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ void ipc_cmd_config(char **args, int num, int client_fd) {
8282
ipc_handle_bool(args, num, client_fd, &smart_gaps, IPC_FLAG_COMMIT);
8383
} else if (streq("smart_borders", *args)) {
8484
ipc_handle_bool(args, num, client_fd, &smart_borders, IPC_FLAG_COMMIT);
85+
} else if (streq("respect_tiled_min_size", *args)) {
86+
ipc_handle_bool(args, num, client_fd, &respect_tiled_min_size, IPC_FLAG_COMMIT);
8587
} else if (streq("focus_wrapping", *args)) {
8688
ipc_handle_bool(args, num, client_fd, &focus_wrapping, IPC_FLAG_COMMIT);
8789
} else if (streq("focus_on_activate", *args)) {

src/ipc_cmd/wm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ void ipc_cmd_wm(char **args, int num, int client_fd) {
5050
smart_gaps ? "true" : "false");
5151
offset += snprintf(buf + offset, sizeof(buf) - offset, " \"smart_borders\": %s,\n",
5252
smart_borders ? "true" : "false");
53+
offset += snprintf(buf + offset, sizeof(buf) - offset, " \"respect_tiled_min_size\": %s,\n",
54+
respect_tiled_min_size ? "true" : "false");
5355
offset += snprintf(buf + offset, sizeof(buf) - offset, " \"focus_wrapping\": %s,\n",
5456
focus_wrapping ? "true" : "false");
5557

src/master_stack.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,17 @@ static void set_node_geom(node_t *n, struct wlr_box geom, output_t *m, desktop_t
142142
r.height = MIN_HEIGHT;
143143
}
144144

145-
if ((int)n->constraints.min_width > MIN_WIDTH && r.width < (int)n->constraints.min_width &&
146-
geom.width > 0) {
147-
r.x = geom.x + (geom.width - (int)n->constraints.min_width) / 2;
148-
r.width = n->constraints.min_width;
149-
}
150-
if ((int)n->constraints.min_height > MIN_HEIGHT && r.height < (int)n->constraints.min_height &&
151-
geom.height > 0) {
152-
r.y = geom.y + (geom.height - (int)n->constraints.min_height) / 2;
153-
r.height = n->constraints.min_height;
145+
if (respect_tiled_min_size) {
146+
if ((int)n->constraints.min_width > MIN_WIDTH && r.width < (int)n->constraints.min_width &&
147+
geom.width > 0) {
148+
r.x = geom.x + (geom.width - (int)n->constraints.min_width) / 2;
149+
r.width = n->constraints.min_width;
150+
}
151+
if ((int)n->constraints.min_height > MIN_HEIGHT && r.height < (int)n->constraints.min_height &&
152+
geom.height > 0) {
153+
r.y = geom.y + (geom.height - (int)n->constraints.min_height) / 2;
154+
r.height = n->constraints.min_height;
155+
}
154156
}
155157

156158
n->client->tiled_rectangle = r;

src/tree.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ int border_width = 2;
6060
int window_gap = 10;
6161
bool smart_gaps = false;
6262
bool smart_borders = false;
63+
bool respect_tiled_min_size = false;
6364
bool focus_wrapping = true;
6465
int focus_on_activate = FOCUS_ON_ACTIVATE_FOCUS;
6566
double split_ratio = 0.5;
@@ -387,7 +388,7 @@ static void render_leaf(output_t *m, desktop_t *d, node_t *n, struct wlr_box rec
387388
}
388389

389390
// clamp up to constraints and center within the tile slot
390-
if (use_centering) {
391+
if (respect_tiled_min_size && use_centering) {
391392
if ((int)n->constraints.min_width > MIN_WIDTH && r.width < (int)n->constraints.min_width &&
392393
slot.width > 0) {
393394
r.x = slot.x + (slot.width - (int)n->constraints.min_width) / 2;
@@ -527,15 +528,20 @@ static void compute_split_rects(node_t *n, desktop_t *d, struct wlr_box rect,
527528
*first_rect = rect;
528529
*second_rect = rect;
529530

531+
uint16_t first_min_w = respect_tiled_min_size &&
532+
n->first_child ? n->first_child->constraints.min_width : 0;
533+
uint16_t second_min_w = respect_tiled_min_size &&
534+
n->second_child ? n->second_child->constraints.min_width : 0;
535+
uint16_t first_min_h = respect_tiled_min_size &&
536+
n->first_child ? n->first_child->constraints.min_height : 0;
537+
uint16_t second_min_h = respect_tiled_min_size &&
538+
n->second_child ? n->second_child->constraints.min_height : 0;
539+
530540
if (n->split_type == TYPE_VERTICAL) {
531-
split_dimension(rect.width, n->split_ratio,
532-
n->first_child ? n->first_child->constraints.min_width : 0,
533-
n->second_child ? n->second_child->constraints.min_width : 0, &first_rect->width,
541+
split_dimension(rect.width, n->split_ratio, first_min_w, second_min_w, &first_rect->width,
534542
&second_rect->width, &second_rect->x);
535543
} else {
536-
split_dimension(rect.height, n->split_ratio,
537-
n->first_child ? n->first_child->constraints.min_height : 0,
538-
n->second_child ? n->second_child->constraints.min_height : 0, &first_rect->height,
544+
split_dimension(rect.height, n->split_ratio, first_min_h, second_min_h, &first_rect->height,
539545
&second_rect->height, &second_rect->y);
540546
}
541547
}

0 commit comments

Comments
 (0)