diff --git a/common/util.c b/common/util.c index c7ef2ac4..cb142a5e 100644 --- a/common/util.c +++ b/common/util.c @@ -1,8 +1,8 @@ #define _POSIX_C_SOURCE 200809L #include -#include #include #include +#include #include #include #include @@ -10,6 +10,12 @@ #include "log.h" #include "util.h" +uint32_t get_current_time_msec(void) { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return now.tv_sec * 1000 + now.tv_nsec / 1000000; +} + int wrap(int i, int max) { return ((i % max) + max) % max; } diff --git a/include/util.h b/include/util.h index 867eb0a4..7f47d713 100644 --- a/include/util.h +++ b/include/util.h @@ -6,7 +6,13 @@ #include /** - * Wrap i into the range [0, max[ + * Get the current time, in milliseconds. + */ + +uint32_t get_current_time_msec(void); + +/** + * Wrap i into the range [0, max] */ int wrap(int i, int max); diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 8e39dac1..d6c50acc 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -4,8 +4,6 @@ #include #include #include -#include -#include #include #include #include @@ -13,9 +11,9 @@ #include #include #include -#include "list.h" -#include "log.h" #include "config.h" +#include "log.h" +#include "util.h" #include "sway/commands.h" #include "sway/desktop.h" #include "sway/desktop/transaction.h" @@ -24,19 +22,12 @@ #include "sway/input/tablet.h" #include "sway/layers.h" #include "sway/output.h" -#include "sway/tree/arrange.h" #include "sway/tree/container.h" #include "sway/tree/root.h" #include "sway/tree/view.h" #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_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;