input: start window move right away if user starts dragging the window

When the user left-clicks the title-bar, we start a timer. When the
timer has elapsed, we initiate a 'move' operation.

However, if the user clicked, and then started dragging right away,
there was a very visible lag since we waited for the timeout before
starting the move.

Now, on a pointer motion event we detect a running 'move' timer, and
abort it and instead start the 'move' operation right away.
This commit is contained in:
Daniel Eklöf 2020-02-29 15:38:04 +01:00
parent 33744ebe63
commit ea2d7f8b8c
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

19
input.c
View file

@ -758,6 +758,7 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
{
struct wayland *wayl = data;
struct terminal *term = wayl->mouse_focus;
struct wl_window *win = term->window;
/* Workaround buggy Sway 1.2 */
if (term == NULL) {
@ -787,7 +788,17 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
switch (term->active_surface) {
case TERM_SURF_NONE:
case TERM_SURF_SEARCH:
break;
case TERM_SURF_TITLE:
/* We've started a 'move' timer, but user started dragging
* right away - abort the timer and initiate the actual move
* right away */
if (wayl->mouse.button == BTN_LEFT && win->csd.move_timeout_fd != -1) {
fdm_del(wayl->fdm, win->csd.move_timeout_fd);
win->csd.move_timeout_fd = -1;
xdg_toplevel_move(win->xdg_toplevel, wayl->seat, win->csd.serial);
}
break;
case TERM_SURF_BORDER_LEFT:
@ -922,6 +933,14 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
}
}
}
else if (state == WL_POINTER_BUTTON_STATE_RELEASED) {
struct wl_window *win = term->window;
if (win->csd.move_timeout_fd != -1) {
fdm_del(wayl->fdm, win->csd.move_timeout_fd);
win->csd.move_timeout_fd = -1;
}
}
return;
case TERM_SURF_BORDER_LEFT: