事件循环框架

This commit is contained in:
2026-04-01 16:08:01 +08:00
parent 90a25fb120
commit 196dab9bb3
11 changed files with 119 additions and 9 deletions

View File

@@ -2,6 +2,7 @@
#include <stddef.h>
#include "core/event.h"
#include "core/types.h"
typedef struct backend_t backend_t;
@@ -16,3 +17,5 @@ void backend_destroy(backend_t *backend);
backend_detect_t *backend_detect(backend_t *backend);
void backend_detect_destroy(backend_detect_t *detect);
bool backend_next_event(backend_t *backend, event_t *event);

View File

@@ -63,9 +63,10 @@ typedef struct pointer_enter_event_t {
} pointer_enter_event_t;
typedef struct window_map_request_event_t {
window_id_t id;
window_id_t window;
window_props_t props;
window_metadata_t metadata;
window_geometry_mode_t geometry;
} window_map_request_event_t;
typedef enum window_remove_reason_t {
@@ -154,7 +155,6 @@ typedef struct configure_request_event_t {
typedef struct event_t {
event_type_t type;
uint32_t time_ms;
union {
key_press_event_t key_press;
pointer_button_event_t pointer_button_press;

View File

@@ -4,6 +4,7 @@
#include "base/memory.h"
#include "core/backend.h"
#include "core/event.h"
#include "core/state.h"
#include "core/wm_desc.h"
@@ -90,3 +91,12 @@ void runtime_shutdown(runtime_t *runtime) {
if (runtime->config_module_handle) dlclose(runtime->config_module_handle);
runtime->config_module_handle = nullptr;
}
void runtime_run(runtime_t *runtime) {
for (;;) {
event_t event = {0};
if (!backend_next_event(runtime->backend, &event)) {
break;
}
}
}

View File

@@ -30,3 +30,4 @@ typedef struct runtime_t {
bool runtime_init(runtime_t *runtime, runtime_init_desc_t *desc);
void runtime_init_desc_cleanup(runtime_init_desc_t *desc);
void runtime_shutdown(runtime_t *runtime);
void runtime_run(runtime_t *runtime);

View File

@@ -34,6 +34,8 @@ typedef struct window_props_t {
window_id_t transient_for;
bool override_redirect;
bool skip_taskbar;
bool urgent;
window_type_t *types;
size_t type_count;
@@ -48,3 +50,9 @@ typedef struct window_metadata_t {
const char *class_name;
const char *instance_name;
} window_metadata_t;
typedef struct window_geometry_t {
window_geometry_mode_t mode;
rect_t rect;
bool fixed_size;
} window_geometry_t;