feat: dont resize client when in overview

This commit is contained in:
DreamMaoMao 2026-05-19 10:02:21 +08:00
parent f3d0c18d19
commit af09d8ba45
9 changed files with 445 additions and 138 deletions

View file

@ -58,6 +58,14 @@ int32_t is_special_animation_rule(Client *c) {
}
}
void set_overview_enter_animation(Client *c) {
struct wlr_box geo = c->geom;
c->animainit_geom.width = geo.width * 1.2;
c->animainit_geom.height = geo.height * 1.2;
c->animainit_geom.x = geo.x + (geo.width - c->animainit_geom.width) / 2;
c->animainit_geom.y = geo.y + (geo.height - c->animainit_geom.height) / 2;
}
void set_client_open_animation(Client *c, struct wlr_box geo) {
int32_t slide_direction;
int32_t horizontal, horizontal_value;
@ -213,6 +221,16 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int32_t sx,
return;
}
void scene_buffer_apply_overview_effect(struct wlr_scene_buffer *buffer,
int32_t sx, int32_t sy, void *data) {
BufferData *buffer_data = (BufferData *)data;
if (buffer_data->width > 0 && buffer_data->height > 0) {
wlr_scene_buffer_set_dest_size(buffer, buffer_data->width,
buffer_data->height);
}
}
void buffer_set_effect(Client *c, BufferData data) {
if (!c || c->iskilling)
@ -226,8 +244,13 @@ void buffer_set_effect(Client *c, BufferData data) {
if (c == grabc)
data.should_scale = false;
wlr_scene_node_for_each_buffer(&c->scene_surface->node,
scene_buffer_apply_effect, &data);
if (c->mon->isoverview && config.ov_no_resize) {
wlr_scene_node_for_each_buffer(
&c->scene_surface->node, scene_buffer_apply_overview_effect, &data);
} else {
wlr_scene_node_for_each_buffer(&c->scene_surface->node,
scene_buffer_apply_effect, &data);
}
}
void apply_shield(Client *c, struct wlr_box clip_box) {
@ -679,10 +702,13 @@ void client_apply_clip(Client *c, float factor) {
}
apply_shield(c, clip_box);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
if (!c->mon->isoverview || !config.ov_no_resize) {
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node,
&clip_box);
}
buffer_set_effect(
c, (BufferData){1.0f, 1.0f, clip_box.width, clip_box.height, true});
return;
}
@ -727,7 +753,10 @@ void client_apply_clip(Client *c, float factor) {
// 应用窗口表面剪切
apply_shield(c, clip_box);
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
if (!c->mon->isoverview || !config.ov_no_resize) {
wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip_box);
}
// 获取剪切后的表面的实际大小用于计算缩放
int32_t acutal_surface_width = geometry.width - offset.x - offset.width;
@ -875,6 +904,7 @@ void client_animation_next_tick(Client *c) {
c->animation.tagining = false;
c->animation.running = false;
c->animation.overining = false;
if (c->animation.tagouting) {
c->animation.tagouting = false;
@ -1017,9 +1047,8 @@ void client_set_pending_state(Client *c) {
c->animation.should_animate = false;
} else if (config.animations && c->animation.tagining) {
c->animation.should_animate = true;
} else if (!config.animations || c == grabc ||
(!c->is_pending_open_animation &&
wlr_box_equal(&c->current, &c->pending))) {
} else if (c == grabc || (!c->is_pending_open_animation &&
wlr_box_equal(&c->current, &c->pending))) {
c->animation.should_animate = false;
} else {
c->animation.should_animate = true;
@ -1093,8 +1122,11 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
c->animation.begin_fade_in = false;
}
if (c->animation.action == OPEN && !c->animation.tagining &&
!c->animation.tagouting && wlr_box_equal(&c->geom, &c->current)) {
if (c->animation.overining) {
c->animation.action = OVERVIEW;
} else if (c->animation.action == OPEN && !c->animation.tagining &&
!c->animation.tagouting &&
wlr_box_equal(&c->geom, &c->current)) {
c->animation.action = c->animation.action;
} else if (c->animation.tagouting) {
c->animation.duration = config.animation_duration_tag;
@ -1133,8 +1165,10 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
}
// c->geom 是真实的窗口大小和位置,跟过度的动画无关,用于计算布局
c->configure_serial = client_set_size(c, c->geom.width - 2 * c->bw,
c->geom.height - 2 * c->bw);
if (!c->mon->isoverview || !config.ov_no_resize) {
c->configure_serial = client_set_size(c, c->geom.width - 2 * c->bw,
c->geom.height - 2 * c->bw);
}
if (c->configure_serial != 0) {
c->mon->resizing_count_pending++;
@ -1177,6 +1211,15 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
c->animainit_geom = c->geom;
}
if (config.animations && config.ov_no_resize && c->mon->isoverview &&
c != c->mon->sel && c->animation.action == OVERVIEW) {
set_overview_enter_animation(c);
}
if (!config.animations && config.ov_no_resize && c->mon->isoverview) {
c->animainit_geom = c->geom;
}
// 开始应用动画设置
client_set_pending_state(c);