@@ -589,7 +589,7 @@ static void Wayland_move_window(SDL_Window *window)
589
589
}
590
590
}
591
591
592
- static void SetFullscreen (SDL_Window * window , struct wl_output * output )
592
+ static void SetFullscreen (SDL_Window * window , struct wl_output * output , bool fullscreen )
593
593
{
594
594
SDL_WindowData * wind = window -> internal ;
595
595
SDL_VideoData * viddata = wind -> waylandData ;
@@ -602,7 +602,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output)
602
602
603
603
wind -> fullscreen_exclusive = output ? window -> fullscreen_exclusive : false;
604
604
++ wind -> fullscreen_deadline_count ;
605
- if (output ) {
605
+ if (fullscreen ) {
606
606
Wayland_SetWindowResizable (SDL_GetVideoDevice (), window , true);
607
607
wl_surface_commit (wind -> surface );
608
608
@@ -619,7 +619,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output)
619
619
620
620
wind -> fullscreen_exclusive = output ? window -> fullscreen_exclusive : false;
621
621
++ wind -> fullscreen_deadline_count ;
622
- if (output ) {
622
+ if (fullscreen ) {
623
623
Wayland_SetWindowResizable (SDL_GetVideoDevice (), window , true);
624
624
wl_surface_commit (wind -> surface );
625
625
@@ -655,7 +655,7 @@ static void UpdateWindowFullscreen(SDL_Window *window, bool fullscreen)
655
655
SDL_VideoDisplay * disp = SDL_GetVideoDisplay (window -> current_fullscreen_mode .displayID );
656
656
if (disp ) {
657
657
wind -> fullscreen_was_positioned = true;
658
- SetFullscreen (window , disp -> internal -> output );
658
+ SetFullscreen (window , disp -> internal -> output , true );
659
659
}
660
660
}
661
661
}
@@ -2314,7 +2314,19 @@ SDL_FullscreenResult Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Win
2314
2314
// Don't send redundant fullscreen set/unset events.
2315
2315
if (!!fullscreen != wind -> is_fullscreen ) {
2316
2316
wind -> fullscreen_was_positioned = !!fullscreen ;
2317
- SetFullscreen (window , fullscreen ? output : NULL );
2317
+
2318
+ /* Only use the specified output if an exclusive mode is being used, or a position was explicitly requested
2319
+ * before entering fullscreen desktop. Otherwise, let the compositor handle placement, as it has more
2320
+ * information about where the window is and where it should go, particularly if fullscreen is being requested
2321
+ * before the window is mapped, or the window spans multiple outputs.
2322
+ */
2323
+ if (!window -> fullscreen_exclusive ) {
2324
+ if (window -> undefined_x || window -> undefined_y ||
2325
+ (wind -> num_outputs && !window -> last_position_pending )) {
2326
+ output = NULL ;
2327
+ }
2328
+ }
2329
+ SetFullscreen (window , output , !!fullscreen );
2318
2330
} else if (wind -> is_fullscreen ) {
2319
2331
/*
2320
2332
* If the window is already fullscreen, this is likely a request to switch between
@@ -2325,7 +2337,7 @@ SDL_FullscreenResult Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Win
2325
2337
*/
2326
2338
if (wind -> last_displayID != display -> id ) {
2327
2339
wind -> fullscreen_was_positioned = true;
2328
- SetFullscreen (window , output );
2340
+ SetFullscreen (window , output , true );
2329
2341
} else {
2330
2342
ConfigureWindowGeometry (window );
2331
2343
CommitLibdecorFrame (window );
@@ -2759,7 +2771,7 @@ bool Wayland_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window)
2759
2771
SDL_VideoDisplay * display = SDL_GetVideoDisplayForFullscreenWindow (window );
2760
2772
if (display && wind -> last_displayID != display -> id ) {
2761
2773
struct wl_output * output = display -> internal -> output ;
2762
- SetFullscreen (window , output );
2774
+ SetFullscreen (window , output , true );
2763
2775
2764
2776
return true;
2765
2777
}
0 commit comments