diff --git a/backend/drm/drm.c b/backend/drm/drm.c index d2f75f71f..fb70b2b44 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -1211,7 +1211,7 @@ static bool drm_connector_move_cursor(struct wlr_output *output, struct wlr_box box = { .x = x, .y = y }; int width, height; - wlr_output_transformed_resolution(output, &width, &height); + wlr_output_transformed_resolution(output, NULL, &width, &height); enum wl_output_transform transform = wlr_output_transform_invert(output->transform); diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index c8e44b0e6..c9dd07619 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -382,7 +382,7 @@ void wlr_output_destroy(struct wlr_output *output); * Computes the transformed output resolution. */ void wlr_output_transformed_resolution(struct wlr_output *output, - int *width, int *height); + const struct wlr_output_state *state, int *width, int *height); /** * Computes the transformed and scaled output resolution. */ diff --git a/types/output/cursor.c b/types/output/cursor.c index 4a823dab1..8d16e2344 100644 --- a/types/output/cursor.c +++ b/types/output/cursor.c @@ -90,8 +90,9 @@ static void output_cursor_get_box(struct wlr_output_cursor *cursor, void wlr_output_add_software_cursors_to_render_pass(struct wlr_output *output, struct wlr_render_pass *render_pass, const pixman_region32_t *damage) { + // TODO: pass output state from caller int width, height; - wlr_output_transformed_resolution(output, &width, &height); + wlr_output_transformed_resolution(output, NULL, &width, &height); struct wlr_output_cursor *cursor; wl_list_for_each(cursor, &output->cursors, link) { @@ -153,7 +154,7 @@ static void output_cursor_damage_whole(struct wlr_output_cursor *cursor) { static void output_cursor_update_visible(struct wlr_output_cursor *cursor) { struct wlr_box output_box; output_box.x = output_box.y = 0; - wlr_output_transformed_resolution(cursor->output, &output_box.width, + wlr_output_transformed_resolution(cursor->output, NULL, &output_box.width, &output_box.height); struct wlr_box cursor_box; diff --git a/types/output/output.c b/types/output/output.c index 46da1f425..323f46441 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -459,19 +459,24 @@ void wlr_output_destroy(struct wlr_output *output) { } void wlr_output_transformed_resolution(struct wlr_output *output, - int *width, int *height) { - if (output->transform % 2 == 0) { - *width = output->width; - *height = output->height; - } else { - *width = output->height; - *height = output->width; + const struct wlr_output_state *state, int *width, int *height) { + output_pending_resolution(output, state, width, height); + + enum wl_output_transform transform = output->transform; + if (state && state->committed & WLR_OUTPUT_STATE_TRANSFORM) { + transform = state->transform; + } + + if (transform % 2 != 0) { + int tmp = *width; + *width = *height; + *height = tmp; } } void wlr_output_effective_resolution(struct wlr_output *output, int *width, int *height) { - wlr_output_transformed_resolution(output, width, height); + wlr_output_transformed_resolution(output, NULL, width, height); *width /= output->scale; *height /= output->scale; } @@ -494,7 +499,7 @@ struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output) { void output_pending_resolution(struct wlr_output *output, const struct wlr_output_state *state, int *width, int *height) { - if (state->committed & WLR_OUTPUT_STATE_MODE) { + if (state && state->committed & WLR_OUTPUT_STATE_MODE) { switch (state->mode_type) { case WLR_OUTPUT_STATE_MODE_FIXED: *width = state->mode->width; diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index 7231422e8..12a9c249f 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -330,7 +330,7 @@ static void logical_to_buffer_coords(pixman_region32_t *region, const struct ren static void output_to_buffer_coords(pixman_region32_t *damage, struct wlr_output *output) { int width, height; - wlr_output_transformed_resolution(output, &width, &height); + wlr_output_transformed_resolution(output, NULL, &width, &height); wlr_region_transform(damage, damage, wlr_output_transform_invert(output->transform), width, height); @@ -1709,7 +1709,7 @@ static void scene_output_handle_damage(struct wl_listener *listener, void *data) struct wlr_output_event_damage *event = data; int width, height; - wlr_output_transformed_resolution(output, &width, &height); + wlr_output_transformed_resolution(output, NULL, &width, &height); pixman_region32_t damage; pixman_region32_init(&damage);