8161273: [hidpi] The frame insets size is wrong on Linux HiDPI because it is not scaled
Reviewed-by: alexsch
This commit is contained in:
parent
6ac698e26b
commit
cb959adf02
@ -266,6 +266,12 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
return new Insets(i.top, i.left, i.bottom, i.right);
|
||||
}
|
||||
|
||||
private Insets copyAndScaleDown(Insets i) {
|
||||
return new Insets(scaleDown(i.top), scaleDown(i.left),
|
||||
scaleDown(i.bottom), scaleDown(i.right));
|
||||
}
|
||||
|
||||
|
||||
// insets which we get from WM (e.g from _NET_FRAME_EXTENTS)
|
||||
private Insets wm_set_insets;
|
||||
|
||||
@ -289,7 +295,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
|
||||
if (wm_set_insets != null) {
|
||||
wm_set_insets = copy(wm_set_insets);
|
||||
wm_set_insets = copyAndScaleDown(wm_set_insets);
|
||||
}
|
||||
return wm_set_insets;
|
||||
}
|
||||
@ -386,6 +392,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
} else {
|
||||
correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent());
|
||||
if (correctWM != null) {
|
||||
correctWM = copyAndScaleDown(correctWM);
|
||||
}
|
||||
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
if (correctWM != null) {
|
||||
@ -470,6 +479,9 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
Insets res = getWMSetInsets(null);
|
||||
if (res == null) {
|
||||
res = XWM.getWM().guessInsets(this);
|
||||
if (res != null) {
|
||||
res = copyAndScaleDown(res);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -756,7 +768,7 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
}
|
||||
}
|
||||
if (correctWM != null) {
|
||||
handleCorrectInsets(correctWM);
|
||||
handleCorrectInsets(copyAndScaleDown(correctWM));
|
||||
} else {
|
||||
//Only one attempt to correct insets is made (to lower risk)
|
||||
//if insets are still not available we simply set the flag
|
||||
|
@ -23,8 +23,9 @@
|
||||
|
||||
/**
|
||||
* @test @summary setLocationRelativeTo stopped working in Ubuntu 13.10 (Unity)
|
||||
* @bug 8036915
|
||||
* @run main GetScreenLocationTest
|
||||
* @bug 8036915 8161273
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1 GetScreenLocationTest
|
||||
* @run main/othervm -Dsun.java2d.uiScale=2 GetScreenLocationTest
|
||||
*/
|
||||
import java.awt.*;
|
||||
|
||||
@ -33,28 +34,28 @@ public class GetScreenLocationTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
Window frame = null;
|
||||
for(int i = 0; i < 50; i++) {
|
||||
for(int i = 0; i < 30; i++) {
|
||||
if(frame != null) frame.dispose();
|
||||
frame = new Dialog((Frame)null);
|
||||
frame.setBounds(0, 0, 200, 200);
|
||||
frame.setBounds(0, 0, 200, 100);
|
||||
frame.setVisible(true);
|
||||
robot.waitForIdle();
|
||||
robot.delay(200);
|
||||
frame.setLocation(321, 321);
|
||||
frame.setLocation(321, 121);
|
||||
robot.waitForIdle();
|
||||
robot.delay(200);
|
||||
Dimension size = frame.getSize();
|
||||
if(size.width != 200 || size.height != 200) {
|
||||
if(size.width != 200 || size.height != 100) {
|
||||
frame.dispose();
|
||||
throw new RuntimeException("getSize() is wrong " + size);
|
||||
}
|
||||
Rectangle r = frame.getBounds();
|
||||
frame.dispose();
|
||||
if(r.x != 321 || r.y != 321) {
|
||||
if(r.x != 321 || r.y != 121) {
|
||||
throw new RuntimeException("getLocation() returns " +
|
||||
"wrong coordinates " + r.getLocation());
|
||||
}
|
||||
if(r.width != 200 || r.height != 200) {
|
||||
if(r.width != 200 || r.height != 100) {
|
||||
throw new RuntimeException("getSize() is wrong " + r.getSize());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user