diff --git a/common/util.c b/common/util.c index 7c492bcbf..ae1fe4431 100644 --- a/common/util.c +++ b/common/util.c @@ -141,3 +141,9 @@ bool sway_set_cloexec(int fd, bool cloexec) { } return true; } + +uint32_t get_current_time_in_msec(void) { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return now.tv_sec * 1000 + now.tv_nsec / 1000000; +} diff --git a/include/util.h b/include/util.h index f887d4895..92f5916cf 100644 --- a/include/util.h +++ b/include/util.h @@ -61,4 +61,6 @@ const char *sway_wl_output_subpixel_to_string(enum wl_output_subpixel subpixel); bool sway_set_cloexec(int fd, bool cloexec); +uint32_t get_current_time_in_msec(void); + #endif diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 1fd57ec4e..aeab558cb 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -32,12 +32,6 @@ #include "sway/tree/workspace.h" #include "wlr-layer-shell-unstable-v1-protocol.h" -static uint32_t get_current_time_msec(void) { - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - return now.tv_sec * 1000 + now.tv_nsec / 1000000; -} - /** * Returns the node at the cursor's position. If there is a surface at that * location, it is stored in **surface (it may not be a view). @@ -144,7 +138,7 @@ struct sway_node *node_at_coords( } void cursor_rebase(struct sway_cursor *cursor) { - uint32_t time_msec = get_current_time_msec(); + uint32_t time_msec = get_current_time_in_msec(); seatop_rebase(cursor->seat, time_msec); } @@ -359,7 +353,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, struct wlr_input_device *device, uint32_t time_msec, uint32_t button, enum wl_pointer_button_state state) { if (time_msec == 0) { - time_msec = get_current_time_msec(); + time_msec = get_current_time_in_msec(); } seatop_button(cursor->seat, time_msec, device, button, state);