diff options
-rw-r--r-- | common/util.c | 8 | ||||
-rw-r--r-- | include/util.h | 8 | ||||
-rw-r--r-- | sway/input/cursor.c | 13 |
3 files changed, 16 insertions, 13 deletions
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 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <ctype.h> | 2 | #include <ctype.h> |
3 | #include <float.h> | ||
4 | #include <fcntl.h> | 3 | #include <fcntl.h> |
5 | #include <math.h> | 4 | #include <math.h> |
5 | #include <time.h> | ||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <string.h> | 7 | #include <string.h> |
8 | #include <strings.h> | 8 | #include <strings.h> |
@@ -10,6 +10,12 @@ | |||
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 | |||
13 | int wrap(int i, int max) { | 19 | int wrap(int i, int max) { |
14 | return ((i % max) + max) % max; | 20 | return ((i % max) + max) % max; |
15 | } | 21 | } |
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 @@ | |||
6 | #include <wayland-server-protocol.h> | 6 | #include <wayland-server-protocol.h> |
7 | 7 | ||
8 | /** | 8 | /** |
9 | * Wrap i into the range [0, max[ | 9 | * Get the current time, in milliseconds. |
10 | */ | ||
11 | |||
12 | uint32_t get_current_time_msec(void); | ||
13 | |||
14 | /** | ||
15 | * Wrap i into the range [0, max] | ||
10 | */ | 16 | */ |
11 | int wrap(int i, int max); | 17 | int wrap(int i, int max); |
12 | 18 | ||
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 @@ | |||
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 <float.h> | ||
8 | #include <limits.h> | ||
9 | #include <strings.h> | 7 | #include <strings.h> |
10 | #include <wlr/types/wlr_box.h> | 8 | #include <wlr/types/wlr_box.h> |
11 | #include <wlr/types/wlr_cursor.h> | 9 | #include <wlr/types/wlr_cursor.h> |
@@ -13,9 +11,9 @@ | |||
13 | #include <wlr/types/wlr_tablet_v2.h> | 11 | #include <wlr/types/wlr_tablet_v2.h> |
14 | #include <wlr/types/wlr_xcursor_manager.h> | 12 | #include <wlr/types/wlr_xcursor_manager.h> |
15 | #include <wlr/util/region.h> | 13 | #include <wlr/util/region.h> |
16 | #include "list.h" | ||
17 | #include "log.h" | ||
18 | #include "config.h" | 14 | #include "config.h" |
15 | #include "log.h" | ||
16 | #include "util.h" | ||
19 | #include "sway/commands.h" | 17 | #include "sway/commands.h" |
20 | #include "sway/desktop.h" | 18 | #include "sway/desktop.h" |
21 | #include "sway/desktop/transaction.h" | 19 | #include "sway/desktop/transaction.h" |
@@ -24,19 +22,12 @@ | |||
24 | #include "sway/input/tablet.h" | 22 | #include "sway/input/tablet.h" |
25 | #include "sway/layers.h" | 23 | #include "sway/layers.h" |
26 | #include "sway/output.h" | 24 | #include "sway/output.h" |
27 | #include "sway/tree/arrange.h" | ||
28 | #include "sway/tree/container.h" | 25 | #include "sway/tree/container.h" |
29 | #include "sway/tree/root.h" | 26 | #include "sway/tree/root.h" |
30 | #include "sway/tree/view.h" | 27 | #include "sway/tree/view.h" |
31 | #include "sway/tree/workspace.h" | 28 | #include "sway/tree/workspace.h" |
32 | #include "wlr-layer-shell-unstable-v1-protocol.h" | 29 | #include "wlr-layer-shell-unstable-v1-protocol.h" |
33 | 30 | ||
34 | static uint32_t get_current_time_msec(void) { | ||
35 | struct timespec now; | ||
36 | clock_gettime(CLOCK_MONOTONIC, &now); | ||
37 | return now.tv_nsec / 1000; | ||
38 | } | ||
39 | |||
40 | static struct wlr_surface *layer_surface_at(struct sway_output *output, | 31 | static struct wlr_surface *layer_surface_at(struct sway_output *output, |
41 | struct wl_list *layer, double ox, double oy, double *sx, double *sy) { | 32 | struct wl_list *layer, double ox, double oy, double *sx, double *sy) { |
42 | struct sway_layer_surface *sway_layer; | 33 | struct sway_layer_surface *sway_layer; |