diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2020-05-03 11:37:44 -0500 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2020-05-03 11:37:44 -0500 |
commit | 1b87831e00181cfc83a5f6eb3d60b8a2d83ace8e (patch) | |
tree | 654e910cf3211c649e77bf3e8a626e07442cfed2 | |
parent | f7d2524435af54f0a46eddfec95d7a2dd2ad72d6 (diff) |
inline xytosurface
-rw-r--r-- | dwl.c | 36 |
1 files changed, 9 insertions, 27 deletions
@@ -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[]) { |