From 6d4cb4e8c425c9997cd7d35b589ce80ea2906785 Mon Sep 17 00:00:00 2001 From: Ander Conselvan de Oliveira Date: Fri, 30 Nov 2012 17:34:24 +0200 Subject: [PATCH] window: Let clients set buffer transformations When a window's buffer transformation is set, its buffers are reallocated with the appropriate size (i.e., with width and height swapped in case of 90 or 270 degree rotation). --- clients/window.c | 36 ++++++++++++++++++++++++++++++++---- clients/window.h | 7 +++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/clients/window.c b/clients/window.c index fa247ab..d08542d 100644 --- a/clients/window.c +++ b/clients/window.c @@ -209,6 +209,7 @@ struct window { int focus_count; enum window_buffer_type buffer_type; + enum wl_output_transform buffer_transform; struct toysurface *toysurface; cairo_surface_t *cairo_surface; @@ -1181,34 +1182,61 @@ window_get_display(struct window *window) static void window_create_surface(struct window *window) { + struct rectangle allocation = window->allocation; uint32_t flags = 0; int dx, dy; if (!window->transparent) flags = SURFACE_OPAQUE; + switch (window->buffer_transform) { + case WL_OUTPUT_TRANSFORM_90: + case WL_OUTPUT_TRANSFORM_270: + case WL_OUTPUT_TRANSFORM_FLIPPED_90: + case WL_OUTPUT_TRANSFORM_FLIPPED_270: + allocation.width = window->allocation.height; + allocation.height = window->allocation.width; + break; + default: + break; + } + if (!window->toysurface && window->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW && window->display->dpy) { window->toysurface = egl_window_surface_create(window->display, window->surface, flags, - &window->allocation); + &allocation); } if (!window->toysurface) window->toysurface = shm_surface_create(window->display, window->surface, flags, - &window->allocation); + &allocation); window_get_resize_dx_dy(window, &dx, &dy); window->cairo_surface = window->toysurface->prepare(window->toysurface, dx, dy, - window->allocation.width, - window->allocation.height, + allocation.width, + allocation.height, window->resizing); } +int +window_get_buffer_transform(struct window *window) +{ + return window->buffer_transform; +} + +void +window_set_buffer_transform(struct window *window, + enum wl_output_transform transform) +{ + window->buffer_transform = transform; + wl_surface_set_buffer_transform(window->surface, transform); +} + static void frame_destroy(struct frame *frame); void diff --git a/clients/window.h b/clients/window.h index 804eef5..f13ea35 100644 --- a/clients/window.h +++ b/clients/window.h @@ -240,6 +240,13 @@ void window_show_frame_menu(struct window *window, struct input *input, uint32_t time); +int +window_get_buffer_transform(struct window *window); + +void +window_set_buffer_transform(struct window *window, + enum wl_output_transform transform); + void window_destroy(struct window *window); -- 2.7.4