@@ -181,7 +181,7 @@ static void SetMinMaxDimensions(SDL_Window *window)
181
181
182
182
#ifdef HAVE_LIBDECOR_H
183
183
if (wind -> shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR ) {
184
- if (!wind -> shell_surface .libdecor .initial_configure_seen || ! wind -> shell_surface . libdecor . frame ) {
184
+ if (!wind -> shell_surface .libdecor .frame ) {
185
185
return ; // Can't do anything yet, wait for ShowWindow
186
186
}
187
187
/* No need to change these values if the window is non-resizable,
@@ -198,7 +198,7 @@ static void SetMinMaxDimensions(SDL_Window *window)
198
198
} else
199
199
#endif
200
200
if (wind -> shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL ) {
201
- if (wind -> shell_surface .xdg .toplevel .xdg_toplevel == NULL ) {
201
+ if (! wind -> shell_surface .xdg .toplevel .xdg_toplevel ) {
202
202
return ; // Can't do anything yet, wait for ShowWindow
203
203
}
204
204
xdg_toplevel_set_min_size (wind -> shell_surface .xdg .toplevel .xdg_toplevel ,
@@ -750,7 +750,9 @@ static void handle_configure_xdg_shell_surface(void *data, struct xdg_surface *x
750
750
xdg_surface_ack_configure (xdg , serial );
751
751
}
752
752
753
- wind -> shell_surface .xdg .initial_configure_seen = true;
753
+ if (wind -> shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE ) {
754
+ wind -> shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME ;
755
+ }
754
756
}
755
757
756
758
static const struct xdg_surface_listener shell_surface_listener_xdg = {
@@ -980,10 +982,6 @@ static void handle_configure_xdg_toplevel(void *data,
980
982
wind -> active = active ;
981
983
window -> tiled = tiled ;
982
984
wind -> resizing = resizing ;
983
-
984
- if (wind -> shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE ) {
985
- wind -> shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME ;
986
- }
987
985
}
988
986
989
987
static void handle_close_xdg_toplevel (void * data , struct xdg_toplevel * xdg_toplevel )
@@ -1132,9 +1130,7 @@ static void handle_configure_zxdg_decoration(void *data,
1132
1130
WAYLAND_wl_display_roundtrip (internal -> waylandData -> display );
1133
1131
1134
1132
Wayland_HideWindow (device , window );
1135
- SDL_zero (internal -> shell_surface );
1136
1133
internal -> shell_surface_type = WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR ;
1137
-
1138
1134
Wayland_ShowWindow (device , window );
1139
1135
}
1140
1136
}
@@ -1417,11 +1413,8 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
1417
1413
libdecor_state_free (state );
1418
1414
}
1419
1415
1420
- if (!wind -> shell_surface .libdecor .initial_configure_seen ) {
1421
- LibdecorGetMinContentSize (frame , & wind -> system_limits .min_width , & wind -> system_limits .min_height );
1422
- wind -> shell_surface .libdecor .initial_configure_seen = true;
1423
- }
1424
1416
if (wind -> shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE ) {
1417
+ LibdecorGetMinContentSize (frame , & wind -> system_limits .min_width , & wind -> system_limits .min_height );
1425
1418
wind -> shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME ;
1426
1419
}
1427
1420
@@ -1830,12 +1823,10 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
1830
1823
}
1831
1824
}
1832
1825
1833
- /* The window was hidden, but the sync point hasn't yet been reached.
1834
- * Pump events to avoid a possible protocol violation.
1835
- */
1836
- if (data -> show_hide_sync_required ) {
1826
+ // Always roundtrip to ensure there are no pending buffer attachments.
1827
+ do {
1837
1828
WAYLAND_wl_display_roundtrip (c -> display );
1838
- }
1829
+ } while ( data -> show_hide_sync_required );
1839
1830
1840
1831
data -> shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE ;
1841
1832
@@ -1996,7 +1987,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
1996
1987
#ifdef HAVE_LIBDECOR_H
1997
1988
if (data -> shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR ) {
1998
1989
if (data -> shell_surface .libdecor .frame ) {
1999
- while (! data -> shell_surface . libdecor . initial_configure_seen ) {
1990
+ while (data -> shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE ) {
2000
1991
WAYLAND_wl_display_flush (c -> display );
2001
1992
WAYLAND_wl_display_dispatch (c -> display );
2002
1993
}
@@ -2010,7 +2001,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window)
2010
2001
*/
2011
2002
wl_surface_commit (data -> surface );
2012
2003
if (data -> shell_surface .xdg .surface ) {
2013
- while (! data -> shell_surface . xdg . initial_configure_seen ) {
2004
+ while (data -> shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE ) {
2014
2005
WAYLAND_wl_display_flush (c -> display );
2015
2006
WAYLAND_wl_display_dispatch (c -> display );
2016
2007
}
@@ -2159,26 +2150,27 @@ void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window)
2159
2150
if (wind -> shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR ) {
2160
2151
if (wind -> shell_surface .libdecor .frame ) {
2161
2152
libdecor_frame_unref (wind -> shell_surface .libdecor .frame );
2162
- wind -> shell_surface .libdecor .frame = NULL ;
2163
2153
2164
2154
SDL_SetPointerProperty (props , SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER , NULL );
2165
2155
SDL_SetPointerProperty (props , SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER , NULL );
2166
2156
}
2167
2157
} else
2168
2158
#endif
2159
+ {
2169
2160
if (wind -> shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP ) {
2170
- Wayland_ReleasePopup (_this , window );
2171
- } else if (wind -> shell_surface .xdg .toplevel .xdg_toplevel ) {
2172
- xdg_toplevel_destroy (wind -> shell_surface .xdg .toplevel .xdg_toplevel );
2173
- wind -> shell_surface . xdg . toplevel . xdg_toplevel = NULL ;
2174
- SDL_SetPointerProperty ( props , SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER , NULL );
2175
- }
2176
- if (wind -> shell_surface .xdg .surface ) {
2177
- xdg_surface_destroy (wind -> shell_surface .xdg .surface );
2178
- wind -> shell_surface . xdg . surface = NULL ;
2179
- SDL_SetPointerProperty ( props , SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER , NULL );
2161
+ Wayland_ReleasePopup (_this , window );
2162
+ } else if (wind -> shell_surface .xdg .toplevel .xdg_toplevel ) {
2163
+ xdg_toplevel_destroy (wind -> shell_surface .xdg .toplevel .xdg_toplevel );
2164
+ SDL_SetPointerProperty ( props , SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER , NULL ) ;
2165
+ }
2166
+
2167
+ if (wind -> shell_surface .xdg .surface ) {
2168
+ xdg_surface_destroy (wind -> shell_surface .xdg .surface );
2169
+ SDL_SetPointerProperty ( props , SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER , NULL ) ;
2170
+ }
2180
2171
}
2181
2172
2173
+ SDL_zero (wind -> shell_surface );
2182
2174
wind -> show_hide_sync_required = true;
2183
2175
struct wl_callback * cb = wl_display_sync (_this -> internal -> display );
2184
2176
wl_callback_add_listener (cb , & show_hide_sync_listener , (void * )((uintptr_t )window -> id ));
0 commit comments