aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/wm/client.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2021-09-29 10:53:41 -0700
committerNicholas Noll <nbnoll@eml.cc>2021-09-29 10:53:41 -0700
commit88b8c199e3524b7c4e2667db3683c77d70f34a26 (patch)
treeafe6f897edf813e9cf2c9221f3eab3fee935a900 /sys/cmd/wm/client.c
parentb9a07a67b85e9192faa0e285b4419bd5ef242a03 (diff)
feat(wm): working prototype
Diffstat (limited to 'sys/cmd/wm/client.c')
-rw-r--r--sys/cmd/wm/client.c45
1 files changed, 26 insertions, 19 deletions
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;
}
}
-
-