PatchworkOS
Loading...
Searching...
No Matches
dwm.c
Go to the documentation of this file.
1#include "dwm.h"
2
3#include "client.h"
4#include "compositor.h"
5#include "kbd.h"
6#include "screen.h"
7#include "surface.h"
8
9#include <errno.h>
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <sys/fb.h>
14#include <sys/io.h>
15#include <sys/list.h>
16#include <sys/math.h>
17#include <sys/proc.h>
18#include <threads.h>
19
20static char id[MAX_NAME];
21static fd_t data;
22
23static fd_t kbd;
24static fd_t mouse;
25
28
35
37
39
41{
42 fd_t fd = openf("/net/local/%s/accept:nonblock", id);
43 if (fd == ERR)
44 {
45 printf("dwm: failed to open accept file (%s)\n", strerror(errno));
46 return NULL;
47 }
48
49 client_t* client = client_new(fd);
50 if (client == NULL)
51 {
52 printf("dwm: failed to accept client (%s)\n", strerror(errno));
53 close(fd);
54 return NULL;
55 }
56
57 list_push(&clients, &client->entry);
59 printf("dwm: accepted client %d total %lu\n", client->fd, clientAmount);
60 return client;
61}
62
63static void dwm_client_disconnect(client_t* client)
64{
65 list_remove(&clients, &client->entry);
66 client_free(client);
68 printf("dwm: disconnect client\n");
69}
70
71static void dwm_send_event_to_all(surface_id_t target, event_type_t type, void* data, uint64_t size)
72{
73 client_t* client;
74 client_t* temp;
75 LIST_FOR_EACH_SAFE(client, temp, &clients, entry)
76 {
77 if (client_send_event(client, target, type, data, size) == ERR)
78 {
80 }
81 }
82}
83
84void dwm_init(void)
85{
86 if (readfile("/net/local/seqpacket:nonblock", id, MAX_NAME - 1, 0) == ERR)
87 {
88 printf("dwm: failed to create socket (%s)\n", strerror(errno));
89 abort();
90 }
91
92 fd_t ctl = openf("/net/local/%s/ctl", id);
93 if (ctl == ERR)
94 {
95 printf("dwm: failed to open control file (%s)\n", strerror(errno));
96 abort();
97 }
98 if (writef(ctl, "bind dwm") == ERR)
99 {
100 printf("dwm: failed to bind socket (%s)\n", strerror(errno));
101 abort();
102 }
103 if (writef(ctl, "listen") == ERR)
104 {
105 printf("dwm: failed to listen (%s)\n", strerror(errno));
106 abort();
107 }
108 close(ctl);
109
110 data = openf("/net/local/%s/data", id);
111 if (data == ERR)
112 {
113 printf("dwm: failed to open data file (%s)\n", strerror(errno));
114 abort();
115 }
116
117 kbd = open("/dev/kbd/0/events");
118 if (kbd == ERR)
119 {
120 printf("dwm: failed to open keyboard (%s)\n", strerror(errno));
121 abort();
122 }
123
124 char name[MAX_NAME] = {0};
125 if (readfile("/dev/kbd/0/name", name, MAX_NAME - 1, 0) != ERR)
126 {
127 printf("dwm: using keyboard '%s'\n", name);
128 }
129
130 mouse = open("/dev/mouse/0/events");
131 if (mouse == ERR)
132 {
133 printf("dwm: failed to open mouse (%s)\n", strerror(errno));
134 abort();
135 }
136
137 memset(name, 0, MAX_NAME);
138 if (readfile("/dev/mouse/0/name", name, MAX_NAME - 1, 0) != ERR)
139 {
140 printf("dwm: using mouse '%s'\n", name);
141 }
142
144 clientAmount = 0;
145
148 wall = NULL;
149 cursor = NULL;
152
153 focus = NULL;
154
155 pollCtx = NULL;
156}
157
158void dwm_deinit(void)
159{
160 close(kbd);
161 close(mouse);
162 close(data);
163
164 free(pollCtx);
165}
166
168{
169 event_report_t event;
170 event.flags = flags;
171 surface_get_info(surface, &event.info);
172
173 client_send_event(client, surface->id, EVENT_REPORT, &event, sizeof(event));
174
175 gevent_report_t globalEvent;
176 globalEvent.flags = flags;
177 globalEvent.info = event.info;
178
179 dwm_send_event_to_all(SURFACE_ID_NONE, GEVENT_REPORT, &globalEvent, sizeof(globalEvent));
180}
181
183{
184 surface_t* panel;
185 LIST_FOR_EACH_REVERSE(panel, &panels, dwmEntry)
186 {
187 if (panel->id == id)
188 {
189 return panel;
190 }
191 }
192
193 surface_t* window;
194 LIST_FOR_EACH_REVERSE(window, &windows, dwmEntry)
195 {
196 if (window->id == id)
197 {
198 return window;
199 }
200 }
201
202 if (wall != NULL && wall->id == id)
203 {
204 return wall;
205 }
206
207 if (fullscreen != NULL && fullscreen->id == id)
208 {
209 return fullscreen;
210 }
211
212 return NULL;
213}
214
216{
217 switch (surface->type)
218 {
219 case SURFACE_WINDOW:
220 {
221 list_push(&windows, &surface->dwmEntry);
222 }
223 break;
224 case SURFACE_PANEL:
225 {
226 list_push(&panels, &surface->dwmEntry);
227 }
228 break;
229 case SURFACE_CURSOR:
230 {
231 if (cursor != NULL)
232 {
233 printf("dwm: attach (cursor != NULL)\n");
234 errno = EALREADY;
235 return ERR;
236 }
237
238 cursor = surface;
239 }
240 break;
241 case SURFACE_WALL:
242 {
243 if (wall != NULL)
244 {
245 printf("dwm: attach (wall != NULL)\n");
246 errno = EALREADY;
247 return ERR;
248 }
249
250 wall = surface;
251 }
252 break;
254 {
255 if (fullscreen != NULL)
256 {
257 printf("dwm: attach (fullscreen != NULL)\n");
258 errno = EALREADY;
259 return ERR;
260 }
261
262 fullscreen = surface;
263 focus = surface;
264 }
265 break;
266 default:
267 {
268 printf("dwm: attach (default)\n");
269 errno = EINVAL;
270 return ERR;
271 }
272 }
273
274 gevent_attach_t event;
275 surface_get_info(surface, &event.info);
276 dwm_send_event_to_all(SURFACE_ID_NONE, GEVENT_ATTACH, &event, sizeof(event));
277 return 0;
278}
279
280void dwm_detach(surface_t* surface)
281{
282 if (surface == focus)
283 {
284 focus = NULL;
285 }
286 if (surface == prevCursorTarget)
287 {
289 }
290
291 gevent_detach_t event;
292 surface_get_info(surface, &event.info);
293 dwm_send_event_to_all(SURFACE_ID_NONE, GEVENT_DETACH, &event, sizeof(event));
294
295 switch (surface->type)
296 {
297 case SURFACE_WINDOW:
298 {
299 list_remove(&windows, &surface->dwmEntry);
300 }
301 break;
302 case SURFACE_PANEL:
303 {
304 list_remove(&panels, &surface->dwmEntry);
305 }
306 break;
307 case SURFACE_CURSOR:
308 {
309 cursor = NULL;
310 }
311 break;
312 case SURFACE_WALL:
313 {
314 wall = NULL;
315 }
316 break;
318 {
320 focus = NULL;
321 }
322 break;
323 default:
324 {
325 printf("dwm: attempt to detach invalid surface\n");
326 abort();
327 }
328 }
329}
330
332{
333 if (fullscreen != NULL)
334 {
335 return;
336 }
337
338 if (surface == focus)
339 {
340 return;
341 }
342
343 if (focus != NULL)
344 {
345 focus->flags &= ~SURFACE_FOCUSED;
347 }
348
349 if (surface != NULL)
350 {
351 surface->flags |= SURFACE_FOCUSED;
352 if (surface->type == SURFACE_WINDOW)
353 {
354 // Move to end of list
355 list_remove(&windows, &surface->dwmEntry);
356 list_push(&windows, &surface->dwmEntry);
357 }
358 focus = surface;
360 }
361 else
362 {
363 focus = NULL;
364 }
365}
366
368{
369 if (fullscreen != NULL)
370 {
371 return fullscreen;
372 }
373
374 surface_t* panel;
375 LIST_FOR_EACH_REVERSE(panel, &panels, dwmEntry)
376 {
377 rect_t rect = SURFACE_SCREEN_RECT(panel);
378 if (RECT_CONTAINS_POINT(&rect, point))
379 {
380 return panel;
381 }
382 }
383
384 surface_t* window;
385 LIST_FOR_EACH_REVERSE(window, &windows, dwmEntry)
386 {
387 rect_t rect = SURFACE_SCREEN_RECT(window);
388 if (RECT_CONTAINS_POINT(&rect, point))
389 {
390 return window;
391 }
392 }
393
394 if (wall == NULL)
395 {
396 return NULL;
397 }
398
399 rect_t wallRect = SURFACE_SCREEN_RECT(wall);
400 if (RECT_CONTAINS_POINT(&wallRect, point))
401 {
402 return wall;
403 }
404
405 return NULL;
406}
407
408// TODO: Cache this or something
410{
411 clock_t deadline = CLOCKS_NEVER;
412 surface_t* nextTimer = NULL;
413
414 surface_t* window;
415 LIST_FOR_EACH(window, &windows, dwmEntry)
416 {
417 if (window->timer.deadline < deadline)
418 {
419 deadline = window->timer.deadline;
420 nextTimer = window;
421 }
422 }
423
424 surface_t* panel;
425 LIST_FOR_EACH(panel, &panels, dwmEntry)
426 {
427 if (panel->timer.deadline < deadline)
428 {
429 deadline = panel->timer.deadline;
430 nextTimer = panel;
431 }
432 }
433
434 if (wall != NULL && wall->timer.deadline < deadline)
435 {
436 deadline = wall->timer.deadline;
437 nextTimer = wall;
438 }
439
440 if (cursor != NULL && cursor->timer.deadline < deadline)
441 {
442 deadline = cursor->timer.deadline;
443 nextTimer = cursor;
444 }
445
446 if (fullscreen != NULL && fullscreen->timer.deadline < deadline)
447 {
448 deadline = fullscreen->timer.deadline;
449 nextTimer = fullscreen;
450 }
451
452 return nextTimer;
453}
454
455static void dwm_kbd_read(void)
456{
457 if (poll1(kbd, POLLIN, 0) == POLLIN)
458 {
459 // The kbd_event_t and event_kbd_t naming is a bit weird.
460 kbd_event_t kbdEvent;
461 if (read(kbd, &kbdEvent, sizeof(kbd_event_t)) != sizeof(kbd_event_t))
462 {
463 printf("dwm: failed to read kbd event\n");
464 return;
465 }
466
467 if (focus == NULL)
468 {
469 return;
470 }
471
472 event_kbd_t event;
473 event.type = kbdEvent.type;
474 event.mods = kbdEvent.mods;
475 event.code = kbdEvent.code;
476 event.ascii = kbd_ascii(event.code, event.mods);
478
479 gevent_kbd_t globalEvent = event;
480 dwm_send_event_to_all(SURFACE_ID_NONE, GEVENT_KBD, &globalEvent, sizeof(globalEvent));
481 }
482}
483
484static void dwm_handle_mouse_event(const mouse_event_t* mouseEvent)
485{
486 static mouse_buttons_t prevHeld = MOUSE_NONE;
487
488 if (cursor == NULL)
489 {
490 return;
491 }
492
493 mouse_buttons_t held = mouseEvent->buttons;
494 mouse_buttons_t pressed = mouseEvent->buttons & ~prevHeld;
495 mouse_buttons_t released = prevHeld & ~mouseEvent->buttons;
496
497 point_t oldCursorPos = cursor->pos;
498 cursor->pos.x = CLAMP(cursor->pos.x + mouseEvent->deltaX, 0, (int64_t)screen_width() - 1);
499 cursor->pos.y = CLAMP(cursor->pos.y + mouseEvent->deltaY, 0, (int64_t)screen_height() - 1);
500
501 point_t cursorDelta = {.x = cursor->pos.x - oldCursorPos.x, .y = cursor->pos.y - oldCursorPos.y};
503 if (surface != prevCursorTarget)
504 {
505 if (prevCursorTarget != NULL)
506 {
507 event_cursor_leave_t event = {
508 .held = held,
509 .pressed = MOUSE_NONE,
510 .released = MOUSE_NONE,
511 .pos.x = cursor->pos.x - prevCursorTarget->pos.x,
512 .pos.y = cursor->pos.y - prevCursorTarget->pos.y,
513 .screenPos = cursor->pos,
514 .delta = cursorDelta,
515 };
517 sizeof(event_cursor_leave_t));
518 }
519
520 if (surface != NULL)
521 {
522 event_cursor_enter_t event = {
523 .held = held,
524 .pressed = MOUSE_NONE,
525 .released = MOUSE_NONE,
526 .pos.x = cursor->pos.x - surface->pos.x,
527 .pos.y = cursor->pos.y - surface->pos.y,
528 .screenPos = cursor->pos,
529 .delta = cursorDelta,
530 };
531 client_send_event(surface->client, surface->id, EVENT_CURSOR_ENTER, &event, sizeof(event_cursor_enter_t));
532 }
533 prevCursorTarget = surface;
534 }
535
536 if (pressed != MOUSE_NONE)
537 {
538 dwm_focus_set(surface);
539 rect_t surfaceRect = SURFACE_SCREEN_RECT(surface);
540 compositor_invalidate(&surfaceRect);
541 }
542
543 surface_t* destSurface;
544 if (held != MOUSE_NONE && focus != NULL)
545 {
546 destSurface = focus;
547 }
548 else
549 {
550 destSurface = surface;
551 }
552
553 if (destSurface != NULL)
554 {
555 event_mouse_t event = {
556 .held = held,
557 .pressed = pressed,
558 .released = released,
559 .pos.x = cursor->pos.x - destSurface->pos.x,
560 .pos.y = cursor->pos.y - destSurface->pos.y,
561 .screenPos = cursor->pos,
562 .delta = cursorDelta,
563 };
564 client_send_event(destSurface->client, destSurface->id, EVENT_MOUSE, &event, sizeof(event_mouse_t));
565
566 gevent_mouse_t globalEvent = event;
567 globalEvent.pos = globalEvent.screenPos;
568 dwm_send_event_to_all(SURFACE_ID_NONE, GEVENT_MOUSE, &globalEvent, sizeof(globalEvent));
569 }
570
571 prevHeld = held;
572}
573
574static void dwm_mouse_read(void)
575{
576 static mouse_buttons_t prevHeld = MOUSE_NONE;
577
578 mouse_event_t total = {0};
579 bool received = false;
580 while (1)
581 {
582 if (poll1(mouse, POLLIN, 0) != POLLIN)
583 {
584 break;
585 }
586
587 mouse_event_t mouseEvent;
588 if (read(mouse, &mouseEvent, sizeof(mouse_event_t)) != sizeof(mouse_event_t))
589 {
590 printf("dwm: failed to read mouse event\n");
591 return;
592 }
593
594 total.buttons |= mouseEvent.buttons;
595 total.deltaX += mouseEvent.deltaX;
596 total.deltaY += mouseEvent.deltaY;
597 received = true;
598 }
599
600 if (!received)
601 {
602 return;
603 }
604
606}
607
608static void dwm_poll_ctx_update(void)
609{
610 void* newCtx = realloc(pollCtx, sizeof(poll_ctx_t) + (sizeof(pollfd_t) * clientAmount));
611 if (newCtx == NULL)
612 {
613 printf("dwm: failed to realloc pollCtx\n");
614 abort();
615 }
616 else
617 {
618 pollCtx = newCtx;
619 }
620 pollCtx->data.fd = data;
622 pollCtx->data.revents = 0;
623 pollCtx->kbd.fd = kbd;
625 pollCtx->kbd.revents = 0;
628 pollCtx->mouse.revents = 0;
629
630 uint64_t i = 0;
631 client_t* client;
632 LIST_FOR_EACH(client, &clients, entry)
633 {
634 pollfd_t* fd = &pollCtx->clients[i++];
635 fd->fd = client->fd;
636 fd->events = POLLIN;
637 fd->revents = 0;
638 }
639}
640
641static void dwm_poll(void)
642{
644
645 surface_t* timer = dwm_next_timer();
646 clock_t timeout = CLOCKS_NEVER;
647 if (timer != NULL)
648 {
649 clock_t time = uptime();
650 timeout = timer->timer.deadline > time ? timer->timer.deadline - time : 0;
651 }
652
653 uint64_t events = poll((pollfd_t*)pollCtx, sizeof(poll_ctx_t) / sizeof(pollfd_t) + clientAmount, timeout);
654 if (events == ERR)
655 {
656 printf("dwm: poll failed (%s)\n", strerror(errno));
657 abort();
658 }
659
660 clock_t time = uptime();
661 if (timer != NULL && time >= timer->timer.deadline)
662 {
663 if (timer->timer.flags & TIMER_REPEAT)
664 {
665 timer->timer.deadline = time + timer->timer.timeout;
666 }
667 else
668 {
669 timer->timer.deadline = CLOCKS_NEVER;
670 }
671 client_send_event(timer->client, timer->id, EVENT_TIMER, NULL, 0);
672 }
673}
674
675static void dwm_update(void)
676{
677 dwm_poll();
678
679 if (pollCtx->data.revents & POLLIN)
680 {
682 return; // The clients array is now invalid, so we have to update it.
683 }
684 if (pollCtx->kbd.revents & POLLIN)
685 {
686 dwm_kbd_read();
687 }
689 {
691 }
692
693 uint64_t i = 0;
694 client_t* client;
695 client_t* temp;
696 LIST_FOR_EACH_SAFE(client, temp, &clients, entry)
697 {
698 pollfd_t* fd = &pollCtx->clients[i++];
699 if (fd->revents & POLLHUP)
700 {
701 printf("dwm: client %d hung up\n", client->fd);
702 dwm_client_disconnect(client);
703 }
704 else if (fd->revents & POLLERR)
705 {
706 printf("dwm: client %d error\n", client->fd);
707 dwm_client_disconnect(client);
708 }
709 else if (fd->revents & POLLIN)
710 {
711 if (client_receive_cmds(client) == ERR)
712 {
713 printf("dwm: client %d receive commands failed (%s)\n", client->fd, strerror(errno));
714 dwm_client_disconnect(client);
715 }
716 }
717 }
718
719 compositor_ctx_t ctx = {
720 .windows = &windows,
721 .panels = &panels,
722 .wall = wall,
723 .cursor = cursor,
724 .fullscreen = fullscreen,
725 };
726 compositor_draw(&ctx);
727}
728
729void dwm_loop(void)
730{
731 while (1)
732 {
733 dwm_update();
734 }
735}
#define MAX_NAME
Maximum length of names.
Definition MAX_NAME.h:11
uint64_t client_receive_cmds(client_t *client)
Definition client.c:427
void client_free(client_t *client)
Definition client.c:52
uint64_t client_send_event(client_t *client, surface_id_t target, event_type_t type, void *data, uint64_t size)
Definition client.c:516
client_t * client_new(fd_t fd)
Definition client.c:32
#define CLOCKS_NEVER
Definition clock_t.h:16
@ TIMER_REPEAT
Definition cmd.h:77
void compositor_invalidate(const rect_t *rect)
Definition compositor.c:135
void compositor_draw(compositor_ctx_t *ctx)
Definition compositor.c:117
static surface_t * wall
Definition dwm.c:31
static fd_t kbd
Definition dwm.c:23
static uint64_t clientAmount
Definition dwm.c:27
static void dwm_update(void)
Definition dwm.c:675
static surface_t * cursor
Definition dwm.c:32
static void dwm_handle_mouse_event(const mouse_event_t *mouseEvent)
Definition dwm.c:484
static poll_ctx_t * pollCtx
Definition dwm.c:38
static void dwm_client_disconnect(client_t *client)
Definition dwm.c:63
static list_t panels
Definition dwm.c:30
static surface_t * fullscreen
Definition dwm.c:33
static list_t clients
Definition dwm.c:26
static surface_t * dwm_next_timer(void)
Definition dwm.c:409
static void dwm_mouse_read(void)
Definition dwm.c:574
static list_t windows
Definition dwm.c:29
static surface_t * focus
Definition dwm.c:36
static void dwm_send_event_to_all(surface_id_t target, event_type_t type, void *data, uint64_t size)
Definition dwm.c:71
static fd_t data
Definition dwm.c:21
static client_t * dwm_client_accept(void)
Definition dwm.c:40
static surface_t * prevCursorTarget
Definition dwm.c:34
static fd_t mouse
Definition dwm.c:24
static surface_t * dwm_surface_under_point(const point_t *point)
Definition dwm.c:367
static void dwm_kbd_read(void)
Definition dwm.c:455
static void dwm_poll(void)
Definition dwm.c:641
static void dwm_poll_ctx_update(void)
Definition dwm.c:608
#define GEVENT_KBD
Definition event.h:94
#define GEVENT_ATTACH
Definition event.h:91
#define EVENT_CURSOR_LEAVE
Definition event.h:88
#define EVENT_MOUSE
Definition event.h:85
report_flags_t
Report flags.
Definition event.h:34
#define EVENT_CURSOR_ENTER
Definition event.h:87
#define GEVENT_MOUSE
Definition event.h:95
#define EVENT_KBD
Definition event.h:84
#define GEVENT_REPORT
Definition event.h:93
#define GEVENT_DETACH
Definition event.h:92
uint16_t event_type_t
Event type.
Definition event.h:72
#define EVENT_REPORT
Definition event.h:89
#define EVENT_TIMER
Definition event.h:86
@ REPORT_IS_FOCUSED
Definition event.h:38
#define SURFACE_ID_NONE
Definition surface.h:54
uint64_t surface_id_t
Definition surface.h:53
@ SURFACE_WALL
Definition surface.h:38
@ SURFACE_WINDOW
Definition surface.h:35
@ SURFACE_PANEL
Definition surface.h:36
@ SURFACE_CURSOR
Definition surface.h:37
@ SURFACE_FULLSCREEN
Definition surface.h:39
@ SURFACE_FOCUSED
Definition surface.h:50
#define EINVAL
Invalid argument.
Definition errno.h:142
#define EALREADY
Operation already in progress.
Definition errno.h:597
#define errno
Error number variable.
Definition errno.h:27
uint64_t writef(fd_t fd, const char *_RESTRICT format,...)
Wrapper for writing a formatted string to a file.
Definition writef.c:9
fd_t open(const char *path)
System call for opening files.
Definition open.c:9
poll_events_t poll1(fd_t fd, poll_events_t events, clock_t timeout)
Wrapper for polling one file.
Definition poll1.c:9
uint64_t close(fd_t fd)
System call for closing files.
Definition close.c:9
uint64_t readfile(const char *path, void *buffer, uint64_t count, uint64_t offset)
Wrapper for reading a file directly using a path.
Definition readfile.c:3
uint64_t poll(pollfd_t *fds, uint64_t amount, clock_t timeout)
System call for polling files.
Definition poll.c:9
fd_t openf(const char *_RESTRICT format,...)
Wrapper for opening files with a formatted path.
Definition openf.c:9
uint64_t read(fd_t fd, void *buffer, uint64_t count)
System call for reading from files.
Definition read.c:9
@ POLLIN
File descriptor is ready to read.
Definition io.h:290
@ POLLHUP
Stream socket peer closed connection, or shut down writing of connection.
Definition io.h:293
@ POLLERR
File descriptor caused an error.
Definition io.h:292
#define LIST_FOR_EACH(elem, list, member)
Iterates over a list.
Definition list.h:65
#define LIST_FOR_EACH_SAFE(elem, temp, list, member)
Safely iterates over a list, allowing for element removal during iteration.
Definition list.h:81
static void list_remove(list_t *list, list_entry_t *entry)
Removes a list entry from its current list.
Definition list.h:317
static void list_push(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
Definition list.h:345
#define LIST_FOR_EACH_REVERSE(elem, list, member)
Iterates over a list in reverse.
Definition list.h:95
static void list_init(list_t *list)
Initializes a list.
Definition list.h:198
#define CLAMP(x, low, high)
Definition math.h:17
mouse_buttons_t
Mouse buttons enum.
Definition mouse.h:31
@ MOUSE_NONE
None.
Definition mouse.h:32
clock_t uptime(void)
System call for retreving the time since boot.
Definition uptime.c:6
#define NULL
Pointer error value.
Definition NULL.h:23
#define ERR
Integer error value.
Definition ERR.h:17
__UINT64_TYPE__ fd_t
A file descriptor.
Definition fd_t.h:12
__UINT64_TYPE__ clock_t
A nanosecond time.
Definition clock_t.h:13
void dwm_focus_set(surface_t *surface)
Definition dwm.c:331
uint64_t dwm_attach(surface_t *surface)
Definition dwm.c:215
void dwm_report_produce(surface_t *surface, client_t *client, report_flags_t flags)
Definition dwm.c:167
void dwm_detach(surface_t *surface)
Definition dwm.c:280
void dwm_loop(void)
Definition dwm.c:729
surface_t * dwm_surface_find(surface_id_t id)
Definition dwm.c:182
void dwm_init(void)
Definition dwm.c:84
void dwm_deinit(void)
Definition dwm.c:158
char kbd_ascii(keycode_t code, kbd_mods_t mods)
Definition kbd.c:95
#define RECT_CONTAINS_POINT(rect, point)
Definition rect.h:61
uint64_t screen_height(void)
Definition screen.c:199
uint64_t screen_width(void)
Definition screen.c:194
#define SURFACE_SCREEN_RECT(surface)
Definition surface.h:37
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__INT64_TYPE__ int64_t
Definition stdint.h:16
_PUBLIC int printf(const char *_RESTRICT format,...)
Definition printf.c:5
_PUBLIC void * realloc(void *ptr, size_t size)
Definition realloc.c:13
_PUBLIC _NORETURN void abort(void)
Definition abort.c:7
_PUBLIC void free(void *ptr)
Definition free.c:11
_PUBLIC char * strerror(int errnum)
Definition strerror.c:6
_PUBLIC void * memset(void *s, int c, size_t n)
Definition memset.c:4
list_entry_t entry
Definition client.h:14
fd_t fd
Definition client.h:15
list_t * windows
Definition compositor.h:11
Keyboard event.
Definition event.h:138
kbd_mods_t mods
Definition event.h:140
kbd_event_type_t type
Definition event.h:139
keycode_t code
Definition event.h:141
Mouse event.
Definition event.h:151
point_t screenPos
Definition event.h:156
mouse_buttons_t held
Definition event.h:152
point_t pos
Definition event.h:155
Report event.
Definition event.h:180
surface_info_t info
Definition event.h:182
report_flags_t flags
Definition event.h:181
Global Attach event.
Definition event.h:191
surface_info_t info
Definition event.h:192
Global Detach event.
Definition event.h:201
surface_info_t info
Definition event.h:202
Keyboard event structure.
Definition kbd.h:313
kbd_event_type_t type
Type of keyboard event (press or release)
Definition kbd.h:315
keycode_t code
Keycode of the key involved in the event.
Definition kbd.h:317
kbd_mods_t mods
Active keyboard modifiers.
Definition kbd.h:316
A doubly linked list.
Definition list.h:51
Mouse event structure.
Definition mouse.h:45
mouse_buttons_t buttons
Which buttons were held down durring the event.
Definition mouse.h:47
int64_t deltaY
Change in Y coordinate.
Definition mouse.h:49
int64_t deltaX
Change in X coordinate.
Definition mouse.h:48
int64_t y
Definition point.h:14
int64_t x
Definition point.h:13
pollfd_t mouse
Definition dwm.h:24
pollfd_t clients[]
Definition dwm.h:25
pollfd_t kbd
Definition dwm.h:23
pollfd_t data
Definition dwm.h:22
Poll file descriptor structure.
Definition io.h:307
poll_events_t revents
The events that occurred.
Definition io.h:310
poll_events_t events
The events to wait for.
Definition io.h:309
fd_t fd
The file descriptor to poll.
Definition io.h:308
Definition rect.h:13
client_t * client
Definition surface.h:24
surface_type_t type
Definition surface.h:31
timer_t timer
Definition surface.h:32
point_t pos
Definition surface.h:25
surface_id_t id
Definition surface.h:30
list_entry_t dwmEntry
Definition surface.h:22
surface_flags_t flags
Definition surface.h:33
timer_flags_t flags
Definition surface.h:15
clock_t timeout
Definition surface.h:16
clock_t deadline
Definition surface.h:17
void surface_get_info(surface_t *surface, surface_info_t *info)
Definition surface.c:63
_PUBLIC time_t time(time_t *timer)
Definition time.c:5