The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
heimdall_proto.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file heimdall_proto.h
5 * @brief the messages between heimdalld (the window server) and its clients.
6 *
7 * a client connects to the Unix socket HEIM_SOCKET. every message, in both
8 * directions, is one heim_msg_t of 64 bytes. a message that carries an open
9 * file (a shared memory buffer) has it in an SCM_RIGHTS control message
10 * sent with it.
11 *
12 * the start: the client sends HEIM_REQ_HELLO, the server answers with
13 * HEIM_EV_WELCOME (the screen size).
14 *
15 * a window: the client picks a window number (not 0, its own), sends
16 * HEIM_REQ_CREATE, then HEIM_REQ_ATTACH with a shared memory buffer of
17 * premultiplied ARGB pixels, draws into it, and sends HEIM_REQ_COMMIT with
18 * the part it changed. the window shows after its first commit. after a
19 * commit, the server sends HEIM_EV_FRAME when the change is on the
20 * screen; a client that draws again before that can be seen half drawn.
21 *
22 * the server draws the title bar and the buttons (server-side
23 * decorations); the size of a window is the size of its content. a window
24 * is placed by the server. HEIM_EV_CONFIGURE asks the client for another
25 * size (maximize, a resize with the mouse): the client attaches a buffer
26 * of that size and commits it.
27 *
28 * a popup (a menu, a select's choices, a popover, a tooltip) is a window
29 * with HEIM_WINDOW_POPUP and a parent window. it has no decorations and
30 * its pixels can be see-through; the client draws its shadow in a margin
31 * around it. HEIM_REQ_PLACE gives a rect in the parent's content to show
32 * it next to and a side; the server puts it there, on the other side
33 * when there is no room, and inside the screen. a popup is above its
34 * parent and gets the keyboard (a tooltip, HEIM_WINDOW_TOOLTIP, gets no
35 * input at all). a press outside the open popups closes them: each gets
36 * HEIM_EV_CLOSE, and the press goes nowhere else.
37 *
38 * a panel (HEIM_WINDOW_PANEL) is a bar of the desktop shell: the server
39 * puts it at the bottom of the screen, the full width (it sends
40 * HEIM_EV_CONFIGURE for the width), above the windows. its height is not
41 * part of the work area: maximized and new windows stay above it. a click
42 * on it does not take the keyboard from the window that has it.
43 *
44 * the shell: one client can ask to be the shell (HEIM_REQ_SHELL, the
45 * first that asks). it then gets HEIM_EV_WINDOW for each normal window
46 * when the window shows or changes (title, state), HEIM_EV_WINDOW_APP
47 * with the program of the window, and HEIM_EV_WINDOW_GONE; the window
48 * field is 0 and info.id is the server's number for the window. the shell
49 * can activate, minimize and close any window (HEIM_REQ_ACT) and end the
50 * session (HEIM_REQ_QUIT).
51 */
52
53#include <stdint.h>
54
55#define HEIM_SOCKET "/run/heimdall"
56#define HEIM_PROTOCOL_VERSION 1
57#define HEIM_TITLE_MAX 40
58
59// the longest settings name (libconf: /etc/ginnos/<name>.conf), with the 0
60#define HEIM_SETTINGS_MAX 48
61#define HEIM_SIZE_MAX 8192
62#define HEIM_APP_ID_MAX 48 // the program of a window: "idunn-gallery"
63#define HEIM_CLIPBOARD_MAX (1024 * 1024)
64
65#define HEIM_REQ_HELLO 1 // hello: the protocol version
66#define HEIM_REQ_CREATE 2 // create: size, flags, title
67#define HEIM_REQ_ATTACH 3 // attach, with the buffer's fd: size, stride
68#define HEIM_REQ_COMMIT 4 // rect: the part that changed
69#define HEIM_REQ_TITLE 5 // title
70#define HEIM_REQ_CURSOR 6 // cursor: the pointer shape over the content
71#define HEIM_REQ_DESTROY 7
72#define HEIM_REQ_CLIP_SET 8 // clip: the length; with an fd of the text when not 0
73#define HEIM_REQ_CLIP_GET 9 // answered with HEIM_EV_CLIPBOARD
74#define HEIM_REQ_SETTINGS 10 // settings: a settings file changed; all clients are told
75#define HEIM_REQ_PLACE 11 // place: where a popup goes
76#define HEIM_REQ_APP_ID 12 // app: the program of the window (for the shell)
77#define HEIM_REQ_SHELL 13 // be the shell (answered with HEIM_EV_WINDOW for each window)
78#define HEIM_REQ_ACT 14 // act: the shell does something to a window
79#define HEIM_REQ_QUIT 15 // the shell ends the session
80
81#define HEIM_EV_WELCOME 64 // size: the screen
82#define HEIM_EV_CONFIGURE 65 // configure: the size the window should get
83#define HEIM_EV_CLOSE 66 // the user closed the window (the client decides)
84#define HEIM_EV_FOCUS 67 // focus: the window got or lost the keyboard
85#define HEIM_EV_KEY 68 // key
86#define HEIM_EV_POINTER 69 // pointer
87#define HEIM_EV_FRAME 70 // the last commit is on the screen
88#define HEIM_EV_CLIPBOARD 71 // clip: the length; with an fd of the text when not 0
89#define HEIM_EV_SETTINGS 72 // settings: the settings file that changed (read it again)
90#define HEIM_EV_SCREEN 73 // size: the screen has a new size
91#define HEIM_EV_WINDOW 74 // info: a window showed or changed (to the shell)
92#define HEIM_EV_WINDOW_APP 75 // app: the program of a window (to the shell)
93#define HEIM_EV_WINDOW_GONE 76 // info (id only): a window went (to the shell)
94
95// create flags
96#define HEIM_WINDOW_RESIZABLE 0x01 // the user can resize it
97#define HEIM_WINDOW_ALPHA 0x02 // the content has see-through pixels
98#define HEIM_WINDOW_UNDECORATED 0x04 // no title bar and no shadow
99#define HEIM_WINDOW_POPUP 0x08 // a popup of create.parent (see above)
100#define HEIM_WINDOW_TOOLTIP 0x10 // with POPUP: no keyboard, no pointer
101#define HEIM_WINDOW_PANEL 0x20 // a bar of the shell (see above)
102
103// the side of a rect a popup goes to (place.side)
104#define HEIM_SIDE_BELOW 0 // under it, from its left edge (or above it)
105#define HEIM_SIDE_ABOVE 1 // over it, in the middle (or below it)
106#define HEIM_SIDE_RIGHT 2 // to its right, from its top (or to its left): a sub-menu
107
108// configure state
109#define HEIM_STATE_MAXIMIZED 0x01
110#define HEIM_STATE_MINIMIZED 0x02 // HEIM_EV_WINDOW only
111#define HEIM_STATE_FOCUSED 0x04 // HEIM_EV_WINDOW only: it, or one of its popups
112
113// HEIM_REQ_ACT
114#define HEIM_ACT_ACTIVATE 1 // show it if minimized, raise it, give it the keyboard
115#define HEIM_ACT_MINIMIZE 2
116#define HEIM_ACT_CLOSE 3 // as the close button: the window gets HEIM_EV_CLOSE
117
118// pointer shapes
119#define HEIM_CURSOR_ARROW 0
120#define HEIM_CURSOR_TEXT 1
121#define HEIM_CURSOR_HAND 2
122
123// pointer kinds
124#define HEIM_POINTER_MOTION 1
125#define HEIM_POINTER_PRESS 2 // button: BTN_LEFT, BTN_RIGHT or BTN_MIDDLE
126#define HEIM_POINTER_RELEASE 3
127#define HEIM_POINTER_ENTER 4
128#define HEIM_POINTER_LEAVE 5
129#define HEIM_POINTER_SCROLL 6 // value: wheel steps, positive is up
130
131// buttons held (pointer.buttons)
132#define HEIM_BUTTON_LEFT 0x01
133#define HEIM_BUTTON_RIGHT 0x02
134#define HEIM_BUTTON_MIDDLE 0x04
135
136// modifier keys held (key.mods, pointer.mods)
137#define HEIM_MOD_SHIFT 0x01
138#define HEIM_MOD_CTRL 0x02
139#define HEIM_MOD_ALT 0x04 // the left Alt (Option) key
140#define HEIM_MOD_ALTGR 0x08 // the right Alt (Option) key
141#define HEIM_MOD_META 0x10
142
143// key values (key.value), as /dev/input
144#define HEIM_KEY_RELEASE 0
145#define HEIM_KEY_PRESS 1
146#define HEIM_KEY_REPEAT 2
147
148typedef struct
149{
150 uint16_t type; // HEIM_REQ_ or HEIM_EV_
152 uint32_t window; // the client's window number (0: not about a window)
153 union
154 {
155 uint8_t raw[56];
156 struct
157 {
159 } hello;
160 struct
161 {
164 } size;
165 struct
166 {
169 uint32_t flags; // HEIM_WINDOW_
170 char title[HEIM_TITLE_MAX];
171 uint32_t parent; // POPUP: the window it belongs to
172 } create;
173 struct
174 {
175 int32_t x; // a rect in the parent's content
176 int32_t y;
179 uint32_t side; // HEIM_SIDE_
180 int32_t margin; // the shadow around the popup's card in its buffer
181 } place;
182 struct
183 {
186 int32_t stride; // pixels from one row to the next
187 } attach;
188 struct
189 {
190 int32_t x;
191 int32_t y;
194 } rect;
195 struct
196 {
197 char title[HEIM_TITLE_MAX];
198 } title;
199 struct
200 {
201 uint32_t shape; // HEIM_CURSOR_
202 } cursor;
203 struct
204 {
205 uint32_t length; // bytes of UTF-8 text
206 } clip;
207 struct
208 {
209 char name[HEIM_SETTINGS_MAX]; // "theme"
210 } settings;
211 struct
212 {
215 uint32_t state; // HEIM_STATE_
216 } configure;
217 struct
218 {
220 } focus;
221 struct
222 {
223 uint32_t id; // the server's number for the window
224 uint32_t state; // HEIM_STATE_
225 char title[HEIM_TITLE_MAX];
226 } info;
227 struct
228 {
229 uint32_t id; // HEIM_EV_WINDOW_APP: the window; HEIM_REQ_APP_ID: 0
230 char app[HEIM_APP_ID_MAX];
231 } app;
232 struct
233 {
234 uint32_t id; // the server's number for the window
235 uint32_t action; // HEIM_ACT_
236 } act;
237 struct
238 {
239 uint16_t code; // the Linux key code (KEY_ in sys/input.h)
240 uint16_t value; // HEIM_KEY_
241 uint32_t mods; // HEIM_MOD_
242 char text[8]; // the characters it types (UTF-8), or empty
243 } key;
244 struct
245 {
246 uint16_t kind; // HEIM_POINTER_
247 uint16_t button; // PRESS, RELEASE: BTN_
248 int32_t x; // in the content, from its top left
249 int32_t y;
250 int32_t value; // SCROLL: steps
251 uint32_t buttons; // HEIM_BUTTON_, held after this event
252 uint32_t mods; // HEIM_MOD_
253 } pointer;
254 };
255} heim_msg_t;
256
257_Static_assert(sizeof(heim_msg_t) == 64, "a heimdall message is 64 bytes");
#define HEIM_SETTINGS_MAX
Definition heimdall_proto.h:60
#define HEIM_TITLE_MAX
Definition heimdall_proto.h:57
#define HEIM_APP_ID_MAX
Definition heimdall_proto.h:62
unsigned int uint32_t
Definition fb.h:17
unsigned char uint8_t
Definition fb.h:18
integer types of fixed width.
unsigned short uint16_t
Definition stdint.h:13
int int32_t
Definition stdint.h:14
Definition heimdall_proto.h:149
uint32_t window
Definition heimdall_proto.h:152
uint16_t pad
Definition heimdall_proto.h:151
uint16_t type
Definition heimdall_proto.h:150
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@036354373134063062003205112046203025145166172231 size
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@121317147017324073154211331135276136237173030200 settings
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@130060355233001110013035102162157333212156036106 place
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@271056261357147005074255145262065147320276300361 hello
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@104307314230306310102371271022025156253014054322 cursor
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@222006032252336113255353223174316147003010036234 info
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@006117302234241306076100244315265314136044035002 configure
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@156032266221162017327254246074054301142141071362 create
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@042150225374364270062231070017132274333074035342 app
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@002111155053060333173334172373303140267213275104 act
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@221274002232260152312067145332122246016152120321 rect
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@374223166115347353254167333321362332214026214330 focus
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@161340024314303215115034344115156046323154032055 title
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@267177324144267074353263162004307133132372155274 clip
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@320134202017121334343344364071174330255114211031 pointer
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@054364213114232004276337047146111246212253127361 key
struct heim_msg_t::@116355240226224035152164310115136200013223140253::@036064143043231374140021175043341334313311222064 attach