refactor(core/plan): 使用 need_relayout 简化 dirty_flags
This commit is contained in:
@@ -5,14 +5,6 @@
|
|||||||
|
|
||||||
#include "core/types.h"
|
#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 {
|
typedef enum effect_type_t {
|
||||||
ZDWM_EFFECT_MAP_WINDOW = 1,
|
ZDWM_EFFECT_MAP_WINDOW = 1,
|
||||||
ZDWM_EFFECT_UNMAP_WINDOW,
|
ZDWM_EFFECT_UNMAP_WINDOW,
|
||||||
@@ -74,7 +66,7 @@ typedef struct plan_t {
|
|||||||
effect_t *effects;
|
effect_t *effects;
|
||||||
size_t count;
|
size_t count;
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
dirty_mask_t dirty_flags;
|
bool need_relayout;
|
||||||
} plan_t;
|
} plan_t;
|
||||||
|
|
||||||
void plan_reset(plan_t *plan);
|
void plan_reset(plan_t *plan);
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ static bool manage_window(
|
|||||||
plan_push_effect(plan, &map_effect);
|
plan_push_effect(plan, &map_effect);
|
||||||
|
|
||||||
if (window_need_layout(window)) {
|
if (window_need_layout(window)) {
|
||||||
plan->dirty_flags |= ZDWM_DIRTY_LAYOUT;
|
plan->need_relayout = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -146,11 +146,11 @@ static bool switch_workspace(
|
|||||||
auto workspace_id = command->workspace;
|
auto workspace_id = command->workspace;
|
||||||
|
|
||||||
if (state_output_set_current_workspace(state, output_id, workspace_id)) {
|
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)) {
|
if (state_set_current_output(state, output_id)) {
|
||||||
plan->dirty_flags |= ZDWM_DIRTY_OUTPUT;
|
plan->need_relayout = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: 后续考虑加上 ewmh 相关副作用 */
|
/* TODO: 后续考虑加上 ewmh 相关副作用 */
|
||||||
|
|||||||
Reference in New Issue
Block a user