surface: add wlr_surface new_subsurface and wlr_subsurface destroy events

master
emersion 7 years ago
parent c6aab6f56c
commit eeffe11337
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

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

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

@ -35,7 +35,7 @@ static void wl_compositor_create_surface(struct wl_client *client,
wl_list_insert(&compositor->surfaces, wl_list_insert(&compositor->surfaces,
wl_resource_get_link(surface_resource)); 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, 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->wl_resources);
wl_list_init(&compositor->surfaces); 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; compositor->display_destroy.notify = handle_display_destroy;
wl_display_add_destroy_listener(display, &compositor->display_destroy); wl_display_add_destroy_listener(display, &compositor->display_destroy);

@ -468,7 +468,6 @@ static void wlr_subsurface_parent_commit(struct wlr_subsurface *subsurface,
bool synchronized) { bool synchronized) {
struct wlr_surface *surface = subsurface->surface; struct wlr_surface *surface = subsurface->surface;
if (synchronized || subsurface->synchronized) { if (synchronized || subsurface->synchronized) {
if (subsurface->has_cache) { if (subsurface->has_cache) {
wlr_surface_move_state(surface, subsurface->cached, surface->pending); wlr_surface_move_state(surface, subsurface->cached, surface->pending);
wlr_surface_commit_pending(surface); 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) { void wlr_subsurface_destroy(struct wlr_subsurface *subsurface) {
wl_signal_emit(&subsurface->events.destroy, subsurface);
wlr_surface_state_destroy(subsurface->cached); wlr_surface_state_destroy(subsurface->cached);
if (subsurface->parent) { 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.commit);
wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.destroy);
wl_signal_init(&surface->events.new_subsurface);
wl_list_init(&surface->subsurface_list); wl_list_init(&surface->subsurface_list);
wl_list_init(&surface->subsurface_pending_list); wl_list_init(&surface->subsurface_pending_list);
wl_resource_set_implementation(res, &surface_interface, 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 wl_resource *resource, struct wl_resource *sibling_resource) {
struct wlr_subsurface *subsurface = wl_resource_get_user_data(resource); struct wlr_subsurface *subsurface = wl_resource_get_user_data(resource);
if (!subsurface) {
return;
}
struct wlr_surface *sibling_surface = struct wlr_surface *sibling_surface =
wl_resource_get_user_data(sibling_resource); wl_resource_get_user_data(sibling_resource);
struct wlr_subsurface *sibling = struct wlr_subsurface *sibling =
@ -849,6 +847,7 @@ void wlr_surface_make_subsurface(struct wlr_surface *surface,
} }
subsurface->synchronized = true; subsurface->synchronized = true;
subsurface->surface = surface; subsurface->surface = surface;
wl_signal_init(&subsurface->events.destroy);
// link parent // link parent
subsurface->parent = parent; subsurface->parent = parent;
@ -874,6 +873,8 @@ void wlr_surface_make_subsurface(struct wlr_surface *surface,
subsurface_resource_destroy); subsurface_resource_destroy);
surface->subsurface = subsurface; surface->subsurface = subsurface;
wl_signal_emit(&parent->events.new_subsurface, subsurface);
} }

@ -1406,7 +1406,7 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
xwm_selection_init(xwm); xwm_selection_init(xwm);
xwm->compositor_surface_create.notify = handle_compositor_surface_create; 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->compositor_surface_create);
xwm_create_wm_window(xwm); xwm_create_wm_window(xwm);

Loading…
Cancel
Save