Skip to content

Commit f29c94a

Browse files
committed
wayland: Remove the hack to unset window limits before entering fullscreen
This was to work around a bug in old versions of GNOME, which has since been fixed.
1 parent 221d1f1 commit f29c94a

File tree

2 files changed

+20
-47
lines changed

2 files changed

+20
-47
lines changed

src/video/wayland/SDL_waylandwindow.c

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static void SetMinMaxDimensions(SDL_Window *window)
149149
SDL_WindowData *wind = window->internal;
150150
int min_width, min_height, max_width, max_height;
151151

152-
if ((window->flags & SDL_WINDOW_FULLSCREEN) || wind->fullscreen_deadline_count) {
152+
if (window->flags & SDL_WINDOW_FULLSCREEN) {
153153
min_width = 0;
154154
min_height = 0;
155155
max_width = 0;
@@ -486,38 +486,21 @@ static void CommitLibdecorFrame(SDL_Window *window)
486486
#endif
487487
}
488488

489-
static void fullscreen_deadline_handler(void *data, struct wl_callback *callback, uint32_t callback_data)
489+
static void window_state_deadline_handler(void *data, struct wl_callback *callback, uint32_t callback_data)
490490
{
491491
// Get the window from the ID as it may have been destroyed
492492
SDL_WindowID windowID = (SDL_WindowID)((uintptr_t)data);
493493
SDL_Window *window = SDL_GetWindowFromID(windowID);
494494

495495
if (window && window->internal) {
496-
window->internal->fullscreen_deadline_count--;
496+
window->internal->window_state_deadline_count--;
497497
}
498498

499499
wl_callback_destroy(callback);
500500
}
501501

502-
static struct wl_callback_listener fullscreen_deadline_listener = {
503-
fullscreen_deadline_handler
504-
};
505-
506-
static void maximized_restored_deadline_handler(void *data, struct wl_callback *callback, uint32_t callback_data)
507-
{
508-
// Get the window from the ID as it may have been destroyed
509-
SDL_WindowID windowID = (SDL_WindowID)((uintptr_t)data);
510-
SDL_Window *window = SDL_GetWindowFromID(windowID);
511-
512-
if (window && window->internal) {
513-
window->internal->maximized_restored_deadline_count--;
514-
}
515-
516-
wl_callback_destroy(callback);
517-
}
518-
519-
static struct wl_callback_listener maximized_restored_deadline_listener = {
520-
maximized_restored_deadline_handler
502+
static struct wl_callback_listener window_state_deadline_listener = {
503+
window_state_deadline_handler
521504
};
522505

523506
static void FlushPendingEvents(SDL_Window *window)
@@ -526,7 +509,7 @@ static void FlushPendingEvents(SDL_Window *window)
526509
const bool last_position_pending = window->last_position_pending;
527510
const bool last_size_pending = window->last_size_pending;
528511

529-
while (window->internal->fullscreen_deadline_count || window->internal->maximized_restored_deadline_count) {
512+
while (window->internal->window_state_deadline_count) {
530513
WAYLAND_wl_display_roundtrip(window->internal->waylandData->display);
531514
}
532515

@@ -601,11 +584,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output, bool ful
601584
}
602585

603586
wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : false;
604-
++wind->fullscreen_deadline_count;
605587
if (fullscreen) {
606-
Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, true);
607-
wl_surface_commit(wind->surface);
608-
609588
libdecor_frame_set_fullscreen(wind->shell_surface.libdecor.frame, output);
610589
} else {
611590
libdecor_frame_unset_fullscreen(wind->shell_surface.libdecor.frame);
@@ -618,20 +597,17 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output, bool ful
618597
}
619598

620599
wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : false;
621-
++wind->fullscreen_deadline_count;
622600
if (fullscreen) {
623-
Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, true);
624-
wl_surface_commit(wind->surface);
625-
626601
xdg_toplevel_set_fullscreen(wind->shell_surface.xdg.toplevel.xdg_toplevel, output);
627602
} else {
628603
xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.toplevel.xdg_toplevel);
629604
}
630605
}
631606

632607
// Queue a deadline event
608+
++wind->window_state_deadline_count;
633609
struct wl_callback *cb = wl_display_sync(viddata->display);
634-
wl_callback_add_listener(cb, &fullscreen_deadline_listener, (void *)((uintptr_t)window->id));
610+
wl_callback_add_listener(cb, &window_state_deadline_listener, (void *)((uintptr_t)window->id));
635611
}
636612

637613
static void UpdateWindowFullscreen(SDL_Window *window, bool fullscreen)
@@ -2391,8 +2367,7 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window)
23912367
}
23922368

