summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dwl.c36
1 files changed, 9 insertions, 27 deletions
diff --git a/dwl.c b/dwl.c
index 2d03cbc..c07d1c7 100644
--- a/dwl.c
+++ b/dwl.c
@@ -186,8 +186,6 @@ static void unmapnotify(struct wl_listener *listener, void *data);
static void view(const Arg *arg);
static Client *xytoclient(double x, double y);
static Monitor *xytomon(double x, double y);
-static Client *xytosurface(double x, double y,
- struct wlr_surface **surface, double *sx, double *sy);
/* variables */
static const char broken[] = "broken";
@@ -319,9 +317,12 @@ buttonpress(struct wl_listener *listener, void *data)
switch (event->state) {
case WLR_BUTTON_PRESSED:;
/* Change focus if the button was _pressed_ over a client */
- c = xytosurface(cursor->x, cursor->y, &surface, NULL, NULL);
- if (c)
+ if ((c = xytoclient(cursor->x, cursor->y))) {
+ surface = wlr_xdg_surface_surface_at(c->xdg_surface,
+ cursor->x - c->geom.x - c->bw,
+ cursor->y - c->geom.y - c->bw, NULL, NULL);
focusclient(c, surface, 1);
+ }
keyboard = wlr_seat_get_keyboard(seat);
mods = wlr_keyboard_get_modifiers(keyboard);
@@ -774,7 +775,10 @@ motionnotify(uint32_t time)
}
/* Otherwise, find the client under the pointer and send the event along. */
- c = xytosurface(cursor->x, cursor->y, &surface, &sx, &sy);
+ if ((c = xytoclient(cursor->x, cursor->y)))
+ surface = wlr_xdg_surface_surface_at(c->xdg_surface,
+ cursor->x - c->geom.x - c->bw,
+ cursor->y - c->geom.y - c->bw, &sx, &sy);
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
@@ -1415,28 +1419,6 @@ xytomon(double x, double y)
return o ? o->data : NULL;
}
-Client *
-xytosurface(double x, double y,
- struct wlr_surface **surface, double *sx, double *sy)
-{
- Client *c = xytoclient(x, y);
- /*
- * XDG toplevels may have nested surfaces, such as popup windows
- * for context menus or tooltips. This function tests if any of
- * those are underneath the coordinates x and y (in layout
- * coordinates). If so, it sets the surface pointer to that
- * wlr_surface and the sx and sy coordinates to the coordinates
- * relative to that surface's top-left corner.
- */
- /* XXX set *surface to xdg_surface->surface otherwise? what should
- * sx/sy be in that case? */
- if (c)
- *surface = wlr_xdg_surface_surface_at(c->xdg_surface,
- x - c->geom.x - c->bw,
- y - c->geom.y - c->bw, sx, sy);
- return c;
-}
-
int
main(int argc, char *argv[])
{