diff options
author | Kenny Levinsen <kl@kl.wtf> | 2021-06-20 19:24:55 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-06-23 09:55:36 +0200 |
commit | 80315217f76e923cb19cdb76aaf9a5d177f11f61 (patch) | |
tree | 59a519c26f1803c168bbf8154e72e1c9a95e2fc1 | |
parent | Update clang format to better match existing code (diff) | |
download | sway-80315217f76e923cb19cdb76aaf9a5d177f11f61.tar.gz sway-80315217f76e923cb19cdb76aaf9a5d177f11f61.tar.zst sway-80315217f76e923cb19cdb76aaf9a5d177f11f61.zip |
input: Move get_current_time_msec in from util
get_current_time_msec is only used in cursor.c, so we can move it in and
make it static. This is primarily intended to avoid a symbol collision
with wlroots, which we unfortunately do not have a good solution for
yet.
-rw-r--r-- | common/util.c | 6 | ||||
-rw-r--r-- | include/util.h | 6 | ||||
-rw-r--r-- | sway/input/cursor.c | 7 |
3 files changed, 7 insertions, 12 deletions
diff --git a/common/util.c b/common/util.c index 5ea94f48..199f3ee1 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -10,12 +10,6 @@ | |||
10 | #include "log.h" | 10 | #include "log.h" |
11 | #include "util.h" | 11 | #include "util.h" |
12 | 12 | ||
13 | uint32_t get_current_time_msec(void) { | ||
14 | struct timespec now; | ||
15 | clock_gettime(CLOCK_MONOTONIC, &now); | ||
16 | return now.tv_sec * 1000 + now.tv_nsec / 1000000; | ||
17 | } | ||
18 | |||
19 | int wrap(int i, int max) { | 13 | int wrap(int i, int max) { |
20 | return ((i % max) + max) % max; | 14 | return ((i % max) + max) % max; |
21 | } | 15 | } |
diff --git a/include/util.h b/include/util.h index c80da1cb..f887d489 100644 --- a/include/util.h +++ b/include/util.h | |||
@@ -30,12 +30,6 @@ int parse_movement_amount(int argc, char **argv, | |||
30 | struct movement_amount *amount); | 30 | struct movement_amount *amount); |
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Get the current time, in milliseconds. | ||
34 | */ | ||
35 | |||
36 | uint32_t get_current_time_msec(void); | ||
37 | |||
38 | /** | ||
39 | * Wrap i into the range [0, max] | 33 | * Wrap i into the range [0, max] |
40 | */ | 34 | */ |
41 | int wrap(int i, int max); | 35 | int wrap(int i, int max); |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index cbb5c6e9..c89d5166 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <libevdev/libevdev.h> | 4 | #include <libevdev/libevdev.h> |
5 | #include <linux/input-event-codes.h> | 5 | #include <linux/input-event-codes.h> |
6 | #include <errno.h> | 6 | #include <errno.h> |
7 | #include <time.h> | ||
7 | #include <strings.h> | 8 | #include <strings.h> |
8 | #include <wlr/types/wlr_box.h> | 9 | #include <wlr/types/wlr_box.h> |
9 | #include <wlr/types/wlr_cursor.h> | 10 | #include <wlr/types/wlr_cursor.h> |
@@ -31,6 +32,12 @@ | |||
31 | #include "sway/tree/workspace.h" | 32 | #include "sway/tree/workspace.h" |
32 | #include "wlr-layer-shell-unstable-v1-protocol.h" | 33 | #include "wlr-layer-shell-unstable-v1-protocol.h" |
33 | 34 | ||
35 | static uint32_t get_current_time_msec(void) { | ||
36 | struct timespec now; | ||
37 | clock_gettime(CLOCK_MONOTONIC, &now); | ||
38 | return now.tv_sec * 1000 + now.tv_nsec / 1000000; | ||
39 | } | ||
40 | |||
34 | static struct wlr_surface *layer_surface_at(struct sway_output *output, | 41 | static struct wlr_surface *layer_surface_at(struct sway_output *output, |
35 | struct wl_list *layer, double ox, double oy, double *sx, double *sy) { | 42 | struct wl_list *layer, double ox, double oy, double *sx, double *sy) { |
36 | struct sway_layer_surface *sway_layer; | 43 | struct sway_layer_surface *sway_layer; |