user32: Fix the calculation of system metrics icon sizes.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2017-05-02 16:12:37 +01:00 committed by Alexandre Julliard
parent a7d79fe445
commit fb118b222a
2 changed files with 42 additions and 11 deletions

View File

@ -174,7 +174,6 @@ static const WCHAR SMCAPTIONWIDTH_VALNAME[]= {METRICS_KEY,'S','m','C',
static const WCHAR SMCAPTIONHEIGHT_VALNAME[]= {METRICS_KEY,'S','m','C','a','p','t','i','o','n','H','e','i','g','h','t',0};
static const WCHAR MENUWIDTH_VALNAME[]= {METRICS_KEY,'M','e','n','u','W','i','d','t','h',0};
static const WCHAR MENUHEIGHT_VALNAME[]= {METRICS_KEY,'M','e','n','u','H','e','i','g','h','t',0};
static const WCHAR ICONSIZE_VALNAME[]= {METRICS_KEY,'S','h','e','l','l',' ','I','c','o','n',' ','S','i','z','e',0};
static const WCHAR PADDEDBORDERWIDTH_VALNAME[]= {METRICS_KEY,'P','a','d','d','e','d','B','o','r','d','e','r','W','i','d','t','h',0};
static const WCHAR CAPTIONLOGFONT_VALNAME[]= {METRICS_KEY,'C','a','p','t','i','o','n','F','o','n','t',0};
static const WCHAR SMCAPTIONLOGFONT_VALNAME[]= {METRICS_KEY,'S','m','C','a','p','t','i','o','n','F','o','n','t',0};
@ -1158,7 +1157,6 @@ static UINT_ENTRY( DRAGHEIGHT, 4 );
static UINT_ENTRY( DOUBLECLICKTIME, 500 );
static UINT_ENTRY( FONTSMOOTHING, 2 );
static UINT_ENTRY( GRIDGRANULARITY, 0 );
static UINT_ENTRY( ICONSIZE, 32 );
static UINT_ENTRY( KEYBOARDDELAY, 1 );
static UINT_ENTRY( KEYBOARDSPEED, 31 );
static UINT_ENTRY( MENUSHOWDELAY, 400 );
@ -1323,7 +1321,6 @@ static union sysparam_all_entry * const default_entries[] =
(union sysparam_all_entry *)&entry_FOREGROUNDFLASHCOUNT,
(union sysparam_all_entry *)&entry_FOREGROUNDLOCKTIMEOUT,
(union sysparam_all_entry *)&entry_ICONHORIZONTALSPACING,
(union sysparam_all_entry *)&entry_ICONSIZE,
(union sysparam_all_entry *)&entry_ICONTITLEWRAP,
(union sysparam_all_entry *)&entry_ICONVERTICALSPACING,
(union sysparam_all_entry *)&entry_KEYBOARDDELAY,
@ -2400,7 +2397,9 @@ INT WINAPI GetSystemMetrics( INT index )
return max( 8, ret );
case SM_CXICON:
case SM_CYICON:
get_entry( &entry_ICONSIZE, 0, &ret );
ret = 32;
if (IsProcessDPIAware())
ret = MulDiv( ret, get_display_dpi(), USER_DEFAULT_SCREEN_DPI );
return ret;
case SM_CXCURSOR:
case SM_CYCURSOR:
@ -2492,7 +2491,10 @@ INT WINAPI GetSystemMetrics( INT index )
return GetSystemMetrics(SM_CYMINIMIZED) + max( 0, (INT)ret );
case SM_CXSMICON:
case SM_CYSMICON:
return 16;
ret = 16;
if (IsProcessDPIAware())
ret = MulDiv( ret, get_display_dpi(), USER_DEFAULT_SCREEN_DPI ) & ~1;
return ret;
case SM_CYSMCAPTION:
return GetSystemMetrics(SM_CYSMSIZE) + 1;
case SM_CXSMSIZE:

View File

@ -39,6 +39,8 @@
#endif
static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID);
static BOOL (WINAPI *pIsProcessDPIAware)(void);
static BOOL (WINAPI *pSetProcessDPIAware)(void);
static BOOL strict;
static int dpi, real_dpi;
@ -2702,7 +2704,7 @@ static void test_GetSystemMetrics( void)
HDC hdc = CreateICA( "Display", 0, 0, 0);
UINT avcwCaption;
INT CaptionWidthfromreg;
INT CaptionWidthfromreg, smicon, broken_val;
MINIMIZEDMETRICS minim;
NONCLIENTMETRICSA ncm;
SIZE screen;
@ -2769,8 +2771,9 @@ static void test_GetSystemMetrics( void)
ok_gsm( SM_CYDLGFRAME, 3);
ok_gsm( SM_CYVTHUMB, ncm.iScrollHeight);
ok_gsm( SM_CXHTHUMB, ncm.iScrollHeight);
/* SM_CXICON */
/* SM_CYICON */
/* These don't depend on the Shell Icon Size registry value */
ok_gsm( SM_CXICON, MulDiv( 32, dpi, USER_DEFAULT_SCREEN_DPI ) );
ok_gsm( SM_CYICON, MulDiv( 32, dpi, USER_DEFAULT_SCREEN_DPI ) );
/* SM_CXCURSOR */
/* SM_CYCURSOR */
ok_gsm( SM_CYMENU, ncm.iMenuHeight + 1);
@ -2815,8 +2818,32 @@ static void test_GetSystemMetrics( void)
/* sign-extension for iHorzGap/iVertGap is broken on Win9x */
ok_gsm( SM_CXMINSPACING, GetSystemMetrics( SM_CXMINIMIZED) + (short)minim.iHorzGap );
ok_gsm( SM_CYMINSPACING, GetSystemMetrics( SM_CYMINIMIZED) + (short)minim.iVertGap );
/* SM_CXSMICON */
/* SM_CYSMICON */
smicon = MulDiv( 16, dpi, USER_DEFAULT_SCREEN_DPI );
if (!pIsProcessDPIAware || pIsProcessDPIAware())
smicon = max( min( smicon, CaptionWidthfromreg - 2), 4 ) & ~1;
todo_wine_if( real_dpi == dpi && smicon != (MulDiv( 16, dpi, USER_DEFAULT_SCREEN_DPI) & ~1) )
{
broken_val = (min( ncm.iCaptionHeight, CaptionWidthfromreg ) - 2) & ~1;
broken_val = min( broken_val, 20 );
if (smicon == 4)
{
ok_gsm_2( SM_CXSMICON, smicon, 6 );
ok_gsm_2( SM_CYSMICON, smicon, 6 );
}
else if (smicon < broken_val)
{
ok_gsm_2( SM_CXSMICON, smicon, broken_val );
ok_gsm_2( SM_CYSMICON, smicon, broken_val );
}
else
{
ok_gsm( SM_CXSMICON, smicon );
ok_gsm( SM_CYSMICON, smicon );
}
}
ok_gsm( SM_CYSMCAPTION, ncm.iSmCaptionHeight + 1);
ok_gsm_3( SM_CXSMSIZE,
ncm.iSmCaptionWidth, /* classic/standard windows style */
@ -2960,7 +2987,9 @@ START_TEST(sysparams)
HANDLE hInstance, hdll;
hdll = GetModuleHandleA("user32.dll");
pChangeDisplaySettingsExA=(void*)GetProcAddress(hdll, "ChangeDisplaySettingsExA");
pChangeDisplaySettingsExA = (void*)GetProcAddress(hdll, "ChangeDisplaySettingsExA");
pIsProcessDPIAware = (void*)GetProcAddress(hdll, "IsProcessDPIAware");
pSetProcessDPIAware = (void*)GetProcAddress(hdll, "SetProcessDPIAware");
hInstance = GetModuleHandleA( NULL );
hdc = GetDC(0);