From 7ae8800a637f9c4b0bc0ab33e10bc40fc30f91fa Mon Sep 17 00:00:00 2001 From: Vincent Vanlaer Date: Tue, 6 Feb 2018 12:36:38 +0100 Subject: Cancel rootston move/resize/rotate on escape press --- rootston/keyboard.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'rootston/keyboard.c') diff --git a/rootston/keyboard.c b/rootston/keyboard.c index f1123599..c29df46a 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -159,6 +159,9 @@ static bool keyboard_execute_compositor_binding(struct roots_keyboard *keyboard, if (keysym == XKB_KEY_Escape) { wlr_seat_pointer_end_grab(keyboard->seat->seat); wlr_seat_keyboard_end_grab(keyboard->seat->seat); + roots_seat_cancel_move(keyboard->seat); + roots_seat_cancel_resize(keyboard->seat); + roots_seat_cancel_rotate(keyboard->seat); } return false; -- cgit v1.2.3 From 90eb50d9aabe7665ae081c869b2986c691150b56 Mon Sep 17 00:00:00 2001 From: Vincent Vanlaer Date: Tue, 6 Feb 2018 22:55:56 +0100 Subject: Merge roots_seat_cancel_* into one function --- include/rootston/seat.h | 6 +----- rootston/keyboard.c | 4 +--- rootston/seat.c | 43 ++++++++++++++++--------------------------- 3 files changed, 18 insertions(+), 35 deletions(-) (limited to 'rootston/keyboard.c') diff --git a/include/rootston/seat.h b/include/rootston/seat.h index 70e8e867..0eb3bee8 100644 --- a/include/rootston/seat.h +++ b/include/rootston/seat.h @@ -84,16 +84,12 @@ void roots_seat_cycle_focus(struct roots_seat *seat); void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view); -void roots_seat_cancel_move(struct roots_seat *seat); - void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, uint32_t edges); -void roots_seat_cancel_resize(struct roots_seat *seat); - void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view); -void roots_seat_cancel_rotate(struct roots_seat *seat); +void roots_seat_cancel_transform(struct roots_seat *seat); struct roots_seat_view *roots_seat_view_from_view( struct roots_seat *seat, struct roots_view *view); diff --git a/rootston/keyboard.c b/rootston/keyboard.c index c29df46a..e399ac96 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -159,9 +159,7 @@ static bool keyboard_execute_compositor_binding(struct roots_keyboard *keyboard, if (keysym == XKB_KEY_Escape) { wlr_seat_pointer_end_grab(keyboard->seat->seat); wlr_seat_keyboard_end_grab(keyboard->seat->seat); - roots_seat_cancel_move(keyboard->seat); - roots_seat_cancel_resize(keyboard->seat); - roots_seat_cancel_rotate(keyboard->seat); + roots_seat_cancel_transform(keyboard->seat); } return false; diff --git a/rootston/seat.c b/rootston/seat.c index a97f66ba..559a8b7f 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -738,18 +738,6 @@ void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) { ROOTS_XCURSOR_MOVE, seat->cursor->cursor); } -void roots_seat_cancel_move(struct roots_seat *seat) { - struct roots_cursor *cursor = seat->cursor; - struct roots_view *view = roots_seat_get_focus(seat); - - if (cursor->mode != ROOTS_CURSOR_MOVE || view == NULL) { - return; - } - - cursor->mode = ROOTS_CURSOR_PASSTHROUGH; - view_move(view, cursor->view_x, cursor->view_y); -} - void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, uint32_t edges) { struct roots_cursor *cursor = seat->cursor; @@ -778,18 +766,6 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, resize_name, seat->cursor->cursor); } -void roots_seat_cancel_resize(struct roots_seat *seat) { - struct roots_cursor *cursor = seat->cursor; - struct roots_view *view = roots_seat_get_focus(seat); - - if (cursor->mode != ROOTS_CURSOR_RESIZE || view == NULL) { - return; - } - - cursor->mode = ROOTS_CURSOR_PASSTHROUGH; - view_move_resize(view, cursor->view_x, cursor->view_y, cursor->view_width, cursor->view_height); -} - void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) { struct roots_cursor *cursor = seat->cursor; cursor->mode = ROOTS_CURSOR_ROTATE; @@ -803,14 +779,27 @@ void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) { ROOTS_XCURSOR_ROTATE, seat->cursor->cursor); } -void roots_seat_cancel_rotate(struct roots_seat *seat) { +void roots_seat_cancel_transform(struct roots_seat *seat) { struct roots_cursor *cursor = seat->cursor; struct roots_view *view = roots_seat_get_focus(seat); - if (cursor->mode != ROOTS_CURSOR_ROTATE || view == NULL) { + if (view == NULL) { return; } + switch(cursor->mode) { + case ROOTS_CURSOR_MOVE: + view_move(view, cursor->view_x, cursor->view_y); + break; + case ROOTS_CURSOR_RESIZE: + view_move_resize(view, cursor->view_x, cursor->view_y, cursor->view_width, cursor->view_height); + break; + case ROOTS_CURSOR_ROTATE: + view->rotation = cursor->view_rotation; + break; + case ROOTS_CURSOR_PASSTHROUGH: + break; + } + cursor->mode = ROOTS_CURSOR_PASSTHROUGH; - view->rotation = cursor->view_rotation; } -- cgit v1.2.3 From 74264d4f6243fc8ff87e66faf1940d3dd9d5b501 Mon Sep 17 00:00:00 2001 From: Vincent Vanlaer Date: Thu, 8 Feb 2018 13:13:33 +0100 Subject: Rename roots_seat_cancel_transform --- include/rootston/seat.h | 2 +- rootston/keyboard.c | 2 +- rootston/seat.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'rootston/keyboard.c') diff --git a/include/rootston/seat.h b/include/rootston/seat.h index 0eb3bee8..2be8e467 100644 --- a/include/rootston/seat.h +++ b/include/rootston/seat.h @@ -89,7 +89,7 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view, void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view); -void roots_seat_cancel_transform(struct roots_seat *seat); +void roots_seat_end_compositor_grab(struct roots_seat *seat); struct roots_seat_view *roots_seat_view_from_view( struct roots_seat *seat, struct roots_view *view); diff --git a/rootston/keyboard.c b/rootston/keyboard.c index e399ac96..ddf541b4 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -159,7 +159,7 @@ static bool keyboard_execute_compositor_binding(struct roots_keyboard *keyboard, if (keysym == XKB_KEY_Escape) { wlr_seat_pointer_end_grab(keyboard->seat->seat); wlr_seat_keyboard_end_grab(keyboard->seat->seat); - roots_seat_cancel_transform(keyboard->seat); + roots_seat_end_compositor_grab(keyboard->seat); } return false; diff --git a/rootston/seat.c b/rootston/seat.c index 559a8b7f..edb98095 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -779,7 +779,7 @@ void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) { ROOTS_XCURSOR_ROTATE, seat->cursor->cursor); } -void roots_seat_cancel_transform(struct roots_seat *seat) { +void roots_seat_end_compositor_grab(struct roots_seat *seat) { struct roots_cursor *cursor = seat->cursor; struct roots_view *view = roots_seat_get_focus(seat); -- cgit v1.2.3