diff options
author | Phil Jones <philj56@gmail.com> | 2022-07-31 13:29:03 +0100 |
---|---|---|
committer | Phil Jones <philj56@gmail.com> | 2022-07-31 13:29:03 +0100 |
commit | 9eafa5884fb8cad11732860c6de06ac13921c40e (patch) | |
tree | cd096d67176fa8cc2c706f1fa79298e8d548d330 | |
parent | 655bde52896b4d6995d0c1b349a7f34d0bb221b1 (diff) |
Add checks for old wayland versions.
-rw-r--r-- | meson.build | 8 | ||||
-rw-r--r-- | src/main.c | 19 |
2 files changed, 25 insertions, 2 deletions
diff --git a/meson.build b/meson.build index 8776e76..2bd56a6 100644 --- a/meson.build +++ b/meson.build @@ -122,6 +122,14 @@ xkbcommon = dependency('xkbcommon') glib = dependency('glib-2.0') gio_unix = dependency('gio-unix-2.0') +if wayland_client.version().version_compare('<1.20.0') + add_project_arguments( + ['-DNO_WL_OUTPUT_NAME=1'], + language: 'c' + ) +endif + + # Generate the necessary Wayland headers / sources with wayland-scanner wayland_scanner = find_program( @@ -518,8 +518,10 @@ static const struct wl_output_listener wl_output_listener = { .mode = output_mode, .done = output_done, .scale = output_scale, +#ifndef NO_WL_OUTPUT_NAME .name = output_name, .description = output_description, +#endif }; static void registry_global( @@ -551,11 +553,18 @@ static void registry_global( log_debug("Bound to seat %u.\n", name); } else if (!strcmp(interface, wl_output_interface.name)) { struct output_list_element *el = xmalloc(sizeof(*el)); + if (version < 4) { + el->name = xstrdup(""); + log_warning("Using an outdated compositor, " + "output selection will not work.\n"); + } else { + version = 4; + } el->wl_output = wl_registry_bind( wl_registry, name, &wl_output_interface, - 4); + version); wl_output_add_listener( el->wl_output, &wl_output_listener, @@ -570,11 +579,17 @@ static void registry_global( 1); log_debug("Bound to shm %u.\n", name); } else if (!strcmp(interface, zwlr_layer_shell_v1_interface.name)) { + if (version < 4) { + log_warning("Using an outdated compositor, " + "screen anchoring may not work.\n"); + } else { + version = 4; + } tofi->zwlr_layer_shell = wl_registry_bind( wl_registry, name, &zwlr_layer_shell_v1_interface, - 4); + version); log_debug("Bound to zwlr_layer_shell_v1 %u.\n", name); } } |