[Spice-devel] [PATCH vdagent v4 1/4] vdagent: add GTK+

Jakub Janků janku.jakub.jj at gmail.com
Tue Dec 5 18:45:50 UTC 2017


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..cefa2d6 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 >= 3.10])
 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);
+
 reconnect:
     if (version_mismatch) {
         syslog(LOG_INFO, "Version mismatch, restarting");
-- 
2.14.3



More information about the Spice-devel mailing list