From 828744849d0b41d0b65db4f0bcb9be7e8698fdd0 Mon Sep 17 00:00:00 2001 From: Phil Jones Date: Fri, 3 Mar 2023 00:28:53 +0000 Subject: Convert to using wp_viewporter. This is the next step in supporting fractional scaling, as wl_surface_set_buffer_scale only supports integer scale factors. --- src/config.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/config.c') diff --git a/src/config.c b/src/config.c index 23dbc7f..31db79d 100644 --- a/src/config.c +++ b/src/config.c @@ -775,14 +775,6 @@ void config_fixup_values(struct tofi *tofi) base_height /= scale; } - tofi->window.width = fixup_percentage( - tofi->window.width, - base_width, - tofi->window.width_is_percent); - tofi->window.height = fixup_percentage( - tofi->window.height, - base_height, - tofi->window.height_is_percent); tofi->window.margin_top = fixup_percentage( tofi->window.margin_top, base_height, @@ -816,6 +808,27 @@ void config_fixup_values(struct tofi *tofi) base_width, tofi->window.entry.padding_right_is_percent); + /* + * Window width and height are a little special. We're only going to be + * using them to specify sizes to Wayland, which always wants scaled + * pixels, so always scale them here (unless we've directly specified a + * scaled size). + */ + tofi->window.width = fixup_percentage( + tofi->window.width, + tofi->output_width, + tofi->window.width_is_percent); + tofi->window.height = fixup_percentage( + tofi->window.height, + tofi->output_height, + tofi->window.height_is_percent); + if (tofi->window.width_is_percent || !tofi->use_scale) { + tofi->window.width /= scale; + } + if (tofi->window.height_is_percent || !tofi->use_scale) { + tofi->window.height /= scale; + } + /* Don't attempt percentage handling if exclusive_zone is set to -1. */ if (tofi->window.exclusive_zone > 0) { /* Exclusive zone base depends on anchor. */ -- cgit v1.2.3