Skip to content

Commit

Permalink
Add handling for out-of-screen(s) window bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
CmP-lt committed Jun 4, 2022
1 parent d685608 commit 451cc3d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion jadx-gui/src/main/java/jadx/gui/settings/JadxSettings.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package jadx.gui.settings;

import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Window;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -216,13 +219,28 @@ public boolean loadWindowPos(Window window) {
if (pos == null || pos.getBounds() == null) {
return false;
}
if (!isAccessibleInAnyScreen(pos)) {
return false;
}
window.setBounds(pos.getBounds());
if (window instanceof MainWindow) {
((JFrame) window).setExtendedState(getMainWindowExtendedState());
}
window.setBounds(pos.getBounds());
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);
return false;
}

public boolean isShowHeapUsageBar() {
return showHeapUsageBar;
}
Expand Down

0 comments on commit 451cc3d

Please sign in to comment.