core: 定义核心事件数据模型并更新其文档

This commit is contained in:
2026-03-21 02:51:43 +08:00
parent 4c96f2a1db
commit 931dc3d8d5
22 changed files with 1204 additions and 220 deletions

View File

@@ -10,8 +10,8 @@
#include <xcb/xproto.h>
#include "core/backend.h"
#include "core/wm_desc.h"
#include "utils.h"
#include "wm_desc.h"
struct wm_backend_t {
xcb_connection_t *conn;

View File

@@ -2,7 +2,7 @@
#include <stddef.h>
#include "wm_desc.h"
#include "core/wm_desc.h"
typedef struct wm_backend_t wm_backend_t;

View File

@@ -1,7 +1,8 @@
#pragma once
#include <stdint.h>
#include "core/types.h"
#include "core/wm_desc.h"
typedef enum wm_event_type_t {
WM_EVENT_KEY_PRESS,
@@ -9,9 +10,11 @@ typedef enum wm_event_type_t {
WM_EVENT_POINTER_BUTTON_RELEASE,
WM_EVENT_POINTER_MOTION,
WM_EVENT_WINDOW_MAP_REQUEST,
WM_EVENT_WINDOW_UNMAP,
WM_EVENT_WINDOW_DESTROY,
WM_EVENT_WINDOW_REMOVE,
WM_EVENT_WINDOW_METADATA_CHANGED,
WM_EVENT_WINDOW_HINTS_CHANGED,
WM_EVENT_WINDOW_ACTIVATE_REQUEST,
WM_EVENT_WINDOW_STATE_REQUEST,
WM_EVENT_CONFIGURE_REQUEST,
} wm_event_type_t;
@@ -51,6 +54,99 @@ typedef struct wm_pointer_motion_event_t {
wm_point_t local;
} wm_pointer_motion_event_t;
typedef struct wm_window_map_request_event_t {
wm_window_info_t info;
wm_window_id_t transient_for;
bool is_dialog;
} wm_window_map_request_event_t;
typedef enum wm_window_remove_reason_t {
WM_WINDOW_REMOVE_WITHDRAWN,
WM_WINDOW_REMOVE_DESTROY,
} wm_window_remove_reason_t;
typedef struct wm_window_remove_event_t {
wm_window_id_t window;
wm_window_remove_reason_t reason;
} wm_window_remove_event_t;
typedef enum wm_window_metadata_change_flags_t {
WM_WINDOW_METADATA_CHANGE_TITLE = 1u << 0,
WM_WINDOW_METADATA_CHANGE_APP_ID = 1u << 1,
WM_WINDOW_METADATA_CHANGE_CLASS = 1u << 2,
WM_WINDOW_METADATA_CHANGE_INSTANCE = 1u << 3,
} wm_window_metadata_change_flags_t;
typedef struct wm_window_metadata_change_event_t {
wm_window_id_t window;
uint32_t changed_fields;
const char *title;
const char *app_id;
const char *class_name;
const char *instance_name;
} wm_window_metadata_change_event_t;
typedef enum wm_window_hint_changed_flags_t {
WM_WINDOW_HINT_CHANGED_NONE = 0,
WM_WINDOW_HINT_CHANGED_URGENT = 1u << 0,
WM_WINDOW_HINT_CHANGED_FIXED_SIZE = 1u << 1,
WM_WINDOW_HINT_CHANGED_SKIP_TASKBAR = 1u << 2,
} wm_window_hint_changed_flags_t;
typedef struct wm_window_hints_changed_event_t {
wm_window_id_t window;
uint32_t changed_fields;
bool urgent;
bool fixed_size;
bool skip_taskbar;
} wm_window_hints_changed_event_t;
typedef enum wm_window_activation_source_t {
WM_WINDOW_ACTIVATION_SOURCE_LEGACY = 0,
WM_WINDOW_ACTIVATION_SOURCE_APPLICATION = 1,
WM_WINDOW_ACTIVATION_SOURCE_PAGER = 2,
} wm_window_activation_source_t;
typedef struct wm_window_activate_request_event_t {
wm_window_id_t window;
wm_window_activation_source_t source;
} wm_window_activate_request_event_t;
typedef enum wm_window_state_request_kind_t {
WM_WINDOW_STATE_REQUEST_FULLSCREEN,
WM_WINDOW_STATE_REQUEST_MAXIMIZED,
WM_WINDOW_STATE_REQUEST_MINIMIZED,
} wm_window_state_request_kind_t;
typedef enum wm_window_state_request_action_t {
WM_WINDOW_STATE_REQUEST_ACTION_ADD,
WM_WINDOW_STATE_REQUEST_ACTION_REMOVE,
WM_WINDOW_STATE_REQUEST_ACTION_TOGGLE,
} wm_window_state_request_action_t;
typedef struct wm_window_state_request_event_t {
wm_window_id_t window;
wm_window_state_request_kind_t kind;
wm_window_state_request_action_t action;
} wm_window_state_request_event_t;
typedef enum wm_configure_request_field_t {
WM_CONFIGURE_REQUEST_FIELD_NONE = 0,
WM_CONFIGURE_REQUEST_FIELD_X = 1u << 0,
WM_CONFIGURE_REQUEST_FIELD_Y = 1u << 1,
WM_CONFIGURE_REQUEST_FIELD_WIDTH = 1u << 2,
WM_CONFIGURE_REQUEST_FIELD_HEIGHT = 1u << 3,
} wm_configure_request_field_t;
typedef struct wm_configure_request_event_t {
wm_window_id_t window;
uint32_t changed_fields;
int32_t x;
int32_t y;
int32_t width;
int32_t height;
} wm_configure_request_event_t;
typedef struct wm_event_t {
wm_event_type_t type;
uint32_t time_ms;
@@ -59,5 +155,12 @@ typedef struct wm_event_t {
wm_pointer_button_event_t pointer_button_press;
wm_pointer_button_event_t pointer_button_release;
wm_pointer_motion_event_t pointer_motion;
wm_window_map_request_event_t window_map_request;
wm_window_remove_event_t window_remove;
wm_window_metadata_change_event_t window_metadata_change;
wm_window_hints_changed_event_t window_hints_changed;
wm_window_activate_request_event_t window_activate_request;
wm_window_state_request_event_t window_state_request;
wm_configure_request_event_t configure_request;
} data;
} wm_event_t;

View File

@@ -5,8 +5,8 @@
#include "core/backend.h"
#include "core/state.h"
#include "core/types.h"
#include "core/wm_desc.h"
#include "utils.h"
#include "wm_desc.h"
bool wm_runtime_init(wm_runtime_t *runtime) {
p_clear(runtime, 1);

View File

@@ -4,8 +4,8 @@
#include <string.h>
#include "core/types.h"
#include "core/wm_desc.h"
#include "utils.h"
#include "wm_desc.h"
void wm_state_init(wm_state_t *state, const wm_output_info_t *outputs,
size_t output_count, const wm_workspace_desc_t *workspaces,

View File

@@ -3,7 +3,7 @@
#include <stddef.h>
#include "core/types.h"
#include "wm_desc.h"
#include "core/wm_desc.h"
/* 核心实体定义 */
typedef struct wm_window_t {
@@ -75,7 +75,8 @@ typedef struct wm_state_t {
* - wm_state_init() / wm_state_cleanup() 必须成对调用
* - 同一个 state 生命周期内wm_state_init() 不允许重复调用
* - 除 wm_state_init() 外,其余 state 相关接口都要求 state 已初始化
* - workspaces[i] 必须满足 wm_workspace_desc_valid(&workspaces[i], output_count)
* - workspaces[i] 必须满足 wm_workspace_desc_valid(&workspaces[i],
* output_count)
* - 传入空指针、未初始化对象或违反前置条件属于调用方错误
*
* 初始化时根据描述表构建 outputs[] 与 workspaces[]。
@@ -84,8 +85,7 @@ typedef struct wm_state_t {
* workspace若某个 output 没有任何归属 workspacewm_state_init() 会失败。
*/
void wm_state_init(wm_state_t *state, const wm_output_info_t *outputs,
size_t output_count,
const wm_workspace_desc_t *workspaces,
size_t output_count, const wm_workspace_desc_t *workspaces,
size_t workspace_count);
void wm_state_cleanup(wm_state_t *state);