Cancel rootston move/resize/rotate on escape press

This commit is contained in:
Vincent Vanlaer 2018-02-06 12:36:38 +01:00
parent 7e3bb39d49
commit 7ae8800a63
3 changed files with 45 additions and 0 deletions

View file

@ -84,11 +84,17 @@ 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_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, void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view,
uint32_t edges); 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_begin_rotate(struct roots_seat *seat, struct roots_view *view);
void roots_seat_cancel_rotate(struct roots_seat *seat);
struct roots_seat_view *roots_seat_view_from_view( struct roots_seat *seat, struct roots_seat_view *roots_seat_view_from_view( struct roots_seat *seat,
struct roots_view *view); struct roots_view *view);

View file

@ -159,6 +159,9 @@ static bool keyboard_execute_compositor_binding(struct roots_keyboard *keyboard,
if (keysym == XKB_KEY_Escape) { if (keysym == XKB_KEY_Escape) {
wlr_seat_pointer_end_grab(keyboard->seat->seat); wlr_seat_pointer_end_grab(keyboard->seat->seat);
wlr_seat_keyboard_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; return false;

View file

@ -738,6 +738,18 @@ void roots_seat_begin_move(struct roots_seat *seat, struct roots_view *view) {
ROOTS_XCURSOR_MOVE, seat->cursor->cursor); 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, void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view,
uint32_t edges) { uint32_t edges) {
struct roots_cursor *cursor = seat->cursor; struct roots_cursor *cursor = seat->cursor;
@ -766,6 +778,18 @@ void roots_seat_begin_resize(struct roots_seat *seat, struct roots_view *view,
resize_name, seat->cursor->cursor); 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) { void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) {
struct roots_cursor *cursor = seat->cursor; struct roots_cursor *cursor = seat->cursor;
cursor->mode = ROOTS_CURSOR_ROTATE; cursor->mode = ROOTS_CURSOR_ROTATE;
@ -778,3 +802,15 @@ void roots_seat_begin_rotate(struct roots_seat *seat, struct roots_view *view) {
wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager, wlr_xcursor_manager_set_cursor_image(seat->cursor->xcursor_manager,
ROOTS_XCURSOR_ROTATE, seat->cursor->cursor); ROOTS_XCURSOR_ROTATE, seat->cursor->cursor);
} }
void roots_seat_cancel_rotate(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) {
return;
}
cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
view->rotation = cursor->view_rotation;
}