JBR-4150 IDE regularly locks up at sun.lwawt.macosx.LWCToolkit.getScreenInsets

Restored caching screen insets. Added handling of dock resize.
This commit is contained in:
Alexey Ushakov
2021-12-28 22:50:09 +01:00
committed by jbrbot
parent eaf3433ff9
commit 6203371298
3 changed files with 14 additions and 7 deletions

View File

@@ -65,6 +65,7 @@ import java.util.List;
import java.util.Map;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.java2d.SunGraphicsEnvironment;
class _AppEventHandler {
private static final int NOTIFY_ABOUT = 1;
@@ -83,6 +84,7 @@ class _AppEventHandler {
private static final int NOTIFY_SCREEN_WAKE = 14;
private static final int NOTIFY_SYSTEM_SLEEP = 15;
private static final int NOTIFY_SYSTEM_WAKE = 16;
private static final int NOTIFY_SCREEN_CHANGE_PARAMETERS = 17;
private static final int REGISTER_USER_SESSION = 1;
private static final int REGISTER_SCREEN_SLEEP = 2;
@@ -264,6 +266,10 @@ class _AppEventHandler {
case NOTIFY_SYSTEM_WAKE:
instance.systemSleepDispatcher.dispatch(new _NativeEvent(Boolean.FALSE));
break;
case NOTIFY_SCREEN_CHANGE_PARAMETERS:
((SunGraphicsEnvironment)SunGraphicsEnvironment.
getLocalGraphicsEnvironment()).displayChanged();
break;
default:
System.err.println("EAWT unknown native notification: " + code);
break;

View File

@@ -56,6 +56,7 @@ public final class CGraphicsDevice extends GraphicsDevice
private volatile double yResolution;
private volatile Rectangle bounds;
private volatile int scale;
private volatile Insets screenInsets;
private GraphicsConfiguration config;
private static boolean metalPipelineEnabled = false;
@@ -183,13 +184,7 @@ public final class CGraphicsDevice extends GraphicsDevice
}
public Insets getScreenInsets() {
// the insets are queried synchronously and are not cached
// since there are no Quartz or Cocoa means to receive notifications
// on insets changes (e.g. when the Dock is resized):
// the existing CGDisplayReconfigurationCallBack is not notified
// as well as the NSApplicationDidChangeScreenParametersNotification
// is fired on the Dock location changes only
return nativeGetScreenInsets(displayID);
return screenInsets;
}
public int getScaleFactor() {
@@ -212,6 +207,7 @@ public final class CGraphicsDevice extends GraphicsDevice
xResolution = nativeGetXResolution(displayID);
yResolution = nativeGetYResolution(displayID);
bounds = nativeGetBounds(displayID).getBounds(); //does integer rounding
screenInsets = nativeGetScreenInsets(displayID);
initScaleFactor();
resizeFSWindow(getFullScreenWindow(), bounds);
//TODO configs?

View File

@@ -258,6 +258,7 @@ AWT_ASSERT_APPKIT_THREAD;
[ctr addObserver:clz selector:@selector(_appDidDeactivate) name:NSApplicationDidResignActiveNotification object:nil];
[ctr addObserver:clz selector:@selector(_appDidHide) name:NSApplicationDidHideNotification object:nil];
[ctr addObserver:clz selector:@selector(_appDidUnhide) name:NSApplicationDidUnhideNotification object:nil];
[ctr addObserver:clz selector:@selector(_didChangeScreenParameters) name:NSApplicationDidChangeScreenParametersNotification object:nil];
return self;
}
@@ -491,6 +492,10 @@ AWT_ASSERT_APPKIT_THREAD;
}
}
+ (void)_didChangeScreenParameters {
[ApplicationDelegate _notifyJava:com_apple_eawt__AppEventHandler_NOTIFY_SCREEN_CHANGE_PARAMETERS];
}
// Retrieves the menu to be attached to the Dock icon (AppKit callback)
- (NSMenu *)applicationDockMenu:(NSApplication *)sender {
AWT_ASSERT_APPKIT_THREAD;