Blame SOURCES/0005-meson-add-wayland-protocols.patch

be82ae
From 8d3731162c2b3aae518f8d8b2d7190c4deec9911 Mon Sep 17 00:00:00 2001
be82ae
From: Francesco Giudici <fgiudici@redhat.com>
be82ae
Date: Thu, 27 Feb 2020 11:55:15 +0100
be82ae
Subject: [PATCH 5/9] meson: add wayland protocols
be82ae
be82ae
Generate wayland protocols: these will be used later for locking the
be82ae
mouse pointer and getting relative mouse movements when using the mouse
be82ae
in server mode in Wayland.
be82ae
The meson build steps have been freely taken and adapted from Weston
be82ae
source code:
be82ae
https://gitlab.freedesktop.org/wayland/weston/-/blob/master/protocol/meson.build
be82ae
be82ae
Signed-off-by: Francesco Giudici <fgiudici@redhat.com>
be82ae
Acked-by: Frediano Ziglio <fziglio@redhat.com>
be82ae
(cherry picked from commit d70044ab49728524c68796dd371d2bf7d94d27e5)
be82ae
---
be82ae
 meson.build       | 20 +++++++++++++++
be82ae
 meson_options.txt |  4 +++
be82ae
 src/meson.build   | 62 +++++++++++++++++++++++++++++++++++++++++++++--
be82ae
 3 files changed, 84 insertions(+), 2 deletions(-)
be82ae
be82ae
diff --git a/meson.build b/meson.build
be82ae
index c442a0d..7426ea5 100644
be82ae
--- a/meson.build
be82ae
+++ b/meson.build
be82ae
@@ -31,6 +31,7 @@ spice_gtk_config_data = configuration_data()
be82ae
 spice_gtk_include = [include_directories('.')]
be82ae
 spice_glib_deps = []
be82ae
 spice_gtk_deps = []
be82ae
+spice_wayland_deps = []
be82ae
 spice_acl_deps = []
be82ae
 
be82ae
 #
be82ae
@@ -152,6 +153,25 @@ if d.found()
be82ae
   spice_gtk_has_gtk = true
be82ae
 endif
be82ae
 
be82ae
+# wayland protocols
be82ae
+spice_gtk_has_wayland_protocols = false
be82ae
+# Check if gtk is enabled and supports the wayland backend
be82ae
+if host_machine.system() != 'windows' and spice_gtk_has_gtk and compiler.has_header('gtk-3.0/gdk/gdkwayland.h')
be82ae
+  d = dependency('wayland-protocols', version: '>= 1.17', required: get_option('wayland-protocols'))
be82ae
+  if d.found()
be82ae
+    spice_gtk_config_data.set('HAVE_WAYLAND_PROTOCOLS', '1')
be82ae
+    dir_wp_base = d.get_pkgconfig_variable('pkgdatadir')
be82ae
+    dep_scanner = dependency('wayland-scanner', native: true)
be82ae
+    prog_scanner = find_program(dep_scanner.get_pkgconfig_variable('wayland_scanner'))
be82ae
+
be82ae
+    wayland_libs_version_required = '1.17.0'
be82ae
+    spice_wayland_deps += dependency('wayland-server', version : '>= @0@'.format(wayland_libs_version_required))
be82ae
+    spice_wayland_deps += dependency('wayland-cursor', version : '>= @0@'.format(wayland_libs_version_required))
be82ae
+    spice_wayland_deps += dependency('wayland-client', version : '>= @0@'.format(wayland_libs_version_required))
be82ae
+    spice_gtk_has_wayland_protocols = true
be82ae
+  endif
be82ae
+endif
be82ae
+
be82ae
 # webdav
be82ae
 spice_gtk_has_phodav = false
be82ae
 d = dependency('libphodav-2.0', required: get_option('webdav'))
be82ae
diff --git a/meson_options.txt b/meson_options.txt
be82ae
index 9804217..60b87ca 100644
be82ae
--- a/meson_options.txt
be82ae
+++ b/meson_options.txt
be82ae
@@ -2,6 +2,10 @@ option('gtk',
be82ae
     type : 'feature',
be82ae
     description: 'Enable gtk+')
be82ae
 
be82ae
+option('wayland-protocols',
be82ae
+    type : 'feature',
be82ae
+    description: 'Enable wayland protocols')
be82ae
+
be82ae
 option('webdav',
be82ae
     type : 'feature',
be82ae
     description: 'Enable webdav support')
