opt: use a unified node layer setting function

This commit is contained in:
DreamMaoMao 2026-02-27 09:36:10 +08:00
parent 1d4a305e30
commit 00051994b6
4 changed files with 44 additions and 57 deletions

View file

@ -268,7 +268,7 @@ void apply_border(Client *c) {
} }
struct wlr_box fullgeom = c->animation.current; struct wlr_box fullgeom = c->animation.current;
int32_t bw = (int32_t)c->bw; // 使用有符号类型避免负数问题 int32_t bw = (int32_t)c->bw; // 使用有符号类型避免负数问题
// 设置场景表面的位置(缩进边框宽度) // 设置场景表面的位置(缩进边框宽度)
wlr_scene_node_set_position(&c->scene_surface->node, bw, bw); wlr_scene_node_set_position(&c->scene_surface->node, bw, bw);
@ -290,7 +290,6 @@ void apply_border(Client *c) {
wlr_scene_node_set_position(&c->border[3]->node, fullgeom.width - bw, 0); wlr_scene_node_set_position(&c->border[3]->node, fullgeom.width - bw, 0);
} }
void client_apply_clip(Client *c, float factor) { void client_apply_clip(Client *c, float factor) {
if (c->iskilling || !client_surface(c)->mapped) if (c->iskilling || !client_surface(c)->mapped)
return; return;
@ -504,6 +503,8 @@ void client_animation_next_tick(Client *c) {
wlr_seat_pointer_notify_enter(seat, surface, sx, sy); wlr_seat_pointer_notify_enter(seat, surface, sx, sy);
} }
client_apply_node_layer(c);
// end flush in next frame, not the current frame // end flush in next frame, not the current frame
c->need_output_flush = false; c->need_output_flush = false;
} }
@ -790,6 +791,8 @@ void resize(Client *c, struct wlr_box geo, int32_t interact) {
c->animainit_geom = c->geom; c->animainit_geom = c->geom;
} }
client_apply_node_layer(c);
// 开始应用动画设置 // 开始应用动画设置
client_set_pending_state(c); client_set_pending_state(c);

View file

