Merge pull request #609 from VincentVanlaer/cancel-grab
Cancel rootson move/resize/rotate on escape
This commit is contained in:
commit
09c2626e32
|
@ -89,6 +89,8 @@ 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_begin_rotate(struct roots_seat *seat, struct roots_view *view);
|
||||||
|
|
||||||
|
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_seat_view *roots_seat_view_from_view( struct roots_seat *seat,
|
||||||
struct roots_view *view);
|
struct roots_view *view);
|
||||||
|
|
||||||
|
|
|
@ -244,40 +244,33 @@ static void roots_cursor_press_button(struct roots_cursor *cursor,
|
||||||
roots_seat_begin_rotate(seat, view);
|
roots_seat_begin_rotate(seat, view);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
if (view && !surface) {
|
if (view && !surface) {
|
||||||
if (cursor->pointer_view) {
|
if (cursor->pointer_view) {
|
||||||
seat_view_deco_button(cursor->pointer_view, sx, sy, button, state);
|
seat_view_deco_button(cursor->pointer_view, sx, sy, button, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == WLR_BUTTON_RELEASED &&
|
||||||
|
cursor->mode != ROOTS_CURSOR_PASSTHROUGH) {
|
||||||
|
cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
case WLR_BUTTON_RELEASED:
|
||||||
|
if (!is_touch) {
|
||||||
|
roots_cursor_update_position(cursor, time);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case WLR_BUTTON_PRESSED:
|
||||||
|
roots_seat_set_focus(seat, view);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == WLR_BUTTON_RELEASED &&
|
if (!is_touch) {
|
||||||
cursor->mode != ROOTS_CURSOR_PASSTHROUGH) {
|
wlr_seat_pointer_notify_button(seat->seat, time, button, state);
|
||||||
cursor->mode = ROOTS_CURSOR_PASSTHROUGH;
|
|
||||||
if (seat->seat->pointer_state.button_count == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((view && surface) ||
|
|
||||||
(state == WLR_BUTTON_RELEASED &&
|
|
||||||
seat->seat->pointer_state.button_count != 0)) {
|
|
||||||
if (!is_touch) {
|
|
||||||
wlr_seat_pointer_notify_button(seat->seat, time, button, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (state) {
|
|
||||||
case WLR_BUTTON_RELEASED:
|
|
||||||
if (!is_touch) {
|
|
||||||
roots_cursor_update_position(cursor, time);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WLR_BUTTON_PRESSED:
|
|
||||||
roots_seat_set_focus(seat, view);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,7 @@ 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_end_compositor_grab(keyboard->seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -778,3 +778,28 @@ 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_end_compositor_grab(struct roots_seat *seat) {
|
||||||
|
struct roots_cursor *cursor = seat->cursor;
|
||||||
|
struct roots_view *view = roots_seat_get_focus(seat);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue