Skip to content

Commit

Permalink
Bring back borderless mode for macOS and Linux
Browse files Browse the repository at this point in the history
This partially reverts 0e78180
  • Loading branch information
Susko3 committed Apr 22, 2024
1 parent 69a26ce commit f3dfc4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions osu.Framework/Platform/SDL/SDL3Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -859,16 +859,17 @@ public static SDL_Scancode ToScancode(this InputKey inputKey)
}
}

public static WindowState ToWindowState(this SDL_WindowFlags windowFlags)
public static WindowState ToWindowState(this SDL_WindowFlags windowFlags, bool isFullscreenBorderless)
{
// for windows
if (windowFlags.HasFlagFast(SDL_WindowFlags.SDL_WINDOW_BORDERLESS))
return WindowState.FullscreenBorderless;

if (windowFlags.HasFlagFast(SDL_WindowFlags.SDL_WINDOW_MINIMIZED))
return WindowState.Minimised;

if (windowFlags.HasFlagFast(SDL_WindowFlags.SDL_WINDOW_FULLSCREEN))
return WindowState.Fullscreen;
return isFullscreenBorderless ? WindowState.FullscreenBorderless : WindowState.Fullscreen;

if (windowFlags.HasFlagFast(SDL_WindowFlags.SDL_WINDOW_MAXIMIZED))
return WindowState.Maximised;
Expand Down
18 changes: 12 additions & 6 deletions osu.Framework/Platform/SDL3Window_Windowing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ public virtual IEnumerable<WindowMode> SupportedWindowModes
if (RuntimeInfo.IsMobile)
return new[] { Configuration.WindowMode.Fullscreen };

if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows)
return Enum.GetValues<WindowMode>();

return new[] { Configuration.WindowMode.Windowed, Configuration.WindowMode.Fullscreen };
return Enum.GetValues<WindowMode>();
}
}

Expand Down Expand Up @@ -577,7 +574,7 @@ private unsafe void updateAndFetchWindowSpecifics()
}
else
{
windowState = SDL3.SDL_GetWindowFlags(SDLWindowHandle).ToWindowState();
windowState = SDL3.SDL_GetWindowFlags(SDLWindowHandle).ToWindowState(SDL3.SDL_GetWindowFullscreenMode(SDLWindowHandle) == null);
}

if (windowState != stateBefore)
Expand Down Expand Up @@ -799,7 +796,16 @@ private void storeWindowSizeToConfig()
/// <returns>
/// The size of the borderless window's draw area.
/// </returns>
protected virtual Size SetBorderless(Display display) => throw new PlatformNotSupportedException();
protected virtual unsafe Size SetBorderless(Display display)
{
ensureWindowOnDisplay(display);

// this is a generally sane method of handling borderless, and works well on macOS and linux.
SDL3.SDL_SetWindowFullscreenMode(SDLWindowHandle, null);
SDL3.SDL_SetWindowFullscreen(SDLWindowHandle, SDL_bool.SDL_TRUE);

return display.Bounds.Size;
}

#endregion

Expand Down

0 comments on commit f3dfc4a

Please sign in to comment.