Handle wlr_surface->events.new_subsurface

Add view-child.c, xdg-popup.c, subsurface.c in order to track damage
associated with new XDG subsurfaces.
This commit is contained in:
Johan Malm 2021-03-02 20:37:23 +00:00
parent 15a7910a02
commit d54a998dd8
7 changed files with 196 additions and 78 deletions

34
src/subsurface.c Normal file
View file

@ -0,0 +1,34 @@
/*
* Copyright (C) 2020 the sway authors
* This file is only needed in support of tracking damage
*/
#include "labwc.h"
static void
subsurface_handle_destroy(struct wl_listener *listener, void *data)
{
struct view_subsurface *subsurface = wl_container_of(listener,
subsurface, destroy);
struct view_child *view_child = (struct view_child *)subsurface;
if (!view_child) {
return;
}
wl_list_remove(&subsurface->destroy.link);
view_child_finish(&subsurface->view_child);
free(subsurface);
}
void
subsurface_create(struct view *view, struct wlr_subsurface *wlr_subsurface)
{
struct view_subsurface *subsurface = calloc(1, sizeof(struct view_subsurface));
if (!subsurface) {
return;
}
view_child_init(&subsurface->view_child, view, wlr_subsurface->surface);
subsurface->subsurface = wlr_subsurface;
subsurface->destroy.notify = subsurface_handle_destroy;
wl_signal_add(&wlr_subsurface->events.destroy, &subsurface->destroy);
}