File fix-zero-time.diff of Package sway
diff --git a/common/util.c b/common/util.c
index 7c492bcbf3..ae1fe4431d 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 f887d4895f..92f5916cf2 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 1fd57ec4e9..aeab558cbf 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);
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index a2e99d2bc6..19645b4c97 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -16,6 +16,7 @@
#include "sway/tree/view.h"
#include "sway/tree/workspace.h"
#include "log.h"
+#include "util.h"
#if WLR_HAS_XWAYLAND
#include "sway/xwayland.h"
#endif
@@ -1148,5 +1149,7 @@ void seatop_begin_default(struct sway_seat *seat) {
seat->seatop_impl = &seatop_impl;
seat->seatop_data = e;
- seatop_rebase(seat, 0);
+
+ uint32_t time_msec = get_current_time_in_msec();
+ seatop_rebase(seat, time_msec);
}