Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Win] Update intrinsic device scale factor dynamically #29810

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Win] Update intrinsic device scale factor dynamically
https://bugs.webkit.org/show_bug.cgi?id=274377

Reviewed by Fujii Hironori.

When intrinsic device scale factor dynamically is changed, i.e. moving
between different displays, we need to change intrinsic device scale
factor and repaint contents.
For main web contents, although WebView can't receive WM_DPICHANGED by
default, it's sufficient to update on WM_SIZE handler
because MainWindow's WM_DPICHANGED handling contains resizing window.
Above change also enables WebInspector resize when receiving WM_DPICHANGED,
just as MainWindow does.

    * Source\WebKit\UIProcess\Inspector\win\WebInspectorUIProxyWin.cpp:
    * Source\WebKit\UIProcess\win\WebView.cpp:

Canonical link: https://commits.webkit.org/280003@main
  • Loading branch information
khei4 authored and fujii committed Jun 14, 2024
commit 50c1741732a33548a144c043375f433523104f47
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ LRESULT CALLBACK WebInspectorUIProxy::wndProc(HWND hwnd, UINT msg, WPARAM wParam
case WM_CLOSE:
inspector->close();
return 0;
case WM_DPICHANGED: {
RECT& rect = *reinterpret_cast<RECT*>(lParam);
SetWindowPos(hwnd, nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE);
return 0;
}
default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/UIProcess/win/WebView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ LRESULT WebView::onPrintClientEvent(HWND hWnd, UINT, WPARAM wParam, LPARAM, bool

LRESULT WebView::onSizeEvent(HWND hwnd, UINT, WPARAM, LPARAM lParam, bool& handled)
{
if (m_page)
m_page->setIntrinsicDeviceScaleFactor(deviceScaleFactorForWindow(hwnd));
// If there are no m_page, use intrinsic device scale factor.
float deviceScaleFactor = m_page ? m_page->deviceScaleFactor() : deviceScaleFactorForWindow(hwnd);
m_viewSize = expandedIntSize(FloatSize(LOWORD(lParam), HIWORD(lParam)) / deviceScaleFactor);
Expand Down