refactor(policy): 删除 action 模块,将 action -> command 解析放在 policy 模块内部

- 删除 src/core/action.c|h,将 spawn 移至 src/base/process
- policy_resolve_action 实现完整的 action 分发逻辑
- binding_table_cycle_mode 改为纯计算,返回模式 ID 而非修改状态
- 从 state 移除 state_workspace_cycle_layout / state_cycle_current_output
- 新增 ZDWM_COMMAND_QUIT 命令,通过 plan 标志驱动 runtime 退出
- set_binding_mode 现在生成 BIND_KEY effect 以同步后端按键绑定
- 扩展 action 数据类型支持 window_send_to_workspace 和 window_cycle_output
This commit is contained in:
2026-05-27 01:12:04 +08:00
parent ff3b51fd1d
commit 09d5e4b4d0
14 changed files with 497 additions and 368 deletions

View File

@@ -145,39 +145,6 @@ static void state_workspace_adjust_focused_window(
workspace->focused_window_id = ZDWM_WINDOW_ID_INVALID;
}
bool state_workspace_cycle_layout(
state_t *state,
workspace_id_t workspace_id,
int32_t delta
) {
workspace_t *workspace =
(workspace_t *)state_workspace_get(state, workspace_id);
if (!workspace) return false;
int32_t index = 0;
bool matched = false;
auto layout_count = (int32_t)workspace->layout_count;
for (int32_t i = 0; i < layout_count; i++) {
if (workspace->layout_id == workspace->available_layouts[i]) {
index = i;
matched = true;
break;
}
}
if (!matched) return false;
auto new_index = index + delta;
new_index %= layout_count;
if (new_index < 0) new_index += layout_count;
if (new_index == index) return false;
auto next_layout_id = workspace->available_layouts[new_index];
workspace->layout_id = next_layout_id;
return true;
}
bool state_workspace_set_layout_by_index(
state_t *state,
workspace_id_t workspace_id,
@@ -309,14 +276,6 @@ bool state_output_valid(const state_t *state, output_id_t id) {
#endif
}
void state_cycle_current_output(state_t *state, int delta) {
int64_t count = (int64_t)state->output_count;
int64_t current = (int64_t)state->current_output_index;
int64_t next = (current + (int64_t)delta) % count;
if (next < 0) next += count;
state->current_output_index = (size_t)next;
}
bool state_set_current_output(state_t *state, output_id_t output_id) {
for (size_t i = 0; i < state->output_count; ++i) {
auto output = &state->outputs[i];