Skip to content

Commit f255319

Browse files
author
Federico Fissore
committed
Maximized state of IDE gets properly stored and restored. Fixes #2909
1 parent d00ca7f commit f255319

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

app/src/processing/app/Base.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ protected boolean restoreSketches() throws Exception {
558558
location = nextEditorLocation();
559559
}
560560
// If file did not exist, null will be returned for the Editor
561-
if (handleOpen(new File(path), location, true, false, false) != null) {
561+
if (handleOpen(new File(path), location, nextEditorLocation(), true, false, false) != null) {
562562
opened++;
563563
}
564564
}
@@ -890,10 +890,10 @@ public Editor handleOpen(File file, boolean untitled) throws Exception {
890890
}
891891

892892
protected Editor handleOpen(File file, int[] location, boolean showEditor, boolean untitled) throws Exception {
893-
return handleOpen(file, location, showEditor, true, untitled);
893+
return handleOpen(file, location, location, showEditor, true, untitled);
894894
}
895895

896-
protected Editor handleOpen(File file, int[] location, boolean showEditor, boolean storeOpenedSketches, boolean untitled) throws Exception {
896+
protected Editor handleOpen(File file, int[] storedLocation, int[] defaultLocation, boolean showEditor, boolean storeOpenedSketches, boolean untitled) throws Exception {
897897
if (!file.exists()) return null;
898898

899899
// Cycle through open windows to make sure that it's not already open.
@@ -905,7 +905,7 @@ protected Editor handleOpen(File file, int[] location, boolean showEditor, boole
905905
}
906906
}
907907

908-
final Editor editor = new Editor(this, file, location, BaseNoGui.getPlatform());
908+
Editor editor = new Editor(this, file, storedLocation, defaultLocation, BaseNoGui.getPlatform());
909909

910910
// Make sure that the sketch actually loaded
911911
if (editor.getSketch() == null) {

app/src/processing/app/Editor.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public boolean apply(Sketch sketch) {
179179
private Runnable exportAppHandler;
180180

181181

182-
public Editor(Base ibase, File file, int[] location, Platform platform) throws Exception {
182+
public Editor(Base ibase, File file, int[] storedLocation, int[] defaultLocation, Platform platform) throws Exception {
183183
super("Arduino");
184184
this.base = ibase;
185185
this.platform = platform;
@@ -326,7 +326,7 @@ public void windowDeactivated(WindowEvent e) {
326326
// System.out.println("t2");
327327

328328
// Set the window bounds and the divider location before setting it visible
329-
setPlacement(location);
329+
setPlacement(storedLocation, defaultLocation);
330330

331331

332332
// Set the minimum size for the editor window
@@ -414,6 +414,14 @@ public boolean importData(JComponent src, Transferable transferable) {
414414
}
415415
}
416416

417+
private void setPlacement(int[] storedLocation, int[] defaultLocation) {
418+
if (storedLocation.length > 5 && storedLocation[5] != 0) {
419+
setExtendedState(storedLocation[5]);
420+
setPlacement(defaultLocation);
421+
} else {
422+
setPlacement(storedLocation);
423+
}
424+
}
417425

418426
private void setPlacement(int[] location) {
419427
setBounds(location[0], location[1], location[2], location[3]);
@@ -422,9 +430,8 @@ private void setPlacement(int[] location) {
422430
}
423431
}
424432

425-
426433
protected int[] getPlacement() {
427-
int[] location = new int[5];
434+
int[] location = new int[6];
428435

429436
// Get the dimensions of the Frame
430437
Rectangle bounds = getBounds();
@@ -435,6 +442,7 @@ protected int[] getPlacement() {
435442

436443
// Get the current placement of the divider
437444
location[4] = splitPane.getDividerLocation();
445+
location[5] = getExtendedState() & MAXIMIZED_BOTH;
438446

439447
return location;
440448
}

0 commit comments

Comments
 (0)