mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-14 20:41:43 +01:00
Compare commits
3 Commits
mono/2.303
...
1982
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ce8fafc69 | ||
|
|
bc6ee1d8f4 | ||
|
|
624c5cc0d8 |
@@ -43,6 +43,9 @@ import sun.awt.SunToolkit;
|
||||
import sun.awt.image.SunWritableRaster;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
|
||||
import static sun.java2d.SunGraphicsEnvironment.toDeviceSpace;
|
||||
import static sun.java2d.SunGraphicsEnvironment.toDeviceSpaceAbs;
|
||||
|
||||
/**
|
||||
* This class is used to generate native system input events
|
||||
* for the purposes of test automation, self-running demos, and
|
||||
@@ -377,13 +380,9 @@ public class Robot {
|
||||
*/
|
||||
public synchronized Color getPixelColor(int x, int y) {
|
||||
checkScreenCaptureAllowed();
|
||||
AffineTransform tx = GraphicsEnvironment.
|
||||
getLocalGraphicsEnvironment().getDefaultScreenDevice().
|
||||
getDefaultConfiguration().getDefaultTransform();
|
||||
x = (int) (x * tx.getScaleX());
|
||||
y = (int) (y * tx.getScaleY());
|
||||
Color color = new Color(peer.getRGBPixel(x, y));
|
||||
return color;
|
||||
Point point = peer.useAbsoluteCoordinates() ? toDeviceSpaceAbs(x, y)
|
||||
: toDeviceSpace(x, y);
|
||||
return new Color(peer.getRGBPixel(point.x, point.y));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -516,16 +515,17 @@ public class Robot {
|
||||
|
||||
} else {
|
||||
|
||||
int sX = (int) Math.floor(screenRect.x * uiScaleX);
|
||||
int sY = (int) Math.floor(screenRect.y * uiScaleY);
|
||||
int sWidth = (int) Math.ceil(screenRect.width * uiScaleX);
|
||||
int sHeight = (int) Math.ceil(screenRect.height * uiScaleY);
|
||||
int temppixels[];
|
||||
Rectangle scaledRect = new Rectangle(sX, sY, sWidth, sHeight);
|
||||
temppixels = peer.getRGBPixels(scaledRect);
|
||||
Rectangle scaledRect;
|
||||
if (peer.useAbsoluteCoordinates()) {
|
||||
scaledRect = toDeviceSpaceAbs(gc, screenRect.x,
|
||||
screenRect.y, screenRect.width, screenRect.height);
|
||||
} else {
|
||||
scaledRect = toDeviceSpace(gc, screenRect.x,
|
||||
screenRect.y, screenRect.width, screenRect.height);
|
||||
}
|
||||
|
||||
// HighResolutionImage
|
||||
pixels = temppixels;
|
||||
pixels = peer.getRGBPixels(scaledRect);
|
||||
buffer = new DataBufferInt(pixels, pixels.length);
|
||||
raster = Raster.createPackedRaster(buffer, scaledRect.width,
|
||||
scaledRect.height, scaledRect.width, bandmasks, null);
|
||||
|
||||
@@ -117,4 +117,14 @@ public interface RobotPeer
|
||||
* @see Robot#createScreenCapture(Rectangle)
|
||||
*/
|
||||
int[] getRGBPixels(Rectangle bounds);
|
||||
|
||||
/**
|
||||
* Determines if absolute coordinates should be used by this peer.
|
||||
*
|
||||
* @return {@code true} if absolute coordinates should be used,
|
||||
* {@code false} otherwise
|
||||
*/
|
||||
default boolean useAbsoluteCoordinates() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package sun.java2d;
|
||||
|
||||
import java.awt.AWTError;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
@@ -452,54 +453,125 @@ public abstract class SunGraphicsEnvironment extends GraphicsEnvironment
|
||||
return current;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bounds of the graphics configuration in device space.
|
||||
*
|
||||
* @param config the graphics configuration which bounds are requested
|
||||
* @return the bounds of the area covered by this
|
||||
* {@code GraphicsConfiguration} in device space (pixels)
|
||||
*/
|
||||
public static Rectangle getGCDeviceBounds(GraphicsConfiguration config) {
|
||||
AffineTransform tx = config.getDefaultTransform();
|
||||
Rectangle bounds = config.getBounds();
|
||||
bounds.width *= tx.getScaleX();
|
||||
bounds.height *= tx.getScaleY();
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the size (w, h) from the device space to the user's space using
|
||||
* passed graphics configuration.
|
||||
*
|
||||
* @param gc the graphics configuration to be used for transformation
|
||||
* @param w the width in the device space
|
||||
* @param h the height in the device space
|
||||
* @return the size in the user's space
|
||||
*/
|
||||
public static Dimension toUserSpace(GraphicsConfiguration gc,
|
||||
int w, int h) {
|
||||
AffineTransform tx = gc.getDefaultTransform();
|
||||
return new Dimension(
|
||||
Region.clipRound(w / tx.getScaleX()),
|
||||
Region.clipRound(h / tx.getScaleY())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts absolute coordinates from the user's space to the device space
|
||||
* using appropriate device transformation.
|
||||
*
|
||||
* @param x absolute coordinate in the user's space
|
||||
* @param y absolute coordinate in the user's space
|
||||
* @return the point which uses device space (pixels)
|
||||
*/
|
||||
public static Point toDeviceSpaceAbs(int x, int y) {
|
||||
GraphicsConfiguration gc = getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
gc = getGraphicsConfigurationAtPoint(gc, x, y);
|
||||
return toDeviceSpaceAbs(gc, x, y, 0, 0).getLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the rectangle from the user's space to the device space using
|
||||
* appropriate device transformation.
|
||||
*
|
||||
* @param rect the rectangle in the user's space
|
||||
* @return the rectangle which uses device space (pixels)
|
||||
*/
|
||||
public static Rectangle toDeviceSpaceAbs(Rectangle rect) {
|
||||
GraphicsConfiguration gc = getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
gc = getGraphicsConfigurationAtPoint(gc, rect.x, rect.y);
|
||||
return toDeviceSpaceAbs(gc, rect.x, rect.y, rect.width, rect.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts absolute coordinates (x, y) and the size (w, h) from the user's
|
||||
* space to the device space using passed graphics configuration.
|
||||
*
|
||||
* @param gc the graphics configuration to be used for transformation
|
||||
* @param x absolute coordinate in the user's space
|
||||
* @param y absolute coordinate in the user's space
|
||||
* @param w the width in the user's space
|
||||
* @param h the height in the user's space
|
||||
* @return the rectangle which uses device space (pixels)
|
||||
*/
|
||||
public static Rectangle toDeviceSpaceAbs(GraphicsConfiguration gc,
|
||||
int x, int y, int w, int h) {
|
||||
AffineTransform tx = gc.getDefaultTransform();
|
||||
Rectangle screen = gc.getBounds();
|
||||
return new Rectangle(
|
||||
screen.x + Region.clipRound((x - screen.x) * tx.getScaleX()),
|
||||
screen.y + Region.clipRound((y - screen.y) * tx.getScaleY()),
|
||||
Region.clipRound(w * tx.getScaleX()),
|
||||
Region.clipRound(h * tx.getScaleY())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts coordinates from the user's space to the device space using
|
||||
* appropriate device transformation.
|
||||
*
|
||||
* @param x coordinate in the user space
|
||||
* @param y coordinate in the user space
|
||||
* @return the point which uses device space(pixels)
|
||||
* @param x coordinate in the user's space
|
||||
* @param y coordinate in the user's space
|
||||
* @return the point which uses device space (pixels)
|
||||
*/
|
||||
public static Point convertToDeviceSpace(double x, double y) {
|
||||
GraphicsConfiguration gc = getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
gc = getGraphicsConfigurationAtPoint(gc, x, y);
|
||||
|
||||
AffineTransform tx = gc.getDefaultTransform();
|
||||
x = Region.clipRound(x * tx.getScaleX());
|
||||
y = Region.clipRound(y * tx.getScaleY());
|
||||
return new Point((int) x, (int) y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts bounds from the user's space to the device space using
|
||||
* appropriate device transformation.
|
||||
*
|
||||
* @param bounds the rectangle in the user space
|
||||
* @return the rectangle which uses device space(pixels)
|
||||
*/
|
||||
public static Rectangle convertToDeviceSpace(Rectangle bounds) {
|
||||
public static Point toDeviceSpace(int x, int y) {
|
||||
GraphicsConfiguration gc = getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||
gc = getGraphicsConfigurationAtPoint(gc, bounds.x, bounds.y);
|
||||
return convertToDeviceSpace(gc, bounds);
|
||||
gc = getGraphicsConfigurationAtPoint(gc, x, y);
|
||||
return toDeviceSpace(gc, x, y, 0, 0).getLocation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts bounds from the user's space to the device space using
|
||||
* appropriate device transformation of the passed graphics configuration.
|
||||
* Converts coordinates (x, y) and the size (w, h) from the user's
|
||||
* space to the device space using passed graphics configuration.
|
||||
*
|
||||
* @param bounds the rectangle in the user space
|
||||
* @return the rectangle which uses device space(pixels)
|
||||
* @param gc the graphics configuration to be used for transformation
|
||||
* @param x coordinate in the user's space
|
||||
* @param y coordinate in the user's space
|
||||
* @param w the width in the user's space
|
||||
* @param h the height in the user's space
|
||||
* @return the rectangle which uses device space (pixels)
|
||||
*/
|
||||
public static Rectangle convertToDeviceSpace(GraphicsConfiguration gc,
|
||||
Rectangle bounds) {
|
||||
public static Rectangle toDeviceSpace(GraphicsConfiguration gc,
|
||||
int x, int y, int w, int h) {
|
||||
AffineTransform tx = gc.getDefaultTransform();
|
||||
return new Rectangle(
|
||||
Region.clipRound(bounds.x * tx.getScaleX()),
|
||||
Region.clipRound(bounds.y * tx.getScaleY()),
|
||||
Region.clipRound(bounds.width * tx.getScaleX()),
|
||||
Region.clipRound(bounds.height * tx.getScaleY())
|
||||
Region.clipRound(x * tx.getScaleX()),
|
||||
Region.clipRound(y * tx.getScaleY()),
|
||||
Region.clipRound(w * tx.getScaleX()),
|
||||
Region.clipRound(h * tx.getScaleY())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ public class Win32GraphicsDevice extends GraphicsDevice implements
|
||||
// display mode
|
||||
Rectangle screenBounds = getDefaultConfiguration().getBounds();
|
||||
w.setBounds(screenBounds.x, screenBounds.y,
|
||||
dm.getWidth(), dm.getHeight());
|
||||
screenBounds.width, screenBounds.height);
|
||||
// Note: no call to replaceSurfaceData is required here since
|
||||
// replacement will be caused by an upcoming display change event
|
||||
} else {
|
||||
|
||||
@@ -520,7 +520,11 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
|
||||
@Override
|
||||
public boolean updateGraphicsData(GraphicsConfiguration gc) {
|
||||
var old = getGraphicsConfiguration().getDefaultTransform();
|
||||
winGraphicsConfig = (Win32GraphicsConfig)gc;
|
||||
if (gc != null && !old.equals(gc.getDefaultTransform())) {
|
||||
syncBounds(); // the bounds of the peer depend on the DPI
|
||||
}
|
||||
try {
|
||||
replaceSurfaceData();
|
||||
} catch (InvalidPipeException e) {
|
||||
@@ -529,6 +533,15 @@ public abstract class WComponentPeer extends WObjectPeer
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure that the native peer's coordinates are in sync with the target.
|
||||
*/
|
||||
void syncBounds() {
|
||||
Rectangle r = ((Component) target).getBounds();
|
||||
setBounds(r.x, r.y, r.width, r.height, SET_BOUNDS);
|
||||
}
|
||||
|
||||
|
||||
//This will return null for Components not yet added to a Container
|
||||
@Override
|
||||
public ColorModel getColorModel() {
|
||||
|
||||
@@ -36,6 +36,8 @@ import java.awt.peer.DialogPeer;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.im.InputMethodManager;
|
||||
|
||||
import static sun.java2d.SunGraphicsEnvironment.toUserSpace;
|
||||
|
||||
final class WDialogPeer extends WWindowPeer implements DialogPeer {
|
||||
// Toolkit & peer internals
|
||||
|
||||
@@ -117,8 +119,8 @@ final class WDialogPeer extends WWindowPeer implements DialogPeer {
|
||||
if (((Dialog)target).isUndecorated()) {
|
||||
return super.getMinimumSize();
|
||||
}
|
||||
return new Dimension(scaleDownX(getSysMinWidth()),
|
||||
scaleDownY(getSysMinHeight()));
|
||||
return toUserSpace(getGraphicsConfiguration(),
|
||||
getSysMinWidth(), getSysMinHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,9 @@ import sun.awt.SunToolkit;
|
||||
import sun.awt.im.InputMethodManager;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
import static sun.java2d.SunGraphicsEnvironment.convertToDeviceSpace;
|
||||
import static sun.java2d.SunGraphicsEnvironment.getGCDeviceBounds;
|
||||
import static sun.java2d.SunGraphicsEnvironment.toDeviceSpaceAbs;
|
||||
import static sun.java2d.SunGraphicsEnvironment.toUserSpace;
|
||||
|
||||
class WFramePeer extends WWindowPeer implements FramePeer {
|
||||
|
||||
@@ -98,10 +100,10 @@ class WFramePeer extends WWindowPeer implements FramePeer {
|
||||
*/
|
||||
private Rectangle adjustMaximizedBounds(Rectangle bounds) {
|
||||
// All calculations should be done in the device space
|
||||
bounds = convertToDeviceSpace(bounds);
|
||||
bounds = toDeviceSpaceAbs(bounds);
|
||||
|
||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||
Rectangle currentDevBounds = convertToDeviceSpace(gc, gc.getBounds());
|
||||
Rectangle currentDevBounds = getGCDeviceBounds(gc);
|
||||
// Prepare data for WM_GETMINMAXINFO message.
|
||||
// ptMaxPosition should be in coordinate system of the current monitor,
|
||||
// not the main monitor, or monitor on which we maximize the window.
|
||||
@@ -126,16 +128,6 @@ class WFramePeer extends WWindowPeer implements FramePeer {
|
||||
public void displayChanged() {
|
||||
super.displayChanged();
|
||||
SunToolkit.executeOnEventHandlerThread(target, this::updateIcon);
|
||||
if (!screenChangedFlag &&
|
||||
(getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 &&
|
||||
(getExtendedState() & Frame.ICONIFIED) == 0) {
|
||||
// A workaround to update the maximized state of the frame
|
||||
SunToolkit.executeOnEventHandlerThread(target, ()->{
|
||||
int state = getExtendedState();
|
||||
setState(Frame.NORMAL);
|
||||
setState(state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private native void updateIcon();
|
||||
@@ -167,13 +159,13 @@ class WFramePeer extends WWindowPeer implements FramePeer {
|
||||
|
||||
@Override
|
||||
public final Dimension getMinimumSize() {
|
||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||
Dimension d = new Dimension();
|
||||
if (!((Frame)target).isUndecorated()) {
|
||||
d.setSize(scaleDownX(getSysMinWidth()),
|
||||
scaleDownY(getSysMinHeight()));
|
||||
d.setSize(toUserSpace(gc, getSysMinWidth(), getSysMinHeight()));
|
||||
}
|
||||
if (((Frame)target).getMenuBar() != null) {
|
||||
d.height += scaleDownY(getSysMenuHeight());
|
||||
d.height += toUserSpace(gc, 0, getSysMenuHeight()).height;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.peer.RobotPeer;
|
||||
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
import static sun.java2d.SunGraphicsEnvironment.toDeviceSpaceAbs;
|
||||
|
||||
final class WRobotPeer implements RobotPeer {
|
||||
|
||||
@@ -40,7 +40,7 @@ final class WRobotPeer implements RobotPeer {
|
||||
public native void mouseMoveImpl(int x, int y);
|
||||
@Override
|
||||
public void mouseMove(int x, int y) {
|
||||
Point point = SunGraphicsEnvironment.convertToDeviceSpace(x, y);
|
||||
Point point = toDeviceSpaceAbs(x, y);
|
||||
mouseMoveImpl(point.x, point.y);
|
||||
}
|
||||
@Override
|
||||
@@ -61,6 +61,11 @@ final class WRobotPeer implements RobotPeer {
|
||||
return getRGBPixels(new Rectangle(x, y, 1, 1))[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAbsoluteCoordinates() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int [] getRGBPixels(Rectangle bounds) {
|
||||
int pixelArray[] = new int[bounds.width*bounds.height];
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.IllegalComponentStateException;
|
||||
import java.awt.Image;
|
||||
import java.awt.Insets;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
@@ -75,6 +74,8 @@ import sun.java2d.pipe.Region;
|
||||
import sun.java2d.SunGraphics2D;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import static sun.java2d.SunGraphicsEnvironment.toUserSpace;
|
||||
|
||||
public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
DisplayChangedListener
|
||||
{
|
||||
@@ -90,9 +91,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
|
||||
private TranslucentWindowPainter painter;
|
||||
|
||||
private int screenNum = 0;
|
||||
protected boolean screenChangedFlag;
|
||||
|
||||
/*
|
||||
* A key used for storing a list of active windows in AppContext. The value
|
||||
* is a list of windows, sorted by the time of activation: later a window is
|
||||
@@ -121,8 +119,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
private WindowListener windowListener;
|
||||
private MouseMotionListener mouseMotionListener;
|
||||
private MouseListener mouseListener;
|
||||
private float scaleX;
|
||||
private float scaleY;
|
||||
|
||||
private Insets sysInsets; // set from native updateInsets
|
||||
|
||||
@@ -216,13 +212,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
super(target);
|
||||
// update GC based on the current bounds
|
||||
updateGC();
|
||||
try {
|
||||
screenNum = getScreenImOn();
|
||||
} catch (IllegalComponentStateException e) {
|
||||
if (log.isLoggable(PlatformLogger.Level.WARNING)) {
|
||||
log.warning(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,8 +236,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||
Win32GraphicsDevice gd = (Win32GraphicsDevice) gc.getDevice();
|
||||
gd.addDisplayChangedListener(this);
|
||||
scaleX = gd.getDefaultScaleX();
|
||||
scaleY = gd.getDefaultScaleY();
|
||||
|
||||
initActiveWindowsTracking((Window)target);
|
||||
|
||||
@@ -335,6 +322,12 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final void syncBounds() {
|
||||
// Windows will take care of the top-level window/frame/dialog, and
|
||||
// update the location/size when DPI changes.
|
||||
}
|
||||
|
||||
// Synchronize the insets members (here & in helper) with actual window
|
||||
// state.
|
||||
native void updateInsets(Insets i);
|
||||
@@ -516,9 +509,10 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
minimumSize = ((Component)target).getMinimumSize();
|
||||
}
|
||||
if (minimumSize != null) {
|
||||
int w = Math.max(minimumSize.width, scaleDownX(getSysMinWidth()));
|
||||
int h = Math.max(minimumSize.height, scaleDownY(getSysMinHeight()));
|
||||
setMinSize(w, h);
|
||||
Dimension sysMin = toUserSpace(getGraphicsConfiguration(),
|
||||
getSysMinWidth(), getSysMinHeight());
|
||||
setMinSize(Math.max(minimumSize.width, sysMin.width),
|
||||
Math.max(minimumSize.height, sysMin.height));
|
||||
} else {
|
||||
setMinSize(0, 0);
|
||||
}
|
||||
@@ -676,23 +670,8 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
|
||||
AWTAccessor.getComponentAccessor().
|
||||
setGraphicsConfiguration((Component)target, winGraphicsConfig);
|
||||
|
||||
// checkDPIChange(oldDev, newDev);
|
||||
}
|
||||
|
||||
/*private void checkDPIChange(Win32GraphicsDevice oldDev,
|
||||
Win32GraphicsDevice newDev) {
|
||||
float newScaleX = newDev.getDefaultScaleX();
|
||||
float newScaleY = newDev.getDefaultScaleY();
|
||||
|
||||
if (scaleX != newScaleX || scaleY != newScaleY) {
|
||||
windowDPIChange(oldDev.getScreen(), scaleX, scaleY,
|
||||
newDev.getScreen(), newScaleX, newScaleY);
|
||||
scaleX = newScaleX;
|
||||
scaleY = newScaleY;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* From the DisplayChangedListener interface.
|
||||
*
|
||||
@@ -706,17 +685,9 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
*/
|
||||
@Override
|
||||
public void displayChanged() {
|
||||
int scrn = getScreenImOn();
|
||||
screenChangedFlag = scrn != screenNum;
|
||||
screenNum = scrn;
|
||||
SunToolkit.executeOnEventHandlerThread(target, ()->{
|
||||
updateGC();
|
||||
adjustBoundsOnDPIChange();
|
||||
});
|
||||
SunToolkit.executeOnEventHandlerThread(target, this::updateGC);
|
||||
}
|
||||
|
||||
private native void adjustBoundsOnDPIChange();
|
||||
|
||||
/**
|
||||
* Part of the DisplayChangedListener interface: components
|
||||
* do not need to react to this event
|
||||
@@ -752,78 +723,9 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
return true;
|
||||
}
|
||||
|
||||
// These are the peer bounds. They get updated at:
|
||||
// 1. the WWindowPeer.setBounds() method.
|
||||
// 2. the native code (on WM_SIZE/WM_MOVE)
|
||||
private volatile int sysX = 0;
|
||||
private volatile int sysY = 0;
|
||||
private volatile int sysW = 0;
|
||||
private volatile int sysH = 0;
|
||||
|
||||
@Override
|
||||
public native void repositionSecurityWarning();
|
||||
|
||||
@Override
|
||||
public void setBounds(int x, int y, int width, int height, int op) {
|
||||
sysX = x;
|
||||
sysY = y;
|
||||
sysW = width;
|
||||
sysH = height;
|
||||
|
||||
/* [tav] JDK-8176097 fixed by JRE-119
|
||||
int cx = x + width / 2;
|
||||
int cy = y + height / 2;
|
||||
GraphicsConfiguration current = getGraphicsConfiguration();
|
||||
GraphicsConfiguration other = SunGraphicsEnvironment
|
||||
.getGraphicsConfigurationAtPoint(current, cx, cy);
|
||||
if (!current.equals(other)) {
|
||||
AffineTransform tx = other.getDefaultTransform();
|
||||
double otherScaleX = tx.getScaleX();
|
||||
double otherScaleY = tx.getScaleY();
|
||||
initScales();
|
||||
if (scaleX != otherScaleX || scaleY != otherScaleY) {
|
||||
x = (int) Math.floor(x * otherScaleX / scaleX);
|
||||
y = (int) Math.floor(y * otherScaleY / scaleY);
|
||||
}
|
||||
}*/
|
||||
|
||||
super.setBounds(x, y, width, height, op);
|
||||
}
|
||||
|
||||
private void initScales() {
|
||||
|
||||
if (scaleX >= 1 && scaleY >= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
GraphicsConfiguration gc = getGraphicsConfiguration();
|
||||
if (gc instanceof Win32GraphicsConfig) {
|
||||
Win32GraphicsDevice gd = ((Win32GraphicsConfig) gc).getDevice();
|
||||
scaleX = gd.getDefaultScaleX();
|
||||
scaleY = gd.getDefaultScaleY();
|
||||
} else {
|
||||
AffineTransform tx = gc.getDefaultTransform();
|
||||
scaleX = (float) tx.getScaleX();
|
||||
scaleY = (float) tx.getScaleY();
|
||||
}
|
||||
}
|
||||
|
||||
final int scaleUpX(int x) {
|
||||
return Region.clipRound(x * scaleX);
|
||||
}
|
||||
|
||||
final int scaleUpY(int y) {
|
||||
return Region.clipRound(y * scaleY);
|
||||
}
|
||||
|
||||
final int scaleDownX(int x) {
|
||||
return Region.clipRound(x / scaleX);
|
||||
}
|
||||
|
||||
final int scaleDownY(int y) {
|
||||
return Region.clipRound(y / scaleY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(Graphics g) {
|
||||
// We assume we print the whole frame,
|
||||
@@ -992,9 +894,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
}
|
||||
}
|
||||
|
||||
/*native void windowDPIChange(int prevScreen, float prevScaleX, float prevScaleY,
|
||||
int newScreen, float newScaleX, float newScaleY);*/
|
||||
|
||||
/*
|
||||
* The method maps the list of the active windows to the window's AppContext,
|
||||
* then the method registers ActiveWindowListener, GuiDisposedListener listeners;
|
||||
|
||||
@@ -86,7 +86,6 @@ Java_sun_awt_windows_WMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls,
|
||||
POINT pt;
|
||||
|
||||
VERIFY(::GetCursorPos(&pt));
|
||||
AwtWin32GraphicsDevice::ScaleDownDPoint(&pt);
|
||||
if (pointClass == NULL) {
|
||||
jclass pointClassLocal = env->FindClass("java/awt/Point");
|
||||
DASSERT(pointClassLocal != NULL);
|
||||
@@ -107,6 +106,9 @@ Java_sun_awt_windows_WMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls,
|
||||
yID = env->GetFieldID(pointClass, "y", "I");
|
||||
CHECK_NULL_RETURN(yID, (jint)0);
|
||||
|
||||
pt.x = (device == NULL) ? pt.x : device->ScaleDownAbsX(pt.x);
|
||||
pt.y = (device == NULL) ? pt.y : device->ScaleDownAbsY(pt.y);
|
||||
|
||||
env->SetIntField(point, xID, pt.x);
|
||||
env->SetIntField(point, yID, pt.y);
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "awt_Toolkit.h"
|
||||
#include "awt_Window.h"
|
||||
#include "awt_Win32GraphicsDevice.h"
|
||||
#include "awt_Win32GraphicsConfig.h"
|
||||
#include "Hashtable.h"
|
||||
#include "ComCtl32Util.h"
|
||||
|
||||
@@ -598,7 +597,7 @@ AwtComponent::CreateHWnd(JNIEnv *env, LPCWSTR title,
|
||||
/*
|
||||
* Fix for 4046446.
|
||||
*/
|
||||
SetWindowPos(GetHWnd(), 0, x, y, w, h, SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOACTIVATE);
|
||||
Reshape(x, y, w, h);
|
||||
|
||||
/* Set default colors. */
|
||||
m_colorForeground = colorForeground;
|
||||
@@ -964,11 +963,11 @@ AwtComponent::SetWindowPos(HWND wnd, HWND after,
|
||||
}
|
||||
|
||||
void AwtComponent::Reshape(int x, int y, int w, int h) {
|
||||
/* ReshapeNoScale(ScaleUpX(x), ScaleUpY(y), ScaleUpX(w), ScaleUpY(h));
|
||||
ReshapeNoScale(ScaleUpX(x), ScaleUpY(y), ScaleUpX(w), ScaleUpY(h));
|
||||
}
|
||||
|
||||
void AwtComponent::ReshapeNoScale(int x, int y, int w, int h)
|
||||
{*/
|
||||
{
|
||||
#if defined(DEBUG)
|
||||
RECT rc;
|
||||
::GetWindowRect(GetHWnd(), &rc);
|
||||
@@ -976,57 +975,9 @@ void AwtComponent::ReshapeNoScale(int x, int y, int w, int h)
|
||||
DTRACE_PRINTLN4("AwtComponent::Reshape from %d, %d, %d, %d", rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
|
||||
#endif
|
||||
|
||||
int usrX = x;
|
||||
int usrY = y;
|
||||
|
||||
AwtWin32GraphicsDevice* device = UGetDeviceByBounds(URectBounds(x, y, w, h, USER_SPACE), this);
|
||||
x = device->ScaleUpX(x);
|
||||
y = device->ScaleUpY(y);
|
||||
w = device->ScaleUpX(w);
|
||||
h = device->ScaleUpY(h);
|
||||
|
||||
AwtWindow* container = GetContainer();
|
||||
AwtComponent* parent = GetParent();
|
||||
|
||||
// [tav] Handle the fact that an owned window is most likely positioned relative to its owner, and it may
|
||||
// require pixel-perfect alignment. For that, compensate rounding errors (caused by converting from the device
|
||||
// space to the integer user space and back) for the owner's origin and for the owner's client area origin.
|
||||
if (IsTopLevel() && parent != NULL &&
|
||||
(device->GetScaleX() > 1 || device->GetScaleY() > 1))
|
||||
{
|
||||
RECT parentInsets;
|
||||
parent->GetInsets(&parentInsets);
|
||||
// Convert the owner's client area origin to user space
|
||||
int parentInsetsUsrX = device->ScaleDownX(parentInsets.left);
|
||||
int parentInsetsUsrY = device->ScaleDownY(parentInsets.top);
|
||||
|
||||
RECT parentRect;
|
||||
VERIFY(::GetWindowRect(parent->GetHWnd(), &parentRect));
|
||||
// Convert the owner's origin to user space
|
||||
int parentUsrX = device->ScaleDownX(parentRect.left);
|
||||
int parentUsrY = device->ScaleDownY(parentRect.top);
|
||||
|
||||
// Calc the offset from the owner's client area in user space
|
||||
int offsetUsrX = usrX - parentUsrX - parentInsetsUsrX;
|
||||
int offsetUsrY = usrY - parentUsrY - parentInsetsUsrY;
|
||||
|
||||
// Convert the offset to device space
|
||||
int offsetDevX = device->ScaleUpX(offsetUsrX);
|
||||
int offsetDevY = device->ScaleUpY(offsetUsrY);
|
||||
|
||||
// Finally calc the window's location based on the frame's and its insets system numbers.
|
||||
int devX = parentRect.left + parentInsets.left + offsetDevX;
|
||||
int devY = parentRect.top + parentInsets.top + offsetDevY;
|
||||
|
||||
// Check the toplevel is not going to be moved to another screen.
|
||||
::SetRect(&parentRect, devX, devY, devX + w, devY + h);
|
||||
HMONITOR hmon = ::MonitorFromRect(&parentRect, MONITOR_DEFAULTTONEAREST);
|
||||
if (hmon != NULL && AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hmon) == device->GetDeviceIndex()) {
|
||||
x = devX;
|
||||
y = devY;
|
||||
}
|
||||
}
|
||||
|
||||
if (container != NULL && container == parent) {
|
||||
container->SubtractInsetPoint(x, y);
|
||||
}
|
||||
@@ -1133,6 +1084,7 @@ void SpyWinMessage(HWND hwnd, UINT message, LPCTSTR szComment) {
|
||||
WIN_MSG(WM_DESTROY)
|
||||
WIN_MSG(WM_MOVE)
|
||||
WIN_MSG(WM_SIZE)
|
||||
WIN_MSG(WM_DPICHANGED)
|
||||
WIN_MSG(WM_ACTIVATE)
|
||||
WIN_MSG(WM_SETFOCUS)
|
||||
WIN_MSG(WM_KILLFOCUS)
|
||||
@@ -1571,9 +1523,9 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_SIZE:
|
||||
{
|
||||
RECT r;
|
||||
// fix 4128317 : use GetClientRect for full 32-bit int precision and
|
||||
// fix 4128317 : use GetWindowRect for full 32-bit int precision and
|
||||
// to avoid negative client area dimensions overflowing 16-bit params - robi
|
||||
::GetClientRect( GetHWnd(), &r );
|
||||
::GetWindowRect(GetHWnd(), &r);
|
||||
mr = WmSize(static_cast<UINT>(wParam), r.right - r.left, r.bottom - r.top);
|
||||
//mr = WmSize(wParam, LOWORD(lParam), HIWORD(lParam));
|
||||
SetCompositionWindow(r);
|
||||
@@ -1590,11 +1542,9 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
break;
|
||||
case WM_ENTERSIZEMOVE:
|
||||
m_inMoveResizeLoop = TRUE;
|
||||
mr = WmEnterSizeMove();
|
||||
break;
|
||||
case WM_EXITSIZEMOVE:
|
||||
m_inMoveResizeLoop = FALSE;
|
||||
mr = WmExitSizeMove();
|
||||
break;
|
||||
// Bug #4039858 (Selecting menu item causes bogus mouse click event)
|
||||
@@ -2015,10 +1965,6 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
mr = WmContextMenu((HWND)wParam,
|
||||
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
break;
|
||||
#define WM_DPICHANGED 0x02E0 // Since Win 8.1 in WinUser.h
|
||||
case WM_DPICHANGED:
|
||||
mr = WmDPIChanged(HIWORD(wParam), LOWORD(wParam), (RECT*)lParam);
|
||||
break;
|
||||
|
||||
/*
|
||||
* These messages are used to route Win32 calls to the
|
||||
@@ -4057,8 +4003,8 @@ void AwtComponent::OpenCandidateWindow(int x, int y)
|
||||
}
|
||||
HWND hTop = GetTopLevelParentForWindow(hWnd);
|
||||
::ClientToScreen(hTop, &p);
|
||||
int sx = ScaleUpX(x, ABSOLUTE_COORD) - p.x;
|
||||
int sy = ScaleUpY(y, ABSOLUTE_COORD) - p.y;
|
||||
int sx = ScaleUpAbsX(x) - p.x;
|
||||
int sy = ScaleUpAbsY(y) - p.y;
|
||||
if (!m_bitsCandType) {
|
||||
SetCandidateWindow(m_bitsCandType, sx, sy);
|
||||
return;
|
||||
@@ -4944,64 +4890,70 @@ void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
|
||||
}
|
||||
}
|
||||
|
||||
int AwtComponent::ScaleUpX(int x, const UCoordRelativity& relativity) {
|
||||
if (relativity == ABSOLUTE_COORD) return ScaleUpDX(x);
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
|
||||
int AwtComponent::GetScreenImOn() {
|
||||
HWND hWindow = GetAncestor(GetHWnd(), GA_ROOT);
|
||||
AwtComponent *comp = AwtComponent::GetComponent(hWindow);
|
||||
if (comp && comp->IsTopLevel()) {
|
||||
return comp->GetScreenImOn();
|
||||
}
|
||||
return AwtWin32GraphicsDevice::DeviceIndexForWindow(hWindow);
|
||||
}
|
||||
|
||||
|
||||
int AwtComponent::ScaleUpX(int x) {
|
||||
int screen = GetScreenImOn();
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? x : device->ScaleUpX(x);
|
||||
}
|
||||
|
||||
int AwtComponent::ScaleUpDX(int x) {
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
|
||||
int AwtComponent::ScaleUpAbsX(int x) {
|
||||
int screen = GetScreenImOn();
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? x : device->ScaleUpDX(x);
|
||||
return device == NULL ? x : device->ScaleUpAbsX(x);
|
||||
}
|
||||
|
||||
int AwtComponent::ScaleUpY(int y, const UCoordRelativity& relativity) {
|
||||
if (relativity == ABSOLUTE_COORD) return ScaleUpDY(y);
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
|
||||
int AwtComponent::ScaleUpY(int y) {
|
||||
int screen = GetScreenImOn();
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? y : device->ScaleUpY(y);
|
||||
}
|
||||
|
||||
int AwtComponent::ScaleUpDY(int y) {
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
|
||||
int AwtComponent::ScaleUpAbsY(int y) {
|
||||
int screen = GetScreenImOn();
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? y : device->ScaleUpDY(y);
|
||||
return device == NULL ? y : device->ScaleUpAbsY(y);
|
||||
}
|
||||
|
||||
int AwtComponent::ScaleDownX(int x, const UCoordRelativity& relativity) {
|
||||
if (relativity == ABSOLUTE_COORD) return ScaleDownDX(x);
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
|
||||
int AwtComponent::ScaleDownX(int x) {
|
||||
int screen = GetScreenImOn();
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? x : device->ScaleDownX(x);
|
||||
}
|
||||
|
||||
int AwtComponent::ScaleDownDX(int x) {
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
|
||||
int AwtComponent::ScaleDownAbsX(int x) {
|
||||
int screen = GetScreenImOn();
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? x : device->ScaleDownDX(x);
|
||||
return device == NULL ? x : device->ScaleDownAbsX(x);
|
||||
}
|
||||
|
||||
int AwtComponent::ScaleDownY(int y, const UCoordRelativity& relativity) {
|
||||
if (relativity == ABSOLUTE_COORD) return ScaleUpDY(y);
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
|
||||
int AwtComponent::ScaleDownY(int y) {
|
||||
int screen = GetScreenImOn();
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? y : device->ScaleDownY(y);
|
||||
}
|
||||
|
||||
int AwtComponent::ScaleDownDY(int y) {
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
|
||||
int AwtComponent::ScaleDownAbsY(int y) {
|
||||
int screen = GetScreenImOn();
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? y : device->ScaleDownDY(y);
|
||||
return device == NULL ? y : device->ScaleDownAbsY(y);
|
||||
}
|
||||
|
||||
void AwtComponent::ScaleDownRect(RECT& r) {
|
||||
@@ -5309,7 +5261,7 @@ void AwtComponent::SendMouseEvent(jint id, jlong when, jint x, jint y,
|
||||
id, when, modifiers,
|
||||
ScaleDownX(x + insets.left),
|
||||
ScaleDownY(y + insets.top),
|
||||
ScaleDownX(xAbs), ScaleDownY(yAbs),
|
||||
ScaleDownAbsX(xAbs), ScaleDownAbsY(yAbs),
|
||||
clickCount, popupTrigger, button);
|
||||
|
||||
if (safe_ExceptionOccurred(env)) {
|
||||
@@ -5382,8 +5334,8 @@ AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y,
|
||||
id, when, modifiers,
|
||||
ScaleDownX(x + insets.left),
|
||||
ScaleDownY(y + insets.top),
|
||||
ScaleDownX(xAbs),
|
||||
ScaleDownY(yAbs),
|
||||
ScaleDownAbsX(xAbs),
|
||||
ScaleDownAbsY(yAbs),
|
||||
clickCount, popupTrigger,
|
||||
scrollType, scrollAmount,
|
||||
roundedWheelRotation, preciseWheelRotation);
|
||||
@@ -5893,8 +5845,8 @@ jobject AwtComponent::_GetLocationOnScreen(void *param)
|
||||
RECT rect;
|
||||
VERIFY(::GetWindowRect(p->GetHWnd(),&rect));
|
||||
result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
|
||||
p->ScaleDownX(rect.left),
|
||||
p->ScaleDownY(rect.top));
|
||||
p->ScaleDownAbsX(rect.left),
|
||||
p->ScaleDownAbsY(rect.top));
|
||||
}
|
||||
ret:
|
||||
env->DeleteGlobalRef(self);
|
||||
@@ -7494,8 +7446,8 @@ void AwtComponent::VerifyState()
|
||||
target = parent;
|
||||
}
|
||||
|
||||
x = ScaleUpX(x, RELATIVITY_FOR_COMP_XY(this));
|
||||
y = ScaleUpY(y, RELATIVITY_FOR_COMP_XY(this));
|
||||
x = ScaleUpX(x);
|
||||
y = ScaleUpY(y);
|
||||
width = ScaleUpX(width);
|
||||
height = ScaleUpY(height);
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "awt_Brush.h"
|
||||
#include "awt_Pen.h"
|
||||
#include "awt_Win32GraphicsDevice.h"
|
||||
#include "awt_Util.h"
|
||||
|
||||
#include "GDIWindowSurfaceData.h"
|
||||
|
||||
@@ -272,10 +271,11 @@ public:
|
||||
/*
|
||||
* methods on this component
|
||||
*/
|
||||
virtual int GetScreenImOn();
|
||||
virtual void Show();
|
||||
virtual void Hide();
|
||||
virtual void Reshape(int x, int y, int w, int h);
|
||||
// void ReshapeNoScale(int x, int y, int w, int h);
|
||||
void ReshapeNoScale(int x, int y, int w, int h);
|
||||
|
||||
/*
|
||||
* Fix for 4046446.
|
||||
@@ -605,10 +605,6 @@ public:
|
||||
return mrDoDefault;
|
||||
}
|
||||
|
||||
virtual MsgRouting WmDPIChanged(UINT xDPI, UINT yDPI, RECT* bounds) {
|
||||
return mrDoDefault;
|
||||
}
|
||||
|
||||
void UpdateColorModel();
|
||||
|
||||
jintArray CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha);
|
||||
@@ -731,14 +727,14 @@ public:
|
||||
return m_bPauseDestroy;
|
||||
}
|
||||
|
||||
int ScaleUpX(int x, const UCoordRelativity& relativity = RELATIVE_COORD);
|
||||
int ScaleUpY(int y, const UCoordRelativity& relativity = RELATIVE_COORD);
|
||||
int ScaleDownX(int x, const UCoordRelativity& relativity = RELATIVE_COORD);
|
||||
int ScaleDownY(int y, const UCoordRelativity& relativity = RELATIVE_COORD);
|
||||
int ScaleUpDX(int x);
|
||||
int ScaleUpDY(int y);
|
||||
int ScaleDownDX(int x);
|
||||
int ScaleDownDY(int y);
|
||||
int ScaleUpX(int x);
|
||||
int ScaleUpAbsX(int x);
|
||||
int ScaleUpY(int y);
|
||||
int ScaleUpAbsY(int y);
|
||||
int ScaleDownX(int x);
|
||||
int ScaleDownAbsX(int x);
|
||||
int ScaleDownY(int y);
|
||||
int ScaleDownAbsY(int y);
|
||||
void ScaleDownRect(RECT& r);
|
||||
//void ScaleDownDRect(RECT& r);
|
||||
|
||||
@@ -755,8 +751,6 @@ protected:
|
||||
static BOOL sm_suppressFocusAndActivation;
|
||||
static BOOL sm_restoreFocusAndActivation;
|
||||
|
||||
INLINE BOOL IsInMoveResizeLoop() { return m_inMoveResizeLoop; }
|
||||
|
||||
/*
|
||||
* The function sets the focus-restore flag ON/OFF.
|
||||
* When the flag is ON, focus is restored immidiately after the proxy loses it.
|
||||
@@ -853,8 +847,6 @@ private:
|
||||
int m_wheelRotationAmountX;
|
||||
int m_wheelRotationAmountY;
|
||||
|
||||
BOOL m_inMoveResizeLoop;
|
||||
|
||||
BOOL deadKeyActive;
|
||||
|
||||
/*
|
||||
|
||||
@@ -473,9 +473,14 @@ Java_sun_awt_windows_WGlobalCursorManager_getCursorPos(JNIEnv *env,
|
||||
|
||||
POINT p;
|
||||
::GetCursorPos(&p);
|
||||
AwtWin32GraphicsDevice::ScaleDownDPoint(&p);
|
||||
env->SetIntField(point, AwtCursor::pointXID, (jint)p.x);
|
||||
env->SetIntField(point, AwtCursor::pointYID, (jint)p.y);
|
||||
HMONITOR monitor = MonitorFromPoint(p, MONITOR_DEFAULTTOPRIMARY);
|
||||
int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
|
||||
int x = (device == NULL) ? p.x : device->ScaleDownAbsX(p.x);
|
||||
int y = (device == NULL) ? p.y : device->ScaleDownAbsY(p.y);
|
||||
env->SetIntField(point, AwtCursor::pointXID, x);
|
||||
env->SetIntField(point, AwtCursor::pointYID, y);
|
||||
|
||||
CATCH_BAD_ALLOC;
|
||||
}
|
||||
|
||||
@@ -263,8 +263,6 @@ void AwtDragSource::_DoDragDrop(void* param) {
|
||||
AwtDropTarget::SetCurrentDnDDataObject(dragSource);
|
||||
|
||||
::GetCursorPos(&dragSource->m_dragPoint);
|
||||
POINT dragPoint = {dragSource->m_dragPoint.x, dragSource->m_dragPoint.y};
|
||||
AwtWin32GraphicsDevice::ScaleDownDPoint(&dragPoint);
|
||||
|
||||
dragSource->Signal();
|
||||
|
||||
@@ -284,7 +282,7 @@ void AwtDragSource::_DoDragDrop(void* param) {
|
||||
|
||||
call_dSCddfinished(env, peer, res == DRAGDROP_S_DROP && effects != DROPEFFECT_NONE,
|
||||
convertDROPEFFECTToActions(effects),
|
||||
dragPoint);
|
||||
dragSource->m_dragPoint);
|
||||
|
||||
env->DeleteLocalRef(peer);
|
||||
|
||||
@@ -644,13 +642,11 @@ HRESULT __stdcall AwtDragSource::QueryContinueDrag(BOOL fEscapeKeyPressed, DWOR
|
||||
POINT dragPoint;
|
||||
|
||||
::GetCursorPos(&dragPoint);
|
||||
POINT _dragPoint = {dragPoint.x, dragPoint.y};
|
||||
AwtWin32GraphicsDevice::ScaleDownDPoint(&_dragPoint);
|
||||
|
||||
if ( (dragPoint.x != m_dragPoint.x || dragPoint.y != m_dragPoint.y) &&
|
||||
m_lastmods == modifiers) {//cannot move before cursor change
|
||||
call_dSCmouseMoved(env, m_peer,
|
||||
m_actions, modifiers, _dragPoint);
|
||||
m_actions, modifiers, dragPoint);
|
||||
JNU_CHECK_EXCEPTION_RETURN(env, E_UNEXPECTED);
|
||||
m_dragPoint = dragPoint;
|
||||
}
|
||||
@@ -663,7 +659,7 @@ HRESULT __stdcall AwtDragSource::QueryContinueDrag(BOOL fEscapeKeyPressed, DWOR
|
||||
return DRAGDROP_S_CANCEL;
|
||||
} else if (m_lastmods != modifiers) {
|
||||
call_dSCchanged(env, m_peer,
|
||||
m_actions, modifiers, _dragPoint);
|
||||
m_actions, modifiers, dragPoint);
|
||||
m_bRestoreNodropCustomCursor = TRUE;
|
||||
}
|
||||
|
||||
@@ -718,8 +714,6 @@ HRESULT __stdcall AwtDragSource::GiveFeedback(DWORD dwEffect) {
|
||||
POINT curs;
|
||||
|
||||
::GetCursorPos(&curs);
|
||||
POINT _curs = {curs.x, curs.y};
|
||||
AwtWin32GraphicsDevice::ScaleDownDPoint(&_curs);
|
||||
|
||||
m_droptarget = ::WindowFromPoint(curs);
|
||||
|
||||
@@ -728,13 +722,13 @@ HRESULT __stdcall AwtDragSource::GiveFeedback(DWORD dwEffect) {
|
||||
if (invalid) {
|
||||
// Don't call dragExit if dragEnter and dragOver haven't been called.
|
||||
if (!m_enterpending) {
|
||||
call_dSCexit(env, m_peer, _curs);
|
||||
call_dSCexit(env, m_peer, curs);
|
||||
}
|
||||
m_droptarget = (HWND)NULL;
|
||||
m_enterpending = TRUE;
|
||||
} else if (m_droptarget != NULL) {
|
||||
(*(m_enterpending ? call_dSCenter : call_dSCmotion))
|
||||
(env, m_peer, m_actions, modifiers, _curs);
|
||||
(env, m_peer, m_actions, modifiers, curs);
|
||||
|
||||
m_enterpending = FALSE;
|
||||
}
|
||||
@@ -1178,14 +1172,14 @@ HRESULT __stdcall AwtDragSource::GetProcessId(FORMATETC __RPC_FAR *pFormatEtc, S
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void ScaleDown(POINT &pt) {
|
||||
static void ScaleDownAbs(POINT &pt) {
|
||||
HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
|
||||
int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
|
||||
if (device) {
|
||||
pt.x = device->ScaleDownX(pt.x);
|
||||
pt.y = device->ScaleDownY(pt.y);
|
||||
pt.x = device->ScaleDownAbsX(pt.x);
|
||||
pt.y = device->ScaleDownAbsY(pt.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1194,7 +1188,7 @@ DECLARE_JAVA_CLASS(dSCClazz, "sun/awt/windows/WDragSourceContextPeer")
|
||||
void
|
||||
AwtDragSource::call_dSCenter(JNIEnv* env, jobject self, jint targetActions,
|
||||
jint modifiers, POINT pt) {
|
||||
ScaleDown(pt);
|
||||
ScaleDownAbs(pt);
|
||||
DECLARE_VOID_JAVA_METHOD(dSCenter, dSCClazz, "dragEnter", "(IIII)V");
|
||||
DASSERT(!JNU_IsNull(env, self));
|
||||
env->CallVoidMethod(self, dSCenter, targetActions, modifiers, pt.x, pt.y);
|
||||
@@ -1207,7 +1201,7 @@ AwtDragSource::call_dSCenter(JNIEnv* env, jobject self, jint targetActions,
|
||||
void
|
||||
AwtDragSource::call_dSCmotion(JNIEnv* env, jobject self, jint targetActions,
|
||||
jint modifiers, POINT pt) {
|
||||
ScaleDown(pt);
|
||||
ScaleDownAbs(pt);
|
||||
DECLARE_VOID_JAVA_METHOD(dSCmotion, dSCClazz, "dragMotion", "(IIII)V");
|
||||
DASSERT(!JNU_IsNull(env, self));
|
||||
env->CallVoidMethod(self, dSCmotion, targetActions, modifiers, pt.x, pt.y);
|
||||
@@ -1220,7 +1214,7 @@ AwtDragSource::call_dSCmotion(JNIEnv* env, jobject self, jint targetActions,
|
||||
void
|
||||
AwtDragSource::call_dSCchanged(JNIEnv* env, jobject self, jint targetActions,
|
||||
jint modifiers, POINT pt) {
|
||||
ScaleDown(pt);
|
||||
ScaleDownAbs(pt);
|
||||
DECLARE_VOID_JAVA_METHOD(dSCchanged, dSCClazz, "operationChanged",
|
||||
"(IIII)V");
|
||||
DASSERT(!JNU_IsNull(env, self));
|
||||
@@ -1233,7 +1227,7 @@ AwtDragSource::call_dSCchanged(JNIEnv* env, jobject self, jint targetActions,
|
||||
|
||||
void
|
||||
AwtDragSource::call_dSCexit(JNIEnv* env, jobject self, POINT pt) {
|
||||
ScaleDown(pt);
|
||||
ScaleDownAbs(pt);
|
||||
DECLARE_VOID_JAVA_METHOD(dSCexit, dSCClazz, "dragExit", "(II)V");
|
||||
DASSERT(!JNU_IsNull(env, self));
|
||||
env->CallVoidMethod(self, dSCexit, pt.x, pt.y);
|
||||
@@ -1246,7 +1240,7 @@ AwtDragSource::call_dSCexit(JNIEnv* env, jobject self, POINT pt) {
|
||||
void
|
||||
AwtDragSource::call_dSCddfinished(JNIEnv* env, jobject self, jboolean success,
|
||||
jint operations, POINT pt) {
|
||||
ScaleDown(pt);
|
||||
ScaleDownAbs(pt);
|
||||
DECLARE_VOID_JAVA_METHOD(dSCddfinished, dSCClazz, "dragDropFinished", "(ZIII)V");
|
||||
DASSERT(!JNU_IsNull(env, self));
|
||||
env->CallVoidMethod(self, dSCddfinished, success, operations, pt.x, pt.y);
|
||||
@@ -1259,7 +1253,7 @@ AwtDragSource::call_dSCddfinished(JNIEnv* env, jobject self, jboolean success,
|
||||
void
|
||||
AwtDragSource::call_dSCmouseMoved(JNIEnv* env, jobject self, jint targetActions,
|
||||
jint modifiers, POINT pt) {
|
||||
ScaleDown(pt);
|
||||
ScaleDownAbs(pt);
|
||||
DECLARE_VOID_JAVA_METHOD(dSCmouseMoved, dSCClazz, "dragMouseMoved",
|
||||
"(IIII)V");
|
||||
DASSERT(!JNU_IsNull(env, self));
|
||||
|
||||
@@ -1320,18 +1320,18 @@ Java_sun_awt_windows_WFileDialogPeer_toBack(JNIEnv *env, jobject peer)
|
||||
CATCH_BAD_ALLOC;
|
||||
}
|
||||
|
||||
int ScaleDownX(int x, HWND hwnd) {
|
||||
int ScaleDownAbsX(int x, HWND hwnd) {
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(hwnd);
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? x : device->ScaleDownX(x);
|
||||
return device == NULL ? x : device->ScaleDownAbsX(x);
|
||||
}
|
||||
|
||||
int ScaleDownY(int y, HWND hwnd) {
|
||||
int ScaleDownAbsY(int y, HWND hwnd) {
|
||||
int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(hwnd);
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
return device == NULL ? y : device->ScaleDownY(y);
|
||||
return device == NULL ? y : device->ScaleDownAbsY(y);
|
||||
}
|
||||
|
||||
jobject AwtFileDialog::_GetLocationOnScreen(void *param)
|
||||
@@ -1346,7 +1346,8 @@ jobject AwtFileDialog::_GetLocationOnScreen(void *param)
|
||||
RECT rect;
|
||||
VERIFY(::GetWindowRect(hwnd, &rect));
|
||||
result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
|
||||
ScaleDownX(rect.left, hwnd), ScaleDownY(rect.top, hwnd));
|
||||
ScaleDownAbsX(rect.left, hwnd),
|
||||
ScaleDownAbsY(rect.top, hwnd));
|
||||
}
|
||||
|
||||
if (result != NULL)
|
||||
|
||||
@@ -332,17 +332,13 @@ AwtFrame* AwtFrame::Create(jobject self, jobject parent)
|
||||
frame->CreateHWnd(env, L"",
|
||||
style,
|
||||
exStyle,
|
||||
0, 0, 0, 0,
|
||||
x, y, width, height,
|
||||
hwndParent,
|
||||
NULL,
|
||||
::GetSysColor(COLOR_WINDOWTEXT),
|
||||
::GetSysColor(COLOR_WINDOWFRAME),
|
||||
self);
|
||||
/*
|
||||
* Reshape here instead of during create, so that a
|
||||
* WM_NCCALCSIZE is sent.
|
||||
*/
|
||||
frame->Reshape(x, y, width, height);
|
||||
frame->RecalcNonClient();
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
@@ -1250,22 +1246,6 @@ MsgRouting AwtFrame::WmSysCommand(UINT uCmdType, int xPos, int yPos)
|
||||
return AwtWindow::WmSysCommand(uCmdType, xPos, yPos);
|
||||
}
|
||||
|
||||
MsgRouting AwtFrame::WmDPIChanged(UINT xDPI, UINT yDPI, RECT* bounds) {
|
||||
if (isZoomed() && !m_maxBoundsSet) {
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd()));
|
||||
if (device) {
|
||||
float factorX = xDPI / 96.0f / device->GetScaleX();
|
||||
float factorY = yDPI / 96.0f / device->GetScaleY();
|
||||
|
||||
// adjust rcNormalPosition for the zoomed frame
|
||||
AwtFrame::__SetState(this, AwtFrame::__GetState(this), factorX, factorY);
|
||||
return mrConsume;
|
||||
}
|
||||
}
|
||||
return AwtWindow::WmDPIChanged(xDPI, yDPI, bounds);
|
||||
}
|
||||
|
||||
LRESULT AwtFrame::WinThreadExecProc(ExecuteArgs * args)
|
||||
{
|
||||
switch( args->cmdId ) {
|
||||
@@ -1376,15 +1356,6 @@ void AwtFrame::_SetState(void *param)
|
||||
PDATA pData;
|
||||
JNI_CHECK_PEER_GOTO(self, ret);
|
||||
f = (AwtFrame *)pData;
|
||||
AwtFrame::__SetState(f, state);
|
||||
ret:
|
||||
env->DeleteGlobalRef(self);
|
||||
|
||||
delete sss;
|
||||
}
|
||||
|
||||
void AwtFrame::__SetState(AwtFrame* f, int state, float factorX, float factorY)
|
||||
{
|
||||
HWND hwnd = f->GetHWnd();
|
||||
if (::IsWindow(hwnd))
|
||||
{
|
||||
@@ -1408,11 +1379,6 @@ void AwtFrame::__SetState(AwtFrame* f, int state, float factorX, float factorY)
|
||||
wp.length = sizeof(wp);
|
||||
::GetWindowPlacement(hwnd, &wp);
|
||||
|
||||
wp.rcNormalPosition.left *= factorX;
|
||||
wp.rcNormalPosition.right *= factorX;
|
||||
wp.rcNormalPosition.top *= factorY;
|
||||
wp.rcNormalPosition.bottom *= factorY;
|
||||
|
||||
// Iconify first.
|
||||
// If both iconify & zoom are TRUE, handle this case
|
||||
// with wp.flags field below.
|
||||
@@ -1446,6 +1412,10 @@ void AwtFrame::__SetState(AwtFrame* f, int state, float factorX, float factorY)
|
||||
f->setZoomed(zoom);
|
||||
}
|
||||
}
|
||||
ret:
|
||||
env->DeleteGlobalRef(self);
|
||||
|
||||
delete sss;
|
||||
}
|
||||
|
||||
jint AwtFrame::_GetState(void *param)
|
||||
@@ -1454,21 +1424,12 @@ jint AwtFrame::_GetState(void *param)
|
||||
|
||||
jobject self = (jobject)param;
|
||||
|
||||
jint result = java_awt_Frame_NORMAL;
|
||||
AwtFrame *f = NULL;
|
||||
|
||||
PDATA pData;
|
||||
JNI_CHECK_PEER_GOTO(self, ret);
|
||||
f = (AwtFrame *)pData;
|
||||
jint result = AwtFrame::__GetState(f);
|
||||
ret:
|
||||
env->DeleteGlobalRef(self);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
jint AwtFrame::__GetState(AwtFrame* f)
|
||||
{
|
||||
jint result = java_awt_Frame_NORMAL;
|
||||
if (::IsWindow(f->GetHWnd()))
|
||||
{
|
||||
DASSERT(!::IsBadReadPtr(f, sizeof(AwtFrame)));
|
||||
@@ -1483,6 +1444,9 @@ jint AwtFrame::__GetState(AwtFrame* f)
|
||||
f->isIconic() ? " iconic" : "",
|
||||
f->isZoomed() ? " zoomed" : "");
|
||||
}
|
||||
ret:
|
||||
env->DeleteGlobalRef(self);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,6 @@ public:
|
||||
MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button);
|
||||
MsgRouting WmGetIcon(WPARAM iconType, LRESULT& retVal);
|
||||
MsgRouting WmShowWindow(BOOL show, UINT status);
|
||||
MsgRouting WmDPIChanged(UINT xDPI, UINT yDPI, RECT* bounds);
|
||||
MsgRouting WmNcCalcSize(BOOL fCalcValidRects, LPNCCALCSIZE_PARAMS lpncsp, LRESULT& retVal);
|
||||
MsgRouting WmNcHitTest(int x, int y, LRESULT& retVal);
|
||||
MsgRouting WmWindowPosChanging(LPARAM windowPos);
|
||||
@@ -141,9 +140,7 @@ public:
|
||||
|
||||
// some methods called on Toolkit thread
|
||||
static void _SetState(void *param);
|
||||
static void __SetState(AwtFrame* f, int state, float factorX = 1, float factorY = 1);
|
||||
static jint _GetState(void *param);
|
||||
static jint __GetState(AwtFrame* f);
|
||||
static void _SetMaximizedBounds(void *param);
|
||||
static void _ClearMaximizedBounds(void *param);
|
||||
static void _SetMenuBar(void *param);
|
||||
|
||||
@@ -288,14 +288,17 @@ void AwtList::SetMultiSelect(BOOL ms) {
|
||||
|
||||
UnsubclassHWND();
|
||||
AwtToolkit::DestroyComponentHWND(m_hwnd);
|
||||
CreateHWnd(env, L"", style, exStyle,
|
||||
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
||||
CreateHWnd(env, L"", style, exStyle, 0, 0, 0, 0,
|
||||
parentHWnd,
|
||||
NULL,
|
||||
::GetSysColor(COLOR_WINDOWTEXT),
|
||||
::GetSysColor(COLOR_WINDOW),
|
||||
peer);
|
||||
|
||||
SetWindowPos(GetHWnd(), 0,
|
||||
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
|
||||
SWP_NOZORDER | SWP_NOCOPYBITS | SWP_NOACTIVATE);
|
||||
|
||||
SendListMessage(WM_SETFONT, (WPARAM)font, (LPARAM)FALSE);
|
||||
SendListMessage(LB_SETITEMHEIGHT, 0, MAKELPARAM(itemHeight, 0));
|
||||
SendListMessage(LB_RESETCONTENT);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#include "awt_Util.h"
|
||||
#include "awt_Component.h"
|
||||
#include "awt_Win32GraphicsDevice.h"
|
||||
#include "awt_Win32GraphicsConfig.h"
|
||||
|
||||
AwtWin32GraphicsDevice* UGetDeviceByBounds(const URectBounds& bounds, AwtComponent* comp)
|
||||
{
|
||||
URectBounds _bounds(bounds);
|
||||
if (comp != NULL && !comp->IsTopLevel()) {
|
||||
// use the ancestor window to match the device
|
||||
_bounds = UGetWindowRectBounds(::GetAncestor(comp->GetHWnd(), GA_ROOT));
|
||||
}
|
||||
Devices::InstanceAccess devices;
|
||||
POINT center = {_bounds.x + _bounds.width / 2, _bounds.y + _bounds.height / 2};
|
||||
for (int i = 0; i < devices->GetNumDevices(); i++) {
|
||||
RECT rect = AwtWin32GraphicsConfig::getMonitorBounds(i, _bounds.space);
|
||||
if (::PtInRect(&rect, center)) {
|
||||
return devices->GetDevice(i);
|
||||
}
|
||||
}
|
||||
// default to the hwnd's device
|
||||
return comp != NULL ? devices->GetDevice(AwtWin32GraphicsDevice::DeviceIndexForWindow(comp->GetHWnd())) : NULL;
|
||||
}
|
||||
|
||||
URectBounds UGetWindowRectBounds(HWND hwnd)
|
||||
{
|
||||
RECT r;
|
||||
::GetWindowRect(hwnd, &r);
|
||||
return URectBounds(r.left, r.top, r.right - r.left, r.bottom - r.top, DEVICE_SPACE);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef NATIVE_AWT_UTIL_H
|
||||
#define NATIVE_AWT_UTIL_H
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
typedef enum {
|
||||
DEVICE_SPACE,
|
||||
USER_SPACE
|
||||
} UCoordSpace;
|
||||
|
||||
typedef enum {
|
||||
RELATIVE_COORD,
|
||||
ABSOLUTE_COORD
|
||||
} UCoordRelativity;
|
||||
|
||||
#define RELATIVITY_FOR_COMP_XY(compPtr) compPtr->IsTopLevel() ? ABSOLUTE_COORD : RELATIVE_COORD
|
||||
|
||||
typedef struct URectBounds {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
UCoordSpace space;
|
||||
|
||||
URectBounds(int _x, int _y, int _w, int _h, const UCoordSpace& _space) : x(_x), y(_y), width(_w), height(_h), space(_space) {}
|
||||
|
||||
URectBounds(const URectBounds& b) : x(b.x), y(b.y), width(b.width), height(b.height), space(b.space) {}
|
||||
|
||||
URectBounds& operator=(const URectBounds& b) {
|
||||
x = b.x;
|
||||
y = b.y;
|
||||
width = b.width;
|
||||
height = b.height;
|
||||
space = b.space;
|
||||
return *this;
|
||||
}
|
||||
} URectBounds;
|
||||
|
||||
class AwtComponent;
|
||||
class AwtWin32GraphicsDevice;
|
||||
|
||||
URectBounds UGetWindowRectBounds(HWND hwnd);
|
||||
AwtWin32GraphicsDevice* UGetDeviceByBounds(const URectBounds& bounds, AwtComponent* comp = NULL);
|
||||
|
||||
#endif //NATIVE_AWT_UTIL_H
|
||||
@@ -77,36 +77,6 @@ inline int shiftToMask(int numBits, int shift) {
|
||||
return mask;
|
||||
}
|
||||
|
||||
RECT AwtWin32GraphicsConfig::getMonitorBounds(int screen, const UCoordSpace& space)
|
||||
{
|
||||
RECT rRW = {0, 0, 0, 0};
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
|
||||
|
||||
if (TRUE == MonitorBounds(AwtWin32GraphicsDevice::GetMonitor(screen), &rRW)) {
|
||||
int x = (device == NULL || space == DEVICE_SPACE) ? rRW.left
|
||||
: device->ScaleDownX(rRW.left);
|
||||
int y = (device == NULL || space == DEVICE_SPACE) ? rRW.top
|
||||
: device->ScaleDownY(rRW.top);
|
||||
int w = (device == NULL || space == DEVICE_SPACE) ? rRW.right - rRW.left
|
||||
: device->ScaleDownX(rRW.right - rRW.left);
|
||||
int h = (device == NULL || space == DEVICE_SPACE) ? rRW.bottom - rRW.top
|
||||
: device->ScaleDownY(rRW.bottom - rRW.top);
|
||||
|
||||
::SetRect(&rRW, x, y, x + w, y + h);
|
||||
}
|
||||
else {
|
||||
// 4910760 - don't return a null bounds, return the bounds of the
|
||||
// primary screen
|
||||
int w = ::GetSystemMetrics(SM_CXSCREEN);
|
||||
int h = ::GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
::SetRect(&rRW, 0, 0, device == NULL || space == DEVICE_SPACE ? w : device->ScaleDownX(w),
|
||||
device == NULL || space == DEVICE_SPACE ? h : device->ScaleDownY(h));
|
||||
}
|
||||
return rRW;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_awt_Win32GraphicsConfig
|
||||
* Method: getBounds
|
||||
@@ -124,8 +94,30 @@ JNIEXPORT jobject JNICALL
|
||||
CHECK_NULL_RETURN(clazz, NULL);
|
||||
mid = env->GetMethodID(clazz, "<init>", "(IIII)V");
|
||||
if (mid != 0) {
|
||||
RECT r = AwtWin32GraphicsConfig::getMonitorBounds((int)screen, USER_SPACE);
|
||||
bounds = env->NewObject(clazz, mid, r.left, r.top, r.right - r.left, r.bottom - r.top);
|
||||
RECT rRW = {0, 0, 0, 0};
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
|
||||
|
||||
if (TRUE == MonitorBounds(AwtWin32GraphicsDevice::GetMonitor(screen), &rRW)) {
|
||||
int w = (device == NULL) ? rRW.right - rRW.left
|
||||
: device->ScaleDownX(rRW.right - rRW.left);
|
||||
int h = (device == NULL) ? rRW.bottom - rRW.top
|
||||
: device->ScaleDownY(rRW.bottom - rRW.top);
|
||||
|
||||
bounds = env->NewObject(clazz, mid, rRW.left, rRW.top, w, h);
|
||||
|
||||
}
|
||||
else {
|
||||
// 4910760 - don't return a null bounds, return the bounds of the
|
||||
// primary screen
|
||||
int w = ::GetSystemMetrics(SM_CXSCREEN);
|
||||
int h = ::GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
bounds = env->NewObject(clazz, mid,
|
||||
0, 0,
|
||||
device == NULL ? w : device->ScaleDownX(w),
|
||||
device == NULL ? h : device->ScaleDownY(h));
|
||||
}
|
||||
if (safe_ExceptionOccurred(env)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ class AwtWin32GraphicsConfig {
|
||||
public:
|
||||
/* sun.awt.Win32GraphicsConfig fields and method IDs */
|
||||
static jfieldID win32GCVisualID;
|
||||
static RECT getMonitorBounds(int screen, const UCoordSpace& space);
|
||||
};
|
||||
|
||||
#endif /* AWT_WIN32GRAPHICSCONFIG_H */
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
#include <sun_awt_Win32GraphicsDevice.h>
|
||||
#include "awt_Canvas.h"
|
||||
#include "awt_Win32GraphicsDevice.h"
|
||||
#include "awt_Win32GraphicsConfig.h"
|
||||
#include "awt_Window.h"
|
||||
#include "java_awt_Transparency.h"
|
||||
#include "java_awt_color_ColorSpace.h"
|
||||
@@ -78,6 +77,7 @@ AwtWin32GraphicsDevice::AwtWin32GraphicsDevice(int screen,
|
||||
this->devicesArray = arr;
|
||||
this->scaleX = 1;
|
||||
this->scaleY = 1;
|
||||
disableScaleAutoRefresh = FALSE;
|
||||
javaDevice = NULL;
|
||||
colorData = new ImgColorData;
|
||||
colorData->grayscale = GS_NOTGRAY;
|
||||
@@ -629,47 +629,51 @@ void AwtWin32GraphicsDevice::SetScale(float sx, float sy)
|
||||
scaleY = sy;
|
||||
}
|
||||
|
||||
int AwtWin32GraphicsDevice::ScaleUpX(int x, const UCoordRelativity& relativity)
|
||||
int AwtWin32GraphicsDevice::ScaleUpX(int x)
|
||||
{
|
||||
return relativity == RELATIVE_COORD ? ClipRound(x * scaleX) : ScaleUpDX(x);
|
||||
return ClipRound(x * scaleX);
|
||||
}
|
||||
|
||||
// scale up the delta [x - device.x]
|
||||
int AwtWin32GraphicsDevice::ScaleUpDX(int x)
|
||||
int AwtWin32GraphicsDevice::ScaleUpAbsX(int x)
|
||||
{
|
||||
RECT devBounds = AwtWin32GraphicsConfig::getMonitorBounds(screen, DEVICE_SPACE);
|
||||
return devBounds.left + ClipRound((x - devBounds.left) * scaleX);
|
||||
LONG screen = pMonitorInfo->rcMonitor.left;
|
||||
return screen + ClipRound((x - screen) * scaleX);
|
||||
}
|
||||
|
||||
int AwtWin32GraphicsDevice::ScaleUpY(int y, const UCoordRelativity& relativity)
|
||||
int AwtWin32GraphicsDevice::ScaleUpY(int y)
|
||||
{
|
||||
return relativity == RELATIVE_COORD ? ClipRound(y * scaleY) : ScaleUpDY(y);
|
||||
return ClipRound(y * scaleY);
|
||||
}
|
||||
|
||||
// scale up the delta [y - device.y]
|
||||
int AwtWin32GraphicsDevice::ScaleUpDY(int y)
|
||||
int AwtWin32GraphicsDevice::ScaleUpAbsY(int y)
|
||||
{
|
||||
RECT devBounds = AwtWin32GraphicsConfig::getMonitorBounds(screen, DEVICE_SPACE);
|
||||
return devBounds.top + ClipRound((y - devBounds.top) * scaleY);
|
||||
LONG screen = pMonitorInfo->rcMonitor.top;
|
||||
return screen + ClipRound((y - screen) * scaleY);
|
||||
}
|
||||
|
||||
int AwtWin32GraphicsDevice::ScaleDownX(int x, const UCoordRelativity& relativity)
|
||||
int AwtWin32GraphicsDevice::ScaleDownX(int x)
|
||||
{
|
||||
return relativity == RELATIVE_COORD ? ClipRound(x / scaleX) : ScaleDownDX(x);
|
||||
return ClipRound(x / scaleX);
|
||||
}
|
||||
|
||||
// scale down the delta [x - device.x]
|
||||
int AwtWin32GraphicsDevice::ScaleDownDX(int x)
|
||||
int AwtWin32GraphicsDevice::ScaleDownAbsX(int x)
|
||||
{
|
||||
RECT devBounds = AwtWin32GraphicsConfig::getMonitorBounds(screen, USER_SPACE);
|
||||
return devBounds.left + ClipRound((x - devBounds.left) / scaleX);
|
||||
LONG screen = pMonitorInfo->rcMonitor.left;
|
||||
return screen + ClipRound((x - screen) / scaleX);
|
||||
}
|
||||
|
||||
int AwtWin32GraphicsDevice::ScaleDownY(int y, const UCoordRelativity& relativity)
|
||||
int AwtWin32GraphicsDevice::ScaleDownY(int y)
|
||||
{
|
||||
return relativity == RELATIVE_COORD ? ClipRound(y / scaleY) : ScaleDownDY(y);
|
||||
return ClipRound(y / scaleY);
|
||||
}
|
||||
|
||||
int AwtWin32GraphicsDevice::ScaleDownAbsY(int y)
|
||||
{
|
||||
LONG screen = pMonitorInfo->rcMonitor.top;
|
||||
return screen + ClipRound((y - screen) / scaleY);
|
||||
}
|
||||
|
||||
|
||||
int AwtWin32GraphicsDevice::ClipRound(double value)
|
||||
{
|
||||
value -= 0.5;
|
||||
@@ -686,13 +690,6 @@ int AwtWin32GraphicsDevice::ClipRound(double value)
|
||||
return (int)ceil(value);
|
||||
}
|
||||
|
||||
// scale down the delta [y - device.y]
|
||||
int AwtWin32GraphicsDevice::ScaleDownDY(int y)
|
||||
{
|
||||
RECT devBounds = AwtWin32GraphicsConfig::getMonitorBounds(screen, USER_SPACE);
|
||||
return devBounds.top + ClipRound((y - devBounds.top) / scaleY);
|
||||
}
|
||||
|
||||
// scale down the delta [pt.xy - device.xy]
|
||||
void AwtWin32GraphicsDevice::ScaleDownDPoint(POINT *pt)
|
||||
{
|
||||
@@ -709,11 +706,13 @@ void AwtWin32GraphicsDevice::ScaleDownDPoint(POINT *pt)
|
||||
|
||||
void AwtWin32GraphicsDevice::InitDesktopScales()
|
||||
{
|
||||
float dpiX = -1.0f;
|
||||
float dpiY = -1.0f;
|
||||
GetScreenDpi(GetMonitor(), &dpiX, &dpiY);
|
||||
if (dpiX > 0 && dpiY > 0) {
|
||||
SetScale(dpiX / 96, dpiY / 96);
|
||||
if (!disableScaleAutoRefresh) {
|
||||
float dpiX = -1.0f;
|
||||
float dpiY = -1.0f;
|
||||
GetScreenDpi(GetMonitor(), &dpiX, &dpiY);
|
||||
if (dpiX > 0 && dpiY > 0) {
|
||||
SetScale(dpiX / 96, dpiY / 96);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,6 +736,12 @@ void AwtWin32GraphicsDevice::DisableOffscreenAcceleration()
|
||||
// REMIND: noop for now
|
||||
}
|
||||
|
||||
void AwtWin32GraphicsDevice::DisableScaleAutoRefresh()
|
||||
{
|
||||
disableScaleAutoRefresh = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Invalidates the GraphicsDevice object associated with this
|
||||
* device by disabling offscreen acceleration and calling
|
||||
@@ -797,6 +802,22 @@ void AwtWin32GraphicsDevice::ResetAllMonitorInfo()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function updates the scale factor for all monitors on the system.
|
||||
*/
|
||||
void AwtWin32GraphicsDevice::ResetAllDesktopScales()
|
||||
{
|
||||
if (!Devices::GetInstance()){
|
||||
return;
|
||||
}
|
||||
Devices::InstanceAccess devices;
|
||||
int devicesNum = devices->GetNumDevices();
|
||||
for (int deviceIndex = 0; deviceIndex < devicesNum; deviceIndex++) {
|
||||
devices->GetDevice(deviceIndex)->InitDesktopScales();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AwtWin32GraphicsDevice::DisableOffscreenAccelerationForDevice(
|
||||
HMONITOR hMonitor)
|
||||
{
|
||||
@@ -1444,6 +1465,7 @@ JNIEXPORT void JNICALL
|
||||
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
|
||||
|
||||
if (device != NULL ) {
|
||||
device->DisableScaleAutoRefresh();
|
||||
device->SetScale(scaleX, scaleY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ extern "C" {
|
||||
#include "colordata.h"
|
||||
#include "awt_Palette.h"
|
||||
#include "Devices.h"
|
||||
#include "awt_Util.h"
|
||||
|
||||
class AwtPalette;
|
||||
class Devices;
|
||||
@@ -66,19 +65,20 @@ public:
|
||||
int GetDeviceIndex() { return screen; }
|
||||
void Release();
|
||||
void DisableOffscreenAcceleration();
|
||||
void DisableScaleAutoRefresh();
|
||||
void Invalidate(JNIEnv *env);
|
||||
void InitDesktopScales();
|
||||
void SetScale(float scaleX, float scaleY);
|
||||
float GetScaleX();
|
||||
float GetScaleY();
|
||||
int ScaleUpX(int x, const UCoordRelativity& relativity = RELATIVE_COORD);
|
||||
int ScaleUpY(int y, const UCoordRelativity& relativity = RELATIVE_COORD);
|
||||
int ScaleDownX(int x, const UCoordRelativity& relativity = RELATIVE_COORD);
|
||||
int ScaleDownY(int y, const UCoordRelativity& relativity = RELATIVE_COORD);
|
||||
int ScaleUpDX(int x);
|
||||
int ScaleUpDY(int y);
|
||||
int ScaleDownDX(int x);
|
||||
int ScaleDownDY(int y);
|
||||
int ScaleUpX(int x);
|
||||
int ScaleUpAbsX(int x);
|
||||
int ScaleUpY(int y);
|
||||
int ScaleUpAbsY(int y);
|
||||
int ScaleDownX(int x);
|
||||
int ScaleDownAbsX(int x);
|
||||
int ScaleDownY(int y);
|
||||
int ScaleDownAbsY(int y);
|
||||
|
||||
static void ScaleDownDPoint(POINT *pt);
|
||||
static int DeviceIndexForWindow(HWND hWnd);
|
||||
@@ -94,6 +94,7 @@ public:
|
||||
static HMONITOR GetMonitor(int deviceIndex);
|
||||
static LPMONITORINFO GetMonitorInfo(int deviceIndex);
|
||||
static void ResetAllMonitorInfo();
|
||||
static void ResetAllDesktopScales();
|
||||
static BOOL IsPrimaryPalettized() { return primaryPalettized; }
|
||||
static int GetDefaultDeviceIndex() { return primaryIndex; }
|
||||
static void DisableOffscreenAccelerationForDevice(HMONITOR hMonitor);
|
||||
@@ -124,6 +125,7 @@ private:
|
||||
Devices *devicesArray;
|
||||
float scaleX;
|
||||
float scaleY;
|
||||
BOOL disableScaleAutoRefresh;
|
||||
|
||||
static HDC MakeDCFromMonitor(HMONITOR);
|
||||
static int ClipRound(double value);
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "awt_IconCursor.h"
|
||||
#include "ComCtl32Util.h"
|
||||
#include "math.h"
|
||||
#include "awt_Util.h"
|
||||
|
||||
#include "java_awt_Insets.h"
|
||||
#include <java_awt_Container.h>
|
||||
@@ -155,17 +154,6 @@ struct SetFullScreenExclusiveModeStateStruct {
|
||||
jboolean isFSEMState;
|
||||
};
|
||||
|
||||
/* // struct for _WindowDPIChange() method
|
||||
struct ScaleStruct {
|
||||
jobject window;
|
||||
jint prevScreen;
|
||||
jfloat prevScaleX;
|
||||
jfloat prevScaleY;
|
||||
jint screen;
|
||||
jfloat scaleX;
|
||||
jfloat scaleY;
|
||||
}; */
|
||||
|
||||
struct OverrideHandle {
|
||||
jobject frame;
|
||||
HWND handle;
|
||||
@@ -181,10 +169,6 @@ jfieldID AwtWindow::autoRequestFocusID;
|
||||
jfieldID AwtWindow::securityWarningWidthID;
|
||||
jfieldID AwtWindow::securityWarningHeightID;
|
||||
|
||||
jfieldID AwtWindow::sysXID;
|
||||
jfieldID AwtWindow::sysYID;
|
||||
jfieldID AwtWindow::sysWID;
|
||||
jfieldID AwtWindow::sysHID;
|
||||
jfieldID AwtWindow::windowTypeID;
|
||||
jfieldID AwtWindow::sysInsetsID;
|
||||
jmethodID AwtWindow::notifyWindowStateChangedMID;
|
||||
@@ -248,13 +232,11 @@ AwtWindow::AwtWindow() {
|
||||
m_alwaysOnTop = false;
|
||||
|
||||
fullScreenExclusiveModeState = FALSE;
|
||||
/*m_winSizeMove = FALSE;
|
||||
m_winSizeMove = FALSE;
|
||||
prevScaleRec.screen = -1;
|
||||
prevScaleRec.scaleX = -1.0f;
|
||||
prevScaleRec.scaleY = -1.0f;*/
|
||||
prevScaleRec.scaleY = -1.0f;
|
||||
m_overriddenHwnd = NULL;
|
||||
|
||||
::SetRect(&m_boundsOnDPIChange, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
AwtWindow::~AwtWindow()
|
||||
@@ -983,51 +965,6 @@ MsgRouting AwtWindow::WmTimer(UINT_PTR timerID)
|
||||
return mrConsume;
|
||||
}
|
||||
|
||||
MsgRouting AwtWindow::WmDPIChanged(UINT xDPI, UINT yDPI, RECT* bounds) {
|
||||
if (!::IsWindowVisible(GetHWnd())) {
|
||||
// may diverge with Component::Reshape in this state
|
||||
return mrDoDefault;
|
||||
}
|
||||
if (IsInMoveResizeLoop()) {
|
||||
// Dragged with mouse to new screen. In this case the new bounds must be set immediately
|
||||
// or otherwise OS will reset it back to the previous values.
|
||||
::SetWindowPos(GetHWnd(), NULL,
|
||||
bounds->left, bounds->top,
|
||||
bounds->right - bounds->left, bounds->bottom - bounds->top,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
} else {
|
||||
// Either DPI of this screen changed, or the window moved to a new screen by a shortcut (shift+meta+arrow).
|
||||
// Store the new bounds for async update.
|
||||
::CopyRect(&m_boundsOnDPIChange, bounds);
|
||||
}
|
||||
return mrConsume;
|
||||
}
|
||||
|
||||
void AwtWindow::_AdjustBoundsOnDPIChange(void* param)
|
||||
{
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
|
||||
jobject jwnd = (jobject)param;
|
||||
PDATA pData;
|
||||
JNI_CHECK_PEER_GOTO(jwnd, done);
|
||||
AwtWindow *window = (AwtWindow *)pData;
|
||||
|
||||
int x = window->m_boundsOnDPIChange.left;
|
||||
int y = window->m_boundsOnDPIChange.top;
|
||||
int width = window->m_boundsOnDPIChange.right - window->m_boundsOnDPIChange.left;
|
||||
int height = window->m_boundsOnDPIChange.bottom - window->m_boundsOnDPIChange.top;
|
||||
|
||||
if (width > 0 && height > 0) {
|
||||
::SetRect(&window->m_boundsOnDPIChange, 0, 0, 0, 0); // drop it
|
||||
|
||||
::SetWindowPos(window->GetHWnd(), NULL,
|
||||
x, y, width, height,
|
||||
SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
}
|
||||
done:
|
||||
env->DeleteGlobalRef(jwnd);
|
||||
}
|
||||
|
||||
// The security warning is visible if:
|
||||
// 1. The window has the keyboard window focus, OR
|
||||
// 2. The mouse pointer is located within the window bounds,
|
||||
@@ -1197,20 +1134,20 @@ AwtWindow* AwtWindow::Create(jobject self, jobject parent)
|
||||
// specify WS_EX_TOOLWINDOW to remove parentless windows from taskbar
|
||||
exStyle |= WS_EX_TOOLWINDOW;
|
||||
}
|
||||
jint x = env->GetIntField(target, AwtComponent::xID);
|
||||
jint y = env->GetIntField(target, AwtComponent::yID);
|
||||
jint width = env->GetIntField(target, AwtComponent::widthID);
|
||||
jint height = env->GetIntField(target, AwtComponent::heightID);
|
||||
|
||||
window->CreateHWnd(env, L"",
|
||||
style, exStyle,
|
||||
0, 0, 0, 0,
|
||||
x, y, width, height,
|
||||
(awtParent != NULL) ? awtParent->GetHWnd() : NULL,
|
||||
NULL,
|
||||
::GetSysColor(COLOR_WINDOWTEXT),
|
||||
::GetSysColor(COLOR_WINDOW),
|
||||
self);
|
||||
|
||||
jint x = env->GetIntField(target, AwtComponent::xID);
|
||||
jint y = env->GetIntField(target, AwtComponent::yID);
|
||||
jint width = env->GetIntField(target, AwtComponent::widthID);
|
||||
jint height = env->GetIntField(target, AwtComponent::heightID);
|
||||
|
||||
/*
|
||||
* Initialize icon as inherited from parent if it exists
|
||||
*/
|
||||
@@ -1220,13 +1157,7 @@ AwtWindow* AwtWindow::Create(jobject self, jobject parent)
|
||||
window->m_iconInherited = TRUE;
|
||||
}
|
||||
window->DoUpdateIcon();
|
||||
|
||||
|
||||
/*
|
||||
* Reshape here instead of during create, so that a WM_NCCALCSIZE
|
||||
* is sent.
|
||||
*/
|
||||
window->Reshape(x, y, width, height);
|
||||
window->RecalcNonClient();
|
||||
}
|
||||
} catch (...) {
|
||||
env->DeleteLocalRef(target);
|
||||
@@ -1284,6 +1215,48 @@ void AwtWindow::moveToDefaultLocation() {
|
||||
VERIFY(::SetWindowPos(GetHWnd(), NULL, defLoc.left, defLoc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER));
|
||||
}
|
||||
|
||||
/**
|
||||
* Override AwtComponent::Reshape() to handle absolute screen coordinates used
|
||||
* by the top-level windows.
|
||||
*/
|
||||
void AwtWindow::Reshape(int x, int y, int w, int h) {
|
||||
if (IsEmbeddedFrame()) {
|
||||
// Not the "real" top level window
|
||||
return AwtComponent::Reshape(x, y, w, h);
|
||||
}
|
||||
// Yes, use x,y in user's space to find the nearest monitor in device space.
|
||||
POINT pt = {x + w / 2, y + h / 2};
|
||||
Devices::InstanceAccess devices;
|
||||
HMONITOR monitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST);
|
||||
int screen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(monitor);
|
||||
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
|
||||
// Try to set the correct size and jump to the correct location, even if it is
|
||||
// on the different monitor. Note that for the "size" we use the current
|
||||
// monitor, so the WM_DPICHANGED will adjust it for the "target" monitor.
|
||||
int scaleUpAbsX = device == NULL ? x : device->ScaleUpAbsX(x);
|
||||
int scaleUpAbsY = device == NULL ? y : device->ScaleUpAbsY(y);
|
||||
ReshapeNoScale(scaleUpAbsX, scaleUpAbsY, ScaleUpX(w), ScaleUpY(h));
|
||||
// The window manager may tweak the size for different reasons, so try
|
||||
// to make sure our window has the correct size in the user's space.
|
||||
// NOOP if the size was changed already or changing is in progress.
|
||||
RECT rc;
|
||||
::GetWindowRect(GetHWnd(), &rc);
|
||||
ReshapeNoScale(rc.left, rc.top, ScaleUpX(w), ScaleUpY(h));
|
||||
// the window manager may ignore our "SetWindowPos" request, in this,
|
||||
// case the WmMove/WmSize will not come and we need to manually resync
|
||||
// the "java.awt.Window" locations, because "java.awt.Window" already
|
||||
// uses location ignored by the window manager.
|
||||
::GetWindowRect(GetHWnd(), &rc);
|
||||
if (x != ScaleDownAbsX(rc.left) || y != ScaleDownAbsY(rc.top)) {
|
||||
WmMove(rc.left, rc.top);
|
||||
}
|
||||
int userW = ScaleDownX(rc.right - rc.left);
|
||||
int userH = ScaleDownY(rc.bottom - rc.top);
|
||||
if (w != userW || h != userH) {
|
||||
WmSize(SIZENORMAL, rc.right - rc.left, rc.bottom - rc.top);
|
||||
}
|
||||
}
|
||||
|
||||
void AwtWindow::Show()
|
||||
{
|
||||
m_visible = true;
|
||||
@@ -1870,6 +1843,16 @@ MsgRouting AwtWindow::WmShowWindow(BOOL show, UINT status)
|
||||
return AwtCanvas::WmShowWindow(show, status);
|
||||
}
|
||||
|
||||
void AwtWindow::WmDPIChanged(const LPARAM &lParam) {
|
||||
// need to update the scales now, otherwise the ReshapeNoScale() will
|
||||
// calculate the bounds wrongly
|
||||
AwtWin32GraphicsDevice::ResetAllDesktopScales();
|
||||
RECT *r = (RECT *) lParam;
|
||||
ReshapeNoScale(r->left, r->top, r->right - r->left, r->bottom - r->top);
|
||||
CheckIfOnNewScreen(true);
|
||||
}
|
||||
|
||||
|
||||
MsgRouting AwtWindow::WmEraseBkgnd(HDC hDC, BOOL& didErase)
|
||||
{
|
||||
if (!IsUndecorated()) {
|
||||
@@ -1900,61 +1883,21 @@ MsgRouting AwtWindow::WmMove(int x, int y)
|
||||
return mrDoDefault;
|
||||
}
|
||||
|
||||
if (m_screenNum == -1) {
|
||||
// Set initial value
|
||||
m_screenNum = GetScreenImOn();
|
||||
}
|
||||
else if (CheckIfOnNewScreen()) {
|
||||
DoUpdateIcon();
|
||||
}
|
||||
// Check for the new screen and update the java peer
|
||||
CheckIfOnNewScreen(false); // postpone if different DPI
|
||||
|
||||
/* Update the java AWT target component's fields directly */
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
if (env->EnsureLocalCapacity(1) < 0) {
|
||||
return mrConsume;
|
||||
}
|
||||
jobject peer = GetPeer(env);
|
||||
jobject target = env->GetObjectField(peer, AwtObject::targetID);
|
||||
jobject target = GetTarget(env);
|
||||
|
||||
URectBounds rect = UGetWindowRectBounds(GetHWnd());
|
||||
AwtWin32GraphicsDevice* device = UGetDeviceByBounds(rect, this);
|
||||
RECT rect;
|
||||
::GetWindowRect(GetHWnd(), &rect);
|
||||
|
||||
int usrX = device->ScaleDownX(rect.x);
|
||||
int usrY = device->ScaleDownY(rect.y);
|
||||
|
||||
// [tav] Convert x/y to user space, asymmetrically to AwtComponent::Reshape.
|
||||
AwtComponent* parent = GetParent();
|
||||
if (parent != NULL && (device->GetScaleX() > 1 || device->GetScaleY() > 1)) {
|
||||
|
||||
RECT parentInsets;
|
||||
parent->GetInsets(&parentInsets);
|
||||
// Convert the owner's client area origin to user space
|
||||
int parentInsetsUsrX = device->ScaleDownX(parentInsets.left);
|
||||
int parentInsetsUsrY = device->ScaleDownY(parentInsets.top);
|
||||
|
||||
RECT parentRect;
|
||||
VERIFY(::GetWindowRect(parent->GetHWnd(), &parentRect));
|
||||
// Convert the owner's origin to user space
|
||||
int parentUsrX = device->ScaleDownX(parentRect.left);
|
||||
int parentUsrY = device->ScaleDownY(parentRect.top);
|
||||
|
||||
// Calc the offset from the owner's client area in device space
|
||||
int offsetDevX = rect.x - parentRect.left - parentInsets.left;
|
||||
int offsetDevY = rect.y - parentRect.top - parentInsets.top;
|
||||
|
||||
// Convert the offset to user space
|
||||
int offsetUsrX = device->ScaleDownX(offsetDevX);
|
||||
int offsetUsrY = device->ScaleDownY(offsetDevY);
|
||||
|
||||
// Finally calc the window's location based on the frame's and its insets user space values.
|
||||
usrX = parentUsrX + parentInsetsUsrX + offsetUsrX;
|
||||
usrY = parentUsrY + parentInsetsUsrY + offsetUsrY;
|
||||
}
|
||||
|
||||
(env)->SetIntField(target, AwtComponent::xID, usrX);
|
||||
(env)->SetIntField(target, AwtComponent::yID, usrY);
|
||||
(env)->SetIntField(peer, AwtWindow::sysXID, rect.x);
|
||||
(env)->SetIntField(peer, AwtWindow::sysYID, rect.y);
|
||||
(env)->SetIntField(target, AwtComponent::xID, ScaleDownAbsX(rect.left));
|
||||
(env)->SetIntField(target, AwtComponent::yID, ScaleDownAbsY(rect.top));
|
||||
SendComponentEvent(java_awt_event_ComponentEvent_COMPONENT_MOVED);
|
||||
|
||||
env->DeleteLocalRef(target);
|
||||
@@ -1996,18 +1939,27 @@ MsgRouting AwtWindow::WmSizing()
|
||||
return mrDoDefault;
|
||||
}
|
||||
|
||||
/*MsgRouting AwtWindow::WmEnterSizeMove()
|
||||
MsgRouting AwtWindow::WmEnterSizeMove()
|
||||
{
|
||||
m_winSizeMove = TRUE;
|
||||
// Below is a workaround, see CheckWindowDPIChange
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(m_screenNum);
|
||||
if (device) {
|
||||
prevScaleRec.screen = m_screenNum;
|
||||
prevScaleRec.scaleX = device->GetScaleX();
|
||||
prevScaleRec.scaleY = device->GetScaleY();
|
||||
}
|
||||
// Above is a workaround
|
||||
return mrDoDefault;
|
||||
}
|
||||
|
||||
MsgRouting AwtWindow::WmExitSizeMove()
|
||||
{
|
||||
m_winSizeMove = FALSE;
|
||||
CheckWindowDPIChange();
|
||||
CheckWindowDPIChange(); // workaround
|
||||
return mrDoDefault;
|
||||
}*/
|
||||
}
|
||||
|
||||
/*
|
||||
* Override AwtComponent's size handling to first update the
|
||||
@@ -2022,6 +1974,8 @@ MsgRouting AwtWindow::WmSize(UINT type, int w, int h)
|
||||
UpdateSecurityWarningVisibility();
|
||||
return mrDoDefault;
|
||||
}
|
||||
// Check for the new screen and update the java peer
|
||||
CheckIfOnNewScreen(false); // postpone if different DPI
|
||||
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
if (env->EnsureLocalCapacity(1) < 0)
|
||||
@@ -2029,16 +1983,8 @@ MsgRouting AwtWindow::WmSize(UINT type, int w, int h)
|
||||
jobject target = GetTarget(env);
|
||||
// fix 4167248 : ensure the insets are up-to-date before using
|
||||
BOOL insetsChanged = UpdateInsets(NULL);
|
||||
int newWidth = w + m_insets.left + m_insets.right;
|
||||
int newHeight = h + m_insets.top + m_insets.bottom;
|
||||
URectBounds rect = UGetWindowRectBounds(GetHWnd());
|
||||
AwtWin32GraphicsDevice* device = UGetDeviceByBounds(rect, this);
|
||||
(env)->SetIntField(target, AwtComponent::widthID, device->ScaleDownX(newWidth));
|
||||
(env)->SetIntField(target, AwtComponent::heightID, device->ScaleDownY(newHeight));
|
||||
|
||||
jobject peer = GetPeer(env);
|
||||
(env)->SetIntField(peer, AwtWindow::sysWID, newWidth);
|
||||
(env)->SetIntField(peer, AwtWindow::sysHID, newHeight);
|
||||
(env)->SetIntField(target, AwtComponent::widthID, ScaleDownX(w));
|
||||
(env)->SetIntField(target, AwtComponent::heightID, ScaleDownY(h));
|
||||
|
||||
if (!AwtWindow::IsResizing()) {
|
||||
WindowResized();
|
||||
@@ -2120,6 +2066,11 @@ LRESULT AwtWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT retValue = 0L;
|
||||
|
||||
switch(message) {
|
||||
case WM_DPICHANGED: {
|
||||
WmDPIChanged(lParam);
|
||||
mr = mrConsume;
|
||||
break;
|
||||
}
|
||||
case WM_GETICON:
|
||||
mr = WmGetIcon(wParam, retValue);
|
||||
break;
|
||||
@@ -2272,98 +2223,81 @@ int AwtWindow::GetScreenImOn() {
|
||||
return scrnNum;
|
||||
}
|
||||
|
||||
/* Check to see if we've been moved onto another screen.
|
||||
/*
|
||||
* Check to see if we've been moved onto another screen.
|
||||
* If so, update internal data, surfaces, etc.
|
||||
*/
|
||||
|
||||
BOOL AwtWindow::CheckIfOnNewScreen() {
|
||||
void AwtWindow::CheckIfOnNewScreen(BOOL force) {
|
||||
int curScrn = GetScreenImOn();
|
||||
|
||||
if (curScrn != m_screenNum) { // we've been moved
|
||||
// if moved from one monitor to another with different DPI, we should
|
||||
// update the m_screenNum only if the size was updated as well in the
|
||||
// WM_DPICHANGED.
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* oldDevice = devices->GetDevice(m_screenNum);
|
||||
AwtWin32GraphicsDevice* newDevice = devices->GetDevice(curScrn);
|
||||
if (!force && m_winSizeMove && oldDevice && newDevice) {
|
||||
if (oldDevice->GetScaleX() != newDevice->GetScaleX()
|
||||
|| oldDevice->GetScaleY() != newDevice->GetScaleY()) {
|
||||
// scales are different, wait for WM_DPICHANGED
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
|
||||
jclass peerCls = env->GetObjectClass(m_peerObject);
|
||||
DASSERT(peerCls);
|
||||
CHECK_NULL_RETURN(peerCls, TRUE);
|
||||
CHECK_NULL(peerCls);
|
||||
|
||||
jmethodID draggedID = env->GetMethodID(peerCls, "draggedToNewScreen",
|
||||
"()V");
|
||||
DASSERT(draggedID);
|
||||
if (draggedID == NULL) {
|
||||
env->DeleteLocalRef(peerCls);
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
env->CallVoidMethod(m_peerObject, draggedID);
|
||||
m_screenNum = curScrn;
|
||||
|
||||
env->DeleteLocalRef(peerCls);
|
||||
return TRUE;
|
||||
|
||||
DoUpdateIcon();
|
||||
}
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
/* void AwtWindow::CheckWindowDPIChange() {
|
||||
|
||||
if (prevScaleRec.screen != -1 ) {
|
||||
float prevScaleX = prevScaleRec.scaleX;
|
||||
float prevScaleY = prevScaleRec.scaleY;
|
||||
|
||||
if (prevScaleX >= 1 && prevScaleY >= 1) {
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(m_screenNum);
|
||||
if (device) {
|
||||
float scaleX = device->GetScaleX();
|
||||
float scaleY = device->GetScaleY();
|
||||
if (prevScaleX != scaleX || prevScaleY != scaleY) {
|
||||
WindowDPIChange(prevScaleRec.screen, prevScaleX, prevScaleY,
|
||||
m_screenNum, scaleX, scaleY);
|
||||
void AwtWindow::CheckWindowDPIChange() {
|
||||
if (prevScaleRec.screen != -1 && prevScaleRec.screen != m_screenNum) {
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice *device = devices->GetDevice(m_screenNum);
|
||||
if (device) {
|
||||
if (prevScaleRec.scaleX != device->GetScaleX()
|
||||
|| prevScaleRec.scaleY != device->GetScaleY()) {
|
||||
RECT rect;
|
||||
::GetWindowRect(GetHWnd(), &rect);
|
||||
int x = rect.left;
|
||||
int y = rect.top;
|
||||
int w = rect.right - rect.left;
|
||||
int h = rect.bottom - rect.top;
|
||||
RECT bounds;
|
||||
if (MonitorBounds(device->GetMonitor(), &bounds)) {
|
||||
x = x < bounds.left ? bounds.left : x;
|
||||
y = y < bounds.top ? bounds.top : y;
|
||||
x = (x + w > bounds.right) ? bounds.right - w : x;
|
||||
y = (y + h > bounds.bottom) ? bounds.bottom - h : y;
|
||||
}
|
||||
ReshapeNoScale(x, y, w, h);
|
||||
}
|
||||
}
|
||||
prevScaleRec.screen = -1;
|
||||
prevScaleRec.scaleX = -1.0f;
|
||||
prevScaleRec.scaleY = -1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void AwtWindow::WindowDPIChange(int prevScreen,
|
||||
float prevScaleX, float prevScaleY,
|
||||
int screen, float scaleX,
|
||||
float scaleY)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
RECT rect;
|
||||
|
||||
if (prevScaleX == scaleX && prevScaleY == scaleY) {
|
||||
return;
|
||||
}
|
||||
|
||||
::GetWindowRect(GetHWnd(), &rect);
|
||||
x = rect.left;
|
||||
y = rect.top;
|
||||
w = (rect.right - rect.left) * scaleX / prevScaleX;
|
||||
h = (rect.bottom - rect.top) * scaleY / prevScaleY;
|
||||
|
||||
if (prevScreen != screen) {
|
||||
Devices::InstanceAccess devices;
|
||||
AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
|
||||
if (device) {
|
||||
RECT bounds;
|
||||
if (MonitorBounds(device->GetMonitor(), &bounds)) {
|
||||
x = x < bounds.left ? bounds.left : x;
|
||||
y = y < bounds.top ? bounds.top : y;
|
||||
|
||||
x = (x + w > bounds.right) ? bounds.right - w : x;
|
||||
y = (y + h > bounds.bottom) ? bounds.bottom - h : y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReshapeNoScale(x, y, w, h);
|
||||
} */
|
||||
|
||||
BOOL AwtWindow::IsFocusableWindow() {
|
||||
/*
|
||||
* For Window/Frame/Dialog to accept focus it should:
|
||||
@@ -2750,15 +2684,11 @@ void AwtWindow::_ReshapeFrame(void *param)
|
||||
{
|
||||
env->SetIntField(target, AwtComponent::widthID,
|
||||
w = minWidth);
|
||||
env->SetIntField(peer, AwtWindow::sysWID,
|
||||
w);
|
||||
}
|
||||
if (h < minHeight)
|
||||
{
|
||||
env->SetIntField(target, AwtComponent::heightID,
|
||||
h = minHeight);
|
||||
env->SetIntField(peer, AwtWindow::sysHID,
|
||||
h);
|
||||
}
|
||||
}
|
||||
env->DeleteLocalRef(target);
|
||||
@@ -3425,40 +3355,6 @@ void AwtWindow::_GetNativeWindowSize(void* param) {
|
||||
env->DeleteGlobalRef(self);
|
||||
}
|
||||
|
||||
/*void AwtWindow::_WindowDPIChange(void* param)
|
||||
{
|
||||
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
|
||||
ScaleStruct *ss = (ScaleStruct *)param;
|
||||
jobject self = ss->window;
|
||||
jint prevScreen = ss->prevScreen;
|
||||
jfloat prevScaleX = ss->prevScaleX;
|
||||
jfloat prevScaleY = ss->prevScaleY;
|
||||
jint screen = ss->screen;
|
||||
jfloat scaleX = ss->scaleX;
|
||||
jfloat scaleY = ss->scaleY;
|
||||
|
||||
PDATA pData;
|
||||
JNI_CHECK_PEER_GOTO(self, ret);
|
||||
AwtWindow *window = (AwtWindow *)pData;
|
||||
|
||||
if (window->m_winSizeMove) {
|
||||
if (window->prevScaleRec.screen == -1) {
|
||||
window->prevScaleRec.screen = prevScreen;
|
||||
window->prevScaleRec.scaleX = prevScaleX;
|
||||
window->prevScaleRec.scaleY = prevScaleY;
|
||||
}
|
||||
}
|
||||
else {
|
||||
window->WindowDPIChange(prevScreen, prevScaleX, prevScaleY,
|
||||
screen, scaleX, scaleY);
|
||||
}
|
||||
|
||||
ret:
|
||||
env->DeleteGlobalRef(self);
|
||||
delete ss;
|
||||
}*/
|
||||
|
||||
extern "C" int getSystemMetricValue(int msgType);
|
||||
extern "C" {
|
||||
|
||||
@@ -3515,11 +3411,6 @@ Java_sun_awt_windows_WWindowPeer_initIDs(JNIEnv *env, jclass cls)
|
||||
{
|
||||
TRY;
|
||||
|
||||
CHECK_NULL(AwtWindow::sysXID = env->GetFieldID(cls, "sysX", "I"));
|
||||
CHECK_NULL(AwtWindow::sysYID = env->GetFieldID(cls, "sysY", "I"));
|
||||
CHECK_NULL(AwtWindow::sysWID = env->GetFieldID(cls, "sysW", "I"));
|
||||
CHECK_NULL(AwtWindow::sysHID = env->GetFieldID(cls, "sysH", "I"));
|
||||
|
||||
CHECK_NULL(AwtWindow::sysInsetsID = env->GetFieldID(cls, "sysInsets", "Ljava/awt/Insets;"));
|
||||
|
||||
AwtWindow::windowTypeID = env->GetFieldID(cls, "windowType",
|
||||
@@ -4161,49 +4052,6 @@ Java_sun_awt_windows_WWindowPeer_repositionSecurityWarning(JNIEnv *env,
|
||||
CATCH_BAD_ALLOC;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_awt_windows_WWindowPeer
|
||||
* Method: _AdjustBoundsOnDPIChange
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_awt_windows_WWindowPeer_adjustBoundsOnDPIChange(JNIEnv *env, jobject self)
|
||||
{
|
||||
TRY;
|
||||
|
||||
AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_AdjustBoundsOnDPIChange, (void*)env->NewGlobalRef(self));
|
||||
// global refs deleted in _AdjustBoundsOnDisplayChange
|
||||
|
||||
CATCH_BAD_ALLOC;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_awt_windows_WWindowPeer
|
||||
* Method: windowDPIChange
|
||||
* Signature: (IFFIFF)V
|
||||
*/
|
||||
/*JNIEXPORT void JNICALL
|
||||
Java_sun_awt_windows_WWindowPeer_windowDPIChange(JNIEnv *env, jobject self,
|
||||
jint prevScreen, jfloat prevScaleX, jfloat prevScaleY,
|
||||
jint screen, jfloat scaleX, jfloat scaleY)
|
||||
{
|
||||
TRY;
|
||||
|
||||
ScaleStruct *ss = new ScaleStruct;
|
||||
ss->window = env->NewGlobalRef(self);
|
||||
ss->prevScreen = prevScreen;
|
||||
ss->prevScaleX = prevScaleX;
|
||||
ss->prevScaleY = prevScaleY;
|
||||
ss->screen = screen;
|
||||
ss->scaleX = scaleX;
|
||||
ss->scaleY = scaleY;
|
||||
|
||||
AwtToolkit::GetInstance().InvokeFunction(AwtWindow::_WindowDPIChange, ss);
|
||||
// global refs and ss are deleted in _WindowDPIChange
|
||||
|
||||
CATCH_BAD_ALLOC;
|
||||
}*/
|
||||
|
||||
/*
|
||||
* Class: sun_awt_windows_WLightweightFramePeer
|
||||
* Method: overrideNativeHandle
|
||||
|
||||
@@ -58,12 +58,6 @@ public:
|
||||
static jfieldID securityWarningHeightID;
|
||||
|
||||
/* sun.awt.windows.WWindowPeer field and method IDs */
|
||||
// The coordinates at the peer.
|
||||
static jfieldID sysXID;
|
||||
static jfieldID sysYID;
|
||||
static jfieldID sysWID;
|
||||
static jfieldID sysHID;
|
||||
|
||||
static jfieldID sysInsetsID;
|
||||
|
||||
static jfieldID windowTypeID;
|
||||
@@ -131,6 +125,7 @@ public:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
virtual void Reshape(int x, int y, int w, int h);
|
||||
virtual void Invalidate(RECT* r);
|
||||
virtual void Show();
|
||||
virtual void SetResizable(BOOL isResizable);
|
||||
@@ -138,7 +133,7 @@ public:
|
||||
virtual void RecalcNonClient();
|
||||
virtual void RedrawNonClient();
|
||||
virtual int GetScreenImOn();
|
||||
virtual BOOL CheckIfOnNewScreen();
|
||||
virtual void CheckIfOnNewScreen(BOOL force);
|
||||
virtual void Grab();
|
||||
virtual void Ungrab();
|
||||
virtual void Ungrab(BOOL doPost);
|
||||
@@ -180,8 +175,8 @@ public:
|
||||
virtual MsgRouting WmMove(int x, int y);
|
||||
virtual MsgRouting WmSize(UINT type, int w, int h);
|
||||
virtual MsgRouting WmSizing();
|
||||
/*virtual MsgRouting WmEnterSizeMove();
|
||||
virtual MsgRouting WmExitSizeMove();*/
|
||||
virtual MsgRouting WmEnterSizeMove();
|
||||
virtual MsgRouting WmExitSizeMove();
|
||||
virtual MsgRouting WmPaint(HDC hDC);
|
||||
virtual MsgRouting WmSettingChange(UINT wFlag, LPCTSTR pszSection);
|
||||
virtual MsgRouting WmNcCalcSize(BOOL fCalcValidRects,
|
||||
@@ -197,8 +192,6 @@ public:
|
||||
virtual MsgRouting HandleEvent(MSG *msg, BOOL synthetic);
|
||||
virtual void WindowResized();
|
||||
|
||||
MsgRouting WmDPIChanged(UINT xDPI, UINT yDPI, RECT* bounds);
|
||||
|
||||
static jboolean _RequestWindowFocus(void *param);
|
||||
|
||||
virtual BOOL AwtSetActiveWindow(BOOL isMouseEventCause = FALSE, UINT hittest = HTCLIENT);
|
||||
@@ -255,8 +248,6 @@ public:
|
||||
static void _RepositionSecurityWarning(void* param);
|
||||
static void _SetFullScreenExclusiveModeState(void* param);
|
||||
static void _GetNativeWindowSize(void* param);
|
||||
// static void _WindowDPIChange(void* param);
|
||||
static void _AdjustBoundsOnDPIChange(void* param);
|
||||
static void _OverrideHandle(void *param);
|
||||
|
||||
inline static BOOL IsResizing() {
|
||||
@@ -296,7 +287,6 @@ private:
|
||||
// from its hierarchy when shown. Currently applied to instances of
|
||||
// javax/swing/Popup$HeavyWeightWindow class.
|
||||
BOOL m_isIgnoringMouseEvents; // Make window transparent for mouse events (used for JCEF)
|
||||
RECT m_boundsOnDPIChange; /* bounds to asynchronously adjust on DPI change */
|
||||
|
||||
// SetTranslucency() is the setter for the following two fields
|
||||
BYTE m_opacity; // The opacity level. == 0xff by default (when opacity mode is disabled)
|
||||
@@ -412,19 +402,18 @@ protected:
|
||||
private:
|
||||
int m_screenNum;
|
||||
|
||||
/*typedef struct {
|
||||
typedef struct {
|
||||
jint screen;
|
||||
jfloat scaleX;
|
||||
jfloat scaleY;
|
||||
} ScaleRec;
|
||||
|
||||
BOOL m_winSizeMove;
|
||||
ScaleRec prevScaleRec;*/
|
||||
ScaleRec prevScaleRec;
|
||||
|
||||
void InitOwner(AwtWindow *owner);
|
||||
/*void CheckWindowDPIChange();
|
||||
void WindowDPIChange(int prevScreen, float prevScaleX, float prevScaleY,
|
||||
int newScreen, float scaleX, float scaleY); */
|
||||
void CheckWindowDPIChange();
|
||||
void WmDPIChanged(const LPARAM &lParam);
|
||||
|
||||
Type m_windowType;
|
||||
void InitType(JNIEnv *env, jobject peer);
|
||||
|
||||
@@ -41,6 +41,10 @@ extern const UINT SYSCOMMAND_IMM;
|
||||
* See winuser.h for details.
|
||||
*/
|
||||
|
||||
#ifndef WM_DPICHANGED
|
||||
#define WM_DPICHANGED 0x02E0
|
||||
#endif //WM_DPICHANGED
|
||||
|
||||
#ifndef WM_MOUSEWHEEL
|
||||
#define WM_MOUSEWHEEL 0x020A
|
||||
#endif //WM_MOUSEWHEEL
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Canvas;
|
||||
import java.awt.Checkbox;
|
||||
import java.awt.Choice;
|
||||
import java.awt.Component;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Label;
|
||||
import java.awt.List;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.ScrollPane;
|
||||
import java.awt.Scrollbar;
|
||||
import java.awt.TextArea;
|
||||
import java.awt.TextField;
|
||||
import java.awt.Window;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8211999
|
||||
* @run main/othervm SetComponentsBounds
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1 SetComponentsBounds
|
||||
* @run main/othervm -Dsun.java2d.uiScale=2.25 SetComponentsBounds
|
||||
*/
|
||||
public final class SetComponentsBounds {
|
||||
|
||||
private static final int X = 111;
|
||||
private static final int Y = 222;
|
||||
private static final int WIDTH = 321;
|
||||
private static final int HEIGHT = 123;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
var ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
for (GraphicsDevice gd : ge.getScreenDevices()) {
|
||||
test(gd.getDefaultConfiguration(), true);
|
||||
test(gd.getDefaultConfiguration(), false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(GraphicsConfiguration gc, boolean visible) throws Exception {
|
||||
Rectangle screen = gc.getBounds();
|
||||
Window frame = new Frame();
|
||||
try {
|
||||
frame.setLayout(null); // trigger use the minimum size of
|
||||
// the peer
|
||||
frame.setBounds(screen.x + 100, screen.y + 100, 500, 500);
|
||||
frame.add(new Button());
|
||||
frame.add(new Canvas());
|
||||
frame.add(new Checkbox());
|
||||
frame.add(new Choice());
|
||||
frame.add(new Label());
|
||||
frame.add(new List());
|
||||
frame.add(new Scrollbar());
|
||||
frame.add(new ScrollPane());
|
||||
frame.add(new TextArea());
|
||||
frame.add(new TextField());
|
||||
for (Component comp : frame.getComponents()) {
|
||||
comp.setBounds(X, Y, WIDTH, HEIGHT);
|
||||
}
|
||||
if (visible) {
|
||||
frame.setVisible(true);
|
||||
} else {
|
||||
frame.pack();
|
||||
}
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
checkGC(gc, frame);
|
||||
for (Component comp : frame.getComponents()) {
|
||||
Rectangle bounds = comp.getBounds();
|
||||
if (bounds.x != X || bounds.y != Y || bounds.width != WIDTH) {
|
||||
System.err.println("Screen bounds:" + screen);
|
||||
System.err.println("Component:" + comp);
|
||||
throw new RuntimeException("Wrong bounds:" + bounds);
|
||||
}
|
||||
if (bounds.height > HEIGHT) {
|
||||
// different check for HEIGHT, it depends on the font
|
||||
throw new RuntimeException("Wrong height:" + bounds.height);
|
||||
}
|
||||
checkGC(gc, comp);
|
||||
}
|
||||
} finally {
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkGC(GraphicsConfiguration gc, Component comp) {
|
||||
GraphicsConfiguration compGC = comp.getGraphicsConfiguration();
|
||||
if (compGC != gc) {
|
||||
System.err.println("Expected GC:" + gc);
|
||||
System.err.println("Actual GC:" + compGC);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 6345003 8171363
|
||||
* @bug 6345003 8171363 8211999
|
||||
* @summary grab problems with EmbeddedFrame
|
||||
* @requires (os.family == "windows")
|
||||
* @modules java.desktop/java.awt.peer
|
||||
@@ -67,6 +67,7 @@ public class EmbeddedFrameGrabTest {
|
||||
final Frame frame = new Frame("AWT Frame");
|
||||
frame.pack();
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
FramePeer frame_peer = AWTAccessor.getComponentAccessor()
|
||||
.getPeer(frame);
|
||||
Class comp_peer_class
|
||||
@@ -88,6 +89,7 @@ public class EmbeddedFrameGrabTest {
|
||||
final Panel p = new Panel();
|
||||
p.setLayout(new BorderLayout());
|
||||
embedded_frame.add(p, BorderLayout.CENTER);
|
||||
embedded_frame.setBounds(0, 0, 150, 150);
|
||||
embedded_frame.validate();
|
||||
p.add(combo);
|
||||
p.validate();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
@@ -30,7 +31,7 @@ import java.awt.Toolkit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8176359 8231564
|
||||
* @bug 8176359 8231564 8211999
|
||||
* @key headful
|
||||
* @requires (os.family == "windows" | os.family == "mac")
|
||||
* @summary setMaximizedBounds() should work if set to the screen other than
|
||||
@@ -58,15 +59,23 @@ public final class MaximizedToOppositeScreenSmall {
|
||||
Rectangle framAt = gd1.getDefaultConfiguration().getBounds();
|
||||
framAt.grow(-framAt.width / 2 + 100, -framAt.height / 2 + 100);
|
||||
for (GraphicsDevice gd2 : gds) {
|
||||
Rectangle maxTo = gd2.getDefaultConfiguration().getBounds();
|
||||
maxTo.grow(-maxTo.width / 2 + 120, -maxTo.height / 2 + 120);
|
||||
Frame frame = new Frame(gd1.getDefaultConfiguration());
|
||||
try {
|
||||
frame.setLayout(null); // trigger use the minimum size of
|
||||
// the peer
|
||||
frame.setBounds(framAt);
|
||||
|
||||
frame.setVisible(true);
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
|
||||
Dimension minimumSize = frame.getMinimumSize();
|
||||
minimumSize.width = Math.max(minimumSize.width, 120);
|
||||
minimumSize.height = Math.max(minimumSize.height, 120);
|
||||
Rectangle maxTo = gd2.getDefaultConfiguration().getBounds();
|
||||
maxTo.grow(-maxTo.width / 2 + minimumSize.width,
|
||||
-maxTo.height / 2 + minimumSize.height);
|
||||
|
||||
frame.setMaximizedBounds(maxTo);
|
||||
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
robot.waitForIdle();
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8211999
|
||||
* @key headful
|
||||
* @summary verifies the full-screen window bounds and graphics configuration
|
||||
*/
|
||||
public final class FullscreenWindowProps {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
var ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice gd = ge.getDefaultScreenDevice();
|
||||
|
||||
if (!gd.isFullScreenSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Frame frame = new Frame() {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
super.paint(g);
|
||||
g.setColor(Color.GREEN);
|
||||
g.fillRect(0, 0, getWidth(), getHeight());
|
||||
}
|
||||
};
|
||||
try {
|
||||
frame.setBackground(Color.MAGENTA);
|
||||
frame.setVisible(true);
|
||||
gd.setFullScreenWindow(frame);
|
||||
Thread.sleep(4000);
|
||||
|
||||
for (DisplayMode dm : gd.getDisplayModes()) {
|
||||
if (dm.getWidth() == 1024 && dm.getHeight() == 768) {
|
||||
gd.setDisplayMode(dm);
|
||||
Thread.sleep(4000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GraphicsConfiguration frameGC = frame.getGraphicsConfiguration();
|
||||
Rectangle frameBounds = frame.getBounds();
|
||||
|
||||
GraphicsConfiguration screenGC = gd.getDefaultConfiguration();
|
||||
Rectangle screenBounds = screenGC.getBounds();
|
||||
|
||||
if (frameGC != screenGC) {
|
||||
System.err.println("Expected: " + screenGC);
|
||||
System.err.println("Actual: " + frameGC);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
checkSize(frameBounds.x, screenBounds.x, "x");
|
||||
checkSize(frameBounds.y, screenBounds.y, "Y");
|
||||
checkSize(frameBounds.width, screenBounds.width, "width");
|
||||
checkSize(frameBounds.height, screenBounds.height, "height");
|
||||
} finally {
|
||||
gd.setFullScreenWindow(null);
|
||||
frame.dispose();
|
||||
Thread.sleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkSize(int actual, int expected, String prop) {
|
||||
if (Math.abs(actual - expected) > 30) { // let's allow size variation,
|
||||
// the bug is reproduced anyway
|
||||
System.err.println("Expected: " + expected);
|
||||
System.err.println("Actual: " + actual);
|
||||
throw new RuntimeException(prop + " is wrong");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Frame;
|
||||
import java.awt.List;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 4909485 8211999
|
||||
* @key headful
|
||||
*/
|
||||
public final class ListMultipleSelectTest {
|
||||
|
||||
private static List aList;
|
||||
private static Panel panel;
|
||||
private static Point p;
|
||||
private static Robot robot;
|
||||
private static int[] selected;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Frame frame = new Frame();
|
||||
try {
|
||||
panel = new Panel();
|
||||
aList = new List();
|
||||
aList.add("Test item1");
|
||||
aList.add("Test item2");
|
||||
aList.add("Test item3");
|
||||
aList.add("Test item4");
|
||||
|
||||
frame.setLayout(new FlowLayout()); //list should fill whole frame's space
|
||||
panel.add(aList);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
panel.setVisible(true);
|
||||
frame.add(panel);
|
||||
frame.setVisible(true);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(" InterruptedException. Test failed. ");
|
||||
}
|
||||
|
||||
Dimension listSize = aList.getSize();
|
||||
p = aList.getLocationOnScreen();
|
||||
int stepY = listSize.height / aList.getItemCount();
|
||||
|
||||
// System.out.println("itemCount = "+aList.getItemCount());
|
||||
// System.out.println("Size Of aList="+ listSize);
|
||||
// System.out.println("stepY = "+stepY);
|
||||
// System.out.println("Point:" +p);
|
||||
System.out.println("Multiple mode is ON");
|
||||
aList.setMultipleMode(true);
|
||||
//=================================================
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(0);
|
||||
robot.setAutoWaitForIdle(false);
|
||||
robot.delay(10);
|
||||
robot.waitForIdle();
|
||||
|
||||
//=================================================
|
||||
|
||||
for (int i = 0; i < aList.getItemCount(); i++) {
|
||||
//select all items in the List
|
||||
mousePress(p.x + listSize.width / 2, p.y + stepY / 2 + stepY * i);
|
||||
}
|
||||
|
||||
selected = aList.getSelectedIndexes();
|
||||
System.out.println("Multiple mode is ON");
|
||||
aList.setMultipleMode(true);
|
||||
int[] newSelected = aList.getSelectedIndexes();
|
||||
if (!java.util.Arrays.equals(newSelected, selected)) {
|
||||
throw new RuntimeException(" Incorrect item remains selected " +
|
||||
"after setMultipleMode(true). ");
|
||||
}
|
||||
|
||||
aList.setMultipleMode(false);
|
||||
System.out.println("Multiple mode is OFF");
|
||||
selected = aList.getSelectedIndexes();
|
||||
if (selected[0] != 3 || selected.length != 1) {
|
||||
throw new RuntimeException(" Incorrect item remains selected " +
|
||||
"after setMultipleMode(false) or it is more then one " +
|
||||
"item remaining.Forward. ");
|
||||
}
|
||||
|
||||
System.out.println("Multiple mode is ON");
|
||||
aList.setMultipleMode(true);
|
||||
|
||||
if (selected[0] != 3 || selected.length != 1) {
|
||||
throw new RuntimeException(" Incorrect item remains selected " +
|
||||
"after setMultipleMode(true) or it is more then one " +
|
||||
"item remaining. ");
|
||||
}
|
||||
|
||||
deselectAll();
|
||||
for (int i = aList.getItemCount() - 1; i >= 0; i--) {
|
||||
mousePress(p.x + listSize.width / 2, p.y + stepY / 2 + stepY * i);
|
||||
}
|
||||
|
||||
System.out.println("Multiple mode is OFF");
|
||||
aList.setMultipleMode(false);
|
||||
|
||||
selected = aList.getSelectedIndexes();
|
||||
if (selected[0] != 0 || selected.length != 1) {
|
||||
throw new RuntimeException(" Incorrect item remains selected " +
|
||||
"after setMultipleMode(false) or it is more then one " +
|
||||
"item remaining.Backward. ");
|
||||
}
|
||||
System.out.println("Test succeeded.");
|
||||
} finally {
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static void mousePress(int x, int y) {
|
||||
robot.mouseMove(x, y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.delay(1000);
|
||||
}
|
||||
|
||||
private static void deselectAll() {
|
||||
for (int i = 0; i < selected.length; i++) {
|
||||
aList.deselect(selected[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
/*
|
||||
@test
|
||||
@key headful
|
||||
@bug 8017472
|
||||
@bug 8017472 8211999
|
||||
@summary MouseEvent has wrong coordinates when using multiple monitors
|
||||
@run main MouseEventTest
|
||||
*/
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
@@ -38,7 +40,7 @@ import javax.imageio.ImageIO;
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8215105
|
||||
* @bug 8215105 8211999
|
||||
* @summary tests that Robot can capture the common colors without artifacts
|
||||
*/
|
||||
public final class CheckCommonColors {
|
||||
@@ -48,16 +50,20 @@ public final class CheckCommonColors {
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
try {
|
||||
test();
|
||||
} finally {
|
||||
frame.dispose();
|
||||
var ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
for (GraphicsDevice gd : ge.getScreenDevices()) {
|
||||
try {
|
||||
test(gd.getDefaultConfiguration().getBounds());
|
||||
} finally {
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void test() {
|
||||
private static void test(Rectangle screen) {
|
||||
frame.setSize(400, 400);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setLocation((int)screen.getCenterX() - 200,
|
||||
(int)screen.getCenterY() - 200);
|
||||
frame.setUndecorated(true);
|
||||
for (final Color color : List.of(Color.WHITE, Color.LIGHT_GRAY,
|
||||
Color.GRAY, Color.DARK_GRAY,
|
||||
@@ -69,16 +75,24 @@ public final class CheckCommonColors {
|
||||
robot.waitForIdle();
|
||||
frame.setBackground(color);
|
||||
frame.setVisible(true);
|
||||
checkPixels(color);
|
||||
checkPixels(color, true);
|
||||
checkPixels(color, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkPixels(final Color color) {
|
||||
private static void checkPixels(final Color color, boolean useRect) {
|
||||
System.out.println("color = " + color + ", useRect = " + useRect);
|
||||
int attempt = 0;
|
||||
while (true) {
|
||||
Point p = frame.getLocationOnScreen();
|
||||
p.translate(frame.getWidth() / 2, frame.getHeight() / 2);
|
||||
Color pixel = robot.getPixelColor(p.x, p.y);
|
||||
Color pixel;
|
||||
Rectangle rect = new Rectangle(p.x, p.y, 1, 1);
|
||||
if (useRect) {
|
||||
BufferedImage bi = robot.createScreenCapture(rect);
|
||||
pixel = new Color(bi.getRGB(0, 0));
|
||||
} else {
|
||||
pixel = robot.getPixelColor(rect.x, rect.y);
|
||||
}
|
||||
if (color.equals(pixel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.awt.Robot;
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8201364 8232433
|
||||
* @bug 8201364 8232433 8211999
|
||||
* @summary Component.getLocation() should returns correct location if
|
||||
* Component.setBounds() was ignored by the OS
|
||||
*/
|
||||
@@ -64,8 +64,11 @@ public final class LocationAtScreenCorner {
|
||||
Rectangle bounds = device.getDefaultConfiguration().getBounds();
|
||||
test(robot, frame, bounds.x, bounds.y);
|
||||
test(robot, frame, bounds.width, bounds.y);
|
||||
test(robot, frame, bounds.x + bounds.width, bounds.y);
|
||||
test(robot, frame, bounds.x, bounds.height);
|
||||
test(robot, frame, bounds.x, bounds.y + bounds.height);
|
||||
test(robot, frame, bounds.width, bounds.height);
|
||||
test(robot, frame, bounds.x + bounds.width, bounds.y + bounds.height);
|
||||
}
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
95
test/jdk/java/awt/Window/SlowMotion/SlowMotion.java
Normal file
95
test/jdk/java/awt/Window/SlowMotion/SlowMotion.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8211999
|
||||
* @run main/timeout=300 SlowMotion
|
||||
* @summary places the window on the screen outside of any insets, and waits to
|
||||
* catch any strange window moving
|
||||
*/
|
||||
public final class SlowMotion {
|
||||
|
||||
// some additional space, if getScreenInsets() does not work, say on Linux
|
||||
private static final int SAFE = 100;
|
||||
private static final int HEIGHT = 350;
|
||||
private static final int WIDTH = 279;
|
||||
private static Robot robot;
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice[] sds = ge.getScreenDevices();
|
||||
|
||||
for (GraphicsDevice sd : sds) {
|
||||
GraphicsConfiguration gc = sd.getDefaultConfiguration();
|
||||
Rectangle bounds = gc.getBounds();
|
||||
bounds.translate(SAFE, SAFE);
|
||||
Point point = new Point(bounds.x, bounds.y);
|
||||
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
|
||||
while (point.y < bounds.y + bounds.height - insets.bottom - HEIGHT - SAFE * 2) {
|
||||
while (point.x < bounds.x + bounds.width - insets.right - WIDTH - SAFE * 2) {
|
||||
test(point, new Frame());
|
||||
test(point, new Window(null));
|
||||
test(point, new Dialog((Dialog) null));
|
||||
point.translate(bounds.width / 6, 0);
|
||||
}
|
||||
point.setLocation(bounds.x, point.y + bounds.height / 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(final Point loc, Window window) {
|
||||
try {
|
||||
window.setBounds(loc.x, loc.y, WIDTH, HEIGHT);
|
||||
window.setVisible(true);
|
||||
robot.delay(1000); // intentionally very slow, we try to catch
|
||||
// very very last suspicion event
|
||||
Rectangle bounds = window.getBounds();
|
||||
if (loc.x != bounds.x || loc.y != bounds.y
|
||||
|| bounds.width != WIDTH || bounds.height != HEIGHT) {
|
||||
System.err.println("Component = " + window);
|
||||
System.err.println("Actual bounds = " + bounds);
|
||||
System.err.println("Expected location = " + loc);
|
||||
System.err.println("Expected width = " + WIDTH);
|
||||
System.err.println("Expected height = " + HEIGHT);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
} finally {
|
||||
window.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.Window;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8211999
|
||||
* @summary The test creates the packed/unpacked top level components on the
|
||||
* different screens and compares their bounds
|
||||
* @run main/othervm WindowSizeDifferentScreens
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1 WindowSizeDifferentScreens
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1.25 WindowSizeDifferentScreens
|
||||
*/
|
||||
public final class WindowSizeDifferentScreens {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
test("window");
|
||||
test("dialog");
|
||||
test("frame");
|
||||
}
|
||||
|
||||
private static void test(String top) throws Exception {
|
||||
var ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
Robot robot = new Robot();
|
||||
Window main = getTopLevel(top);
|
||||
try {
|
||||
main.setVisible(true);
|
||||
robot.waitForIdle();
|
||||
main.setSize(500, 500);
|
||||
robot.waitForIdle();
|
||||
for (GraphicsDevice gd : ge.getScreenDevices()) {
|
||||
Rectangle bounds = gd.getDefaultConfiguration().getBounds();
|
||||
Point point = bounds.getLocation();
|
||||
point.translate(100, 100);
|
||||
main.setLocation(point);
|
||||
main.setBackground(Color.RED);
|
||||
robot.waitForIdle();
|
||||
|
||||
Window packed = getTopLevel(top);
|
||||
Window unpacked = getTopLevel(top);
|
||||
try {
|
||||
packed.pack();
|
||||
robot.waitForIdle();
|
||||
packed.setBackground(Color.GREEN);
|
||||
unpacked.setBackground(Color.BLUE);
|
||||
packed.setSize(500, 500);
|
||||
unpacked.setSize(500, 500);
|
||||
packed.setLocation(point);
|
||||
unpacked.setLocation(point);
|
||||
robot.waitForIdle();
|
||||
packed.setVisible(true);
|
||||
unpacked.setVisible(true);
|
||||
robot.waitForIdle();
|
||||
Rectangle mBounds = main.getBounds();
|
||||
Rectangle pBounds = packed.getBounds();
|
||||
Rectangle uBounds = unpacked.getBounds();
|
||||
|
||||
if (!mBounds.equals(uBounds) ||
|
||||
!mBounds.equals(pBounds)) {
|
||||
System.err.println("Expected bounds: " + mBounds);
|
||||
System.err.println("Actual unpacked: " + uBounds);
|
||||
System.err.println("Actual packed: " + pBounds);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
} finally {
|
||||
packed.dispose();
|
||||
unpacked.dispose();
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
main.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static Window getTopLevel(String top) {
|
||||
switch (top) {
|
||||
case "window": return new Window(null);
|
||||
case "dialog": return new Dialog((Dialog) null);
|
||||
case "frame" : return new Frame();
|
||||
default: throw new IllegalArgumentException("Unexpected: " + top);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,10 @@
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Frame;
|
||||
import java.awt.GraphicsConfiguration;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
@@ -47,7 +47,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 4955110 8238575
|
||||
* @bug 4955110 8238575 8211999
|
||||
* @summary tests that DragSourceDragEvent.getDropAction() accords to its new
|
||||
* spec (does not depend on the user drop action)
|
||||
* @library ../../regtesthelpers
|
||||
@@ -57,6 +57,7 @@ import test.java.awt.regtesthelpers.Util;
|
||||
*/
|
||||
public final class Button2DragTest {
|
||||
|
||||
private static final int SIZE = 200;
|
||||
private volatile boolean dropSuccess;
|
||||
private volatile boolean locationValid = true;
|
||||
|
||||
@@ -79,8 +80,8 @@ public final class Button2DragTest {
|
||||
final DragSourceListener dragSourceListener = new DragSourceListener() {
|
||||
private void checkLocation(DragSourceEvent dsde) {
|
||||
if (!frame.getBounds().contains(dsde.getLocation())) {
|
||||
System.err.println("Expected in" + frame.getBounds());
|
||||
System.err.println("Actual" + dsde.getLocation());
|
||||
System.err.println("Expected in: " + frame.getBounds());
|
||||
System.err.println("Actual: " + dsde.getLocation());
|
||||
locationValid = false;
|
||||
}
|
||||
}
|
||||
@@ -130,8 +131,10 @@ public final class Button2DragTest {
|
||||
|
||||
frame.setBackground(Color.GREEN);
|
||||
frame.setUndecorated(true);
|
||||
frame.setSize(200, 200);
|
||||
frame.setLocationRelativeTo(null);
|
||||
Rectangle screen = frame.getGraphicsConfiguration().getBounds();
|
||||
int x = (int) (screen.getCenterX() - SIZE / 2);
|
||||
int y = (int) (screen.getCenterY() - SIZE / 2);
|
||||
frame.setBounds(x, y, SIZE, SIZE);
|
||||
frame.setVisible(true);
|
||||
|
||||
Robot robot = Util.createRobot();
|
||||
|
||||
@@ -24,7 +24,10 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.event.InputEvent;
|
||||
import javax.swing.JFrame;
|
||||
@@ -35,13 +38,15 @@ import javax.swing.SwingUtilities;
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8149849
|
||||
* @bug 8149849 8211999
|
||||
* @summary [hidpi] DnD issues (cannot DnD from JFileChooser to JEditorPane or
|
||||
* other text component) when scale > 1
|
||||
* @run main/othervm DNDTextToScaledArea
|
||||
* @run main/othervm -Dsun.java2d.uiScale=2 DNDTextToScaledArea
|
||||
*/
|
||||
public class DNDTextToScaledArea {
|
||||
|
||||
private static final int SIZE = 300;
|
||||
private static final String TEXT = "ABCDEFGH";
|
||||
private static JFrame frame;
|
||||
private static JTextArea srcTextArea;
|
||||
@@ -51,10 +56,17 @@ public class DNDTextToScaledArea {
|
||||
private static volatile boolean passed = false;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
var lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
for (GraphicsDevice device : lge.getScreenDevices()) {
|
||||
test(device);
|
||||
}
|
||||
}
|
||||
|
||||
SwingUtilities.invokeAndWait(DNDTextToScaledArea::createAndShowGUI);
|
||||
private static void test(GraphicsDevice device) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(150);
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> createAndShowGUI(device));
|
||||
robot.waitForIdle();
|
||||
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
@@ -62,6 +74,11 @@ public class DNDTextToScaledArea {
|
||||
dstPoint = getPoint(dstTextArea, 0.75);
|
||||
});
|
||||
robot.waitForIdle();
|
||||
// check the destination
|
||||
robot.mouseMove(dstPoint.x, dstPoint.y);
|
||||
robot.mousePress(InputEvent.BUTTON1_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_MASK);
|
||||
robot.waitForIdle();
|
||||
|
||||
dragAndDrop(robot, srcPoint, dstPoint);
|
||||
robot.waitForIdle();
|
||||
@@ -77,11 +94,12 @@ public class DNDTextToScaledArea {
|
||||
}
|
||||
}
|
||||
|
||||
private static void createAndShowGUI() {
|
||||
|
||||
frame = new JFrame();
|
||||
frame.setSize(300, 300);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
private static void createAndShowGUI(GraphicsDevice device) {
|
||||
frame = new JFrame(device.getDefaultConfiguration());
|
||||
Rectangle screen = device.getDefaultConfiguration().getBounds();
|
||||
int x = (int) (screen.getCenterX() - SIZE / 2);
|
||||
int y = (int) (screen.getCenterY() - SIZE / 2);
|
||||
frame.setBounds(x, y, SIZE, SIZE);
|
||||
|
||||
JPanel panel = new JPanel(new BorderLayout());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user