This is an optimization that is particularly helpful for scrollbar code.
Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/user32/sysparams.c | 74 ++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 42 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 3f93f9c827..cdeea657c8 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -2646,9 +2646,8 @@ INT WINAPI GetSystemMetrics( INT index ) { case SM_CXVSCROLL: case SM_CYHSCROLL: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); - return ncm.iScrollWidth; + get_entry( &entry_SCROLLWIDTH, 0, &ret ); + return max( ret, 8 ); case SM_CYCAPTION: ncm.cbSize = sizeof(ncm); SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); @@ -2664,9 +2663,8 @@ INT WINAPI GetSystemMetrics( INT index ) case SM_CXHTHUMB: case SM_CYVSCROLL: case SM_CXHSCROLL: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); - return ncm.iScrollHeight; + get_entry( &entry_SCROLLHEIGHT, 0, &ret ); + return max( ret, 8 ); case SM_CXICON: case SM_CYICON: return map_to_dpi( 32, GetDpiForSystem() ); @@ -2712,21 +2710,20 @@ INT WINAPI GetSystemMetrics( INT index ) case SM_CYMIN: return GetSystemMetrics( SM_CYCAPTION) + 2 * GetSystemMetrics( SM_CYFRAME); case SM_CXSIZE: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); - return ncm.iCaptionWidth; + get_entry( &entry_CAPTIONWIDTH, 0, &ret ); + return max( ret, 8 ); case SM_CYSIZE: ncm.cbSize = sizeof(ncm); SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); return ncm.iCaptionHeight; case SM_CXFRAME: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); - return GetSystemMetrics(SM_CXDLGFRAME) + ncm.iBorderWidth; + get_entry( &entry_BORDER, 0, &ret ); + ret = max( ret, 1 ); + return GetSystemMetrics(SM_CXDLGFRAME) + ret; case SM_CYFRAME: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); - return GetSystemMetrics(SM_CYDLGFRAME) + ncm.iBorderWidth; + get_entry( &entry_BORDER, 0, &ret ); + ret = max( ret, 1 ); + return GetSystemMetrics(SM_CYDLGFRAME) + ret; case SM_CXMINTRACK: return GetSystemMetrics(SM_CXMIN); case SM_CYMINTRACK: @@ -2780,17 +2777,15 @@ INT WINAPI GetSystemMetrics( INT index ) SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); return ncm.iSmCaptionHeight + 1; case SM_CXSMSIZE: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); - return ncm.iSmCaptionWidth; + get_entry( &entry_SMCAPTIONWIDTH, 0, &ret ); + return ret; case SM_CYSMSIZE: ncm.cbSize = sizeof(ncm); SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); return ncm.iSmCaptionHeight; case SM_CXMENUSIZE: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); - return ncm.iMenuWidth; + get_entry( &entry_MENUWIDTH, 0, &ret ); + return ret; case SM_CYMENUSIZE: ncm.cbSize = sizeof(ncm); SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 ); @@ -2901,9 +2896,8 @@ INT WINAPI GetSystemMetricsForDpi( INT index, UINT dpi ) { case SM_CXVSCROLL: case SM_CYHSCROLL: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); - return ncm.iScrollWidth; + get_entry_dpi( &entry_SCROLLWIDTH, 0, &ret, dpi ); + return max( ret, 8 ); case SM_CYCAPTION: ncm.cbSize = sizeof(ncm); SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); @@ -2912,9 +2906,8 @@ INT WINAPI GetSystemMetricsForDpi( INT index, UINT dpi ) case SM_CXHTHUMB: case SM_CYVSCROLL: case SM_CXHSCROLL: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); - return ncm.iScrollHeight; + get_entry_dpi( &entry_SCROLLHEIGHT, 0, &ret, dpi ); + return max( ret, 8 ); case SM_CXICON: case SM_CYICON: return map_to_dpi( 32, dpi ); @@ -2929,21 +2922,20 @@ INT WINAPI GetSystemMetricsForDpi( INT index, UINT dpi ) SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); return ncm.iMenuHeight + 1; case SM_CXSIZE: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); - return ncm.iCaptionWidth; + get_entry_dpi( &entry_CAPTIONWIDTH, 0, &ret, dpi ); + return max( ret, 8 ); case SM_CYSIZE: ncm.cbSize = sizeof(ncm); SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); return ncm.iCaptionHeight; case SM_CXFRAME: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); - return GetSystemMetricsForDpi( SM_CXDLGFRAME, dpi ) + ncm.iBorderWidth; + get_entry_dpi( &entry_BORDER, 0, &ret, dpi ); + ret = max( ret, 1 ); + return GetSystemMetricsForDpi( SM_CXDLGFRAME, dpi ) + ret; case SM_CYFRAME: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); - return GetSystemMetricsForDpi( SM_CYDLGFRAME, dpi ) + ncm.iBorderWidth; + get_entry_dpi( &entry_BORDER, 0, &ret, dpi ); + ret = max( ret, 1 ); + return GetSystemMetricsForDpi( SM_CYDLGFRAME, dpi ) + ret; case SM_CXICONSPACING: im.cbSize = sizeof(im); SystemParametersInfoForDpi( SPI_GETICONMETRICS, sizeof(im), &im, 0, dpi ); @@ -2960,17 +2952,15 @@ INT WINAPI GetSystemMetricsForDpi( INT index, UINT dpi ) SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); return ncm.iSmCaptionHeight + 1; case SM_CXSMSIZE: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); - return ncm.iSmCaptionWidth; + get_entry_dpi( &entry_SMCAPTIONWIDTH, 0, &ret, dpi ); + return ret; case SM_CYSMSIZE: ncm.cbSize = sizeof(ncm); SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); return ncm.iSmCaptionHeight; case SM_CXMENUSIZE: - ncm.cbSize = sizeof(ncm); - SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi ); - return ncm.iMenuWidth; + get_entry_dpi( &entry_MENUWIDTH, 0, &ret, dpi ); + return ret; case SM_CYMENUSIZE: ncm.cbSize = sizeof(ncm); SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );