UI/Qt: Set WC's max FPS to the refresh rate of the current screen

This commit is contained in:
Luke Wilde 2025-07-25 16:43:27 +01:00 committed by Alexander Kalenik
commit 124bdce99c
Notes: github-actions[bot] 2025-07-26 14:10:29 +00:00
5 changed files with 40 additions and 4 deletions

View file

@ -47,7 +47,7 @@ namespace Ladybird {
bool is_using_dark_system_theme(QWidget&);
WebContentView::WebContentView(QWidget* window, RefPtr<WebView::WebContentClient> parent_client, size_t page_index)
WebContentView::WebContentView(QWidget* window, RefPtr<WebView::WebContentClient> parent_client, size_t page_index, WebContentViewInitialState initial_state)
: QWidget(window)
{
m_client_state.client = parent_client;
@ -60,6 +60,7 @@ WebContentView::WebContentView(QWidget* window, RefPtr<WebView::WebContentClient
setFocusPolicy(Qt::FocusPolicy::StrongFocus);
m_device_pixel_ratio = devicePixelRatio();
m_maximum_frames_per_second = initial_state.maximum_frames_per_second;
QObject::connect(qGuiApp, &QGuiApplication::screenRemoved, [this](QScreen*) {
update_screen_rects();
@ -538,6 +539,12 @@ void WebContentView::set_device_pixel_ratio(double device_pixel_ratio)
handle_resize();
}
void WebContentView::set_maximum_frames_per_second(double maximum_frames_per_second)
{
m_maximum_frames_per_second = maximum_frames_per_second;
client().async_set_maximum_frames_per_second(m_client_state.page_index, m_maximum_frames_per_second);
}
void WebContentView::update_viewport_size()
{
auto scaled_width = int(width() * m_device_pixel_ratio);