surface: add wlr_surface new_subsurface and wlr_subsurface destroy events

This commit is contained in:
emersion 2018-01-21 14:22:33 +01:00
parent c6aab6f56c
commit eeffe11337
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
5 changed files with 16 additions and 10 deletions

View File

@ -13,7 +13,7 @@ struct wlr_compositor {
struct wl_listener display_destroy;
struct {
struct wl_signal create_surface;
struct wl_signal new_surface;
} events;
};

View File

@ -56,6 +56,10 @@ struct wlr_subsurface {
struct wl_list parent_pending_link;
struct wl_listener parent_destroy_listener;
struct {
struct wl_signal destroy;
} events;
};
struct wlr_surface {
@ -70,6 +74,7 @@ struct wlr_surface {
struct {
struct wl_signal commit;
struct wl_signal new_subsurface;
struct wl_signal destroy;
} events;

View File

@ -35,7 +35,7 @@ static void wl_compositor_create_surface(struct wl_client *client,
wl_list_insert(&compositor->surfaces,
wl_resource_get_link(surface_resource));
wl_signal_emit(&compositor->events.create_surface, surface);
wl_signal_emit(&compositor->events.new_surface, surface);
}
static void wl_compositor_create_region(struct wl_client *client,
@ -185,7 +185,7 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display,
wl_list_init(&compositor->wl_resources);
wl_list_init(&compositor->surfaces);
wl_signal_init(&compositor->events.create_surface);
wl_signal_init(&compositor->events.new_surface);
compositor->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &compositor->display_destroy);

View File

@ -424,7 +424,7 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) {
// commit subsurface order
struct wlr_subsurface *subsurface;
wl_list_for_each_reverse(subsurface, &surface->subsurface_pending_list,
parent_pending_link) {
parent_pending_link) {
wl_list_remove(&subsurface->parent_link);
wl_list_insert(&surface->subsurface_list, &subsurface->parent_link);
@ -468,7 +468,6 @@ static void wlr_subsurface_parent_commit(struct wlr_subsurface *subsurface,
bool synchronized) {
struct wlr_surface *surface = subsurface->surface;
if (synchronized || subsurface->synchronized) {
if (subsurface->has_cache) {
wlr_surface_move_state(surface, subsurface->cached, surface->pending);
wlr_surface_commit_pending(surface);
@ -604,6 +603,8 @@ static void wlr_surface_state_destroy(struct wlr_surface_state *state) {
}
void wlr_subsurface_destroy(struct wlr_subsurface *subsurface) {
wl_signal_emit(&subsurface->events.destroy, subsurface);
wlr_surface_state_destroy(subsurface->cached);
if (subsurface->parent) {
@ -651,6 +652,7 @@ struct wlr_surface *wlr_surface_create(struct wl_resource *res,
wl_signal_init(&surface->events.commit);
wl_signal_init(&surface->events.destroy);
wl_signal_init(&surface->events.new_subsurface);
wl_list_init(&surface->subsurface_list);
wl_list_init(&surface->subsurface_pending_list);
wl_resource_set_implementation(res, &surface_interface,
@ -740,10 +742,6 @@ static void subsurface_place_above(struct wl_client *client,
struct wl_resource *resource, struct wl_resource *sibling_resource) {
struct wlr_subsurface *subsurface = wl_resource_get_user_data(resource);
if (!subsurface) {
return;
}
struct wlr_surface *sibling_surface =
wl_resource_get_user_data(sibling_resource);
struct wlr_subsurface *sibling =
@ -849,6 +847,7 @@ void wlr_surface_make_subsurface(struct wlr_surface *surface,
}
subsurface->synchronized = true;
subsurface->surface = surface;
wl_signal_init(&subsurface->events.destroy);
// link parent
subsurface->parent = parent;
@ -874,6 +873,8 @@ void wlr_surface_make_subsurface(struct wlr_surface *surface,
subsurface_resource_destroy);
surface->subsurface = subsurface;
wl_signal_emit(&parent->events.new_subsurface, subsurface);
}

View File

@ -1406,7 +1406,7 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
xwm_selection_init(xwm);
xwm->compositor_surface_create.notify = handle_compositor_surface_create;
wl_signal_add(&wlr_xwayland->compositor->events.create_surface,
wl_signal_add(&wlr_xwayland->compositor->events.new_surface,
&xwm->compositor_surface_create);
xwm_create_wm_window(xwm);