From d6b8823dce209d985687b634cf813ec8815891ce Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Fri, 26 Feb 2021 21:38:20 -0500 Subject: [PATCH] [client] wayland: gracefully downgrade to wl_output v2 We don't necessarily need `wl_output.release`, which is the only addition in v3. This allows Looking Glass to run on Ubuntu 20.04 without having to go difficult lengths to acquire newer Wayland packages. Since 20.04 is an LTS release, this seems worthwhile for the small amount of complexity this introduces. Fixes https://forum.level1techs.com/t/latest-build-allow-inhibiting-shortcuts-dialog-ubuntu/168684/6. --- client/displayservers/Wayland/output.c | 19 +++++++++++-------- client/displayservers/Wayland/wayland.h | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client/displayservers/Wayland/output.c b/client/displayservers/Wayland/output.c index 1359cc28..e6f49e9c 100644 --- a/client/displayservers/Wayland/output.c +++ b/client/displayservers/Wayland/output.c @@ -71,7 +71,8 @@ void waylandOutputFree(void) struct WaylandOutput * temp; wl_list_for_each_safe(node, temp, &wlWm.outputs, link) { - wl_output_release(node->output); + if (node->version >= 3) + wl_output_release(node->output); wl_list_remove(&node->link); free(node); } @@ -83,16 +84,17 @@ void waylandOutputBind(uint32_t name, uint32_t version) if (!node) return; - if (version < 3) + if (version < 2) { - DEBUG_WARN("wl_output version too old: expected 3, got %d", version); + DEBUG_WARN("wl_output version too old: expected >= 2, got %d", version); return; } - node->name = name; - node->scale = 0; - node->output = wl_registry_bind(wlWm.registry, name, - &wl_output_interface, 3); + node->name = name; + node->scale = 0; + node->version = version; + node->output = wl_registry_bind(wlWm.registry, name, + &wl_output_interface, version >= 3 ? 3 : 2); if (!node->output) { @@ -113,7 +115,8 @@ void waylandOutputTryUnbind(uint32_t name) { if (node->name == name) { - wl_output_release(node->output); + if (node->version >= 3) + wl_output_release(node->output); wl_list_remove(&node->link); free(node); break; diff --git a/client/displayservers/Wayland/wayland.h b/client/displayservers/Wayland/wayland.h index 5e06a3ee..de6388ba 100644 --- a/client/displayservers/Wayland/wayland.h +++ b/client/displayservers/Wayland/wayland.h @@ -56,6 +56,7 @@ struct WaylandOutput uint32_t name; int32_t scale; struct wl_output * output; + uint32_t version; struct wl_list link; };