aboutsummaryrefslogtreecommitdiff
path: root/rootston/cursor.c
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2017-09-30 13:22:42 +0200
committeremersion <contact@emersion.fr>2017-09-30 13:22:42 +0200
commit28d4b475dc74302653882e5f5f58506c5c16bcb6 (patch)
treeabb3f42949154bc67a40770a008fa99664d1917e /rootston/cursor.c
parent33a97576ca3169b7771a0bd574383f5cf502f583 (diff)
Add edges support, remove get_input_bounds
Diffstat (limited to 'rootston/cursor.c')
-rw-r--r--rootston/cursor.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/rootston/cursor.c b/rootston/cursor.c
index c57bff52..ac6b1dc3 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 - (double)view->wlr_surface->current.width - view->x;
- input->offs_y = cursor->y - (double)view->wlr_surface->current.height - view->y;
+ input->offs_x = cursor->x - view->x;
+ input->offs_y = cursor->y - view->y;
+ input->view_width = view->wlr_surface->current.width;
+ input->view_height = view->wlr_surface->current.height;
input->resize_edges = edges;
wlr_seat_pointer_clear_focus(input->wl_seat);
}
@@ -64,9 +66,24 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
break;
case ROOTS_CURSOR_RESIZE:
if (input->active_view) {
- // TODO: edges
- uint32_t width = input->cursor->x - input->offs_x;
- uint32_t height = input->cursor->y - input->offs_y;
+ int dx = input->cursor->x - input->offs_x;
+ int dy = input->cursor->y - input->offs_y;
+ int width = input->view_width;
+ int height = input->view_height;
+ if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_TOP) {
+ input->active_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;
+ width -= dx;
+ }
+ if (input->resize_edges & ROOTS_CURSOR_RESIZE_EDGE_RIGHT) {
+ width += dx;
+ }
view_resize(input->active_view, width, height);
}
break;