aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/wm/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/wm/client.c')
-rw-r--r--sys/cmd/wm/client.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/sys/cmd/wm/client.c b/sys/cmd/wm/client.c
index 33dfcb1..2a8c0c0 100644
--- a/sys/cmd/wm/client.c
+++ b/sys/cmd/wm/client.c
@@ -9,8 +9,8 @@ focus(Client *client, struct wlr_surface *new)
struct wlr_keyboard *keyboard;
if(client) {
- wl_list_remove(&client->link);
- wl_list_insert(&server.clients, &client->link);
+ wl_list_remove(&client->stack);
+ wl_list_insert(&server.client.stack, &client->stack);
}
seat = server.input.seat;
@@ -61,7 +61,7 @@ Client*
client_at(double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
{
Client *it;
- wl_list_for_each(it, &server.clients, link) {
+ wl_list_for_each(it, &server.client.list, link) {
if(client_has(it, lx, ly, surface, sx, sy))
return it;
}
@@ -100,3 +100,38 @@ setinteractive(Client *client, int mode, uint32 edges) {
server.resize = edges;
}
}
+
+static
+void
+apply_bounds(Client *client, struct wlr_box *box)
+{
+ client->geo.width = MAX(1, client->geo.width);
+ client->geo.height = MAX(1, client->geo.height);
+
+ if(client->geo.x >= box->x + box->width)
+ client->geo.x = box->x + box->width - client->geo.width;
+ if(client->geo.y >= box->y + box->height)
+ client->geo.y = box->y + box->height - client->geo.height;
+ if(client->geo.x + client->geo.width + 2*client->border <= box->x)
+ client->geo.x = box->x;
+ if(client->geo.y + client->geo.height + 2*client->border <= box->y)
+ client->geo.y = box->y;
+}
+
+void
+resize(Client *client, int x, int y, int w, int h, int interact)
+{
+ struct wlr_box *box = interact ? &server.monitor.geometry : &client->monitor->window;
+
+ client->geo.x = x;
+ client->geo.y = y;
+ client->geo.width = w;
+ client->geo.height = h;
+
+ apply_bounds(client, box);
+
+ client->resize = wlr_xdg_toplevel_set_size(client->xdg,
+ client->geo.width - 2*client->border,
+ client->geo.height - 2*client->border
+ );
+}