This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyutani-server.h
348 lines (276 loc) · 7.35 KB
/
yutani-server.h
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
/**
* @brief Internal definitions used by the Yutani (NG) compositor.
*
* @copyright
* This file is part of SiriusOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2013-2021 K. Lange
* Copyright (C) 2024 Gamma Microsystems
*/
#pragma once
#include <_cheader.h>
#include <stdint.h>
#include <sys/time.h>
#include <sirius/yutani.h>
_Begin_C_Header
/* Mouse resolution scaling */
#define MOUSE_SCALE 3
#define YUTANI_INCOMING_MOUSE_SCALE * 3
/* Mouse cursor hotspot */
#define MOUSE_OFFSET_X 26
#define MOUSE_OFFSET_Y 26
/* Mouse cursor size */
#define MOUSE_WIDTH 64
#define MOUSE_HEIGHT 64
/* How much the mouse needs to move to break off a tiled window */
#define UNTILE_SENSITIVITY (MOUSE_SCALE * 5)
/* Screenshot modes */
#define YUTANI_SCREENSHOT_FULL 1
#define YUTANI_SCREENSHOT_WINDOW 2
/*
* Animation effect types.
* XXX: Should this be in the client library?
*/
typedef enum {
YUTANI_EFFECT_NONE,
/* Basic animations */
YUTANI_EFFECT_FADE_IN,
YUTANI_EFFECT_FADE_OUT,
/* XXX: Are these used? */
YUTANI_EFFECT_MINIMIZE,
YUTANI_EFFECT_UNMINIMIZE,
/* Dialog animations, faster than the fades */
YUTANI_EFFECT_SQUEEZE_IN,
YUTANI_EFFECT_SQUEEZE_OUT,
YUTANI_EFFECT_DISAPPEAR,
} yutani_effect;
/* Animation lengths */
static int yutani_animation_lengths[] = {
0, /* None */
200, /* Fade In */
200, /* Fade Out */
200, /* Minimize */
200, /* Unminimized */
100, /* Squeeze in */
100, /* Squeeze out */
10, /* Disappear */
};
static int yutani_is_closing_animation[] = {
0,
0,
1,
0,
0,
0,
1,
1,
};
static int yutani_is_minimizing_animation[] = {
0,
0,
0,
1,
0,
0,
0,
0
};
/* Debug Options */
#define YUTANI_DEBUG_WINDOW_BOUNDS 1
#define YUTANI_DEBUG_WINDOW_SHAPES 1
/* Command line flag values */
struct {
int nested;
int nest_width;
int nest_height;
} yutani_options = {
.nested = 0,
.nest_width = 640,
.nest_height = 480,
};
/*
* Server window definitions
*/
typedef struct YutaniServerWindow {
/* Window identifier number */
yutani_wid_t wid;
/* Window location */
signed long x;
signed long y;
/* Stack order */
unsigned short z;
/* Window size */
int32_t width;
int32_t height;
/* Canvas buffer */
uint8_t * buffer;
uint32_t bufid;
uint32_t newbufid;
uint8_t * newbuffer;
/* Connection that owns this window */
uintptr_t owner;
/* Rotation of windows XXX */
int16_t rotation;
/* Client advertisements */
uint32_t client_flags;
uint32_t client_icon;
uint32_t client_length;
char * client_strings;
/* Window animations */
uint64_t anim_mode;
uint64_t anim_start;
/* Alpha shaping threshold */
int alpha_threshold;
/*
* Mouse cursor selection
* Originally, this specified whether the mouse was
* hidden, but it plays double duty since client
* control over mouse cursors was added.
*/
int show_mouse;
int default_mouse;
/* Tiling / untiling information */
int tiled;
int32_t untiled_width;
int32_t untiled_height;
int32_t untiled_left;
int32_t untiled_top;
/* Client-configurable server behavior flags */
uint32_t server_flags;
/* Window opacity */
int opacity;
/* Window is hidden? */
int hidden;
int minimized;
int32_t icon_x, icon_y, icon_w, icon_h;
} yutani_server_window_t;
typedef struct YutaniGlobals {
/* Display resolution */
unsigned int width;
unsigned int height;
uint32_t stride;
/* TODO: What about multiple screens?
*
* Obviously this is the whole canvas size,
* but we need to be able to track different
* monitors if/when we ever get support for that.
*/
/* Core graphics context */
void * backend_framebuffer;
gfx_context_t * backend_ctx;
/* Mouse location */
signed int mouse_x;
signed int mouse_y;
/*
* Previous mouse location, so that events can have
* both the new and old mouse location together
*/
signed int last_mouse_x;
signed int last_mouse_y;
/* List of all windows */
list_t * windows;
/* Hash of window IDs to their objects */
hashmap_t * wids_to_windows;
/*
* Window stacking information
* TODO: Support multiple top and bottom windows.
*/
yutani_server_window_t * bottom_z;
list_t * mid_zs;
list_t * menu_zs;
list_t * overlay_zs;
yutani_server_window_t * top_z;
/* Damage region list */
list_t * update_list;
/* Mouse cursors */
sprite_t mouse_sprite;
sprite_t mouse_sprite_drag;
sprite_t mouse_sprite_resize_v;
sprite_t mouse_sprite_resize_h;
sprite_t mouse_sprite_resize_da;
sprite_t mouse_sprite_resize_db;
sprite_t mouse_sprite_point;
sprite_t mouse_sprite_ibeam;
int current_cursor;
/* Server backend communication identifier */
char * server_ident;
FILE * server;
/* Pointer to focused window */
yutani_server_window_t * focused_window;
/* Mouse movement state */
int mouse_state;
/* Pointer to window being manipulated by mouse actions */
yutani_server_window_t * mouse_window;
/* Buffered information on mouse-moved window */
int mouse_win_x;
int mouse_win_y;
int mouse_init_x;
int mouse_init_y;
int mouse_init_r;
int32_t mouse_click_x_orig;
int32_t mouse_click_y_orig;
int mouse_drag_button;
int mouse_moved;
int32_t mouse_click_x;
int32_t mouse_click_y;
/* Pointer to window being resized */
yutani_server_window_t * resizing_window;
int32_t resizing_w;
int32_t resizing_h;
yutani_scale_direction_t resizing_direction;
int32_t resizing_offset_x;
int32_t resizing_offset_y;
int resizing_button;
/* List of clients subscribing to window information events */
list_t * window_subscribers;
/* When the server started, used for timing functions */
time_t start_time;
suseconds_t start_subtime;
/* Pointer to last hovered window to allow exit events */
yutani_server_window_t * old_hover_window;
/* Key bindings */
hashmap_t * key_binds;
/* Windows to remove after the end of the rendering pass */
list_t * windows_to_remove;
/* For nested mode, the host Yutani context and window */
yutani_t * host_context;
yutani_window_t * host_window;
/* Map of clients to their windows */
hashmap_t * clients_to_windows;
/* Toggles for debugging window locations */
int debug_bounds;
int debug_shapes;
/* If the next rendered frame should be saved as a screenshot */
int screenshot_frame;
/* Next frame should resize host context */
int resize_on_next;
/* Last mouse buttons - used for some specialized mouse drivers */
uint32_t last_mouse_buttons;
/* Clipboard buffer */
char clipboard[512];
int clipboard_size;
/* VirtualBox Seamless mode support information */
int vbox_rects;
int vbox_pointer;
/* Renderer plugin context */
void * renderer_ctx;
int reload_renderer;
uint8_t active_modifiers;
uint64_t resize_release_time;
int32_t resizing_init_w;
int32_t resizing_init_h;
list_t * windows_to_minimize;
list_t * minimized_zs;
} yutani_globals_t;
struct key_bind {
uintptr_t owner;
int response;
};
/* Exported functions for plugins */
extern int yutani_window_is_top(yutani_globals_t * yg, yutani_server_window_t * window);
extern int yutani_window_is_bottom(yutani_globals_t * yg, yutani_server_window_t * window);
extern uint64_t yutani_time_since(yutani_globals_t * yg, uint64_t start_time);
extern void yutani_window_to_device(yutani_server_window_t * window, int32_t x, int32_t y, int32_t * out_x, int32_t * out_y);
extern void yutani_device_to_window(yutani_server_window_t * window, int32_t x, int32_t y, int32_t * out_x, int32_t * out_y);
extern uint32_t yutani_color_for_wid(yutani_wid_t wid);
_End_C_Header