@@ -33,6 +33,7 @@ typedef struct Wayland_ColorInfoState
3333{
3434 struct wp_image_description_v1 * wp_image_description ;
3535 struct wp_image_description_info_v1 * wp_image_description_info ;
36+ struct wl_event_queue * queue ;
3637
3738 union
3839 {
@@ -73,6 +74,9 @@ void Wayland_FreeColorInfoState(Wayland_ColorInfoState *state)
7374{
7475 if (state ) {
7576 Wayland_CancelColorInfoRequest (state );
77+ if (state -> queue ) {
78+ WAYLAND_wl_event_queue_destroy (state -> queue );
79+ }
7680
7781 switch (state -> object_type ) {
7882 case WAYLAND_COLOR_OBJECT_TYPE_WINDOW :
@@ -212,18 +216,10 @@ static void PumpColorspaceEvents(Wayland_ColorInfoState *state)
212216 SDL_VideoData * vid = SDL_GetVideoDevice ()-> internal ;
213217
214218 // Run the image description sequence to completion in its own queue.
215- struct wl_event_queue * queue = WAYLAND_wl_display_create_queue (vid -> display );
216- if (state -> deferred_event_processing ) {
217- WAYLAND_wl_proxy_set_queue ((struct wl_proxy * )state -> wp_image_description_info , queue );
218- } else {
219- WAYLAND_wl_proxy_set_queue ((struct wl_proxy * )state -> wp_image_description , queue );
220- }
221-
222219 while (state -> wp_image_description ) {
223- WAYLAND_wl_display_dispatch_queue (vid -> display , queue );
220+ WAYLAND_wl_display_dispatch_queue (vid -> display , state -> queue );
224221 }
225222
226- WAYLAND_wl_event_queue_destroy (queue );
227223 Wayland_FreeColorInfoState (state );
228224}
229225
@@ -246,8 +242,20 @@ static void image_description_handle_ready(void *data,
246242{
247243 Wayland_ColorInfoState * state = (Wayland_ColorInfoState * )data ;
248244
249- // This will inherit the queue of the factory image description object.
250- state -> wp_image_description_info = wp_image_description_v1_get_information (state -> wp_image_description );
245+ /* If event processing was deferred, then the image description is on the default queue.
246+ * Otherwise, it will inherit the queue from the image description object.
247+ */
248+ if (state -> deferred_event_processing ) {
249+ SDL_VideoData * vid = SDL_GetVideoDevice ()-> internal ;
250+ state -> queue = Wayland_DisplayCreateQueue (vid -> display , "SDL Color Management Queue" );
251+
252+ struct wl_proxy * image_desc_wrapper = WAYLAND_wl_proxy_create_wrapper (state -> wp_image_description );
253+ WAYLAND_wl_proxy_set_queue (image_desc_wrapper , state -> queue );
254+ state -> wp_image_description_info = wp_image_description_v1_get_information ((struct wp_image_description_v1 * )image_desc_wrapper );
255+ WAYLAND_wl_proxy_wrapper_destroy (image_desc_wrapper );
256+ } else {
257+ state -> wp_image_description_info = wp_image_description_v1_get_information (state -> wp_image_description );
258+ }
251259 wp_image_description_info_v1_add_listener (state -> wp_image_description_info , & image_description_info_listener , data );
252260
253261 if (state -> deferred_event_processing ) {
@@ -271,7 +279,17 @@ void Wayland_GetColorInfoForWindow(SDL_WindowData *window_data, bool defer_event
271279 state -> window_data = window_data ;
272280 state -> object_type = WAYLAND_COLOR_OBJECT_TYPE_WINDOW ;
273281 state -> deferred_event_processing = defer_event_processing ;
274- state -> wp_image_description = wp_color_management_surface_feedback_v1_get_preferred (window_data -> wp_color_management_surface_feedback );
282+
283+ if (!defer_event_processing ) {
284+ state -> queue = Wayland_DisplayCreateQueue (window_data -> waylandData -> display , "SDL Color Management Queue" );
285+
286+ struct wl_proxy * surface_feedback_wrapper = WAYLAND_wl_proxy_create_wrapper (window_data -> wp_color_management_surface_feedback );
287+ WAYLAND_wl_proxy_set_queue (surface_feedback_wrapper , state -> queue );
288+ state -> wp_image_description = wp_color_management_surface_feedback_v1_get_preferred ((struct wp_color_management_surface_feedback_v1 * )surface_feedback_wrapper );
289+ WAYLAND_wl_proxy_wrapper_destroy (surface_feedback_wrapper );
290+ } else {
291+ state -> wp_image_description = wp_color_management_surface_feedback_v1_get_preferred (window_data -> wp_color_management_surface_feedback );
292+ }
275293 wp_image_description_v1_add_listener (state -> wp_image_description , & image_description_listener , state );
276294
277295 if (!defer_event_processing ) {
@@ -291,7 +309,17 @@ void Wayland_GetColorInfoForOutput(SDL_DisplayData *display_data, bool defer_eve
291309 state -> display_data = display_data ;
292310 state -> object_type = WAYLAND_COLOR_OBJECT_TYPE_DISPLAY ;
293311 state -> deferred_event_processing = defer_event_processing ;
294- state -> wp_image_description = wp_color_management_output_v1_get_image_description (display_data -> wp_color_management_output );
312+
313+ if (!defer_event_processing ) {
314+ state -> queue = Wayland_DisplayCreateQueue (display_data -> videodata -> display , "SDL Color Management Queue" );
315+
316+ struct wl_proxy * output_feedback_wrapper = WAYLAND_wl_proxy_create_wrapper (display_data -> wp_color_management_output );
317+ WAYLAND_wl_proxy_set_queue (output_feedback_wrapper , state -> queue );
318+ state -> wp_image_description = wp_color_management_output_v1_get_image_description ((struct wp_color_management_output_v1 * )output_feedback_wrapper );
319+ WAYLAND_wl_proxy_wrapper_destroy (output_feedback_wrapper );
320+ } else {
321+ state -> wp_image_description = wp_color_management_output_v1_get_image_description (display_data -> wp_color_management_output );
322+ }
295323 wp_image_description_v1_add_listener (state -> wp_image_description , & image_description_listener , state );
296324
297325 if (!defer_event_processing ) {
0 commit comments