view: fix child position calc

Previously, the position was calculated incorrectly for nested
subsurfaces.
This commit is contained in:
Kirill Primak 2021-09-07 16:12:21 +03:00 committed by Simon Ser
parent adf9e16c88
commit e76e13ef85
3 changed files with 22 additions and 34 deletions

View file

@ -21,18 +21,15 @@
static const struct sway_view_child_impl popup_impl;
static void popup_get_root_coords(struct sway_view_child *child,
int *root_sx, int *root_sy) {
static void popup_get_view_coords(struct sway_view_child *child,
int *sx, int *sy) {
struct sway_xdg_popup *popup = (struct sway_xdg_popup *)child;
struct wlr_xdg_surface *surface = popup->wlr_xdg_surface;
int x_offset = -child->view->geometry.x - surface->geometry.x;
int y_offset = -child->view->geometry.y - surface->geometry.y;
wlr_xdg_popup_get_toplevel_coords(surface->popup,
x_offset + surface->popup->geometry.x,
y_offset + surface->popup->geometry.y,
root_sx, root_sy);
surface->popup->geometry.x - surface->geometry.x,
surface->popup->geometry.y - surface->geometry.y,
sx, sy);
}
static void popup_destroy(struct sway_view_child *child) {
@ -47,7 +44,7 @@ static void popup_destroy(struct sway_view_child *child) {
}
static const struct sway_view_child_impl popup_impl = {
.get_root_coords = popup_get_root_coords,
.get_view_coords = popup_get_view_coords,
.destroy = popup_destroy,
};