Skip to content

Commit

Permalink
fix(gui): detect if a window is opened inside a visible screen (PR #521)
Browse files Browse the repository at this point in the history
  • Loading branch information
asashour authored and skylot committed Mar 26, 2019
1 parent 9557f04 commit 3537f84
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions 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.*;
import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -142,14 +145,25 @@ public void saveWindowPos(Window window) {

public boolean loadWindowPos(Window window) {
WindowLocation pos = windowPos.get(window.getClass().getSimpleName());
if (pos == null) {
if (pos == null || !isContainedInAnyScreen(pos)) {
return false;
}

window.setLocation(pos.getX(), pos.getY());
window.setSize(pos.getWidth(), pos.getHeight());
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() {
return showHeapUsageBar;
}
Expand Down

0 comments on commit 3537f84

Please sign in to comment.