meson: add xdg-activation-v1.xml conditionally

Only enable XDG activation when compiling against wayland-protocols
1.21. Older versions don’t have this protocol.

When available, define HAVE_XDG_ACTIVATION.

Make all usages of xdg_activation_v1 and xdg_activation_token_v1
conditional.
This commit is contained in:
Daniel Eklöf 2021-05-11 17:58:40 +02:00
parent bf44f3f594
commit 03e1b906ab
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
3 changed files with 31 additions and 3 deletions

View file

@ -88,16 +88,21 @@ wscanner_prog = find_program(
wl_proto_headers = []
wl_proto_src = []
foreach prot : [
wl_proto_xml = [
wayland_protocols_datadir + '/stable/xdg-shell/xdg-shell.xml',
wayland_protocols_datadir + '/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml',
wayland_protocols_datadir + '/unstable/xdg-output/xdg-output-unstable-v1.xml',
wayland_protocols_datadir + '/unstable/primary-selection/primary-selection-unstable-v1.xml',
wayland_protocols_datadir + '/stable/presentation-time/presentation-time.xml',
wayland_protocols_datadir + '/unstable/text-input/text-input-unstable-v3.xml',
wayland_protocols_datadir + '/staging/xdg-activation/xdg-activation-v1.xml',
]
if wayland_protocols.version().version_compare('>=1.21')
add_project_arguments('-DHAVE_XDG_ACTIVATION', language: 'c')
wl_proto_xml += [wayland_protocols_datadir + '/staging/xdg-activation/xdg-activation-v1.xml']
endif
foreach prot : wl_proto_xml
wl_proto_headers += custom_target(
prot.underscorify() + '-client-header',
output: '@BASENAME@.h',

View file

@ -985,6 +985,7 @@ handle_global(void *data, struct wl_registry *registry,
}
}
#if defined(HAVE_XDG_ACTIVATION)
else if (strcmp(interface, xdg_activation_v1_interface.name) == 0) {
const uint32_t required = 1;
if (!verify_iface_version(interface, version, required))
@ -993,6 +994,7 @@ handle_global(void *data, struct wl_registry *registry,
wayl->xdg_activation = wl_registry_bind(
wayl->registry, name, &xdg_activation_v1_interface, required);
}
#endif
#if defined(FOOT_IME_ENABLED) && FOOT_IME_ENABLED
else if (strcmp(interface, zwp_text_input_manager_v3_interface.name) == 0) {
@ -1192,7 +1194,11 @@ wayl_init(const struct config *conf, struct fdm *fdm)
if (wayl->primary_selection_device_manager == NULL)
LOG_WARN("no primary selection available");
#if defined(HAVE_XDG_ACTIVATION)
if (wayl->xdg_activation == NULL && conf->bell.urgent) {
#else
if (conf->bell.urgent) {
#endif
LOG_WARN(
"no XDG activation support; "
"bell.urgent will fall back to coloring the window margins red");
@ -1286,8 +1292,10 @@ wayl_destroy(struct wayland *wayl)
zwp_text_input_manager_v3_destroy(wayl->text_input_manager);
#endif
#if defined(HAVE_XDG_ACTIVATION)
if (wayl->xdg_activation != NULL)
xdg_activation_v1_destroy(wayl->xdg_activation);
#endif
if (wayl->xdg_output_manager != NULL)
zxdg_output_manager_v1_destroy(wayl->xdg_output_manager);
if (wayl->shell != NULL)
@ -1465,8 +1473,10 @@ wayl_win_destroy(struct wl_window *win)
wayl_win_subsurface_destroy(&win->scrollback_indicator);
wayl_win_subsurface_destroy(&win->render_timer);
#if defined(HAVE_XDG_ACTIVATION)
if (win->xdg_activation_token != NULL)
xdg_activation_token_v1_destroy(win->xdg_activation_token);
#endif
if (win->frame_callback != NULL)
wl_callback_destroy(win->frame_callback);
if (win->xdg_toplevel_decoration != NULL)
@ -1588,6 +1598,7 @@ wayl_roundtrip(struct wayland *wayl)
wayl_flush(wayl);
}
#if defined(HAVE_XDG_ACTIVATION)
static void
activation_token_done(void *data, struct xdg_activation_token_v1 *xdg_token,
const char *token)
@ -1607,10 +1618,12 @@ activation_token_done(void *data, struct xdg_activation_token_v1 *xdg_token,
static const struct xdg_activation_token_v1_listener activation_token_listener = {
.done = &activation_token_done,
};
#endif /* HAVE_XDG_ACTIVATION */
bool
wayl_win_set_urgent(struct wl_window *win)
{
#if defined(HAVE_XDG_ACTIVATION)
struct wayland *wayl = win->term->wl;
if (wayl->xdg_activation == NULL)
@ -1632,6 +1645,9 @@ wayl_win_set_urgent(struct wl_window *win)
xdg_activation_token_v1_commit(token);
win->xdg_activation_token = token;
return true;
#else
return false;
#endif
}
bool

View file

@ -12,11 +12,14 @@
#include <presentation-time.h>
#include <primary-selection-unstable-v1.h>
#include <text-input-unstable-v3.h>
#include <xdg-activation-v1.h>
#include <xdg-decoration-unstable-v1.h>
#include <xdg-output-unstable-v1.h>
#include <xdg-shell.h>
#if defined(HAVE_XDG_ACTIVATION)
#include <xdg-activation-v1.h>
#endif
#include <tllist.h>
#include "fdm.h"
@ -383,7 +386,9 @@ struct wl_window {
struct wl_surface *surface;
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
#if defined(HAVE_XDG_ACTIVATION)
struct xdg_activation_token_v1 *xdg_activation_token;
#endif
struct zxdg_toplevel_decoration_v1 *xdg_toplevel_decoration;
@ -451,7 +456,9 @@ struct wayland {
struct wl_data_device_manager *data_device_manager;
struct zwp_primary_selection_device_manager_v1 *primary_selection_device_manager;
#if defined(HAVE_XDG_ACTIVATION)
struct xdg_activation_v1 *xdg_activation;
#endif
struct wp_presentation *presentation;
uint32_t presentation_clock_id;