From 989a1ce6e801c0f7bd72bd785e71088d97889e97 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Sun, 24 May 2026 17:58:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(listeners):=20=E8=B0=83=E6=95=B4=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=BB=93=E6=9E=84=E4=BD=93=E5=AD=97=E6=AE=B5=E5=B9=B6?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=96=87=E6=A1=A3=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/zdwm/listeners.h | 5 +++-- src/core/listeners.c | 8 +++++--- src/core/listeners.h | 44 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/include/zdwm/listeners.h b/include/zdwm/listeners.h index 42ae4bf..e12c8a8 100644 --- a/include/zdwm/listeners.h +++ b/include/zdwm/listeners.h @@ -30,13 +30,14 @@ typedef void zdwm_workspace_active_updated( typedef struct zdwm_layout_notify_t { zdwm_workspace_id_t workspace; zdwm_layout_id_t id; - const char *symbol; /* 不持有内存 */ + const char *name; /* 不持有内存 */ + const char *symbol; /* 不持有内存 */ + const char *description; /* 不持有内存 */ } zdwm_layout_notify_t; typedef void zdwm_layout_notify(zdwm_layout_notify_t layout, void *user_data); typedef struct zdwm_binding_mode_notify_t { bool is_default_mode; - bool is_current_mode; zdwm_binding_mode_id_t id; const char *name; /* 不持有内存 */ } zdwm_binding_mode_notify_t; diff --git a/src/core/listeners.c b/src/core/listeners.c index e8b39f3..5dca003 100644 --- a/src/core/listeners.c +++ b/src/core/listeners.c @@ -173,9 +173,11 @@ void listeners_notify_layout( if (!slot) return; zdwm_layout_notify_t notify = { - .workspace = workspace_id, - .id = layout_id, - .symbol = slot->symbol, + .workspace = workspace_id, + .id = layout_id, + .name = slot->name, + .symbol = slot->symbol, + .description = slot->description, }; FOR_EACH_LISTENER(layout_listeners, item->fn(notify, item->user_data)); diff --git a/src/core/listeners.h b/src/core/listeners.h index 140fa83..d26e1fd 100644 --- a/src/core/listeners.h +++ b/src/core/listeners.h @@ -95,43 +95,87 @@ void listeners_add_window_removed_listener( ); void listeners_cleanup(listeners_t *listeners); + +/** + * @brief 通知当前 output 信息 + * + * @param listeners 通知函数集合 + * @param output_id 当前 output id + */ void listeners_notify_current_output( const listeners_t *listeners, output_id_t output_id ); + +/** + * @brief 通知初始化 workspace 列表 + */ void listeners_notify_initial_workspaces( const listeners_t *listeners, const state_t *state ); + +/** + * @brief 通知当前激活的 workspace 信息 + */ void listeners_notify_workspace_active( const listeners_t *listeners, output_id_t output_id, workspace_id_t workspace_id ); + +/** + * @brief 通知当前布局信息 + * + * @param listeners 通知函数集合 + * @param layouts 布局注册系统 + * @param workspace_id 当前 workspace id + * @param layout_id 当前 workspace 的当前布局 id + */ void listeners_notify_layout( const listeners_t *listeners, const layout_registry_t *layouts, workspace_id_t workspace_id, layout_id_t layout_id ); + +/** + * @brief 通知当前绑定模式信息 + */ void listeners_notify_binding_mode( const listeners_t *listeners, const binding_table_t *binding_table ); + +/** + * @brief 通知初始窗口列表 + */ void listeners_notify_initial_windows( const listeners_t *listeners, const state_t *state ); + +/** + * @brief 通知新增窗口 + */ void listeners_notify_window_added( const listeners_t *listeners, const state_t *state, window_id_t window_id ); + +/** + * @brief 通知窗口信息更新 + */ void listeners_notify_window_updated( const listeners_t *listeners, const state_t *state, window_id_t window_id ); + +/** + * @brief 通知移除窗口 + */ void listeners_notify_window_removed( const listeners_t *listeners, window_id_t window_id