@ -31,11 +31,8 @@ void set_tagin_animation(Monitor *m, Client *c) {
void set_arrange_visible(Monitor *m, Client *c, bool want_animation) { void set_arrange_visible(Monitor *m, Client *c, bool want_animation) {
if (!c->is_clip_to_hide || !ISTILED(c) || !is_scroller_layout(c->mon)) { wlr_scene_node_set_enabled(&c->scene->node, true);
c->is_clip_to_hide = false; wlr_scene_node_set_enabled(&c->scene_surface->node, true);
wlr_scene_node_set_enabled(&c->scene->node, true);
wlr_scene_node_set_enabled(&c->scene_surface->node, true);
}
client_set_suspended(c, false); client_set_suspended(c, false);
if (!c->animation.tag_from_rule && want_animation && if (!c->animation.tag_from_rule && want_animation &&

View file

@ -1374,21 +1374,8 @@ int32_t toggleoverlay(const Arg *arg) {
selmon->sel->isoverlay ^= 1; selmon->sel->isoverlay ^= 1;
if (selmon->sel->isoverlay) { client_apply_node_layer(selmon->sel);
wlr_scene_node_reparent(
&selmon->sel->scene->node,
selmon->sel->mon->layers_scene_tree[LyrOverlay]);
wlr_scene_node_raise_to_top(&selmon->sel->scene->node);
} else if (client_should_overtop(selmon->sel) && selmon->sel->isfloating) {
wlr_scene_node_reparent(&selmon->sel->scene->node,
selmon->sel->mon->layers_scene_tree[LyrTop]);
} else {
wlr_scene_node_reparent(
&selmon->sel->scene->node,
selmon->sel->mon
->layers_scene_tree[selmon->sel->isfloating ? LyrTop
: LyrTile]);
}
setborder_color(selmon->sel); setborder_color(selmon->sel);
return 0; return 0;
} }

View file

@ -397,7 +397,6 @@ struct Client {
int32_t force_tiled_state; int32_t force_tiled_state;
pid_t pid; pid_t pid;
Client *swallowing, *swallowedby; Client *swallowing, *swallowedby;
bool is_clip_to_hide;
bool drag_to_tile; bool drag_to_tile;
bool scratchpad_switching_mon; bool scratchpad_switching_mon;
bool fake_no_border; bool fake_no_border;
@ -816,6 +815,7 @@ static void handle_iamge_copy_capture_new_session(struct wl_listener *listener,
void *data); void *data);
static Monitor *get_monitor_nearest_to(int32_t lx, int32_t ly); static Monitor *get_monitor_nearest_to(int32_t lx, int32_t ly);
static bool match_monitor_spec(char *spec, Monitor *m); static bool match_monitor_spec(char *spec, Monitor *m);
static void client_apply_node_layer(Client *c);
#include "data/static_keymap.h" #include "data/static_keymap.h"
#include "dispatch/bind_declare.h" #include "dispatch/bind_declare.h"
@ -1541,8 +1541,7 @@ void applyrules(Client *c) {
newtags & mon->tagset[mon->seltags])); newtags & mon->tagset[mon->seltags]));
if (c->mon) { if (c->mon) {
wlr_scene_node_reparent(&c->scene->node, client_apply_node_layer(c);
c->mon->layers_scene_tree[LyrTile]);
} }
if (c->mon && if (c->mon &&
@ -1583,8 +1582,7 @@ void applyrules(Client *c) {
// apply overlay rule // apply overlay rule
if (c->isoverlay && c->scene) { if (c->isoverlay && c->scene) {
wlr_scene_node_reparent(&c->scene->node, client_apply_node_layer(c);
c->mon->layers_scene_tree[LyrOverlay]);
wlr_scene_node_raise_to_top(&c->scene->node); wlr_scene_node_raise_to_top(&c->scene->node);
} }
} }
@ -3912,7 +3910,6 @@ void init_client_properties(Client *c) {
c->isnamedscratchpad = 0; c->isnamedscratchpad = 0;
c->is_scratchpad_show = 0; c->is_scratchpad_show = 0;
c->need_float_size_reduce = 0; c->need_float_size_reduce = 0;
c->is_clip_to_hide = 0;
c->is_restoring_from_ov = 0; c->is_restoring_from_ov = 0;
c->isurgent = 0; c->isurgent = 0;
c->need_output_flush = 0; c->need_output_flush = 0;
@ -4677,6 +4674,33 @@ void requeststartdrag(struct wl_listener *listener, void *data) {
wlr_data_source_destroy(event->drag->source); wlr_data_source_destroy(event->drag->source);
} }
void client_apply_node_layer(Client *c) {
if (c->animation.tagining || c->animation.tagouting) {
if (c->isoverlay) {
wlr_scene_node_reparent(&c->scene->node,
c->mon->layers_scene_tree[LyrOverlay]);
} else if (c->isfloating || c->isfullscreen) {
wlr_scene_node_reparent(&c->scene->node,
c->mon->layers_scene_tree[LyrTop]);
} else {
wlr_scene_node_reparent(&c->scene->node,
c->mon->layers_scene_tree[LyrTile]);
}
} else {
if (c->isfloating) {
wlr_scene_node_reparent(&c->scene->node,
layers[c->isoverlay ? LyrOverlay : LyrTop]);
} else if (c->isfullscreen) {
wlr_scene_node_reparent(&c->scene->node,
c->mon->layers_scene_tree[LyrTop]);
} else {
wlr_scene_node_reparent(
&c->scene->node,
c->mon->layers_scene_tree[c->isoverlay ? LyrOverlay : LyrTile]);
}
}
}
void setborder_color(Client *c) { void setborder_color(Client *c) {
if (!c || !c->mon) if (!c || !c->mon)
return; return;
@ -5011,17 +5035,7 @@ setfloating(Client *c, int32_t floating) {
} }
} }
if (c->isoverlay) { client_apply_node_layer(c);
wlr_scene_node_reparent(&c->scene->node,
c->mon->layers_scene_tree[LyrOverlay]);
} else if (client_should_overtop(c) && c->isfloating) {
wlr_scene_node_reparent(&c->scene->node,
c->mon->layers_scene_tree[LyrTop]);
} else {
wlr_scene_node_reparent(
&c->scene->node,
c->mon->layers_scene_tree[c->isfloating ? LyrTop : LyrTile]);
}
if (!c->isfloating && old_floating_state) { if (!c->isfloating && old_floating_state) {
restore_size_per(c->mon, c); restore_size_per(c->mon, c);
@ -5107,9 +5121,7 @@ void setmaximizescreen(Client *c, int32_t maximizescreen) {
setfloating(c, 1); setfloating(c, 1);
} }
wlr_scene_node_reparent( client_apply_node_layer(c);
&c->scene->node,
c->mon->layers_scene_tree[c->isfloating ? LyrTop : LyrTile]);
if (!c->ismaximizescreen && old_maximizescreen_state) { if (!c->ismaximizescreen && old_maximizescreen_state) {
restore_size_per(c->mon, c); restore_size_per(c->mon, c);
} }
@ -5171,18 +5183,7 @@ void setfullscreen(Client *c, int32_t fullscreen) // 用自定义全屏代理自
setfloating(c, 1); setfloating(c, 1);
} }
if (c->isoverlay) { client_apply_node_layer(c);
wlr_scene_node_reparent(&c->scene->node,
c->mon->layers_scene_tree[LyrOverlay]);
} else if (client_should_overtop(c) && c->isfloating) {
wlr_scene_node_reparent(&c->scene->node,
c->mon->layers_scene_tree[LyrTop]);
} else {
wlr_scene_node_reparent(
&c->scene->node,
c->mon->layers_scene_tree[fullscreen || c->isfloating ? LyrTop
: LyrTile]);
}
if (!c->isfullscreen && old_fullscreen_state) { if (!c->isfullscreen && old_fullscreen_state) {
restore_size_per(c->mon, c); restore_size_per(c->mon, c);
@ -5896,8 +5897,7 @@ void unmapnotify(struct wl_listener *listener, void *data) {
Client *prev_in_stack = c->prev_in_stack; Client *prev_in_stack = c->prev_in_stack;
c->iskilling = 1; c->iskilling = 1;
if (animations && !c->is_clip_to_hide && !c->isminimized && if (animations && !c->isminimized && (!c->mon || VISIBLEON(c, c->mon)))
(!c->mon || VISIBLEON(c, c->mon)))
init_fadeout_client(c); init_fadeout_client(c);
// If the client is in a stack, remove it from the stack // If the client is in a stack, remove it from the stack