mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-22 08:00:45 +00:00
UI/Qt: Set WC's max FPS to the refresh rate of the current screen
This commit is contained in:
parent
b0d97c991f
commit
124bdce99c
Notes:
github-actions[bot]
2025-07-26 14:10:29 +00:00
Author: https://github.com/Lubrsi
Commit: 124bdce99c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5606
Reviewed-by: https://github.com/Psychpsyo
Reviewed-by: https://github.com/kalenikaliaksandr
5 changed files with 40 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue