wayland: xdg-activation is now always available

Since we're requiring wayland-protocols >= 1.32
This commit is contained in:
Daniel Eklöf 2023-07-31 16:32:28 +02:00
parent e0475a5421
commit d59a4e7a77
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 5 additions and 43 deletions

View file

@ -152,15 +152,9 @@ wl_proto_xml = [
wayland_protocols_datadir + '/unstable/primary-selection/primary-selection-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 + '/stable/presentation-time/presentation-time.xml',
wayland_protocols_datadir + '/unstable/text-input/text-input-unstable-v3.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']
xdg_activation = true
else
xdg_activation = false
endif
if wayland_protocols.version().version_compare('>=1.31') if wayland_protocols.version().version_compare('>=1.31')
add_project_arguments('-DHAVE_FRACTIONAL_SCALE', language: 'c') add_project_arguments('-DHAVE_FRACTIONAL_SCALE', language: 'c')
wl_proto_xml += [wayland_protocols_datadir + '/stable/viewporter/viewporter.xml'] wl_proto_xml += [wayland_protocols_datadir + '/stable/viewporter/viewporter.xml']
@ -394,7 +388,6 @@ summary(
'Themes': get_option('themes'), 'Themes': get_option('themes'),
'IME': get_option('ime'), 'IME': get_option('ime'),
'Grapheme clustering': utf8proc.found(), 'Grapheme clustering': utf8proc.found(),
'Wayland: xdg-activation-v1': xdg_activation,
'Wayland: fractional-scale-v1': fractional_scale, 'Wayland: fractional-scale-v1': fractional_scale,
'Wayland: cursor-shape-v1': cursor_shape, 'Wayland: cursor-shape-v1': cursor_shape,
'utmp backend': utmp_backend, 'utmp backend': utmp_backend,

View file

@ -86,7 +86,6 @@ spawn_url_launcher_with_token(struct terminal *term,
return ret; return ret;
} }
#if defined(HAVE_XDG_ACTIVATION)
struct spawn_activation_context { struct spawn_activation_context {
struct terminal *term; struct terminal *term;
char *url; char *url;
@ -101,13 +100,11 @@ activation_token_done(const char *token, void *data)
free(ctx->url); free(ctx->url);
free(ctx); free(ctx);
} }
#endif
static bool static bool
spawn_url_launcher(struct seat *seat, struct terminal *term, const char *url, spawn_url_launcher(struct seat *seat, struct terminal *term, const char *url,
uint32_t serial) uint32_t serial)
{ {
#if defined(HAVE_XDG_ACTIVATION)
struct spawn_activation_context *ctx = xmalloc(sizeof(*ctx)); struct spawn_activation_context *ctx = xmalloc(sizeof(*ctx));
*ctx = (struct spawn_activation_context){ *ctx = (struct spawn_activation_context){
.term = term, .term = term,
@ -123,7 +120,6 @@ spawn_url_launcher(struct seat *seat, struct terminal *term, const char *url,
free(ctx->url); free(ctx->url);
free(ctx); free(ctx);
#endif
return spawn_url_launcher_with_token(term, url, NULL); return spawn_url_launcher_with_token(term, url, NULL);
} }

View file

@ -1217,7 +1217,6 @@ handle_global(void *data, struct wl_registry *registry,
} }
} }
#if defined(HAVE_XDG_ACTIVATION)
else if (strcmp(interface, xdg_activation_v1_interface.name) == 0) { else if (strcmp(interface, xdg_activation_v1_interface.name) == 0) {
const uint32_t required = 1; const uint32_t required = 1;
if (!verify_iface_version(interface, version, required)) if (!verify_iface_version(interface, version, required))
@ -1226,7 +1225,6 @@ handle_global(void *data, struct wl_registry *registry,
wayl->xdg_activation = wl_registry_bind( wayl->xdg_activation = wl_registry_bind(
wayl->registry, name, &xdg_activation_v1_interface, required); wayl->registry, name, &xdg_activation_v1_interface, required);
} }
#endif
#if defined(HAVE_FRACTIONAL_SCALE) #if defined(HAVE_FRACTIONAL_SCALE)
else if (strcmp(interface, wp_viewporter_interface.name) == 0) { else if (strcmp(interface, wp_viewporter_interface.name) == 0) {
@ -1481,11 +1479,7 @@ wayl_init(struct fdm *fdm, struct key_binding_manager *key_binding_manager,
if (wayl->primary_selection_device_manager == NULL) if (wayl->primary_selection_device_manager == NULL)
LOG_WARN("no primary selection available"); LOG_WARN("no primary selection available");
#if defined(HAVE_XDG_ACTIVATION)
if (wayl->xdg_activation == NULL) { if (wayl->xdg_activation == NULL) {
#else
if (true) {
#endif
LOG_WARN( LOG_WARN(
"no XDG activation support; " "no XDG activation support; "
"bell.urgent will fall back to coloring the window margins red"); "bell.urgent will fall back to coloring the window margins red");
@ -1604,10 +1598,8 @@ wayl_destroy(struct wayland *wayl)
if (wayl->cursor_shape_manager != NULL) if (wayl->cursor_shape_manager != NULL)
wp_cursor_shape_manager_v1_destroy(wayl->cursor_shape_manager); wp_cursor_shape_manager_v1_destroy(wayl->cursor_shape_manager);
#endif #endif
#if defined(HAVE_XDG_ACTIVATION)
if (wayl->xdg_activation != NULL) if (wayl->xdg_activation != NULL)
xdg_activation_v1_destroy(wayl->xdg_activation); xdg_activation_v1_destroy(wayl->xdg_activation);
#endif
if (wayl->xdg_output_manager != NULL) if (wayl->xdg_output_manager != NULL)
zxdg_output_manager_v1_destroy(wayl->xdg_output_manager); zxdg_output_manager_v1_destroy(wayl->xdg_output_manager);
if (wayl->shell != NULL) if (wayl->shell != NULL)
@ -1739,11 +1731,9 @@ wayl_win_init(struct terminal *term, const char *token)
wl_surface_commit(win->surface.surf); wl_surface_commit(win->surface.surf);
#if defined(HAVE_XDG_ACTIVATION)
/* Complete XDG startup notification */ /* Complete XDG startup notification */
if (token) if (token)
xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface.surf); xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface.surf);
#endif
if (!wayl_win_subsurface_new(win, &win->overlay, false)) { if (!wayl_win_subsurface_new(win, &win->overlay, false)) {
LOG_ERR("failed to create overlay surface"); LOG_ERR("failed to create overlay surface");
@ -1850,14 +1840,13 @@ wayl_win_destroy(struct wl_window *win)
shm_purge(term->render.chains.url); shm_purge(term->render.chains.url);
shm_purge(term->render.chains.csd); shm_purge(term->render.chains.csd);
#if defined(HAVE_XDG_ACTIVATION)
tll_foreach(win->xdg_tokens, it) { tll_foreach(win->xdg_tokens, it) {
xdg_activation_token_v1_destroy(it->item->xdg_token); xdg_activation_token_v1_destroy(it->item->xdg_token);
free(it->item); free(it->item);
tll_remove(win->xdg_tokens, it); tll_remove(win->xdg_tokens, it);
} }
#endif
#if defined(HAVE_FRACTIONAL_SCALE) #if defined(HAVE_FRACTIONAL_SCALE)
if (win->fractional_scale != NULL) if (win->fractional_scale != NULL)
wp_fractional_scale_v1_destroy(win->fractional_scale); wp_fractional_scale_v1_destroy(win->fractional_scale);
@ -2090,7 +2079,6 @@ wayl_win_alpha_changed(struct wl_window *win)
wl_surface_set_opaque_region(win->surface.surf, NULL); wl_surface_set_opaque_region(win->surface.surf, NULL);
} }
#if defined(HAVE_XDG_ACTIVATION)
static void static void
activation_token_for_urgency_done(const char *token, void *data) activation_token_for_urgency_done(const char *token, void *data)
{ {
@ -2100,12 +2088,10 @@ activation_token_for_urgency_done(const char *token, void *data)
win->urgency_token_is_pending = false; win->urgency_token_is_pending = false;
xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface.surf); xdg_activation_v1_activate(wayl->xdg_activation, token, win->surface.surf);
} }
#endif /* HAVE_XDG_ACTIVATION */
bool bool
wayl_win_set_urgent(struct wl_window *win) wayl_win_set_urgent(struct wl_window *win)
{ {
#if defined(HAVE_XDG_ACTIVATION)
if (win->urgency_token_is_pending) { if (win->urgency_token_is_pending) {
/* We already have a pending token. Dont request another one, /* We already have a pending token. Dont request another one,
* to avoid flooding the Wayland socket */ * to avoid flooding the Wayland socket */
@ -2119,7 +2105,6 @@ wayl_win_set_urgent(struct wl_window *win)
win->urgency_token_is_pending = true; win->urgency_token_is_pending = true;
return true; return true;
} }
#endif
return false; return false;
} }
@ -2229,8 +2214,6 @@ wayl_win_subsurface_destroy(struct wayl_sub_surface *surf)
} }
} }
#if defined(HAVE_XDG_ACTIVATION)
static void static void
activation_token_done(void *data, struct xdg_activation_token_v1 *xdg_token, activation_token_done(void *data, struct xdg_activation_token_v1 *xdg_token,
const char *token) const char *token)
@ -2296,4 +2279,3 @@ wayl_get_activation_token(
xdg_activation_token_v1_commit(token); xdg_activation_token_v1_commit(token);
return true; return true;
} }
#endif

