Commit 3537f849 authored by Ahmed Ashour's avatar Ahmed Ashour Committed by skylot

fix(gui): detect if a window is opened inside a visible screen (PR #521)

parent 9557f04f
package jadx.gui.settings; package jadx.gui.settings;
import java.awt.*; import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
...@@ -142,14 +145,25 @@ public class JadxSettings extends JadxCLIArgs { ...@@ -142,14 +145,25 @@ public class JadxSettings extends JadxCLIArgs {
public boolean loadWindowPos(Window window) { public boolean loadWindowPos(Window window) {
WindowLocation pos = windowPos.get(window.getClass().getSimpleName()); WindowLocation pos = windowPos.get(window.getClass().getSimpleName());
if (pos == null) { if (pos == null || !isContainedInAnyScreen(pos)) {
return false; return false;
} }
window.setLocation(pos.getX(), pos.getY()); window.setLocation(pos.getX(), pos.getY());
window.setSize(pos.getWidth(), pos.getHeight()); window.setSize(pos.getWidth(), pos.getHeight());
return true; return true;
} }
private static boolean isContainedInAnyScreen(WindowLocation pos) {
for (GraphicsDevice gd : GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()) {
if (gd.getDefaultConfiguration().getBounds().contains(
pos.getX(), pos.getY(), pos.getWidth(), pos.getHeight())) {
return true;
}
}
return false;
}
public boolean isShowHeapUsageBar() { public boolean isShowHeapUsageBar() {
return showHeapUsageBar; return showHeapUsageBar;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment