diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-06-05 17:12:31 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-06-06 13:38:41 +0200 |
commit | d7900c6e5e82406c1ed6a6df2ff3d1896149deff (patch) | |
tree | ed8ca52d119bdbc250c3e2e7d5e7f8f63d450449 /sway | |
parent | Add wayland_client dependency to common (diff) | |
download | sway-d7900c6e5e82406c1ed6a6df2ff3d1896149deff.tar.gz sway-d7900c6e5e82406c1ed6a6df2ff3d1896149deff.tar.zst sway-d7900c6e5e82406c1ed6a6df2ff3d1896149deff.zip |
common/util: fix `get_current_time_msec` returning microseconds
This commit makes `get_current_time_msec` correctly return milliseconds
as opposed to microseconds. It also considers the value of `tv_sec`, so
we don't lose occasionally go back in time by one second. Finally, the
function is moved into `util.c` so that it can be reused elsewhere
without having to consider these pitfalls.
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/cursor.c | 13 |
1 files changed, 2 insertions, 11 deletions
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; |