mirror of
https://codeberg.org/dwl/dwl.git
synced 2024-12-27 03:36:31 +00:00
respect size hints
This commit is contained in:
parent
2aa391361c
commit
72e0a560d9
2 changed files with 49 additions and 52 deletions
83
client.h
83
client.h
|
@ -81,6 +81,32 @@ client_get_geometry(Client *c, struct wlr_box *geom)
|
||||||
wlr_xdg_surface_get_geometry(c->surface.xdg, geom);
|
wlr_xdg_surface_get_geometry(c->surface.xdg, geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min)
|
||||||
|
{
|
||||||
|
struct wlr_xdg_toplevel *toplevel;
|
||||||
|
struct wlr_xdg_toplevel_state *state;
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
if (client_is_x11(c)) {
|
||||||
|
struct wlr_xwayland_surface_size_hints *size_hints;
|
||||||
|
size_hints = c->surface.xwayland->size_hints;
|
||||||
|
if (size_hints) {
|
||||||
|
max->width = size_hints->max_width;
|
||||||
|
max->height = size_hints->max_height;
|
||||||
|
min->width = size_hints->min_width;
|
||||||
|
min->height = size_hints->min_height;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
toplevel = c->surface.xdg->toplevel;
|
||||||
|
state = &toplevel->current;
|
||||||
|
max->width = state->max_width;
|
||||||
|
max->height = state->max_height;
|
||||||
|
min->width = state->min_width;
|
||||||
|
min->height = state->min_height;
|
||||||
|
}
|
||||||
|
|
||||||
static inline const char *
|
static inline const char *
|
||||||
client_get_title(Client *c)
|
client_get_title(Client *c)
|
||||||
{
|
{
|
||||||
|
@ -94,39 +120,31 @@ client_get_title(Client *c)
|
||||||
static inline int
|
static inline int
|
||||||
client_is_float_type(Client *c)
|
client_is_float_type(Client *c)
|
||||||
{
|
{
|
||||||
struct wlr_xdg_toplevel *toplevel;
|
struct wlr_box min = {0}, max = {0};
|
||||||
struct wlr_xdg_toplevel_state state;
|
client_get_size_hints(c, &max, &min);
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
if (client_is_x11(c)) {
|
if (client_is_x11(c)) {
|
||||||
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||||
struct wlr_xwayland_surface_size_hints *size_hints;
|
|
||||||
if (surface->modal)
|
if (surface->modal)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (size_t i = 0; i < surface->window_type_len; i++)
|
for (size_t i = 0; i < surface->window_type_len; i++)
|
||||||
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] ||
|
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog]
|
||||||
surface->window_type[i] == netatom[NetWMWindowTypeSplash] ||
|
|| surface->window_type[i] == netatom[NetWMWindowTypeSplash]
|
||||||
surface->window_type[i] == netatom[NetWMWindowTypeToolbar] ||
|
|| surface->window_type[i] == netatom[NetWMWindowTypeToolbar]
|
||||||
surface->window_type[i] == netatom[NetWMWindowTypeUtility])
|
|| surface->window_type[i] == netatom[NetWMWindowTypeUtility])
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
size_hints = surface->size_hints;
|
return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0)
|
||||||
if (size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
|
&& (min.width == max.width || min.height == max.height))
|
||||||
&& (size_hints->max_width == size_hints->min_width ||
|
|| c->surface.xwayland->parent;
|
||||||
size_hints->max_height == size_hints->min_height))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
toplevel = c->surface.xdg->toplevel;
|
return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0)
|
||||||
state = toplevel->current;
|
&& (min.width == max.width || min.height == max.height))
|
||||||
return (state.min_width != 0 && state.min_height != 0
|
|| c->surface.xdg->toplevel->parent;
|
||||||
&& (state.min_width == state.max_width
|
|
||||||
|| state.min_height == state.max_height))
|
|
||||||
|| toplevel->parent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
@ -206,31 +224,6 @@ client_surface_at(Client *c, double cx, double cy, double *sx, double *sy)
|
||||||
return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy);
|
return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
|
||||||
client_min_size(Client *c, int *width, int *height)
|
|
||||||
{
|
|
||||||
struct wlr_xdg_toplevel *toplevel;
|
|
||||||
struct wlr_xdg_toplevel_state *state;
|
|
||||||
#ifdef XWAYLAND
|
|
||||||
if (client_is_x11(c)) {
|
|
||||||
struct wlr_xwayland_surface_size_hints *size_hints;
|
|
||||||
size_hints = c->surface.xwayland->size_hints;
|
|
||||||
if (size_hints) {
|
|
||||||
*width = size_hints->min_width;
|
|
||||||
*height = size_hints->min_height;
|
|
||||||
} else {
|
|
||||||
*width = 0;
|
|
||||||
*height = 0;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
toplevel = c->surface.xdg->toplevel;
|
|
||||||
state = &toplevel->current;
|
|
||||||
*width = state->min_width;
|
|
||||||
*height = state->min_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
client_restack_surface(Client *c)
|
client_restack_surface(Client *c)
|
||||||
{
|
{
|
||||||
|
|
18
dwl.c
18
dwl.c
|
@ -381,9 +381,15 @@ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
void
|
void
|
||||||
applybounds(Client *c, struct wlr_box *bbox)
|
applybounds(Client *c, struct wlr_box *bbox)
|
||||||
{
|
{
|
||||||
/* set minimum possible */
|
struct wlr_box min = {0}, max = {0};
|
||||||
c->geom.width = MAX(1, c->geom.width);
|
client_get_size_hints(c, &max, &min);
|
||||||
c->geom.height = MAX(1, c->geom.height);
|
/* 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)
|
if (c->geom.x >= bbox->x + bbox->width)
|
||||||
c->geom.x = bbox->x + bbox->width - c->geom.width;
|
c->geom.x = bbox->x + bbox->width - c->geom.width;
|
||||||
|
@ -1721,13 +1727,11 @@ requeststartdrag(struct wl_listener *listener, void *data)
|
||||||
void
|
void
|
||||||
resize(Client *c, int x, int y, int w, int h, int interact)
|
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;
|
struct wlr_box *bbox = interact ? &sgeom : &c->mon->w;
|
||||||
client_min_size(c, &min_width, &min_height);
|
|
||||||
c->geom.x = x;
|
c->geom.x = x;
|
||||||
c->geom.y = y;
|
c->geom.y = y;
|
||||||
c->geom.width = MAX(min_width + 2 * c->bw, w);
|
c->geom.width = w;
|
||||||
c->geom.height = MAX(min_height + 2 * c->bw, h);
|
c->geom.height = h;
|
||||||
applybounds(c, bbox);
|
applybounds(c, bbox);
|
||||||
|
|
||||||
/* Update scene-graph, including borders */
|
/* Update scene-graph, including borders */
|
||||||
|
|
Loading…
Reference in a new issue