aboutsummaryrefslogtreecommitdiff
path: root/libs/libgui/msg.h
blob: b29d0c8ce0f67e6639a61ac50c391e2fbc7419f3 (plain) (blame)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// MIT License, Copyright (c) 2021 Marvin Borner

#ifndef MSG_H
#define MSG_H

#include <def.h>
#include <libgui/gfx.h>
#include <sys.h>

#define MSG_PING_SEND 0x07734
#define MSG_PING_RECV 0x7474

#define MSG_MAGIC 0x42042069
#define MSG_SUCCESS (1 << 29)
#define MSG_FAILURE (1 << 30)

enum message_state {
	MSG_GO_ON,
	MSG_NEED_ANSWER,
};

struct message_header {
	struct bus_header bus;
	u32 magic;
	u32 type;
	enum message_state state;
};

struct message_ping {
	struct message_header header;
	u32 ping;
};

struct message_new_window {
	struct message_header header;
	u32 id;
	u32 shid;
	vec2 off;
	vec2 size;
	vec2 pos;
	struct context ctx;
};

struct message_redraw_window {
	struct message_header header;
	u32 id;
};

struct message_destroy_window {
	struct message_header header;
	u32 id;
};

struct message_mouse {
	struct message_header header;
	u32 id;
	vec2 pos;
	struct {
		u8 click : 1;
	} bits;
};

enum message_type {
	GUI_PING,
	GUI_NEW_WINDOW,
	GUI_REDRAW_WINDOW,
	GUI_DESTROY_WINDOW,

	GUI_MOUSE,
	GUI_KEYBOARD,
};

res msg_connect_bus(const char *bus, u32 *conn);
res msg_connect_conn(u32 conn);
res msg_send(enum message_type type, void *data, u32 size) NONNULL;
res msg_receive(void *buf, u32 size) NONNULL;

#endif