opt: optimize scroll clip offeset

This commit is contained in:
DreamMaoMao
2025-05-20 09:10:40 +08:00
parent 26634f28e4
commit 4a560c1a60

View File

@@ -1178,27 +1178,29 @@ struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
// // make tagout tagin animations not visible in other monitors // // make tagout tagin animations not visible in other monitors
if (ISTILED(c) || c->animation.tagining || c->animation.tagouted || if (ISTILED(c) || c->animation.tagining || c->animation.tagouted ||
c->animation.tagouting) { c->animation.tagouting) {
if (c->animation.current.x <= c->mon->m.x) { if (c->animation.current.x < c->mon->m.x) {
offsetx = GEZERO(c->mon->m.x - c->animation.current.x); offsetx = c->mon->m.x - c->bw - c->animation.current.x;
offsetx = offsetx < 0 ? 0 : offsetx;
clip_box->x = clip_box->x + offsetx; clip_box->x = clip_box->x + offsetx;
clip_box->width = clip_box->width - offsetx; clip_box->width = clip_box->width - offsetx;
} else if (c->animation.current.x + c->animation.current.width >= } else if (c->animation.current.x + c->animation.current.width >
c->mon->m.x + c->mon->m.width) { c->mon->m.x + c->mon->m.width) {
clip_box->width = clip_box->width - clip_box->width = clip_box->width -
(c->animation.current.x + c->animation.current.width - (c->animation.current.x + c->animation.current.width -
c->mon->m.x - c->mon->m.width) - c->mon->m.x - c->mon->m.width) +
c->bw; c->bw;
} }
if (c->animation.current.y <= c->mon->m.y) { if (c->animation.current.y < c->mon->m.y) {
offsety = GEZERO(c->mon->m.y - c->animation.current.y); offsety = c->mon->m.y - c->bw - c->animation.current.y;
offsety = offsety < 0 ? 0 : offsety;
clip_box->y = clip_box->y + offsety; clip_box->y = clip_box->y + offsety;
clip_box->height = clip_box->height - offsety; clip_box->height = clip_box->height - offsety;
} else if (c->animation.current.y + c->animation.current.height >= } else if (c->animation.current.y + c->animation.current.height >
c->mon->m.y + c->mon->m.height) { c->mon->m.y + c->mon->m.height) {
clip_box->height = clip_box->height - clip_box->height = clip_box->height -
(c->animation.current.y + c->animation.current.height - (c->animation.current.y + c->animation.current.height -
c->mon->m.y - c->mon->m.height) - c->mon->m.y - c->mon->m.height) +
c->bw; c->bw;
} }
} }
@@ -1206,7 +1208,7 @@ struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
offset.x = offsetx; offset.x = offsetx;
offset.y = offsety; offset.y = offsety;
if ((clip_box->width <= 0 || clip_box->height <= 0) && if ((clip_box->width < 0 || clip_box->height < 0) &&
(ISTILED(c) || c->animation.tagouting || c->animation.tagining)) { (ISTILED(c) || c->animation.tagouting || c->animation.tagining)) {
c->is_clip_to_hide = true; c->is_clip_to_hide = true;
wlr_scene_node_set_enabled(&c->scene->node, false); wlr_scene_node_set_enabled(&c->scene->node, false);