< prev index next >
src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 28,37 ****
--- 28,38 ----
import java.awt.peer.*;
import sun.awt.AWTAccessor;
import sun.awt.im.InputMethodManager;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
+ import sun.java2d.pipe.Region;
class WFramePeer extends WWindowPeer implements FramePeer {
static {
initIDs();
*** 67,78 ****
@Override
public void setMaximizedBounds(Rectangle b) {
if (b == null) {
clearMaximizedBounds();
} else {
! Rectangle adjBounds = (Rectangle)b.clone();
! adjustMaximizedBounds(adjBounds);
setMaximizedBounds(adjBounds.x, adjBounds.y, adjBounds.width, adjBounds.height);
}
}
/**
--- 68,78 ----
@Override
public void setMaximizedBounds(Rectangle b) {
if (b == null) {
clearMaximizedBounds();
} else {
! Rectangle adjBounds = adjustMaximizedBounds(b);
setMaximizedBounds(adjBounds.x, adjBounds.y, adjBounds.width, adjBounds.height);
}
}
/**
*** 84,115 ****
* compensate for differences between the primary monitor and the monitor
* that displays the window.
* The method translates the incoming bounds to the values acceptable
* by the window manager. For more details, please refer to 6699851.
*/
! private void adjustMaximizedBounds(Rectangle b) {
GraphicsConfiguration currentDevGC = getGraphicsConfiguration();
GraphicsDevice primaryDev = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
GraphicsConfiguration primaryDevGC = primaryDev.getDefaultConfiguration();
if (currentDevGC != null && currentDevGC != primaryDevGC) {
Rectangle currentDevBounds = currentDevGC.getBounds();
Rectangle primaryDevBounds = primaryDevGC.getBounds();
! boolean isCurrentDevLarger =
! ((currentDevBounds.width - primaryDevBounds.width > 0) ||
! (currentDevBounds.height - primaryDevBounds.height > 0));
!
! // the window manager doesn't seem to compensate for differences when
! // the primary monitor is larger than the monitor that display the window
! if (isCurrentDevLarger) {
! b.width -= (currentDevBounds.width - primaryDevBounds.width);
! b.height -= (currentDevBounds.height - primaryDevBounds.height);
}
}
}
@Override
public boolean updateGraphicsData(GraphicsConfiguration gc) {
boolean result = super.updateGraphicsData(gc);
--- 84,167 ----
* compensate for differences between the primary monitor and the monitor
* that displays the window.
* The method translates the incoming bounds to the values acceptable
* by the window manager. For more details, please refer to 6699851.
*/
! private Rectangle adjustMaximizedBounds(Rectangle b) {
GraphicsConfiguration currentDevGC = getGraphicsConfiguration();
GraphicsDevice primaryDev = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
GraphicsConfiguration primaryDevGC = primaryDev.getDefaultConfiguration();
if (currentDevGC != null && currentDevGC != primaryDevGC) {
+ double currScaleX = currentDevGC.getDefaultTransform().getScaleX();
+ double currScaleY = currentDevGC.getDefaultTransform().getScaleY();
+ double priScaleX = primaryDevGC.getDefaultTransform().getScaleX();
+ double priScaleY = primaryDevGC.getDefaultTransform().getScaleY();
Rectangle currentDevBounds = currentDevGC.getBounds();
Rectangle primaryDevBounds = primaryDevGC.getBounds();
! //scale the bounds for proper comparisions.
! currentDevBounds = scaleBounds(currentDevBounds, currScaleX, currScaleY);
! b = scaleBounds(b, currScaleX, currScaleY);
! Rectangle scaledPrimaryDevBounds = scaleBounds(primaryDevBounds, priScaleX, priScaleY);
!
! //due to floating point operations, it could be possible in some
! //scenarios, that the width and height are slightly larger
! //than the maximum permissible values.
! if (b.width > currentDevBounds.width) {
! b.width = currentDevBounds.width;
! }
!
! if (b.height > currentDevBounds.height) {
! b.height = currentDevBounds.height;
! }
!
! //To maximize a window onto secondary screen, we still need to
! //provide the primary screen coordinates, and set the width
! //and height equal to primary screen bounds.
! if (scaledPrimaryDevBounds.width < currentDevBounds.width &&
! b.width == currentDevBounds.width) {
! b.width = primaryDevBounds.width;
! }
!
! if (scaledPrimaryDevBounds.height < currentDevBounds.height &&
! b.height == currentDevBounds.height) {
! b.height = primaryDevBounds.height;
! }
!
! if (b.x == currentDevBounds.x) {
! b.x = primaryDevBounds.x;
! }
!
! if (b.y == currentDevBounds.y) {
! b.y = primaryDevBounds.y;
! }
!
! return b;
! } else {
! double priScaleX = primaryDevGC.getDefaultTransform().getScaleX();
! double priScaleY = primaryDevGC.getDefaultTransform().getScaleY();
! return scaleBounds(b, priScaleX, priScaleY);
! }
}
+
+ private Rectangle scaleBounds(Rectangle source, double scaleX, double scaleY) {
+ Rectangle res = (Rectangle)source.clone();
+
+ if (scaleX > 1.0) {
+ res.x = Region.clipScale(source.x, scaleX);
+ res.width = Region.clipScale(source.width, scaleX);
}
+
+ if (scaleY > 1.0) {
+ res.y = Region.clipScale(source.y, scaleY);
+ res.height = Region.clipScale(source.height, scaleY);
+ }
+
+ return res;
}
@Override
public boolean updateGraphicsData(GraphicsConfiguration gc) {
boolean result = super.updateGraphicsData(gc);
< prev index next >