opt: use config.xxx instead of global presets

This commit is contained in:
tonybanters 2026-03-12 06:49:58 -07:00 committed by DreamMaoMao
parent 1fc89d01eb
commit a7461d9d5b
13 changed files with 826 additions and 997 deletions

View file

@ -3,7 +3,7 @@ int32_t bind_to_view(const Arg *arg) {
return 0;
uint32_t target = arg->ui;
if (view_current_to_back && selmon->pertag->curtag &&
if (config.view_current_to_back && selmon->pertag->curtag &&
(target & TAGMASK) == (selmon->tagset[selmon->seltags])) {
if (selmon->pertag->prevtag)
target = 1 << (selmon->pertag->prevtag - 1);
@ -11,13 +11,13 @@ int32_t bind_to_view(const Arg *arg) {
target = 0;
}
if (!view_current_to_back &&
if (!config.view_current_to_back &&
(target & TAGMASK) == (selmon->tagset[selmon->seltags])) {
return 0;
}
if ((int32_t)target == INT_MIN && selmon->pertag->curtag == 0) {
if (view_current_to_back && selmon->pertag->prevtag)
if (config.view_current_to_back && selmon->pertag->prevtag)
target = 1 << (selmon->pertag->prevtag - 1);
else
target = 0;
@ -96,7 +96,7 @@ int32_t destroy_all_virtual_output(const Arg *arg) {
}
int32_t defaultgaps(const Arg *arg) {
setgaps(gappoh, gappov, gappih, gappiv);
setgaps(config.gappoh, config.gappov, config.gappih, config.gappiv);
return 0;
}
@ -140,7 +140,7 @@ int32_t focusdir(const Arg *arg) {
c = get_focused_stack_client(c);
if (c) {
focusclient(c, 1);
if (warpcursor)
if (config.warpcursor)
warp_cursor(c);
} else {
if (config.focus_cross_tag) {
@ -196,7 +196,7 @@ int32_t focuslast(const Arg *arg) {
}
int32_t toggle_trackpad_enable(const Arg *arg) {
disable_trackpad = !disable_trackpad;
config.disable_trackpad = !config.disable_trackpad;
return 0;
}
@ -225,7 +225,7 @@ int32_t focusmon(const Arg *arg) {
return 0;
selmon = tm;
if (warpcursor) {
if (config.warpcursor) {
warp_cursor_to_selmon(selmon);
}
c = focustop(selmon);
@ -258,7 +258,7 @@ int32_t focusstack(const Arg *arg) {
return 0;
focusclient(tc, 1);
if (warpcursor)
if (config.warpcursor)
warp_cursor(tc);
return 0;
}
@ -390,7 +390,7 @@ int32_t moveresize(const Arg *arg) {
/* Doesn't work for X11 output - the next absolute motion event
* returns the cursor to where it started */
if (grabc->isfloating) {
rzcorner = drag_corner;
rzcorner = config.drag_corner;
grabcx = (int)round(cursor->x);
grabcy = (int)round(cursor->y);
if (rzcorner == 4)
@ -404,7 +404,7 @@ int32_t moveresize(const Arg *arg) {
? 0
: 2);
if (drag_warp_cursor) {
if (config.drag_warp_cursor) {
grabcx = rzcorner & 1 ? grabc->geom.x + grabc->geom.width
: grabc->geom.x;
grabcy = rzcorner & 2 ? grabc->geom.y + grabc->geom.height
@ -476,9 +476,9 @@ int32_t resizewin(const Arg *arg) {
if (!c || c->isfullscreen || c->ismaximizescreen)
return 0;
int32_t animations_state_backup = animations;
int32_t animations_state_backup = config.animations;
if (!c->isfloating)
animations = 0;
config.animations = 0;
if (ISTILED(c)) {
switch (arg->ui) {
@ -505,7 +505,7 @@ int32_t resizewin(const Arg *arg) {
break;
}
resize_tile_client(c, false, offsetx, offsety, 0);
animations = animations_state_backup;
config.animations = animations_state_backup;
return 0;
}
@ -536,7 +536,7 @@ int32_t resizewin(const Arg *arg) {
c->iscustomsize = 1;
c->float_geom = c->geom;
resize(c, c->geom, 0);
animations = animations_state_backup;
config.animations = animations_state_backup;
return 0;
}
@ -608,7 +608,7 @@ int32_t set_proportion(const Arg *arg) {
return 0;
if (selmon->visible_tiling_clients == 1 &&
!scroller_ignore_proportion_single)
!config.scroller_ignore_proportion_single)
return 0;
Client *tc = selmon->sel;
@ -616,7 +616,7 @@ int32_t set_proportion(const Arg *arg) {
if (tc) {
tc = get_scroll_stack_head(tc);
uint32_t max_client_width =
selmon->w.width - 2 * scroller_structs - gappih;
selmon->w.width - 2 * config.scroller_structs - config.gappih;
tc->scroller_proportion = arg->f;
tc->geom.width = max_client_width * arg->f;
arrange(selmon, false, false);
@ -650,7 +650,7 @@ int32_t smartmovewin(const Arg *arg) {
if (c->geom.x + c->geom.width < tc->geom.x ||
c->geom.x > tc->geom.x + tc->geom.width)
continue;
buttom = tc->geom.y + tc->geom.height + gappiv;
buttom = tc->geom.y + tc->geom.height + config.gappiv;
if (top > buttom && ny < buttom) {
tar = MAX(tar, buttom);
};
@ -670,7 +670,7 @@ int32_t smartmovewin(const Arg *arg) {
if (c->geom.x + c->geom.width < tc->geom.x ||
c->geom.x > tc->geom.x + tc->geom.width)
continue;
top = tc->geom.y - gappiv;
top = tc->geom.y - config.gappiv;
if (buttom < top && (ny + c->geom.height) > top) {
tar = MIN(tar, top - c->geom.height);
};
@ -690,7 +690,7 @@ int32_t smartmovewin(const Arg *arg) {
if (c->geom.y + c->geom.height < tc->geom.y ||
c->geom.y > tc->geom.y + tc->geom.height)
continue;
right = tc->geom.x + tc->geom.width + gappih;
right = tc->geom.x + tc->geom.width + config.gappih;
if (left > right && nx < right) {
tar = MAX(tar, right);
};
@ -709,7 +709,7 @@ int32_t smartmovewin(const Arg *arg) {
if (c->geom.y + c->geom.height < tc->geom.y ||
c->geom.y > tc->geom.y + tc->geom.height)
continue;
left = tc->geom.x - gappih;
left = tc->geom.x - config.gappih;
if (right < left && (nx + c->geom.width) > left) {
tar = MIN(tar, left - c->geom.width);
};
@ -757,14 +757,14 @@ int32_t smartresizewin(const Arg *arg) {
if (c->geom.x + c->geom.width < tc->geom.x ||
c->geom.x > tc->geom.x + tc->geom.width)
continue;
top = tc->geom.y - gappiv;
top = tc->geom.y - config.gappiv;
if (buttom < top && (nh + c->geom.y) > top) {
tar = MAX(tar, top - c->geom.y);
};
}
nh = tar == -99999 ? nh : tar;
if (c->geom.y + nh + gappov > selmon->w.y + selmon->w.height)
nh = selmon->w.y + selmon->w.height - c->geom.y - gappov;
if (c->geom.y + nh + config.gappov > selmon->w.y + selmon->w.height)
nh = selmon->w.y + selmon->w.height - c->geom.y - config.gappov;
break;
case LEFT:
nw -= selmon->w.width / 16;
@ -780,15 +780,15 @@ int32_t smartresizewin(const Arg *arg) {
if (c->geom.y + c->geom.height < tc->geom.y ||
c->geom.y > tc->geom.y + tc->geom.height)
continue;
left = tc->geom.x - gappih;
left = tc->geom.x - config.gappih;
if (right < left && (nw + c->geom.x) > left) {
tar = MIN(tar, left - c->geom.x);
};
}
nw = tar == 99999 ? nw : tar;
if (c->geom.x + nw + gappoh > selmon->w.x + selmon->w.width)
nw = selmon->w.x + selmon->w.width - c->geom.x - gappoh;
if (c->geom.x + nw + config.gappoh > selmon->w.x + selmon->w.width)
nw = selmon->w.x + selmon->w.width - c->geom.x - config.gappoh;
break;
}
@ -1046,7 +1046,7 @@ int32_t switch_proportion_preset(const Arg *arg) {
return 0;
if (selmon->visible_tiling_clients == 1 &&
!scroller_ignore_proportion_single)
!config.scroller_ignore_proportion_single)
return 0;
Client *tc = selmon->sel;
@ -1087,7 +1087,7 @@ int32_t switch_proportion_preset(const Arg *arg) {
}
uint32_t max_client_width =
selmon->w.width - 2 * scroller_structs - gappih;
selmon->w.width - 2 * config.scroller_structs - config.gappih;
tc->scroller_proportion = target_proportion;
tc->geom.width = max_client_width * target_proportion;
arrange(selmon, false, false);
@ -1170,7 +1170,7 @@ int32_t tagmon(const Arg *arg) {
focusclient(c, 1);
arrange(selmon, false, false);
}
if (warpcursor) {
if (config.warpcursor) {
warp_cursor_to_selmon(c->mon);
}
return 0;
@ -1257,11 +1257,12 @@ int32_t toggle_scratchpad(const Arg *arg) {
return 0;
wl_list_for_each_safe(c, tmp, &clients, link) {
if (!scratchpad_cross_monitor && c->mon != selmon) {
if (!config.scratchpad_cross_monitor && c->mon != selmon) {
continue;
}
if (single_scratchpad && c->isnamedscratchpad && !c->isminimized) {
if (config.single_scratchpad && c->isnamedscratchpad &&
!c->isminimized) {
set_minimized(c);
continue;
}
@ -1662,7 +1663,8 @@ int32_t toggleoverview(const Arg *arg) {
if (!selmon)
return 0;
if (selmon->isoverview && ov_tab_mode && arg->i != 1 && selmon->sel) {
if (selmon->isoverview && config.ov_tab_mode && arg->i != 1 &&
selmon->sel) {
focusstack(&(Arg){.i = 1});
return 0;
}