Alexandre Julliard : user32: Implement Get/SetProcessDpiAwarenessInternal( ).

Alexandre Julliard julliard at winehq.org
Wed Apr 11 16:12:55 CDT 2018


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Apr 11 15:45:33 2018 +0200

user32: Implement Get/SetProcessDpiAwarenessInternal().

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

---

 .../ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec       |  4 +--
 dlls/user32/sysparams.c                            | 31 ++++++++++++++++++++++
 dlls/user32/tests/sysparams.c                      | 21 +++++++++++++++
 dlls/user32/user32.spec                            |  2 ++
 include/winuser.h                                  |  2 ++
 5 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-1-0/ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec b/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-1-0/ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec
index 63cecb4..ca1fe1c 100644
--- a/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-1-0/ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec
+++ b/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-1-0/ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec
@@ -1,3 +1,3 @@
 @ stub GetDpiForMonitorInternal
-@ stub GetProcessDpiAwarenessInternal
-@ stub SetProcessDpiAwarenessInternal
+@ stdcall GetProcessDpiAwarenessInternal(long ptr) user32.GetProcessDpiAwarenessInternal
+@ stdcall SetProcessDpiAwarenessInternal(long) user32.SetProcessDpiAwarenessInternal
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index a018dfc..8b6ea50 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -2963,6 +2963,37 @@ BOOL WINAPI SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
     return TRUE;
 }
 
+/**********************************************************************
+ *              GetProcessDpiAwarenessInternal   (USER32.@)
+ */
+BOOL WINAPI GetProcessDpiAwarenessInternal( HANDLE process, DPI_AWARENESS *awareness )
+{
+    if (process && process != GetCurrentProcess())
+    {
+        WARN( "not supported on other process %p\n", process );
+        *awareness = DPI_AWARENESS_UNAWARE;
+    }
+    else *awareness = GetAwarenessFromDpiAwarenessContext( dpi_awareness );
+    return TRUE;
+}
+
+/**********************************************************************
+ *              SetProcessDpiAwarenessInternal   (USER32.@)
+ */
+BOOL WINAPI SetProcessDpiAwarenessInternal( DPI_AWARENESS awareness )
+{
+    static const DPI_AWARENESS_CONTEXT contexts[3] = { DPI_AWARENESS_CONTEXT_UNAWARE,
+                                                       DPI_AWARENESS_CONTEXT_SYSTEM_AWARE,
+                                                       DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE };
+
+    if (awareness < DPI_AWARENESS_UNAWARE || awareness > DPI_AWARENESS_PER_MONITOR_AWARE)
+    {
+        SetLastError( ERROR_INVALID_PARAMETER );
+        return FALSE;
+    }
+    return SetProcessDpiAwarenessContext( contexts[awareness] );
+}
+
 /***********************************************************************
  *              AreDpiAwarenessContextsEqual   (USER32.@)
  */
diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c
index 5c27248..e132992 100644
--- a/dlls/user32/tests/sysparams.c
+++ b/dlls/user32/tests/sysparams.c
@@ -42,6 +42,8 @@ static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD,
 static BOOL (WINAPI *pIsProcessDPIAware)(void);
 static BOOL (WINAPI *pSetProcessDPIAware)(void);
 static BOOL (WINAPI *pSetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
+static BOOL (WINAPI *pGetProcessDpiAwarenessInternal)(HANDLE,DPI_AWARENESS*);
+static BOOL (WINAPI *pSetProcessDpiAwarenessInternal)(DPI_AWARENESS);
 static DPI_AWARENESS_CONTEXT (WINAPI *pGetThreadDpiAwarenessContext)(void);
 static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
 static DPI_AWARENESS_CONTEXT (WINAPI *pGetWindowDpiAwarenessContext)(HWND);
@@ -3027,6 +3029,23 @@ static void test_dpi_aware(void)
         ret = pSetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE );
         ok( !ret, "got %d\n", ret );
         ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
