From 1684bef4a02fcb8751cdbce861c6e28037afd76c Mon Sep 17 00:00:00 2001 From: Jaehoon Jeong Date: Wed, 30 Sep 2015 14:50:58 +0900 Subject: [PATCH] shell: fix resize correctly Change-Id: If5daa8d638f29a6411097194e2dc82b3b7647c95 --- .../desktop-shell/desktop-shell-internal.h | 2 + src/lib/desktop-shell/shell-surface.c | 40 +++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/lib/desktop-shell/desktop-shell-internal.h b/src/lib/desktop-shell/desktop-shell-internal.h index 3b04c80..2051e2d 100644 --- a/src/lib/desktop-shell/desktop-shell-internal.h +++ b/src/lib/desktop-shell/desktop-shell-internal.h @@ -113,6 +113,8 @@ struct shell_surface pepper_bool_t resizing; } resize; + int32_t last_width, last_height; + /* Data structures per surface type */ shell_surface_type_t type; /* Current surface type */ shell_surface_type_t next_type; /* Requested surface type */ diff --git a/src/lib/desktop-shell/shell-surface.c b/src/lib/desktop-shell/shell-surface.c index 601474f..32868db 100644 --- a/src/lib/desktop-shell/shell-surface.c +++ b/src/lib/desktop-shell/shell-surface.c @@ -18,6 +18,9 @@ handle_surface_commit(pepper_event_listener_t *listener, { shell_surface_t *shsurf = data; + int vw, vh; + double sx, sy; + if (shsurf->has_next_geometry) { shsurf->geometry = shsurf->next_geometry; @@ -32,6 +35,29 @@ handle_surface_commit(pepper_event_listener_t *listener, shsurf->type = shsurf->next_type; shsurf->next_type = SHELL_SURFACE_TYPE_NONE; } + + pepper_view_get_size(shsurf->view, &vw, &vh); + + sx = (vw - shsurf->last_width); + sy = (vh - shsurf->last_height); + + if (sx || sy) + { + double vx, vy; + + pepper_view_get_position(shsurf->view, &vx, &vy); + + if (shsurf->resize.edges & WL_SHELL_SURFACE_RESIZE_LEFT) + vx = vx - sx; + + if (shsurf->resize.edges & WL_SHELL_SURFACE_RESIZE_TOP) + vy = vy - sy; + + pepper_view_set_position(shsurf->view, vx, vy); + + shsurf->last_width = vw; + shsurf->last_height = vh; + } } static void @@ -879,8 +905,7 @@ static void pointer_resize_grab_motion(pepper_pointer_t *pointer, void *data, uint32_t time, double x, double y) { shell_surface_t *shsurf = data; - uint32_t width = 0, height = 0; - int32_t dx = 0, dy = 0; + double dx = 0.f, dy = 0.f; pepper_pointer_set_position(pointer, x, y); @@ -902,10 +927,7 @@ pointer_resize_grab_motion(pepper_pointer_t *pointer, void *data, uint32_t time, dy = y - shsurf->resize.py; } - width = shsurf->resize.vw + dx; - height = shsurf->resize.vh + dy; - - shsurf->send_configure(shsurf, width, height); + shsurf->send_configure(shsurf, shsurf->resize.vw + dx, shsurf->resize.vh + dy); } static void @@ -946,10 +968,12 @@ shell_surface_resize(shell_surface_t *shsurf, pepper_seat_t *seat, uint32_t seri { pepper_pointer_t *pointer = pepper_seat_get_pointer(seat); + pepper_pointer_get_position(pointer, &shsurf->resize.px, &shsurf->resize.py); + pepper_view_get_position(shsurf->view, &shsurf->resize.vx, &shsurf->resize.vy); - pepper_view_get_size(shsurf->view, &shsurf->resize.vw, &shsurf->resize.vh); - pepper_pointer_get_position(pointer, &shsurf->resize.px, &shsurf->resize.py); + shsurf->resize.vw = shsurf->geometry.w; + shsurf->resize.vh = shsurf->geometry.h; shsurf->resize.edges = edges; shsurf->resize.resizing = PEPPER_TRUE; -- 2.34.1