Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed intentation, added a setKioskMode(bool) function that properly …

…warns the user if not on windows, started a unit test for kiosk mode
  • Loading branch information...
commit 47257db028a011e5f50aaa498ab28e7f81b5ecd0 1 parent 4d83abc
@kritzikratzi authored
View
21 src/fullscreen/SoftFullScreen.java
@@ -66,8 +66,8 @@
// the first time wait until the frame is displayed
boolean fsIsInitialized;
- // are we in kiosk mode? (OS X only)
- boolean kioskMode;
+ // are we in kiosk mode? (OS X only)
+ boolean kioskMode;
// Daddy...
PApplet dad;
@@ -104,7 +104,7 @@ public SoftFullScreen( PApplet dad, int screenNr ){
public SoftFullScreen( PApplet dad, int screenNr, boolean kioskMode ){
super( dad );
this.dad = dad;
- this.kioskMode = kioskMode;
+ setKioskMode( kioskMode );
GraphicsDevice[] devices = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
if( screenNr >= devices.length ){
@@ -120,10 +120,9 @@ public void windowDeiconified( WindowEvent w ){
if( isFullScreen() && PApplet.platform == PConstants.MACOSX ){
new JAppleMenuBar().setVisible( false, SoftFullScreen.this.kioskMode );
}
-
}
};
-
+
fsFrame = new Frame( fsDevice.getDefaultConfiguration() );
fsFrame.addWindowListener(listener);
fsFrame.setTitle( dad.frame == null? "":dad.frame.getTitle() );
@@ -274,4 +273,16 @@ 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. " );
}
+
+ /**
+ * Changes kiosk mode, this will only apply once you (re-)enter fullscreen mode.
+ */
+ public void setKioskMode( boolean kioskMode ){
+ this.kioskMode = kioskMode;
+
+ if( kioskMode && PApplet.platform != PConstants.MACOSX ){
+ System.err.println( "Warning: Kiosk Mode only works on Mac OS X. " );
+ System.err.println( " Continuing without kiosk mode. " );
+ }
+ }
}
View
48 src/fullscreen/tests/Tests.java
@@ -1,6 +1,11 @@
package fullscreen.tests;
import java.awt.GraphicsEnvironment;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
import java.lang.reflect.InvocationTargetException;
import japplemenubar.JAppleMenuBar;
@@ -165,7 +170,50 @@ public void iconify() throws Exception{
killSketch( sketch );
}
+
+ /**
+ * Tests if kiosk mode works.
+ */
+ @Test
+ public void kioskMode() throws Exception {
+ Demo.Simple sketch = new Demo.Simple( "kiosk mode", 640, 480, PApplet.JAVA2D );
+ if( PApplet.platform == PApplet.MACOSX ){
+ sketch.frameRate( 60 );
+
+ SoftFullScreen fs = new SoftFullScreen( sketch );
+ fs.setKioskMode( true );
+ fs.enter();
+
+ Thread.sleep( 500 );
+ Robot r = new Robot();
+ r.setAutoDelay( 100 );
+
+ // let's get the keyboard focus by clicking our sketch
+ Point where = sketch.getLocationOnScreen();
+ r.mouseMove( where.x + 100, where.y + 100 );
+ r.mousePress( MouseEvent.BUTTON1_MASK );
+ r.mouseRelease( MouseEvent.BUTTON1_MASK );
+ Thread.sleep( 5000 );
+ // press apple+tab
+ /*r.keyPress( KeyEvent.VK_META );
+ r.keyPress( KeyEvent.VK_Q );
+ r.keyRelease( KeyEvent.VK_META );
+ r.keyRelease( KeyEvent.VK_Q );*/
+
+ //r.mousePress( MouseEvent.BUTTON1_MASK );
+ //r.mouseRelease( MouseEvent.BUTTON1_MASK );
+
+ // yea, this doesn't really check anything at this point
+ if( !sketch.hasFocus() ){
+ fail( "Kiosk mode not working [frame should have focus after pressing apple+tab, but it doesn't]" );
+ }
+
+ fs.leave();
+ }
+
+ killSketch( sketch );
+ }
/**
* Kill a sketch
View
9 src/japplemenubar/JAppleMenuBar.java
@@ -35,9 +35,8 @@
public native void setVisible( boolean visibility, boolean kioskMode );
- public void setVisible( boolean visibility )
- {
- // Keep original API in-tact. Default kiosk-mode to off.
- setVisible( visibility, false );
- }
+ public void setVisible( boolean visibility ){
+ // Keep original API in-tact. Default kiosk-mode to off.
+ setVisible( visibility, false );
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.