author | serb |
Thu, 24 Oct 2019 14:54:31 -0700 | |
changeset 59175 | d2123a27cfe7 |
parent 58599 | a9b346a481d7 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
53673
e04d39094915
8214076: Cleanup the code related to GraphicsEnvironment/Device/Configuration
serb
parents:
52537
diff
changeset
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
12047 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package sun.awt; |
|
27 |
||
15988 | 28 |
import java.awt.AWTPermission; |
29 |
import java.awt.DisplayMode; |
|
12047 | 30 |
import java.awt.GraphicsConfiguration; |
31 |
import java.awt.GraphicsDevice; |
|
15989
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
32 |
import java.awt.Insets; |
52537
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
33 |
import java.awt.Rectangle; |
12047 | 34 |
import java.awt.Window; |
52537
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
35 |
import java.awt.geom.Rectangle2D; |
59175
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
36 |
import java.awt.peer.WindowPeer; |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
14166
diff
changeset
|
37 |
import java.util.Objects; |
52537
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
38 |
|
36900
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
39 |
import sun.java2d.SunGraphicsEnvironment; |
12047 | 40 |
import sun.java2d.opengl.CGLGraphicsConfig; |
41 |
||
59175
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
42 |
import static java.awt.peer.ComponentPeer.SET_BOUNDS; |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
43 |
|
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
44 |
public final class CGraphicsDevice extends GraphicsDevice |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
45 |
implements DisplayChangedListener { |
12047 | 46 |
|
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
47 |
/** |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
48 |
* CoreGraphics display ID. This identifier can become non-valid at any time |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
49 |
* therefore methods, which is using this id should be ready to it. |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
50 |
*/ |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
51 |
private volatile int displayID; |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
52 |
private volatile double xResolution; |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
53 |
private volatile double yResolution; |
52537
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
54 |
private volatile Rectangle bounds; |
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
55 |
private volatile int scale; |
12047 | 56 |
|
53673
e04d39094915
8214076: Cleanup the code related to GraphicsEnvironment/Device/Configuration
serb
parents:
52537
diff
changeset
|
57 |
private final GraphicsConfiguration config; |
12047 | 58 |
|
59 |
private static AWTPermission fullScreenExclusivePermission; |
|
60 |
||
13241
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
61 |
// Save/restore DisplayMode for the Full Screen mode |
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
62 |
private DisplayMode originalMode; |
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
63 |
|
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
64 |
public CGraphicsDevice(final int displayID) { |
12047 | 65 |
this.displayID = displayID; |
53673
e04d39094915
8214076: Cleanup the code related to GraphicsEnvironment/Device/Configuration
serb
parents:
52537
diff
changeset
|
66 |
config = CGLGraphicsConfig.getConfig(this, displayID, 0); |
58599
a9b346a481d7
8229810: [macos] NullPointerException getting bounds of GraphicsConfiguration
serb
parents:
53673
diff
changeset
|
67 |
// initializes default device state, might be redundant step since we |
a9b346a481d7
8229810: [macos] NullPointerException getting bounds of GraphicsConfiguration
serb
parents:
53673
diff
changeset
|
68 |
// call "displayChanged()" later anyway, but we do not want to leave the |
a9b346a481d7
8229810: [macos] NullPointerException getting bounds of GraphicsConfiguration
serb
parents:
53673
diff
changeset
|
69 |
// device in an inconsistent state after construction |
a9b346a481d7
8229810: [macos] NullPointerException getting bounds of GraphicsConfiguration
serb
parents:
53673
diff
changeset
|
70 |
displayChanged(); |
12047 | 71 |
} |
72 |
||
73 |
/** |
|
74 |
* Return a list of all configurations. |
|
75 |
*/ |
|
76 |
@Override |
|
77 |
public GraphicsConfiguration[] getConfigurations() { |
|
53673
e04d39094915
8214076: Cleanup the code related to GraphicsEnvironment/Device/Configuration
serb
parents:
52537
diff
changeset
|
78 |
return new GraphicsConfiguration[]{config}; |
12047 | 79 |
} |
80 |
||
81 |
/** |
|
82 |
* Return the default configuration. |
|
83 |
*/ |
|
84 |
@Override |
|
85 |
public GraphicsConfiguration getDefaultConfiguration() { |
|
53673
e04d39094915
8214076: Cleanup the code related to GraphicsEnvironment/Device/Configuration
serb
parents:
52537
diff
changeset
|
86 |
return config; |
12047 | 87 |
} |
88 |
||
89 |
/** |
|
90 |
* Return a human-readable screen description. |
|
91 |
*/ |
|
92 |
@Override |
|
93 |
public String getIDstring() { |
|
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
94 |
return "Display " + displayID; |
12047 | 95 |
} |
96 |
||
97 |
/** |
|
98 |
* Returns the type of the graphics device. |
|
99 |
* @see #TYPE_RASTER_SCREEN |
|
100 |
* @see #TYPE_PRINTER |
|
101 |
* @see #TYPE_IMAGE_BUFFER |
|
102 |
*/ |
|
103 |
@Override |
|
104 |
public int getType() { |
|
105 |
return TYPE_RASTER_SCREEN; |
|
106 |
} |
|
107 |
||
108 |
public double getXResolution() { |
|
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
109 |
return xResolution; |
12047 | 110 |
} |
111 |
||
112 |
public double getYResolution() { |
|
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
113 |
return yResolution; |
12047 | 114 |
} |
115 |
||
52537
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
116 |
Rectangle getBounds() { |
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
117 |
return bounds.getBounds(); |
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
118 |
} |
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
119 |
|
15989
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
120 |
public Insets getScreenInsets() { |
29256
751f31639710
8072069: Toolkit.getScreenInsets() doesn't update if insets change
anashaty
parents:
28235
diff
changeset
|
121 |
// the insets are queried synchronously and are not cached |
751f31639710
8072069: Toolkit.getScreenInsets() doesn't update if insets change
anashaty
parents:
28235
diff
changeset
|
122 |
// since there are no Quartz or Cocoa means to receive notifications |
751f31639710
8072069: Toolkit.getScreenInsets() doesn't update if insets change
anashaty
parents:
28235
diff
changeset
|
123 |
// on insets changes (e.g. when the Dock is resized): |
751f31639710
8072069: Toolkit.getScreenInsets() doesn't update if insets change
anashaty
parents:
28235
diff
changeset
|
124 |
// the existing CGDisplayReconfigurationCallBack is not notified |
751f31639710
8072069: Toolkit.getScreenInsets() doesn't update if insets change
anashaty
parents:
28235
diff
changeset
|
125 |
// as well as the NSApplicationDidChangeScreenParametersNotification |
751f31639710
8072069: Toolkit.getScreenInsets() doesn't update if insets change
anashaty
parents:
28235
diff
changeset
|
126 |
// is fired on the Dock location changes only |
751f31639710
8072069: Toolkit.getScreenInsets() doesn't update if insets change
anashaty
parents:
28235
diff
changeset
|
127 |
return nativeGetScreenInsets(displayID); |
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
128 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
129 |
|
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
130 |
public int getScaleFactor() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
131 |
return scale; |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
132 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
133 |
|
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
134 |
public void invalidate(final int defaultDisplayID) { |
59175
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
135 |
//TODO do we need to restore the full-screen window/modes on old device? |
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
136 |
displayID = defaultDisplayID; |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
137 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
138 |
|
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
139 |
@Override |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
140 |
public void displayChanged() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
141 |
xResolution = nativeGetXResolution(displayID); |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
142 |
yResolution = nativeGetYResolution(displayID); |
52537
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
143 |
bounds = nativeGetBounds(displayID).getBounds(); //does integer rounding |
36900
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
144 |
initScaleFactor(); |
59175
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
145 |
resizeFSWindow(getFullScreenWindow(), bounds); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
146 |
//TODO configs? |
17151
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
147 |
} |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
148 |
|
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
149 |
@Override |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
150 |
public void paletteChanged() { |
9bfcf2a592fc
8009012: [macosx] DisplayChangedListener is not implemented in LWWindowPeer/CGraphicsEnvironment
serb
parents:
16840
diff
changeset
|
151 |
// devices do not need to react to this event. |
15989
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
152 |
} |
12047 | 153 |
|
154 |
/** |
|
155 |
* Enters full-screen mode, or returns to windowed mode. |
|
156 |
*/ |
|
157 |
@Override |
|
158 |
public synchronized void setFullScreenWindow(Window w) { |
|
159 |
Window old = getFullScreenWindow(); |
|
160 |
if (w == old) { |
|
161 |
return; |
|
162 |
} |
|
163 |
||
164 |
boolean fsSupported = isFullScreenSupported(); |
|
13241
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
165 |
|
12047 | 166 |
if (fsSupported && old != null) { |
21790
dae43c3c462d
8028512: [macosx] Crash in full screen api if incorrect display mode is used
serb
parents:
17151
diff
changeset
|
167 |
// enter windowed mode and restore original display mode |
dae43c3c462d
8028512: [macosx] Crash in full screen api if incorrect display mode is used
serb
parents:
17151
diff
changeset
|
168 |
exitFullScreenExclusive(old); |
13241
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
169 |
if (originalMode != null) { |
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
170 |
setDisplayMode(originalMode); |
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
171 |
originalMode = null; |
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
172 |
} |
12047 | 173 |
} |
174 |
||
175 |
super.setFullScreenWindow(w); |
|
176 |
||
177 |
if (fsSupported && w != null) { |
|
13241
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
178 |
if (isDisplayChangeSupported()) { |
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
179 |
originalMode = getDisplayMode(); |
92c2140b5bb2
7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7
alexsch
parents:
12836
diff
changeset
|
180 |
} |
12047 | 181 |
// enter fullscreen mode |
182 |
enterFullScreenExclusive(w); |
|
183 |
} |
|
184 |
} |
|
185 |
||
186 |
/** |
|
187 |
* Returns true if this GraphicsDevice supports |
|
188 |
* full-screen exclusive mode and false otherwise. |
|
189 |
*/ |
|
190 |
@Override |
|
191 |
public boolean isFullScreenSupported() { |
|
192 |
return isFSExclusiveModeAllowed(); |
|
193 |
} |
|
194 |
||
195 |
private static boolean isFSExclusiveModeAllowed() { |
|
196 |
SecurityManager security = System.getSecurityManager(); |
|
197 |
if (security != null) { |
|
198 |
if (fullScreenExclusivePermission == null) { |
|
199 |
fullScreenExclusivePermission = |
|
200 |
new AWTPermission("fullScreenExclusive"); |
|
201 |
} |
|
202 |
try { |
|
203 |
security.checkPermission(fullScreenExclusivePermission); |
|
204 |
} catch (SecurityException e) { |
|
205 |
return false; |
|
206 |
} |
|
207 |
} |
|
208 |
return true; |
|
209 |
} |
|
210 |
||
211 |
private static void enterFullScreenExclusive(Window w) { |
|
30469 | 212 |
FullScreenCapable peer = AWTAccessor.getComponentAccessor().getPeer(w); |
12047 | 213 |
if (peer != null) { |
214 |
peer.enterFullScreenMode(); |
|
215 |
} |
|
216 |
} |
|
217 |
||
218 |
private static void exitFullScreenExclusive(Window w) { |
|
30469 | 219 |
FullScreenCapable peer = AWTAccessor.getComponentAccessor().getPeer(w); |
12047 | 220 |
if (peer != null) { |
221 |
peer.exitFullScreenMode(); |
|
222 |
} |
|
223 |
} |
|
12836
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
224 |
|
59175
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
225 |
/** |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
226 |
* Reapplies the size of this device to the full-screen window. |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
227 |
*/ |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
228 |
private static void resizeFSWindow(final Window w, final Rectangle b) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
229 |
if (w != null) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
230 |
WindowPeer peer = AWTAccessor.getComponentAccessor().getPeer(w); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
231 |
if (peer != null) { |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
232 |
peer.setBounds(b.x, b.y, b.width, b.height, SET_BOUNDS); |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
233 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
234 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
235 |
} |
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
236 |
|
12836
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
237 |
@Override |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
238 |
public boolean isDisplayChangeSupported() { |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
239 |
return true; |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
240 |
} |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
241 |
|
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
242 |
@Override |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
14166
diff
changeset
|
243 |
public void setDisplayMode(final DisplayMode dm) { |
14161
2b346f8e3b8f
7175704: [macosx] "8" PIT: NPE in GetDisplayMode fullscreen test
kizune
parents:
13241
diff
changeset
|
244 |
if (dm == null) { |
2b346f8e3b8f
7175704: [macosx] "8" PIT: NPE in GetDisplayMode fullscreen test
kizune
parents:
13241
diff
changeset
|
245 |
throw new IllegalArgumentException("Invalid display mode"); |
2b346f8e3b8f
7175704: [macosx] "8" PIT: NPE in GetDisplayMode fullscreen test
kizune
parents:
13241
diff
changeset
|
246 |
} |
15331
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
14166
diff
changeset
|
247 |
if (!Objects.equals(dm, getDisplayMode())) { |
410070becfef
8003173: [macosx] Fullscreen on Mac leaves an empty rectangle
serb
parents:
14166
diff
changeset
|
248 |
nativeSetDisplayMode(displayID, dm.getWidth(), dm.getHeight(), |
59175
d2123a27cfe7
8232200: [macos 10.15] Windows in fullscreen tests jumps around the screen
serb
parents:
58599
diff
changeset
|
249 |
dm.getBitDepth(), dm.getRefreshRate()); |
12836
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
250 |
} |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
251 |
} |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
252 |
|
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
253 |
@Override |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
254 |
public DisplayMode getDisplayMode() { |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
255 |
return nativeGetDisplayMode(displayID); |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
256 |
} |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
257 |
|
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
258 |
@Override |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
259 |
public DisplayMode[] getDisplayModes() { |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
260 |
return nativeGetDisplayModes(displayID); |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
261 |
} |
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
262 |
|
36900
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
263 |
private void initScaleFactor() { |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
264 |
if (SunGraphicsEnvironment.isUIScaleEnabled()) { |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
265 |
double debugScale = SunGraphicsEnvironment.getDebugScale(); |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
266 |
scale = (int) (debugScale >= 1 |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
267 |
? Math.round(debugScale) |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
268 |
: nativeGetScaleFactor(displayID)); |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
269 |
} else { |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
270 |
scale = 1; |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
271 |
} |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
272 |
} |
3940219afc12
8150844: [hidpi] [macosx] -Dsun.java2d.uiScale should be taken into account for OS X
alexsch
parents:
30469
diff
changeset
|
273 |
|
16840
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
15989
diff
changeset
|
274 |
private static native double nativeGetScaleFactor(int displayID); |
64446d4710c4
8000629: [macosx] Blurry rendering with Java 7 on Retina display
serb
parents:
15989
diff
changeset
|
275 |
|
15989
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
276 |
private static native void nativeSetDisplayMode(int displayID, int w, int h, int bpp, int refrate); |
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
277 |
|
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
278 |
private static native DisplayMode nativeGetDisplayMode(int displayID); |
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
279 |
|
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
280 |
private static native DisplayMode[] nativeGetDisplayModes(int displayID); |
12836
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
281 |
|
15989
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
282 |
private static native double nativeGetXResolution(int displayID); |
12836
66cabfe1972f
7124247: [macosx] Implement GraphicsDevice.setDisplayMode()
kizune
parents:
12636
diff
changeset
|
283 |
|
15989
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
284 |
private static native double nativeGetYResolution(int displayID); |
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
285 |
|
0fe0985a7bde
8003169: [macosx] JVM crash after disconnecting from projector
serb
parents:
15988
diff
changeset
|
286 |
private static native Insets nativeGetScreenInsets(int displayID); |
52537
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
287 |
|
814c49afb1a7
8211992: GraphicsConfiguration.getDevice().getDisplayMode() causes JVM crash on Mac
serb
parents:
47216
diff
changeset
|
288 |
private static native Rectangle2D nativeGetBounds(int displayID); |
12047 | 289 |
} |