diff options
-rw-r--r-- | include/wlr/types/wlr_data_device.h | 1 | ||||
-rw-r--r-- | include/wlr/types/wlr_surface.h | 12 | ||||
-rw-r--r-- | include/wlr/types/wlr_wl_shell.h | 2 | ||||
-rw-r--r-- | include/wlr/types/wlr_xdg_shell_v6.h | 2 | ||||
-rw-r--r-- | include/wlr/xwayland.h | 1 | ||||
-rw-r--r-- | rootston/wl_shell.c | 2 | ||||
-rw-r--r-- | rootston/xdg_shell_v6.c | 2 | ||||
-rw-r--r-- | types/wlr_data_device.c | 13 | ||||
-rw-r--r-- | types/wlr_surface.c | 11 | ||||
-rw-r--r-- | types/wlr_wl_shell.c | 17 | ||||
-rw-r--r-- | types/wlr_xdg_shell_v6.c | 17 | ||||
-rw-r--r-- | xwayland/xwm.c | 14 |
12 files changed, 50 insertions, 44 deletions
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h index 4893bbf4..92d15972 100644 --- a/include/wlr/types/wlr_data_device.h +++ b/include/wlr/types/wlr_data_device.h @@ -73,7 +73,6 @@ struct wlr_drag_icon { } events; struct wl_listener surface_destroy; - struct wl_listener surface_commit; struct wl_listener seat_client_destroy; }; diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index c8e3761a..9f88d044 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -77,6 +77,10 @@ struct wlr_surface { struct wl_listener compositor_listener; void *compositor_data; + // surface commit callback for the role that runs before all others + void (*role_committed)(struct wlr_surface *surface, void *role_data); + void *role_data; + // subsurface properties struct wlr_subsurface *subsurface; struct wl_list subsurface_list; // wlr_subsurface::parent_link @@ -146,4 +150,12 @@ void wlr_surface_send_leave(struct wlr_surface *surface, void wlr_surface_send_frame_done(struct wlr_surface *surface, const struct timespec *when); +/** + * Set a callback for surface commit that runs before all the other callbacks. + * This is intended for use by the surface role. + */ +void wlr_surface_set_role_committed(struct wlr_surface *surface, + void (*role_committed)(struct wlr_surface *surface, void *role_data), + void *role_data); + #endif diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 29446b04..375477c7 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -70,7 +70,6 @@ struct wlr_wl_shell_surface { char *class; struct wl_listener surface_destroy_listener; - struct wl_listener surface_commit_listener; struct wlr_wl_shell_surface *parent; struct wl_list popup_link; @@ -79,7 +78,6 @@ struct wlr_wl_shell_surface { struct { struct wl_signal destroy; - struct wl_signal commit; struct wl_signal ping_timeout; struct wl_signal request_move; diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index b723a950..280bea27 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -122,10 +122,8 @@ struct wlr_xdg_surface_v6 { struct wlr_box *geometry; struct wl_listener surface_destroy_listener; - struct wl_listener surface_commit_listener; struct { - struct wl_signal commit; struct wl_signal destroy; struct wl_signal ping_timeout; diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 230cfeed..37b09204 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -134,7 +134,6 @@ struct wlr_xwayland_surface { } events; struct wl_listener surface_destroy; - struct wl_listener surface_commit; void *data; }; diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index d0aad407..7f70acae 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -150,7 +150,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { roots_surface->set_state.notify = handle_set_state; wl_signal_add(&surface->events.set_state, &roots_surface->set_state); roots_surface->surface_commit.notify = handle_surface_commit; - wl_signal_add(&surface->events.commit, &roots_surface->surface_commit); + wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit); struct roots_view *view = calloc(1, sizeof(struct roots_view)); if (!view) { diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index a0503ad8..0515263b 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -253,7 +253,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { return; } roots_surface->commit.notify = handle_commit; - wl_signal_add(&surface->events.commit, &roots_surface->commit); + wl_signal_add(&surface->surface->events.commit, &roots_surface->commit); roots_surface->destroy.notify = handle_destroy; wl_signal_add(&surface->events.destroy, &roots_surface->destroy); roots_surface->request_move.notify = handle_request_move; diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c index 51789047..af81d861 100644 --- a/types/wlr_data_device.c +++ b/types/wlr_data_device.c @@ -651,7 +651,7 @@ static void wlr_drag_icon_destroy(struct wlr_drag_icon *icon) { return; } wl_signal_emit(&icon->events.destroy, icon); - wl_list_remove(&icon->surface_commit.link); + wlr_surface_set_role_committed(icon->surface, NULL, NULL); wl_list_remove(&icon->surface_destroy.link); wl_list_remove(&icon->seat_client_destroy.link); wl_list_remove(&icon->link); @@ -665,10 +665,9 @@ static void handle_drag_icon_surface_destroy(struct wl_listener *listener, wlr_drag_icon_destroy(icon); } -static void handle_drag_icon_surface_commit(struct wl_listener *listener, - void *data) { - struct wlr_drag_icon *icon = - wl_container_of(listener, icon, surface_commit); +static void handle_drag_icon_surface_commit(struct wlr_surface *surface, + void *role_data) { + struct wlr_drag_icon *icon = role_data; icon->sx += icon->surface->current->sx; icon->sy += icon->surface->current->sy; } @@ -701,8 +700,8 @@ static struct wlr_drag_icon *wlr_drag_icon_create( wl_signal_add(&icon->surface->events.destroy, &icon->surface_destroy); icon->surface_destroy.notify = handle_drag_icon_surface_destroy; - wl_signal_add(&icon->surface->events.commit, &icon->surface_commit); - icon->surface_commit.notify = handle_drag_icon_surface_commit; + wlr_surface_set_role_committed(icon->surface, + handle_drag_icon_surface_commit, icon); wl_signal_add(&client->events.destroy, &icon->seat_client_destroy); icon->seat_client_destroy.notify = handle_drag_icon_seat_client_destroy; diff --git a/types/wlr_surface.c b/types/wlr_surface.c index ad0c6f68..8e024177 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -428,6 +428,10 @@ static void wlr_surface_commit_pending(struct wlr_surface *surface) { } } + if (surface->role_committed) { + surface->role_committed(surface, surface->role_data); + } + // TODO: add the invalid bitfield to this callback wl_signal_emit(&surface->events.commit, surface); } @@ -943,3 +947,10 @@ void wlr_surface_send_frame_done(struct wlr_surface *surface, wl_resource_destroy(cb->resource); } } + +void wlr_surface_set_role_committed(struct wlr_surface *surface, + void (*role_committed)(struct wlr_surface *surface, void *role_data), + void *role_data) { + surface->role_committed = role_committed; + surface->role_data = role_data; +} diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 5476ddb6..a13717c1 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -418,7 +418,7 @@ static void shell_surface_destroy(struct wlr_wl_shell_surface *surface) { wl_list_remove(&surface->link); wl_list_remove(&surface->surface_destroy_listener.link); - wl_list_remove(&surface->surface_commit_listener.link); + wlr_surface_set_role_committed(surface->surface, NULL, NULL); wl_event_source_remove(surface->ping_timer); free(surface->transient_state); free(surface->title); @@ -439,10 +439,9 @@ static void handle_wlr_surface_destroyed(struct wl_listener *listener, wl_container_of(listener, surface, surface_destroy_listener); shell_surface_destroy(surface); } -static void handle_wlr_surface_committed(struct wl_listener *listener, - void *data) { - struct wlr_wl_shell_surface *surface = - wl_container_of(listener, surface, surface_commit_listener); +static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface, + void *role_data) { + struct wlr_wl_shell_surface *surface = role_data; if (!surface->configured && wlr_surface_has_buffer(surface->surface) && surface->state != WLR_WL_SHELL_SURFACE_STATE_NONE) { @@ -459,8 +458,6 @@ static void handle_wlr_surface_committed(struct wl_listener *listener, surface->popup_state->seat); shell_pointer_grab_maybe_end(&grab->pointer_grab); } - - wl_signal_emit(&surface->events.commit, surface); } static int shell_surface_ping_timeout(void *user_data) { @@ -511,7 +508,6 @@ static void shell_protocol_get_shell_surface(struct wl_client *client, wl_surface->resource); wl_signal_init(&wl_surface->events.destroy); - wl_signal_init(&wl_surface->events.commit); wl_signal_init(&wl_surface->events.ping_timeout); wl_signal_init(&wl_surface->events.request_move); wl_signal_init(&wl_surface->events.request_resize); @@ -525,9 +521,8 @@ static void shell_protocol_get_shell_surface(struct wl_client *client, &wl_surface->surface_destroy_listener); wl_surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed; - wl_signal_add(&wl_surface->surface->events.commit, - &wl_surface->surface_commit_listener); - wl_surface->surface_commit_listener.notify = handle_wlr_surface_committed; + wlr_surface_set_role_committed(surface, handle_wlr_surface_committed, + wl_surface); struct wl_display *display = wl_client_get_display(client); struct wl_event_loop *loop = wl_display_get_event_loop(display); diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index e288883d..09675a7b 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -210,7 +210,7 @@ static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) { wl_resource_set_user_data(surface->resource, NULL); wl_list_remove(&surface->link); wl_list_remove(&surface->surface_destroy_listener.link); - wl_list_remove(&surface->surface_commit_listener.link); + wlr_surface_set_role_committed(surface->surface, NULL, NULL); free(surface->geometry); free(surface->next_geometry); free(surface->title); @@ -1048,10 +1048,9 @@ static void wlr_xdg_surface_v6_popup_committed( } } -static void handle_wlr_surface_committed(struct wl_listener *listener, - void *data) { - struct wlr_xdg_surface_v6 *surface = - wl_container_of(listener, surface, surface_commit_listener); +static void handle_wlr_surface_committed(struct wlr_surface *wlr_surface, + void *role_data) { + struct wlr_xdg_surface_v6 *surface = role_data; if (wlr_surface_has_buffer(surface->surface) && !surface->configured) { wl_resource_post_error(surface->resource, @@ -1086,8 +1085,6 @@ static void handle_wlr_surface_committed(struct wl_listener *listener, surface->added = true; wl_signal_emit(&surface->client->shell->events.new_surface, surface); } - - wl_signal_emit(&surface->events.commit, surface); } static void xdg_shell_get_xdg_surface(struct wl_client *wl_client, @@ -1149,7 +1146,6 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client, wl_signal_init(&surface->events.request_move); wl_signal_init(&surface->events.request_resize); wl_signal_init(&surface->events.request_show_window_menu); - wl_signal_init(&surface->events.commit); wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.ping_timeout); @@ -1157,9 +1153,8 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client, &surface->surface_destroy_listener); surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed; - wl_signal_add(&surface->surface->events.commit, - &surface->surface_commit_listener); - surface->surface_commit_listener.notify = handle_wlr_surface_committed; + wlr_surface_set_role_committed(surface->surface, + handle_wlr_surface_committed, surface); wlr_log(L_DEBUG, "new xdg_surface %p (res %p)", surface, surface->resource); wl_resource_set_implementation(surface->resource, diff --git a/xwayland/xwm.c b/xwayland/xwm.c index f7ea879d..d9bfaf2e 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -222,7 +222,7 @@ static void wlr_xwayland_surface_destroy( if (xsurface->surface) { wl_list_remove(&xsurface->surface_destroy.link); - wl_list_remove(&xsurface->surface_commit.link); + wlr_surface_set_role_committed(xsurface->surface, NULL, NULL); } free(xsurface->title); @@ -517,9 +517,9 @@ static void read_surface_property(struct wlr_xwm *xwm, free(reply); } -static void handle_surface_commit(struct wl_listener *listener, void *data) { - struct wlr_xwayland_surface *xsurface = - wl_container_of(listener, xsurface, surface_commit); +static void handle_surface_commit(struct wlr_surface *wlr_surface, + void *role_data) { + struct wlr_xwayland_surface *xsurface = role_data; if (!xsurface->added && wlr_surface_has_buffer(xsurface->surface) && @@ -560,8 +560,8 @@ static void xwm_map_shell_surface(struct wlr_xwm *xwm, read_surface_property(xwm, xsurface, props[i]); } - xsurface->surface_commit.notify = handle_surface_commit; - wl_signal_add(&surface->events.commit, &xsurface->surface_commit); + wlr_surface_set_role_committed(xsurface->surface, handle_surface_commit, + xsurface); xsurface->surface_destroy.notify = handle_surface_destroy; wl_signal_add(&surface->events.destroy, &xsurface->surface_destroy); @@ -692,7 +692,7 @@ static void xwm_handle_unmap_notify(struct wlr_xwm *xwm, } if (xsurface->surface) { - wl_list_remove(&xsurface->surface_commit.link); + wlr_surface_set_role_committed(xsurface->surface, NULL, NULL); wl_list_remove(&xsurface->surface_destroy.link); } xsurface->surface = NULL; |