core: 添加窗口规则 (rules) 数据结构和配置接口
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <zdwm/layout.h>
|
||||
#include <zdwm/rules.h>
|
||||
#include <zdwm/types.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
@@ -54,6 +55,19 @@ typedef struct zdwm_api_t {
|
||||
const zdwm_layout_id_t *layout_ids,
|
||||
size_t layout_count,
|
||||
zdwm_layout_id_t initial_layout_id);
|
||||
|
||||
/**
|
||||
* 用户调用这个函数添加窗口规则
|
||||
* @param builder 配置构建上下文
|
||||
* @param match 窗口匹配条件,不能为 nullptr
|
||||
* @param action 匹配后执行的动作,不能为 nullptr
|
||||
* @returns 添加成功返回 true ,不合法时返回 false
|
||||
* @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);
|
||||
} zdwm_api_t;
|
||||
|
||||
/**
|
||||
|
||||
38
include/zdwm/rules.h
Normal file
38
include/zdwm/rules.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef ZDWM_RULES_H
|
||||
#define ZDWM_RULES_H
|
||||
|
||||
#include <zdwm/types.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief 窗口匹配条件
|
||||
* @details 仅匹配不为 nullptr 的字段,多个字段按且规则匹配
|
||||
*/
|
||||
typedef struct zdwm_rule_match_t {
|
||||
const char *app_id;
|
||||
const char *role;
|
||||
const char *class_name;
|
||||
const char *instance_name;
|
||||
} zdwm_rule_match_t;
|
||||
|
||||
typedef struct zdwm_rule_action_t {
|
||||
/**
|
||||
* 目标 workspace id
|
||||
* - 若规则不想指定 workspace ,则将其设为 ZDWM_WORKSPACE_ID_INVALID
|
||||
*/
|
||||
zdwm_workspace_id_t workspace;
|
||||
|
||||
bool switch_to_workspace; /* 自动切换到目标 workspace(仅 true 时生效) */
|
||||
bool fullscreen; /* 强制全屏(仅 true 时生效) */
|
||||
bool maximize; /* 强制最大化(仅 true 时生效) */
|
||||
bool floating; /* 强制浮动(仅 true 时生效) */
|
||||
} zdwm_rule_action_t;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZDWM_RULES_H */
|
||||
Reference in New Issue
Block a user