From 45a3b761a6058bb83f1a5ebfc18b517a680be659 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 14 Sep 2017 08:39:57 -0400 Subject: [PATCH] xdg-surface-v6: add events --- include/wlr/types/wlr_xdg_shell_v6.h | 6 ++++++ types/wlr_xdg_shell_v6.c | 11 +++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 890f404f..6e2f43c4 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -52,6 +52,12 @@ struct wlr_xdg_surface_v6 { struct wl_listener surface_destroy_listener; struct wl_listener surface_commit_listener; + struct { + struct wl_signal request_minimize; + struct wl_signal commit; + struct wl_signal destroy; + } events; + void *data; }; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index cc940997..df01730f 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -109,8 +109,8 @@ static void xdg_toplevel_unset_fullscreen(struct wl_client *client, static void xdg_toplevel_set_minimized(struct wl_client *client, struct wl_resource *resource) { - // TODO event for minimization request - wlr_log(L_DEBUG, "TODO: xdg toplevel set minimized"); + struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); + wl_signal_emit(&surface->events.request_minimize, surface); } static const struct zxdg_toplevel_v6_interface zxdg_toplevel_v6_implementation = @@ -132,6 +132,7 @@ static const struct zxdg_toplevel_v6_interface zxdg_toplevel_v6_implementation = }; static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) { + wl_signal_emit(&surface->events.destroy, surface); wl_resource_set_user_data(surface->resource, NULL); wl_list_remove(&surface->link); wl_list_remove(&surface->surface_destroy_listener.link); @@ -254,6 +255,8 @@ static void handle_wlr_surface_committed(struct wl_listener *listener, if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) { wlr_xdg_surface_v6_toplevel_committed(surface); } + + wl_signal_emit(&surface->events.commit, surface); } static void xdg_shell_get_xdg_surface(struct wl_client *client, @@ -281,6 +284,10 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client, surface->resource = wl_resource_create(client, &zxdg_surface_v6_interface, wl_resource_get_version(_xdg_shell), id); + wl_signal_init(&surface->events.request_minimize); + wl_signal_init(&surface->events.commit); + wl_signal_init(&surface->events.destroy); + wl_signal_add(&surface->surface->signals.destroy, &surface->surface_destroy_listener); surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed;