mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-04 13:29:56 -05:00
opt: optimize reload config code struct
This commit is contained in:
parent
876c233ed3
commit
33416a10d9
1 changed files with 78 additions and 13 deletions
|
|
@ -2439,17 +2439,57 @@ void parse_config(void) {
|
||||||
override_config();
|
override_config();
|
||||||
}
|
}
|
||||||
|
|
||||||
void reload_config(const Arg *arg) {
|
void reapply_monitor_rules(void) {
|
||||||
Client *c;
|
ConfigMonitorRule *mr;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
int i, jk;
|
int ji, jk;
|
||||||
Keyboard *kb;
|
struct wlr_output_state state;
|
||||||
char *rule_monitor_name = NULL;
|
wlr_output_state_init(&state);
|
||||||
parse_config();
|
|
||||||
init_baked_points();
|
wl_list_for_each(m, &mons, link) {
|
||||||
handlecursoractivity();
|
if (!m->wlr_output->enabled) {
|
||||||
reset_keyboard_layout();
|
continue;
|
||||||
run_exec();
|
}
|
||||||
|
|
||||||
|
for (ji = 0; ji < config.monitor_rules_count; ji++) {
|
||||||
|
if (config.monitor_rules_count < 1)
|
||||||
|
break;
|
||||||
|
|
||||||
|
mr = &config.monitor_rules[ji];
|
||||||
|
if (!mr->name || regex_match(mr->name, m->wlr_output->name)) {
|
||||||
|
|
||||||
|
m->mfact = mr->mfact;
|
||||||
|
m->nmaster = mr->nmaster;
|
||||||
|
m->m.x = mr->x;
|
||||||
|
m->m.y = mr->y;
|
||||||
|
|
||||||
|
if (mr->layout) {
|
||||||
|
for (jk = 0; jk < LENGTH(layouts); jk++) {
|
||||||
|
if (strcmp(layouts[jk].name, mr->layout) == 0) {
|
||||||
|
m->lt = &layouts[jk];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mr->width > 0 && mr->height > 0 && mr->refresh > 0) {
|
||||||
|
wlr_output_state_set_custom_mode(
|
||||||
|
&state, mr->width, mr->height, mr->refresh * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_output_state_set_scale(&state, mr->scale);
|
||||||
|
wlr_output_state_set_transform(&state, mr->rr);
|
||||||
|
wlr_output_layout_add(output_layout, m->wlr_output, mr->x,
|
||||||
|
mr->y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
wlr_output_state_finish(&state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reapply_border(void) {
|
||||||
|
Client *c;
|
||||||
|
|
||||||
// reset border width when config change
|
// reset border width when config change
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
|
|
@ -2459,14 +2499,20 @@ void reload_config(const Arg *arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// reset keyboard repeat rate when config change
|
void reapply_keyboard(void) {
|
||||||
|
Keyboard *kb;
|
||||||
wl_list_for_each(kb, &keyboards, link) {
|
wl_list_for_each(kb, &keyboards, link) {
|
||||||
wlr_keyboard_set_repeat_info(kb->wlr_keyboard, repeat_rate,
|
wlr_keyboard_set_repeat_info(kb->wlr_keyboard, repeat_rate,
|
||||||
repeat_delay);
|
repeat_delay);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// reset master status when config change
|
void reapply_master(void) {
|
||||||
|
|
||||||
|
int i;
|
||||||
|
Monitor *m;
|
||||||
for (i = 0; i <= LENGTH(tags); i++) {
|
for (i = 0; i <= LENGTH(tags); i++) {
|
||||||
wl_list_for_each(m, &mons, link) {
|
wl_list_for_each(m, &mons, link) {
|
||||||
if (!m->wlr_output->enabled) {
|
if (!m->wlr_output->enabled) {
|
||||||
|
|
@ -2481,8 +2527,12 @@ void reload_config(const Arg *arg) {
|
||||||
m->gappov = gappov;
|
m->gappov = gappov;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// reset tag status by tag rules
|
void reapply_tagrule(void) {
|
||||||
|
Monitor *m;
|
||||||
|
int i, jk;
|
||||||
|
char *rule_monitor_name = NULL;
|
||||||
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;
|
||||||
|
|
@ -2505,6 +2555,21 @@ void reload_config(const Arg *arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void reload_config(const Arg *arg) {
|
||||||
|
parse_config();
|
||||||
|
init_baked_points();
|
||||||
|
handlecursoractivity();
|
||||||
|
reset_keyboard_layout();
|
||||||
|
run_exec();
|
||||||
|
|
||||||
|
reapply_border();
|
||||||
|
reapply_keyboard();
|
||||||
|
reapply_master();
|
||||||
|
|
||||||
|
reapply_tagrule();
|
||||||
|
reapply_monitor_rules();
|
||||||
|
|
||||||
arrange(selmon, false);
|
arrange(selmon, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue