Skip to content

Commit c124268

Browse files
author
duke
committed
Backport c6e041649514b964f5baaa88880c4d146275db8d
1 parent 6e37df1 commit c124268

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
import sun.java2d.opengl.WGLGraphicsConfig;
4848
import sun.java2d.windows.WindowsFlags;
4949

50+
import static java.awt.peer.ComponentPeer.SET_BOUNDS;
51+
5052
import static sun.awt.Win32GraphicsEnvironment.debugScaleX;
5153
import static sun.awt.Win32GraphicsEnvironment.debugScaleY;
5254

@@ -443,6 +445,21 @@ public synchronized void setFullScreenWindow(Window w) {
443445
protected native void enterFullScreenExclusive(int screen, WindowPeer w);
444446
protected native void exitFullScreenExclusive(int screen, WindowPeer w);
445447

448+
/**
449+
* Reapplies the size of this graphics device to
450+
* the given full-screen window.
451+
* @param w a Window that needs resizing
452+
* @param b new full-screen window bounds
453+
*/
454+
private static void resizeFSWindow(final Window w, final Rectangle b) {
455+
if (w != null) {
456+
WindowPeer peer = AWTAccessor.getComponentAccessor().getPeer(w);
457+
if (peer != null) {
458+
peer.setBounds(b.x, b.y, b.width, b.height, SET_BOUNDS);
459+
}
460+
}
461+
}
462+
446463
@Override
447464
public boolean isDisplayChangeSupported() {
448465
return (isFullScreenSupported() && getFullScreenWindow() != null);
@@ -465,13 +482,9 @@ public synchronized void setDisplayMode(DisplayMode dm) {
465482
WWindowPeer peer = AWTAccessor.getComponentAccessor().getPeer(w);
466483
configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
467484
dm.getBitDepth(), dm.getRefreshRate());
468-
// resize the fullscreen window to the dimensions of the new
469-
// display mode
470-
Rectangle screenBounds = getDefaultConfiguration().getBounds();
471-
w.setBounds(screenBounds.x, screenBounds.y,
472-
screenBounds.width, screenBounds.height);
473-
// Note: no call to replaceSurfaceData is required here since
474-
// replacement will be caused by an upcoming display change event
485+
// Note: the full-screen window will get resized to the dimensions of the new
486+
// display mode in the upcoming display change event, when the DPI scales
487+
// would already be correctly set etc.
475488
} else {
476489
throw new IllegalStateException("Must be in fullscreen mode " +
477490
"in order to set display mode");
@@ -531,6 +544,10 @@ public void displayChanged() {
531544
defaultConfig = null;
532545
configs = null;
533546
initScaleFactors();
547+
548+
Rectangle screenBounds = getDefaultConfiguration().getBounds();
549+
resizeFSWindow(getFullScreenWindow(), screenBounds);
550+
534551
// pass on to all top-level windows on this display
535552
topLevels.notifyListeners();
536553
}

test/jdk/java/awt/FullScreen/FullscreenWindowProps/FullscreenWindowProps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
/**
3434
* @test
35-
* @bug 8211999
35+
* @bug 8211999 8282863
3636
* @key headful
3737
* @summary verifies the full-screen window bounds and graphics configuration
3838
*/

0 commit comments

Comments
 (0)