2626import java .awt .event .*;
2727import java .awt .geom .Rectangle2D ;
2828import java .awt .image .*;
29- import java .lang .reflect .*;
3029import java .net .URL ;
3130import 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 }
0 commit comments