Skip to content

Commit 279a50c

Browse files
committed
wayland: Fall-back to the compositor for fullscreen-desktop window placement
Only use the specified output if an exclusive mode is being used, or a position was explicitly requested before entering fullscreen desktop. Otherwise, let the compositor handle placement, as it has more information about where the window is and where it should go, especially if fullscreen was requested before the window was fully mapped, or the window spans multiple outputs.
1 parent ea995b1 commit 279a50c

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/video/wayland/SDL_waylandwindow.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ static void Wayland_move_window(SDL_Window *window)
589589
}
590590
}
591591

592-
static void SetFullscreen(SDL_Window *window, struct wl_output *output)
592+
static void SetFullscreen(SDL_Window *window, struct wl_output *output, bool fullscreen)
593593
{
594594
SDL_WindowData *wind = window->internal;
595595
SDL_VideoData *viddata = wind->waylandData;
@@ -602,7 +602,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output)
602602

603603
wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : false;
604604
++wind->fullscreen_deadline_count;
605-
if (output) {
605+
if (fullscreen) {
606606
Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, true);
607607
wl_surface_commit(wind->surface);
608608

@@ -619,7 +619,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output)
619619

620620
wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : false;
621621
++wind->fullscreen_deadline_count;
622-
if (output) {
622+
if (fullscreen) {
623623
Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, true);
624624
wl_surface_commit(wind->surface);
625625

@@ -655,7 +655,7 @@ static void UpdateWindowFullscreen(SDL_Window *window, bool fullscreen)
655655
SDL_VideoDisplay *disp = SDL_GetVideoDisplay(window->current_fullscreen_mode.displayID);
656656
if (disp) {
657657
wind->fullscreen_was_positioned = true;
658-
SetFullscreen(window, disp->internal->output);
658+
SetFullscreen(window, disp->internal->output, true);
659659
}
660660
}
661661
}
@@ -2314,7 +2314,19 @@ SDL_FullscreenResult Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Win
23142314
// Don't send redundant fullscreen set/unset events.
23152315
if (!!fullscreen != wind->is_fullscreen) {
23162316
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);
23182330
} else if (wind->is_fullscreen) {
23192331
/*
23202332
* 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
23252337
*/
23262338
if (wind->last_displayID != display->id) {
23272339
wind->fullscreen_was_positioned = true;
2328-
SetFullscreen(window, output);
2340+
SetFullscreen(window, output, true);
23292341
} else {
23302342
ConfigureWindowGeometry(window);
23312343
CommitLibdecorFrame(window);
@@ -2759,7 +2771,7 @@ bool Wayland_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window)
27592771
SDL_VideoDisplay *display = SDL_GetVideoDisplayForFullscreenWindow(window);
27602772
if (display && wind->last_displayID != display->id) {
27612773
struct wl_output *output = display->internal->output;
2762-
SetFullscreen(window, output);
2774+
SetFullscreen(window, output, true);
27632775

27642776
return true;
27652777
}

0 commit comments

Comments
 (0)