winex11: Try to read the dpi from the user key first.
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
39b467da61
commit
d645c6ffac
|
@ -42,12 +42,37 @@ static Pixmap stock_bitmap_pixmap; /* phys bitmap for the default stock bitmap
|
|||
|
||||
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
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 x11drv_funcs;
|
||||
static const struct gdi_dc_funcs *xrender_funcs;
|
||||
|
||||
/******************************************************************************
|
||||
* get_reg_dword
|
||||
*
|
||||
* Read a DWORD value from the registry
|
||||
*/
|
||||
static BOOL get_reg_dword(HKEY base, const WCHAR *key_name, const WCHAR *value_name, DWORD *value)
|
||||
{
|
||||
HKEY key;
|
||||
DWORD type, data, size = sizeof(data);
|
||||
BOOL ret = FALSE;
|
||||
|
||||
if (RegOpenKeyW(base, key_name, &key) == ERROR_SUCCESS)
|
||||
{
|
||||
if (RegQueryValueExW(key, value_name, NULL, &type, (void *)&data, &size) == ERROR_SUCCESS &&
|
||||
type == REG_DWORD)
|
||||
{
|
||||
*value = data;
|
||||
ret = TRUE;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* get_dpi
|
||||
*
|
||||
|
@ -55,22 +80,13 @@ static const struct gdi_dc_funcs *xrender_funcs;
|
|||
*/
|
||||
static DWORD get_dpi(void)
|
||||
{
|
||||
DWORD dpi = 96;
|
||||
HKEY hkey;
|
||||
DWORD dpi;
|
||||
|
||||
if (RegOpenKeyW(HKEY_CURRENT_CONFIG, dpi_key_name, &hkey) == 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(type == REG_DWORD && new_dpi != 0)
|
||||
dpi = new_dpi;
|
||||
}
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -92,6 +108,9 @@ static BOOL WINAPI device_init( INIT_ONCE *once, void *param, void **context )
|
|||
|
||||
/* Initialize device caps */
|
||||
log_pixels_x = log_pixels_y = get_dpi();
|
||||
if (!log_pixels_x)
|
||||
log_pixels_x = log_pixels_y = USER_DEFAULT_SCREEN_DPI;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue