From 77d28183b53a9fc85efe4788f3a53f3077084f6b Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 30 Sep 2017 13:54:51 +0200 Subject: Partially fix resize offset --- include/rootston/input.h | 2 +- rootston/cursor.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/rootston/input.h b/include/rootston/input.h index c2e0ff75..1fae07d7 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -78,7 +78,7 @@ struct roots_input { enum roots_cursor_mode mode; struct roots_view *active_view; int offs_x, offs_y; - int view_width, view_height; + int view_x, view_y, view_width, view_height; uint32_t resize_edges; // Ring buffer of input events that could trigger move/resize/rotate diff --git a/rootston/cursor.c b/rootston/cursor.c index ac6b1dc3..bef30746 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -33,8 +33,10 @@ void view_begin_resize(struct roots_input *input, struct wlr_cursor *cursor, struct roots_view *view, uint32_t edges) { input->mode = ROOTS_CURSOR_RESIZE; wlr_log(L_DEBUG, "begin resize"); - input->offs_x = cursor->x - view->x; - input->offs_y = cursor->y - view->y; + input->offs_x = cursor->x; + input->offs_y = cursor->y; + input->view_x = view->x; + input->view_y = view->y; input->view_width = view->wlr_surface->current.width; input->view_height = view->wlr_surface->current.height; input->resize_edges = edges; @@ -71,14 +73,14 @@ void cursor_update_position(struct roots_input *input, uint32_t time) { int width = input->view_width; int height = input->view_height; if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) { - input->active_view->y = dy; + input->active_view->y = input->view_y + dy; height -= dy; } if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_BOTTOM) { height += dy; } if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_LEFT) { - input->active_view->x = dx; + input->active_view->x = input->view_x + dx; width -= dx; } if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) { -- cgit v1.2.3