format code

This commit is contained in:
DreamMaoMao 2025-05-03 13:27:00 +08:00
parent ec2e5d5019
commit f3ab9d87a5

View file

@ -232,7 +232,8 @@ struct Client {
bool dirty; bool dirty;
uint32_t configure_serial; uint32_t configure_serial;
struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel; struct wlr_foreign_toplevel_handle_v1 *foreign_toplevel;
int isfloating, isurgent, isfullscreen, isfakefullscreen, need_float_size_reduce, isminied, isoverlay; int isfloating, isurgent, isfullscreen, isfakefullscreen,
need_float_size_reduce, isminied, isoverlay;
int ismaxmizescreen; int ismaxmizescreen;
int overview_backup_bw; int overview_backup_bw;
int fullscreen_backup_x, fullscreen_backup_y, fullscreen_backup_w, int fullscreen_backup_x, fullscreen_backup_y, fullscreen_backup_w,
@ -605,18 +606,19 @@ static struct wlr_box setclient_coordinate_center(struct wlr_box geom,
static unsigned int get_tags_first_tag(unsigned int tags); static unsigned int get_tags_first_tag(unsigned int tags);
static void client_commit(Client *c); static void client_commit(Client *c);
static void apply_border(Client *c, struct wlr_box clip_box, int offsetx, int offsety); static void apply_border(Client *c, struct wlr_box clip_box, int offsetx,
int offsety);
static void client_set_opacity(Client *c, double opacity); static void client_set_opacity(Client *c, double opacity);
static void init_baked_points(void); static void init_baked_points(void);
static void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int sx, int sy, static void scene_buffer_apply_opacity(struct wlr_scene_buffer *buffer, int sx,
void *data); int sy, void *data);
static Client *direction_select(const Arg *arg); static Client *direction_select(const Arg *arg);
static void view_in_mon(const Arg *arg, bool want_animation, Monitor *m); static void view_in_mon(const Arg *arg, bool want_animation, Monitor *m);
static void buffer_set_effect(Client *c, animationScale scale_data); static void buffer_set_effect(Client *c, animationScale scale_data);
static void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, static void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer,
int sy, void *data); int sx, int sy, void *data);
static void client_set_pending_state(Client *c); static void client_set_pending_state(Client *c);
static void set_rect_size(struct wlr_scene_rect *rect, int width, int height); static void set_rect_size(struct wlr_scene_rect *rect, int width, int height);
@ -1249,11 +1251,11 @@ void toggleoverlay(const Arg *arg) {
selmon->sel->isoverlay ^= 1; selmon->sel->isoverlay ^= 1;
if (selmon->sel->isoverlay) { if (selmon->sel->isoverlay) {
wlr_scene_node_reparent(&selmon->sel->scene->node, wlr_scene_node_reparent(&selmon->sel->scene->node, layers[LyrOverlay]);
layers[LyrOverlay]);
wlr_scene_node_raise_to_top(&selmon->sel->scene->node); wlr_scene_node_raise_to_top(&selmon->sel->scene->node);
} else { } else {
wlr_scene_node_reparent(&selmon->sel->scene->node, wlr_scene_node_reparent(
&selmon->sel->scene->node,
layers[selmon->sel->isfloating ? LyrFloat : LyrTile]); layers[selmon->sel->isfloating ? LyrFloat : LyrTile]);
} }
setborder_color(selmon->sel); setborder_color(selmon->sel);
@ -1789,12 +1791,10 @@ arrange(Monitor *m, bool want_animation) {
} }
} }
if (c->mon == m && c->ismaxmizescreen && !c->animation.tagouted &&
if (c->mon == m && c->ismaxmizescreen !c->animation.tagouting && VISIBLEON(c, m)) {
&& !c->animation.tagouted && !c->animation.tagouting && VISIBLEON(c, m)) {
reset_maxmizescreen_size(c); reset_maxmizescreen_size(c);
} }
} }
// 给全屏窗口设置背景为黑色 // 给全屏窗口设置背景为黑色
@ -1854,8 +1854,10 @@ Client *center_select(Monitor *m) {
void apply_window_snap(Client *c) { void apply_window_snap(Client *c) {
int snap_up = 99999, snap_down = 99999, snap_left = 99999, snap_right = 99999; int snap_up = 99999, snap_down = 99999, snap_left = 99999, snap_right = 99999;
int snap_up_temp = 0 ,snap_down_temp = 0, snap_left_temp = 0, snap_right_temp = 0; int snap_up_temp = 0, snap_down_temp = 0, snap_left_temp = 0,
int snap_up_screen = 0, snap_down_screen = 0, snap_left_screen = 0, snap_right_screen = 0; snap_right_temp = 0;
int snap_up_screen = 0, snap_down_screen = 0, snap_left_screen = 0,
snap_right_screen = 0;
Client *tc; Client *tc;
if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling) if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling)
return; return;
@ -1863,13 +1865,15 @@ void apply_window_snap(Client *c) {
if (!c->isfloating || !enable_floating_snap) if (!c->isfloating || !enable_floating_snap)
return; return;
// 第一次遍历,计算客户端数量
wl_list_for_each(tc, &clients, link) { wl_list_for_each(tc, &clients, link) {
if (tc && tc->isfloating && !tc->iskilling && client_surface(tc)->mapped && VISIBLEON(tc, c->mon)) { if (tc && tc->isfloating && !tc->iskilling && client_surface(tc)->mapped &&
VISIBLEON(tc, c->mon)) {
snap_left_temp = c->geom.x - tc->geom.x - tc->geom.width; snap_left_temp = c->geom.x - tc->geom.x - tc->geom.width;
snap_right_temp = tc->geom.x - c->geom.x - c->geom.width; snap_right_temp = tc->geom.x - c->geom.x - c->geom.width;
snap_up_temp = c->geom.y - tc->geom.y - tc->geom.height; snap_up_temp = c->geom.y - tc->geom.y - tc->geom.height;
snap_down_temp = tc->geom.y - c->geom.y - c->geom.height; snap_down_temp = tc->geom.y - c->geom.y - c->geom.height;
if (snap_left_temp < snap_left && snap_left_temp >= 0) { if (snap_left_temp < snap_left && snap_left_temp >= 0) {
snap_left = snap_left_temp; snap_left = snap_left_temp;
} }
@ -1888,7 +1892,8 @@ void apply_window_snap(Client *c) {
snap_left_screen = c->geom.x - c->mon->m.x; snap_left_screen = c->geom.x - c->mon->m.x;
snap_right_screen = c->mon->m.x + c->mon->m.width - c->geom.x - c->geom.width; snap_right_screen = c->mon->m.x + c->mon->m.width - c->geom.x - c->geom.width;
snap_up_screen = c->geom.y - c->mon->m.y; snap_up_screen = c->geom.y - c->mon->m.y;
snap_down_screen = c->mon->m.y + c->mon->m.height - c->geom.y - c->geom.height; snap_down_screen =
c->mon->m.y + c->mon->m.height - c->geom.y - c->geom.height;
if (snap_up_screen > 0 && snap_up_screen < snap_up) if (snap_up_screen > 0 && snap_up_screen < snap_up)
snap_up = snap_up_screen; snap_up = snap_up_screen;
@ -1916,7 +1921,6 @@ void apply_window_snap(Client *c) {
} }
resize(c, c->geom, 1); resize(c, c->geom, 1);
} }
Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating, Client *find_client_by_direction(Client *tc, const Arg *arg, bool findfloating,
@ -4567,15 +4571,18 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy,
void *data) { void *data) {
animationScale *scale_data = (animationScale *)data; animationScale *scale_data = (animationScale *)data;
if (scale_data->should_scale && scale_data->height_scale < 1 && scale_data->width_scale < 1) { if (scale_data->should_scale && scale_data->height_scale < 1 &&
scale_data->width_scale < 1) {
scale_data->should_scale = false; scale_data->should_scale = false;
} }
if (scale_data->should_scale && scale_data->height_scale == 1 && scale_data->width_scale < 1) { if (scale_data->should_scale && scale_data->height_scale == 1 &&
scale_data->width_scale < 1) {
scale_data->should_scale = false; scale_data->should_scale = false;
} }
if (scale_data->should_scale && scale_data->height_scale < 1 && scale_data->width_scale == 1) { if (scale_data->should_scale && scale_data->height_scale < 1 &&
scale_data->width_scale == 1) {
scale_data->should_scale = false; scale_data->should_scale = false;
} }
@ -4614,7 +4621,6 @@ void scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, int sy,
} }
} }
// TODO: blur set, opacity set // TODO: blur set, opacity set
} }
void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx, void snap_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx,
@ -4630,7 +4636,8 @@ void buffer_set_effect(Client *c, animationScale data) {
data.should_scale = false; data.should_scale = false;
} }
if(client_is_x11(c) && c->current.height >= c->animation.current.height && c->current.width >= c->animation.current.width) { if (client_is_x11(c) && c->current.height >= c->animation.current.height &&
c->current.width >= c->animation.current.width) {
data.should_scale = false; data.should_scale = false;
} }
@ -4909,8 +4916,8 @@ void resize(Client *c, struct wlr_box geo, int interact) {
client_set_opacity(c, 1); client_set_opacity(c, 1);
} }
if (c->animation.action == OPEN && !c->animation.tagining if (c->animation.action == OPEN && !c->animation.tagining &&
&& !c->animation.tagouting && wlr_box_equal(&c->geom, &c->current)) { !c->animation.tagouting && wlr_box_equal(&c->geom, &c->current)) {
c->animation.action = c->animation.action; c->animation.action = c->animation.action;
} else if (c->animation.tagouting) { } else if (c->animation.tagouting) {
c->animation.duration = animation_duration_tag; c->animation.duration = animation_duration_tag;
@ -5124,7 +5131,6 @@ void reset_maxmizescreen_size(Client *c) {
resize(c, c->geom, 0); resize(c, c->geom, 0);
} }
void setmaxmizescreen(Client *c, int maxmizescreen) { void setmaxmizescreen(Client *c, int maxmizescreen) {
struct wlr_box maxmizescreen_box; struct wlr_box maxmizescreen_box;
if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling) if (!c || !c->mon || !client_surface(c)->mapped || c->iskilling)
@ -5164,9 +5170,7 @@ void setmaxmizescreen(Client *c, int maxmizescreen) {
} }
} }
void void setfakefullscreen(Client *c, int fakefullscreen) {
setfakefullscreen(Client *c, int fakefullscreen)
{
c->isfakefullscreen = fakefullscreen; c->isfakefullscreen = fakefullscreen;
if (!c->mon) if (!c->mon)
return; return;
@ -6442,9 +6446,7 @@ void togglefloating(const Arg *arg) {
setborder_color(sel); setborder_color(sel);
} }
void void togglefakefullscreen(const Arg *arg) {
togglefakefullscreen(const Arg *arg)
{
Client *sel = focustop(selmon); Client *sel = focustop(selmon);
if (sel) if (sel)
setfakefullscreen(sel, !sel->isfakefullscreen); setfakefullscreen(sel, !sel->isfakefullscreen);