mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-23 05:15:58 +01:00
rootston-desktop: popup input handling
This commit is contained in:
parent
f9379f9a46
commit
4c9807d3a6
1 changed files with 44 additions and 0 deletions
|
@ -93,6 +93,36 @@ static struct wlr_subsurface *subsurface_at(struct wlr_surface *surface,
|
||||||
return NULL;
|
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 roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
||||||
struct wlr_surface **surface, double *sx, double *sy) {
|
struct wlr_surface **surface, double *sx, double *sy) {
|
||||||
for (int i = desktop->views->length - 1; i >= 0; --i) {
|
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_sx = lx - view->x;
|
||||||
double view_sy = ly - view->y;
|
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;
|
double sub_x, sub_y;
|
||||||
struct wlr_subsurface *subsurface =
|
struct wlr_subsurface *subsurface =
|
||||||
subsurface_at(view->wlr_surface, view_sx, view_sy, &sub_x, &sub_y);
|
subsurface_at(view->wlr_surface, view_sx, view_sy, &sub_x, &sub_y);
|
||||||
|
|
Loading…
Reference in a new issue