diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-09-21 13:48:46 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-09-21 13:48:46 -0400 |
commit | 675a71dce789eb6aa3ba7e38ba137c9e4c6a5f07 (patch) | |
tree | b09ee14d32e8460526b16bed2b690b80e9dce2ae /examples | |
parent | 7a3edf6e6218b79e47541a0d5ebed64e094055b4 (diff) |
compositor.c: determine xdg position by window geom
Diffstat (limited to 'examples')
-rw-r--r-- | examples/compositor.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/compositor.c b/examples/compositor.c index 24013c52..7c4bed09 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -67,6 +67,7 @@ struct sample_state { struct example_xdg_surface_v6 { struct wlr_xdg_surface_v6 *surface; + // position of the wlr_surface in the layout struct { int lx; int ly; @@ -338,11 +339,14 @@ static struct wlr_xdg_surface_v6 *example_xdg_surface_at( wl_list_for_each(xdg_surface, &xdg_client->surfaces, link) { struct example_xdg_surface_v6 *esurface = xdg_surface->data; - if (sample->cursor->x >= esurface->position.lx && - sample->cursor->y >= esurface->position.ly && - sample->cursor->x <= esurface->position.lx + + double window_x = esurface->position.lx + xdg_surface->geometry->x; + double window_y = esurface->position.ly + xdg_surface->geometry->y; + + if (sample->cursor->x >= window_x && + sample->cursor->y >= window_y && + sample->cursor->x <= window_x + xdg_surface->geometry->width && - sample->cursor->y <= esurface->position.ly + + sample->cursor->y <= window_y + xdg_surface->geometry->height) { return xdg_surface; } |