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.c116
1 files changed, 55 insertions, 61 deletions
diff --git a/sys/cmd/wm/client.c b/sys/cmd/wm/client.c
index f626cfa..3139367 100644
--- a/sys/cmd/wm/client.c
+++ b/sys/cmd/wm/client.c
@@ -2,47 +2,67 @@
static char broken[] = "broken";
+// -----------------------------------------------------------------------
+// scripts
+
+void *
+move_client(Arg *arg)
+{
+ return nil;
+}
+
+void *
+float_client(Arg *arg)
+{
+ return nil;
+}
+
+void *
+resize_client(Arg *arg)
+{
+ return nil;
+}
+
+// -----------------------------------------------------------------------
+// core
+
void
focus(Client *client, int lift)
{
- struct wlr_seat *seat;
struct wlr_surface *old, *new;
struct wlr_xdg_surface *xdg;
struct wlr_keyboard *keyboard;
- new = server.input.seat->keyboard_state.focused_surface;
+ if(!client) {
+ wlr_seat_keyboard_notify_clear_focus(server.input.seat);
+ return;
+ }
+
+ old = server.input.seat->keyboard_state.focused_surface;
- if(client && lift) {
+ if(lift) {
wl_list_remove(&client->stack);
wl_list_insert(&server.client.stack, &client->stack);
}
- seat = server.input.seat;
- old = seat->keyboard_state.focused_surface;
-
+ new = client->xdg->surface;
if(old==new)
return;
- if(client) {
- wl_list_remove(&client->focus);
- wl_list_insert(&server.client.focus, &client->focus);
- server.monitor.selected = client->monitor;
- client->isurgent = 0;
- }
+ wl_list_remove(&client->focus);
+ wl_list_insert(&server.client.focus, &client->focus);
+ server.monitor.selected = client->monitor;
+ client->isurgent = 0;
+ // XXX: do we need for non-client case?
if(old) {
- xdg = wlr_xdg_surface_from_wlr_surface(seat->keyboard_state.focused_surface);
+ xdg = wlr_xdg_surface_from_wlr_surface(old);
wlr_xdg_toplevel_set_activated(xdg, false);
}
- if(!client) {
- wlr_seat_keyboard_notify_clear_focus(seat);
- return;
- }
+ keyboard = wlr_seat_get_keyboard(server.input.seat);
- keyboard = wlr_seat_get_keyboard(seat);
-
- wlr_seat_keyboard_notify_enter(seat, client->xdg->surface,
+ wlr_seat_keyboard_notify_enter(server.input.seat, new,
keyboard->keycodes,
keyboard->num_keycodes,
&keyboard->modifiers
@@ -51,8 +71,19 @@ focus(Client *client, int lift)
wlr_xdg_toplevel_set_activated(client->xdg, true);
}
+Client*
+client_at(double x, double y)
+{
+ Client *client;
+ wl_list_for_each(client, &server.client.list, link)
+ if(VISIBLE_ON(client, client->monitor) && wlr_box_contains_point(&client->geometry, x, y))
+ return client;
+ return nil;
+}
+
+static
int
-client_has(Client *client, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
+has(Client *client, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
{
double x, y, vsx = lx - client->geometry.x, vsy = ly - client->geometry.y;
struct wlr_surface *find = nil;
@@ -68,49 +99,12 @@ client_has(Client *client, double lx, double ly, struct wlr_surface **surface, d
return false;
}
-Client*
-client_at(double lx, double ly, struct wlr_surface **surface, double *sx, double *sy)
+struct wlr_surface *
+client_surface_at(Client *client, double cx, double cy, double *sx, double *sy)
{
- Client *it;
- wl_list_for_each(it, &server.client.list, link) {
- if(client_has(it, lx, ly, surface, sx, sy))
- return it;
- }
-
- return nil;
+ return wlr_xdg_surface_surface_at(client->xdg, cx, cy, sx, sy);
}
-void
-setinteractive(Client *client, int mode, uint32 edges) {
- double bx, by;
- struct wlr_box box;
- struct wlr_surface *focused = server.input.seat->pointer_state.focused_surface;
-
- if(client->xdg->surface != focused)
- return;
-
- server.grab.client = client;
- server.cursor.mode = mode;
-
- if(mode == CursorMove) {
- server.grab.x = server.cursor.dot->x - client->geometry.x;
- server.grab.y = server.cursor.dot->y - client->geometry.y;
- } else {
- wlr_xdg_surface_get_geometry(client->xdg, &box);
-
- bx = (client->geometry.x + box.x) + ((edges & WLR_EDGE_RIGHT) ? box.width : 0);
- by = (client->geometry.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->geometry.x;
- server.grab.box.y += client->geometry.y;
-
- server.resize = edges;
- }
-}
static
void