Alexandre Julliard : gdi32: Take DPI awareness into account for the LOGPIXELSX/Y device caps.

Alexandre Julliard julliard at winehq.org
Thu Apr 12 15:28:14 CDT 2018


Module: wine
Branch: master
Commit: 31967ef51df71994ab9b273353ea4937b8231b82
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=31967ef51df71994ab9b273353ea4937b8231b82

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Apr 12 13:25:16 2018 +0200

gdi32: Take DPI awareness into account for the LOGPIXELSX/Y device caps.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/gdi32/driver.c           |  5 +----
 dlls/gdi32/gdi_private.h      |  1 +
 dlls/gdi32/gdiobj.c           | 18 ++++++++++++++++++
 dlls/user32/tests/sysparams.c |  1 -
 4 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c
index fcf016b..c81a2e1 100644
--- a/dlls/gdi32/driver.c
+++ b/dlls/gdi32/driver.c
@@ -298,7 +298,6 @@ static BOOL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffe
 
 static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
 {
-    static int screen_dpi;
     int bpp;
 
     switch (cap)
@@ -351,9 +350,7 @@ static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
     case SHADEBLENDCAPS:  return 0;
     case COLORMGMTCAPS:   return 0;
     case LOGPIXELSX:
-    case LOGPIXELSY:
-        if (!screen_dpi && !(screen_dpi = get_dpi())) screen_dpi = 96;
-        return screen_dpi;
+    case LOGPIXELSY:      return get_system_dpi();
     case NUMCOLORS:
         bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
         return (bpp > 8) ? -1 : (1 << bpp);
diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index cf904d6..c5e4231 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -304,6 +304,7 @@ extern BOOL GDI_dec_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
 extern void GDI_hdc_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
 extern void GDI_hdc_not_using_object(HGDIOBJ obj, HDC hdc) DECLSPEC_HIDDEN;
 extern DWORD get_dpi(void) DECLSPEC_HIDDEN;
+extern DWORD get_system_dpi(void) DECLSPEC_HIDDEN;
 
 /* mapping.c */
 extern BOOL dp_to_lp( DC *dc, POINT *points, INT count ) DECLSPEC_HIDDEN;
diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c
index 16b82a3..db03f49 100644
--- a/dlls/gdi32/gdiobj.c
+++ b/dlls/gdi32/gdiobj.c
@@ -641,6 +641,24 @@ DWORD get_dpi(void)
     return 0;
 }
 
+/******************************************************************************
+ *              get_system_dpi
+ *
+ * Get the system DPI, based on the DPI awareness mode.
+ */
+DWORD get_system_dpi(void)
+{
+    static UINT (WINAPI *pGetDpiForSystem)(void);
+
+    if (!pGetDpiForSystem)
+    {
+        static const WCHAR user32W[] = {'u','s','e','r','3','2','.','d','l','l',0};
+        HMODULE user = GetModuleHandleW( user32W );
+        if (user) pGetDpiForSystem = (void *)GetProcAddress( user, "GetDpiForSystem" );
+    }
+    return pGetDpiForSystem ? pGetDpiForSystem() : 96;
+}
+
 static HFONT create_scaled_font( const LOGFONTW *deffont )
 {
     LOGFONTW lf;
diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c
index 5b185b9..4d60ea5 100644
--- a/dlls/user32/tests/sysparams.c
+++ b/dlls/user32/tests/sysparams.c
@@ -3091,7 +3091,6 @@ static void test_dpi_aware(void)
         dpi = pGetDpiForSystem();
         ok( dpi == USER_DEFAULT_SCREEN_DPI, "wrong dpi %u\n", dpi );
         dpi = GetDeviceCaps( hdc, LOGPIXELSX );
-        todo_wine_if (real_dpi != USER_DEFAULT_SCREEN_DPI)
         ok( dpi == USER_DEFAULT_SCREEN_DPI, "wrong dpi %u\n", dpi );
         ok( !pIsProcessDPIAware(), "still aware\n" );
         context = pGetThreadDpiAwarenessContext();




More information about the wine-cvs mailing list