Skip to content

Commit e32ae26

Browse files
libretroadminLibretroAdmin
authored andcommitted
rgui: don't pre-center custom viewport (fixes right-aligned menu)
Since 439c672 ("Support viewport bias with integer overscale and custom aspect ratios"), the ASPECT_RATIO_CUSTOM path in video_viewport_get_scaled_aspect2() / video_viewport_get_scaled_integer() positions the custom viewport as: x = custom_vp->x; padding_x = vp_width - custom_vp->width; (positive when the menu is narrower than the screen) x += padding_x * vp_bias_x; (default bias 0.5) i.e. the driver now centers the custom viewport itself via the viewport bias. RGUI, however, was *also* baking the centering into the viewport it hands to the driver: vp.x = (full_width - width) / 2; so the offset was applied twice. On a wide screen with a 4:3 menu aspect the menu ended up flush against the right edge (and the bottom), and because RGUI writes these values into the shared settings->video_vp_custom, opening the menu in-game also shifted the content viewport and left it shifted afterwards. Set the base position to 0 and let the driver's bias logic do the centering (default 0.5 == centered), matching how every other custom-viewport consumer is now expected to behave. All in-tree video drivers route their viewport through video_driver_update_viewport(), so none position RGUI from custom_vp->x directly. Fixes a regression reported on KMSDRM + GL (Pi4, aarch64); driver- independent.
1 parent 132a4d1 commit e32ae26

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

menu/drivers/rgui.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6263,8 +6263,15 @@ static void rgui_update_menu_viewport(
62636263
rgui->menu_video_settings.vp.height = 1;
62646264
}
62656265

6266-
rgui->menu_video_settings.vp.x = (vp.full_width - rgui->menu_video_settings.vp.width) / 2;
6267-
rgui->menu_video_settings.vp.y = (vp.full_height - rgui->menu_video_settings.vp.height) / 2;
6266+
/* Leave the viewport at the origin and let the video driver's
6267+
* viewport-bias logic centre it (default bias 0.5 == centred).
6268+
* Pre-centring here as well (vp.x = (full_width - width) / 2)
6269+
* double-applies the offset since 439c672c22 made the
6270+
* ASPECT_RATIO_CUSTOM path add padding * bias on top of vp.x,
6271+
* which pushed the menu hard against the right/bottom edge on
6272+
* wide screens. */
6273+
rgui->menu_video_settings.vp.x = 0;
6274+
rgui->menu_video_settings.vp.y = 0;
62686275
}
62696276

62706277
static bool rgui_set_aspect_ratio(

0 commit comments

Comments
 (0)