JDK-8087498 : [Mac] Full screen mode fails for certain StageStyles
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-04-23
  • Updated: 2018-06-27
  • Resolved: 2016-11-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The following test case proves that for stages that are initialized with other stage styles than DECORATED, the stage.setFullScreen() method does not work. If you run the sample and try, say, StageStyle.TRANSPARENT, JavaFX hangs instead of making the stage full screen.

This is problematic, because modern Mac applications like Safari, Chrome, Spotify, etc., that place contents in the window title bar and use rounded corners are forced to use StageStyle.TRANSPARENT to do so. However, in Mac OSX Yosemite the green maximize button should now work as a full screen button according to Apples design guidelines. We cannot implement our own green full screen button and live up to the Mac guidelines, unless this bug is fixed.

public class FullScreenBug extends Application {

	@Override
	public void start(Stage stage) throws Exception {
		BorderPane borderPane = new BorderPane();
		ToggleButton button = new ToggleButton("Full Screen");
		button.setOnAction(event -> {
			stage.setFullScreen(button.isSelected());
		});
		borderPane.setCenter(button);
		stage.setWidth(800);
		stage.setHeight(600);
		stage.setScene(new Scene(borderPane));
		stage.initStyle(StageStyle.TRANSPARENT);
		stage.show();
	}
	
	public static void main(String[] args) {
		Application.launch(args);
	}
}

Comments
http://hg.openjdk.java.net/openjfx/9-dev/rt/rev/9b8dcdf29ff5
22-11-2016

+1
22-11-2016

Looks good to me, but Dave should also review.
14-11-2016

Please review the updated webrev http://cr.openjdk.java.net/~azvegint/jdk/9/8087498/01/ This issues happens because of missing NSResizableWindowMask. This fix additionally makes window resizable before entering fullscreen and restores its state after. It is aligned to Windows behavior: it is allowed to fullscreen unresizable window. Linux just shows the "press ESC" message off centered and window remains in its original size.
11-11-2016

I see similar behaviors (1 and 2) as reported by Dave on my Mac (OS X 10.11.5) with Retina.
08-08-2016

The change helps, without it, the application failed to visibly enter full screen mode. It exposed two issue (at least one I had not seen before). Perhaps these should be in a separate JBS, but I would like to know that before I +1 this change. 1) the white box remained the declared size - it did not present as full screen like I see on my linux host. 2) likely related to #1, The "press ESC" message was off center, starting but cut off in the lower right of the white box. Perhaps the clipping of the message is a clue - that for some reason the window clip has not been reset. On my screen I am seeing the "press ESC" message off centered, in the lower right corner of the transparent box. Using the tests described in JDK-8145393, I am not seeing any issue. My display is attached at DELL P2714T: Resolution: 1920 x 1080 @ 60Hz (1080p) OS is 10.9.5
08-08-2016

See JDK-8145393 for an additional test case.
04-08-2016

Review request: http://cr.openjdk.java.net/~azvegint/jdk/9/8087498/00 The fix add NSWindowCollectionBehaviorFullScreenPrimary behaviour for undecorated windows.
04-08-2016

I just tested similar code and getting the same issue on my Mac using JDK 9EA build 102. OS X El Capitan 10.11.3 java version "9-ea" Java(TM) SE Runtime Environment (build 9-ea+102-2016-01-21-003129.javare.4316.nc) Java HotSpot(TM) 64-Bit Server VM (build 9-ea+102-2016-01-21-003129.javare.4316.nc, mixed mode) // Full screen toggle scene.setOnMouseClicked((MouseEvent event) -> { if (event.getClickCount() == 2) { Platform.runLater(() -> primaryStage.setFullScreen(!primaryStage.isFullScreen()) ); } }); Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Not on FX application thread; currentThread = JavaFX Application Thread at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:236) at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:423) at javafx.stage.Window.setShowing(Window.java:926) at javafx.stage.Window.hide(Window.java:952) at com.sun.javafx.stage.WindowPeerListener.closed(WindowPeerListener.java:100) at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:118) at com.sun.javafx.tk.quantum.GlassWindowEventHandler.run(GlassWindowEventHandler.java:40) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.tk.quantum.GlassWindowEventHandler.lambda$handleWindowEvent$408(GlassWindowEventHandler.java:150) at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389) at com.sun.javafx.tk.quantum.GlassWindowEventHandler.handleWindowEvent(GlassWindowEventHandler.java:148) at com.sun.glass.ui.Window.handleWindowEvent(Window.java:1266) at com.sun.glass.ui.Window.notifyDestroy(Window.java:1183) at com.sun.glass.ui.mac.MacApplication._enterNestedEventLoopImpl(Native Method) at com.sun.glass.ui.mac.MacApplication._enterNestedEventLoop(MacApplication.java:109) at com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511) at com.sun.glass.ui.mac.MacView._enterFullscreen(Native Method) at com.sun.glass.ui.View.enterFullscreen(View.java:784) at com.sun.javafx.tk.quantum.WindowStage.applyFullScreen(WindowStage.java:637) at com.sun.javafx.tk.quantum.WindowStage.setFullScreen(WindowStage.java:727) at javafx.stage.Stage.setFullScreen(Stage.java:667) at com.jfxbe.PlayingVideo.lambda$null$2(PlayingVideo.java:111) at com.sun.javafx.application.PlatformImpl.lambda$null$158(PlatformImpl.java:315) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$159(PlatformImpl.java:314) at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
11-02-2016

It fails on OS X 10.9.5 too.
23-04-2015

Target to 9, but we should consider a backport to 8u60.
23-04-2015

Great. Thanks, Kevin!
23-04-2015

I can confirm that it works fine on Windows 7. So I suspect that this is Mac-specific. Will update the bug after I test it on OS X 10.9.5 as to whether it is Yosemite-specific.
23-04-2015

I have only tested this on Yosemite, so you could be right, but I do not know how the bug affects other OS versions or other OS'es
23-04-2015

This is Mac-specific, right? And is it limited to 10.10 (Yosemite)? I don't have my Mac handy, but will test it later today.
23-04-2015