gdk/wayland: Enable xdg-activation only if wayland-protocols >= 1.21

This way we can keep the same wayland-protocols requirement, so the latest GTK3
still builds on distributions shipping older versions of wayland-protocols,
such as Debian Bullseye.

Should fix CI builds as well.
This commit is contained in:
Joan Bruguera 2022-08-16 23:41:12 +02:00 committed by Carlos Garnacho
parent 3b25f9a662
commit 22c95cd1e9
9 changed files with 56 additions and 9 deletions

View File

@ -292,4 +292,7 @@
#mesondefine ISO_CODES_PREFIX
/* Define if tracker3 is available */
#mesondefine HAVE_TRACKER3
#mesondefine HAVE_TRACKER3
/* Define if xdg_activation's wl-protocols definition is available */
#mesondefine HAVE_XDG_ACTIVATION

View File

@ -467,6 +467,16 @@ if test "$enable_wayland_backend" = "yes"; then
[AC_MSG_ERROR([Could not find wayland-scanner in your PATH, required for parsing wayland extension protocols])])
AC_SUBST([WAYLAND_SCANNER])
# For xdg-activation support
XDG_ACTIVATION_DEPENDENCIES="wayland-protocols >= 1.21"
PKG_CHECK_EXISTS($XDG_ACTIVATION_DEPENDENCIES, [have_xdg_activation_deps=yes], [have_xdg_activation_deps=no])
AC_MSG_CHECKING([for XDG_ACTIVATION_DEPENDENCIES])
AM_CONDITIONAL(USE_XDG_ACTIVATION, test "$have_xdg_activation_deps" = "yes")
if test "$have_xdg_activation_deps" = "yes" ; then
AC_DEFINE([HAVE_XDG_ACTIVATION], [1],
[Define if xdg_activation's wl-protocols definition is available])
fi
AM_CONDITIONAL(USE_WAYLAND, true)
else
AM_CONDITIONAL(USE_WAYLAND, false)

View File

@ -23,8 +23,6 @@ noinst_LTLIBRARIES = \
BUILT_SOURCES = \
pointer-gestures-unstable-v1-client-protocol.h \
pointer-gestures-unstable-v1-protocol.c \
xdg-activation-v1-client-protocol.h \
xdg-activation-v1-protocol.c \
xdg-shell-client-protocol.h \
xdg-shell-protocol.c \
xdg-shell-unstable-v6-client-protocol.h \
@ -45,6 +43,11 @@ BUILT_SOURCES = \
gtk-shell-protocol.c \
primary-selection-unstable-v1-client-protocol.h \
primary-selection-unstable-v1-protocol.c
if USE_XDG_ACTIVATION
BUILT_SOURCES += \
xdg-activation-v1-client-protocol.h \
xdg-activation-v1-protocol.c
endif
nodist_libgdk_wayland_la_SOURCES = \
$(BUILT_SOURCES)

View File

@ -30,6 +30,7 @@
#include "gdkinternals.h"
#include "gdkintl.h"
#ifdef HAVE_XDG_ACTIVATION
typedef struct {
gchar *token;
} AppLaunchData;
@ -47,6 +48,7 @@ token_done (gpointer data,
static const struct xdg_activation_token_v1_listener token_listener = {
token_done,
};
#endif
static char *
gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context,
@ -58,6 +60,7 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context
g_object_get (context, "display", &display, NULL);
#ifdef HAVE_XDG_ACTIVATION
if (display->xdg_activation)
{
struct xdg_activation_token_v1 *token;
@ -95,7 +98,9 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context
id = app_launch_data.token;
wl_event_queue_destroy (event_queue);
}
else if (display->gtk_shell_version >= 3)
else
#endif
if (display->gtk_shell_version >= 3)
{
id = g_uuid_string_random ();
gtk_shell1_notify_launch (display->gtk_shell, id);

View File

@ -85,7 +85,9 @@
#define MIN_SYSTEM_BELL_DELAY_MS 20
#define GTK_SHELL1_VERSION 5
#ifdef HAVE_XDG_ACTIVATION
#define XDG_ACTIVATION_VERSION 1
#endif
static void _gdk_wayland_display_load_cursor_theme (GdkWaylandDisplay *display_wayland);
@ -520,6 +522,7 @@ gdk_registry_handle_global (void *data,
_gdk_wayland_screen_init_xdg_output (display_wayland->screen);
_gdk_wayland_display_async_roundtrip (display_wayland);
}
#ifdef HAVE_XDG_ACTIVATION
else if (strcmp (interface, "xdg_activation_v1") == 0)
{
display_wayland->xdg_activation_version =
@ -529,6 +532,7 @@ gdk_registry_handle_global (void *data,
&xdg_activation_v1_interface,
display_wayland->xdg_activation_version);
}
#endif
g_hash_table_insert (display_wayland->known_globals,
GUINT_TO_POINTER (id), g_strdup (interface));
@ -945,9 +949,11 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display,
{
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
#ifdef HAVE_XDG_ACTIVATION
/* Will be signaled with focus activation */
if (display_wayland->xdg_activation)
return;
#endif
if (startup_id == NULL)
{
@ -957,7 +963,11 @@ gdk_wayland_display_notify_startup_complete (GdkDisplay *display,
return;
}
if (!display_wayland->xdg_activation && display_wayland->gtk_shell)
#ifdef HAVE_XDG_ACTIVATION
if (display_wayland->xdg_activation) /* FIXME: Isn't this redundant? */
return;
#endif
if (display_wayland->gtk_shell)
gtk_shell1_set_startup_id (display_wayland->gtk_shell, startup_id);
}

View File

@ -36,7 +36,9 @@
#include <gdk/wayland/server-decoration-client-protocol.h>
#include <gdk/wayland/xdg-output-unstable-v1-client-protocol.h>
#include <gdk/wayland/primary-selection-unstable-v1-client-protocol.h>
#ifdef HAVE_XDG_ACTIVATION
#include <gdk/wayland/xdg-activation-v1-client-protocol.h>
#endif
#include <glib.h>
#include <gdk/gdkkeys.h>
@ -98,8 +100,10 @@ struct _GdkWaylandDisplay
struct zwp_keyboard_shortcuts_inhibit_manager_v1 *keyboard_shortcuts_inhibit;
struct org_kde_kwin_server_decoration_manager *server_decoration_manager;
struct zxdg_output_manager_v1 *xdg_output_manager;
struct xdg_activation_v1 *xdg_activation;
uint32_t xdg_output_version;
#ifdef HAVE_XDG_ACTIVATION
struct xdg_activation_v1 *xdg_activation;
#endif
GList *async_roundtrips;
@ -127,7 +131,9 @@ struct _GdkWaylandDisplay
int data_device_manager_version;
int gtk_shell_version;
int xdg_output_manager_version;
#ifdef HAVE_XDG_ACTIVATION
int xdg_activation_version;
#endif
uint32_t server_decoration_mode;

View File

@ -3811,6 +3811,7 @@ gdk_wayland_window_get_input_shape (GdkWindow *window)
return NULL;
}
#ifdef HAVE_XDG_ACTIVATION
static void
token_done (gpointer data,
struct xdg_activation_token_v1 *provider,
@ -3824,6 +3825,7 @@ token_done (gpointer data,
static const struct xdg_activation_token_v1_listener token_listener = {
token_done,
};
#endif
static void
gdk_wayland_window_focus (GdkWindow *window,
@ -3836,6 +3838,7 @@ gdk_wayland_window_focus (GdkWindow *window,
startup_id = g_steal_pointer (&display_wayland->startup_notification_id);
#ifdef HAVE_XDG_ACTIVATION
if (display_wayland->xdg_activation)
{
GdkSeat *seat = gdk_display_get_default_seat (display);
@ -3874,7 +3877,9 @@ gdk_wayland_window_focus (GdkWindow *window,
startup_id,
impl->display_server.wl_surface);
}
else if (impl->display_server.gtk_surface)
else
#endif
if (impl->display_server.gtk_surface)
{
if (timestamp != GDK_CURRENT_TIME)
gtk_surface1_present (impl->display_server.gtk_surface, timestamp);

View File

@ -36,7 +36,8 @@ gdk_wayland_deps = [
]
# wayland protocols
proto_dir = dependency('wayland-protocols').get_pkgconfig_variable('pkgdatadir')
wlprotocolsdep = dependency('wayland-protocols')
proto_dir = wlprotocolsdep.get_pkgconfig_variable('pkgdatadir')
assert(proto_dir != '', 'Could not get pkgdatadir from wayland-protocols.pc')
wayland_scanner = find_program('wayland-scanner')
@ -57,8 +58,10 @@ proto_sources = [
['server-decoration', 'private' ],
['xdg-output', 'unstable', 'v1', ],
['primary-selection', 'unstable', 'v1', ],
['xdg-activation', 'staging', 'v1', ],
]
if wlprotocolsdep.version().version_compare('>=1.21')
proto_sources += [['xdg-activation', 'staging', 'v1', ]]
endif
gdk_wayland_gen_headers = []

View File

@ -561,6 +561,8 @@ if wayland_enabled
wlegldep = dependency('wayland-egl')
backend_immodules += ['wayland']
cdata.set('HAVE_XDG_ACTIVATION', wlprotocolsdep.version().version_compare('>=1.21'))
wayland_pkgs = [
'wayland-client', wayland_req,
'xkbcommon', xkbcommon_req,