mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-03-24 09:06:31 -04:00
Merge branch 'mangowm:main' into main
This commit is contained in:
commit
ffb41b093f
6 changed files with 168 additions and 148 deletions
|
|
@ -356,6 +356,8 @@ typedef struct {
|
||||||
int32_t single_scratchpad;
|
int32_t single_scratchpad;
|
||||||
int32_t xwayland_persistence;
|
int32_t xwayland_persistence;
|
||||||
int32_t syncobj_enable;
|
int32_t syncobj_enable;
|
||||||
|
float drag_tile_refresh_interval;
|
||||||
|
float drag_floating_refresh_interval;
|
||||||
int32_t allow_tearing;
|
int32_t allow_tearing;
|
||||||
int32_t allow_shortcuts_inhibit;
|
int32_t allow_shortcuts_inhibit;
|
||||||
int32_t allow_lock_transparent;
|
int32_t allow_lock_transparent;
|
||||||
|
|
@ -372,6 +374,9 @@ typedef int32_t (*FuncType)(const Arg *);
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
bool parse_config_file(Config *config, const char *file_path, bool must_exist);
|
bool parse_config_file(Config *config, const char *file_path, bool must_exist);
|
||||||
|
bool apply_rule_to_state(Monitor *m, const ConfigMonitorRule *rule,
|
||||||
|
struct wlr_output_state *state, int vrr, int custom);
|
||||||
|
bool monitor_matches_rule(Monitor *m, const ConfigMonitorRule *rule);
|
||||||
|
|
||||||
// Helper function to trim whitespace from start and end of a string
|
// Helper function to trim whitespace from start and end of a string
|
||||||
void trim_whitespace(char *str) {
|
void trim_whitespace(char *str) {
|
||||||
|
|
@ -947,6 +952,7 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value,
|
||||||
(*arg).f = atof(arg_value);
|
(*arg).f = atof(arg_value);
|
||||||
} else if (strcmp(func_name, "switch_proportion_preset") == 0) {
|
} else if (strcmp(func_name, "switch_proportion_preset") == 0) {
|
||||||
func = switch_proportion_preset;
|
func = switch_proportion_preset;
|
||||||
|
(*arg).i = parse_circle_direction(arg_value);
|
||||||
} else if (strcmp(func_name, "viewtoleft") == 0) {
|
} else if (strcmp(func_name, "viewtoleft") == 0) {
|
||||||
func = viewtoleft;
|
func = viewtoleft;
|
||||||
(*arg).i = atoi(arg_value);
|
(*arg).i = atoi(arg_value);
|
||||||
|
|
@ -1399,6 +1405,10 @@ bool parse_option(Config *config, char *key, char *value) {
|
||||||
config->xwayland_persistence = atoi(value);
|
config->xwayland_persistence = atoi(value);
|
||||||
} else if (strcmp(key, "syncobj_enable") == 0) {
|
} else if (strcmp(key, "syncobj_enable") == 0) {
|
||||||
config->syncobj_enable = atoi(value);
|
config->syncobj_enable = atoi(value);
|
||||||
|
} else if (strcmp(key, "drag_tile_refresh_interval") == 0) {
|
||||||
|
config->drag_tile_refresh_interval = atof(value);
|
||||||
|
} else if (strcmp(key, "drag_floating_refresh_interval") == 0) {
|
||||||
|
config->drag_floating_refresh_interval = atof(value);
|
||||||
} else if (strcmp(key, "allow_tearing") == 0) {
|
} else if (strcmp(key, "allow_tearing") == 0) {
|
||||||
config->allow_tearing = atoi(value);
|
config->allow_tearing = atoi(value);
|
||||||
} else if (strcmp(key, "allow_shortcuts_inhibit") == 0) {
|
} else if (strcmp(key, "allow_shortcuts_inhibit") == 0) {
|
||||||
|
|
@ -3149,6 +3159,13 @@ void override_config(void) {
|
||||||
// 杂项设置
|
// 杂项设置
|
||||||
xwayland_persistence = CLAMP_INT(config.xwayland_persistence, 0, 1);
|
xwayland_persistence = CLAMP_INT(config.xwayland_persistence, 0, 1);
|
||||||
syncobj_enable = CLAMP_INT(config.syncobj_enable, 0, 1);
|
syncobj_enable = CLAMP_INT(config.syncobj_enable, 0, 1);
|
||||||
|
drag_tile_refresh_interval =
|
||||||
|
CLAMP_FLOAT(config.drag_tile_refresh_interval, 1.0f, 16.0f);
|
||||||
|
drag_floating_refresh_interval =
|
||||||
|
CLAMP_FLOAT(config.drag_floating_refresh_interval, 1.0f, 16.0f);
|
||||||
|
drag_tile_to_tile = CLAMP_INT(config.drag_tile_to_tile, 0, 1);
|
||||||
|
drag_floating_refresh_interval =
|
||||||
|
CLAMP_FLOAT(config.drag_floating_refresh_interval, 0.0f, 1000.0f);
|
||||||
allow_tearing = CLAMP_INT(config.allow_tearing, 0, 2);
|
allow_tearing = CLAMP_INT(config.allow_tearing, 0, 2);
|
||||||
allow_shortcuts_inhibit = CLAMP_INT(config.allow_shortcuts_inhibit, 0, 1);
|
allow_shortcuts_inhibit = CLAMP_INT(config.allow_shortcuts_inhibit, 0, 1);
|
||||||
allow_lock_transparent = CLAMP_INT(config.allow_lock_transparent, 0, 1);
|
allow_lock_transparent = CLAMP_INT(config.allow_lock_transparent, 0, 1);
|
||||||
|
|
@ -3337,6 +3354,8 @@ void set_value_default() {
|
||||||
config.single_scratchpad = single_scratchpad;
|
config.single_scratchpad = single_scratchpad;
|
||||||
config.xwayland_persistence = xwayland_persistence;
|
config.xwayland_persistence = xwayland_persistence;
|
||||||
config.syncobj_enable = syncobj_enable;
|
config.syncobj_enable = syncobj_enable;
|
||||||
|
config.drag_tile_refresh_interval = drag_tile_refresh_interval;
|
||||||
|
config.drag_floating_refresh_interval = drag_floating_refresh_interval;
|
||||||
config.allow_tearing = allow_tearing;
|
config.allow_tearing = allow_tearing;
|
||||||
config.allow_shortcuts_inhibit = allow_shortcuts_inhibit;
|
config.allow_shortcuts_inhibit = allow_shortcuts_inhibit;
|
||||||
config.allow_lock_transparent = allow_lock_transparent;
|
config.allow_lock_transparent = allow_lock_transparent;
|
||||||
|
|
@ -3566,14 +3585,12 @@ void reapply_monitor_rules(void) {
|
||||||
int32_t ji, vrr, custom;
|
int32_t ji, vrr, custom;
|
||||||
int32_t mx, my;
|
int32_t mx, my;
|
||||||
struct wlr_output_state state;
|
struct wlr_output_state state;
|
||||||
struct wlr_output_mode *internal_mode = NULL;
|
|
||||||
wlr_output_state_init(&state);
|
|
||||||
bool match_rule = false;
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
|
||||||
|
wlr_output_state_init(&state);
|
||||||
|
|
||||||
for (ji = 0; ji < config.monitor_rules_count; ji++) {
|
for (ji = 0; ji < config.monitor_rules_count; ji++) {
|
||||||
if (config.monitor_rules_count < 1)
|
if (config.monitor_rules_count < 1)
|
||||||
|
|
@ -3581,73 +3598,22 @@ void reapply_monitor_rules(void) {
|
||||||
|
|
||||||
mr = &config.monitor_rules[ji];
|
mr = &config.monitor_rules[ji];
|
||||||
|
|
||||||
// 检查是否匹配的变量
|
if (monitor_matches_rule(m, mr)) {
|
||||||
match_rule = true;
|
|
||||||
|
|
||||||
// 检查四个标识字段的匹配
|
|
||||||
if (mr->name != NULL) {
|
|
||||||
if (!regex_match(mr->name, m->wlr_output->name)) {
|
|
||||||
match_rule = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mr->make != NULL) {
|
|
||||||
if (m->wlr_output->make == NULL ||
|
|
||||||
strcmp(mr->make, m->wlr_output->make) != 0) {
|
|
||||||
match_rule = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mr->model != NULL) {
|
|
||||||
if (m->wlr_output->model == NULL ||
|
|
||||||
strcmp(mr->model, m->wlr_output->model) != 0) {
|
|
||||||
match_rule = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mr->serial != NULL) {
|
|
||||||
if (m->wlr_output->serial == NULL ||
|
|
||||||
strcmp(mr->serial, m->wlr_output->serial) != 0) {
|
|
||||||
match_rule = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 只有当所有指定的标识都匹配时才应用规则
|
|
||||||
if (match_rule) {
|
|
||||||
mx = mr->x == INT32_MAX ? m->m.x : mr->x;
|
mx = mr->x == INT32_MAX ? m->m.x : mr->x;
|
||||||
my = mr->y == INT32_MAX ? m->m.y : mr->y;
|
my = mr->y == INT32_MAX ? m->m.y : mr->y;
|
||||||
vrr = mr->vrr >= 0 ? mr->vrr : 0;
|
vrr = mr->vrr >= 0 ? mr->vrr : 0;
|
||||||
custom = mr->custom >= 0 ? mr->custom : 0;
|
custom = mr->custom >= 0 ? mr->custom : 0;
|
||||||
|
|
||||||
if (mr->width > 0 && mr->height > 0 && mr->refresh > 0) {
|
(void)apply_rule_to_state(m, mr, &state, vrr, custom);
|
||||||
internal_mode = get_nearest_output_mode(
|
|
||||||
m->wlr_output, mr->width, mr->height, mr->refresh);
|
|
||||||
if (internal_mode) {
|
|
||||||
wlr_output_state_set_mode(&state, internal_mode);
|
|
||||||
} else if (custom ||
|
|
||||||
wlr_output_is_headless(m->wlr_output)) {
|
|
||||||
wlr_output_state_set_custom_mode(
|
|
||||||
&state, mr->width, mr->height,
|
|
||||||
(int32_t)roundf(mr->refresh * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vrr) {
|
|
||||||
enable_adaptive_sync(m, &state);
|
|
||||||
} else {
|
|
||||||
wlr_output_state_set_adaptive_sync_enabled(&state, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
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, mx, my);
|
wlr_output_layout_add(output_layout, m->wlr_output, mx, my);
|
||||||
|
wlr_output_commit_state(m->wlr_output, &state);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_output_commit_state(m->wlr_output, &state);
|
|
||||||
wlr_output_state_finish(&state);
|
wlr_output_state_finish(&state);
|
||||||
updatemons(NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
updatemons(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reapply_cursor_style(void) {
|
void reapply_cursor_style(void) {
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ int32_t drag_warp_cursor = 1;
|
||||||
int32_t xwayland_persistence = 1; /* xwayland persistence */
|
int32_t xwayland_persistence = 1; /* xwayland persistence */
|
||||||
int32_t syncobj_enable = 0;
|
int32_t syncobj_enable = 0;
|
||||||
int32_t allow_lock_transparent = 0;
|
int32_t allow_lock_transparent = 0;
|
||||||
double drag_tile_refresh_interval = 16.0;
|
double drag_tile_refresh_interval = 8.0;
|
||||||
double drag_floating_refresh_interval = 8.0;
|
double drag_floating_refresh_interval = 8.0;
|
||||||
int32_t allow_tearing = TEARING_DISABLED;
|
int32_t allow_tearing = TEARING_DISABLED;
|
||||||
int32_t allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
|
int32_t allow_shortcuts_inhibit = SHORTCUTS_INHIBIT_ENABLE;
|
||||||
|
|
|
||||||
|
|
@ -1080,13 +1080,28 @@ int32_t switch_proportion_preset(const Arg *arg) {
|
||||||
for (int32_t i = 0; i < config.scroller_proportion_preset_count; i++) {
|
for (int32_t i = 0; i < config.scroller_proportion_preset_count; i++) {
|
||||||
if (config.scroller_proportion_preset[i] ==
|
if (config.scroller_proportion_preset[i] ==
|
||||||
tc->scroller_proportion) {
|
tc->scroller_proportion) {
|
||||||
if (i == config.scroller_proportion_preset_count - 1) {
|
|
||||||
target_proportion = config.scroller_proportion_preset[0];
|
if (arg->i == NEXT) {
|
||||||
break;
|
if (i == config.scroller_proportion_preset_count - 1) {
|
||||||
|
target_proportion =
|
||||||
|
config.scroller_proportion_preset[0];
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
target_proportion =
|
||||||
|
config.scroller_proportion_preset[i + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
target_proportion =
|
if (i == 0) {
|
||||||
config.scroller_proportion_preset[i + 1];
|
target_proportion =
|
||||||
break;
|
config.scroller_proportion_preset
|
||||||
|
[config.scroller_proportion_preset_count - 1];
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
target_proportion =
|
||||||
|
config.scroller_proportion_preset[i - 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,6 @@ void save_old_size_per(Monitor *m) {
|
||||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||||
c->old_master_inner_per = c->master_inner_per;
|
c->old_master_inner_per = c->master_inner_per;
|
||||||
c->old_stack_inner_per = c->stack_inner_per;
|
c->old_stack_inner_per = c->stack_inner_per;
|
||||||
} else {
|
|
||||||
if (c->old_master_inner_per <= 0.0f ||
|
|
||||||
c->old_master_inner_per > 1.0f) {
|
|
||||||
c->old_master_inner_per = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c->old_stack_inner_per <= 0.0f ||
|
|
||||||
c->old_stack_inner_per > 1.0f) {
|
|
||||||
c->old_stack_inner_per = 1.0f;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +44,10 @@ void restore_size_per(Monitor *m, Client *c) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it is possible that the current floating window is moved to another tag,
|
||||||
|
// but the tag has not executed save_old_size_per
|
||||||
|
// so it must be judged whether their old size values are initial values
|
||||||
|
|
||||||
if (!c->ismaster && c->old_stack_inner_per < 1.0 &&
|
if (!c->ismaster && c->old_stack_inner_per < 1.0 &&
|
||||||
c->old_stack_inner_per > 0.0f && c->stack_inner_per < 1.0 &&
|
c->old_stack_inner_per > 0.0f && c->stack_inner_per < 1.0 &&
|
||||||
c->stack_inner_per > 0.0f) {
|
c->stack_inner_per > 0.0f) {
|
||||||
|
|
@ -285,6 +279,21 @@ void resize_tile_master_horizontal(Client *grabc, bool isdrag, int32_t offsetx,
|
||||||
// 应用到所有平铺窗口
|
// 应用到所有平铺窗口
|
||||||
wl_list_for_each(tc, &clients, link) {
|
wl_list_for_each(tc, &clients, link) {
|
||||||
if (VISIBLEON(tc, grabc->mon) && ISTILED(tc)) {
|
if (VISIBLEON(tc, grabc->mon) && ISTILED(tc)) {
|
||||||
|
|
||||||
|
if (!isdrag && tc != grabc && type != CENTER_TILE) {
|
||||||
|
if (!tc->ismaster && new_stack_inner_per != 1.0f &&
|
||||||
|
grabc->old_stack_inner_per != 1.0f)
|
||||||
|
tc->stack_inner_per = (1 - new_stack_inner_per) /
|
||||||
|
(1 - grabc->old_stack_inner_per) *
|
||||||
|
tc->stack_inner_per;
|
||||||
|
if (tc->ismaster && new_master_inner_per != 1.0f &&
|
||||||
|
grabc->old_master_inner_per != 1.0f)
|
||||||
|
tc->master_inner_per =
|
||||||
|
(1.0f - new_master_inner_per) /
|
||||||
|
(1.0f - grabc->old_master_inner_per) *
|
||||||
|
tc->master_inner_per;
|
||||||
|
}
|
||||||
|
|
||||||
tc->master_mfact_per = new_master_mfact_per;
|
tc->master_mfact_per = new_master_mfact_per;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -440,6 +449,20 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx,
|
||||||
// 应用到所有平铺窗口
|
// 应用到所有平铺窗口
|
||||||
wl_list_for_each(tc, &clients, link) {
|
wl_list_for_each(tc, &clients, link) {
|
||||||
if (VISIBLEON(tc, grabc->mon) && ISTILED(tc)) {
|
if (VISIBLEON(tc, grabc->mon) && ISTILED(tc)) {
|
||||||
|
if (!isdrag && tc != grabc && type != CENTER_TILE) {
|
||||||
|
if (!tc->ismaster && new_stack_inner_per != 1.0f &&
|
||||||
|
grabc->old_stack_inner_per != 1.0f)
|
||||||
|
tc->stack_inner_per = (1 - new_stack_inner_per) /
|
||||||
|
(1 - grabc->old_stack_inner_per) *
|
||||||
|
tc->stack_inner_per;
|
||||||
|
if (tc->ismaster && new_master_inner_per != 1.0f &&
|
||||||
|
grabc->old_master_inner_per != 1.0f)
|
||||||
|
tc->master_inner_per =
|
||||||
|
(1.0f - new_master_inner_per) /
|
||||||
|
(1.0f - grabc->old_master_inner_per) *
|
||||||
|
tc->master_inner_per;
|
||||||
|
}
|
||||||
|
|
||||||
tc->master_mfact_per = new_master_mfact_per;
|
tc->master_mfact_per = new_master_mfact_per;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -462,6 +485,7 @@ void resize_tile_master_vertical(Client *grabc, bool isdrag, int32_t offsetx,
|
||||||
|
|
||||||
void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx,
|
void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx,
|
||||||
int32_t offsety, uint32_t time, bool isvertical) {
|
int32_t offsety, uint32_t time, bool isvertical) {
|
||||||
|
Client *tc = NULL;
|
||||||
float delta_x, delta_y;
|
float delta_x, delta_y;
|
||||||
float new_scroller_proportion;
|
float new_scroller_proportion;
|
||||||
float new_stack_proportion;
|
float new_stack_proportion;
|
||||||
|
|
@ -622,12 +646,22 @@ void resize_tile_scroller(Client *grabc, bool isdrag, int32_t offsetx,
|
||||||
// 应用限制,确保比例在合理范围内
|
// 应用限制,确保比例在合理范围内
|
||||||
new_scroller_proportion =
|
new_scroller_proportion =
|
||||||
fmaxf(0.1f, fminf(1.0f, new_scroller_proportion));
|
fmaxf(0.1f, fminf(1.0f, new_scroller_proportion));
|
||||||
new_stack_proportion = fmaxf(0.1f, fminf(1.0f, new_stack_proportion));
|
new_stack_proportion = fmaxf(0.1f, fminf(0.9f, new_stack_proportion));
|
||||||
|
|
||||||
grabc->stack_proportion = new_stack_proportion;
|
grabc->stack_proportion = new_stack_proportion;
|
||||||
|
|
||||||
stack_head->scroller_proportion = new_scroller_proportion;
|
stack_head->scroller_proportion = new_scroller_proportion;
|
||||||
|
|
||||||
|
wl_list_for_each(tc, &clients, link) {
|
||||||
|
if (new_stack_proportion != 1.0f &&
|
||||||
|
grabc->old_stack_proportion != 1.0f && tc != grabc &&
|
||||||
|
ISTILED(tc) && get_scroll_stack_head(tc) == stack_head) {
|
||||||
|
tc->stack_proportion = (1.0f - new_stack_proportion) /
|
||||||
|
(1.0f - grabc->old_stack_proportion) *
|
||||||
|
tc->stack_proportion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isdrag) {
|
if (!isdrag) {
|
||||||
arrange(grabc->mon, false, false);
|
arrange(grabc->mon, false, false);
|
||||||
return;
|
return;
|
||||||
|
|
@ -670,6 +704,18 @@ void resize_tile_client(Client *grabc, bool isdrag, int32_t offsetx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If there are no calculation omissions,
|
||||||
|
these two functions will never be triggered.
|
||||||
|
Just in case to facilitate the final investigation*/
|
||||||
|
|
||||||
|
void check_size_per_valid(Client *c) {
|
||||||
|
if (c->ismaster) {
|
||||||
|
assert(c->master_inner_per > 0.0f && c->master_inner_per <= 1.0f);
|
||||||
|
} else {
|
||||||
|
assert(c->stack_inner_per > 0.0f && c->stack_inner_per <= 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num,
|
void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num,
|
||||||
double total_left_stack_hight_percent,
|
double total_left_stack_hight_percent,
|
||||||
double total_right_stack_hight_percent,
|
double total_right_stack_hight_percent,
|
||||||
|
|
@ -685,6 +731,7 @@ void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num,
|
||||||
|
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||||
|
|
||||||
if (total_master_inner_percent > 0.0 && i < nmasters) {
|
if (total_master_inner_percent > 0.0 && i < nmasters) {
|
||||||
c->ismaster = true;
|
c->ismaster = true;
|
||||||
c->stack_inner_per = stack_num ? 1.0f / stack_num : 1.0f;
|
c->stack_inner_per = stack_num ? 1.0f / stack_num : 1.0f;
|
||||||
|
|
@ -700,17 +747,20 @@ void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num,
|
||||||
: 1.0f;
|
: 1.0f;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
check_size_per_valid(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wl_list_for_each(c, &clients, link) {
|
wl_list_for_each(c, &clients, link) {
|
||||||
if (VISIBLEON(c, m) && ISTILED(c)) {
|
if (VISIBLEON(c, m) && ISTILED(c)) {
|
||||||
|
|
||||||
if (total_master_inner_percent > 0.0 && i < nmasters) {
|
if (total_master_inner_percent > 0.0 && i < nmasters) {
|
||||||
c->ismaster = true;
|
c->ismaster = true;
|
||||||
if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) {
|
if ((stack_index % 2) ^ (tile_cilent_num % 2 == 0)) {
|
||||||
c->stack_inner_per =
|
c->stack_inner_per =
|
||||||
stack_num > 1 ? 1.0f / ((stack_num - 1) / 2) : 1.0f;
|
stack_num > 1 ? 1.0f / ((stack_num - 1) / 2.0f)
|
||||||
|
: 1.0f;
|
||||||
} else {
|
} else {
|
||||||
c->stack_inner_per =
|
c->stack_inner_per =
|
||||||
stack_num > 1 ? 2.0f / stack_num : 1.0f;
|
stack_num > 1 ? 2.0f / stack_num : 1.0f;
|
||||||
|
|
@ -739,6 +789,8 @@ void reset_size_per_mon(Monitor *m, int32_t tile_cilent_num,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
check_size_per_valid(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
117
src/mango.c
117
src/mango.c
|
|
@ -806,7 +806,6 @@ static int32_t keep_idle_inhibit(void *data);
|
||||||
static void check_keep_idle_inhibit(Client *c);
|
static void check_keep_idle_inhibit(Client *c);
|
||||||
static void pre_caculate_before_arrange(Monitor *m, bool want_animation,
|
static void pre_caculate_before_arrange(Monitor *m, bool want_animation,
|
||||||
bool from_view, bool only_caculate);
|
bool from_view, bool only_caculate);
|
||||||
|
|
||||||
#include "data/static_keymap.h"
|
#include "data/static_keymap.h"
|
||||||
#include "dispatch/bind_declare.h"
|
#include "dispatch/bind_declare.h"
|
||||||
#include "layout/layout.h"
|
#include "layout/layout.h"
|
||||||
|
|
@ -2878,6 +2877,49 @@ void enable_adaptive_sync(Monitor *m, struct wlr_output_state *state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool monitor_matches_rule(Monitor *m, const ConfigMonitorRule *rule) {
|
||||||
|
if (rule->name != NULL && !regex_match(rule->name, m->wlr_output->name))
|
||||||
|
return false;
|
||||||
|
if (rule->make != NULL && (m->wlr_output->make == NULL ||
|
||||||
|
strcmp(rule->make, m->wlr_output->make) != 0))
|
||||||
|
return false;
|
||||||
|
if (rule->model != NULL && (m->wlr_output->model == NULL ||
|
||||||
|
strcmp(rule->model, m->wlr_output->model) != 0))
|
||||||
|
return false;
|
||||||
|
if (rule->serial != NULL &&
|
||||||
|
(m->wlr_output->serial == NULL ||
|
||||||
|
strcmp(rule->serial, m->wlr_output->serial) != 0))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 将规则中的显示参数应用到 wlr_output_state 中,返回是否设置了自定义模式 */
|
||||||
|
bool apply_rule_to_state(Monitor *m, const ConfigMonitorRule *rule,
|
||||||
|
struct wlr_output_state *state, int vrr, int custom) {
|
||||||
|
bool mode_set = false;
|
||||||
|
if (rule->width > 0 && rule->height > 0 && rule->refresh > 0) {
|
||||||
|
struct wlr_output_mode *internal_mode = get_nearest_output_mode(
|
||||||
|
m->wlr_output, rule->width, rule->height, rule->refresh);
|
||||||
|
if (internal_mode) {
|
||||||
|
wlr_output_state_set_mode(state, internal_mode);
|
||||||
|
mode_set = true;
|
||||||
|
} else if (custom || wlr_output_is_headless(m->wlr_output)) {
|
||||||
|
wlr_output_state_set_custom_mode(
|
||||||
|
state, rule->width, rule->height,
|
||||||
|
(int32_t)roundf(rule->refresh * 1000));
|
||||||
|
mode_set = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vrr) {
|
||||||
|
enable_adaptive_sync(m, state);
|
||||||
|
} else {
|
||||||
|
wlr_output_state_set_adaptive_sync_enabled(state, false);
|
||||||
|
}
|
||||||
|
wlr_output_state_set_scale(state, rule->scale);
|
||||||
|
wlr_output_state_set_transform(state, rule->rr);
|
||||||
|
return mode_set;
|
||||||
|
}
|
||||||
|
|
||||||
void createmon(struct wl_listener *listener, void *data) {
|
void createmon(struct wl_listener *listener, void *data) {
|
||||||
/* This event is raised by the backend when a new output (aka a display or
|
/* This event is raised by the backend when a new output (aka a display or
|
||||||
* monitor) becomes available. */
|
* monitor) becomes available. */
|
||||||
|
|
@ -2887,9 +2929,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
int32_t ji, vrr, custom;
|
int32_t ji, vrr, custom;
|
||||||
struct wlr_output_state state;
|
struct wlr_output_state state;
|
||||||
Monitor *m = NULL;
|
Monitor *m = NULL;
|
||||||
struct wlr_output_mode *internal_mode = NULL;
|
|
||||||
bool custom_monitor_mode = false;
|
bool custom_monitor_mode = false;
|
||||||
bool match_rule = false;
|
|
||||||
|
|
||||||
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
if (!wlr_output_init_render(wlr_output, alloc, drw))
|
||||||
return;
|
return;
|
||||||
|
|
@ -2919,7 +2959,6 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
for (i = 0; i < LENGTH(m->layers); i++)
|
for (i = 0; i < LENGTH(m->layers); i++)
|
||||||
wl_list_init(&m->layers[i]);
|
wl_list_init(&m->layers[i]);
|
||||||
|
|
||||||
wlr_output_state_init(&state);
|
|
||||||
/* Initialize monitor state using configured rules */
|
/* Initialize monitor state using configured rules */
|
||||||
m->gappih = gappih;
|
m->gappih = gappih;
|
||||||
m->gappiv = gappiv;
|
m->gappiv = gappiv;
|
||||||
|
|
@ -2932,6 +2971,8 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
m->m.y = INT32_MAX;
|
m->m.y = INT32_MAX;
|
||||||
float scale = 1;
|
float scale = 1;
|
||||||
enum wl_output_transform rr = WL_OUTPUT_TRANSFORM_NORMAL;
|
enum wl_output_transform rr = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
|
||||||
|
wlr_output_state_init(&state);
|
||||||
wlr_output_state_set_scale(&state, scale);
|
wlr_output_state_set_scale(&state, scale);
|
||||||
wlr_output_state_set_transform(&state, rr);
|
wlr_output_state_set_transform(&state, rr);
|
||||||
|
|
||||||
|
|
@ -2941,38 +2982,7 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
r = &config.monitor_rules[ji];
|
r = &config.monitor_rules[ji];
|
||||||
|
|
||||||
// 检查是否匹配的变量
|
if (monitor_matches_rule(m, r)) {
|
||||||
match_rule = true;
|
|
||||||
|
|
||||||
// 检查四个标识字段的匹配
|
|
||||||
if (r->name != NULL) {
|
|
||||||
if (!regex_match(r->name, m->wlr_output->name)) {
|
|
||||||
match_rule = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r->make != NULL) {
|
|
||||||
if (m->wlr_output->make == NULL ||
|
|
||||||
strcmp(r->make, m->wlr_output->make) != 0) {
|
|
||||||
match_rule = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r->model != NULL) {
|
|
||||||
if (m->wlr_output->model == NULL ||
|
|
||||||
strcmp(r->model, m->wlr_output->model) != 0) {
|
|
||||||
match_rule = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r->serial != NULL) {
|
|
||||||
if (m->wlr_output->serial == NULL ||
|
|
||||||
strcmp(r->serial, m->wlr_output->serial) != 0) {
|
|
||||||
match_rule = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match_rule) {
|
|
||||||
m->m.x = r->x == INT32_MAX ? INT32_MAX : r->x;
|
m->m.x = r->x == INT32_MAX ? INT32_MAX : r->x;
|
||||||
m->m.y = r->y == INT32_MAX ? INT32_MAX : r->y;
|
m->m.y = r->y == INT32_MAX ? INT32_MAX : r->y;
|
||||||
vrr = r->vrr >= 0 ? r->vrr : 0;
|
vrr = r->vrr >= 0 ? r->vrr : 0;
|
||||||
|
|
@ -2980,36 +2990,13 @@ void createmon(struct wl_listener *listener, void *data) {
|
||||||
scale = r->scale;
|
scale = r->scale;
|
||||||
rr = r->rr;
|
rr = r->rr;
|
||||||
|
|
||||||
if (r->width > 0 && r->height > 0 && r->refresh > 0) {
|
if (apply_rule_to_state(m, r, &state, vrr, custom)) {
|
||||||
internal_mode = get_nearest_output_mode(m->wlr_output, r->width,
|
custom_monitor_mode = true;
|
||||||
r->height, r->refresh);
|
|
||||||
if (internal_mode) {
|
|
||||||
custom_monitor_mode = true;
|
|
||||||
wlr_output_state_set_mode(&state, internal_mode);
|
|
||||||
} else if (custom || wlr_output_is_headless(m->wlr_output)) {
|
|
||||||
custom_monitor_mode = true;
|
|
||||||
wlr_output_state_set_custom_mode(
|
|
||||||
&state, r->width, r->height,
|
|
||||||
(int32_t)roundf(r->refresh * 1000));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
break; // 只应用第一个匹配规则
|
||||||
if (vrr) {
|
|
||||||
enable_adaptive_sync(m, &state);
|
|
||||||
} else {
|
|
||||||
wlr_output_state_set_adaptive_sync_enabled(&state, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_output_state_set_scale(&state, r->scale);
|
|
||||||
wlr_output_state_set_transform(&state, r->rr);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The mode is a tuple of (width, height, refresh rate), and each
|
|
||||||
* monitor supports only a specific set of modes. We just pick the
|
|
||||||
* monitor's preferred mode; a more sophisticated compositor would let
|
|
||||||
* the user configure it. */
|
|
||||||
if (!custom_monitor_mode)
|
if (!custom_monitor_mode)
|
||||||
wlr_output_state_set_mode(&state,
|
wlr_output_state_set_mode(&state,
|
||||||
wlr_output_preferred_mode(wlr_output));
|
wlr_output_preferred_mode(wlr_output));
|
||||||
|
|
@ -4026,9 +4013,9 @@ void init_client_properties(Client *c) {
|
||||||
c->master_mfact_per = 0.0f;
|
c->master_mfact_per = 0.0f;
|
||||||
c->master_inner_per = 0.0f;
|
c->master_inner_per = 0.0f;
|
||||||
c->stack_inner_per = 0.0f;
|
c->stack_inner_per = 0.0f;
|
||||||
c->old_stack_inner_per = 0.0f;
|
c->old_stack_inner_per = 1.0f;
|
||||||
c->old_master_inner_per = 0.0f;
|
c->old_master_inner_per = 1.0f;
|
||||||
c->old_master_mfact_per = 0.0f;
|
c->old_master_mfact_per = 1.0f;
|
||||||
c->isterm = 0;
|
c->isterm = 0;
|
||||||
c->allow_csd = 0;
|
c->allow_csd = 0;
|
||||||
c->force_maximize = 0;
|
c->force_maximize = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue