Files
zswm/src/include/event-adapter.h
2025-08-22 15:47:58 +08:00

117 lines
2.9 KiB
C

#pragma once
#include <stdint.h>
#include "types.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_symbol;
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;
xcb_window_t window;
xcb_window_t parent;
xcb_window_t sibling;
int32_t x, y;
uint32_t width, height, border_width;
uint32_t value_mask;
uint8_t stack_mode;
} 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;
xcb_window_t window;
xcb_window_t parent;
} 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);