From 88b8c199e3524b7c4e2667db3683c77d70f34a26 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 29 Sep 2021 10:53:41 -0700 Subject: feat(wm): working prototype --- sys/cmd/wm/client.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'sys/cmd/wm/client.c') diff --git a/sys/cmd/wm/client.c b/sys/cmd/wm/client.c index 7d828a0..33dfcb1 100644 --- a/sys/cmd/wm/client.c +++ b/sys/cmd/wm/client.c @@ -8,12 +8,15 @@ focus(Client *client, struct wlr_surface *new) struct wlr_xdg_surface *xdg; struct wlr_keyboard *keyboard; - if(!client) - return; + if(client) { + wl_list_remove(&client->link); + wl_list_insert(&server.clients, &client->link); + } seat = server.input.seat; old = seat->keyboard_state.focused_surface; - if(old == new) + + if(old==new) return; if(old) { @@ -21,20 +24,26 @@ focus(Client *client, struct wlr_surface *new) wlr_xdg_toplevel_set_activated(xdg, false); } + if(!client) { + wlr_seat_keyboard_notify_clear_focus(seat); + return; + } + keyboard = wlr_seat_get_keyboard(seat); - wl_list_remove(&client->link); - wl_list_insert(&server.clients, &client->link); + wlr_seat_keyboard_notify_enter(seat, client->xdg->surface, + keyboard->keycodes, + keyboard->num_keycodes, + &keyboard->modifiers + ); wlr_xdg_toplevel_set_activated(client->xdg, true); - wlr_seat_keyboard_notify_enter(seat, client->xdg->surface, - keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers); } int -clienthas(Client *client, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) +client_has(Client *client, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { - double x, y, vsx = lx - client->x, vsy = ly - client->y; + double x, y, vsx = lx - client->geo.x, vsy = ly - client->geo.y; struct wlr_surface *find = nil; find = wlr_xdg_surface_surface_at(client->xdg, vsx, vsy, &x, &y); @@ -49,11 +58,11 @@ clienthas(Client *client, double lx, double ly, struct wlr_surface **surface, do } Client* -clientat(double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) +client_at(double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { Client *it; wl_list_for_each(it, &server.clients, link) { - if(clienthas(it, lx, ly, surface, sx, sy)) + if(client_has(it, lx, ly, surface, sx, sy)) return it; } @@ -73,23 +82,21 @@ setinteractive(Client *client, int mode, uint32 edges) { server.cursor.mode = mode; if(mode == CursorMove) { - server.grab.x = server.cursor.dot->x - client->x; - server.grab.y = server.cursor.dot->y - client->y; + server.grab.x = server.cursor.dot->x - client->geo.x; + server.grab.y = server.cursor.dot->y - client->geo.y; } else { wlr_xdg_surface_get_geometry(client->xdg, &box); - bx = (client->x + box.x) + ((edges & WLR_EDGE_RIGHT) ? box.width : 0); - by = (client->y + box.y) + ((edges & WLR_EDGE_BOTTOM) ? box.height : 0); + bx = (client->geo.x + box.x) + ((edges & WLR_EDGE_RIGHT) ? box.width : 0); + by = (client->geo.y + box.y) + ((edges & WLR_EDGE_BOTTOM) ? box.height : 0); server.grab.x = server.cursor.dot->x - bx; server.grab.y = server.cursor.dot->y - by; server.grab.box = box; - server.grab.box.x += client->x; - server.grab.box.y += client->y; + server.grab.box.x += client->geo.x; + server.grab.box.y += client->geo.y; server.resize = edges; } } - - -- cgit v1.2.1