mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-101990 workaround. JDK Application class is used instead of custom native method invocation. Prevents crashes with JDK7 because of non-AppKit thread invocations.
This commit is contained in:
@@ -38,6 +38,8 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static com.intellij.ui.mac.foundation.Foundation.invoke;
|
||||
@@ -251,7 +253,34 @@ public class MacMainFrameDecorator implements UISettingsListener, Disposable {
|
||||
if (myInFullScreen != state) {
|
||||
final ID window = MacUtil.findWindowForTitle(myFrame.getTitle());
|
||||
if (window == null) return;
|
||||
invoke(window, "toggleFullScreen:", window);
|
||||
if (SystemInfo.isJavaVersionAtLeast("1.7")) {
|
||||
requestToggleFullScreen(myFrame);
|
||||
} else {
|
||||
invoke(window, "toggleFullScreen:", window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void requestToggleFullScreen(final Window window) {
|
||||
try {
|
||||
//Load Application class from the jdk not from our eawtstub.jar
|
||||
Class<?> applicationClass = window.getClass().getClassLoader().loadClass("com.apple.eawt.Application");
|
||||
Method requestToggleFullScreenMethod = applicationClass.getDeclaredMethod("requestToggleFullScreen", Window.class);
|
||||
Object theApplicationInstance = applicationClass.getDeclaredMethod("getApplication").invoke(null);
|
||||
requestToggleFullScreenMethod.invoke(theApplicationInstance, window);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
LOG.warn("Looks like the com.apple.eawt.Application class does not exist anymore");
|
||||
}
|
||||
catch (NoSuchMethodException e) {
|
||||
LOG.warn("Looks like the com.apple.eawt.Application.requestToggleFullScreen class is removed");
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
LOG.warn("com.apple.eawt.Application method invocation has failed");
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
LOG.warn("com.apple.eawt.Application method invocation has failed");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user