23932369
// Not currently fullscreen or maximized, and no state pending; nothing to do.
2394-
if (!(window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED)) &&
2395-
!wind->fullscreen_deadline_count && !wind->maximized_restored_deadline_count) {
2370+
if (!(window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED)) && !wind->window_state_deadline_count) {
23962371
return;
23972372
}
23982373

@@ -2403,9 +2378,9 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window)
24032378
}
24042379
libdecor_frame_unset_maximized(wind->shell_surface.libdecor.frame);
24052380

2406-
++wind->maximized_restored_deadline_count;
2381+
++wind->window_state_deadline_count;
24072382
struct wl_callback *cb = wl_display_sync(_this->internal->display);
2408-
wl_callback_add_listener(cb, &maximized_restored_deadline_listener, (void *)((uintptr_t)window->id));
2383+
wl_callback_add_listener(cb, &window_state_deadline_listener, (void *)((uintptr_t)window->id));
24092384
} else
24102385
#endif
24112386
// Note that xdg-shell does NOT provide a way to unset minimize!
@@ -2415,9 +2390,9 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window)
24152390
}
24162391
xdg_toplevel_unset_maximized(wind->shell_surface.xdg.toplevel.xdg_toplevel);
24172392

2418-
++wind->maximized_restored_deadline_count;
2393+
++wind->window_state_deadline_count;
24192394
struct wl_callback *cb = wl_display_sync(_this->internal->display);
2420-
wl_callback_add_listener(cb, &maximized_restored_deadline_listener, (void *)((uintptr_t)window->id));
2395+
wl_callback_add_listener(cb, &window_state_deadline_listener, (void *)((uintptr_t)window->id));
24212396
}
24222397
}
24232398

@@ -2477,8 +2452,7 @@ void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
24772452
}
24782453

24792454
// Not fullscreen, already maximized, and no state pending; nothing to do.
2480-
if (!(window->flags & SDL_WINDOW_FULLSCREEN) && (window->flags & SDL_WINDOW_MAXIMIZED) &&
2481-
!wind->fullscreen_deadline_count && !wind->maximized_restored_deadline_count) {
2455+
if (!(window->flags & SDL_WINDOW_FULLSCREEN) && (window->flags & SDL_WINDOW_MAXIMIZED) && !wind->window_state_deadline_count) {
24822456
return;
24832457
}
24842458

@@ -2492,9 +2466,9 @@ void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
24922466
wl_surface_commit(wind->surface);
24932467
libdecor_frame_set_maximized(wind->shell_surface.libdecor.frame);
24942468

2495-
++wind->maximized_restored_deadline_count;
2469+
++wind->window_state_deadline_count;
24962470
struct wl_callback *cb = wl_display_sync(viddata->display);
2497-
wl_callback_add_listener(cb, &maximized_restored_deadline_listener, (void *)((uintptr_t)window->id));
2471+
wl_callback_add_listener(cb, &window_state_deadline_listener, (void *)((uintptr_t)window->id));
24982472
} else
24992473
#endif
25002474
if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) {
@@ -2506,9 +2480,9 @@ void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
25062480
wl_surface_commit(wind->surface);
25072481
xdg_toplevel_set_maximized(wind->shell_surface.xdg.toplevel.xdg_toplevel);
25082482

2509-
++wind->maximized_restored_deadline_count;
2483+
++wind->window_state_deadline_count;
25102484
struct wl_callback *cb = wl_display_sync(viddata->display);
2511-
wl_callback_add_listener(cb, &maximized_restored_deadline_listener, (void *)((uintptr_t)window->id));
2485+
wl_callback_add_listener(cb, &window_state_deadline_listener, (void *)((uintptr_t)window->id));
25122486
}
25132487
}
25142488

@@ -3066,7 +3040,7 @@ bool Wayland_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window)
30663040

30673041
do {
30683042
WAYLAND_wl_display_roundtrip(_this->internal->display);
3069-
} while (wind->fullscreen_deadline_count || wind->maximized_restored_deadline_count);
3043+
} while (wind->window_state_deadline_count);
30703044

30713045
return true;
30723046
}

src/video/wayland/SDL_waylandwindow.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ struct SDL_WindowData
194194
} text_input_props;
195195

196196
SDL_DisplayID last_displayID;
197-
int fullscreen_deadline_count;
198-
int maximized_restored_deadline_count;
197+
int window_state_deadline_count;
199198
Uint64 last_focus_event_time_ns;
200199
int icc_fd;
201200
Uint32 icc_size;

0 commit comments

Comments
 (0)