wayland: Add event queue dispatch helper

Dispatch failing should always fatal; use a helper to centralize the
error handling everywhere.
This commit is contained in:
Jonas Ådahl 2023-02-11 23:13:39 +01:00
parent 04c3af537c
commit dd9433b50e
4 changed files with 21 additions and 16 deletions

View File

@ -2694,3 +2694,17 @@ gdk_wayland_display_query_registry (GdkDisplay *display,
return FALSE;
}
void
gdk_wayland_display_dispatch_queue (GdkDisplay *display,
struct wl_event_queue *event_queue)
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
if (wl_display_dispatch_queue (display_wayland->wl_display, event_queue) == -1)
{
g_message ("Error %d (%s) dispatching to Wayland display.",
errno, g_strerror (errno));
_exit (1);
}
}

View File

@ -158,6 +158,9 @@ struct _GdkWaylandDisplayClass
gboolean gdk_wayland_display_prefers_ssd (GdkDisplay *display);
void gdk_wayland_display_dispatch_queue (GdkDisplay *display,
struct wl_event_queue *event_queue);
G_END_DECLS
#endif /* __GDK_WAYLAND_DISPLAY__ */

View File

@ -1334,8 +1334,6 @@ gdk_wayland_surface_present_popup (GdkWaylandPopup *wayland_popup,
GdkPopupLayout *layout)
{
GdkSurface *surface = GDK_SURFACE (wayland_popup);
GdkWaylandDisplay *display_wayland =
GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
GdkWaylandSurface *wayland_surface = GDK_WAYLAND_SURFACE (wayland_popup);
if (!wayland_surface->mapped)
@ -1389,13 +1387,8 @@ gdk_wayland_surface_present_popup (GdkWaylandPopup *wayland_popup,
while (wayland_popup->display_server.xdg_popup && !is_relayout_finished (surface))
{
if (wl_display_dispatch_queue (display_wayland->wl_display,
wayland_surface->event_queue) == -1)
{
g_message ("Error %d (%s) dispatching to Wayland display.",
errno, g_strerror (errno));
_exit (1);
}
gdk_wayland_display_dispatch_queue (surface->display,
wayland_surface->event_queue);
}
if (wayland_popup->display_server.xdg_popup)

View File

@ -2120,13 +2120,8 @@ gdk_wayland_toplevel_focus (GdkToplevel *toplevel,
while (startup_id == NULL)
{
if (wl_display_dispatch_queue (display_wayland->wl_display,
event_queue) == -1)
{
g_message ("Error %d (%s) dispatching to Wayland display.",
errno, g_strerror (errno));
_exit (1);
}
gdk_wayland_display_dispatch_queue (GDK_DISPLAY (display_wayland),
event_queue);
}
xdg_activation_token_v1_destroy (token);