HaxeFlixel / HaxeFlixel/flixel

Fullscreen toggle unreliable? (MacOS)

Open
#3,089 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haxe
Stars
2.2k
Forks
522
Avg merge
34m
Merged PRs (30d)
1

Description

  • Haxe version: 4.2.5
  • Flixel version: 5.6.2
  • OpenFL version: 9.3.3-L3uoGG
  • Lime version: 8.1.2
  • Affected targets: MacOS 14.0 (23A344)

Code snippet reproducing the issue:


import flixel.FlxG;
import flixel.FlxState;

class PlayState extends FlxState
{
	override public function create()
	{
		super.create();
	}

	var fullscreen_cached:Bool = false;

	override public function update(elapsed:Float)
	{
		super.update(elapsed);
		// trace elapsed
		FlxG.watch.addQuick("FlxG.fullscreen", FlxG.fullscreen);
		// FlxG.watch.addQuick("displaystate", stage.displayState);
		if (FlxG.keys.justPressed.F)
		{
			FlxG.fullscreen = !FlxG.fullscreen;
		}
		if (FlxG.keys.justPressed.G)
		{
			FlxG.stage.window.fullscreen = !FlxG.stage.window.fullscreen;
		}
		if (FlxG.keys.justPressed.H)
		{
			fullscreen_cached = !fullscreen_cached;
			FlxG.stage.window.fullscreen = fullscreen_cached;
		}
	}
}

Observed behavior:
The game starts windowed mode (either neko or CPP builds have it).
Optional: Press F2 to open debug window to see FlxG.fullscreen in the watch panel.
1: Press F to toggle to fullscreen
2: Press F again. Note in the debug window that FlxG.fullscreen is now false, even though the game remains in windowed mode.
3: Press F again. FlxG.fullscreen is now true, and the game remains in fullscreen.
4: Press F again. This time it switches to windowed mode, and in the debugger, FlxG.fullscreen is now negative
(you can keep pressing F and the behaviour loops)

Expected behavior:
I expect step 2 to bring me back to windowed mode.

Also note, pressing G to assign FlxG.state.window.fullscreen also has errors, but you press it three times to go back to windowed rather than four. Caching the value yourself as in H works. (But doesn't keep track of the user manually maximising the window by pressing the button).

I guess I should see if Lime... has this behaviour as well. Indeed it does, though...slightly different behaviour - https://github.com/openfl/lime/issues/1771

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Haxe reproduction in the issue and compare FlxG.fullscreen with FlxG.stage.window.fullscreen on macOS. Review the linked Lime issue for related behavior before tracing the fullscreen state changes. Done means the reproduction returns to windowed mode on the second F press and remains consistent with the expected toggle behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos
Domain
desktop-dev, game-dev, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.