Permalink
Browse files

sketch now pauses on minification.

  • Loading branch information...
1 parent 10115d4 commit 3fa85cc1d78ffd60e8261866b17a9c5072dc1155 @kritzikratzi committed Jul 15, 2010
Showing with 38 additions and 2 deletions.
  1. +12 −1 src/fullscreen/FullScreenBase.java
  2. +26 −1 src/fullscreen/tests/Tests.java
@@ -1,5 +1,7 @@
package fullscreen;
+import japplemenubar.JAppleMenuBar;
+
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
@@ -43,7 +45,7 @@ public FullScreenBase( PApplet dad ){
// Listen to processings key events
dad.registerKeyEvent( this );
-
+ if( dad.frame != null ) registerFrame( dad.frame );
Class<?> clazz = dad.g.getClass();
while( clazz != null ){
if( clazz.getName().equals( "processing.opengl.PGraphicsOpenGL" ) )
@@ -119,6 +121,15 @@ public void keyPressed( KeyEvent e ){
// Window listener
f.addWindowListener( new WindowAdapter(){
+ public void windowDeiconified( WindowEvent w ){
+ dad.loop();
+ }
+
+ @Override
+ public void windowIconified( WindowEvent e ){
+ dad.noLoop();
+ }
+
public void windowClosing( WindowEvent e ){
dad.exit();
}
@@ -100,7 +100,6 @@ public void issue10_4() throws Exception{
assertFrameRate( 640, 480, SoftFullScreen.class );
}
-
/**
* Tests if the framerate is larger than a certain value.
* @throws NoSuchMethodException
@@ -133,6 +132,32 @@ private void assertFrameRate( int width, int height, Class<? extends FullScreenB
}
+ /**
+ * Tests if the frame really pauses when iconified, and also that it automatically continues when deiconified
+ */
+ @Test
+ public void iconify() throws Exception{
+ Demo.Simple sketch = new Demo.Simple( "iconify", 640, 480, PApplet.JAVA2D );
+ sketch.frameRate( 60 );
+
+ SoftFullScreen fs = new SoftFullScreen( sketch );
+ Thread.sleep( 2000 );
+
+ fs.minimize();
+ int startFrameNum = sketch.frameCount;
+ Thread.sleep( 2000 );
+ int finalFrameNum = sketch.frameCount;
+ fs.restore();
+
+ killSketch( sketch );
+
+ if( finalFrameNum - startFrameNum > 10 ){
+ fail( "Sketch didn't pause when iconified! [" + (finalFrameNum - startFrameNum) + " frames were drawn]" );
+ }
+
+ }
+
+
/**
* Kill a sketch

0 comments on commit 3fa85cc

Please sign in to comment.