Skip to content

Commit fe5f7d5

Browse files
committed
fix --external and window placement issues (fixes #158)
1 parent 3eeb196 commit fe5f7d5

3 files changed

Lines changed: 25 additions & 13 deletions

File tree

app/src/processing/app/RunnerListenerEdtAdapter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public RunnerListenerEdtAdapter(RunnerListener wrapped) {
1010
this.wrapped = wrapped;
1111
}
1212

13+
/** Need the original object so we can see if it's a JavaEditor */
14+
public RunnerListener getWrapped() {
15+
return wrapped;
16+
}
17+
1318
@Override
1419
public void statusError(String message) {
1520
EventQueue.invokeLater(() -> wrapped.statusError(message));

java/src/processing/mode/java/runner/Runner.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,24 @@ public class Runner implements MessageConsumer {
8585

8686
public Runner(JavaBuild build, RunnerListener listener) throws SketchException {
8787
this.listener = listener;
88-
// this.sketch = sketch;
8988
this.build = build;
9089

9190
checkLocalHost();
9291

93-
if (listener instanceof JavaEditor) {
94-
this.editor = (JavaEditor) listener;
95-
sketchErr = editor.getConsole().getErr();
96-
sketchOut = editor.getConsole().getOut();
97-
} else {
92+
if (listener instanceof RunnerListenerEdtAdapter) {
93+
// RunnerListener gets wrapped so that it behaves on the EDT.
94+
// Need to extract the wrapped Object and see if it's a Java Editor,
95+
// in which case we'll be passing additional parameters to the PApplet.
96+
// https://github.com/processing/processing/issues/5843
97+
RunnerListener wrapped = ((RunnerListenerEdtAdapter) listener).getWrapped();
98+
if (wrapped instanceof JavaEditor) {
99+
editor = (JavaEditor) wrapped;
100+
sketchErr = editor.getConsole().getErr();
101+
sketchOut = editor.getConsole().getOut();
102+
}
103+
}
104+
// If it's not a JavaEditor, then we don't redirect to a console.
105+
if (editor == null) {
98106
sketchErr = System.err;
99107
sketchOut = System.out;
100108
}
@@ -466,10 +474,8 @@ protected StringList getSketchParams(boolean present, String[] args) {
466474
}
467475
params.append(PApplet.ARGS_EXTERNAL);
468476
}
469-
470477
params.append(PApplet.ARGS_DISPLAY + "=" + runDisplay);
471478

472-
473479
if (present) {
474480
params.append(PApplet.ARGS_PRESENT);
475481
// if (Preferences.getBoolean("run.present.exclusive")) {
@@ -495,6 +501,7 @@ protected StringList getSketchParams(boolean present, String[] args) {
495501
if (args != null) {
496502
params.append(args);
497503
}
504+
498505
// Pass back the whole list
499506
return params;
500507
}

todo.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ X add PVector.setHeading() for parity with p5.js
2323
X https://github.com/processing/processing4/issues/193
2424
X automatically lock closed issues
2525
X https://github.com/apps/lock
26+
X Display Window doesn't remember its position
27+
X https://github.com/processing/processing4/issues/158
28+
_ seems that --external not getting passed
29+
_ https://github.com/processing/processing/issues/5843
30+
_ https://github.com/processing/processing/issues/5781
2631

2732
earlier
2833
o further streamline the downloader
@@ -70,11 +75,6 @@ already fixed in 4.x? (confirm/close on release)
7075
_ HDPI support GNOME desktop
7176
_ https://github.com/processing/processing/issues/6059
7277

73-
_ Display Window doesn't remember its position
74-
_ https://github.com/processing/processing4/issues/158
75-
_ seems that --external not getting passed
76-
_ https://github.com/processing/processing/issues/5843
77-
_ https://github.com/processing/processing/issues/5781
7878
_ remove the JRE Downloader
7979
_ https://github.com/processing/processing4/issues/155
8080
_ editor breakpoints out of the .pde files

0 commit comments

Comments
 (0)