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 c9dd07619..ce454915b 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -387,7 +387,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 323f46441..8de7fcbc3 100644 --- a/types/output/output.c +++ b/types/output/output.c @@ -475,10 +475,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 12a9c249f..88c2fbf27 100644 --- a/types/scene/wlr_scene.c +++ b/types/scene/wlr_scene.c @@ -439,7 +439,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; @@ -2687,7 +2687,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 7226809e7..be2d8e566 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 9916a604c..17b3b5c33 100644 --- a/types/wlr_screencopy_v1.c +++ b/types/wlr_screencopy_v1.c @@ -569,7 +569,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;