style: 禁掉 clang-format 的 AlignConsecutiveAssignments 规则并重新格式化整个项目

This commit is contained in:
2026-06-24 13:05:56 +08:00
parent 8f671bd755
commit bf3de7fb92
38 changed files with 763 additions and 731 deletions

View File

@@ -17,9 +17,9 @@ static constexpr char launcher[] =
typedef struct zdwm_action_data_raise_or_run_t raise_or_run_data_t;
static raise_or_run_data_t terminal = {"XTerm", "xterm"};
static raise_or_run_data_t editor = {"Emacs", "emacsclient -a '' -r -n"};
static raise_or_run_data_t browser = {"firefox", "firefox-bin"};
static raise_or_run_data_t chrome = {"Google-chrome", "google-chrome-stable"};
static raise_or_run_data_t editor = {"Emacs", "emacsclient -a '' -r -n"};
static raise_or_run_data_t browser = {"firefox", "firefox-bin"};
static raise_or_run_data_t chrome = {"Google-chrome", "google-chrome-stable"};
bool config_defaults_build(
const zdwm_api_t *api,
@@ -52,10 +52,12 @@ bool config_defaults_build(
);
zdwm_layout_id_t floating_id =
api->register_layout(builder, "floating", "><>", "floating", nullptr);
if (fair_id == ZDWM_LAYOUT_ID_INVALID ||
maximize_id == ZDWM_LAYOUT_ID_INVALID ||
fullscreen_id == ZDWM_LAYOUT_ID_INVALID ||
floating_id == ZDWM_LAYOUT_ID_INVALID) {
if (
fair_id == ZDWM_LAYOUT_ID_INVALID ||
maximize_id == ZDWM_LAYOUT_ID_INVALID ||
fullscreen_id == ZDWM_LAYOUT_ID_INVALID ||
floating_id == ZDWM_LAYOUT_ID_INVALID
) {
return false;
}
@@ -105,7 +107,7 @@ bool config_defaults_build(
MODE, \
KEY, \
{ \
.type = ZDWM_ACTION_RAISE_OR_RUN, \
.type = ZDWM_ACTION_RAISE_OR_RUN, \
.as.raise_or_run = (zdwm_action_data_raise_or_run_t)__VA_ARGS__, \
} \
)
@@ -136,7 +138,7 @@ bool config_defaults_build(
);
zdwm_action_t window_cycle_output_action = {
.type = ZDWM_ACTION_WINDOW_CYCLE_OUTPUT,
.type = ZDWM_ACTION_WINDOW_CYCLE_OUTPUT,
.as.window_cycle_output = {.delta = 1, .keep_focus = true},
};
BIND_DEFAULT(Super("o"), window_cycle_output_action);
@@ -154,7 +156,7 @@ bool config_defaults_build(
zdwm_action_t send_window_to_workspace_action = {
.type = ZDWM_ACTION_WINDOW_SEND_TO_WORKSPACE_SAME_OUTPUT_BY_INDEX,
.as.window_send_to_workspace_same_output_by_index = {
.index = i,
.index = i,
.switch_workspace = false,
},
};
@@ -170,32 +172,32 @@ bool config_defaults_build(
api->set_interaction_fps(builder, 30);
zdwm_bar_config_t bar_config = {
.height = 28,
.show_top = true,
.padding_x = 10,
.fps = 30,
.height = 28,
.show_top = true,
.padding_x = 10,
.fps = 30,
.font_family = "Terminus, Sarasa Term SC",
.font_size = 10,
.dpi = 144,
.font_size = 10,
.dpi = 144,
.bg = "#222222",
.fg = "#bbbbbb",
.tag_cell_padding_x = 10,
.tag_cell_padding_x = 10,
.tag_indicator_width = 4,
.tag_bg = "#222222",
.tag_fg = "#bbbbbb",
.tag_active_bg = "#005577",
.tag_active_fg = "#eeeeee",
.tag_urgent_bg = "#222222",
.tag_urgent_fg = "#ff0000",
.layout_bg = "#222222",
.layout_fg = "#bbbbbb",
.tag_bg = "#222222",
.tag_fg = "#bbbbbb",
.tag_active_bg = "#005577",
.tag_active_fg = "#eeeeee",
.tag_urgent_bg = "#222222",
.tag_urgent_fg = "#ff0000",
.layout_bg = "#222222",
.layout_fg = "#bbbbbb",
.binding_show_default = true,
.binding_padding_x = 2,
.binding_mode_bg = "#900000",
.binding_mode_fg = "#ffffff",
.binding_padding_x = 2,
.binding_mode_bg = "#900000",
.binding_mode_fg = "#ffffff",
.window_focused_bg = "#005577",
.window_focused_fg = "#eeeeee",

View File

@@ -10,9 +10,9 @@
static char *config_loader_join_path(const char *base, const char *suffix) {
if (!base || !suffix) return nullptr;
size_t base_len = strlen(base);
size_t base_len = strlen(base);
size_t suffix_len = strlen(suffix);
char *path = p_new(char, base_len + suffix_len + 1);
char *path = p_new(char, base_len + suffix_len + 1);
memcpy(path, base, base_len);
memcpy(path + base_len, suffix, suffix_len + 1);
return path;
@@ -25,28 +25,28 @@ static bool config_loader_resolve_path(
) {
const char *path = override_path;
if (path && *path) {
*out_path = p_strdup(path);
*out_path = p_strdup(path);
*out_is_explicit = true;
return true;
}
path = getenv("ZDWM_CONFIG_LIB");
if (path && *path) {
*out_path = p_strdup(path);
*out_path = p_strdup(path);
*out_is_explicit = true;
return true;
}
path = getenv("XDG_CONFIG_HOME");
if (path && *path) {
*out_path = config_loader_join_path(path, "/zdwm/config.so");
*out_path = config_loader_join_path(path, "/zdwm/config.so");
*out_is_explicit = false;
return *out_path != nullptr;
}
path = getenv("HOME");
if (path && *path) {
*out_path = config_loader_join_path(path, "/.config/zdwm/config.so");
*out_path = config_loader_join_path(path, "/.config/zdwm/config.so");
*out_is_explicit = false;
return *out_path != nullptr;
}
@@ -79,7 +79,7 @@ bool config_loader_load(config_loader_t *loader, const char *override_path) {
}
dlerror();
loader->setup = (zdwm_config_setup_fn *)dlsym(loader->handle, "setup");
loader->setup = (zdwm_config_setup_fn *)dlsym(loader->handle, "setup");
const char *error = dlerror();
if (!error) return true;

View File

@@ -38,8 +38,10 @@ struct zdwm_config_builder_t {
void runtime_config_cleanup(runtime_init_desc_t *desc) {
if (!desc) return;
if (desc->layouts.slots || desc->layouts.slot_count ||
desc->layouts.slot_capacity) {
if (
desc->layouts.slots || desc->layouts.slot_count ||
desc->layouts.slot_capacity
) {
layout_registry_cleanup(&desc->layouts);
}
binding_table_destroy(desc->binding_table);
@@ -53,13 +55,15 @@ void runtime_config_cleanup(runtime_init_desc_t *desc) {
static void config_builder_cleanup(zdwm_config_builder_t *builder) {
if (!builder) return;
if (builder->layouts.slots || builder->layouts.slot_count ||
builder->layouts.slot_capacity) {
if (
builder->layouts.slots || builder->layouts.slot_count ||
builder->layouts.slot_capacity
) {
layout_registry_cleanup(&builder->layouts);
}
workspace_desc_list_cleanup(&builder->workspaces, &builder->workspace_count);
builder->workspace_capacity = 0;
builder->output_count = 0;
builder->output_count = 0;
binding_table_destroy(builder->binding_table);
builder->binding_table = nullptr;
@@ -93,10 +97,10 @@ static workspace_id_t runtime_config_define_workspace(
}
workspace_desc_t desc = {
.output_index = output_index,
.name = name,
.layout_ids = layout_ids,
.layout_count = layout_count,
.output_index = output_index,
.name = name,
.layout_ids = layout_ids,
.layout_count = layout_count,
.initial_layout_id = initial_layout_id,
};
if (!workspace_desc_valid(&desc, builder->output_count)) {
@@ -110,15 +114,15 @@ static workspace_id_t runtime_config_define_workspace(
}
workspace_id_t workspace_id = (workspace_id_t)builder->workspace_count;
workspace_desc_t *slot = array_push(
workspace_desc_t *slot = array_push(
builder->workspaces,
builder->workspace_count,
builder->workspace_capacity
);
slot->output_index = output_index;
slot->name = p_strdup(name);
slot->layout_ids = p_copy(layout_ids, layout_count);
slot->layout_count = layout_count;
slot->output_index = output_index;
slot->name = p_strdup(name);
slot->layout_ids = p_copy(layout_ids, layout_count);
slot->layout_count = layout_count;
slot->initial_layout_id = initial_layout_id;
return workspace_id;
}
@@ -151,14 +155,14 @@ static bool runtime_config_add_rule(
if (!rule_match_valid(match)) return false;
if (!rule_action_valid(action, builder->workspace_count)) return false;
rules_t *rules = &builder->rules;
rules_t *rules = &builder->rules;
rule_item_t *rule = array_push(rules->items, rules->count, rules->capacity);
rule->match.app_id = p_strdup_nullable(match->app_id);
rule->match.role = p_strdup_nullable(match->role);
rule->match.class_name = p_strdup_nullable(match->class_name);
rule->match.app_id = p_strdup_nullable(match->app_id);
rule->match.role = p_strdup_nullable(match->role);
rule->match.class_name = p_strdup_nullable(match->class_name);
rule->match.instance_name = p_strdup_nullable(match->instance_name);
rule->action = *action;
rule->action = *action;
return true;
}
@@ -308,18 +312,18 @@ static bool config_builder_finish(
if (!layout_registry_move(&builder->layouts, &out->layouts)) return false;
if (!rules_move(&builder->rules, &out->rules)) return false;
out->border = builder->border;
out->fps = builder->fps;
out->binding_table = builder->binding_table;
out->workspaces = builder->workspaces;
out->workspace_count = builder->workspace_count;
out->listeners = builder->listeners;
out->bar = builder->bar;
builder->binding_table = nullptr;
builder->workspaces = nullptr;
builder->workspace_count = 0;
out->border = builder->border;
out->fps = builder->fps;
out->binding_table = builder->binding_table;
out->workspaces = builder->workspaces;
out->workspace_count = builder->workspace_count;
out->listeners = builder->listeners;
out->bar = builder->bar;
builder->binding_table = nullptr;
builder->workspaces = nullptr;
builder->workspace_count = 0;
builder->workspace_capacity = 0;
builder->output_count = 0;
builder->output_count = 0;
p_clear(&builder->listeners, 1);
p_clear(&builder->bar, 1);
return true;
@@ -333,17 +337,17 @@ static bool runtime_config_build(
) {
if (!setup || !out) return false;
zdwm_config_builder_t builder = {0};
builder.output_count = output_count;
builder.binding_table = binding_table_create();
builder.output_count = output_count;
builder.binding_table = binding_table_create();
/* clang-format off */
zdwm_api_t api = {
.abi_version = ZDWM_CONFIG_ABI_VERSION,
.builtin_layouts =
{
.fair = fair,
.fullscreen = fullscreen,
.maximize = maximize,
},
.builtin_layouts = {
.fair = fair,
.fullscreen = fullscreen,
.maximize = maximize,
},
.register_layout = runtime_config_register_layout,
.define_workspace = runtime_config_define_workspace,
.add_rule = runtime_config_add_rule,
@@ -355,20 +359,19 @@ static bool runtime_config_build(
.set_interaction_fps = runtime_config_set_interaction_fps,
.subscribe_current_output = runtime_config_subscribe_current_output,
.subscribe_initial_workspace_list =
runtime_config_subscribe_initial_workspace_list,
.subscribe_workspace_active = runtime_config_subscribe_workspace_active,
.subscribe_layout = runtime_config_subscribe_layout,
.subscribe_binding_mode = runtime_config_subscribe_binding_mode,
.subscribe_initial_window_list =
runtime_config_subscribe_initial_window_list,
.subscribe_window_added = runtime_config_subscribe_window_added,
.subscribe_window_updated = runtime_config_subscribe_window_updated,
.subscribe_window_removed = runtime_config_subscribe_window_removed,
.subscribe_current_output = runtime_config_subscribe_current_output,
.subscribe_initial_workspace_list = runtime_config_subscribe_initial_workspace_list,
.subscribe_workspace_active = runtime_config_subscribe_workspace_active,
.subscribe_layout = runtime_config_subscribe_layout,
.subscribe_binding_mode = runtime_config_subscribe_binding_mode,
.subscribe_initial_window_list = runtime_config_subscribe_initial_window_list,
.subscribe_window_added = runtime_config_subscribe_window_added,
.subscribe_window_updated = runtime_config_subscribe_window_updated,
.subscribe_window_removed = runtime_config_subscribe_window_removed,
.set_bar_config = runtime_config_set_bar_config,
};
/* clang-format on */
bool ok = setup(&api, &builder, outputs, output_count) &&
config_builder_finish(&builder, out);
config_builder_cleanup(&builder);
@@ -390,7 +393,7 @@ bool runtime_config_load(const char *override_path, runtime_init_desc_t *out) {
bool ok = runtime_config_build(setup, out->outputs, out->output_count, out);
if (ok) {
out->config_module_handle = loader.handle;
loader.handle = nullptr;
loader.handle = nullptr;
}
config_loader_cleanup(&loader);