From 94fa6c88f4eb956c75fce6c65acb335f4f9a4a07 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 18 Apr 2018 00:15:25 +0100 Subject: [PATCH] output: don't emit the mode event if it hasn't changed This also fixes #535. --- backend/drm/drm.c | 8 ++++++-- include/wlr/interfaces/wlr_output.h | 1 + types/wlr_output.c | 13 +++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 187db368..fcc435e6 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -496,11 +496,15 @@ static bool wlr_drm_connector_set_mode(struct wlr_output *output, conn->state = WLR_DRM_CONN_CONNECTED; wlr_output_update_mode(&conn->output, mode); + // When switching VTs, the mode is not updated but the buffers become + // invalid, so we need to manually damage the output here + wlr_output_damage_whole(&conn->output); + // Since realloc_crtcs can deallocate planes on OTHER outputs, - // we actually need to reinitialize any than has changed + // we actually need to reinitialize any that has changed ssize_t output_index = -1; wl_list_for_each(conn, &drm->outputs, link) { - output_index += 1; + output_index++; struct wlr_output_mode *mode = conn->output.current_mode; struct wlr_drm_crtc *crtc = conn->crtc; diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index 5edd1ae1..c9ddf615 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -33,6 +33,7 @@ void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width, int32_t height, int32_t refresh); void wlr_output_update_enabled(struct wlr_output *output, bool enabled); void wlr_output_update_needs_swap(struct wlr_output *output); +void wlr_output_damage_whole(struct wlr_output *output); void wlr_output_send_frame(struct wlr_output *output); #endif diff --git a/types/wlr_output.c b/types/wlr_output.c index d8b026b7..9cb3b6de 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -178,6 +178,11 @@ void wlr_output_update_mode(struct wlr_output *output, void wlr_output_update_custom_mode(struct wlr_output *output, int32_t width, int32_t height, int32_t refresh) { + if (output->width == width && output->height == height && + output->refresh == refresh) { + return; + } + output->width = width; output->height = height; wlr_output_update_matrix(output); @@ -563,7 +568,7 @@ void wlr_output_update_needs_swap(struct wlr_output *output) { wlr_signal_emit_safe(&output->events.needs_swap, output); } -static void output_damage_whole(struct wlr_output *output) { +void wlr_output_damage_whole(struct wlr_output *output) { int width, height; wlr_output_transformed_resolution(output, &width, &height); @@ -577,7 +582,7 @@ static void output_fullscreen_surface_reset(struct wlr_output *output) { wl_list_remove(&output->fullscreen_surface_commit.link); wl_list_remove(&output->fullscreen_surface_destroy.link); output->fullscreen_surface = NULL; - output_damage_whole(output); + wlr_output_damage_whole(output); } } @@ -591,7 +596,7 @@ static void output_fullscreen_surface_handle_commit( output->fullscreen_height != surface->current->height) { output->fullscreen_width = surface->current->width; output->fullscreen_height = surface->current->height; - output_damage_whole(output); + wlr_output_damage_whole(output); return; } @@ -627,7 +632,7 @@ void wlr_output_set_fullscreen_surface(struct wlr_output *output, output_fullscreen_surface_reset(output); output->fullscreen_surface = surface; - output_damage_whole(output); + wlr_output_damage_whole(output); if (surface == NULL) { return;