diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-02-29 14:38:04 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-02-29 14:38:04 +0000 |
| commit | ea2d7f8b8c5782d422d02058861fa9a754055b17 (patch) | |
| tree | 150350b1a7da835f44a8c9aa54ca64f288b66370 /input.c | |
| parent | input: fix 'unused variable' warning (release builds) (diff) | |
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.
Diffstat (limited to 'input.c')
| -rw-r--r-- | input.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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: |
