Skip to content

Commit 1877703

Browse files
author
Federico Fissore
committed
Centering the first Editor to the middle of the main monitor. Fixes #1629
1 parent 143c91f commit 1877703

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/src/processing/app/Base.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,11 @@ protected void handleActivated(Editor whichEditor) {
581581

582582

583583
protected int[] nextEditorLocation() {
584-
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
585584
int defaultWidth = Preferences.getInteger("editor.window.width.default");
586585
int defaultHeight = Preferences.getInteger("editor.window.height.default");
587586

588587
if (activeEditor == null) {
588+
Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().getBounds();
589589
// If no current active editor, use default placement
590590
return new int[] {
591591
(screen.width - defaultWidth) / 2,
@@ -594,13 +594,15 @@ protected int[] nextEditorLocation() {
594594
};
595595

596596
} else {
597+
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
598+
597599
// With a currently active editor, open the new window
598600
// using the same dimensions, but offset slightly.
599601
synchronized (editors) {
600602
final int OVER = 50;
601603
// In release 0160, don't
602604
//location = activeEditor.getPlacement();
603-
Editor lastOpened = editors.get(editors.size() - 1);
605+
Editor lastOpened = activeEditor;
604606
int[] location = lastOpened.getPlacement();
605607
// Just in case the bounds for that window are bad
606608
location[0] += OVER;

0 commit comments

Comments
 (0)