mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-08 13:29:56 -05:00
feat: respect the min and max size hint for the floating window
This commit is contained in:
parent
5e52921c80
commit
c8513da37e
3 changed files with 60 additions and 0 deletions
|
|
@ -795,6 +795,10 @@ void resize(Client *c, struct wlr_box geo, int interact) {
|
||||||
bbox); // 去掉这个推荐的窗口大小,因为有时推荐的窗口特别大导致平铺异常
|
bbox); // 去掉这个推荐的窗口大小,因为有时推荐的窗口特别大导致平铺异常
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!c->ismaxmizescreen && !c->isfullscreen && c->isfloating) {
|
||||||
|
client_set_size_bound(c);
|
||||||
|
}
|
||||||
|
|
||||||
if (!c->is_pending_open_animation) {
|
if (!c->is_pending_open_animation) {
|
||||||
c->animation.begin_fade_in = false;
|
c->animation.begin_fade_in = false;
|
||||||
}
|
}
|
||||||
|
|
@ -839,6 +843,7 @@ void resize(Client *c, struct wlr_box geo, int interact) {
|
||||||
if (c == grabc) {
|
if (c == grabc) {
|
||||||
c->animation.running = false;
|
c->animation.running = false;
|
||||||
c->need_output_flush = false;
|
c->need_output_flush = false;
|
||||||
|
|
||||||
c->animainit_geom = c->current = c->pending = c->animation.current =
|
c->animainit_geom = c->current = c->pending = c->animation.current =
|
||||||
c->geom;
|
c->geom;
|
||||||
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
wlr_scene_node_set_position(&c->scene->node, c->geom.x, c->geom.y);
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,10 @@ static inline int client_is_float_type(Client *c) {
|
||||||
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;
|
||||||
xcb_size_hints_t *size_hints = surface->size_hints;
|
xcb_size_hints_t *size_hints = surface->size_hints;
|
||||||
|
|
||||||
|
if (!size_hints)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (surface->modal)
|
if (surface->modal)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
@ -469,4 +473,52 @@ static inline bool client_request_minimize(Client *c, void *data) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return c->surface.xdg->toplevel->requested.minimized;
|
return c->surface.xdg->toplevel->requested.minimized;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void client_set_size_bound(Client *c) {
|
||||||
|
struct wlr_xdg_toplevel *toplevel;
|
||||||
|
struct wlr_xdg_toplevel_state state;
|
||||||
|
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
if (client_is_x11(c)) {
|
||||||
|
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
||||||
|
xcb_size_hints_t *size_hints = surface->size_hints;
|
||||||
|
|
||||||
|
if (!size_hints)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((unsigned int)c->geom.width - 2 * c->bw < size_hints->min_width &&
|
||||||
|
size_hints->min_width > 0)
|
||||||
|
c->geom.width = size_hints->min_width + 2 * c->bw;
|
||||||
|
if ((unsigned int)c->geom.height - 2 * c->bw < size_hints->min_height &&
|
||||||
|
size_hints->min_height > 0)
|
||||||
|
c->geom.height = size_hints->min_height + 2 * c->bw;
|
||||||
|
if ((unsigned int)c->geom.width - 2 * c->bw > size_hints->max_width &&
|
||||||
|
size_hints->max_width > 0)
|
||||||
|
c->geom.width = size_hints->max_width + 2 * c->bw;
|
||||||
|
if ((unsigned int)c->geom.height - 2 * c->bw > size_hints->max_height &&
|
||||||
|
size_hints->max_height > 0)
|
||||||
|
c->geom.height = size_hints->max_height + 2 * c->bw;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
toplevel = c->surface.xdg->toplevel;
|
||||||
|
state = toplevel->current;
|
||||||
|
if ((unsigned int)c->geom.width - 2 * c->bw < state.min_width &&
|
||||||
|
state.min_width > 0) {
|
||||||
|
c->geom.width = state.min_width + 2 * c->bw;
|
||||||
|
}
|
||||||
|
if ((unsigned int)c->geom.height - 2 * c->bw < state.min_height &&
|
||||||
|
state.min_height > 0) {
|
||||||
|
c->geom.height = state.min_height + 2 * c->bw;
|
||||||
|
}
|
||||||
|
if ((unsigned int)c->geom.width - 2 * c->bw > state.max_width &&
|
||||||
|
state.max_width > 0) {
|
||||||
|
c->geom.width = state.max_width + 2 * c->bw;
|
||||||
|
}
|
||||||
|
if ((unsigned int)c->geom.height - 2 * c->bw > state.max_height &&
|
||||||
|
state.max_height > 0) {
|
||||||
|
c->geom.height = state.max_height + 2 * c->bw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1086,6 +1086,7 @@ int applyrulesgeom(Client *c) {
|
||||||
|
|
||||||
c->geom.width = r->width > 0 ? r->width : c->geom.width;
|
c->geom.width = r->width > 0 ? r->width : c->geom.width;
|
||||||
c->geom.height = r->height > 0 ? r->height : c->geom.height;
|
c->geom.height = r->height > 0 ? r->height : c->geom.height;
|
||||||
|
client_set_size_bound(c);
|
||||||
|
|
||||||
// 重新计算居中的坐标
|
// 重新计算居中的坐标
|
||||||
if (r->offsetx != 0 || r->offsety != 0 || r->width > 0 || r->height > 0)
|
if (r->offsetx != 0 || r->offsety != 0 || r->width > 0 || r->height > 0)
|
||||||
|
|
@ -1144,6 +1145,8 @@ void applyrules(Client *c) {
|
||||||
if (r->height > 0)
|
if (r->height > 0)
|
||||||
c->geom.height = r->height;
|
c->geom.height = r->height;
|
||||||
|
|
||||||
|
client_set_size_bound(c);
|
||||||
|
|
||||||
if (r->offsetx || r->offsety || r->width > 0 || r->height > 0) {
|
if (r->offsetx || r->offsety || r->width > 0 || r->height > 0) {
|
||||||
hit_rule_pos = true;
|
hit_rule_pos = true;
|
||||||
c->oldgeom = c->geom = setclient_coordinate_center(
|
c->oldgeom = c->geom = setclient_coordinate_center(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue