If there isn't an actual surface under the cursor, *surface will be set to NULL, which is safe now that focus functions handle a NULL surface safely.
KD353LTTUI6LTMYDTNPH3W6NXETRKDTNB6MA64K3WBQC6GSYKPMAC
US4HQXVWZEPU6HZ7Q733QB5QXOD32HJBYHUAQTT3DZGVXBMPNNOAC
6XZIQSMIVP2GZ5S3UCKEVNDSLTHSQEVSXLV4UIFF3G3SRCGJPXYAC
CLFRYF7CROZDF4776NYUZXZ46ZJNH3AEITGA3DOCLZ2QEMMUPOLQC
7B74AT3BXYB7PVW4F6SGQNPMHOU5TEV5TZ54CG6VSQI46XSEKWXQC
XKWY25ZVEJIJU7R23CEG5CTYRAWKZ5FXSHY3ZEZRGCIWYIKQSLOAC
HHQZAOG5ZVAAVGOEGOYMX2MMMTCDGAXN2AST2MXIHF4RAEEK3MHAC
5P7UH7LLJOGQWEXISVRG2V5WNHL2CYXFJCH6RW4LPJRCL557QHTAC
Y2BB47FLZ2TQKPOULIZCKQKCCX75DT7HEPPEJOURE26OD6VD6ZUAC
L4X3HG56S4DS7QJTLMLP47BGCPF2TM5XRUFEN56BTWYJICBYUUEAC
2QL2H4REDZT46FI3LQ4RYEMQYZBNBK3IC3KH3XERAJU3NCZWMNYQC
/* XXX what if (x,y) is within a window's border? */
/* This iterates over all of our surfaces and attempts to find one under the
* cursor. This relies on stack being ordered from top-to-bottom. */
/* Find the topmost visible client (if any) under the cursor, including
* borders. This relies on stack being ordered from top to bottom. */
/* Skip clients that aren't visible */
if (!VISIBLEON(c, c->mon))
continue;
/*
* 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.
*/
double _sx, _sy;
struct wlr_surface *_surface = NULL;
_surface = wlr_xdg_surface_surface_at(c->xdg_surface,
x - c->geom.x - c->bw, y - c->geom.y - c->bw,
&_sx, &_sy);
if (_surface) {
*sx = _sx;
*sy = _sy;
*surface = _surface;
if (VISIBLEON(c, c->mon) && wlr_box_contains_point(&c->geom, 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 instead of
* NULL? what should sx/sy be in that case? */
*surface = wlr_xdg_surface_surface_at(c->xdg_surface,
x - c->geom.x - c->bw, y - c->geom.y - c->bw,
sx, sy);