window: Set egl_window_resize late and once

Previously we resized in attach_surface and create_surface.
THe second resize overwrote dx or dy from the first.
dev
Benjamin Franzke 13 years ago
parent d4af320178
commit 14f7ff91ad
  1. 36
      clients/window.c

@ -681,33 +681,35 @@ free_surface(void *data)
} }
static void static void
window_attach_surface(struct window *window) window_get_resize_dx_dy(struct window *window, int *x, int *y)
{ {
struct display *display = window->display;
struct wl_buffer *buffer;
struct egl_window_surface_data *data;
int32_t x, y;
int width = window->allocation.width;
int height = window->allocation.height;
if (window->resize_edges & WINDOW_RESIZING_LEFT) if (window->resize_edges & WINDOW_RESIZING_LEFT)
x = window->server_allocation.width - width; *x = window->server_allocation.width - window->allocation.width;
else else
x = 0; *x = 0;
if (window->resize_edges & WINDOW_RESIZING_TOP) if (window->resize_edges & WINDOW_RESIZING_TOP)
y = window->server_allocation.height - height; *y = window->server_allocation.height -
window->allocation.height;
else else
y = 0; *y = 0;
window->resize_edges = 0; window->resize_edges = 0;
}
static void
window_attach_surface(struct window *window)
{
struct display *display = window->display;
struct wl_buffer *buffer;
struct egl_window_surface_data *data;
int32_t x, y;
switch (window->buffer_type) { switch (window->buffer_type) {
case WINDOW_BUFFER_TYPE_EGL_WINDOW: case WINDOW_BUFFER_TYPE_EGL_WINDOW:
data = cairo_surface_get_user_data(window->cairo_surface, data = cairo_surface_get_user_data(window->cairo_surface,
&surface_data_key); &surface_data_key);
wl_egl_window_resize(data->window, width, height, x, y);
cairo_gl_surface_swapbuffers(window->cairo_surface); cairo_gl_surface_swapbuffers(window->cairo_surface);
wl_egl_window_get_attached_size(data->window, wl_egl_window_get_attached_size(data->window,
&window->server_allocation.width, &window->server_allocation.width,
@ -715,6 +717,8 @@ window_attach_surface(struct window *window)
break; break;
case WINDOW_BUFFER_TYPE_EGL_IMAGE: case WINDOW_BUFFER_TYPE_EGL_IMAGE:
case WINDOW_BUFFER_TYPE_SHM: case WINDOW_BUFFER_TYPE_SHM:
window_get_resize_dx_dy(window, &x, &y);
if (window->pending_surface != NULL) if (window->pending_surface != NULL)
return; return;
@ -781,13 +785,17 @@ static void
window_resize_cairo_window_surface(struct window *window) window_resize_cairo_window_surface(struct window *window)
{ {
struct egl_window_surface_data *data; struct egl_window_surface_data *data;
int x, y;
data = cairo_surface_get_user_data(window->cairo_surface, data = cairo_surface_get_user_data(window->cairo_surface,
&surface_data_key); &surface_data_key);
window_get_resize_dx_dy(window, &x, &y),
wl_egl_window_resize(data->window, wl_egl_window_resize(data->window,
window->allocation.width, window->allocation.width,
window->allocation.height, 0, 0); window->allocation.height,
x,y);
cairo_gl_surface_set_size(window->cairo_surface, cairo_gl_surface_set_size(window->cairo_surface,
window->allocation.width, window->allocation.width,
window->allocation.height); window->allocation.height);

Loading…
Cancel
Save