refactor(core/plan): 使用 need_relayout 简化 dirty_flags

This commit is contained in:
2026-04-22 19:09:21 +08:00
parent 3121b49d1b
commit 413e68f572
2 changed files with 4 additions and 12 deletions

View File

@@ -5,14 +5,6 @@
#include "core/types.h"
typedef uint32_t dirty_mask_t;
typedef enum dirty_flags_t : dirty_mask_t {
ZDWM_DIRTY_NONE = 0,
ZDWM_DIRTY_LAYOUT = 1u << 0, /* 需要重新计算布局 */
ZDWM_DIRTY_OUTPUT = 1u << 1, /* 当前 output 有变更 */
} dirty_flags_t;
typedef enum effect_type_t {
ZDWM_EFFECT_MAP_WINDOW = 1,
ZDWM_EFFECT_UNMAP_WINDOW,
@@ -74,7 +66,7 @@ typedef struct plan_t {
effect_t *effects;
size_t count;
size_t capacity;
dirty_mask_t dirty_flags;
bool need_relayout;
} plan_t;
void plan_reset(plan_t *plan);

View File

@@ -131,7 +131,7 @@ static bool manage_window(
plan_push_effect(plan, &map_effect);
if (window_need_layout(window)) {
plan->dirty_flags |= ZDWM_DIRTY_LAYOUT;
plan->need_relayout = true;
}
return true;
@@ -146,11 +146,11 @@ static bool switch_workspace(
auto workspace_id = command->workspace;
if (state_output_set_current_workspace(state, output_id, workspace_id)) {
plan->dirty_flags |= ZDWM_DIRTY_LAYOUT;
plan->need_relayout = true;
}
if (state_set_current_output(state, output_id)) {
plan->dirty_flags |= ZDWM_DIRTY_OUTPUT;
plan->need_relayout = true;
}
/* TODO: 后续考虑加上 ewmh 相关副作用 */