Skip to content

Commit e496262

Browse files
author
Anton Tarasov
committed
JRE-907 macOS: add ability to check for scaled display mode
(cherry picked from commit d38092bafd3d4150a7e372a43f5492b8a970f2f6)
1 parent 641a09d commit e496262

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/java.desktop/macosx/native/libawt_lwawt/awt/CGraphicsDevice.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,11 @@ static jobject createJavaDisplayMode(CGDisplayModeRef mode, JNIEnv *env, jint di
141141
h = CGDisplayModeGetHeight(mode);
142142
w = CGDisplayModeGetWidth(mode);
143143
CFRelease(currentBPP);
144+
uint32_t flags = CGDisplayModeGetIOFlags(mode);
145+
BOOL isDisplayModeDefault = (flags & kDisplayModeDefaultFlag) ? YES : NO;
144146
static JNF_CLASS_CACHE(jc_DisplayMode, "java/awt/DisplayMode");
145-
static JNF_CTOR_CACHE(jc_DisplayMode_ctor, jc_DisplayMode, "(IIII)V");
146-
ret = JNFNewObject(env, jc_DisplayMode_ctor, w, h, bpp, refrate);
147+
static JNF_CTOR_CACHE(jc_DisplayMode_ctor, jc_DisplayMode, "(IIIIZ)V");
148+
ret = JNFNewObject(env, jc_DisplayMode_ctor, w, h, bpp, refrate, (jboolean)isDisplayModeDefault);
147149
JNF_COCOA_EXIT(env);
148150
return ret;
149151
}

src/java.desktop/share/classes/java/awt/DisplayMode.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public final class DisplayMode {
5151
private Dimension size;
5252
private int bitDepth;
5353
private int refreshRate;
54+
private boolean isDefault;
5455

5556
/**
5657
* Create a new display mode object with the supplied parameters.
@@ -71,6 +72,13 @@ public DisplayMode(int width, int height, int bitDepth, int refreshRate) {
7172
this.refreshRate = refreshRate;
7273
}
7374

75+
private DisplayMode(int width, int height, int bitDepth, int refreshRate, boolean isDefault) {
76+
this.size = new Dimension(width, height);
77+
this.bitDepth = bitDepth;
78+
this.refreshRate = refreshRate;
79+
this.isDefault = isDefault;
80+
}
81+
7482
/**
7583
* Returns the height of the display, in pixels.
7684
* @return the height of the display, in pixels
@@ -123,6 +131,10 @@ public int getRefreshRate() {
123131
return refreshRate;
124132
}
125133

134+
private boolean isDefault() {
135+
return isDefault;
136+
}
137+
126138
/**
127139
* Returns whether the two display modes are equal.
128140
*

0 commit comments

Comments
 (0)