+
+        ret = pSetProcessDpiAwarenessInternal( DPI_AWARENESS_INVALID );
+        ok( !ret, "got %d\n", ret );
+        ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
+        ret = pSetProcessDpiAwarenessInternal( DPI_AWARENESS_UNAWARE );
+        ok( !ret, "got %d\n", ret );
+        ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
+        ret = pGetProcessDpiAwarenessInternal( 0, &awareness );
+        ok( ret, "got %d\n", ret );
+        ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong value %d\n", awareness );
+        ret = pGetProcessDpiAwarenessInternal( GetCurrentProcess(), &awareness );
+        ok( ret, "got %d\n", ret );
+        ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong value %d\n", awareness );
+        ret = pGetProcessDpiAwarenessInternal( (HANDLE)0xdeadbeef, &awareness );
+        ok( ret, "got %d\n", ret );
+        ok( awareness == DPI_AWARENESS_UNAWARE, "wrong value %d\n", awareness );
+
         ret = pIsProcessDPIAware();
         ok(ret, "got %d\n", ret);
         context = pGetThreadDpiAwarenessContext();
@@ -3140,6 +3159,8 @@ START_TEST(sysparams)
     pIsProcessDPIAware = (void*)GetProcAddress(hdll, "IsProcessDPIAware");
     pSetProcessDPIAware = (void*)GetProcAddress(hdll, "SetProcessDPIAware");
     pSetProcessDpiAwarenessContext = (void*)GetProcAddress(hdll, "SetProcessDpiAwarenessContext");
+    pGetProcessDpiAwarenessInternal = (void*)GetProcAddress(hdll, "GetProcessDpiAwarenessInternal");
+    pSetProcessDpiAwarenessInternal = (void*)GetProcAddress(hdll, "SetProcessDpiAwarenessInternal");
     pGetThreadDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetThreadDpiAwarenessContext");
     pSetThreadDpiAwarenessContext = (void*)GetProcAddress(hdll, "SetThreadDpiAwarenessContext");
     pGetWindowDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetWindowDpiAwarenessContext");
diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec
index d407a18..e990951 100644
--- a/dlls/user32/user32.spec
+++ b/dlls/user32/user32.spec
@@ -353,6 +353,7 @@
 @ stdcall GetPhysicalCursorPos(ptr)
 @ stdcall GetPriorityClipboardFormat(ptr long)
 @ stdcall GetProcessDefaultLayout(ptr)
+@ stdcall GetProcessDpiAwarenessInternal(long ptr)
 @ stdcall GetProcessWindowStation()
 @ stdcall GetProgmanWindow ()
 @ stdcall GetPropA(long str)
@@ -676,6 +677,7 @@
 @ stdcall SetProcessDPIAware()
 @ stdcall SetProcessDefaultLayout(long)
 @ stdcall SetProcessDpiAwarenessContext(long)
+@ stdcall SetProcessDpiAwarenessInternal(long)
 @ stdcall SetProcessWindowStation(long)
 @ stdcall SetProgmanWindow (long)
 @ stdcall SetPropA(long str long)
diff --git a/include/winuser.h b/include/winuser.h
index 63cfd5c..d35c445 100644
--- a/include/winuser.h
+++ b/include/winuser.h
@@ -3747,6 +3747,7 @@ WINUSERAPI HWND        WINAPI GetParent(HWND);
 WINUSERAPI BOOL        WINAPI GetPhysicalCursorPos(POINT*);
 WINUSERAPI INT         WINAPI GetPriorityClipboardFormat(UINT*,INT);
 WINUSERAPI BOOL        WINAPI GetProcessDefaultLayout(DWORD*);
+WINUSERAPI BOOL        WINAPI GetProcessDpiAwarenessInternal(HANDLE,DPI_AWARENESS*);
 WINUSERAPI HANDLE      WINAPI GetPropA(HWND,LPCSTR);
 WINUSERAPI HANDLE      WINAPI GetPropW(HWND,LPCWSTR);
 #define                       GetProp WINELIB_NAME_AW(GetProp)
@@ -4067,6 +4068,7 @@ WINUSERAPI BOOL        WINAPI SetPhysicalCursorPos(INT,INT);
 WINUSERAPI BOOL        WINAPI SetProcessDPIAware(void);
 WINUSERAPI BOOL        WINAPI SetProcessDefaultLayout(DWORD);
 WINUSERAPI BOOL        WINAPI SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT);
+WINUSERAPI BOOL        WINAPI SetProcessDpiAwarenessInternal(DPI_AWARENESS);
 WINUSERAPI BOOL        WINAPI SetProcessWindowStation(HWINSTA);
 WINUSERAPI BOOL        WINAPI SetPropA(HWND,LPCSTR,HANDLE);
 WINUSERAPI BOOL        WINAPI SetPropW(HWND,LPCWSTR,HANDLE);




More information about the wine-cvs mailing list