42 fd_t fd =
openf(
"/net/local/%s/accept:nonblock",
id);
68 printf(
"dwm: disconnect client\n");
92 fd_t ctl =
openf(
"/net/local/%s/ctl",
id);
117 kbd =
open(
"/dev/kbd/0/events");
127 printf(
"dwm: using keyboard '%s'\n", name);
140 printf(
"dwm: using mouse '%s'\n", name);
176 globalEvent.
flags = flags;
177 globalEvent.
info =
event.info;
196 if (window->
id ==
id)
217 switch (surface->
type)
233 printf(
"dwm: attach (cursor != NULL)\n");
245 printf(
"dwm: attach (wall != NULL)\n");
257 printf(
"dwm: attach (fullscreen != NULL)\n");
268 printf(
"dwm: attach (default)\n");
282 if (surface ==
focus)
295 switch (surface->
type)
325 printf(
"dwm: attempt to detach invalid surface\n");
338 if (surface ==
focus)
463 printf(
"dwm: failed to read kbd event\n");
474 event.mods = kbdEvent.
mods;
475 event.code = kbdEvent.
code;
514 .delta = cursorDelta,
529 .delta = cursorDelta,
550 destSurface = surface;
553 if (destSurface !=
NULL)
558 .released = released,
562 .delta = cursorDelta,
579 bool received =
false;
590 printf(
"dwm: failed to read mouse event\n");
613 printf(
"dwm: failed to realloc pollCtx\n");
701 printf(
"dwm: client %d hung up\n", client->
fd);
706 printf(
"dwm: client %d error\n", client->
fd);
#define MAX_NAME
Maximum length of names.
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_CURSOR_LEAVE
report_flags_t
Report flags.
#define EVENT_CURSOR_ENTER
uint16_t event_type_t
Event type.
#define EINVAL
Invalid argument.
#define EALREADY
Operation already in progress.
#define errno
Error number variable.
uint64_t writef(fd_t fd, const char *_RESTRICT format,...)
Wrapper for writing a formatted string to a file.
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.
uint64_t readfile(const char *path, void *buffer, uint64_t count, uint64_t offset)
Wrapper for reading a file directly using a path.
uint64_t poll(pollfd_t *fds, uint64_t amount, clock_t timeout)
System call for polling files.
fd_t openf(const char *_RESTRICT format,...)
Wrapper for opening files with a formatted path.
uint64_t read(fd_t fd, void *buffer, uint64_t count)
System call for reading from files.
@ 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.
#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.
static void list_push(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the 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)
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)
_PUBLIC void * memset(void *s, int c, size_t n)
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)