diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-04-21 15:21:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-21 15:21:52 +0200 |
commit | 4386dcb6247640de382e31dada9369b0861594dc (patch) | |
tree | d89bcb928037955d3bafa8dce7c9469fed4220a0 /sway/input/cursor.c | |
parent | 6e6decf38590e85c0c4d72f5215775e604516ad3 (diff) | |
parent | 4cf77e1de4b0be8b7d9374f04ff0e191ce22610a (diff) |
Merge pull request #1837 from emersion/cursor-default-to-current-time
Default to current time when triggering cursor events
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 5ed4f1f7..831109dc 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -15,6 +15,12 @@ #include "sway/tree/workspace.h" #include "wlr-layer-shell-unstable-v1-protocol.h" +static uint32_t get_current_time_msec() { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return now.tv_nsec / 1000; +} + static struct wlr_surface *layer_surface_at(struct sway_output *output, struct wl_list *layer, double ox, double oy, double *sx, double *sy) { struct sway_layer_surface *sway_layer; @@ -128,7 +134,11 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor, return output->swayc; } -void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time) { +void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec) { + if (time_msec == 0) { + time_msec = get_current_time_msec(); + } + struct wlr_seat *seat = cursor->seat->wlr_seat; struct wlr_surface *surface = NULL; double sx, sy; @@ -152,7 +162,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time) { if (surface != NULL) { if (seat_is_input_allowed(cursor->seat, surface)) { wlr_seat_pointer_notify_enter(seat, surface, sx, sy); - wlr_seat_pointer_notify_motion(seat, time, sx, sy); + wlr_seat_pointer_notify_motion(seat, time_msec, sx, sy); } } else { wlr_seat_pointer_clear_focus(seat); @@ -178,6 +188,10 @@ static void handle_cursor_motion_absolute( void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec, uint32_t button, enum wlr_button_state state) { + if (time_msec == 0) { + time_msec = get_current_time_msec(); + } + struct wlr_surface *surface = NULL; double sx, sy; struct sway_container *cont = |