Event sources marked with wl_event_source_check not dispatched after wl_event_loop_dispatch_idle
Create an event source registered with wl_event_source_check
, for instance an event source for a Wayland connection to a remote compositor (code taken from Weston):
static int dispatch_events(int fd, uint32_t mask, void *data) {
int count = 0;
if (mask & WL_EVENT_READABLE) {
count = wl_display_dispatch(wl->remote_display);
}
if (mask & WL_EVENT_WRITABLE) {
wl_display_flush(wl->remote_display);
}
if (mask == 0) {
count = wl_display_dispatch_pending(wl->remote_display);
wl_display_flush(wl->remote_display);
}
return count;
}
[…]
int fd = wl_display_get_fd(remote_display);
uint32_t events = WL_EVENT_READABLE;
struct wl_event_source *event_source = wl_event_loop_add_fd(loop, fd, events, dispatch_events, NULL);
wl_event_source_check(event_source);
Setup an idle source, and send a request to the remote compositor from the idle source:
static void handle_idle(void *data) {
wl_display_sync(remote_display);
}
wl_event_loop_add_idle(loop, handle_idle, NULL);
The request gets queued to the Wayland internal buffer, because WAYLAND_DEBUG=client
shows it. The request doesn't get flushed to the parent compositor, because WAYLAND_DEBUG=server
doesn't show it. Adding wl_display_flush
after sending the request fixes the bug.
It seems like wl_event_loop_dispatch
dispatches idle sources twice since 5ec8062d. However, checked sources are only dispatched after the second idle source dispatch, not the first. Should we dispatch checked sources twice too?
To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information