aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-11-23 23:00:43 +0000
committerKenny Levinsen <kl@kl.wtf>2020-11-24 23:19:23 +0000
commitab6327da2699e81e877c6f9f63786ff6d3a271cd (patch)
treea4ed12788f00e8d8dd3a355e70ba97fdceae3831
parentrender: don’t call term_arm_blink_timer() from multiple threads (diff)
wayland: Use wl_output_release with wl_output v3
wl_output_release, the use of which was recently introduced, is not available until wl_output interface version 3. However, only wl_output version 2 was bound. This lead to protocol errors when a display was disconnected, causing foot to terminate. Instead, only use wl_output_release if wl_output version 3 is provided and bound. Otherwise, just use wl_output_destroy. Closes: https://codeberg.org/dnkl/foot/issues/219
-rw-r--r--wayland.c13
-rw-r--r--wayland.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/wayland.c b/wayland.c
index b8cd9cd9..8007eeba 100644
--- a/wayland.c
+++ b/wayland.c
@@ -841,11 +841,12 @@ handle_global(void *data, struct wl_registry *registry,
return;
struct wl_output *output = wl_registry_bind(
- wayl->registry, name, &wl_output_interface, required);
+ wayl->registry, name, &wl_output_interface, min(version, 3));
tll_push_back(
wayl->monitors,
- ((struct monitor){.wayl = wayl, .output = output, .wl_name = name}));
+ ((struct monitor){.wayl = wayl, .output = output, .wl_name = name,
+ .use_output_release = version >= WL_OUTPUT_RELEASE_SINCE_VERSION}));
struct monitor *mon = &tll_back(wayl->monitors);
wl_output_add_listener(output, &output_listener, mon);
@@ -901,8 +902,12 @@ monitor_destroy(struct monitor *mon)
{
if (mon->xdg != NULL)
zxdg_output_v1_destroy(mon->xdg);
- if (mon->output != NULL)
- wl_output_release(mon->output);
+ if (mon->output != NULL) {
+ if (mon->use_output_release)
+ wl_output_release(mon->output);
+ else
+ wl_output_destroy(mon->output);
+ }
free(mon->make);
free(mon->model);
free(mon->name);
diff --git a/wayland.h b/wayland.h
index 7bf5eb80..876d791c 100644
--- a/wayland.h
+++ b/wayland.h
@@ -294,6 +294,8 @@ struct monitor {
char *description;
float inch; /* e.g. 24" */
+
+ bool use_output_release;
};
struct wayland;