mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 06:15:38 +00:00
Qt: Fall back to screen for refresh rate
Wayland, always a pain in the arse.
This commit is contained in:
parent
a7f2ad37de
commit
1adc29aeb0
|
@ -370,7 +370,17 @@ std::optional<WindowInfo> GetWindowInfoForWidget(QWidget* widget)
|
||||||
wi.surface_scale = static_cast<float>(dpr);
|
wi.surface_scale = static_cast<float>(dpr);
|
||||||
|
|
||||||
// Query refresh rate, we need it for sync.
|
// Query refresh rate, we need it for sync.
|
||||||
wi.surface_refresh_rate = WindowInfo::QueryRefreshRateForWindow(wi).value_or(0.0f);
|
std::optional<float> surface_refresh_rate = WindowInfo::QueryRefreshRateForWindow(wi);
|
||||||
|
if (!surface_refresh_rate.has_value())
|
||||||
|
{
|
||||||
|
// Fallback to using the screen, getting the rate for Wayland is an utter mess otherwise.
|
||||||
|
const QScreen* widget_screen = widget->screen();
|
||||||
|
if (!widget_screen)
|
||||||
|
widget_screen = QGuiApplication::primaryScreen();
|
||||||
|
surface_refresh_rate = widget_screen ? static_cast<float>(widget_screen->refreshRate()) : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
wi.surface_refresh_rate = surface_refresh_rate.value();
|
||||||
INFO_LOG("Surface refresh rate: {} hz", wi.surface_refresh_rate);
|
INFO_LOG("Surface refresh rate: {} hz", wi.surface_refresh_rate);
|
||||||
|
|
||||||
return wi;
|
return wi;
|
||||||
|
|
Loading…
Reference in a new issue