From 353629b034654c686d0bf28c765a9e0160672310 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 13 Sep 2017 08:44:32 -0400 Subject: xdg-surface geometry --- include/wlr/types/wlr_xdg_shell_v6.h | 5 +++++ types/wlr_xdg_shell_v6.c | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index a6e62628..0a060444 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -1,5 +1,6 @@ #ifndef _WLR_XDG_SHELL_V6_H #define _WLR_XDG_SHELL_V6_H +#include #include struct wlr_xdg_shell_v6 { @@ -25,6 +26,10 @@ struct wlr_xdg_surface_v6 { char *title; char *app_id; + bool has_next_geometry; + struct wlr_box *next_geometry; + struct wlr_box *geometry; + struct wl_listener surface_destroy_listener; struct wl_listener surface_commit_listener; diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 3ed41ff3..487ede3d 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -127,6 +127,8 @@ static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) { wl_list_remove(&surface->link); wl_list_remove(&surface->surface_destroy_listener.link); wl_list_remove(&surface->surface_commit_listener.link); + free(surface->geometry); + free(surface->next_geometry); free(surface); } @@ -172,7 +174,12 @@ static void xdg_surface_ack_configure(struct wl_client *client, static void xdg_surface_set_window_geometry(struct wl_client *client, struct wl_resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) { - wlr_log(L_DEBUG, "TODO xdg surface set window geometry"); + struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource); + surface->has_next_geometry = true; + surface->next_geometry->height = height; + surface->next_geometry->width = width; + surface->next_geometry->x = x; + surface->next_geometry->y = y; } static const struct zxdg_surface_v6_interface zxdg_surface_v6_implementation = { @@ -197,7 +204,17 @@ static void handle_wlr_surface_destroyed(struct wl_listener *listener, static void handle_wlr_surface_committed(struct wl_listener *listener, void *data) { - wlr_log(L_DEBUG, "TODO: handle wlr surface committed"); + + struct wlr_xdg_surface_v6 *surface = + wl_container_of(listener, surface, surface_commit_listener); + + if (surface->has_next_geometry) { + surface->has_next_geometry = false; + surface->geometry->x = surface->next_geometry->x; + surface->geometry->y = surface->next_geometry->y; + surface->geometry->width = surface->next_geometry->width; + surface->geometry->height = surface->next_geometry->height; + } } static void xdg_shell_get_xdg_surface(struct wl_client *client, @@ -208,6 +225,18 @@ static void xdg_shell_get_xdg_surface(struct wl_client *client, if (!(surface = calloc(1, sizeof(struct wlr_xdg_surface_v6)))) { return; } + + if (!(surface->geometry = calloc(1, sizeof(struct wlr_box)))) { + free(surface); + return; + } + + if (!(surface->next_geometry = calloc(1, sizeof(struct wlr_box)))) { + free(surface->geometry); + free(surface); + return; + } + surface->role = WLR_XDG_SURFACE_V6_ROLE_NONE; surface->surface = wl_resource_get_user_data(_surface); surface->resource = wl_resource_create(client, -- cgit v1.2.3