JRE-907 macOS: add ability to check for scaled display mode

(cherry picked from commit e496262aa1)
This commit is contained in:
Anton Tarasov
2021-03-18 14:37:20 +03:00
committed by Vitaly Provodin
parent 7631a99b6c
commit 7bbefb58bd
2 changed files with 16 additions and 2 deletions

View File

@@ -158,9 +158,11 @@ static jobject createJavaDisplayMode(CGDisplayModeRef mode, JNIEnv *env) {
w = CGDisplayModeGetWidth(mode);
CFRelease(currentBPP);
}
uint32_t flags = CGDisplayModeGetIOFlags(mode);
BOOL isDisplayModeDefault = (flags & kDisplayModeDefaultFlag) ? YES : NO;
DECLARE_CLASS_RETURN(jc_DisplayMode, "java/awt/DisplayMode", ret);
DECLARE_METHOD_RETURN(jc_DisplayMode_ctor, jc_DisplayMode, "<init>", "(IIII)V", ret);
ret = (*env)->NewObject(env, jc_DisplayMode, jc_DisplayMode_ctor, w, h, bpp, refrate);
DECLARE_METHOD_RETURN(jc_DisplayMode_ctor, jc_DisplayMode, "<init>", "(IIIIZ)V", ret);
ret = (*env)->NewObject(env, jc_DisplayMode, jc_DisplayMode_ctor, w, h, bpp, refrate, (jboolean)isDisplayModeDefault);
CHECK_EXCEPTION();
JNI_COCOA_EXIT(env);
return ret;

View File

@@ -51,6 +51,7 @@ public final class DisplayMode {
private Dimension size;
private int bitDepth;
private int refreshRate;
private boolean isDefault;
/**
* Create a new display mode object with the supplied parameters.
@@ -71,6 +72,13 @@ public final class DisplayMode {
this.refreshRate = refreshRate;
}
private DisplayMode(int width, int height, int bitDepth, int refreshRate, boolean isDefault) {
this.size = new Dimension(width, height);
this.bitDepth = bitDepth;
this.refreshRate = refreshRate;
this.isDefault = isDefault;
}
/**
* Returns the height of the display, in pixels.
* @return the height of the display, in pixels
@@ -123,6 +131,10 @@ public final class DisplayMode {
return refreshRate;
}
private boolean isDefault() {
return isDefault;
}
/**
* Returns whether the two display modes are equal.
*