1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#ifndef COMET_EVENT_H
#define COMET_EVENT_H
#include "window.h"
#include "layout.h"
typedef struct layout layout_t;
typedef enum {
EVENT_TRIGGER,
EVENT_LEFT_CLICK,
EVENT_MIDDLE_CLICK,
EVENT_RIGHT_CLICK,
EVENT_SCROLL_UP,
EVENT_SCROLL_DOWN,
EVENT_HOVER_START,
EVENT_HOVER_MOVE,
EVENT_HOVER_STOP,
EVENT_MAX,
} event_type_t;
typedef struct {
event_type_t type;
union {
struct {
const char *origin;
const char *payload;
} trigger;
struct {
int x;
int y;
} mouse;
};
} event_t;
typedef struct {
layout_t hovered;
int hover_x, hover_y;
layout_t *layout;
config_t *config;
} event_state_t;
const char *event_type_to_string(event_type_t type);
void event_init_trigger(event_t *event, const char *origin, const char *payload);
void event_init_mouse(event_t *event, event_type_t type, int x, int y);
bool event_is_trigger(event_t event);
bool event_is_mouse(event_t event);
bool event_is_click(event_t event);
bool event_is_scroll(event_t event);
bool event_is_hover(event_t event);
void event_dispatch(event_state_t *state, window_t *window);
#endif
|