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).
Ander Conselvan de Oliveira 12 years ago committed by Kristian Høgsberg
parent ddd3e27ab8
commit 6d4cb4e8c4
  1. 36
      clients/window.c
  2. 7
      clients/window.h

@ -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

@ -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);

Loading…
Cancel
Save