xdg-surface geometry

This commit is contained in:
Tony Crisci 2017-09-13 08:44:32 -04:00
parent 2fd5c7999b
commit 353629b034
2 changed files with 36 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#ifndef _WLR_XDG_SHELL_V6_H #ifndef _WLR_XDG_SHELL_V6_H
#define _WLR_XDG_SHELL_V6_H #define _WLR_XDG_SHELL_V6_H
#include <wlr/types/wlr_box.h>
#include <wayland-server.h> #include <wayland-server.h>
struct wlr_xdg_shell_v6 { struct wlr_xdg_shell_v6 {
@ -25,6 +26,10 @@ struct wlr_xdg_surface_v6 {
char *title; char *title;
char *app_id; 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_destroy_listener;
struct wl_listener surface_commit_listener; struct wl_listener surface_commit_listener;

View File

@ -127,6 +127,8 @@ static void xdg_surface_destroy(struct wlr_xdg_surface_v6 *surface) {
wl_list_remove(&surface->link); wl_list_remove(&surface->link);
wl_list_remove(&surface->surface_destroy_listener.link); wl_list_remove(&surface->surface_destroy_listener.link);
wl_list_remove(&surface->surface_commit_listener.link); wl_list_remove(&surface->surface_commit_listener.link);
free(surface->geometry);
free(surface->next_geometry);
free(surface); 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, static void xdg_surface_set_window_geometry(struct wl_client *client,
struct wl_resource *resource, int32_t x, int32_t y, int32_t width, struct wl_resource *resource, int32_t x, int32_t y, int32_t width,
int32_t height) { 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 = { 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, static void handle_wlr_surface_committed(struct wl_listener *listener,
void *data) { 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, 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)))) { if (!(surface = calloc(1, sizeof(struct wlr_xdg_surface_v6)))) {
return; 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->role = WLR_XDG_SURFACE_V6_ROLE_NONE;
surface->surface = wl_resource_get_user_data(_surface); surface->surface = wl_resource_get_user_data(_surface);
surface->resource = wl_resource_create(client, surface->resource = wl_resource_create(client,