File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed
Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -302,8 +302,18 @@ public WindowState WindowState
302302 /// </remarks>
303303 private void fetchDisplays ( )
304304 {
305- Displays = getSDLDisplays ( ) ;
306- DisplaysChanged ? . Invoke ( Displays ) ;
305+ var newDisplays = getSDLDisplays ( ) ;
306+
307+ if ( newDisplays . Length > 0 )
308+ {
309+ Displays = newDisplays ;
310+ DisplaysChanged ? . Invoke ( newDisplays ) ;
311+ }
312+ else
313+ {
314+ // keep Displays stale if zero displays are currently detected
315+ Logger . Log ( "Got zero displays from SDL, ignoring." ) ;
316+ }
307317 }
308318
309319 /// <summary>
@@ -328,7 +338,7 @@ private static ImmutableArray<Display> getSDLDisplays()
328338 {
329339 int numDisplays = SDL_GetNumVideoDisplays ( ) ;
330340
331- if ( numDisplays <= 0 )
341+ if ( numDisplays < 0 )
332342 throw new InvalidOperationException ( $ "Failed to get number of SDL displays. Return code: { numDisplays } . SDL Error: { SDL_GetError ( ) } ") ;
333343
334344 var builder = ImmutableArray . CreateBuilder < Display > ( numDisplays ) ;
Original file line number Diff line number Diff line change @@ -306,8 +306,18 @@ public WindowState WindowState
306306 /// </remarks>
307307 private void fetchDisplays ( )
308308 {
309- Displays = getSDLDisplays ( ) ;
310- DisplaysChanged ? . Invoke ( Displays ) ;
309+ var newDisplays = getSDLDisplays ( ) ;
310+
311+ if ( newDisplays . Length > 0 )
312+ {
313+ Displays = newDisplays ;
314+ DisplaysChanged ? . Invoke ( newDisplays ) ;
315+ }
316+ else
317+ {
318+ // keep Displays stale if zero displays are currently detected
319+ Logger . Log ( "Got zero displays from SDL, ignoring." ) ;
320+ }
311321 }
312322
313323 /// <summary>
You can’t perform that action at this time.
0 commit comments