aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Headless.SDL2/WindowBase.cs
diff options
context:
space:
mode:
authorTheun de Bruijn <theun@theundebruijn.com>2023-07-06 20:10:15 +1000
committerGitHub <noreply@github.com>2023-07-06 12:10:15 +0200
commitc19c8bbadea027e4f31a0739fac0f2a27fbe6dbf (patch)
treefbe6f52943b04febdad14be7934881502af8a4a2 /src/Ryujinx.Headless.SDL2/WindowBase.cs
parent1c7a90ef359d9974e5bd257c4d8e9bf526a6966c (diff)
Headless: Add support for fullscreen option (#5339)
* Headless: Added support for fullscreen option * Headless: cleanup of fullscreen support * Headless: fullscreen support : implemented proposed changes * Headless: fullscreen support: cleanup * Headless: fullscreen support: fix for OpenGL scaling * Headless: fullscreen support: cleanup * Headless: fullscreen support: cleanup * Headless: fullscreen support: add. macOS fullscreen fix * Headless: fullscreen support: cleanup * Headless: fullscreen support: cleanup * Headless: fullscreen support: cleanup
Diffstat (limited to 'src/Ryujinx.Headless.SDL2/WindowBase.cs')
-rw-r--r--src/Ryujinx.Headless.SDL2/WindowBase.cs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/Ryujinx.Headless.SDL2/WindowBase.cs b/src/Ryujinx.Headless.SDL2/WindowBase.cs
index 2fcd00f8..c542a4e6 100644
--- a/src/Ryujinx.Headless.SDL2/WindowBase.cs
+++ b/src/Ryujinx.Headless.SDL2/WindowBase.cs
@@ -55,6 +55,7 @@ namespace Ryujinx.Headless.SDL2
public IHostUiTheme HostUiTheme { get; }
public int Width { get; private set; }
public int Height { get; private set; }
+ public bool IsFullscreen { get; set; }
protected SDL2MouseDriver MouseDriver;
private readonly InputManager _inputManager;
@@ -158,7 +159,9 @@ namespace Ryujinx.Headless.SDL2
string titleIdSection = string.IsNullOrWhiteSpace(activeProcess.ProgramIdText) ? string.Empty : $" ({activeProcess.ProgramIdText.ToUpper()})";
string titleArchSection = activeProcess.Is64Bit ? " (64-bit)" : " (32-bit)";
- WindowHandle = SDL_CreateWindow($"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, DefaultWidth, DefaultHeight, DefaultFlags | GetWindowFlags());
+ SDL_WindowFlags fullscreenFlag = IsFullscreen ? SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP : 0;
+
+ WindowHandle = SDL_CreateWindow($"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, DefaultWidth, DefaultHeight, DefaultFlags | fullscreenFlag | GetWindowFlags());
if (WindowHandle == IntPtr.Zero)
{
@@ -185,10 +188,16 @@ namespace Ryujinx.Headless.SDL2
switch (evnt.window.windowEvent)
{
case SDL_WindowEventID.SDL_WINDOWEVENT_SIZE_CHANGED:
- Width = evnt.window.data1;
- Height = evnt.window.data2;
- Renderer?.Window.SetSize(Width, Height);
- MouseDriver.SetClientSize(Width, Height);
+ // Unlike on Windows, this event fires on macOS when triggering fullscreen mode.
+ // And promptly crashes the process because `Renderer?.window.SetSize` is undefined.
+ // As we don't need this to fire in either case we can test for isFullscreen.
+ if (!IsFullscreen)
+ {
+ Width = evnt.window.data1;
+ Height = evnt.window.data2;
+ Renderer?.Window.SetSize(Width, Height);
+ MouseDriver.SetClientSize(Width, Height);
+ }
break;
case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE: