diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-10-03 15:57:43 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-10-03 15:57:43 -0400 |
commit | 4c9807d3a68688ee0d6f96e3fc2a60f5edcca857 (patch) | |
tree | c3da92a2dad7945cf9f6e2331f85808d39bf52f1 | |
parent | f9379f9a4694a769c75a7647f05986f38d62f0f1 (diff) |
rootston-desktop: popup input handling
-rw-r--r-- | rootston/desktop.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c index 9781581e..2c4611a8 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -93,6 +93,36 @@ static struct wlr_subsurface *subsurface_at(struct wlr_surface *surface, return NULL; } +static struct wlr_xdg_surface_v6 *xdg_v6_popup_at( + struct wlr_xdg_surface_v6 *surface, double sx, double sy, + double *popup_sx, double *popup_sy) { + struct wlr_xdg_surface_v6 *popup; + wl_list_for_each(popup, &surface->popups, popup_link) { + double _popup_sx = surface->geometry->x + popup->popup_state->geometry.x; + double _popup_sy = surface->geometry->y + popup->popup_state->geometry.y; + int popup_width = popup->popup_state->geometry.width; + int popup_height = popup->popup_state->geometry.height; + + struct wlr_xdg_surface_v6 *_popup = + xdg_v6_popup_at(popup, sx - _popup_sx + popup->geometry->x, + sy - _popup_sy + popup->geometry->y, popup_sx, popup_sy); + if (_popup) { + *popup_sx = *popup_sx + _popup_sx - popup->geometry->x; + *popup_sy = *popup_sy + _popup_sy - popup->geometry->y; + return _popup; + } + + if ((sx > _popup_sx && sx < _popup_sx + popup_width) && + (sy > _popup_sy && sy < _popup_sy + popup_height)) { + *popup_sx = _popup_sx - popup->geometry->x; + *popup_sy = _popup_sy - popup->geometry->y; + return popup; + } + } + + return NULL; +} + struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { for (int i = desktop->views->length - 1; i >= 0; --i) { @@ -101,6 +131,20 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, double view_sx = lx - view->x; double view_sy = ly - view->y; + if (view->type == ROOTS_XDG_SHELL_V6_VIEW) { + double popup_sx, popup_sy; + struct wlr_xdg_surface_v6 *popup = + xdg_v6_popup_at(view->xdg_surface_v6, view_sx, view_sy, + &popup_sx, &popup_sy); + + if (popup) { + *sx = view_sx - popup_sx; + *sy = view_sy - popup_sy; + *surface = popup->surface; + return view; + } + } + double sub_x, sub_y; struct wlr_subsurface *subsurface = subsurface_at(view->wlr_surface, view_sx, view_sy, &sub_x, &sub_y); |