Skip to content

Commit fa8da57

Browse files
committed
clearing brush, back on the EDT, fix focus issues processing#3380 processing#3389
1 parent 445cb17 commit fa8da57

4 files changed

Lines changed: 75 additions & 60 deletions

File tree

core/src/processing/core/PApplet.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9870,20 +9870,20 @@ static public void main(final String mainClass, final String[] sketchArgs) {
98709870
// also suspecting that these "not showing up" bugs might be EDT issues.
98719871
static public void runSketch(final String[] args,
98729872
final PApplet constructedSketch) {
9873-
// EventQueue.invokeLater(new Runnable() {
9874-
// public void run() {
9875-
// runSketchEDT(args, constructedSketch);
9876-
// }
9877-
// });
9878-
// }
9879-
//
9880-
//
9881-
// /**
9882-
// * Moving this to the EDT for 3.0a6 because that's the proper thing to do
9883-
// * when messing with AWT/Swing components. And boy, do we mess with 'em.
9884-
// */
9885-
// static protected void runSketchEDT(final String[] args,
9886-
// final PApplet constructedSketch) {
9873+
EventQueue.invokeLater(new Runnable() {
9874+
public void run() {
9875+
runSketchEDT(args, constructedSketch);
9876+
}
9877+
});
9878+
}
9879+
9880+
9881+
/**
9882+
* Moving this to the EDT for 3.0a6 because that's the proper thing to do
9883+
* when messing with AWT/Swing components. And boy, do we mess with 'em.
9884+
*/
9885+
static protected void runSketchEDT(final String[] args,
9886+
final PApplet constructedSketch) {
98879887
// Supposed to help with flicker, but no effect on OS X.
98889888
// TODO IIRC this helped on Windows, but need to double check.
98899889
System.setProperty("sun.awt.noerasebackground", "true");

core/src/processing/core/PSurfaceAWT.java

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.awt.event.*;
2727
import java.awt.geom.Rectangle2D;
2828
import java.awt.image.*;
29-
import java.lang.reflect.*;
3029
import java.net.URL;
3130
import java.util.ArrayList;
3231

@@ -64,6 +63,7 @@ public PSurfaceAWT(PGraphics graphics) {
6463
//this.graphics = graphics;
6564
super(graphics);
6665

66+
/*
6767
if (checkRetina()) {
6868
// System.out.println("retina in use");
6969
@@ -84,6 +84,7 @@ public PSurfaceAWT(PGraphics graphics) {
8484
// flicker--pushing pixels out before the screen has finished rendering.
8585
// useStrategy = false;
8686
}
87+
*/
8788
canvas = new SmoothCanvas();
8889
// if (useStrategy) {
8990
canvas.setIgnoreRepaint(true);
@@ -104,36 +105,40 @@ public void componentResized(ComponentEvent e) {
104105
}
105106

106107

107-
/**
108-
* Handle grabbing the focus on startup. Other renderers can override this
109-
* if handling needs to be different. For the AWT, the request is invoked
110-
* later on the EDT. Other implementations may not require that, so the
111-
* invokeLater() happens in here rather than requiring the caller to wrap it.
112-
*/
113-
@Override
114-
void requestFocus() {
115-
// for 2.0a6, moving this request to the EDT
116-
EventQueue.invokeLater(new Runnable() {
117-
public void run() {
118-
// Call the request focus event once the image is sure to be on
119-
// screen and the component is valid. The OpenGL renderer will
120-
// request focus for its canvas inside beginDraw().
121-
// http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/FocusSpec.html
122-
// Disabling for 0185, because it causes an assertion failure on OS X
123-
// http://code.google.com/p/processing/issues/detail?id=258
124-
// requestFocus();
125-
126-
// Changing to this version for 0187
127-
// http://code.google.com/p/processing/issues/detail?id=279
128-
//requestFocusInWindow();
129-
130-
// For 3.0, just call this directly on the Canvas object
131-
if (canvas != null) {
132-
canvas.requestFocusInWindow();
133-
}
134-
}
135-
});
136-
}
108+
// /**
109+
// * Handle grabbing the focus on startup. Other renderers can override this
110+
// * if handling needs to be different. For the AWT, the request is invoked
111+
// * later on the EDT. Other implementations may not require that, so the
112+
// * invokeLater() happens in here rather than requiring the caller to wrap it.
113+
// */
114+
// @Override
115+
// void requestFocus() {
116+
//// System.out.println("requesFocus() outer " + EventQueue.isDispatchThread());
117+
// // for 2.0a6, moving this request to the EDT
118+
// EventQueue.invokeLater(new Runnable() {
119+
// public void run() {
120+
// // Call the request focus event once the image is sure to be on
121+
// // screen and the component is valid. The OpenGL renderer will
122+
// // request focus for its canvas inside beginDraw().
123+
// // http://java.sun.com/j2se/1.4.2/docs/api/java/awt/doc-files/FocusSpec.html
124+
// // Disabling for 0185, because it causes an assertion failure on OS X
125+
// // http://code.google.com/p/processing/issues/detail?id=258
126+
// // requestFocus();
127+
//
128+
// // Changing to this version for 0187
129+
// // http://code.google.com/p/processing/issues/detail?id=279
130+
// //requestFocusInWindow();
131+
//
132+
// // For 3.0, just call this directly on the Canvas object
133+
// if (canvas != null) {
134+
// //System.out.println("requesting focus " + EventQueue.isDispatchThread());
135+
// //System.out.println("requesting focus " + frame.isVisible());
136+
// //canvas.requestFocusInWindow();
137+
// canvas.requestFocus();
138+
// }
139+
// }
140+
// });
141+
// }
137142

138143

139144
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -749,6 +754,12 @@ public void placeWindow(int[] location, int[] editorLocation) {
749754
// If displayable() is false, then PSurfaceNone should be used, but...
750755
if (sketch.getGraphics().displayable()) {
751756
frame.setVisible(true);
757+
System.out.println("setting visible on EDT? " + EventQueue.isDispatchThread());
758+
//requestFocus();
759+
if (canvas != null) {
760+
//canvas.requestFocusInWindow();
761+
canvas.requestFocus();
762+
}
752763
}
753764
}
754765

@@ -827,6 +838,7 @@ public void setSmooth(int level) {
827838
}
828839

829840

841+
/*
830842
private boolean checkRetina() {
831843
if (PApplet.platform == PConstants.MACOSX) {
832844
// This should probably be reset each time there's a display change.
@@ -852,6 +864,7 @@ private boolean checkRetina() {
852864
}
853865
return false;
854866
}
867+
*/
855868

856869

857870
/** Get the bounds rectangle for all displays. */
@@ -1262,11 +1275,13 @@ public void keyTyped(java.awt.event.KeyEvent e) {
12621275
canvas.addFocusListener(new FocusListener() {
12631276

12641277
public void focusGained(FocusEvent e) {
1278+
System.out.println(e);
12651279
sketch.focused = true;
12661280
sketch.focusGained();
12671281
}
12681282

12691283
public void focusLost(FocusEvent e) {
1284+
System.out.println(e);
12701285
sketch.focused = false;
12711286
sketch.focusLost();
12721287
}

core/src/processing/core/PSurfaceNone.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,8 @@ public void setSmooth(int level) {
141141

142142
}
143143

144-
void requestFocus() {
145-
// TODO Auto-generated method stub
146-
147-
}
144+
// void requestFocus() {
145+
// }
148146

149147
// public void blit() {
150148
// // TODO Auto-generated method stub
@@ -298,9 +296,9 @@ public void run() {
298296

299297
// EventQueue.invokeLater(new Runnable() {
300298
// public void run() {
301-
if (sketch.frameCount == 1) {
302-
requestFocus();
303-
}
299+
// if (sketch.frameCount == 1) {
300+
// requestFocus();
301+
// }
304302
// }
305303
// });
306304

core/todo.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ X HashMap sucks b/c we'd have to cast everything
2323
X doesn't help to have intParam() etc, too many types (5ish? OutputStream)
2424
X just stick with the current setup
2525
X remove launch(String) since it was calling itself, and anachronistic
26+
X sketches with new fullScreen() method should grab focus by default
27+
X https://github.com/processing/processing/issues/3380
28+
X sketches not getting focus with Java2D
29+
X https://github.com/processing/processing/issues/3389
2630

2731
cleaning
2832
o possible addition for 'implementation' variable
@@ -51,6 +55,8 @@ X ortho function is broken
5155
X https://github.com/processing/processing/issues/1278
5256
X errors with loading SVGs in P3D/P2D
5357
X https://github.com/processing/processing/issues/3379
58+
X sketch window briefly appears on top left corner when using OpenGL
59+
X https://github.com/processing/processing/issues/3308
5460

5561
fixed earlier
5662
X sketch window is not placed at correct location when running a second time
@@ -61,6 +67,8 @@ X save() and saveFrame() with 2X renderers fails
6167
X https://github.com/processing/processing/issues/3255
6268
X NPE when using image() created with createGraphics(PGraphicsRetina2D)
6369
X https://github.com/processing/processing/issues/2510
70+
X Closing OpenGL sketch from the PDE doesn't stop java.exe process
71+
X https://github.com/processing/processing/issues/2335
6472

6573

6674
docs
@@ -79,10 +87,6 @@ _ removeNotify(), addNotify(), setUndecorated(boolean)
7987
_ setting menubar will be surface-specific
8088
_ setLocation(int, int) and setSize(int, int)
8189
_ add the "don't use this" warning to the JFrame in PSurfaceAWT
82-
_ sketches with new fullScreen() method should grab focus by default
83-
_ https://github.com/processing/processing/issues/3380
84-
_ sketches not getting focus with Java2D
85-
_ https://github.com/processing/processing/issues/3389
8690
_ draw() executes twice when noLoop() called in setup()
8791
_ https://github.com/processing/processing/issues/3310
8892
_ broken since 3.0a7, but not in 3.0a5
@@ -92,8 +96,6 @@ _ sketch sometimes doesn't show with noLoop() on Linux
9296
_ https://github.com/processing/processing/issues/3316
9397
_ sketch not always showing with empty draw()
9498
_ https://github.com/processing/processing/issues/3363
95-
_ sketch window briefly appears on top left corner when using OpenGL
96-
_ https://github.com/processing/processing/issues/3308
9799
_ Window never shows with exported application on 64-bit Linux
98100
_ https://github.com/processing/processing/issues/3303
99101

@@ -128,8 +130,6 @@ _ implement external messages (moving the window)
128130

129131
opengl
130132
_ hard crash at 1920x1080, mirrored, Casey's GT 650M 1GB
131-
_ Closing OpenGL sketch from the PDE doesn't stop java.exe process
132-
_ https://github.com/processing/processing/issues/2335
133133
_ add attrib() method
134134
_ https://github.com/processing/processing/issues/2963
135135
_ andres needs input on how the api works
@@ -139,6 +139,8 @@ _ https://github.com/processing/processing/issues/3339
139139

140140

141141
opengl questions
142+
_ issues with how JOGL handles window layout/sizing
143+
_ https://github.com/processing/processing/issues/3401
142144
_ exitCalled() and exitActual made public by Andres, breaks Python
143145
_ also not API we want to expose, so sort this out
144146
_ or maybe we're fine b/c now FX2D needs it as well

0 commit comments

Comments
 (0)