未验证 提交 0809993b 编写于 作者: C CmP-lt 提交者: GitHub

fix(gui): improve restoration of windows saved state (PR #1511)

* Fix restoration of windows saved state
* Don't skip restoration of window saved bounds when they intersect with screen bounds.
* Restore saved bounds of main window regardless of it's saved extended state (fixes divider location of main split pane being restored incorrectly when saved state of main window is maximized).
* Add handling for out-of-screen(s) window bounds
上级 0c3afcc2
......@@ -219,29 +219,22 @@ public class JadxSettings extends JadxCLIArgs {
if (pos == null || pos.getBounds() == null) {
return false;
}
if (window instanceof MainWindow) {
int extendedState = getMainWindowExtendedState();
if (extendedState != JFrame.NORMAL) {
((JFrame) window).setExtendedState(extendedState);
return true;
}
}
if (!isContainedInAnyScreen(pos)) {
if (!isAccessibleInAnyScreen(pos)) {
return false;
}
window.setBounds(pos.getBounds());
if (window instanceof MainWindow) {
((JFrame) window).setExtendedState(getMainWindowExtendedState());
}
return true;
}
private static boolean isContainedInAnyScreen(WindowLocation pos) {
Rectangle bounds = pos.getBounds();
if (bounds.getX() > 0 && bounds.getY() > 0) {
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
if (gd.getDefaultConfiguration().getBounds().contains(bounds)) {
return true;
}
private static boolean isAccessibleInAnyScreen(WindowLocation pos) {
Rectangle windowBounds = pos.getBounds();
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
Rectangle screenBounds = gd.getDefaultConfiguration().getBounds();
if (screenBounds.intersects(windowBounds)) {
return true;
}
}
LOG.debug("Window saved position was ignored: {}", pos);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册