Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save and restore window position and maximized state #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Ghidra/Framework/Docking/src/main/java/docking/RootNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void setIcon(ImageIcon icon) {
void setVisible(boolean state) {
Window mainWindow = getMainWindow();
mainWindow.setVisible(state);
WindowUtilities.ensureOnScreen(mainWindow);
// WindowUtilities.ensureOnScreen(mainWindow);

Iterator<DetachedWindowNode> it = detachedWindows.iterator();
while (it.hasNext()) {
Expand Down Expand Up @@ -433,7 +433,14 @@ Container getContentPane() {
Element saveToXML() {
Element root = new Element(ROOT_NODE_ELEMENT_NAME);
JFrame frame = windowWrapper.getParentFrame();
int state = frame.getExtendedState(); // Get current state (may be maximized)
if ((state & JFrame.MAXIMIZED_BOTH) != 0) { // We are maximized. Want to save un-maximized dimensions
frame.setExtendedState(state & ~JFrame.MAXIMIZED_BOTH);
}
Rectangle r = frame.getBounds();
if ((state & JFrame.MAXIMIZED_BOTH) != 0) { // Revert to original state if needed
frame.setExtendedState(state);
}
root.setAttribute("X_POS", "" + r.x);
root.setAttribute("Y_POS", "" + r.y);
root.setAttribute("WIDTH", "" + r.width);
Expand Down Expand Up @@ -475,10 +482,12 @@ List<ComponentPlaceholder> restoreFromXML(Element rootNodeElement) {
int y = Integer.parseInt(rootNodeElement.getAttributeValue("Y_POS"));
int width = Integer.parseInt(rootNodeElement.getAttributeValue("WIDTH"));
int height = Integer.parseInt(rootNodeElement.getAttributeValue("HEIGHT"));
int state = Integer.parseInt(rootNodeElement.getAttributeValue("EX_STATE"));
JFrame frame = windowWrapper.getParentFrame();
Rectangle bounds = new Rectangle(x, y, width, height);
WindowUtilities.ensureOnScreen(frame, bounds);
// WindowUtilities.ensureOnScreen(frame, bounds);
frame.setBounds(bounds);
frame.setExtendedState(state);

List<ComponentPlaceholder> restoredPlaceholders = new ArrayList<>();
Iterator<?> elementIterator = rootNodeElement.getChildren().iterator();
Expand Down