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.c69
1 files changed, 62 insertions, 7 deletions
diff --git a/sys/cmd/wm/client.c b/sys/cmd/wm/client.c
index 3139367..abd5054 100644
--- a/sys/cmd/wm/client.c
+++ b/sys/cmd/wm/client.c
@@ -5,22 +5,60 @@ static char broken[] = "broken";
// -----------------------------------------------------------------------
// scripts
-void *
+static inline
+void
+grab_client(void)
+{
+ if(server.cursor.mode != CursorNormal)
+ return;
+ if(!(server.grab.client = client_at(server.cursor.dot->x, server.cursor.dot->y)))
+ return;
+
+ floating(server.grab.client, 1);
+}
+
+void
move_client(Arg *arg)
{
- return nil;
+ grab_client();
+ server.cursor.mode = CursorMove;
+
+ server.grab.x = server.cursor.dot->x - server.grab.client->geometry.x;
+ server.grab.y = server.cursor.dot->y - server.grab.client->geometry.y;
+ wlr_xcursor_manager_set_cursor_image(server.cursor.manager, "fleur", server.cursor.dot);
}
-void *
+void
float_client(Arg *arg)
{
- return nil;
+ Client *client = selected_client();
+ wlr_log(WLR_DEBUG, "client selected = %lx", (uintptr)client);
+ if(!client)
+ return;
+
+ floating(client, client->isfloating ? 0 : 1);
}
-void *
+void
resize_client(Arg *arg)
{
- return nil;
+ double x, y;
+ struct wlr_box geometry;
+
+ grab_client();
+ server.cursor.mode = CursorResize;
+
+ wlr_xdg_surface_get_geometry(server.grab.client->xdg, &geometry);
+
+ x = server.grab.client->geometry.x + geometry.x + geometry.width;
+ y = server.grab.client->geometry.y + geometry.y + geometry.height;
+
+ server.grab.x = server.cursor.dot->x - x;
+ server.grab.y = server.cursor.dot->y - y;
+
+ server.grab.box = geometry;
+ server.grab.box.x += server.grab.client->geometry.x;
+ server.grab.box.y += server.grab.client->geometry.y;
}
// -----------------------------------------------------------------------
@@ -75,7 +113,7 @@ Client*
client_at(double x, double y)
{
Client *client;
- wl_list_for_each(client, &server.client.list, link)
+ wl_list_for_each(client, &server.client.stack, stack)
if(VISIBLE_ON(client, client->monitor) && wlr_box_contains_point(&client->geometry, x, y))
return client;
return nil;
@@ -196,3 +234,20 @@ rules(Client *client)
attach(client, monitor, tags);
}
+
+void
+floating(Client *client, int state)
+{
+ wlr_log(WLR_DEBUG, "client %lx, floating = %d", (uintptr)client, state);
+ client->isfloating = state;
+ arrange(client->monitor);
+}
+
+Client *
+selected_client(void)
+{
+ Client *client = wl_container_of(server.client.focus.next, client, focus);
+ if(wl_list_empty(&server.client.focus) || !VISIBLE_ON(client, server.monitor.selected))
+ return nil;
+ return client;
+}