mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-02 20:05:58 +01:00
backend/drm: fix hardware cursors not moving
This adds back `wlr_output::needs_swap`. This allows a backend to request buffer swaps even if the output isn't damaged. This is needed by the DRM backend to trigger pageflips when the cursor moves.
This commit is contained in:
parent
bc001e90e9
commit
4ca38b84ed
6 changed files with 43 additions and 19 deletions
|
@ -619,7 +619,11 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output,
|
||||||
|
|
||||||
gbm_bo_unmap(bo, bo_data);
|
gbm_bo_unmap(bo, bo_data);
|
||||||
|
|
||||||
return drm->iface->crtc_set_cursor(drm, crtc, bo);
|
bool ok = drm->iface->crtc_set_cursor(drm, crtc, bo);
|
||||||
|
if (ok) {
|
||||||
|
wlr_output_update_needs_swap(output);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool wlr_drm_connector_move_cursor(struct wlr_output *output,
|
static bool wlr_drm_connector_move_cursor(struct wlr_output *output,
|
||||||
|
@ -643,8 +647,12 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output,
|
||||||
transformed_box.y -= plane->cursor_hotspot_y;
|
transformed_box.y -= plane->cursor_hotspot_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return drm->iface->crtc_move_cursor(drm, conn->crtc, transformed_box.x,
|
bool ok = drm->iface->crtc_move_cursor(drm, conn->crtc, transformed_box.x,
|
||||||
transformed_box.y);
|
transformed_box.y);
|
||||||
|
if (ok) {
|
||||||
|
wlr_output_update_needs_swap(output);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wlr_drm_connector_destroy(struct wlr_output *output) {
|
static void wlr_drm_connector_destroy(struct wlr_output *output) {
|
||||||
|
|
|
@ -16,11 +16,11 @@ struct roots_output {
|
||||||
|
|
||||||
struct timespec last_frame;
|
struct timespec last_frame;
|
||||||
pixman_region32_t damage, previous_damage;
|
pixman_region32_t damage, previous_damage;
|
||||||
bool frame_scheduled;
|
bool frame_pending;
|
||||||
|
|
||||||
struct wl_listener frame;
|
struct wl_listener frame;
|
||||||
struct wl_listener mode;
|
struct wl_listener mode;
|
||||||
struct wl_listener damage_listener;
|
struct wl_listener needs_swap;
|
||||||
};
|
};
|
||||||
|
|
||||||
void output_add_notify(struct wl_listener *listener, void *data);
|
void output_add_notify(struct wl_listener *listener, void *data);
|
||||||
|
|
|
@ -32,5 +32,6 @@ void wlr_output_update_mode(struct wlr_output *output,
|
||||||
void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width,
|
void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width,
|
||||||
int32_t height, int32_t refresh);
|
int32_t height, int32_t refresh);
|
||||||
void wlr_output_update_enabled(struct wlr_output *output, bool enabled);
|
void wlr_output_update_enabled(struct wlr_output *output, bool enabled);
|
||||||
|
void wlr_output_update_needs_swap(struct wlr_output *output);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,6 +54,7 @@ struct wlr_output {
|
||||||
enum wl_output_subpixel subpixel;
|
enum wl_output_subpixel subpixel;
|
||||||
enum wl_output_transform transform;
|
enum wl_output_transform transform;
|
||||||
|
|
||||||
|
bool needs_swap;
|
||||||
pixman_region32_t damage, previous_damage;
|
pixman_region32_t damage, previous_damage;
|
||||||
float transform_matrix[16];
|
float transform_matrix[16];
|
||||||
|
|
||||||
|
@ -64,8 +65,8 @@ struct wlr_output {
|
||||||
int32_t refresh; // mHz
|
int32_t refresh; // mHz
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct wl_signal damage;
|
|
||||||
struct wl_signal frame;
|
struct wl_signal frame;
|
||||||
|
struct wl_signal needs_swap;
|
||||||
struct wl_signal swap_buffers;
|
struct wl_signal swap_buffers;
|
||||||
struct wl_signal enable;
|
struct wl_signal enable;
|
||||||
struct wl_signal mode;
|
struct wl_signal mode;
|
||||||
|
|
|
@ -258,6 +258,7 @@ static void render_output(struct roots_output *output) {
|
||||||
struct roots_server *server = desktop->server;
|
struct roots_server *server = desktop->server;
|
||||||
|
|
||||||
if (!wlr_output->enabled) {
|
if (!wlr_output->enabled) {
|
||||||
|
output->frame_pending = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,9 +300,9 @@ static void render_output(struct roots_output *output) {
|
||||||
pixman_region32_intersect_rect(&damage, &damage, 0, 0, wlr_output->width,
|
pixman_region32_intersect_rect(&damage, &damage, 0, 0, wlr_output->width,
|
||||||
wlr_output->height);
|
wlr_output->height);
|
||||||
|
|
||||||
// TODO: fullscreen
|
if (!pixman_region32_not_empty(&damage) && !wlr_output->needs_swap) {
|
||||||
if (!pixman_region32_not_empty(&damage)) {
|
// Output doesn't need swap and isn't damaged, skip rendering completely
|
||||||
output->frame_scheduled = false;
|
output->frame_pending = false;
|
||||||
goto damage_finish;
|
goto damage_finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,6 +312,11 @@ static void render_output(struct roots_output *output) {
|
||||||
wlr_renderer_begin(server->renderer, wlr_output);
|
wlr_renderer_begin(server->renderer, wlr_output);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
|
||||||
|
if (!pixman_region32_not_empty(&damage)) {
|
||||||
|
// Output isn't damaged but needs buffer swap
|
||||||
|
goto renderer_end;
|
||||||
|
}
|
||||||
|
|
||||||
int nrects;
|
int nrects;
|
||||||
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
pixman_box32_t *rects = pixman_region32_rectangles(&damage, &nrects);
|
||||||
for (int i = 0; i < nrects; ++i) {
|
for (int i = 0; i < nrects; ++i) {
|
||||||
|
@ -377,7 +383,7 @@ renderer_end:
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
wlr_renderer_end(server->renderer);
|
wlr_renderer_end(server->renderer);
|
||||||
wlr_output_swap_buffers(wlr_output, &now, &damage);
|
wlr_output_swap_buffers(wlr_output, &now, &damage);
|
||||||
output->frame_scheduled = true;
|
output->frame_pending = true;
|
||||||
pixman_region32_copy(&output->previous_damage, &output->damage);
|
pixman_region32_copy(&output->previous_damage, &output->damage);
|
||||||
pixman_region32_clear(&output->damage);
|
pixman_region32_clear(&output->damage);
|
||||||
output->last_frame = desktop->last_frame = now;
|
output->last_frame = desktop->last_frame = now;
|
||||||
|
@ -397,11 +403,11 @@ static void handle_idle_render(void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void schedule_render(struct roots_output *output) {
|
static void schedule_render(struct roots_output *output) {
|
||||||
if (!output->frame_scheduled) {
|
if (!output->frame_pending) {
|
||||||
struct wl_event_loop *ev =
|
struct wl_event_loop *ev =
|
||||||
wl_display_get_event_loop(output->desktop->server->wl_display);
|
wl_display_get_event_loop(output->desktop->server->wl_display);
|
||||||
wl_event_loop_add_idle(ev, handle_idle_render, output);
|
wl_event_loop_add_idle(ev, handle_idle_render, output);
|
||||||
output->frame_scheduled = true;
|
output->frame_pending = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,9 +491,9 @@ static void output_handle_mode(struct wl_listener *listener, void *data) {
|
||||||
output_damage_whole(output);
|
output_damage_whole(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_handle_damage(struct wl_listener *listener, void *data) {
|
static void output_handle_needs_swap(struct wl_listener *listener, void *data) {
|
||||||
struct roots_output *output =
|
struct roots_output *output =
|
||||||
wl_container_of(listener, output, damage_listener);
|
wl_container_of(listener, output, needs_swap);
|
||||||
pixman_region32_union(&output->damage, &output->damage,
|
pixman_region32_union(&output->damage, &output->damage,
|
||||||
&output->wlr_output->damage);
|
&output->wlr_output->damage);
|
||||||
schedule_render(output);
|
schedule_render(output);
|
||||||
|
@ -551,8 +557,8 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
||||||
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
wl_signal_add(&wlr_output->events.frame, &output->frame);
|
||||||
output->mode.notify = output_handle_mode;
|
output->mode.notify = output_handle_mode;
|
||||||
wl_signal_add(&wlr_output->events.mode, &output->mode);
|
wl_signal_add(&wlr_output->events.mode, &output->mode);
|
||||||
output->damage_listener.notify = output_handle_damage;
|
output->needs_swap.notify = output_handle_needs_swap;
|
||||||
wl_signal_add(&wlr_output->events.damage, &output->damage_listener);
|
wl_signal_add(&wlr_output->events.needs_swap, &output->needs_swap);
|
||||||
|
|
||||||
struct roots_output_config *output_config =
|
struct roots_output_config *output_config =
|
||||||
roots_config_get_output(config, wlr_output);
|
roots_config_get_output(config, wlr_output);
|
||||||
|
@ -607,5 +613,7 @@ void output_remove_notify(struct wl_listener *listener, void *data) {
|
||||||
pixman_region32_fini(&output->previous_damage);
|
pixman_region32_fini(&output->previous_damage);
|
||||||
wl_list_remove(&output->link);
|
wl_list_remove(&output->link);
|
||||||
wl_list_remove(&output->frame.link);
|
wl_list_remove(&output->frame.link);
|
||||||
|
wl_list_remove(&output->mode.link);
|
||||||
|
wl_list_remove(&output->needs_swap.link);
|
||||||
free(output);
|
free(output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,8 +272,8 @@ void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,
|
||||||
output->scale = 1;
|
output->scale = 1;
|
||||||
wl_list_init(&output->cursors);
|
wl_list_init(&output->cursors);
|
||||||
wl_list_init(&output->wl_resources);
|
wl_list_init(&output->wl_resources);
|
||||||
wl_signal_init(&output->events.damage);
|
|
||||||
wl_signal_init(&output->events.frame);
|
wl_signal_init(&output->events.frame);
|
||||||
|
wl_signal_init(&output->events.needs_swap);
|
||||||
wl_signal_init(&output->events.swap_buffers);
|
wl_signal_init(&output->events.swap_buffers);
|
||||||
wl_signal_init(&output->events.enable);
|
wl_signal_init(&output->events.enable);
|
||||||
wl_signal_init(&output->events.mode);
|
wl_signal_init(&output->events.mode);
|
||||||
|
@ -504,6 +504,7 @@ void wlr_output_swap_buffers(struct wlr_output *output, struct timespec *when,
|
||||||
|
|
||||||
// TODO: provide `damage` (not `render_damage`) to backend
|
// TODO: provide `damage` (not `render_damage`) to backend
|
||||||
output->impl->swap_buffers(output);
|
output->impl->swap_buffers(output);
|
||||||
|
output->needs_swap = false;
|
||||||
pixman_region32_copy(&output->previous_damage, &output->damage);
|
pixman_region32_copy(&output->previous_damage, &output->damage);
|
||||||
pixman_region32_clear(&output->damage);
|
pixman_region32_clear(&output->damage);
|
||||||
|
|
||||||
|
@ -526,10 +527,15 @@ uint32_t wlr_output_get_gamma_size(struct wlr_output *output) {
|
||||||
return output->impl->get_gamma_size(output);
|
return output->impl->get_gamma_size(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_output_update_needs_swap(struct wlr_output *output) {
|
||||||
|
output->needs_swap = true;
|
||||||
|
wl_signal_emit(&output->events.needs_swap, output);
|
||||||
|
}
|
||||||
|
|
||||||
static void output_damage_whole(struct wlr_output *output) {
|
static void output_damage_whole(struct wlr_output *output) {
|
||||||
pixman_region32_union_rect(&output->damage, &output->damage, 0, 0,
|
pixman_region32_union_rect(&output->damage, &output->damage, 0, 0,
|
||||||
output->width, output->height);
|
output->width, output->height);
|
||||||
wl_signal_emit(&output->events.damage, output);
|
wlr_output_update_needs_swap(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_fullscreen_surface_reset(struct wlr_output *output) {
|
static void output_fullscreen_surface_reset(struct wlr_output *output) {
|
||||||
|
@ -557,7 +563,7 @@ static void output_fullscreen_surface_handle_commit(
|
||||||
pixman_region32_union(&output->damage, &output->damage, &damage);
|
pixman_region32_union(&output->damage, &output->damage, &damage);
|
||||||
pixman_region32_fini(&damage);
|
pixman_region32_fini(&damage);
|
||||||
|
|
||||||
wl_signal_emit(&output->events.damage, output);
|
wlr_output_update_needs_swap(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_fullscreen_surface_handle_destroy(
|
static void output_fullscreen_surface_handle_destroy(
|
||||||
|
@ -599,7 +605,7 @@ static void output_cursor_damage_whole(struct wlr_output_cursor *cursor) {
|
||||||
output_cursor_get_box(cursor, &box);
|
output_cursor_get_box(cursor, &box);
|
||||||
pixman_region32_union_rect(&cursor->output->damage, &cursor->output->damage,
|
pixman_region32_union_rect(&cursor->output->damage, &cursor->output->damage,
|
||||||
box.x, box.y, box.width, box.height);
|
box.x, box.y, box.width, box.height);
|
||||||
wl_signal_emit(&cursor->output->events.damage, cursor->output);
|
wlr_output_update_needs_swap(cursor->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void output_cursor_reset(struct wlr_output_cursor *cursor) {
|
static void output_cursor_reset(struct wlr_output_cursor *cursor) {
|
||||||
|
|
Loading…
Reference in a new issue