42 fd_t fd =
open(
F(
"/net/local/%s/accept:nonblock",
id));
68 printf(
"dwm: disconnect client\n");
99 kbd =
open(
"/dev/kbd/0/events:nonblock");
106 char* name =
readfiles(
"/dev/kbd/0/name");
109 printf(
"dwm: using keyboard '%s'\n", name);
113 mouse =
open(
"/dev/mouse/0/events:nonblock");
123 printf(
"dwm: using mouse '%s'\n", name);
127 id =
readfiles(
"/net/local/seqpacket:nonblock");
134 if (
writefiles(
F(
"/net/local/%s/ctl",
id),
"bind dwm && listen") ==
ERR)
140 data =
open(
F(
"/net/local/%s/data:nonblock",
id));
181 globalEvent.
info =
event.info;
200 if (window->
id ==
id)
221 switch (surface->
type)
237 printf(
"dwm: attach (cursor != NULL)\n");
249 printf(
"dwm: attach (wall != NULL)\n");
261 printf(
"dwm: attach (fullscreen != NULL)\n");
272 printf(
"dwm: attach (default)\n");
286 if (surface ==
focus)
299 switch (surface->
type)
329 printf(
"dwm: attempt to detach invalid surface\n");
342 if (surface ==
focus)
465 int result =
scan(
kbd,
"%u%c", &code, &suffix);
482 mods &= ~KBD_MOD_SHIFT;
493 mods &= ~KBD_MOD_CTRL;
504 mods &= ~KBD_MOD_ALT;
515 mods &= ~KBD_MOD_SUPER;
533 globalEvent.
type =
event.type;
534 globalEvent.
mods =
event.mods;
535 globalEvent.
code =
event.code;
536 globalEvent.
ascii =
event.ascii;
571 .delta = cursorDelta,
586 .delta = cursorDelta,
607 destSurface = surface;
610 if (destSurface !=
NULL)
615 .released = released,
619 .delta = cursorDelta,
641 if (
scan(
mouse,
"%lld%c", &value, &suffix) != 2)
659 if (
x != 0 ||
y != 0)
665 buttons |= (1 << value);
669 if (
x != 0 ||
y != 0)
675 buttons &= ~(1 << value);
679 printf(
"dwm: unknown mouse event suffix '%c'\n", suffix);
684 if (
x != 0 ||
y != 0)
695 printf(
"dwm: failed to realloc pollCtx\n");
783 printf(
"dwm: client %d hung up\n", client->
fd);
788 printf(
"dwm: client %d error\n", client->
fd);
char kbd_ascii(keycode_t code, kbd_mods_t mods)
keycode_t kbd_translate(keycode_t code)
uint64_t screen_height(void)
uint64_t screen_width(void)
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 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_handle_mouse_event(int64_t x, int64_t y, mouse_buttons_t buttons)
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
kbd_mods_t
Keyboard modifiers type.
#define EVENT_GLOBAL_MOUSE
uint16_t event_type_t
Event type.
mouse_buttons_t
Mouse buttons enum.
@ KBD_MOD_SUPER
Super (Windows/Command) modifier.
@ KBD_MOD_CAPS
Caps Lock modifier.
@ KBD_MOD_NONE
No modifier.
@ KBD_MOD_CTRL
Control modifier.
@ KBD_MOD_ALT
Alt modifier.
@ KBD_MOD_SHIFT
Shift modifier.
@ KBD_RELEASE
Key release event.
@ KBD_PRESS
Key press event.
#define EINVAL
Invalid argument.
#define EALREADY
Operation already in progress.
#define errno
Error number variable.
fd_t dup2(fd_t oldFd, fd_t newFd)
System call for duplicating file descriptors, with a destination.
fd_t open(const char *path)
System call for opening files.
size_t writefiles(const char *path, const char *string)
Wrapper for writing a null-terminated string directly to a file using a path.
uint64_t close(fd_t fd)
System call for closing files.
char * readfiles(const char *path)
Wrapper for reading an entire file directly into a null-terminated string.
#define F(format,...)
Allocates a formatted string on the stack.
uint64_t poll(pollfd_t *fds, uint64_t amount, clock_t timeout)
System call for polling files.
#define STDOUT_FILENO
Standard output file descriptor.
uint64_t scan(fd_t fd, const char *format,...)
Wrapper for reading from a file descriptor using scan formatting.
@ 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.
keycode_t
Keyboard keycode type.
@ KBD_RIGHT_SUPER
Right Super key.
@ KBD_LEFT_ALT
Left Alt key.
@ KBD_LEFT_SHIFT
Left Shift key.
@ KBD_RIGHT_SHIFT
Right Shift key.
@ KBD_LEFT_CTRL
Left Control key.
@ KBD_RIGHT_ALT
Right Alt key.
@ KBD_CAPS_LOCK
Caps Lock key.
@ KBD_RIGHT_CTRL
Right Control key.
@ KBD_LEFT_SUPER
Left Super key.
#define LIST_FOR_EACH(elem, list, member)
Iterates over a list.
static void list_remove(list_entry_t *entry)
Removes a list entry from its current 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.
#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)
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
File descriptor type.
__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[]
#define RECT_CONTAINS_POINT(rect, point)
#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)
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)