RE: [RFC v2 2/2] ui: Add a plain Wayland backend for Qemu UI

2021-09-14 Thread Kasireddy, Vivek
Hi Daniel,
 
> On Mon, Sep 13, 2021 at 03:20:36PM -0700, Vivek Kasireddy wrote:
> > Cc: Gerd Hoffmann 
> > Signed-off-by: Vivek Kasireddy 
> > ---
> >  configure |   8 +-
> >  meson.build   |  33 +++
> >  meson_options.txt |   2 +
> >  qapi/ui.json  |   3 +
> >  ui/meson.build|  52 
> >  ui/wayland.c  | 628 ++
> >  6 files changed, 725 insertions(+), 1 deletion(-)  create mode 100644
> > ui/wayland.c
> 
> 
> > diff --git a/ui/meson.build b/ui/meson.build index
> > a73beb0e54..86fc324c82 100644
> > --- a/ui/meson.build
> > +++ b/ui/meson.build
> > @@ -64,6 +64,58 @@ if config_host.has_key('CONFIG_OPENGL') and gbm.found()
> >ui_modules += {'egl-headless' : egl_headless_ss}  endif
> >
> > +wayland_scanner = find_program('wayland-scanner') proto_sources = [
> > +  ['xdg-shell', 'stable', ],
> > +  ['fullscreen-shell', 'unstable', 'v1', ],
> > +  ['linux-dmabuf', 'unstable', 'v1', ], ] wayland_headers = []
> > +wayland_proto_sources = []
> > +
> > +if wayland.found()
> > +  foreach p: proto_sources
> > +proto_name = p.get(0)
> > +proto_stability = p.get(1)
> > +
> > +if proto_stability == 'stable'
> > +  output_base = proto_name
> > +  input = files(join_paths(wlproto_dir,
> '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
> > +else
> > +  proto_version = p.get(2)
> > +  output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability,
> proto_version)
> > +  input = files(join_paths(wlproto_dir,
> '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
> > +endif
> > +
> > +wayland_headers += custom_target('@0@ client 
> > header'.format(output_base),
> > +  input: input,
> > +  output: '@0@-client-protocol.h'.format(output_base),
> > +  command: [
> > +wayland_scanner,
> > +'client-header',
> > +'@INPUT@', '@OUTPUT@',
> > +  ], build_by_default: true
> > +)
> > +
> > +wayland_proto_sources += custom_target('@0@ 
> > source'.format(output_base),
> > +  input: input,
> > +  output: '@0@-protocol.c'.format(output_base),
> > +  command: [
> > +wayland_scanner,
> > +'private-code',
> > +'@INPUT@', '@OUTPUT@',
> > +  ], build_by_default: true
> > +)
> > +  endforeach
> > +endif
> > +
> > +if wayland.found()
> > +  wayland_ss = ss.source_set()
> > +  wayland_ss.add(when: wayland, if_true: files('wayland.c',
> > +'xdg-shell-protocol.c',
> > +'fullscreen-shell-unstable-v1-protocol.c','linux-dmabuf-unstable-v1-p
> > +rotocol.c'))
> > +  #wayland_ss.add(when: wayland, if_true: files('wayland.c'),
> > +[wayland_proto_sources])
> > +  ui_modules += {'wayland' : wayland_ss} endif
> 
> Configure fails on this
> 
>   Program wayland-scanner found: YES (/usr/bin/wayland-scanner)
> 
>   ../ui/meson.build:114:13: ERROR: File xdg-shell-protocol.c does not exist.
> 
> 
> the code a few lines above generates xdg-shell-protocol.c, but that isn't run 
> until you type
> "make", so when meson is resolving the source files they don't exist.
> 
> The alternative line you have commented out looks more like what we would 
> need, but it
> doesn't work either as its syntax is invalid.
[Kasireddy, Vivek] Right, the commented line is the one we'd need but despite 
exhaustively
trying various different combinations, I couldn't get Meson to include the 
auto-generated
protocol sources. If it is not too much trouble, could you please point me to 
an example
where this is done elsewhere in Qemu source that I can look at?

> 
> How did you actually compile this series ?
[Kasireddy, Vivek] Oh, as a workaround, I just manually added the protocol 
sources. I am
sorry I did not realize that this code would be compiled/tested; I mainly 
posted these
RFC/WIP patches to provide additional context to the discussion associated with 
the DRM/
Virtio-gpu kernel patches.

Thanks,
Vivek

> 
> 
> Regards,
> Daniel
> --
> |: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org -o-https://fstop138.berrange.com :|
> |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



Re: [RFC v2 2/2] ui: Add a plain Wayland backend for Qemu UI

2021-09-14 Thread Daniel P . Berrangé
On Mon, Sep 13, 2021 at 03:20:36PM -0700, Vivek Kasireddy wrote:
> Cc: Gerd Hoffmann 
> Signed-off-by: Vivek Kasireddy 
> ---
>  configure |   8 +-
>  meson.build   |  33 +++
>  meson_options.txt |   2 +
>  qapi/ui.json  |   3 +
>  ui/meson.build|  52 
>  ui/wayland.c  | 628 ++
>  6 files changed, 725 insertions(+), 1 deletion(-)
>  create mode 100644 ui/wayland.c


> diff --git a/ui/meson.build b/ui/meson.build
> index a73beb0e54..86fc324c82 100644
> --- a/ui/meson.build
> +++ b/ui/meson.build
> @@ -64,6 +64,58 @@ if config_host.has_key('CONFIG_OPENGL') and gbm.found()
>ui_modules += {'egl-headless' : egl_headless_ss}
>  endif
>  
> +wayland_scanner = find_program('wayland-scanner')
> +proto_sources = [
> +  ['xdg-shell', 'stable', ],
> +  ['fullscreen-shell', 'unstable', 'v1', ],
> +  ['linux-dmabuf', 'unstable', 'v1', ],
> +]
> +wayland_headers = []
> +wayland_proto_sources = []
> +
> +if wayland.found()
> +  foreach p: proto_sources
> +proto_name = p.get(0)
> +proto_stability = p.get(1)
> +
> +if proto_stability == 'stable'
> +  output_base = proto_name
> +  input = files(join_paths(wlproto_dir, 
> '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
> +else
> +  proto_version = p.get(2)
> +  output_base = '@0@-@1@-@2@'.format(proto_name, proto_stability, 
> proto_version)
> +  input = files(join_paths(wlproto_dir, 
> '@0@/@1@/@2@.xml'.format(proto_stability, proto_name, output_base)))
> +endif
> +
> +wayland_headers += custom_target('@0@ client header'.format(output_base),
> +  input: input,
> +  output: '@0@-client-protocol.h'.format(output_base),
> +  command: [
> +wayland_scanner,
> +'client-header',
> +'@INPUT@', '@OUTPUT@',
> +  ], build_by_default: true
> +)
> +
> +wayland_proto_sources += custom_target('@0@ source'.format(output_base),
> +  input: input,
> +  output: '@0@-protocol.c'.format(output_base),
> +  command: [
> +wayland_scanner,
> +'private-code',
> +'@INPUT@', '@OUTPUT@',
> +  ], build_by_default: true
> +)
> +  endforeach
> +endif
> +
> +if wayland.found()
> +  wayland_ss = ss.source_set()
> +  wayland_ss.add(when: wayland, if_true: files('wayland.c', 
> 'xdg-shell-protocol.c', 
> 'fullscreen-shell-unstable-v1-protocol.c','linux-dmabuf-unstable-v1-protocol.c'))
> +  #wayland_ss.add(when: wayland, if_true: files('wayland.c'), 
> [wayland_proto_sources])
> +  ui_modules += {'wayland' : wayland_ss}
> +endif

Configure fails on this

  Program wayland-scanner found: YES (/usr/bin/wayland-scanner)

  ../ui/meson.build:114:13: ERROR: File xdg-shell-protocol.c does not exist.


the code a few lines above generates xdg-shell-protocol.c, but that
isn't run until you type "make", so when meson is resolving the
source files they don't exist.

The alternative line you have commented out looks more like what we
would need, but it doesn't work either as its syntax is invalid.

How did you actually compile this series ?


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|




Re: [RFC v2 2/2] ui: Add a plain Wayland backend for Qemu UI

2021-09-14 Thread Eric Blake
On Mon, Sep 13, 2021 at 03:20:36PM -0700, Vivek Kasireddy wrote:
> Cc: Gerd Hoffmann 
> Signed-off-by: Vivek Kasireddy 
> ---
>  configure |   8 +-
>  meson.build   |  33 +++
>  meson_options.txt |   2 +
>  qapi/ui.json  |   3 +
>  ui/meson.build|  52 
>  ui/wayland.c  | 628 ++
>  6 files changed, 725 insertions(+), 1 deletion(-)
>  create mode 100644 ui/wayland.c

UI review:

> +++ b/qapi/ui.json
> @@ -1112,6 +1112,8 @@
>  #DRI device. Graphical display need to be paired with
>  #VNC or Spice. (Since 3.1)
>  #
> +# @wayland: The Wayland user interface.

Missing a '(since 6.2)' tag.

> +#
>  # @curses: Display video output via curses.  For graphics device
>  #  models which support a text mode, QEMU can display this
>  #  output using a curses/ncurses interface. Nothing is
> @@ -1135,6 +1137,7 @@
>  { 'name': 'none' },
>  { 'name': 'gtk', 'if': 'CONFIG_GTK' },
>  { 'name': 'sdl', 'if': 'CONFIG_SDL' },
> +{ 'name': 'wayland', 'if': 'CONFIG_WAYLAND' },
>  { 'name': 'egl-headless',
>'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } },
>  { 'name': 'curses', 'if': 'CONFIG_CURSES' },

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




[RFC v2 2/2] ui: Add a plain Wayland backend for Qemu UI

2021-09-13 Thread Vivek Kasireddy
Cc: Gerd Hoffmann 
Signed-off-by: Vivek Kasireddy 
---
 configure |   8 +-
 meson.build   |  33 +++
 meson_options.txt |   2 +
 qapi/ui.json  |   3 +
 ui/meson.build|  52 
 ui/wayland.c  | 628 ++
 6 files changed, 725 insertions(+), 1 deletion(-)
 create mode 100644 ui/wayland.c

diff --git a/configure b/configure
index da2501489f..02339681dc 100755
--- a/configure
+++ b/configure
@@ -406,6 +406,7 @@ cfi_debug="false"
 seccomp="auto"
 glusterfs="auto"
 gtk="auto"
+wayland="auto"
 tls_priority="NORMAL"
 gnutls="auto"
 nettle="auto"
@@ -1383,6 +1384,10 @@ for opt do
   ;;
   --enable-gtk) gtk="enabled"
   ;;
+  --disable-wayland) wayland="disabled"
+  ;;
+  --enable-wayland) wayland="enabled"
+  ;;
   --tls-priority=*) tls_priority="$optarg"
   ;;
   --disable-gnutls) gnutls="disabled"
@@ -1868,6 +1873,7 @@ disabled with --disable-FEATURE, default is enabled if 
available
   sdl SDL UI
   sdl-image   SDL Image support for icons
   gtk gtk UI
+  wayland Wayland UI
   vte vte support for the gtk UI
   curses  curses UI
   iconv   font glyph conversion support
@@ -5191,7 +5197,7 @@ if test "$skip_meson" = no; then
 -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
 -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf -Dnvmm=$nvmm \
 -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
--Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl 
-Dsdl_image=$sdl_image \
+-Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dwayland=$wayland 
-Dsdl_image=$sdl_image \
 -Dlibusb=$libusb -Dsmartcard=$smartcard -Dusb_redir=$usb_redir 
-Dvte=$vte \
 -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg 
-Dvnc_png=$vnc_png \
 -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f 
-Dvirtiofsd=$virtiofsd \
diff --git a/meson.build b/meson.build
index 7d7d14a4bc..cda10b7d0f 100644
--- a/meson.build
+++ b/meson.build
@@ -927,6 +927,37 @@ if gtkx11.found()
   x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
kwargs: static_kwargs)
 endif
