JRE-119 [ask if ui scale is enabled natively]

(cherry picked from commit 801f45875fd8699edcbda5896210cec191062261)
(cherry picked from commit 20edebdefa)
(cherry picked from commit 9ac3479114)
This commit is contained in:
Anton Tarasov
2016-09-09 19:30:46 +03:00
committed by jbrbot
parent c6ea7babf2
commit 5f48d18659
3 changed files with 15 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
#include "mmsystem.h"
#include "jlong.h"
#include "awt_DesktopProperties.h"
#include "awt_Win32GraphicsDevice.h"
#include "awt_Toolkit.h"
#include "sun_awt_windows_WDesktopProperties.h"
#include "java_awt_Font.h"
@@ -82,6 +83,11 @@ void AwtDesktopProperties::GetWindowsParameters() {
}
void getInvScale(float &invScaleX, float &invScaleY) {
if (!AwtWin32GraphicsDevice::IsUiScaleEnabled()) {
invScaleX = 1.0f;
invScaleY = 1.0f;
return;
}
static int dpiX = -1;
static int dpiY = -1;
if (dpiX == -1 || dpiY == -1) {

View File

@@ -914,6 +914,14 @@ int AwtWin32GraphicsDevice::GetScreenFromHMONITOR(HMONITOR mon) {
* End of static deviceIndex-based methods
*/
BOOL AwtWin32GraphicsDevice::IsUiScaleEnabled()
{
return JNU_CallStaticMethodByName(AwtToolkit::GetEnv(),
NULL,
"sun/java2d/SunGraphicsEnvironment",
"isUIScaleEnabled",
"()Z").z;
}
const DWORD REQUIRED_FLAGS = ( //Flags which must be set in
PFD_SUPPORT_GDI | //in the PixelFormatDescriptor.

View File

@@ -97,6 +97,7 @@ public:
static int GetDefaultDeviceIndex() { return primaryIndex; }
static HDC GetDCFromScreen(int screen);
static int GetScreenFromHMONITOR(HMONITOR mon);
static BOOL IsUiScaleEnabled(); // if not, be dpi-unaware (backward compatible behaviour)
static int primaryIndex;
static BOOL primaryPalettized;