Files
zdwm/src/interface/event.h
Zedhugh Chen 079f41ce8a refactor: 从 core 中抽出跨模块契约建立 interface/common 模块分层
引入 interface/(零实现声明层)与 common/(共享 ADT 操作层),把跨模块
契约从 core 实现里抽出来,依赖方向回到单向(base ← interface ← common ←
各实现层)。docs/module-layering.org 记录完整方案与判定标准。

interface/(纯类型与多态接口声明,零 .c):
- types.h / event.h / backend.h 从 core 移入
- effect.h 新建(effect_t 从 plan.h 抽出)

common/(多实现层共用的自包含操作,.h + .c):
- event.{h,c}:event_reset / event_cleanup
- listeners.{h,c}:listeners 维护(add / cleanup);notify 留 core
- window.{h,c}:window_list + layer_props/metadata cleanup + window_classify_layer
- workspace.{h,c}:workspace_desc(从 wm_desc.h 拆出,改真实函数)

window 相关整理:
- window_layer_type_t 上浮 interface/types.h(common 的 classify 需要)
- window_classify_layer 移 common/window
- window_info_t 独立成 core/window_info.h(state/command 共享,不寄生)
- 删除 wm_desc.h,base/window_list 并入 common/window

全项目 include 路径同步更新
2026-06-25 03:00:30 +08:00

113 lines
2.9 KiB
C

#pragma once
#include <stdint.h>
#include "interface/types.h"
typedef enum event_type_t {
ZDWM_EVENT_NONE,
ZDWM_EVENT_KEY_PRESS,
ZDWM_EVENT_POINTER_BUTTON_PRESS,
ZDWM_EVENT_POINTER_BUTTON_RELEASE,
ZDWM_EVENT_POINTER_MOTION,
ZDWM_EVENT_POINTER_ENTER,
ZDWM_EVENT_WINDOW_MAP_REQUEST,
ZDWM_EVENT_WINDOW_REMOVE,
ZDWM_EVENT_WINDOW_METADATA_CHANGED,
ZDWM_EVENT_WINDOW_HINTS_CHANGED,
ZDWM_EVENT_WINDOW_ACTIVATE_REQUEST,
ZDWM_EVENT_WINDOW_STATE_REQUEST,
ZDWM_EVENT_CONFIGURE_REQUEST,
} event_type_t;
typedef struct key_press_event_t {
modifier_mask_t modifiers;
keysym_t keysym;
uint32_t keycode;
} key_press_event_t;
typedef struct pointer_button_event_t {
modifier_mask_t modifiers;
button_t button;
window_id_t window;
point_t root;
point_t local;
} pointer_button_event_t;
typedef struct pointer_motion_event_t {
window_id_t window;
point_t root;
point_t local;
} pointer_motion_event_t;
typedef struct window_map_request_event_t {
window_id_t window;
window_id_t transient_for;
bool override_redirect;
bool skip_taskbar;
bool urgent;
bool fullscreen;
bool maximized;
bool minimized;
rect_t rect;
zdwm_size_t min_size;
zdwm_size_t max_size;
window_layer_props_t props;
window_metadata_t metadata;
} window_map_request_event_t;
typedef enum window_remove_reason_t {
ZDWM_WINDOW_REMOVE_WITHDRAWN,
ZDWM_WINDOW_REMOVE_DESTROY,
} window_remove_reason_t;
typedef struct window_remove_event_t {
window_id_t window;
window_remove_reason_t reason;
} window_remove_event_t;
typedef struct window_metadata_change_event_t {
window_id_t window;
uint32_t changed_fields;
window_metadata_t metadata;
} window_metadata_change_event_t;
/* clang-format off */
typedef enum window_activation_source_t {
ZDWM_WINDOW_ACTIVATION_SOURCE_LEGACY = 0,
ZDWM_WINDOW_ACTIVATION_SOURCE_APPLICATION = 1,
ZDWM_WINDOW_ACTIVATION_SOURCE_PAGER = 2,
} window_activation_source_t;
/* clang-format on */
typedef struct window_activate_request_event_t {
window_id_t window;
window_activation_source_t source;
} window_activate_request_event_t;
typedef struct window_state_request_event_t {
window_id_t window;
window_state_request_type_t type;
window_state_request_action_t action;
} window_state_request_event_t;
typedef struct event_t {
event_type_t type;
union {
key_press_event_t key_press;
pointer_button_event_t pointer_button_press;
pointer_button_event_t pointer_button_release;
pointer_motion_event_t pointer_motion;
only_window_data_t pointer_enter;
window_map_request_event_t window_map_request;
window_remove_event_t window_remove;
window_metadata_change_event_t window_metadata_change;
hints_data_t hints;
window_activate_request_event_t window_activate_request;
window_state_request_event_t window_state_request;
configure_data_t configure_request;
} as;
} event_t;