事件适配器
This commit is contained in:
105
src/include/event-adapter.h
Normal file
105
src/include/event-adapter.h
Normal file
@@ -0,0 +1,105 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum event_type_t {
|
||||
EVENT_TYPE_MAPPING_NOTIFY,
|
||||
EVENT_TYPE_KEY_PRESS,
|
||||
EVENT_TYPE_BUTTON_PRESS,
|
||||
EVENT_TYPE_CONFIGURE_REQUEST,
|
||||
EVENT_TYPE_CONFIGURE_NOTIFY,
|
||||
EVENT_TYPE_MAP_REQUEST,
|
||||
EVENT_TYPE_UNMAP_NOTIFY,
|
||||
EVENT_TYPE_DESTROY_NOTIFY,
|
||||
EVENT_TYPE_EXPOSE,
|
||||
EVENT_TYPE_MOTION_NOTIFY,
|
||||
EVENT_TYPE_ENTER_NOTIFY,
|
||||
EVENT_TYPE_FOCUS_IN,
|
||||
EVENT_TYPE_PROPERTY_NOTIFY,
|
||||
EVENT_TYPE_CLIENT_MESSAGE,
|
||||
} event_type_t;
|
||||
|
||||
typedef struct mapping_notify_event_t {
|
||||
event_type_t type;
|
||||
} mapping_notify_event_t;
|
||||
|
||||
typedef struct key_press_event_t {
|
||||
event_type_t type;
|
||||
uint32_t key_symbols;
|
||||
uint32_t modifiers;
|
||||
} key_press_event_t;
|
||||
|
||||
typedef struct button_press_event_t {
|
||||
event_type_t type;
|
||||
} button_press_event_t;
|
||||
|
||||
typedef struct configure_request_event_t {
|
||||
event_type_t type;
|
||||
} configure_request_event_t;
|
||||
|
||||
typedef struct configure_notify_event_t {
|
||||
event_type_t type;
|
||||
} configure_notify_event_t;
|
||||
|
||||
typedef struct map_request_event_t {
|
||||
event_type_t type;
|
||||
} map_request_event_t;
|
||||
|
||||
typedef struct unmap_notify_event_t {
|
||||
event_type_t type;
|
||||
} unmap_notify_event_t;
|
||||
|
||||
typedef struct destroy_notify_event_t {
|
||||
event_type_t type;
|
||||
} destroy_notify_event_t;
|
||||
|
||||
typedef struct expose_event_t {
|
||||
event_type_t type;
|
||||
} expose_event_t;
|
||||
|
||||
typedef struct motion_notify_event_t {
|
||||
event_type_t type;
|
||||
} motion_notify_event_t;
|
||||
|
||||
typedef struct enter_notify_event_t {
|
||||
event_type_t type;
|
||||
} enter_notify_event_t;
|
||||
|
||||
typedef struct focus_in_event_t {
|
||||
event_type_t type;
|
||||
} focus_in_event_t;
|
||||
|
||||
typedef struct property_notify_event_t {
|
||||
event_type_t type;
|
||||
} property_notify_event_t;
|
||||
|
||||
typedef struct client_message_event_t {
|
||||
event_type_t type;
|
||||
} client_message_event_t;
|
||||
|
||||
typedef union generic_event_t {
|
||||
event_type_t type;
|
||||
mapping_notify_event_t mapping_notify;
|
||||
key_press_event_t key_press;
|
||||
button_press_event_t button_press;
|
||||
configure_request_event_t configure_request;
|
||||
configure_notify_event_t configure_notify;
|
||||
map_request_event_t map_request;
|
||||
unmap_notify_event_t unmap_notify;
|
||||
destroy_notify_event_t destroy_notify;
|
||||
expose_event_t expose;
|
||||
motion_notify_event_t motiion_notify;
|
||||
enter_notify_event_t enter_notify;
|
||||
focus_in_event_t focus_in;
|
||||
property_notify_event_t property_notify;
|
||||
client_message_event_t client_message;
|
||||
} generic_event_t;
|
||||
|
||||
typedef void (*event_handler)(generic_event_t *event, void *user_data);
|
||||
|
||||
typedef struct event_adapter_t event_adapter_t;
|
||||
event_adapter_t *create_event_adapter(void);
|
||||
void destroy_event_adapter(event_adapter_t *adapter);
|
||||
void event_adapter_set_handler(event_adapter_t *adapter, event_handler handler,
|
||||
void *user_data);
|
||||
void event_adapter_poll(event_adapter_t *adapter);
|
||||
@@ -54,7 +54,6 @@ typedef struct window_list_t {
|
||||
} window_list_t;
|
||||
window_list_t *scan_window_list(void);
|
||||
void free_window_list(window_list_t *window_list);
|
||||
void start_xcb_event_loop(void);
|
||||
void clean_xcb(void);
|
||||
|
||||
bool get_xresource_uint32(const char *name, uint32_t *value);
|
||||
|
||||
Reference in New Issue
Block a user