be82ae
diff --git a/src/meson.build b/src/meson.build
be82ae
index 654dab5..bdd2239 100644
be82ae
--- a/src/meson.build
be82ae
+++ b/src/meson.build
be82ae
@@ -318,6 +318,64 @@ if spice_gtk_has_gtk
be82ae
                                               command : cmd)
be82ae
   endforeach
be82ae
 
be82ae
+  #
be82ae
+  # Wayland protocols
be82ae
+  #
be82ae
+  if spice_gtk_has_wayland_protocols
be82ae
+
be82ae
+    generated_protocols = [
be82ae
+      [ 'pointer-constraints', 'v1' ],
be82ae
+      [ 'relative-pointer', 'v1' ],
be82ae
+     #[ 'input-method', 'v1' ],
be82ae
+     #[ 'input-timestamps', 'v1' ],
be82ae
+     #[ 'fullscreen-shell', 'v1' ],
be82ae
+     #[ 'linux-dmabuf', 'v1' ],
be82ae
+     #[ 'linux-explicit-synchronization', 'v1' ],
be82ae
+     #[ 'presentation-time', 'stable' ],
be82ae
+     #[ 'tablet', 'v2' ],
be82ae
+     #[ 'text-input', 'v1' ],
be82ae
+     #[ 'viewporter', 'stable' ],
be82ae
+     #[ 'xdg-output', 'v1' ],
be82ae
+     #[ 'xdg-shell', 'v6' ],
be82ae
+     #[ 'xdg-shell', 'stable' ],
be82ae
+    ]
be82ae
+
be82ae
+    foreach proto: generated_protocols
be82ae
+      proto_name = proto[0]
be82ae
+      if proto[1] == 'internal'
be82ae
+        base_file = proto_name
be82ae
+        xml_path = '@0@.xml'.format(proto_name)
be82ae
+      elif proto[1] == 'stable'
be82ae
+        base_file = proto_name
be82ae
+        xml_path = '@0@/stable/@1@/@1@.xml'.format(dir_wp_base, base_file)
be82ae
+      else
be82ae
+        base_file = '@0@-unstable-@1@'.format(proto_name, proto[1])
be82ae
+        xml_path = '@0@/unstable/@1@/@2@.xml'.format(dir_wp_base, proto_name, base_file)
be82ae
+      endif
be82ae
+
be82ae
+      foreach output_type: [ 'client-header', 'server-header', 'private-code' ]
be82ae
+        if output_type == 'client-header'
be82ae
+          output_file = '@0@-client-protocol.h'.format(base_file)
be82ae
+        elif output_type == 'server-header'
be82ae
+          output_file = '@0@-server-protocol.h'.format(base_file)
be82ae
+        else
be82ae
+          output_file = '@0@-protocol.c'.format(base_file)
be82ae
+          if dep_scanner.version().version_compare('< 1.14.91')
be82ae
+              output_type = 'code'
be82ae
+          endif
be82ae
+        endif
be82ae
+
be82ae
+        spice_client_gtk_sources += custom_target(
be82ae
+          '@0@ @1@'.format(base_file, output_type),
be82ae
+          command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
be82ae
+          input: xml_path,
be82ae
+          output: output_file,
be82ae
+        )
be82ae
+        message('@0@ @1@: @2@ -> @3@'.format(prog_scanner, output_type, xml_path, output_file))
be82ae
+      endforeach
be82ae
+    endforeach
be82ae
+  endif
be82ae
+
be82ae
   #
be82ae
   # libspice-client-gtk.so
be82ae
   #
be82ae
@@ -343,11 +401,11 @@ if spice_gtk_has_gtk
be82ae
                                  install : true,
be82ae
                                  link_args : [spice_gtk_version_script],
be82ae
                                  link_depends : spice_client_gtk_syms,
be82ae
-                                 dependencies : [spice_client_glib_dep, spice_gtk_deps])
be82ae
+                                 dependencies : [spice_client_glib_dep, spice_gtk_deps, spice_wayland_deps])
be82ae
 
be82ae
   spice_client_gtk_dep = declare_dependency(sources : spice_widget_enums[1],
be82ae
                                             link_with : spice_client_gtk_lib,
be82ae
-                                            dependencies : [spice_client_glib_dep, spice_gtk_deps])
be82ae
+                                            dependencies : [spice_client_glib_dep, spice_gtk_deps, spice_wayland_deps])
be82ae
 
be82ae
   if spice_gtk_has_introspection
be82ae
     #
be82ae
-- 
be82ae
2.26.2
be82ae