Command-Tab disable while on fullscreen on MacOS?

Hey there, I’ve noticed that I can’t use the Command-Tab to switch windows while on Fullscreen on MacOS. Meanwhile, alt-tabbing works just fine on Linux and Windows.

Here is the code I’m using to set the game as fullscreen.

Device.PreferredBackBufferWidth = Width;
Device.PreferredBackBufferHeight = Height;
Device.IsFullScreen = FullScreen;
Device.ApplyChanges();

Is this a intentional behavior?

1 Like

That sounds like something SDL does… (we use SDL for window management on Mac/Linux) it might just be what SDL does.

If you set graphics.HardwareModeSwitch = false that might fix it, since you get a “soft” fullscreen.

1 Like

What version of MG are you using?

Thanks @dellis1972. I’ll try this as soon as I can.

I’m using the 3.6 version.

Setting graphics.HardwareModeSwitch = false works, I can switch windows using command-tab now, sadly, it breaks how my “resolution manager” works.
The code I’m using for resolution independence is a somewhat modified version of this:

http://blog.roboblob.com/2013/07/27/solving-resolution-independent-rendering-and-2d-camera-using-monogame/comment-page-1/

With an addition of this code to set the window’s height and width.

private static void ApplyResolutionSettings ()
{

#if DESKTOPGL
	OperatingSystem os = Environment.OSVersion;
	if(os.Platform == PlatformID.MacOSX)
		_Device.HardwareModeSwitch = false;

	if (os.Platform == PlatformID.Unix
	      & Directory.Exists ("/System")
	      & Directory.Exists ("/Users")
	      & Directory.Exists ("/Volumes")) 
		_Device.HardwareModeSwitch = false;
#endif

	// If we aren't using a full screen mode, the height and width of the window can
	// be set to anything equal to or smaller than the actual screen size.
	if (_FullScreen == false) {
		if ((ScreenWidth <= GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width)
			&& (ScreenHeight <= GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height)) {
				_Device.PreferredBackBufferWidth = ScreenWidth;
				_Device.PreferredBackBufferHeight = ScreenHeight;
				_Device.IsFullScreen = _FullScreen;
				_Device.ApplyChanges ();


		}
	} else {
		// If we are using full screen mode, we should check to make sure that the display
		// adapter can handle the video mode we are trying to set.  To do this, we will
		// iterate through the display modes supported by the adapter and check them against
		// the mode we want to set.
		foreach (DisplayMode dm in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) {
			// Check the width and height of each mode against the passed values
			if ((dm.Width == ScreenWidth) && (dm.Height == ScreenHeight)) {
				// The mode is supported, so set the buffer formats, apply changes and return
				_Device.PreferredBackBufferWidth = ScreenWidth;
				_Device.PreferredBackBufferHeight = ScreenHeight;
				_Device.IsFullScreen = _FullScreen;
				_Device.ApplyChanges ();
			}
		}
	}

	_dirtyMatrix = true;

	ScreenWidth = _Device.PreferredBackBufferWidth;
	ScreenHeight = _Device.PreferredBackBufferHeight;  
}

With alse _Device.HardwareModeSwitch = false, only works properly if the user sets the game resolution exactly as it own screen resolution.

It would be great if it were possible to use Command-Tab while HardwareModeSwitch were true.
So it is this an SDL2 bug?

1 Like

This will be down to how SDL works I’m afraid. It handles all the window management.
Device.HardwareModeSwitch = false effectively gives you a windowless fullscreen app using whatever the desktop resolution is,.
Device.HardwareModeSwitch = true, changes the hardware display mode.

I’ve noticed that my SDL2 version on MacOS still in version 2.0.0 while, on my linux port, it is on 2.0.5.
Maybe updating it could do the trick, can I simply override the file?