style: 更新 .clang-format 规则并重新格式化所有源文件

- 重构模块使用新的代码风格
- 老代码 (src 目录下的代码) 继续使用之前的代码风格

通过在需要不同代码风格的目录下放对应 .clang-format 配置文件实现
This commit is contained in:
2026-04-14 01:52:53 +08:00
parent 7b5404e8e0
commit 2fc4b33359
62 changed files with 1248 additions and 728 deletions

View File

@@ -35,10 +35,13 @@ typedef struct zdwm_api_t {
* @returns 返回布局算法对应的布局 id ,如果注册失败,返回
* ZDWM_LAYOUT_ID_INVALID
*/
zdwm_layout_id_t (*register_layout)(zdwm_config_builder_t *builder,
const char *name, const char *symbol,
const char *description,
zdwm_layout_fn fn);
zdwm_layout_id_t (*register_layout)(
zdwm_config_builder_t *builder,
const char *name,
const char *symbol,
const char *description,
zdwm_layout_fn fn
);
/**
* 用户调用这个函数添加 output 中的工作空间
@@ -50,11 +53,14 @@ typedef struct zdwm_api_t {
* @param initial_layout_id 初始布局算法 id
* @returns 返回工作空间 id 。如果注册失败,返回 ZDWM_WORKSPACE_ID_INVALID
*/
zdwm_workspace_id_t (*define_workspace)(zdwm_config_builder_t *builder,
size_t output_index, const char *name,
const zdwm_layout_id_t *layout_ids,
size_t layout_count,
zdwm_layout_id_t initial_layout_id);
zdwm_workspace_id_t (*define_workspace)(
zdwm_config_builder_t *builder,
size_t output_index,
const char *name,
const zdwm_layout_id_t *layout_ids,
size_t layout_count,
zdwm_layout_id_t initial_layout_id
);
/**
* 用户调用这个函数添加窗口规则
@@ -65,9 +71,11 @@ typedef struct zdwm_api_t {
* @details 不合法的情况match 所有字段全为 nullptr
* 或 action 无任何动作;或 action 指定的 workspace 不存在
*/
bool (*add_rule)(zdwm_config_builder_t *builder,
const zdwm_rule_match_t *match,
const zdwm_rule_action_t *action);
bool (*add_rule)(
zdwm_config_builder_t *builder,
const zdwm_rule_match_t *match,
const zdwm_rule_action_t *action
);
} zdwm_api_t;
/**
@@ -79,10 +87,12 @@ typedef struct zdwm_api_t {
* @param output_count 屏幕个数
* @returns 用户配置成功返回 true ,配置失败返回 false
*/
typedef bool zdwm_config_setup_fn(const zdwm_api_t *api,
zdwm_config_builder_t *builder,
const zdwm_output_info_t *outputs,
size_t output_count);
typedef bool zdwm_config_setup_fn(
const zdwm_api_t *api,
zdwm_config_builder_t *builder,
const zdwm_output_info_t *outputs,
size_t output_count
);
/* 用户在自己的动态链接库配置中必须实现该函数 */
extern zdwm_config_setup_fn setup;

View File

@@ -30,16 +30,18 @@ typedef struct zdwm_layout_result_t {
size_t item_capacity;
} zdwm_layout_result_t;
typedef bool (*zdwm_layout_fn)(const zdwm_layout_ctx_t *ctx,
zdwm_layout_result_t *out);
typedef bool (*zdwm_layout_fn)(
const zdwm_layout_ctx_t *ctx,
zdwm_layout_result_t *out
);
static inline void zdwm_layout_result_reset(zdwm_layout_result_t *result) {
if (!result) abort();
result->item_count = 0;
}
static inline void zdwm_layout_result_push(zdwm_layout_result_t *result,
zdwm_layout_item_t item) {
static inline void
zdwm_layout_result_push(zdwm_layout_result_t *result, zdwm_layout_item_t item) {
if (!result) abort();
if (result->item_count == result->item_capacity) {
@@ -47,7 +49,8 @@ static inline void zdwm_layout_result_push(zdwm_layout_result_t *result,
zdwm_layout_item_t *items =
realloc(result->items, capacity * sizeof(*result->items));
if (!items) abort();
result->items = items;
result->items = items;
result->item_capacity = capacity;
}

View File

@@ -11,11 +11,9 @@ typedef uint32_t zdwm_layout_id_t;
typedef uint32_t zdwm_window_id_t;
typedef uint32_t zdwm_workspace_id_t;
/* clang-format off */
#define ZDWM_LAYOUT_ID_INVALID ((zdwm_layout_id_t)UINT32_MAX)
#define ZDWM_WINDOW_ID_INVALID ((zdwm_window_id_t)0)
#define ZDWM_WORKSPACE_ID_INVALID ((zdwm_workspace_id_t)UINT32_MAX)
/* clang-format on */
#define ZDWM_LAYOUT_ID_INVALID ((zdwm_layout_id_t)UINT32_MAX)
#define ZDWM_WINDOW_ID_INVALID ((zdwm_window_id_t)0)
#define ZDWM_WORKSPACE_ID_INVALID ((zdwm_workspace_id_t)UINT32_MAX)
typedef struct zdwm_rect_t {
int32_t x;