Skip to content

Commit

Permalink
request glwindow focus in the EDT
Browse files Browse the repository at this point in the history
  • Loading branch information
codeanticode committed Sep 12, 2015
1 parent 528f225 commit 4c0f923
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions core/src/processing/opengl/PSurfaceJOGL.java
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,12 @@ public void setFrameRate(float fps) {


public void requestFocus() {
if (window != null) {
window.requestFocus();
}
display.getEDTUtil().invoke(false, new Runnable() {
@Override
public void run() {
window.requestFocus();
}
});
}


Expand All @@ -713,6 +716,10 @@ public void display(GLAutoDrawable drawable) {
return;
}

if (sketch.frameCount == 0) {
requestFocus();
}

pgl.getGL(drawable);
int pframeCount = sketch.frameCount;
sketch.handleDraw();
Expand All @@ -723,10 +730,6 @@ public void display(GLAutoDrawable drawable) {
pgl.endRender(sketch.sketchWindowColor());
}

if (sketch.frameCount == 1) {
requestFocus();
}

if (sketch.exitCalled()) {
sketch.dispose(); // calls stopThread(), which stops the animator.
sketch.exitActual();
Expand Down

0 comments on commit 4c0f923

Please sign in to comment.