summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-02-01 16:35:34 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-02-01 16:35:34 +0100
commitc8ad37e3036724d22267b7ff6a348199a5f03905 (patch)
tree3ece20bf6c2fb57785b58ec9103543ef3f698be4
parentaa3574faebf51790d3861050d881b55b85c67660 (diff)
egl-wayland-{image,surface}: Fix resize
-rw-r--r--egl-wayland-image.c30
-rw-r--r--egl-wayland-surface.c22
2 files changed, 19 insertions, 33 deletions
diff --git a/egl-wayland-image.c b/egl-wayland-image.c
index 56a8739..82cca62 100644
--- a/egl-wayland-image.c
+++ b/egl-wayland-image.c
@@ -270,7 +270,7 @@ redraw(void *data, uint32_t time)
window->surface.surface,
window->dx, window->dy);
window->attached_width = window->geometry.width;
- window->attached_height = window->geometry.width;
+ window->attached_height = window->geometry.height;
window->dx = window->dy = 0;
@@ -288,33 +288,25 @@ handle_configure(void *data, struct wl_shell *shell,
{
struct display *d = data;
struct window *window = wl_surface_get_user_data(surface);
- int dx = 0;
- int dy = 0;
struct wl_visual *visual;
struct wl_egl_image *old_egl_image = window->surface.egl_image;
-#if 1
- printf("event: width: %d height: %d\natm: width: %d height: %d\n",
- width, height, window->attached_width, window->attached_height);
+#define WINDOW_RESIZING_LEFT 4
+#define WINDOW_RESIZING_TOP 1
- dx = window->attached_width - width;
- dy = window->attached_height - height;
+ if (width <= 0 || height <= 0)
+ return;
- window->dx = -dx;
- window->dy = dy;
- window->geometry.width = width ;
- window->geometry.height = height;
-
- printf("calculated: width: %d, height: %d\n",
- window->geometry.width, window->geometry.height);
- printf("\n");
-#else
- window->dx = 0;
window->dx = 0;
+ window->dy = 0;
window->geometry.width = width;
window->geometry.height = height;
-#endif
+
+ if (edges & WINDOW_RESIZING_LEFT)
+ window->dx = window->attached_width - width;
+ if (edges & WINDOW_RESIZING_TOP)
+ window->dy = window->attached_height - height;
visual = wl_display_get_premultiplied_argb_visual(d->display);
window->surface.egl_image =
diff --git a/egl-wayland-surface.c b/egl-wayland-surface.c
index f4732a3..797235a 100644
--- a/egl-wayland-surface.c
+++ b/egl-wayland-surface.c
@@ -32,6 +32,7 @@ struct window {
struct wl_egl_surface *egl_surface;
int width, height;
+ int attached_width, attached_height;
struct {
EGLSurface surf;
@@ -146,6 +147,8 @@ redraw(void *data, uint32_t time)
glPopMatrix();
eglSwapBuffers(window->display->egl.dpy, window->egl.surf);
+ window->attached_width = window->width;
+ window->attached_height = window->height;
wl_display_frame_callback(window->display->display, redraw, window);
}
@@ -176,25 +179,16 @@ handle_configure(void *data, struct wl_shell *shell,
int dx = 0;
int dy = 0;
- int t_width, t_height;
-
- eglQuerySurface(d->egl.dpy, window->egl.surf, EGL_WIDTH, &t_width);
- eglQuerySurface(d->egl.dpy, window->egl.surf, EGL_HEIGHT, &t_height);
-
- edges = 5;
if (edges & WINDOW_RESIZING_LEFT)
- dx = t_width - width;
+ dx = window->attached_width - width;
if (edges & WINDOW_RESIZING_TOP)
- dy = t_height - height;
-
- t_width = width + 2*dx;
- t_height = height + 2*dy;
+ dy = window->attached_height - height;
- wl_egl_surface_resize(window->egl_surface, t_width, t_height, -dx, -dy);
+ wl_egl_surface_resize(window->egl_surface, width, height, dx, dy);
- window->width = t_width;
- window->height = t_height;
+ window->width = width;
+ window->height = height;
glViewport(0, 0, window->width, window->height);
}