Rename get_current_time_msec to get_current_time_in_msec and move to util.c

get_current_time_msec conflicts with a function with the same name in wlroots.
This commit is contained in:
hwsmm 2025-06-16 00:41:19 +09:00 committed by Kenny Levinsen
parent 17f7c1b782
commit 4b15b3427f
3 changed files with 10 additions and 8 deletions

View file

@ -141,3 +141,9 @@ bool sway_set_cloexec(int fd, bool cloexec) {
} }
return true; 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;
}

View file

@ -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); bool sway_set_cloexec(int fd, bool cloexec);
uint32_t get_current_time_in_msec(void);
#endif #endif

View file

@ -32,12 +32,6 @@
#include "sway/tree/workspace.h" #include "sway/tree/workspace.h"
#include "wlr-layer-shell-unstable-v1-protocol.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 * 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). * 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) { 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); 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, struct wlr_input_device *device, uint32_t time_msec, uint32_t button,
enum wl_pointer_button_state state) { enum wl_pointer_button_state state) {
if (time_msec == 0) { 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); seatop_button(cursor->seat, time_msec, device, button, state);