Permalink
Browse files

Fixed issue #7

  • Loading branch information...
1 parent 2938215 commit 6c5a1b4c15c9319bb5376765b3d94f77fc628195 @kritzikratzi committed Feb 1, 2010
Showing with 55 additions and 54 deletions.
  1. +1 −1 build.xml
  2. +8 −26 src/fullscreen/FullScreen.java
  3. +38 −0 src/fullscreen/FullScreenBase.java
  4. +8 −27 src/fullscreen/SoftFullScreen.java
View
@@ -23,7 +23,7 @@
<!-- path to the sketch folder -->
<property name="sketch.path" value="${user.home}/Documents/Processing" />
- <property name="version" value="0.98.2" />
+ <property name="version" value="0.98.3" />
<fileset id="cp" includes="dependencies/*.jar" />
<path id="cp">
<fileset dir="." includes="dependencies/*.jar" />
@@ -132,8 +132,12 @@ public boolean available(){
*
* @param fullScreen true or false
*/
- public void setFullScreen( boolean fullScreen ){
- new DelayedModeChange( fullScreen );
+ public void setFullScreen( final boolean fullScreen ){
+ new DelayedAction( 2 ) {
+ public void action() {
+ setFullScreenImpl( fullScreen );
+ }
+ };
}
/**
@@ -158,13 +162,13 @@ else if( fullScreen ){
fsDevice.setFullScreenWindow( fsFrame );
setResolution( 0, 0 );
- dad.requestFocus();
dad.setLocation( ( fsFrame.getWidth() - dad.width ) / 2, ( fsFrame.getHeight() - dad.height ) / 2 );
GLDrawableHelper.reAllocate( this );
GLTextureUpdateHelper.update( this );
// Tell the sketch about the resolution change
+ requestFocus();
notifySketch( getSketch() );
}
else{
@@ -183,12 +187,12 @@ else if( fullScreen ){
dad.width + dad.frame.insets().left + dad.frame.insets().right,
dad.height + dad.frame.insets().top + dad.frame.insets().bottom
);*/
- dad.requestFocus();
GLDrawableHelper.reAllocate( this );
GLTextureUpdateHelper.update( this );
// Tell the sketch about the resolution change
+ requestFocus();
notifySketch( getSketch() );
}
}
@@ -345,26 +349,4 @@ public void setRefreshRate( int rate ){
return result;
}
-
- /**
- * A sweet little helper.
- */
- public class DelayedModeChange{
- private boolean state;
- private int skippedFrames = 0;
-
- public DelayedModeChange( boolean state ){
- this.state = state;
- dad.registerPost( this );
- }
-
- public void post(){
- skippedFrames ++;
-
- if( skippedFrames >= 2 ){
- setFullScreenImpl( state );
- dad.unregisterPost( this );
- }
- }
- }
}
@@ -170,6 +170,20 @@ protected static void notifySketch( PApplet dad ){
}
}
+
+ /**
+ * Requests focus for the sketch..
+ */
+ public void requestFocus(){
+ getSketch().requestFocus();
+ new DelayedAction( 2 ){
+ public void action(){
+ getSketch().requestFocus();
+ }
+ };
+ }
+
+
/**
* Is opengl somehow being used in this sketch?
*/
@@ -185,4 +199,28 @@ public boolean isGL(){
public PApplet getSketch() {
return dad;
}
+
+
+ /**
+ * A sweet little helper.
+ */
+ public abstract class DelayedAction{
+ private int skipFrames = 0;
+
+ public DelayedAction( int skipFrames ){
+ dad.registerPost( this );
+ this.skipFrames = skipFrames;
+ }
+
+ public void post(){
+ skipFrames --;
+
+ if( skipFrames <= 0 ){
+ action();
+ dad.unregisterPost( this );
+ }
+ }
+
+ public abstract void action();
+ }
}
@@ -128,8 +128,12 @@ public boolean available(){
*
* @param fullScreen true or false
*/
- public void setFullScreen( boolean fullScreen ){
- new DelayedModeChange( fullScreen );
+ public void setFullScreen( final boolean fullScreen ){
+ new DelayedAction( 2 ){
+ public void action(){
+ setFullScreenImpl( fullScreen );
+ }
+ };
}
@SuppressWarnings("deprecation")
@@ -143,7 +147,6 @@ else if( fullScreen ){
// remove applet from processing frame and attach to fsFrame
dad.frame.setVisible( false );
fsFrame.add( dad );
- dad.requestFocus();
if( PApplet.platform == PConstants.MACOSX ){
new JAppleMenuBar().setVisible( false );
@@ -156,6 +159,7 @@ else if( fullScreen ){
GLDrawableHelper.reAllocate( this );
GLTextureUpdateHelper.update( this );
+ requestFocus();
notifySketch( dad );
return;
@@ -178,11 +182,11 @@ else if( fullScreen ){
}
dad.frame.setVisible( true );
- dad.requestFocus();
GLDrawableHelper.reAllocate( this );
GLTextureUpdateHelper.update( this );
+ requestFocus();
notifySketch( dad );
return;
@@ -198,27 +202,4 @@ public void setResolution( int xRes, int yRes ) {
System.err.println( "Changing resolution is not supported in SoftFullScreen mode. " );
System.err.println( "Use the normal FullScreen mode to make use of that functionality. " );
}
-
-
- /**
- * A sweet little helper.
- */
- public class DelayedModeChange{
- private boolean state;
- private int skippedFrames = 0;
-
- public DelayedModeChange( boolean state ){
- this.state = state;
- dad.registerPost( this );
- }
-
- public void post(){
- skippedFrames ++;
-
- if( skippedFrames >= 2 ){
- setFullScreenImpl( state );
- dad.unregisterPost( this );
- }
- }
- }
}

0 comments on commit 6c5a1b4

Please sign in to comment.