summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoan Bruguera <joanbrugueram@gmail.com>2022-08-16 23:41:12 +0200
committerCarlos Garnacho <carlosg@gnome.org>2022-10-25 23:52:47 +0200
commit22c95cd1e9182a419df37f10e1a6c9e2156d8bdb (patch)
treebed99fb9891d1b2058658414ee65242c6bb9ffa3
parent3b25f9a66221509c11159afd6e49ad227f575939 (diff)
downloadgtk+-22c95cd1e9182a419df37f10e1a6c9e2156d8bdb.tar.gz
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.
-rw-r--r--config.h.meson5
-rw-r--r--configure.ac10
-rw-r--r--gdk/wayland/Makefile.am7
-rw-r--r--gdk/wayland/gdkapplaunchcontext-wayland.c7
-rw-r--r--gdk/wayland/gdkdisplay-wayland.c12
-rw-r--r--gdk/wayland/gdkdisplay-wayland.h8
-rw-r--r--gdk/wayland/gdkwindow-wayland.c7
-rw-r--r--gdk/wayland/meson.build7
-rw-r--r--meson.build2
9 files changed, 56 insertions, 9 deletions
diff --git a/config.h.meson b/config.h.meson
index f6716795f9..b502611cb7 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -292,4 +292,7 @@
#mesondefine ISO_CODES_PREFIX
/* Define if tracker3 is available */
-#mesondefine HAVE_TRACKER3 \ No newline at end of file
+#mesondefine HAVE_TRACKER3
+
+/* Define if xdg_activation's wl-protocols definition is available */
+#mesondefine HAVE_XDG_ACTIVATION \ No newline at end of file
diff --git a/configure.ac b/configure.ac
index a665921783..720ee7df5a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
diff --git a/gdk/wayland/Makefile.am b/gdk/wayland/Makefile.am
index e292a548bc..08ed75ca77 100644
--- a/gdk/wayland/Makefile.am
+++ b/gdk/wayland/Makefile.am
@@ -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)
diff --git a/gdk/wayland/gdkapplaunchcontext-wayland.c b/gdk/wayland/gdkapplaunchcontext-wayland.c
index eb1d2cd88f..340a03732a 100644
--- a/gdk/wayland/gdkapplaunchcontext-wayland.c
+++ b/gdk/wayland/gdkapplaunchcontext-wayland.c
@@ -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);
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index e473996f86..55c0388ec6 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -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);
}
diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h
index 0f66304196..925476a781 100644
--- a/gdk/wayland/gdkdisplay-wayland.h
+++ b/gdk/wayland/gdkdisplay-wayland.h
@@ -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;
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index e3f97cfd1b..6ba939a739 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -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);
diff --git a/gdk/wayland/meson.build b/gdk/wayland/meson.build
index cdc955e797..1a9006077d 100644
--- a/gdk/wayland/meson.build
+++ b/gdk/wayland/meson.build
@@ -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 = []
diff --git a/meson.build b/meson.build
index f0b4fabe8b..8aaeb717e5 100644
--- a/meson.build
+++ b/meson.build
@@ -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,