View file

@ -15,10 +15,7 @@
#include <xdg-decoration-unstable-v1.h> #include <xdg-decoration-unstable-v1.h>
#include <xdg-output-unstable-v1.h> #include <xdg-output-unstable-v1.h>
#include <xdg-shell.h> #include <xdg-shell.h>
#include <xdg-activation-v1.h>
#if defined(HAVE_XDG_ACTIVATION)
#include <xdg-activation-v1.h>
#endif
#if defined(HAVE_FRACTIONAL_SCALE) #if defined(HAVE_FRACTIONAL_SCALE)
#include <viewporter.h> #include <viewporter.h>
@ -345,7 +342,6 @@ struct wl_url {
enum csd_mode {CSD_UNKNOWN, CSD_NO, CSD_YES}; enum csd_mode {CSD_UNKNOWN, CSD_NO, CSD_YES};
#if defined(HAVE_XDG_ACTIVATION)
typedef void (*activation_token_cb_t)(const char *token, void *data); typedef void (*activation_token_cb_t)(const char *token, void *data);
/* /*
@ -359,7 +355,6 @@ struct xdg_activation_token_context {
activation_token_cb_t cb; /* User provided callback */ activation_token_cb_t cb; /* User provided callback */
void *cb_data; /* Callback user pointer */ void *cb_data; /* Callback user pointer */
}; };
#endif
struct wayland; struct wayland;
struct wl_window { struct wl_window {
@ -367,10 +362,10 @@ struct wl_window {
struct wayl_surface surface; struct wayl_surface surface;
struct xdg_surface *xdg_surface; struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel; struct xdg_toplevel *xdg_toplevel;
#if defined(HAVE_XDG_ACTIVATION)
tll(struct xdg_activation_token_context *) xdg_tokens; tll(struct xdg_activation_token_context *) xdg_tokens;
bool urgency_token_is_pending; bool urgency_token_is_pending;
#endif
#if defined(HAVE_FRACTIONAL_SCALE) #if defined(HAVE_FRACTIONAL_SCALE)
struct wp_fractional_scale_v1 *fractional_scale; struct wp_fractional_scale_v1 *fractional_scale;
#endif #endif
@ -451,9 +446,7 @@ struct wayland {
struct wl_data_device_manager *data_device_manager; struct wl_data_device_manager *data_device_manager;
struct zwp_primary_selection_device_manager_v1 *primary_selection_device_manager; struct zwp_primary_selection_device_manager_v1 *primary_selection_device_manager;
#if defined(HAVE_XDG_ACTIVATION)
struct xdg_activation_v1 *xdg_activation; struct xdg_activation_v1 *xdg_activation;
#endif
#if defined(HAVE_CURSOR_SHAPE) #if defined(HAVE_CURSOR_SHAPE)
struct wp_cursor_shape_manager_v1 *cursor_shape_manager; struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
@ -515,8 +508,6 @@ bool wayl_win_subsurface_new_with_custom_parent(
struct wayl_sub_surface *surf, bool allow_pointer_input); struct wayl_sub_surface *surf, bool allow_pointer_input);
void wayl_win_subsurface_destroy(struct wayl_sub_surface *surf); void wayl_win_subsurface_destroy(struct wayl_sub_surface *surf);
#if defined(HAVE_XDG_ACTIVATION)
bool wayl_get_activation_token( bool wayl_get_activation_token(
struct wayland *wayl, struct seat *seat, uint32_t serial, struct wayland *wayl, struct seat *seat, uint32_t serial,
struct wl_window *win, activation_token_cb_t cb, void *cb_data); struct wl_window *win, activation_token_cb_t cb, void *cb_data);
#endif