+
+wayland = not_found
+if not get_option('wayland').auto()
+  wlclientdep = dependency('wayland-client', version: '>= 1.18.90',
+   method: 'pkg-config',
+   required: get_option('wayland'),
+   kwargs: static_kwargs)
+  wlprotocolsdep = dependency('wayland-protocols', version: '>= 1.14.91',
+  method: 'pkg-config',
+  required: get_option('wayland'),
+  kwargs: static_kwargs)
+
+  if not wlprotocolsdep.found()
+wlproto_dir = 
subproject('wayland-protocols').get_variable('wayland_protocols_srcdir')
+  else
+wlproto_dir = wlprotocolsdep.get_pkgconfig_variable('pkgdatadir')
+  endif
+
+  wayland = declare_dependency(dependencies: [wlclientdep, wlprotocolsdep])
+endif
+
+if wayland.found() and get_option('sdl').enabled()
+  error('Wayland and SDL cannot be enabled at the same time')
+endif
+if wayland.found() and get_option('gtk').enabled()
+  error('Wayland and GTK+ cannot be enabled at the same time')
+endif
+if wayland.found() and get_option('cocoa').enabled()
+  error('Wayland and Cocoa cannot be enabled at the same time')
+endif
+
 vnc = not_found
 png = not_found
 jpeg = not_found
