mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JRE-938 [windows] Frame.setMaximizedBounds not hidpi-aware
(cherry picked from commit cc97899923320e1fa17f5e44975c4a0f0ba51014)
(cherry picked from commit ccfe65be7f)
This commit is contained in:
committed by
alexey.ushakov@jetbrains.com
parent
0da95d2c41
commit
183e210205
@@ -1475,6 +1475,10 @@ void AwtFrame::_SetMaximizedBounds(void *param)
|
||||
if (::IsWindow(f->GetHWnd()))
|
||||
{
|
||||
DASSERT(!::IsBadReadPtr(f, sizeof(AwtFrame)));
|
||||
x = f->ScaleUpAbsX(x);
|
||||
y = f->ScaleUpAbsY(y);
|
||||
width = f->ScaleUpX(width);
|
||||
height = f->ScaleUpY(height);
|
||||
f->SetMaximizedBounds(x, y, width, height);
|
||||
}
|
||||
ret:
|
||||
|
||||
54
test/jdk/java/awt/hidpi/SetMaximizedBoundsTest.java
Normal file
54
test/jdk/java/awt/hidpi/SetMaximizedBoundsTest.java
Normal file
@@ -0,0 +1,54 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import sun.awt.SunToolkit;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/* @test
|
||||
* bug JRE-938
|
||||
* @summary Tests that Frame.setMaximizedBounds meets HiDPI.
|
||||
* @author Anton Tarasov
|
||||
* @requires (os.family == "windows")
|
||||
* @modules java.desktop/sun.awt
|
||||
* @run main/othervm -Dsun.java2d.uiScale.enabled=true
|
||||
* -Dsun.java2d.uiScale=2
|
||||
* SetMaximizedBoundsTest
|
||||
*/
|
||||
public class SetMaximizedBoundsTest {
|
||||
private static volatile JFrame frame;
|
||||
private static final Rectangle MAX_BOUNDS = new Rectangle(100, 100, 500, 500);
|
||||
private static volatile Rectangle testBounds;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
|
||||
EventQueue.invokeAndWait(SetMaximizedBoundsTest::show);
|
||||
|
||||
((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
|
||||
|
||||
EventQueue.invokeAndWait(SetMaximizedBoundsTest::maximize);
|
||||
|
||||
((SunToolkit)Toolkit.getDefaultToolkit()).realSync();
|
||||
|
||||
EventQueue.invokeAndWait(SetMaximizedBoundsTest::test);
|
||||
|
||||
if (!MAX_BOUNDS.equals(testBounds)) {
|
||||
throw new RuntimeException("Test FAILED: bad bounds " + testBounds);
|
||||
}
|
||||
System.out.println("Test PASSED");
|
||||
}
|
||||
|
||||
private static void show() {
|
||||
frame = new JFrame("frame");
|
||||
frame.setBounds(200, 200, 200, 200);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void maximize() {
|
||||
frame.setMaximizedBounds(MAX_BOUNDS);
|
||||
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||
}
|
||||
|
||||
private static void test() {
|
||||
testBounds = frame.getBounds();
|
||||
frame.dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user