diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-09-12 06:18:52 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-09-13 07:57:16 -0400 |
commit | 9d2dc8447a64d0f402b309af5a655ce374dad808 (patch) | |
tree | ab971c7b72b532bdf483f4ed1b5aa125b1122c63 | |
parent | b2c71287f29cec22217177d11e8692e73b805b66 (diff) |
use wlr_surface on shell struct and listen to events
-rw-r--r-- | examples/compositor.c | 2 | ||||
-rw-r--r-- | include/wlr/types/wlr_xdg_shell_v6.h | 3 | ||||
-rw-r--r-- | types/wlr_xdg_shell_v6.c | 17 |
3 files changed, 16 insertions, 6 deletions
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) { diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 6bc37940..27fafd2d 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -18,11 +18,12 @@ enum wlr_xdg_surface_v6_role { struct wlr_xdg_surface_v6 { struct wl_resource *resource; - struct wl_resource *surface; + struct wlr_surface *surface; struct wl_list link; enum wlr_xdg_surface_v6_role role; struct wl_listener surface_destroy_listener; + struct wl_listener surface_commit_listener; void *data; }; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 2fff054d..70f22197 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -104,6 +104,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); free(surface); } @@ -118,9 +119,8 @@ static void xdg_surface_get_toplevel(struct wl_client *client, struct wl_resource *resource, uint32_t id) { // TODO: Flesh out struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); - struct wlr_surface *wsurface = wl_resource_get_user_data(surface->surface); - if (wlr_surface_set_role(wsurface, wlr_desktop_xdg_toplevel_role, + if (wlr_surface_set_role(surface->surface, wlr_desktop_xdg_toplevel_role, resource, ZXDG_SHELL_V6_ERROR_ROLE)) { return; } @@ -173,6 +173,11 @@ static void handle_wlr_surface_destroyed(struct wl_listener *listener, xdg_surface_destroy(xdg_surface); } +static void handle_wlr_surface_committed(struct wl_listener *listener, + void *data) { + wlr_log(L_DEBUG, "TODO: handle wlr surface committed"); +} + static void xdg_shell_get_xdg_surface(struct wl_client *client, struct wl_resource *_xdg_shell, uint32_t id, struct wl_resource *_surface) { @@ -182,14 +187,18 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client, return; } surface->role = WLR_XDG_SURFACE_V6_ROLE_NONE; - surface->surface = _surface; + 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); - wl_signal_add(&_surface->destroy_signal, + wl_signal_add(&surface->surface->signals.destroy, &surface->surface_destroy_listener); surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed; + wl_signal_add(&surface->surface->signals.commit, + &surface->surface_commit_listener); + surface->surface_commit_listener.notify = handle_wlr_surface_committed; + 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); |