@@ -528,6 +528,26 @@ void WebContentView::update_palette(PaletteMode mode)
528
528
client ().async_update_system_theme (m_client_state.page_index , make_system_theme_from_qt_palette (*this , mode));
529
529
}
530
530
531
+ void WebContentView::update_screen_rects ()
532
+ {
533
+ auto screens = QGuiApplication::screens ();
534
+
535
+ if (!screens.empty ()) {
536
+ Vector<Web::DevicePixelRect> screen_rects;
537
+ for (auto const & screen : screens) {
538
+ auto geometry = screen->geometry ();
539
+ screen_rects.append (Web::DevicePixelRect (geometry.x (), geometry.y (), geometry.width (), geometry.height ()));
540
+ }
541
+
542
+ // FIXME: Update the screens again when QGuiApplication::screenAdded/Removed signals are emitted
543
+
544
+ // NOTE: The first item in QGuiApplication::screens is always the primary screen.
545
+ // This is not specified in the documentation but QGuiApplication::primaryScreen
546
+ // always returns the first item in the list if it isn't empty.
547
+ client ().async_update_screen_rects (m_client_state.page_index , screen_rects, 0 );
548
+ }
549
+ }
550
+
531
551
void WebContentView::initialize_client (WebView::ViewImplementation::CreateNewClient create_new_client)
532
552
{
533
553
if (create_new_client == CreateNewClient::Yes) {
@@ -563,25 +583,7 @@ void WebContentView::initialize_client(WebView::ViewImplementation::CreateNewCli
563
583
update_palette ();
564
584
client ().async_update_system_fonts (m_client_state.page_index , Gfx::FontDatabase::default_font_query (), Gfx::FontDatabase::fixed_width_font_query (), Gfx::FontDatabase::window_title_font_query ());
565
585
566
- auto screens = QGuiApplication::screens ();
567
-
568
- if (!screens.empty ()) {
569
- Vector<Web::DevicePixelRect> screen_rects;
570
- for (auto const & screen : screens) {
571
- // NOTE: QScreen::geometry() returns the 'device-independent pixels', we multiply
572
- // by the device pixel ratio to get the 'physical pixels' of the display.
573
- auto geometry = screen->geometry ();
574
- auto device_pixel_ratio = screen->devicePixelRatio ();
575
- screen_rects.append (Web::DevicePixelRect (geometry.x (), geometry.y (), geometry.width () * device_pixel_ratio, geometry.height () * device_pixel_ratio));
576
- }
577
-
578
- // FIXME: Update the screens again when QGuiApplication::screenAdded/Removed signals are emitted
579
-
580
- // NOTE: The first item in QGuiApplication::screens is always the primary screen.
581
- // This is not specified in the documentation but QGuiApplication::primaryScreen
582
- // always returns the first item in the list if it isn't empty.
583
- client ().async_update_screen_rects (m_client_state.page_index , screen_rects, 0 );
584
- }
586
+ update_screen_rects ();
585
587
586
588
if (!m_webdriver_content_ipc_path.is_empty ())
587
589
client ().async_connect_to_webdriver (m_client_state.page_index , m_webdriver_content_ipc_path);
0 commit comments