Jacek Caban : win32u: Directly use sysparams in nulldrv_GetDeviceCaps.

Alexandre Julliard julliard at winehq.org
Mon Dec 6 16:07:59 CST 2021


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Dec  6 03:16:10 2021 +0100

win32u: Directly use sysparams in nulldrv_GetDeviceCaps.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/win32u/driver.c         | 50 ++++++++------------------------------------
 dlls/win32u/ntgdi_private.h  |  1 -
 dlls/win32u/sysparams.c      | 20 +++++++++++++++++-
 dlls/win32u/win32u_private.h |  5 ++---
 dlls/win32u/wrappers.c       | 28 -------------------------
 5 files changed, 30 insertions(+), 74 deletions(-)

diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c
index 158e844cccb..5fa1a2ca236 100644
--- a/dlls/win32u/driver.c
+++ b/dlls/win32u/driver.c
@@ -83,28 +83,6 @@ const struct gdi_dc_funcs *get_display_driver(void)
     return &user_driver->dc_funcs;
 }
 
-struct monitor_info
-{
-    const WCHAR *name;
-    RECT rect;
-};
-
-static BOOL CALLBACK monitor_enum_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lparam )
-{
-    struct monitor_info *info = (struct monitor_info *)lparam;
-    MONITORINFOEXW mi;
-
-    mi.cbSize = sizeof(mi);
-    user_callbacks->pGetMonitorInfoW( monitor, (MONITORINFO *)&mi );
-    if (!wcsicmp( info->name, mi.szDevice ))
-    {
-        info->rect = mi.rcMonitor;
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
 static INT CDECL nulldrv_AbortDoc( PHYSDEV dev )
 {
     return 0;
@@ -224,41 +202,31 @@ static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
     case HORZRES:
     {
         DC *dc = get_nulldrv_dc( dev );
-        struct monitor_info info;
+        RECT rect;
         int ret;
 
-        if (!user_callbacks) return 640;
-
         if (dc->display[0])
         {
-            info.name = dc->display;
-            SetRectEmpty( &info.rect );
-            user_callbacks->pEnumDisplayMonitors( NULL, NULL, monitor_enum_proc, (LPARAM)&info );
-            if (!IsRectEmpty( &info.rect ))
-                return info.rect.right - info.rect.left;
+            rect = get_display_rect( dc->display );
+            if (!IsRectEmpty( &rect )) return rect.right - rect.left;
         }
 
-        ret = user_callbacks->pGetSystemMetrics( SM_CXSCREEN );
+        ret = get_system_metrics( SM_CXSCREEN );
         return ret ? ret : 640;
     }
     case VERTRES:
     {
         DC *dc = get_nulldrv_dc( dev );
-        struct monitor_info info;
+        RECT rect;
         int ret;
 
-        if (!user_callbacks) return 480;
-
-        if (dc->display[0] && user_callbacks)
+        if (dc->display[0])
         {
-            info.name = dc->display;
-            SetRectEmpty( &info.rect );
-            user_callbacks->pEnumDisplayMonitors( NULL, NULL, monitor_enum_proc, (LPARAM)&info );
-            if (!IsRectEmpty( &info.rect ))
-                return info.rect.bottom - info.rect.top;
+            rect = get_display_rect( dc->display );
+            if (!IsRectEmpty( &rect )) return rect.bottom - rect.top;
         }
 
-        ret = user_callbacks->pGetSystemMetrics( SM_CYSCREEN );
+        ret = get_system_metrics( SM_CYSCREEN );
         return ret ? ret : 480;
     }
     case BITSPIXEL:
diff --git a/dlls/win32u/ntgdi_private.h b/dlls/win32u/ntgdi_private.h
index 534687cb60b..13c365c075d 100644
--- a/dlls/win32u/ntgdi_private.h
+++ b/dlls/win32u/ntgdi_private.h
@@ -372,7 +372,6 @@ extern void GDI_ReleaseObj( HGDIOBJ ) DECLSPEC_HIDDEN;
 extern UINT GDI_get_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
 extern HGDIOBJ GDI_inc_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
 extern BOOL GDI_dec_ref_count( HGDIOBJ handle ) DECLSPEC_HIDDEN;
-extern DWORD get_system_dpi(void) DECLSPEC_HIDDEN;
 extern HGDIOBJ get_stock_object( INT obj ) DECLSPEC_HIDDEN;
 extern DWORD get_gdi_object_type( HGDIOBJ obj ) DECLSPEC_HIDDEN;
 
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index e1f52461ca9..2072597a968 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -1462,6 +1462,24 @@ RECT get_virtual_screen_rect( UINT dpi )
     return rect;
 }
 
+RECT get_display_rect( const WCHAR *display )
+{
+    struct monitor *monitor;
+    RECT rect = {0};
+
+    if (!lock_display_devices()) return rect;
+
+    LIST_FOR_EACH_ENTRY( monitor, &monitors, struct monitor, entry )
+    {
+        if (!monitor->adapter || wcsicmp( monitor->adapter->dev.device_name, display )) continue;
+        rect = monitor->rc_monitor;
+        break;
+    }
+
+    unlock_display_devices();
+    return map_dpi_rect( rect, system_dpi, get_thread_dpi() );
+}
+
 static RECT get_primary_monitor_rect(void)
 {
     struct monitor *monitor;
@@ -3907,7 +3925,7 @@ BOOL WINAPI NtUserSystemParametersInfo( UINT action, UINT val, void *ptr, UINT w
 #undef WINE_SPI_WARN
 }
 
-static int get_system_metrics( int index )
+int get_system_metrics( int index )
 {
     NONCLIENTMETRICSW ncm;
     MINIMIZEDMETRICS mm;
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index 3728c3b4065..7e867d4f736 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -33,10 +33,7 @@
 struct user_callbacks
 {
     HWND (WINAPI *pGetDesktopWindow)(void);
-    BOOL (WINAPI *pGetMonitorInfoW)( HMONITOR, LPMONITORINFO );
-    INT (WINAPI *pGetSystemMetrics)(INT);
     BOOL (WINAPI *pGetWindowRect)( HWND hwnd, LPRECT rect );
-    BOOL (WINAPI *pEnumDisplayMonitors)( HDC, LPRECT, MONITORENUMPROC, LPARAM );
     BOOL (WINAPI *pRedrawWindow)( HWND, const RECT*, HRGN, UINT );
     LRESULT (WINAPI *pSendMessageTimeoutW)( HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR );
     HWND (WINAPI *pWindowFromDC)( HDC );
@@ -245,7 +242,9 @@ struct unix_funcs
                                       struct window_surface *surface );
 };
 
+extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN;
 extern UINT get_system_dpi(void) DECLSPEC_HIDDEN;
+extern int get_system_metrics( int index ) DECLSPEC_HIDDEN;
 extern RECT get_virtual_screen_rect( UINT dpi ) DECLSPEC_HIDDEN;
 
 extern void wrappers_init( unixlib_handle_t handle ) DECLSPEC_HIDDEN;
diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c
index e81b202fc78..9bdd3ec3634 100644
--- a/dlls/win32u/wrappers.c
+++ b/dlls/win32u/wrappers.c
@@ -958,22 +958,6 @@ static HWND WINAPI call_GetDesktopWindow(void)
     return pGetDesktopWindow ? pGetDesktopWindow() : NULL;
 }
 
-static BOOL WINAPI call_GetMonitorInfoW( HMONITOR monitor, MONITORINFO *info )
-{
-    static BOOL (WINAPI *pGetMonitorInfoW)( HMONITOR, LPMONITORINFO );
-    if (!pGetMonitorInfoW)
-        pGetMonitorInfoW = get_user_proc( "GetMonitorInfoW", FALSE );
-    return pGetMonitorInfoW && pGetMonitorInfoW( monitor, info );
-}
-
-static INT WINAPI call_GetSystemMetrics( INT metric )
-{
-    static INT (WINAPI *pGetSystemMetrics)(INT);
-    if (!pGetSystemMetrics)
-        pGetSystemMetrics = get_user_proc( "GetSystemMetrics", FALSE );
-    return pGetSystemMetrics ? pGetSystemMetrics( metric ) : 0;
-}
-
 static BOOL WINAPI call_GetWindowRect( HWND hwnd, LPRECT rect )
 {
     static BOOL (WINAPI *pGetWindowRect)( HWND hwnd, LPRECT rect );
@@ -982,15 +966,6 @@ static BOOL WINAPI call_GetWindowRect( HWND hwnd, LPRECT rect )
     return pGetWindowRect && pGetWindowRect( hwnd, rect );
 }
 
-static BOOL WINAPI call_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc,
-                                             LPARAM lparam )
-{
-    static BOOL (WINAPI *pEnumDisplayMonitors)( HDC, LPRECT, MONITORENUMPROC, LPARAM );
-    if (!pEnumDisplayMonitors)
-        pEnumDisplayMonitors = get_user_proc( "EnumDisplayMonitors", FALSE );
-    return pEnumDisplayMonitors && pEnumDisplayMonitors( hdc, rect, proc, lparam );
-}
-
 static BOOL WINAPI call_RedrawWindow( HWND hwnd, const RECT *rect, HRGN rgn, UINT flags )
 {
     static BOOL (WINAPI *pRedrawWindow)( HWND, const RECT*, HRGN, UINT );
@@ -1019,10 +994,7 @@ static HWND WINAPI call_WindowFromDC( HDC hdc )
 static const struct user_callbacks user_funcs =
 {
     call_GetDesktopWindow,
-    call_GetMonitorInfoW,
-    call_GetSystemMetrics,
     call_GetWindowRect,
-    call_EnumDisplayMonitors,
     call_RedrawWindow,
     call_SendMessageTimeoutW,
     call_WindowFromDC,




More information about the wine-cvs mailing list