@@ -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
523506static 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
637613static void UpdateWindowFullscreen (SDL_Window * window , bool fullscreen )
@@ -2388,8 +2364,7 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window)
23882364 }
23892365
23902366 // Not currently fullscreen or maximized, and no state pending; nothing to do.
2391- if (!(window -> flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED )) &&
2392- !wind -> fullscreen_deadline_count && !wind -> maximized_restored_deadline_count ) {
2367+ if (!(window -> flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED )) && !wind -> window_state_deadline_count ) {
23932368 return ;
23942369 }
23952370
@@ -2400,9 +2375,9 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window)
24002375 }
24012376 libdecor_frame_unset_maximized (wind -> shell_surface .libdecor .frame );
24022377
2403- ++ wind -> maximized_restored_deadline_count ;
2378+ ++ wind -> window_state_deadline_count ;
24042379 struct wl_callback * cb = wl_display_sync (_this -> internal -> display );
2405- wl_callback_add_listener (cb , & maximized_restored_deadline_listener , (void * )((uintptr_t )window -> id ));
2380+ wl_callback_add_listener (cb , & window_state_deadline_listener , (void * )((uintptr_t )window -> id ));
24062381 } else
24072382#endif
24082383 // Note that xdg-shell does NOT provide a way to unset minimize!
@@ -2412,9 +2387,9 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window)
24122387 }
24132388 xdg_toplevel_unset_maximized (wind -> shell_surface .xdg .toplevel .xdg_toplevel );
24142389
2415- ++ wind -> maximized_restored_deadline_count ;
2390+ ++ wind -> window_state_deadline_count ;
24162391 struct wl_callback * cb = wl_display_sync (_this -> internal -> display );
2417- wl_callback_add_listener (cb , & maximized_restored_deadline_listener , (void * )((uintptr_t )window -> id ));
2392+ wl_callback_add_listener (cb , & window_state_deadline_listener , (void * )((uintptr_t )window -> id ));
24182393 }
24192394}
24202395
@@ -2474,8 +2449,7 @@ void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
24742449 }
24752450
24762451 // Not fullscreen, already maximized, and no state pending; nothing to do.
2477- if (!(window -> flags & SDL_WINDOW_FULLSCREEN ) && (window -> flags & SDL_WINDOW_MAXIMIZED ) &&
2478- !wind -> fullscreen_deadline_count && !wind -> maximized_restored_deadline_count ) {
2452+ if (!(window -> flags & SDL_WINDOW_FULLSCREEN ) && (window -> flags & SDL_WINDOW_MAXIMIZED ) && !wind -> window_state_deadline_count ) {
24792453 return ;
24802454 }
24812455
@@ -2489,9 +2463,9 @@ void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
24892463 wl_surface_commit (wind -> surface );
24902464 libdecor_frame_set_maximized (wind -> shell_surface .libdecor .frame );
24912465
2492- ++ wind -> maximized_restored_deadline_count ;
2466+ ++ wind -> window_state_deadline_count ;
24932467 struct wl_callback * cb = wl_display_sync (viddata -> display );
2494- wl_callback_add_listener (cb , & maximized_restored_deadline_listener , (void * )((uintptr_t )window -> id ));
2468+ wl_callback_add_listener (cb , & window_state_deadline_listener , (void * )((uintptr_t )window -> id ));
24952469 } else
24962470#endif
24972471 if (wind -> shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL ) {
@@ -2503,9 +2477,9 @@ void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window)
25032477 wl_surface_commit (wind -> surface );
25042478 xdg_toplevel_set_maximized (wind -> shell_surface .xdg .toplevel .xdg_toplevel );
25052479
2506- ++ wind -> maximized_restored_deadline_count ;
2480+ ++ wind -> window_state_deadline_count ;
25072481 struct wl_callback * cb = wl_display_sync (viddata -> display );
2508- wl_callback_add_listener (cb , & maximized_restored_deadline_listener , (void * )((uintptr_t )window -> id ));
2482+ wl_callback_add_listener (cb , & window_state_deadline_listener , (void * )((uintptr_t )window -> id ));
25092483 }
25102484}
25112485
@@ -3063,7 +3037,7 @@ bool Wayland_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window)
30633037
30643038 do {
30653039 WAYLAND_wl_display_roundtrip (_this -> internal -> display );
3066- } while (wind -> fullscreen_deadline_count || wind -> maximized_restored_deadline_count );
3040+ } while (wind -> window_state_deadline_count );
30673041
30683042 return true;
30693043}
0 commit comments