窗口 metadata 添加 role 字段

This commit is contained in:
zedhugh committed 2026-04-07 05:33:33 +08:00
1 parent 9728fad871
commit 5353e4c677
6 files changed
+30 -8

No files matched your search

+3 -2
View File
@@ -82,8 +82,9 @@ typedef struct window_remove_event_t {
typedef enum window_metadata_change_flags_t {
ZDWM_WINDOW_METADATA_CHANGE_TITLE = 1u << 0,
ZDWM_WINDOW_METADATA_CHANGE_APP_ID = 1u << 1,
ZDWM_WINDOW_METADATA_CHANGE_CLASS = 1u << 2,
ZDWM_WINDOW_METADATA_CHANGE_INSTANCE = 1u << 3,
ZDWM_WINDOW_METADATA_CHANGE_ROLE = 1u << 2,
ZDWM_WINDOW_METADATA_CHANGE_CLASS = 1u << 3,
ZDWM_WINDOW_METADATA_CHANGE_INSTANCE = 1u << 4,
} window_metadata_change_flags_t;
typedef struct window_metadata_change_event_t {
+16
View File
@@ -66,6 +66,7 @@ void state_cleanup(state_t *state) {
window_t *window = &state->windows[i];
p_delete(&window->title);
p_delete(&window->app_id);
p_delete(&window->role);
p_delete(&window->class_name);
p_delete(&window->instance_name);
}
@@ -286,6 +287,7 @@ const window_t *state_window_add(state_t *state, const window_info_t *info) {
state_window_set_frame_rect(state, id, info->frame_rect);
state_window_set_title(state, id, info->title);
state_window_set_app_id(state, id, info->app_id);
state_window_set_role(state, id, info->role);
state_window_set_class(state, id, info->class_name);
state_window_set_instance(state, id, info->instance_name);
state_window_set_skip_taskbar(state, id, info->skip_taskbar);
@@ -324,6 +326,7 @@ void state_window_remove(state_t *state, window_id_t id) {
workspace_id_t workspace_id = window->workspace_id;
p_delete(&window->title);
p_delete(&window->app_id);
p_delete(&window->role);
p_delete(&window->class_name);
p_delete(&window->instance_name);
@@ -453,6 +456,18 @@ bool state_window_set_app_id(state_t *state, window_id_t window_id,
return true;
}
bool state_window_set_role(state_t *state, window_id_t window_id,
const char *role) {
window_t *window = (window_t *)state_window_get(state, window_id);
if (!window) return false;
p_delete(&window->role);
window->role = p_strdup_nullable(role);
return true;
}
bool state_window_set_class(state_t *state, window_id_t window_id,
const char *class_name) {
window_t *window = (window_t *)state_window_get(state, window_id);
@@ -463,6 +478,7 @@ bool state_window_set_class(state_t *state, window_id_t window_id,
return true;
}
bool state_window_set_instance(state_t *state, window_id_t window_id,
const char *instance_name) {
window_t *window = (window_t *)state_window_get(state, window_id);
+7 -4
View File
@@ -24,10 +24,11 @@ typedef struct window_t {
rect_t frame_rect; /* 当前外框矩形(由 layout 或 float_rect 解析) */
/* 元数据(核心算法不依赖,仅用于规则匹配和信息展示) */
const char *title;
const char *app_id;
const char *class_name;
const char *instance_name;
char *title;
char *app_id;
char *role;
char *class_name;
char *instance_name;
bool skip_taskbar;
} window_t;
@@ -170,6 +171,8 @@ bool state_window_set_title(state_t *state, window_id_t window_id,
const char *title);
bool state_window_set_app_id(state_t *state, window_id_t window_id,
const char *app_id);
bool state_window_set_role(state_t *state, window_id_t window_id,
const char *role);
bool state_window_set_class(state_t *state, window_id_t window_id,
const char *class_name);
bool state_window_set_instance(state_t *state, window_id_t window_id,
+2 -1
View File
@@ -46,7 +46,8 @@ typedef struct window_props_t {
typedef struct window_metadata_t {
char *title;
char *app_id; /* X11 中将其当 role 用 */
char *app_id;
char *role;
char *class_name;
char *instance_name;
} window_metadata_t;
+1
View File
@@ -17,6 +17,7 @@ typedef struct window_info_t {
const char *title;
const char *app_id;
const char *role;
const char *class_name;
const char *instance_name;