wlroots/include/util/time.h
Daniel Hill 47f8cefad8 output/cursor: deferred cursor move
This feature is meant to be used with VRR / Adaptive Sync.
Currently cursor move drives the display at the poll rate of the mouse.
This adds a deferred delay for a variety situations:
To save power on battery
To maintain smooth video playback (i.e. render video 30fps at 60 or 120fps)
To maintain smooth gaming experience (i.e. only enforce redraw at VRR minimum Hz)

I've tried to make it as unopinionated as possible, while also reducing
complexity for downstream developers.

The design should be backwards compatible, as long as
wlr_set_cursor_max_latency() is never called wlr_cursor_move() should act as
normal

I considered using wl_signals, but I'm not familiar with the interface, and it
felt somewhat overkill.

There's a reference implementation in branch deferred-cursor-move:
github:YellowOnion/sway
2024-04-24 22:00:13 +12:00

37 lines
742 B
C

#ifndef UTIL_TIME_H
#define UTIL_TIME_H
#include <stdint.h>
#include <time.h>
static const long NSEC_PER_SEC = 1000000000;
/**
* Get the current time, in milliseconds.
*/
int64_t get_current_time_msec(void);
/**
* Convert a timespec to milliseconds.
*/
int64_t timespec_to_msec(const struct timespec *a);
/**
* Convert a timespec to nanoseconds.
*/
int64_t timespec_to_nsec(const struct timespec *a);
/**
* Convert nanoseconds to a timespec.
*/
void timespec_from_nsec(struct timespec *r, int64_t nsec);
/**
* Subtracts timespec `b` from timespec `a`, and stores the difference in `r`.
*/
void timespec_sub(struct timespec *r, const struct timespec *a,
const struct timespec *b);
int32_t mhz_to_nsec(int32_t mhz);
#endif