Huw Davies : winemac: Try to read the dpi from the user key first.

Alexandre Julliard julliard at winehq.org
Thu Apr 27 15:49:11 CDT 2017


Module: wine
Branch: master
Commit: d74348f9b5482cabf68f88f9b92983c53b3e9f00
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d74348f9b5482cabf68f88f9b92983c53b3e9f00

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Apr 27 11:02:34 2017 +0100

winemac: Try to read the dpi from the user key first.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Ken Thomases <ken at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winemac.drv/gdi.c | 46 ++++++++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/dlls/winemac.drv/gdi.c b/dlls/winemac.drv/gdi.c
index e110227..a0f4ee9 100644
--- a/dlls/winemac.drv/gdi.c
+++ b/dlls/winemac.drv/gdi.c
@@ -63,37 +63,51 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
 static CRITICAL_SECTION device_data_section = { &critsect_debug, -1, 0, 0, 0, 0 };
 
 
-static const WCHAR dpi_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'};
+static const WCHAR dpi_key_name[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\0'};
+static const WCHAR def_dpi_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'};
 static const WCHAR dpi_value_name[] = {'L','o','g','P','i','x','e','l','s','\0'};
 
 static const struct gdi_dc_funcs macdrv_funcs;
 
-
 /******************************************************************************
- *              get_dpi
+ *              get_reg_dword
  *
- * get the dpi from the registry
+ * Read a DWORD value from the registry
  */
-static DWORD get_dpi(void)
+static BOOL get_reg_dword(HKEY base, const WCHAR *key_name, const WCHAR *value_name, DWORD *value)
 {
-    DWORD dpi = 0;
-    HKEY hkey;
+    HKEY key;
+    DWORD type, data, size = sizeof(data);
+    BOOL ret = FALSE;
 
-    if (RegOpenKeyW(HKEY_CURRENT_CONFIG, dpi_key_name, &hkey) == ERROR_SUCCESS)
+    if (RegOpenKeyW(base, key_name, &key) == ERROR_SUCCESS)
     {
-        DWORD type, size, new_dpi;
-
-        size = sizeof(new_dpi);
-        if (RegQueryValueExW(hkey, dpi_value_name, NULL, &type, (void *)&new_dpi, &size) == ERROR_SUCCESS)
+        if (RegQueryValueExW(key, value_name, NULL, &type, (void *)&data, &size) == ERROR_SUCCESS &&
+            type == REG_DWORD)
         {
-            if (type == REG_DWORD && new_dpi != 0)
-                dpi = new_dpi;
+            *value = data;
+            ret = TRUE;
         }
-        RegCloseKey(hkey);
+        RegCloseKey(key);
     }
-    return dpi;
+    return ret;
 }
 
+/******************************************************************************
+ *              get_dpi
+ *
+ * get the dpi from the registry
+ */
+static DWORD get_dpi(void)
+{
+    DWORD dpi;
+
+    if (get_reg_dword(HKEY_CURRENT_USER, dpi_key_name, dpi_value_name, &dpi))
+        return dpi;
+    if (get_reg_dword(HKEY_CURRENT_CONFIG, def_dpi_key_name, dpi_value_name, &dpi))
+        return dpi;
+    return 0;
+}
 
 /***********************************************************************
  *              compute_desktop_rect




More information about the wine-cvs mailing list