--- old/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp 2016-09-02 16:54:31.613292000 +0530 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Window.cpp 2016-09-02 16:54:30.980976000 +0530 @@ -46,11 +46,16 @@ #include "sun_awt_windows_WCanvasPeer.h" #include - +#include #if !defined(__int3264) typedef __int32 LONG_PTR; #endif // __int3264 +#if defined(_MSC_VER) && _MSC_VER >= 1800 +# define ROUND_TO_INT(num) ((int) round(num)) +#else +# define ROUND_TO_INT(num) ((int) floor((num) + 0.5)) +#endif // Used for Swing's Menu/Tooltip animation Support const int UNSPECIFIED = 0; const int TOOLTIP = 1; @@ -3097,7 +3102,7 @@ env->DeleteGlobalRef(self); } - +extern "C" int getSystemMetricValue(int msgType); extern "C" { /* @@ -3407,7 +3412,7 @@ { TRY; - return ::GetSystemMetrics(SM_CYICON); + return getSystemMetricValue(SM_CYICON); CATCH_BAD_ALLOC_RET(0); } @@ -3422,7 +3427,7 @@ { TRY; - return ::GetSystemMetrics(SM_CXICON); + return getSystemMetricValue(SM_CXICON); CATCH_BAD_ALLOC_RET(0); } @@ -3437,7 +3442,7 @@ { TRY; - return ::GetSystemMetrics(SM_CYSMICON); + return getSystemMetricValue(SM_CYSMICON); CATCH_BAD_ALLOC_RET(0); } @@ -3452,11 +3457,41 @@ { TRY; - return ::GetSystemMetrics(SM_CXSMICON); + return getSystemMetricValue(SM_CXSMICON); CATCH_BAD_ALLOC_RET(0); } +int getSystemMetricValue(int msgType) { + int value = 1; + int logPixels = LOGPIXELSX; + switch (msgType) { + case SM_CXICON: + value = ::GetSystemMetrics(SM_CXICON); + break; + case SM_CYICON: + value = ::GetSystemMetrics(SM_CYICON); + logPixels = LOGPIXELSY; + break; + case SM_CXSMICON: + value = ::GetSystemMetrics(SM_CXSMICON); + break; + case SM_CYSMICON: + value = ::GetSystemMetrics(SM_CYSMICON); + logPixels = LOGPIXELSY; + break; + } + HWND hWnd = ::GetDesktopWindow(); + HDC hDC = ::GetDC(hWnd); + int dpi = GetDeviceCaps(hDC, logPixels); + if (dpi != 0 && dpi != 96) { + float invScaleX = 96.0f / dpi; + value = (int) ROUND_TO_INT(value * invScaleX); + } + ::ReleaseDC(hWnd, hDC); + return value; +} + /* * Class: sun_awt_windows_WWindowPeer * Method: setIconImagesData