From 34ec9319d0bd4705366fd880950643f35c8cfdcc Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Tue, 5 Dec 2023 20:36:52 -0500 Subject: [PATCH] wlr_output: Make wlr_output_effective_resolution take state --- examples/fullscreen-shell.c | 2 +- examples/output-layers.c | 2 +- examples/rotation.c | 2 +- examples/tablet.c | 2 +- examples/touch.c | 2 +- include/wlr/types/wlr_output.h | 2 +- types/output/output.c | 14 ++++++++++---- types/scene/wlr_scene.c | 4 ++-- types/wlr_output_layout.c | 2 +- types/wlr_screencopy_v1.c | 2 +- types/wlr_xdg_output_v1.c | 2 +- 11 files changed, 21 insertions(+), 15 deletions(-) diff --git a/examples/fullscreen-shell.c b/examples/fullscreen-shell.c index 956d851af..6a758f22f 100644 --- a/examples/fullscreen-shell.c +++ b/examples/fullscreen-shell.c @@ -86,7 +86,7 @@ static void output_handle_frame(struct wl_listener *listener, void *data) { struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); int width, height; - wlr_output_effective_resolution(output->wlr_output, &width, &height); + wlr_output_effective_resolution(output->wlr_output, NULL, &width, &height); struct wlr_output_state state; wlr_output_state_init(&state); diff --git a/examples/output-layers.c b/examples/output-layers.c index 0535ff0b1..dc1a83f6a 100644 --- a/examples/output-layers.c +++ b/examples/output-layers.c @@ -92,7 +92,7 @@ static void output_handle_frame(struct wl_listener *listener, void *data) { } int width, height; - wlr_output_effective_resolution(output->wlr_output, &width, &height); + wlr_output_effective_resolution(output->wlr_output, NULL, &width, &height); struct wlr_render_pass *pass = wlr_output_begin_render_pass(output->wlr_output, &output_state, NULL); wlr_render_pass_add_rect(pass, &(struct wlr_render_rect_options){ diff --git a/examples/rotation.c b/examples/rotation.c index 18bfbd38d..a50297f70 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -55,7 +55,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { clock_gettime(CLOCK_MONOTONIC, &now); int32_t width, height; - wlr_output_effective_resolution(wlr_output, &width, &height); + wlr_output_effective_resolution(wlr_output, NULL, &width, &height); struct wlr_output_state output_state; wlr_output_state_init(&output_state); diff --git a/examples/tablet.c b/examples/tablet.c index 78666fff7..658895a1d 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -85,7 +85,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { clock_gettime(CLOCK_MONOTONIC, &now); int32_t width, height; - wlr_output_effective_resolution(wlr_output, &width, &height); + wlr_output_effective_resolution(wlr_output, NULL, &width, &height); struct wlr_output_state output_state; wlr_output_state_init(&output_state); diff --git a/examples/touch.c b/examples/touch.c index b891837a4..03ce2dee0 100644 --- a/examples/touch.c +++ b/examples/touch.c @@ -72,7 +72,7 @@ static void output_frame_notify(struct wl_listener *listener, void *data) { struct wlr_output *wlr_output = sample_output->output; int32_t width, height; - wlr_output_effective_resolution(wlr_output, &width, &height); + wlr_output_effective_resolution(wlr_output, NULL, &width, &height); struct wlr_output_state output_state; wlr_output_state_init(&output_state); diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 1de0673f9..0e45f4697 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -344,7 +344,7 @@ void wlr_output_transformed_resolution(struct wlr_output *output, * Computes the transformed and scaled output resolution. */ void wlr_output_effective_resolution(struct wlr_output *output, - int *width, int *height); + const struct wlr_output_state *state, int *width, int *height); /** * Test whether this output state would be accepted by the backend. If this * function returns true, wlr_output_commit_state() will only fail due to a diff --git a/types/output/output.c b/types/output/output.c index 1a0df6c2b..c388e8a9b 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -457,10 +457,16 @@ void wlr_output_transformed_resolution(struct wlr_output *output, } void wlr_output_effective_resolution(struct wlr_output *output, - int *width, int *height) { - wlr_output_transformed_resolution(output, NULL, width, height); - *width /= output->scale; - *height /= output->scale; + const struct wlr_output_state *state, int *width, int *height) { + wlr_output_transformed_resolution(output, state, width, height); + + float scale = output->scale; + if (state && state->committed & WLR_OUTPUT_STATE_SCALE) { + scale = state->scale; + } + + *width /= scale; + *height /= scale; } struct wlr_output_mode *wlr_output_preferred_mode(struct wlr_output *output) { diff --git a/types/scene/wlr_scene.c b/types/scene/wlr_scene.c index bb5faa9f2..65be89631 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -445,7 +445,7 @@ static void update_node_update_outputs(struct wlr_scene_node *node, .x = scene_output->x, .y = scene_output->y, }; - wlr_output_effective_resolution(scene_output->output, + wlr_output_effective_resolution(scene_output->output, NULL, &output_box.width, &output_box.height); pixman_region32_t intersection; @@ -2337,7 +2337,7 @@ static void scene_output_for_each_scene_buffer(const struct wlr_box *output_box, void wlr_scene_output_for_each_buffer(struct wlr_scene_output *scene_output, wlr_scene_buffer_iterator_func_t iterator, void *user_data) { struct wlr_box box = { .x = scene_output->x, .y = scene_output->y }; - wlr_output_effective_resolution(scene_output->output, + wlr_output_effective_resolution(scene_output->output, NULL, &box.width, &box.height); scene_output_for_each_scene_buffer(&box, &scene_output->scene->tree.node, 0, 0, iterator, user_data); diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index ef2751179..fe4a297fd 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -71,7 +71,7 @@ static void output_layout_output_get_box( struct wlr_box *box) { box->x = l_output->x; box->y = l_output->y; - wlr_output_effective_resolution(l_output->output, + wlr_output_effective_resolution(l_output->output, NULL, &box->width, &box->height); } diff --git a/types/wlr_screencopy_v1.c b/types/wlr_screencopy_v1.c index d039659d4..97a7e5675 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -584,7 +584,7 @@ static void capture_output(struct wl_client *wl_client, buffer_box.height = output->height; } else { int ow, oh; - wlr_output_effective_resolution(output, &ow, &oh); + wlr_output_effective_resolution(output, NULL, &ow, &oh); buffer_box = *box; diff --git a/types/wlr_xdg_output_v1.c b/types/wlr_xdg_output_v1.c index 262123987..6b86d2d68 100644 --- a/types/wlr_xdg_output_v1.c +++ b/types/wlr_xdg_output_v1.c @@ -46,7 +46,7 @@ static void output_update(struct wlr_xdg_output_v1 *xdg_output) { } int width, height; - wlr_output_effective_resolution(layout_output->output, &width, &height); + wlr_output_effective_resolution(layout_output->output, NULL, &width, &height); if (xdg_output->width != width || xdg_output->height != height) { xdg_output->width = width; xdg_output->height = height;