Title: [249559] trunk
Revision
249559
Author
hironori.fu...@sony.com
Date
2019-09-05 18:48:39 -0700 (Thu, 05 Sep 2019)

Log Message

[Win] Support Per-Monitor (V2) DPI Awareness
https://bugs.webkit.org/show_bug.cgi?id=201450

Reviewed by Don Olmstead.

Source/WebCore:

* platform/win/GDIUtilities.cpp:
(WebCore::deviceScaleFactorForWindow): Use GetDpiForWindow if available by using soft linking.

Tools:

* MiniBrowser/win/MainWindow.cpp:
(MainWindow::WndProc): Set the window position suggested by WM_DPICHANGED.
* MiniBrowser/win/WinMain.cpp:
(wWinMain): Call SetProcessDpiAwarenessContext by using soft linking.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249558 => 249559)


--- trunk/Source/WebCore/ChangeLog	2019-09-06 01:45:01 UTC (rev 249558)
+++ trunk/Source/WebCore/ChangeLog	2019-09-06 01:48:39 UTC (rev 249559)
@@ -1,3 +1,13 @@
+2019-09-05  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [Win] Support Per-Monitor (V2) DPI Awareness
+        https://bugs.webkit.org/show_bug.cgi?id=201450
+
+        Reviewed by Don Olmstead.
+
+        * platform/win/GDIUtilities.cpp:
+        (WebCore::deviceScaleFactorForWindow): Use GetDpiForWindow if available by using soft linking.
+
 2019-09-05  Charlie Turner  <ctur...@igalia.com>
 
         [EME] Introduce a Proxy CDM for thread-safe access to CDM instances from background decryption threads

Modified: trunk/Source/WebCore/platform/win/GDIUtilities.cpp (249558 => 249559)


--- trunk/Source/WebCore/platform/win/GDIUtilities.cpp	2019-09-06 01:45:01 UTC (rev 249558)
+++ trunk/Source/WebCore/platform/win/GDIUtilities.cpp	2019-09-06 01:48:39 UTC (rev 249559)
@@ -27,11 +27,17 @@
 #include "GDIUtilities.h"
 
 #include "HWndDC.h"
+#include <wtf/win/SoftLinking.h>
 
+SOFT_LINK_LIBRARY(user32);
+SOFT_LINK_OPTIONAL(user32, GetDpiForWindow, UINT, STDAPICALLTYPE, (HWND));
+
 namespace WebCore {
 
 float deviceScaleFactorForWindow(HWND window)
 {
+    if (window && GetDpiForWindowPtr())
+        return GetDpiForWindowPtr()(window) / 96.0f;
     HWndDC dc(window);
     return ::GetDeviceCaps(dc, LOGPIXELSX) / 96.0f;
 }

Modified: trunk/Tools/ChangeLog (249558 => 249559)


--- trunk/Tools/ChangeLog	2019-09-06 01:45:01 UTC (rev 249558)
+++ trunk/Tools/ChangeLog	2019-09-06 01:48:39 UTC (rev 249559)
@@ -1,3 +1,15 @@
+2019-09-05  Fujii Hironori  <hironori.fu...@sony.com>
+
+        [Win] Support Per-Monitor (V2) DPI Awareness
+        https://bugs.webkit.org/show_bug.cgi?id=201450
+
+        Reviewed by Don Olmstead.
+
+        * MiniBrowser/win/MainWindow.cpp:
+        (MainWindow::WndProc): Set the window position suggested by WM_DPICHANGED.
+        * MiniBrowser/win/WinMain.cpp:
+        (wWinMain): Call SetProcessDpiAwarenessContext by using soft linking.
+
 2019-09-05  Chris Dumez  <cdu...@apple.com>
 
         REGRESSION: http/tests/adClickAttribution/second-attribution-converted-with-higher-priority.html and http/tests/adClickAttribution/second-attribution-converted-with-lower-priority.html are flaky timeouts

Modified: trunk/Tools/MiniBrowser/win/MainWindow.cpp (249558 => 249559)


--- trunk/Tools/MiniBrowser/win/MainWindow.cpp	2019-09-06 01:45:01 UTC (rev 249558)
+++ trunk/Tools/MiniBrowser/win/MainWindow.cpp	2019-09-06 01:48:39 UTC (rev 249559)
@@ -264,9 +264,12 @@
     case WM_SIZE:
         thisWindow->resizeSubViews();
         break;
-    case WM_DPICHANGED:
+    case WM_DPICHANGED: {
         thisWindow->updateDeviceScaleFactor();
-        return DefWindowProc(hWnd, message, wParam, lParam);
+        auto& rect = *reinterpret_cast<RECT*>(lParam);
+        SetWindowPos(hWnd, nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE);
+        break;
+    }
     default:
         return DefWindowProc(hWnd, message, wParam, lParam);
     }

Modified: trunk/Tools/MiniBrowser/win/WinMain.cpp (249558 => 249559)


--- trunk/Tools/MiniBrowser/win/WinMain.cpp	2019-09-06 01:45:01 UTC (rev 249558)
+++ trunk/Tools/MiniBrowser/win/WinMain.cpp	2019-09-06 01:48:39 UTC (rev 249559)
@@ -34,11 +34,15 @@
 #include "MiniBrowserReplace.h"
 #include "WebKitLegacyBrowserWindow.h"
 #include <WebKitLegacy/WebKitCOMAPI.h>
+#include <wtf/win/SoftLinking.h>
 
 #if ENABLE(WEBKIT)
 #include "WebKitBrowserWindow.h"
 #endif
 
+SOFT_LINK_LIBRARY(user32);
+SOFT_LINK_OPTIONAL(user32, SetProcessDpiAwarenessContext, BOOL, STDAPICALLTYPE, (DPI_AWARENESS_CONTEXT));
+
 int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow)
 {
 #ifdef _CRTDBG_MAP_ALLOC
@@ -63,7 +67,10 @@
     // Init COM
     OleInitialize(nullptr);
 
-    ::SetProcessDPIAware();
+    if (SetProcessDpiAwarenessContextPtr())
+        SetProcessDpiAwarenessContextPtr()(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
+    else
+        ::SetProcessDPIAware();
 
     auto factory = WebKitLegacyBrowserWindow::create;
 #if ENABLE(WEBKIT)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to