diff --git a/view.c b/view.c index 19ae2ad..e2856a4 100644 --- a/view.c +++ b/view.c @@ -51,10 +51,9 @@ view_get_prev_view(struct cg_view *view) { void view_damage_child(struct cg_view_child *child, bool whole) { - int x, y; - child->get_coords(child, &x, &y); - output_damage_surface(child->view->workspace->output, child->wlr_surface, - x + child->view->ox, y + child->view->oy, whole); + if(child->view != NULL) { + view_damage_part(child->view); + } } static void @@ -138,30 +137,6 @@ subsurface_handle_destroy(struct wl_listener *listener, void *_data) { subsurface_destroy(view_child); } -static void -subsurface_get_coords(struct cg_view_child *child, int *x, int *y) { - struct wlr_surface *surface = child->wlr_surface; - *x = *y = 0; - - if(child->parent && child->parent->get_coords) { - int sx, sy; - child->parent->get_coords(child->parent, &sx, &sy); - *x += sx; - *y += sy; - } else { - while(surface && wlr_surface_is_subsurface(surface)) { - struct wlr_subsurface *subsurface = - wlr_subsurface_from_wlr_surface(surface); - if(subsurface == NULL) { - break; - } - *x += subsurface->current.x; - *y += subsurface->current.y; - surface = subsurface->parent; - } - } -} - static void subsurface_create(struct cg_view_child *parent, struct cg_view *view, struct wlr_subsurface *wlr_subsurface) { @@ -173,7 +148,6 @@ subsurface_create(struct cg_view_child *parent, struct cg_view *view, view_child_init(&subsurface->view_child, parent, view, wlr_subsurface->surface); subsurface->view_child.destroy = subsurface_destroy; - subsurface->view_child.get_coords = subsurface_get_coords; subsurface->wlr_subsurface = wlr_subsurface; subsurface->destroy.notify = subsurface_handle_destroy; @@ -279,6 +253,11 @@ view_unmap(struct cg_view *view) { if(view->wlr_surface == NULL) { return; } + + struct cg_view_child *child, *tmp; + wl_list_for_each_safe(child, tmp, &view->children, link) { + child->destroy(child); + } #if CG_HAS_XWAYLAND if((view->type != CG_XWAYLAND_VIEW || xwayland_view_should_manage(view))) #endif @@ -323,11 +302,6 @@ view_unmap(struct cg_view *view) { wl_list_remove(&view->new_subsurface.link); view->wlr_surface = NULL; - - struct cg_view_child *child, *tmp; - wl_list_for_each_safe(child, tmp, &view->children, link) { - child->destroy(child); - } } void diff --git a/view.h b/view.h index add26b0..62a1f32 100644 --- a/view.h +++ b/view.h @@ -62,7 +62,6 @@ struct cg_view_child { struct wl_listener new_subsurface; void (*destroy)(struct cg_view_child *child); - void (*get_coords)(struct cg_view_child *child, int *x, int *y); }; struct cg_subsurface { diff --git a/xdg_shell.c b/xdg_shell.c index 0e76dc4..d703db5 100644 --- a/xdg_shell.c +++ b/xdg_shell.c @@ -119,22 +119,6 @@ popup_unconstrain(struct cg_xdg_popup *popup) { wlr_xdg_popup_unconstrain_from_box(popup->wlr_popup, &output_toplevel_box); } -static void -xdg_popup_get_coords(struct cg_view_child *child, int *x, int *y) { - if(!child) { - return; - } - struct cg_xdg_popup *popup = (struct cg_xdg_popup *)child; - struct wlr_xdg_surface *surface = popup->wlr_popup->base; - - int x_offset = -surface->geometry.x; - int y_offset = -surface->geometry.y; - - wlr_xdg_popup_get_toplevel_coords( - surface->popup, x_offset + surface->popup->geometry.x, - y_offset + surface->popup->geometry.y, x, y); -} - static void xdg_popup_create(struct cg_view *view, struct wlr_xdg_popup *wlr_popup) { struct cg_xdg_popup *popup = calloc(1, sizeof(struct cg_xdg_popup)); @@ -143,7 +127,6 @@ xdg_popup_create(struct cg_view *view, struct wlr_xdg_popup *wlr_popup) { } popup->wlr_popup = wlr_popup; - popup->view_child.get_coords = xdg_popup_get_coords; view_child_init(&popup->view_child, NULL, view, wlr_popup->base->surface); popup->view_child.destroy = xdg_popup_destroy; popup->destroy.notify = handle_xdg_popup_destroy;