diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 11ac74c9..5f02d0d6 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -183,7 +183,7 @@ struct sway_xwayland_unmanaged { struct sway_view_child; struct sway_view_child_impl { - void (*get_root_coords)(struct sway_view_child *child, int *sx, int *sy); + void (*get_view_coords)(struct sway_view_child *child, int *sx, int *sy); void (*destroy)(struct sway_view_child *child); }; diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 1f70b193..a97ee8be 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c @@ -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, }; diff --git a/sway/tree/view.c b/sway/tree/view.c index 1ee00f8d..ccb03088 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -901,30 +901,19 @@ void view_center_surface(struct sway_view *view) { static const struct sway_view_child_impl subsurface_impl; -static void subsurface_get_root_coords(struct sway_view_child *child, - int *root_sx, int *root_sy) { +static void subsurface_get_view_coords(struct sway_view_child *child, + int *sx, int *sy) { struct wlr_surface *surface = child->surface; - *root_sx = -child->view->geometry.x; - *root_sy = -child->view->geometry.y; - if (child->parent && child->parent->impl && - child->parent->impl->get_root_coords) { - int sx, sy; - child->parent->impl->get_root_coords(child->parent, &sx, &sy); - *root_sx += sx; - *root_sy += sy; + child->parent->impl->get_view_coords) { + child->parent->impl->get_view_coords(child->parent, sx, sy); } else { - while (surface && wlr_surface_is_subsurface(surface)) { - struct wlr_subsurface *subsurface = - wlr_subsurface_from_wlr_surface(surface); - if (subsurface == NULL) { - break; - } - *root_sx += subsurface->current.x; - *root_sy += subsurface->current.y; - surface = subsurface->parent; - } + *sx = *sy = 0; } + struct wlr_subsurface *subsurface = + wlr_subsurface_from_wlr_surface(surface); + *sx += subsurface->current.x; + *sy += subsurface->current.y; } static void subsurface_destroy(struct sway_view_child *child) { @@ -938,7 +927,7 @@ static void subsurface_destroy(struct sway_view_child *child) { } static const struct sway_view_child_impl subsurface_impl = { - .get_root_coords = subsurface_get_root_coords, + .get_view_coords = subsurface_get_view_coords, .destroy = subsurface_destroy, }; @@ -1007,10 +996,12 @@ static void view_child_damage(struct sway_view_child *child, bool whole) { return; } int sx, sy; - child->impl->get_root_coords(child, &sx, &sy); + child->impl->get_view_coords(child, &sx, &sy); desktop_damage_surface(child->surface, - child->view->container->pending.content_x + sx, - child->view->container->pending.content_y + sy, whole); + child->view->container->pending.content_x - + child->view->geometry.x + sx, + child->view->container->pending.content_y - + child->view->geometry.y + sy, whole); } static void view_child_handle_surface_commit(struct wl_listener *listener,