mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-29 05:40:12 -04:00
util: fix and move get_current_time_msec into a util file
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/time.cc` so that it can be reused elsewhere without having to consider these pitfalls.
This commit is contained in:
parent
dcae6f1431
commit
dc13bb827d
5 changed files with 23 additions and 12 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include <wlr/interfaces/wlr_input_device.h>
|
||||
|
||||
#include "util/signal.h"
|
||||
#include "util/time.h"
|
||||
#include "wlr/util/log.h"
|
||||
#include "tablet-unstable-v2-client-protocol.h"
|
||||
|
||||
|
|
@ -84,12 +85,6 @@ struct wlr_wl_tablet_pad_group {
|
|||
struct wl_list strips; // wlr_wl_tablet_pad_strips::link
|
||||
};
|
||||
|
||||
static uint32_t get_current_time_msec(void) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
return now.tv_nsec / (1000 * 1000) + now.tv_sec * 1000;
|
||||
}
|
||||
|
||||
static void handle_tablet_pad_ring_source(void *data,
|
||||
struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2,
|
||||
uint32_t source) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue