Compare commits

...

1 Commits

Author SHA1 Message Date
Ivan Lopatin
31da778bbe JBR-2687: Fixed problems with maximizing to a new screen 2021-11-08 10:46:13 +07:00
6 changed files with 30 additions and 19 deletions

View File

@@ -35,6 +35,7 @@ import java.awt.peer.FramePeer;
import java.security.AccessController;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
import sun.awt.im.InputMethodManager;
import sun.security.action.GetPropertyAction;
@@ -124,15 +125,16 @@ class WFramePeer extends WWindowPeer implements FramePeer {
@Override
public void displayChanged() {
super.displayChanged();
updateIcon();
SunToolkit.executeOnEventHandlerThread(target, this::updateIcon);
if (!screenChangedFlag &&
(getExtendedState() & Frame.MAXIMIZED_BOTH) != 0 &&
(getExtendedState() & Frame.ICONIFIED) == 0)
{
(getExtendedState() & Frame.ICONIFIED) == 0) {
// A workaround to update the maximized state of the frame
int state = getExtendedState();
setState(Frame.NORMAL);
setState(state);
SunToolkit.executeOnEventHandlerThread(target, ()->{
int state = getExtendedState();
setState(Frame.NORMAL);
setState(state);
});
}
}

View File

@@ -37,6 +37,7 @@ 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;
@@ -89,7 +90,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
private TranslucentWindowPainter painter;
private int screenNum;
private int screenNum = 0;
protected boolean screenChangedFlag;
/*
@@ -215,6 +216,13 @@ 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
@@ -630,9 +638,6 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
public void updateGC() {
int scrn = getScreenImOn();
screenChangedFlag = scrn != screenNum;
screenNum = scrn;
if (screenLog.isLoggable(PlatformLogger.Level.FINER)) {
log.finer("Screen number: " + scrn);
}
@@ -701,6 +706,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();

View File

@@ -981,8 +981,8 @@ void AwtComponent::ReshapeNoScale(int x, int y, int w, int h)
int usrY = y;
AwtWin32GraphicsDevice* device = UGetDeviceByBounds(URectBounds(x, y, w, h, USER_SPACE), this);
x = device->ScaleUpX(x, RELATIVITY_FOR_COMP_XY(this));
y = device->ScaleUpY(y, RELATIVITY_FOR_COMP_XY(this));
x = device->ScaleUpX(x);
y = device->ScaleUpY(y);
w = device->ScaleUpX(w);
h = device->ScaleUpY(h);
@@ -2484,7 +2484,7 @@ void AwtComponent::WmTouchHandler(const TOUCHINPUT& touchInput)
const jint scrollModifiers = modifiers & ~java_awt_event_InputEvent_SHIFT_DOWN_MASK;
SendMouseWheelEventFromTouch(p, scrollModifiers, sun_awt_event_TouchEvent_TOUCH_UPDATE, deltaY);
}
const jint deltaX = ScaleDownX(static_cast<int>(m_lastTouchPoint.x - p.x));
if (deltaX != 0) {
const jint scrollModifiers = modifiers | java_awt_event_InputEvent_SHIFT_DOWN_MASK;

View File

@@ -1251,7 +1251,7 @@ MsgRouting AwtFrame::WmSysCommand(UINT uCmdType, int xPos, int yPos)
}
MsgRouting AwtFrame::WmDPIChanged(UINT xDPI, UINT yDPI, RECT* bounds) {
if (isZoomed()) {
if (isZoomed() && !m_maxBoundsSet) {
Devices::InstanceAccess devices;
AwtWin32GraphicsDevice* device = devices->GetDevice(AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd()));
if (device) {

View File

@@ -84,9 +84,10 @@ RECT AwtWin32GraphicsConfig::getMonitorBounds(int screen, const UCoordSpace& spa
AwtWin32GraphicsDevice *device = devices->GetDevice(screen);
if (TRUE == MonitorBounds(AwtWin32GraphicsDevice::GetMonitor(screen), &rRW)) {
// don't scale xy to avoid overlapping of the multi-dpi-monitors bounds in the user space
int x = rRW.left;
int y = rRW.top;
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

View File

@@ -1920,8 +1920,8 @@ MsgRouting AwtWindow::WmMove(int x, int y)
URectBounds rect = UGetWindowRectBounds(GetHWnd());
AwtWin32GraphicsDevice* device = UGetDeviceByBounds(rect, this);
int usrX = device->ScaleDownDX(rect.x);
int usrY = device->ScaleDownDY(rect.y);
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();