@@ -1256,6 +1287,7 @@ if glusterfs.found()
   config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', 
glusterfs_iocb_has_stat)
 endif
 config_host_data.set('CONFIG_GTK', gtk.found())
+config_host_data.set('CONFIG_WAYLAND', wayland.found())
 config_host_data.set('CONFIG_VTE', vte.found())
 config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
 config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
@@ -3052,6 +3084,7 @@ summary_info += {'SDL support':   sdl.found()}
 summary_info += {'SDL image support': sdl_image.found()}
 # TODO: add back version
 summary_info += {'GTK support':   gtk.found()}
+summary_info += {'Wayland support':   wayland.found()}
 summary_info += {'pixman':pixman.found()}
 # TODO: add back version
 summary_info += {'VTE support':   vte.found()}
diff --git a/meson_options.txt b/meson_options.txt
index a9a9b8f4c6..6c0e27e83b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -104,6 +104,8 @@ option('rbd', type : 'feature', value : 'auto',
description: 'Ceph block device driver')
 option('gtk', type : 'feature', value : 'auto',
description: 'GTK+ user interface')
+option('wayland', type : 'feature', value : 'auto',
+   description: 'Wayland user interface')
 option('sdl', type : 'feature', value : 'auto',
description: 'SDL user interface')
 option('sdl_image', type : 'feature', value : 'auto',
diff --git a/qapi/ui.json b/qapi/ui.json
index b2cf7a6759..8da0baa0bd 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1112,6