[Spice-devel] [PATCH vdagent v3 1/3] vdagent: add GTK+

Jakub Janků janku.jakub.jj at gmail.com
Tue Nov 21 22:26:04 UTC 2017


Hi,

On Tue, Nov 21, 2017 at 5:09 PM, Victor Toso <victortoso at redhat.com> wrote:
>
> Hi,
>
> On Mon, Nov 13, 2017 at 06:50:05PM +0100, Jakub Janků wrote:
> > This is a preparatory patch for GTK+ vdagent redesign.
> >
> > Since most of the vdagent code still uses X11 lib,
> > force GDK to use X11 backend by calling
> > gdk_set_allowed_backends("x11").
> > ---
> >  Makefile.am           | 2 ++
> >  configure.ac          | 1 +
> >  src/vdagent/vdagent.c | 5 +++++
> >  3 files changed, 8 insertions(+)
> >
> > diff --git a/Makefile.am b/Makefile.am
> > index 4689713..5a5b014 100644
> > --- a/Makefile.am
> > +++ b/Makefile.am
> > @@ -15,6 +15,7 @@ src_spice_vdagent_CFLAGS =                  \
> >       $(X_CFLAGS)                             \
> >       $(SPICE_CFLAGS)                         \
> >       $(GLIB2_CFLAGS)                         \
> > +     $(GTK_CFLAGS)                           \
> >       $(ALSA_CFLAGS)                          \
> >       -I$(srcdir)/src                         \
> >       -DUDSCS_NO_SERVER                       \
> > @@ -24,6 +25,7 @@ src_spice_vdagent_LDADD =                   \
> >       $(X_LIBS)                               \
> >       $(SPICE_LIBS)                           \
> >       $(GLIB2_LIBS)                           \
> > +     $(GTK_LIBS)                             \
> >       $(ALSA_LIBS)                            \
> >       $(NULL)
> >
> > diff --git a/configure.ac b/configure.ac
> > index d92b527..4f4bc0a 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -86,6 +86,7 @@ AC_ARG_ENABLE([static-uinput],
> >                [enable_static_uinput="no"])
> >
> >  PKG_CHECK_MODULES([GLIB2], [glib-2.0 >= 2.34])
> > +PKG_CHECK_MODULES([GTK], [gtk+-3.0])
>
> I guess we should set a required version here. Initially, a version good
> enough to for the x11 and for wayland we can bump it if necessary.

I've just checked and realized that gdk_set_allowed_backends()
requires version 3.10, so it will have to be surrounded by
#GTK_CHECK_VERSION.
However, the rest of the code should compile with gtk3, no specific
version needed. From what I've done so far, clipboard redesign
shouldn't require a higher version either.

>
> >  PKG_CHECK_MODULES(X, [xfixes xrandr >= 1.3 xinerama x11])
> >  PKG_CHECK_MODULES(SPICE, [spice-protocol >= 0.12.13])
> >  PKG_CHECK_MODULES(ALSA, [alsa >= 1.0.22])
> > diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
> > index ac90634..4710a44 100644
> > --- a/src/vdagent/vdagent.c
> > +++ b/src/vdagent/vdagent.c
> > @@ -36,6 +36,7 @@
> >  #include <spice/vd_agent.h>
> >  #include <poll.h>
> >  #include <glib-unix.h>
> > +#include <gtk/gtk.h>
> >
> >  #include "udscs.h"
> >  #include "vdagentd-proto.h"
> > @@ -400,6 +401,7 @@ int main(int argc, char *argv[])
> >      g_option_context_set_summary(context,
> >                                   "\tSpice session guest agent: X11\n"
> >                                   "\tVersion: " VERSION);
> > +    g_option_context_add_group(context, gtk_get_option_group(FALSE));
> >      g_option_context_parse(context, &argc, &argv, &error);
> >      g_option_context_free(context);
> >
> > @@ -427,6 +429,9 @@ int main(int argc, char *argv[])
> >      if (do_daemonize)
> >          parent_socket = daemonize();
> >
> > +    gdk_set_allowed_backends("x11");
> > +    gtk_init(NULL, NULL);
>
> Hm, if you don't provide argc/argv, gtk_init() will not be able to parse
> command line options, right?

Since gtk command line options are added to the GOptionContext with
g_option_context_add_group(context, gtk_get_option_group(FALSE));
the arguments are parsed when g_option_context_parse() is called.

>
> > +
> >  reconnect:
> >      if (version_mismatch) {
> >          syslog(LOG_INFO, "Version mismatch, restarting");
> > --
> > 2.13.6
> >
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel

Thanks,
Jakub


More information about the Spice-devel mailing list