mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-13 00:45:58 +01:00
util/time: de-duplicate timespec_to_msec
This commit is contained in:
parent
dc13bb827d
commit
c9c31f803e
4 changed files with 15 additions and 12 deletions
|
@ -1,9 +1,16 @@
|
|||
#ifndef UTIL_TIME_H
|
||||
#define UTIL_TIME_H
|
||||
|
||||
#include <time.h>
|
||||
|
||||
/**
|
||||
* Get the current time, in milliseconds.
|
||||
*/
|
||||
uint32_t get_current_time_msec(void);
|
||||
|
||||
/**
|
||||
* Convert a timespec to milliseconds.
|
||||
*/
|
||||
int64_t timespec_to_msec(const struct timespec *a);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "tablet-unstable-v2-protocol.h"
|
||||
#include "util/array.h"
|
||||
#include "util/time.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <types/wlr_tablet_v2.h>
|
||||
|
@ -301,16 +302,10 @@ static ssize_t tablet_tool_button_update(struct wlr_tablet_v2_tablet_tool *tool,
|
|||
return i;
|
||||
}
|
||||
|
||||
static inline int64_t timespec_to_msec(const struct timespec *a) {
|
||||
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
static void send_tool_frame(void *data) {
|
||||
struct wlr_tablet_tool_client_v2 *tool = data;
|
||||
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
zwp_tablet_tool_v2_send_frame(tool->resource, timespec_to_msec(&now));
|
||||
zwp_tablet_tool_v2_send_frame(tool->resource, get_current_time_msec());
|
||||
tool->frame_source = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <wlr/util/log.h>
|
||||
#include <wlr/util/region.h>
|
||||
#include "util/signal.h"
|
||||
#include "util/time.h"
|
||||
|
||||
#define CALLBACK_VERSION 1
|
||||
#define SURFACE_VERSION 4
|
||||
|
@ -1062,10 +1063,6 @@ void wlr_surface_send_leave(struct wlr_surface *surface,
|
|||
}
|
||||
}
|
||||
|
||||
static inline int64_t timespec_to_msec(const struct timespec *a) {
|
||||
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
void wlr_surface_send_frame_done(struct wlr_surface *surface,
|
||||
const struct timespec *when) {
|
||||
struct wl_resource *resource, *tmp;
|
||||
|
|
|
@ -4,8 +4,12 @@
|
|||
|
||||
#include "util/time.h"
|
||||
|
||||
int64_t timespec_to_msec(const struct timespec *a) {
|
||||
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
uint32_t get_current_time_msec(void) {
|
||||
struct timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
return now.tv_sec * 1000 + now.tv_nsec / 1000000;
|
||||
return timespec_to_msec(&now);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue