Files
zswm/src/include/event-adapter.h

179 lines
4.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <stdbool.h>
#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 enum notify_mode_t {
notify_mode_normal = 0,
notify_mode_grab = 1,
notify_mode_ungrab = 2,
notify_mode_while_grabbed = 3
} notify_mode_t;
typedef enum notify_detail_t {
notify_detail_ancestor = 0,
notify_detail_virtual = 1,
notify_detail_inferior = 2,
notify_detail_nonlinear = 3,
notify_detail_nonlinear_virtual = 4,
notify_detail_pointer = 5,
notify_detail_pointer_root = 6,
notify_detail_none = 7,
} notify_detail_t;
typedef enum mapping_t {
MAPPING_MODIFIER = 0,
MAPPING_KEYBOARD = 1,
MAPPING_POINTER = 2
} mapping_t;
typedef struct mapping_notify_event_t {
event_type_t type;
mapping_t request;
} 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;
xcb_window_t window;
xcb_window_t root;
int32_t x, y, root_x, root_y;
uint32_t time; /* 时间戳单位ms */
} 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;
xcb_window_t window;
bool send_event;
} unmap_notify_event_t;
typedef struct destroy_notify_event_t {
event_type_t type;
xcb_window_t window;
} destroy_notify_event_t;
typedef struct expose_event_t {
event_type_t type;
xcb_window_t window;
uint32_t count;
} expose_event_t;
typedef struct motion_notify_event_t {
event_type_t type;
xcb_window_t root;
int32_t root_x;
int32_t root_y;
xcb_window_t window;
int32_t x;
int32_t y;
uint32_t time; /* 时间戳单位ms */
} motion_notify_event_t;
typedef struct enter_notify_event_t {
event_type_t type;
xcb_window_t window;
notify_mode_t mode;
notify_detail_t detail;
} enter_notify_event_t;
typedef struct focus_in_event_t {
event_type_t type;
xcb_window_t window;
} focus_in_event_t;
typedef enum property_state_t {
property_new_value = 0,
property_delete = 1
} property_state_t;
typedef struct property_notify_event_t {
event_type_t type;
xcb_window_t window;
uint32_t xcb_atom;
property_state_t state;
} property_notify_event_t;
typedef union client_message_data_t {
uint8_t data8[20];
uint16_t data16[10];
uint32_t data32[5];
} client_message_data_t;
typedef struct client_message_event_t {
event_type_t type;
xcb_window_t window;
uint32_t message_type;
client_message_data_t data;
uint8_t format;
} 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);