Skip to content

Commit

Permalink
deferred cursors: add a max_cursor_latency for output
Browse files Browse the repository at this point in the history
  • Loading branch information
YellowOnion committed Aug 15, 2024
1 parent 4ef42e5 commit 1d5107d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/wlr/types/wlr_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ struct wlr_output {
enum wlr_output_adaptive_sync_status adaptive_sync_status;
uint32_t render_format;

int max_cursor_latency;

bool needs_frame;
// damage for cursors and fullscreen surface, in output-local coordinates
bool frame_pending;
Expand Down
9 changes: 7 additions & 2 deletions types/output/cursor.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,12 @@ static bool output_cursor_move(struct wlr_output_cursor *cursor,

static bool output_cursor_move_should_defer(struct wlr_output_cursor *cursor,
struct timespec *now) {
if (!cursor->max_latency
int max_latency = cursor->max_latency;

if (!max_latency)
max_latency = cursor->output->max_cursor_latency;

if (!max_latency
|| !cursor->output->refresh // avoid divide by zero
|| cursor->output->adaptive_sync_status != WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED)
return false;
Expand All @@ -518,7 +523,7 @@ static bool output_cursor_move_should_defer(struct wlr_output_cursor *cursor,
int32_t vrr_min = NSEC_PER_SEC / 30; // edid? enforce 30fps minimum for now.
timespec_sub(&delta, now, &cursor->last_presentation);
if (delta.tv_sec
|| delta.tv_nsec >= cursor->max_latency
|| delta.tv_nsec >= max_latency
|| delta.tv_nsec >= vrr_min)
return false;

Expand Down

0 comments on commit 1d5107d

Please sign in to comment.