diff --git a/osu.Framework/Platform/SDL3/SDL3Extensions.cs b/osu.Framework/Platform/SDL3/SDL3Extensions.cs index 711d57fe1b..e2b77fc67e 100644 --- a/osu.Framework/Platform/SDL3/SDL3Extensions.cs +++ b/osu.Framework/Platform/SDL3/SDL3Extensions.cs @@ -860,8 +860,9 @@ 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; @@ -869,7 +870,7 @@ public static WindowState ToWindowState(this SDL_WindowFlags windowFlags) 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; diff --git a/osu.Framework/Platform/SDL3/SDL3Window.cs b/osu.Framework/Platform/SDL3/SDL3Window.cs index bb03b60937..33e509828f 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window.cs @@ -316,7 +316,7 @@ protected void HandleEventFromWatch(SDL_Event evt) case SDL_EventType.SDL_EVENT_WINDOW_RESIZED: // polling via SDL_PollEvent blocks on resizes (https://stackoverflow.com/a/50858339) if (!updatingWindowStateAndSize) - fetchWindowSize(); + fetchWindowSize(storeToConfig: false); break; } diff --git a/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs b/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs index a32d9af91c..42b79980dc 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs @@ -149,10 +149,7 @@ public virtual IEnumerable SupportedWindowModes if (RuntimeInfo.IsMobile) return new[] { Configuration.WindowMode.Fullscreen }; - if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows) - return Enum.GetValues(); - - return new[] { Configuration.WindowMode.Windowed, Configuration.WindowMode.Fullscreen }; + return Enum.GetValues(); } } @@ -447,7 +444,7 @@ private unsafe Rectangle windowDisplayBounds /// Updates and according to SDL state. /// /// Whether the window size has been changed after updating. - private unsafe void fetchWindowSize() + private unsafe void fetchWindowSize(bool storeToConfig = true) { int w, h; SDL_GetWindowSize(SDLWindowHandle, &w, &h); @@ -462,7 +459,8 @@ private unsafe void fetchWindowSize() Scale = (float)drawableW / w; Size = new Size(w, h); - storeWindowSizeToConfig(); + if (storeToConfig) + storeWindowSizeToConfig(); } #region SDL Event Handling @@ -583,7 +581,7 @@ private unsafe void updateAndFetchWindowSpecifics() } else { - windowState = SDL_GetWindowFlags(SDLWindowHandle).ToWindowState(); + windowState = SDL_GetWindowFlags(SDLWindowHandle).ToWindowState(SDL_GetWindowFullscreenMode(SDLWindowHandle) == null); } if (windowState != stateBefore) @@ -805,7 +803,16 @@ private void storeWindowSizeToConfig() /// /// The size of the borderless window's draw area. /// - 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. + SDL_SetWindowFullscreenMode(SDLWindowHandle, null); + SDL_SetWindowFullscreen(SDLWindowHandle, true); + + return display.Bounds.Size; + } #endregion