Skip to content

Commit

Permalink
Work around SDL display hotplugging timing issue. (#470)
Browse files Browse the repository at this point in the history
When adapters suddenly disappear, windows are moved and index of display might have changed, but display events may come after the move event, leading to out-of-bounds exceptions.
  • Loading branch information
jfmu authored Jan 2, 2024
1 parent 303edb5 commit 4b4b822
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/FNAPlatform/SDL2_FNAPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,12 @@ ref bool textInputSuppress
int newIndex = SDL.SDL_GetWindowDisplayIndex(
game.Window.Handle
);

if (newIndex >= GraphicsAdapter.Adapters.Count)
{
GraphicsAdapter.AdaptersChanged(); // quickfix for this event coming in before the display reattach event. (must be fixed in sdl)
}

if (GraphicsAdapter.Adapters[newIndex] != currentAdapter)
{
currentAdapter = GraphicsAdapter.Adapters[newIndex];
Expand Down

0 comments on commit 4b4b822

Please sign in to comment.