format code

This commit is contained in:
DreamMaoMao 2025-06-14 21:45:06 +08:00
parent 247463a1dd
commit 20d132de3f
2 changed files with 87 additions and 90 deletions

View file

@ -686,7 +686,7 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
} else if (strcmp(func_name, "focusmon") == 0) { } else if (strcmp(func_name, "focusmon") == 0) {
func = focusmon; func = focusmon;
(*arg).i = parse_direction(arg_value); (*arg).i = parse_direction(arg_value);
if((*arg).i == UNDIR) { if ((*arg).i == UNDIR) {
(*arg).v = strdup(arg_value); (*arg).v = strdup(arg_value);
} }
} else if (strcmp(func_name, "tagmon") == 0) { } else if (strcmp(func_name, "tagmon") == 0) {

View file

@ -1105,114 +1105,112 @@ bool check_hit_no_border(Client *c) {
} }
void apply_border(Client *c) { void apply_border(Client *c) {
if (c->iskilling || !client_surface(c)->mapped) if (c->iskilling || !client_surface(c)->mapped)
return; return;
bool hit_no_border = check_hit_no_border(c); bool hit_no_border = check_hit_no_border(c);
// Handle no-border cases // Handle no-border cases
if (hit_no_border && smartgaps) { if (hit_no_border && smartgaps) {
c->bw = 0; c->bw = 0;
c->fake_no_border = true; c->fake_no_border = true;
} else if (hit_no_border && !smartgaps) { } else if (hit_no_border && !smartgaps) {
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
set_rect_size(c->border[i], 0, 0); set_rect_size(c->border[i], 0, 0);
wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw); wlr_scene_node_set_position(&c->scene_surface->node, c->bw, c->bw);
c->fake_no_border = true; c->fake_no_border = true;
return; return;
} else if (!c->isfullscreen && VISIBLEON(c, c->mon)) { } else if (!c->isfullscreen && VISIBLEON(c, c->mon)) {
c->bw = c->isnoborder ? 0 : borderpx; c->bw = c->isnoborder ? 0 : borderpx;
c->fake_no_border = false; c->fake_no_border = false;
} }
struct wlr_box geom = c->animation.current; struct wlr_box geom = c->animation.current;
int bw = c->bw; int bw = c->bw;
// Calculate how much the window is outside the monitor // Calculate how much the window is outside the monitor
// These values will be positive when window is outside the monitor // These values will be positive when window is outside the monitor
int outside_left = GEZERO(c->mon->m.x - c->animation.current.x); int outside_left = GEZERO(c->mon->m.x - c->animation.current.x);
int outside_top = GEZERO(c->mon->m.y - c->animation.current.y); int outside_top = GEZERO(c->mon->m.y - c->animation.current.y);
int outside_right = GEZERO((c->animation.current.x + c->animation.current.width) - int outside_right =
(c->mon->m.x + c->mon->m.width)); GEZERO((c->animation.current.x + c->animation.current.width) -
int outside_bottom = GEZERO((c->animation.current.y + c->animation.current.height) - (c->mon->m.x + c->mon->m.width));
(c->mon->m.y + c->mon->m.height)); int outside_bottom =
GEZERO((c->animation.current.y + c->animation.current.height) -
(c->mon->m.y + c->mon->m.height));
// Initialize border dimensions // Initialize border dimensions
int top_width = geom.width; int top_width = geom.width;
int top_height = bw; int top_height = bw;
int bottom_width = geom.width; int bottom_width = geom.width;
int bottom_height = bw; int bottom_height = bw;
int left_width = bw; int left_width = bw;
int left_height = geom.height - 2 * bw; int left_height = geom.height - 2 * bw;
int right_width = bw; int right_width = bw;
int right_height = geom.height - 2 * bw; int right_height = geom.height - 2 * bw;
// Initialize border positions // Initialize border positions
int top_x = 0; int top_x = 0;
int top_y = 0; int top_y = 0;
int bottom_x = 0; int bottom_x = 0;
int bottom_y = geom.height - bottom_height; int bottom_y = geom.height - bottom_height;
int left_x = 0; int left_x = 0;
int left_y = bw; int left_y = bw;
int right_x = geom.width - right_width; int right_x = geom.width - right_width;
int right_y = bw; int right_y = bw;
// Adjust borders when window is outside monitor // Adjust borders when window is outside monitor
if (ISTILED(c) || c->animation.tagining || c->animation.tagouted || c->animation.tagouting) { if (ISTILED(c) || c->animation.tagining || c->animation.tagouted ||
// Top border - reduce height when window goes above monitor c->animation.tagouting) {
if (outside_top > 0) { // Top border - reduce height when window goes above monitor
top_height = GEZERO(bw - outside_top); if (outside_top > 0) {
top_y = top_y + outside_top; top_height = GEZERO(bw - outside_top);
top_y = top_y + outside_top;
left_height = left_height - outside_top; left_height = left_height - outside_top;
right_height = right_height - outside_top; right_height = right_height - outside_top;
left_y = left_y + outside_top; left_y = left_y + outside_top;
right_y = right_y + outside_top; right_y = right_y + outside_top;
} }
// Bottom border - reduce height when window goes below monitor // Bottom border - reduce height when window goes below monitor
if (outside_bottom > 0) { if (outside_bottom > 0) {
bottom_height = GEZERO(bw - outside_bottom); bottom_height = GEZERO(bw - outside_bottom);
left_height = left_height - outside_bottom; left_height = left_height - outside_bottom;
right_height = right_height - outside_bottom; right_height = right_height - outside_bottom;
} }
// Left border - reduce width when window goes left of monitor // Left border - reduce width when window goes left of monitor
if (outside_left > 0) { if (outside_left > 0) {
left_width = GEZERO(bw - outside_left); left_width = GEZERO(bw - outside_left);
left_x = left_x + outside_left; left_x = left_x + outside_left;
top_width = top_width - outside_left; top_width = top_width - outside_left;
bottom_width = bottom_width - outside_left; bottom_width = bottom_width - outside_left;
top_x = top_x + outside_left; top_x = top_x + outside_left;
bottom_x = bottom_x + outside_left; bottom_x = bottom_x + outside_left;
} }
// Right border - reduce width when window goes right of monitor // Right border - reduce width when window goes right of monitor
if (outside_right > 0) { if (outside_right > 0) {
right_width = GEZERO(bw - outside_right); right_width = GEZERO(bw - outside_right);
top_width = top_width - outside_right; top_width = top_width - outside_right;
bottom_width = bottom_width - outside_right; bottom_width = bottom_width - outside_right;
} }
}
} // Position the surface within the borders
wlr_scene_node_set_position(&c->scene_surface->node, bw, bw);
// Position the surface within the borders
wlr_scene_node_set_position(&c->scene_surface->node,
bw,
bw);
// Set border sizes
set_rect_size(c->border[0], top_width, top_height); // Top
set_rect_size(c->border[1], bottom_width, bottom_height); // Bottom
set_rect_size(c->border[2], left_width, left_height); // Left
set_rect_size(c->border[3], right_width, right_height); // Right
// Position borders with offsets
wlr_scene_node_set_position(&c->border[0]->node, top_x, top_y );
wlr_scene_node_set_position(&c->border[1]->node, bottom_x, bottom_y);
wlr_scene_node_set_position(&c->border[2]->node, left_x , left_y);
wlr_scene_node_set_position(&c->border[3]->node, right_x, right_y);
// Set border sizes
set_rect_size(c->border[0], top_width, top_height); // Top
set_rect_size(c->border[1], bottom_width, bottom_height); // Bottom
set_rect_size(c->border[2], left_width, left_height); // Left
set_rect_size(c->border[3], right_width, right_height); // Right
// Position borders with offsets
wlr_scene_node_set_position(&c->border[0]->node, top_x, top_y);
wlr_scene_node_set_position(&c->border[1]->node, bottom_x, bottom_y);
wlr_scene_node_set_position(&c->border[2]->node, left_x, left_y);
wlr_scene_node_set_position(&c->border[3]->node, right_x, right_y);
} }
struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) { struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
@ -1236,10 +1234,9 @@ struct uvec2 clip_to_hide(Client *c, struct wlr_box *clip_box) {
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 - (c->animation.current.x +
clip_box->width - 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);
} }
if (c->animation.current.y < c->mon->m.y) { if (c->animation.current.y < c->mon->m.y) {
@ -4083,12 +4080,12 @@ void focusmon(const Arg *arg) {
do /* don't switch to disabled mons */ do /* don't switch to disabled mons */
selmon = dirtomon(arg->i); selmon = dirtomon(arg->i);
while (!selmon->wlr_output->enabled && i++ < nmons); while (!selmon->wlr_output->enabled && i++ < nmons);
} else if(arg->v) { } else if (arg->v) {
wl_list_for_each(m, &mons, link) { wl_list_for_each(m, &mons, link) {
if (!m->wlr_output->enabled) { if (!m->wlr_output->enabled) {
continue; continue;
} }
if(regex_match(arg->v, m->wlr_output->name)) { if (regex_match(arg->v, m->wlr_output->name)) {
selmon = m; selmon = m;
break; break;
} }