mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-02-07 04:06:14 -05:00
cursor_move defer when enable ADAPTIVE_SYNC
split out from https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4340 Co-authored-by: Daniel Hill <daniel@gluo.nz>
This commit is contained in:
parent
106f0f9506
commit
d9e2c84c49
2 changed files with 35 additions and 1 deletions
|
|
@ -51,6 +51,9 @@ struct wlr_output_cursor {
|
|||
uint64_t wait_point;
|
||||
struct wl_list link;
|
||||
|
||||
bool deferred;
|
||||
double deferred_x, deferred_y;
|
||||
|
||||
struct {
|
||||
struct wl_listener renderer_destroy;
|
||||
} WLR_PRIVATE;
|
||||
|
|
@ -459,6 +462,7 @@ bool wlr_output_cursor_set_buffer(struct wlr_output_cursor *cursor,
|
|||
struct wlr_buffer *buffer, int32_t hotspot_x, int32_t hotspot_y);
|
||||
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
|
||||
double x, double y);
|
||||
void wlr_output_cursor_move_all_deferred(struct wlr_output *output);
|
||||
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -440,8 +440,10 @@ bool output_cursor_set_texture(struct wlr_output_cursor *cursor,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
|
||||
static bool output_cursor_move(struct wlr_output_cursor *cursor,
|
||||
double x, double y) {
|
||||
cursor->deferred = false;
|
||||
|
||||
// Scale coordinates for the output
|
||||
x *= cursor->output->scale;
|
||||
y *= cursor->output->scale;
|
||||
|
|
@ -472,6 +474,34 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
|
|||
return output_move_hardware_cursor(cursor->output, (int)x, (int)y);
|
||||
}
|
||||
|
||||
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
|
||||
double x, double y) {
|
||||
// Scale coordinates for the output
|
||||
x *= cursor->output->scale;
|
||||
y *= cursor->output->scale;
|
||||
|
||||
if (cursor->x == x && cursor->y == y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cursor->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED) {
|
||||
cursor->deferred_x = x;
|
||||
cursor->deferred_y = y;
|
||||
cursor->deferred = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return output_cursor_move(cursor, x, y);
|
||||
}
|
||||
|
||||
void wlr_output_cursor_move_all_deferred(struct wlr_output *output) {
|
||||
struct wlr_output_cursor *cursor;
|
||||
wl_list_for_each(cursor, &output->cursors, link) {
|
||||
if (cursor->deferred)
|
||||
output_cursor_move(cursor, cursor->deferred_x, cursor->deferred_y);
|
||||
}
|
||||
}
|
||||
|
||||
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) {
|
||||
struct wlr_output_cursor *cursor = calloc(1, sizeof(*cursor));
|
||||
if (cursor == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue