42 fd_t fd =
open(
F(
"/net/local/%s/accept:nonblock",
id));
68 printf(
"dwm: disconnect client\n");
86 kbd =
open(
"/dev/kbd/0/events");
93 char* name =
sreadfile(
"/dev/kbd/0/name");
96 printf(
"dwm: using keyboard '%s'\n", name);
110 printf(
"dwm: using mouse '%s'\n", name);
114 id =
sreadfile(
"/net/local/seqpacket:nonblock");
121 if (
swritefile(
F(
"/net/local/%s/ctl",
id),
"bind dwm && listen") ==
ERR)
127 data =
open(
F(
"/net/local/%s/data",
id));
168 globaEVENT_LIB.
info =
event.info;
187 if (window->
id ==
id)
208 switch (surface->
type)
224 printf(
"dwm: attach (cursor != NULL)\n");
236 printf(
"dwm: attach (wall != NULL)\n");
248 printf(
"dwm: attach (fullscreen != NULL)\n");
259 printf(
"dwm: attach (default)\n");
273 if (surface ==
focus)
286 switch (surface->
type)
316 printf(
"dwm: attempt to detach invalid surface\n");
329 if (surface ==
focus)
454 printf(
"dwm: failed to read kbd event\n");
465 event.mods = kbdEvent.
mods;
466 event.code = kbdEvent.
code;
505 .delta = cursorDelta,
520 .delta = cursorDelta,
541 destSurface = surface;
544 if (destSurface !=
NULL)
549 .released = released,
553 .delta = cursorDelta,
570 bool received =
false;
581 printf(
"dwm: failed to read mouse event\n");
604 printf(
"dwm: failed to realloc pollCtx\n");
692 printf(
"dwm: client %d hung up\n", client->
fd);
697 printf(
"dwm: client %d error\n", client->
fd);
uint64_t client_receive_cmds(client_t *client)
void client_free(client_t *client)
uint64_t client_send_event(client_t *client, surface_id_t target, event_type_t type, void *data, uint64_t size)
client_t * client_new(fd_t fd)
void compositor_invalidate(const rect_t *rect)
void compositor_draw(compositor_ctx_t *ctx)
static uint64_t clientAmount
static void dwm_update(void)
static surface_t * cursor
static void dwm_handle_mouse_event(const mouse_event_t *mouseEvent)
static poll_ctx_t * pollCtx
static void dwm_client_disconnect(client_t *client)
static surface_t * fullscreen
static surface_t * dwm_next_timer(void)
static void dwm_mouse_read(void)
static void dwm_send_event_to_all(surface_id_t target, event_type_t type, void *data, uint64_t size)
static client_t * dwm_client_accept(void)
static surface_t * prevCursorTarget
static surface_t * dwm_surface_under_point(const point_t *point)
static void dwm_kbd_read(void)
static void dwm_poll(void)
static void dwm_poll_ctx_update(void)
#define EVENT_GLOBAL_REPORT
#define EVENT_GLOBAL_ATTACH
#define EVENT_GLOBAL_DETACH
#define EVENT_CURSOR_LEAVE
report_flags_t
Report flags.
#define EVENT_CURSOR_ENTER
#define EVENT_GLOBAL_MOUSE
uint16_t event_type_t
Event type.
#define EINVAL
Invalid argument.
#define EALREADY
Operation already in progress.
#define errno
Error number variable.
fd_t open(const char *path)
System call for opening files.
poll_events_t poll1(fd_t fd, poll_events_t events, clock_t timeout)
Wrapper for polling one file.
uint64_t close(fd_t fd)
System call for closing files.
#define F(format,...)
Format string macro.
uint64_t swritefile(const char *path, const char *string)
Wrapper for writing a null-terminated string directly to a file using a path.
uint64_t poll(pollfd_t *fds, uint64_t amount, clock_t timeout)
System call for polling files.
uint64_t read(fd_t fd, void *buffer, uint64_t count)
System call for reading from files.
char * sreadfile(const char *path)
Wrapper for reading an entire file directly into a null-terminated string.
@ POLLIN
File descriptor is ready to read.
@ POLLHUP
Stream socket peer closed connection, or shut down writing of connection.
@ POLLERR
File descriptor caused an error.
#define LIST_FOR_EACH(elem, list, member)
Iterates over a list.
static void list_push_back(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
#define LIST_FOR_EACH_SAFE(elem, temp, list, member)
Safely iterates over a list, allowing for element removal during iteration.
static void list_remove(list_t *list, list_entry_t *entry)
Removes a list entry from its current list.
#define LIST_FOR_EACH_REVERSE(elem, list, member)
Iterates over a list in reverse.
static void list_init(list_t *list)
Initializes a list.
#define CLAMP(x, low, high)
mouse_buttons_t
Mouse buttons enum.
clock_t uptime(void)
System call for retreving the time since boot.
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ fd_t
A file descriptor.
__UINT64_TYPE__ clock_t
A nanosecond time.
void dwm_focus_set(surface_t *surface)
uint64_t dwm_attach(surface_t *surface)
void dwm_report_produce(surface_t *surface, client_t *client, report_flags_t flags)
void dwm_detach(surface_t *surface)
surface_t * dwm_surface_find(surface_id_t id)
static const path_flag_t flags[]
char kbd_ascii(keycode_t code, kbd_mods_t mods)
#define RECT_CONTAINS_POINT(rect, point)
uint64_t screen_height(void)
uint64_t screen_width(void)
#define SURFACE_SCREEN_RECT(surface)
_PUBLIC int printf(const char *_RESTRICT format,...)
_PUBLIC void * realloc(void *ptr, size_t size)
_PUBLIC _NORETURN void abort(void)
_PUBLIC void free(void *ptr)
_PUBLIC char * strerror(int errnum)
Keyboard event structure.
kbd_event_type_t type
Type of keyboard event (press or release)
keycode_t code
Keycode of the key involved in the event.
kbd_mods_t mods
Active keyboard modifiers.
mouse_buttons_t buttons
Which buttons were held down durring the event.
int64_t deltaY
Change in Y coordinate.
int64_t deltaX
Change in X coordinate.
Poll file descriptor structure.
poll_events_t revents
The events that occurred.
poll_events_t events
The events to wait for.
fd_t fd
The file descriptor to poll.
void surface_get_info(surface_t *surface, surface_info_t *info)
_PUBLIC time_t time(time_t *timer)