From 72e0a560d9836c5e8658003f548203bcd722e565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Fri, 24 Jun 2022 19:15:24 -0500 Subject: respect size hints --- dwl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'dwl.c') diff --git a/dwl.c b/dwl.c index e349d8b..36a7543 100644 --- a/dwl.c +++ b/dwl.c @@ -381,9 +381,15 @@ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; void applybounds(Client *c, struct wlr_box *bbox) { - /* set minimum possible */ - c->geom.width = MAX(1, c->geom.width); - c->geom.height = MAX(1, c->geom.height); + struct wlr_box min = {0}, max = {0}; + client_get_size_hints(c, &max, &min); + /* try to set size hints */ + c->geom.width = MAX(min.width + (2 * c->bw), c->geom.width); + c->geom.height = MAX(min.height + (2 * c->bw), c->geom.height); + if (max.width > 0) + c->geom.width = MIN(max.width + (2 * c->bw), c->geom.width); + if (max.height > 0) + c->geom.height = MIN(max.height + (2 * c->bw), c->geom.height); if (c->geom.x >= bbox->x + bbox->width) c->geom.x = bbox->x + bbox->width - c->geom.width; @@ -1721,13 +1727,11 @@ requeststartdrag(struct wl_listener *listener, void *data) void resize(Client *c, int x, int y, int w, int h, int interact) { - int min_width = 0, min_height = 0; struct wlr_box *bbox = interact ? &sgeom : &c->mon->w; - client_min_size(c, &min_width, &min_height); c->geom.x = x; c->geom.y = y; - c->geom.width = MAX(min_width + 2 * c->bw, w); - c->geom.height = MAX(min_height + 2 * c->bw, h); + c->geom.width = w; + c->geom.height = h; applybounds(c, bbox); /* Update scene-graph, including borders */ -- cgit v1.2.3