From 9d2dc8447a64d0f402b309af5a655ce374dad808 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Tue, 12 Sep 2017 06:18:52 -0400 Subject: use wlr_surface on shell struct and listen to events --- examples/compositor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/compositor.c b/examples/compositor.c index 995c1b7d..9d96b053 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -102,7 +102,7 @@ static void handle_output_frame(struct output_state *output, struct wlr_xdg_surface_v6 *xdg_surface; wl_list_for_each(xdg_surface, &sample->xdg_shell->surfaces, link) { output_frame_handle_surface(sample, wlr_output, ts, - xdg_surface->surface); + xdg_surface->surface->resource); } struct wlr_x11_window *x11_window; wl_list_for_each(x11_window, &sample->xwayland->displayable_windows, link) { -- cgit v1.2.3 From 27161a673f2b4bcc6db47759d035881985758001 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Fri, 15 Sep 2017 08:53:08 -0400 Subject: xdg-shell new surface and ack configure events --- examples/compositor.c | 19 +++++++++++++++++++ include/wlr/types/wlr_xdg_shell_v6.h | 7 +++++++ types/wlr_xdg_shell_v6.c | 15 +++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/compositor.c b/examples/compositor.c index 9d96b053..841407bf 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -56,6 +56,8 @@ struct sample_state { struct wl_listener cursor_motion_absolute; struct wl_listener cursor_button; struct wl_listener cursor_axis; + + struct wl_listener new_xdg_surface_v6; }; /* @@ -85,6 +87,15 @@ static void output_frame_handle_surface(struct sample_state *sample, } } } + +static void handle_new_xdg_surface_v6(struct wl_listener *listener, + void *data) { + struct wlr_xdg_surface_v6 *surface = data; + wlr_log(L_DEBUG, "new xdg surface: title=%s, app_id=%s", + surface->title, surface->app_id); + // configure the surface and add it to data structures here +} + static void handle_output_frame(struct output_state *output, struct timespec *ts) { struct compositor_state *state = output->compositor; @@ -309,6 +320,12 @@ int main(int argc, char *argv[]) { state.wl_shell = wlr_wl_shell_create(compositor.display); state.xdg_shell = wlr_xdg_shell_v6_create(compositor.display); + // shell events + wl_signal_add(&state.xdg_shell->events.new_surface, + &state.new_xdg_surface_v6); + state.new_xdg_surface_v6.notify = handle_new_xdg_surface_v6; + + state.data_device_manager = wlr_data_device_manager_create(compositor.display); @@ -341,6 +358,8 @@ int main(int argc, char *argv[]) { wl_display_run(compositor.display); + wl_list_remove(&state.new_xdg_surface_v6.link); + wlr_xwayland_destroy(state.xwayland); close(state.keymap_fd); wlr_seat_destroy(state.wl_seat); diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index a4afaf3b..7c912370 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -8,6 +8,10 @@ struct wlr_xdg_shell_v6 { struct wl_list wl_resources; struct wl_list surfaces; + struct { + struct wl_signal new_surface; + } events; + void *data; }; @@ -53,10 +57,12 @@ struct wlr_xdg_surface_v6 { struct wl_client *client; struct wl_resource *resource; struct wlr_surface *surface; + struct wlr_xdg_shell_v6 *shell; struct wl_list link; enum wlr_xdg_surface_v6_role role; struct wlr_xdg_toplevel_v6 *toplevel_state; + bool configured; struct wl_event_source *configure_idle; struct wl_list configure_list; @@ -74,6 +80,7 @@ struct wlr_xdg_surface_v6 { struct wl_signal request_minimize; struct wl_signal commit; struct wl_signal destroy; + struct wl_signal ack_configure; } events; void *data; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 11b44d6d..d32990db 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -205,7 +205,6 @@ static void wlr_xdg_toplevel_v6_ack_configure( static void xdg_surface_ack_configure(struct wl_client *client, struct wl_resource *resource, uint32_t serial) { - wlr_log(L_DEBUG, "TODO xdg surface ack configure"); struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); // TODO handle popups @@ -237,7 +236,13 @@ static void xdg_surface_ack_configure(struct wl_client *client, wlr_xdg_toplevel_v6_ack_configure(surface, configure); } - // TODO send ack_configure event? + if (!surface->configured) { + surface->configured = true; + wl_signal_emit(&surface->shell->events.new_surface, surface); + } + + wl_signal_emit(&surface->events.ack_configure, surface); + free(configure); } @@ -444,6 +449,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client, } surface->client = client; + surface->shell = xdg_shell; surface->role = WLR_XDG_SURFACE_V6_ROLE_NONE; surface->surface = wl_resource_get_user_data(_surface); surface->resource = wl_resource_create(client, @@ -454,6 +460,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client, wl_signal_init(&surface->events.request_minimize); wl_signal_init(&surface->events.commit); wl_signal_init(&surface->events.destroy); + wl_signal_init(&surface->events.ack_configure); wl_signal_add(&surface->surface->signals.destroy, &surface->surface_destroy_listener); @@ -514,8 +521,12 @@ struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) { return NULL; } xdg_shell->wl_global = wl_global; + + wl_signal_init(&xdg_shell->events.new_surface); + wl_list_init(&xdg_shell->wl_resources); wl_list_init(&xdg_shell->surfaces); + return xdg_shell; } -- cgit v1.2.3 From c912de6390299aeadb871b52bd3ee8ae984d91ca Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 16 Sep 2017 09:13:00 -0400 Subject: compositor.c: implement xdg-toplevel-v6 request events --- examples/compositor.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/compositor.c b/examples/compositor.c index 841407bf..4ddb6565 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -60,6 +60,16 @@ struct sample_state { struct wl_listener new_xdg_surface_v6; }; +struct example_xdg_surface_v6 { + struct wlr_xdg_surface_v6 *surface; + + struct wl_listener destroy_listener; + struct wl_listener request_minimize_listener; + struct wl_listener request_move_listener; + struct wl_listener request_resize_listener; + struct wl_listener request_show_window_menu_listener; +}; + /* * Convert timespec to milliseconds */ @@ -88,12 +98,87 @@ static void output_frame_handle_surface(struct sample_state *sample, } } +static void handle_xdg_surface_v6_destroy(struct wl_listener *listener, + void *data) { + struct example_xdg_surface_v6 *example_surface = + wl_container_of(listener, example_surface, destroy_listener); + wl_list_remove(&example_surface->destroy_listener.link); + wl_list_remove(&example_surface->request_move_listener.link); + wl_list_remove(&example_surface->request_resize_listener.link); + wl_list_remove(&example_surface->request_show_window_menu_listener.link); + wl_list_remove(&example_surface->request_minimize_listener.link); + free(example_surface); +} + +static void handle_xdg_surface_v6_request_move(struct wl_listener *listener, + void *data) { + struct example_xdg_surface_v6 *example_surface = + wl_container_of(listener, example_surface, request_move_listener); + struct wlr_xdg_toplevel_v6_move_event *e = data; + wlr_log(L_DEBUG, "TODO: surface requested move: %s", e->surface->title); +} + +static void handle_xdg_surface_v6_request_resize(struct wl_listener *listener, + void *data) { + struct example_xdg_surface_v6 *example_surface = + wl_container_of(listener, example_surface, request_resize_listener); + struct wlr_xdg_toplevel_v6_resize_event *e = data; + wlr_log(L_DEBUG, "TODO: surface requested resize: %s", e->surface->title); +} + +static void handle_xdg_surface_v6_request_show_window_menu( + struct wl_listener *listener, void *data) { + struct example_xdg_surface_v6 *example_surface = + wl_container_of(listener, example_surface, + request_show_window_menu_listener); + struct wlr_xdg_toplevel_v6_show_window_menu_event *e = data; + wlr_log(L_DEBUG, "TODO: surface requested to show window menu: %s", + e->surface->title); +} + +static void handle_xdg_surface_v6_request_minimize( + struct wl_listener *listener, void *data) { + struct example_xdg_surface_v6 *example_surface = + wl_container_of(listener, example_surface, request_minimize_listener); + wlr_log(L_DEBUG, "TODO: surface requested to be minimized: %s", + example_surface->surface->title); +} + static void handle_new_xdg_surface_v6(struct wl_listener *listener, void *data) { struct wlr_xdg_surface_v6 *surface = data; wlr_log(L_DEBUG, "new xdg surface: title=%s, app_id=%s", surface->title, surface->app_id); - // configure the surface and add it to data structures here + + struct example_xdg_surface_v6 *esurface = + calloc(1, sizeof(struct example_xdg_surface_v6)); + if (esurface == NULL) { + return; + } + + esurface->surface = surface; + + wl_signal_add(&surface->events.destroy, &esurface->destroy_listener); + esurface->destroy_listener.notify = handle_xdg_surface_v6_destroy; + + wl_signal_add(&surface->events.request_move, + &esurface->request_move_listener); + esurface->request_move_listener.notify = handle_xdg_surface_v6_request_move; + + wl_signal_add(&surface->events.request_resize, + &esurface->request_resize_listener); + esurface->request_resize_listener.notify = + handle_xdg_surface_v6_request_resize; + + wl_signal_add(&surface->events.request_show_window_menu, + &esurface->request_show_window_menu_listener); + esurface->request_show_window_menu_listener.notify = + handle_xdg_surface_v6_request_show_window_menu; + + wl_signal_add(&surface->events.request_minimize, + &esurface->request_minimize_listener); + esurface->request_minimize_listener.notify = + handle_xdg_surface_v6_request_minimize; } static void handle_output_frame(struct output_state *output, -- cgit v1.2.3 From 94f4f1878dd035ba1be6bf49ce7c41e45581ea94 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 16 Sep 2017 12:35:49 -0400 Subject: xdg-surface-v6: implement ping --- examples/compositor.c | 23 +++++- include/wlr/types/wlr_xdg_shell_v6.h | 29 ++++++-- types/wlr_xdg_shell_v6.c | 132 +++++++++++++++++++++++++++-------- 3 files changed, 146 insertions(+), 38 deletions(-) (limited to 'examples') diff --git a/examples/compositor.c b/examples/compositor.c index 4ddb6565..fb5d8dfd 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -64,6 +64,7 @@ struct example_xdg_surface_v6 { struct wlr_xdg_surface_v6 *surface; struct wl_listener destroy_listener; + struct wl_listener ping_timeout_listener; struct wl_listener request_minimize_listener; struct wl_listener request_move_listener; struct wl_listener request_resize_listener; @@ -98,11 +99,18 @@ static void output_frame_handle_surface(struct sample_state *sample, } } +static void handle_xdg_surface_v6_ping_timeout(struct wl_listener *listener, + void *data) { + struct wlr_xdg_surface_v6 *surface = data; + wlr_log(L_DEBUG, "got ping timeout for surface: %s", surface->title); +} + static void handle_xdg_surface_v6_destroy(struct wl_listener *listener, void *data) { struct example_xdg_surface_v6 *example_surface = wl_container_of(listener, example_surface, destroy_listener); wl_list_remove(&example_surface->destroy_listener.link); + wl_list_remove(&example_surface->ping_timeout_listener.link); wl_list_remove(&example_surface->request_move_listener.link); wl_list_remove(&example_surface->request_resize_listener.link); wl_list_remove(&example_surface->request_show_window_menu_listener.link); @@ -150,6 +158,8 @@ static void handle_new_xdg_surface_v6(struct wl_listener *listener, wlr_log(L_DEBUG, "new xdg surface: title=%s, app_id=%s", surface->title, surface->app_id); + wlr_xdg_surface_v6_ping(surface); + struct example_xdg_surface_v6 *esurface = calloc(1, sizeof(struct example_xdg_surface_v6)); if (esurface == NULL) { @@ -161,6 +171,10 @@ static void handle_new_xdg_surface_v6(struct wl_listener *listener, wl_signal_add(&surface->events.destroy, &esurface->destroy_listener); esurface->destroy_listener.notify = handle_xdg_surface_v6_destroy; + wl_signal_add(&surface->events.ping_timeout, + &esurface->ping_timeout_listener); + esurface->ping_timeout_listener.notify = handle_xdg_surface_v6_ping_timeout; + wl_signal_add(&surface->events.request_move, &esurface->request_move_listener); esurface->request_move_listener.notify = handle_xdg_surface_v6_request_move; @@ -196,9 +210,12 @@ static void handle_output_frame(struct output_state *output, wl_shell_surface->surface); } struct wlr_xdg_surface_v6 *xdg_surface; - wl_list_for_each(xdg_surface, &sample->xdg_shell->surfaces, link) { - output_frame_handle_surface(sample, wlr_output, ts, - xdg_surface->surface->resource); + struct wlr_xdg_client_v6 *xdg_client; + wl_list_for_each(xdg_client, &sample->xdg_shell->clients, link) { + wl_list_for_each(xdg_surface, &xdg_client->surfaces, link) { + output_frame_handle_surface(sample, wlr_output, ts, + xdg_surface->surface->resource); + } } struct wlr_x11_window *x11_window; wl_list_for_each(x11_window, &sample->xwayland->displayable_windows, link) { diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 3e404b6d..f57dde10 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -5,8 +5,8 @@ struct wlr_xdg_shell_v6 { struct wl_global *wl_global; - struct wl_list wl_resources; - struct wl_list surfaces; + struct wl_list clients; + uint32_t ping_timeout; struct { struct wl_signal new_surface; @@ -15,6 +15,19 @@ struct wlr_xdg_shell_v6 { void *data; }; +struct wlr_xdg_client_v6 { + struct wlr_xdg_shell_v6 *shell; + struct wl_resource *resource; + struct wl_client *client; + struct wl_list surfaces; + + struct wl_list link; // wlr_xdg_shell_v6::clients + + uint32_t ping_serial; + struct wl_event_source *ping_timer; +}; + + enum wlr_xdg_surface_v6_role { WLR_XDG_SURFACE_V6_ROLE_NONE, WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL, @@ -54,11 +67,10 @@ struct wlr_xdg_surface_v6_configure { }; struct wlr_xdg_surface_v6 { - struct wl_client *client; + struct wlr_xdg_client_v6 *client; struct wl_resource *resource; struct wlr_surface *surface; - struct wlr_xdg_shell_v6 *shell; - struct wl_list link; + struct wl_list link; // wlr_xdg_client_v6::surfaces enum wlr_xdg_surface_v6_role role; struct wlr_xdg_toplevel_v6 *toplevel_state; @@ -80,6 +92,7 @@ struct wlr_xdg_surface_v6 { struct wl_signal commit; struct wl_signal destroy; struct wl_signal ack_configure; + struct wl_signal ping_timeout; struct wl_signal request_minimize; struct wl_signal request_move; @@ -117,6 +130,12 @@ struct wlr_xdg_toplevel_v6_show_window_menu_event { struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display); void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell); +/** + * Send a ping to the surface. If the surface does not respond in a reasonable + * amount of time, the ping_timeout event will be emitted. + */ +void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface); + /** * Request that this toplevel surface be the given size. */ diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 8c101020..a8d8c93a 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -296,7 +296,7 @@ static void xdg_surface_ack_configure(struct wl_client *client, if (!surface->configured) { surface->configured = true; - wl_signal_emit(&surface->shell->events.new_surface, surface); + wl_signal_emit(&surface->client->shell->events.new_surface, surface); } wl_signal_emit(&surface->events.ack_configure, surface); @@ -393,7 +393,7 @@ static void wlr_xdg_toplevel_v6_send_configure( static void wlr_xdg_surface_send_configure(void *user_data) { struct wlr_xdg_surface_v6 *surface = user_data; - struct wl_display *display = wl_client_get_display(surface->client); + struct wl_display *display = wl_client_get_display(surface->client->client); // TODO handle popups assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); @@ -416,7 +416,7 @@ static void wlr_xdg_surface_v6_schedule_configure( // TODO handle popups assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - struct wl_display *display = wl_client_get_display(surface->client); + struct wl_display *display = wl_client_get_display(surface->client->client); struct wl_event_loop *loop = wl_display_get_event_loop(display); bool pending_same = !force && @@ -486,32 +486,36 @@ static void handle_wlr_surface_committed(struct wl_listener *listener, wl_signal_emit(&surface->events.commit, surface); } -static void xdg_shell_get_xdg_surface(struct wl_client *client, - struct wl_resource *_xdg_shell, uint32_t id, - struct wl_resource *_surface) { - struct wlr_xdg_shell_v6 *xdg_shell = wl_resource_get_user_data(_xdg_shell); +static void xdg_shell_get_xdg_surface(struct wl_client *wl_client, + struct wl_resource *client_resource, uint32_t id, + struct wl_resource *surface_resource) { + struct wlr_xdg_client_v6 *client = + wl_resource_get_user_data(client_resource); struct wlr_xdg_surface_v6 *surface; if (!(surface = calloc(1, sizeof(struct wlr_xdg_surface_v6)))) { + wl_client_post_no_memory(wl_client); return; } if (!(surface->geometry = calloc(1, sizeof(struct wlr_box)))) { free(surface); + wl_client_post_no_memory(wl_client); return; } if (!(surface->next_geometry = calloc(1, sizeof(struct wlr_box)))) { free(surface->geometry); free(surface); + wl_client_post_no_memory(wl_client); return; } surface->client = client; - surface->shell = xdg_shell; surface->role = WLR_XDG_SURFACE_V6_ROLE_NONE; - surface->surface = wl_resource_get_user_data(_surface); - surface->resource = wl_resource_create(client, - &zxdg_surface_v6_interface, wl_resource_get_version(_xdg_shell), id); + surface->surface = wl_resource_get_user_data(surface_resource); + surface->resource = wl_resource_create(wl_client, + &zxdg_surface_v6_interface, wl_resource_get_version(client_resource), + id); wl_list_init(&surface->configure_list); @@ -522,6 +526,7 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client, wl_signal_init(&surface->events.commit); wl_signal_init(&surface->events.destroy); wl_signal_init(&surface->events.ack_configure); + wl_signal_init(&surface->events.ping_timeout); wl_signal_add(&surface->surface->signals.destroy, &surface->surface_destroy_listener); @@ -534,12 +539,19 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client, wlr_log(L_DEBUG, "new xdg_surface %p (res %p)", surface, surface->resource); wl_resource_set_implementation(surface->resource, &zxdg_surface_v6_implementation, surface, xdg_surface_resource_destroy); - wl_list_insert(&xdg_shell->surfaces, &surface->link); + wl_list_insert(&client->surfaces, &surface->link); } -static void xdg_shell_pong(struct wl_client *client, +static void xdg_shell_pong(struct wl_client *wl_client, struct wl_resource *resource, uint32_t serial) { - wlr_log(L_DEBUG, "TODO xdg shell pong"); + struct wlr_xdg_client_v6 *client = wl_resource_get_user_data(resource); + + if (client->ping_serial != serial) { + return; + } + + wl_event_source_timer_update(client->ping_timer, 0); + client->ping_serial = 0; } static struct zxdg_shell_v6_interface xdg_shell_impl = { @@ -548,8 +560,36 @@ static struct zxdg_shell_v6_interface xdg_shell_impl = { .pong = xdg_shell_pong, }; -static void xdg_shell_destroy(struct wl_resource *resource) { - wl_list_remove(wl_resource_get_link(resource)); +static void wlr_xdg_client_v6_destroy(struct wl_resource *resource) { + struct wlr_xdg_client_v6 *client = wl_resource_get_user_data(resource); + struct wl_list *list = &client->surfaces; + struct wl_list *link, *tmp; + + for (link = list->next, tmp = link->next; + link != list; + link = tmp, tmp = link->next) { + wl_list_remove(link); + wl_list_init(link); + } + + if (client->ping_timer != NULL) { + wl_event_source_remove(client->ping_timer); + } + + wl_list_remove(&client->link); + free(client); +} + +static int wlr_xdg_client_v6_ping_timeout(void *user_data) { + struct wlr_xdg_client_v6 *client = user_data; + + struct wlr_xdg_surface_v6 *surface; + wl_list_for_each(surface, &client->surfaces, link) { + wl_signal_emit(&surface->events.ping_timeout, surface); + } + + client->ping_serial = 0; + return 1; } static void xdg_shell_bind(struct wl_client *wl_client, void *_xdg_shell, @@ -562,11 +602,31 @@ static void xdg_shell_bind(struct wl_client *wl_client, void *_xdg_shell, wl_client_destroy(wl_client); return; } - struct wl_resource *wl_resource = - wl_resource_create( wl_client, &zxdg_shell_v6_interface, version, id); - wl_resource_set_implementation(wl_resource, &xdg_shell_impl, xdg_shell, - xdg_shell_destroy); - wl_list_insert(&xdg_shell->wl_resources, wl_resource_get_link(wl_resource)); + struct wlr_xdg_client_v6 *client = + calloc(1, sizeof(struct wlr_xdg_client_v6)); + if (client == NULL) { + wl_client_post_no_memory(wl_client); + return; + } + + wl_list_init(&client->surfaces); + + client->resource = + wl_resource_create(wl_client, &zxdg_shell_v6_interface, version, id); + client->client = wl_client; + client->shell = xdg_shell; + + wl_resource_set_implementation(client->resource, &xdg_shell_impl, client, + wlr_xdg_client_v6_destroy); + wl_list_insert(&xdg_shell->clients, &client->link); + + struct wl_display *display = wl_client_get_display(client->client); + struct wl_event_loop *loop = wl_display_get_event_loop(display); + client->ping_timer = wl_event_loop_add_timer(loop, + wlr_xdg_client_v6_ping_timeout, client); + if (client->ping_timer == NULL) { + wl_client_post_no_memory(client->client); + } } struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) { @@ -575,6 +635,11 @@ struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) { if (!xdg_shell) { return NULL; } + + xdg_shell->ping_timeout = 10000; + + wl_list_init(&xdg_shell->clients); + struct wl_global *wl_global = wl_global_create(display, &zxdg_shell_v6_interface, 1, xdg_shell, xdg_shell_bind); if (!wl_global) { @@ -585,9 +650,6 @@ struct wlr_xdg_shell_v6 *wlr_xdg_shell_v6_create(struct wl_display *display) { wl_signal_init(&xdg_shell->events.new_surface); - wl_list_init(&xdg_shell->wl_resources); - wl_list_init(&xdg_shell->surfaces); - return xdg_shell; } @@ -595,17 +657,27 @@ void wlr_xdg_shell_v6_destroy(struct wlr_xdg_shell_v6 *xdg_shell) { if (!xdg_shell) { return; } - struct wl_resource *resource = NULL, *temp = NULL; - wl_resource_for_each_safe(resource, temp, &xdg_shell->wl_resources) { - struct wl_list *link = wl_resource_get_link(resource); - wl_list_remove(link); - } - // TODO: destroy surfaces + // TODO: disconnect clients and destroy surfaces + // TODO: this segfault (wl_display->registry_resource_list is not init) // wl_global_destroy(xdg_shell->wl_global); free(xdg_shell); } +void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface) { + if (surface->client->ping_serial != 0) { + // already pinged + return; + } + + surface->client->ping_serial = + wl_display_next_serial(wl_client_get_display(surface->client->client)); + wl_event_source_timer_update(surface->client->ping_timer, + surface->client->shell->ping_timeout); + zxdg_shell_v6_send_ping(surface->client->resource, + surface->client->ping_serial); +} + void wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, uint32_t width, uint32_t height) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); -- cgit v1.2.3