Handle POLLHUP

This makes xdpw exit when either the D-Bus daemon, the Wayland
compositor or Pipewire is shut down. This avoids having dangling
non-functional xdpw instances, e.g. when restarting the compositor.

To test, start Sway nested in Sway, run xdpw with
WAYLAND_DISPLAY=wayland-2, and exit the nested Sway.
This commit is contained in:
Simon Ser 2021-06-08 00:17:32 +02:00 committed by columbarius
parent 96d2789d8f
commit e23e109e41
1 changed files with 13 additions and 0 deletions

View File

@ -196,6 +196,19 @@ int main(int argc, char *argv[]) {
goto error;
}
if (pollfds[EVENT_LOOP_DBUS].revents & POLLHUP) {
logprint(INFO, "event-loop: disconnected from dbus");
break;
}
if (pollfds[EVENT_LOOP_WAYLAND].revents & POLLHUP) {
logprint(INFO, "event-loop: disconnected from wayland");
break;
}
if (pollfds[EVENT_LOOP_PIPEWIRE].revents & POLLHUP) {
logprint(INFO, "event-loop: disconnected from pipewire");
break;
}
if (pollfds[EVENT_LOOP_DBUS].revents & POLLIN) {
logprint(TRACE, "event-loop: got dbus event");
do {