Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions osu.Framework/Platform/SDL2/SDL2Window_Windowing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,18 @@ public WindowState WindowState
/// </remarks>
private void fetchDisplays()
{
Displays = getSDLDisplays();
DisplaysChanged?.Invoke(Displays);
var newDisplays = getSDLDisplays();

if (newDisplays.Length > 0)
{
Displays = newDisplays;
DisplaysChanged?.Invoke(newDisplays);
}
else
{
// keep Displays stale if zero displays are currently detected
Logger.Log("Got zero displays from SDL, ignoring.");
}
}

/// <summary>
Expand All @@ -328,7 +338,7 @@ private static ImmutableArray<Display> getSDLDisplays()
{
int numDisplays = SDL_GetNumVideoDisplays();

if (numDisplays <= 0)
if (numDisplays < 0)
throw new InvalidOperationException($"Failed to get number of SDL displays. Return code: {numDisplays}. SDL Error: {SDL_GetError()}");

var builder = ImmutableArray.CreateBuilder<Display>(numDisplays);
Expand Down
14 changes: 12 additions & 2 deletions osu.Framework/Platform/SDL3/SDL3Window_Windowing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,18 @@ public WindowState WindowState
/// </remarks>
private void fetchDisplays()
{
Displays = getSDLDisplays();
DisplaysChanged?.Invoke(Displays);
var newDisplays = getSDLDisplays();

if (newDisplays.Length > 0)
{
Displays = newDisplays;
DisplaysChanged?.Invoke(newDisplays);
}
else
{
// keep Displays stale if zero displays are currently detected
Logger.Log("Got zero displays from SDL, ignoring.");
}
}

/// <summary>
Expand Down
Loading