[Spice-devel] [PATCH v2 06/10] Drop GTK+ 2.0
Marc-André Lureau
marcandre.lureau at gmail.com
Fri Mar 11 20:50:37 UTC 2016
Not so many systems require gtk+ 2.0 these days, let's move on.
This drops the old python bindings (non-gir based), and the
unsteady/experimental gtk2-only XShm support.
Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
---
Makefile.am | 2 +-
configure.ac | 124 +-------------------
doc/reference/Makefile.am | 2 +-
spice-client-gtk-2.0.pc.in | 12 --
src/Makefile.am | 73 +-----------
src/channel-display-priv.h | 1 -
src/channel-display.c | 41 +------
src/gtk-compat.h | 24 ----
src/spice-widget-cairo.c | 20 ----
src/spice-widget-priv.h | 20 ----
src/spice-widget-x11.c | 280 ---------------------------------------------
src/spice-widget.c | 30 -----
vapi/Makefile.am | 11 +-
13 files changed, 20 insertions(+), 620 deletions(-)
delete mode 100644 spice-client-gtk-2.0.pc.in
delete mode 100644 src/spice-widget-x11.c
diff --git a/Makefile.am b/Makefile.am
index 3d7a174..47cf840 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,7 @@ pkgconfig_DATA = \
$(NULL)
if WITH_GTK
-pkgconfig_DATA += spice-client-gtk-$(SPICE_GTK_API_VERSION).pc
+pkgconfig_DATA += spice-client-gtk-3.0.pc
endif
if WITH_CONTROLLER
diff --git a/configure.ac b/configure.ac
index 4168290..5cba2ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,7 +62,6 @@ esac
AC_MSG_RESULT([$os_win32])
AM_CONDITIONAL([OS_WIN32],[test "$os_win32" = "yes"])
-AC_CHECK_HEADERS([sys/ipc.h sys/shm.h])
AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h])
AC_CHECK_HEADERS([termios.h])
@@ -115,44 +114,30 @@ SPICE_CHECK_SASL
AC_MSG_CHECKING([which gtk+ version to compile against])
AC_ARG_WITH([gtk],
- [AS_HELP_STRING([--with-gtk=@<:@2.0/3.0/no@:>@],[which gtk+ version to compile against @<:@default=3.0@:>@])],
+ [AS_HELP_STRING([--with-gtk=@<:@3.0/no@:>@],[which gtk+ version to compile against @<:@default=3.0@:>@])],
[case "$with_gtk" in
- 2.0|3.0) AC_MSG_RESULT([$with_gtk]) ;;
+ 3.0) AC_MSG_RESULT([$with_gtk]) ;;
no) AC_MSG_RESULT([none]) ;;
*) AC_MSG_ERROR([invalid gtk version specified]) ;;
esac],
[with_gtk=3.0])
case "$with_gtk" in
- 2.0) GTK_API_VERSION=2.0
- GTK_REQUIRED=2.18.0
- SPICE_GTK_API_VERSION=2.0
- ;;
- 3.0) GTK_API_VERSION=3.0
- GTK_REQUIRED=2.91.3
- SPICE_GTK_API_VERSION=3.0
+ 3.0) GTK_REQUIRED=2.91.3
;;
no)
AS_IF([test x$enable_gtk_doc = xyes],
[AC_MSG_ERROR([Without GTK+, gtk-doc must be disabled])])
esac
-AC_SUBST([GTK_API_VERSION])
AC_SUBST([GTK_REQUIRED])
-AC_SUBST([SPICE_GTK_API_VERSION])
AM_CONDITIONAL([WITH_GTK],[test "$with_gtk" != "no"])
-AM_CONDITIONAL([HAVE_GTK_2],[test "$with_gtk" = "2.0"])
-AM_CONDITIONAL([HAVE_GTK_3],[test "$with_gtk" = "3.0"])
AS_IF([test "x$with_gtk" != "xno"],
- [PKG_CHECK_MODULES(GTK, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED)])
+ [PKG_CHECK_MODULES(GTK, gtk+-3.0 >= $GTK_REQUIRED)])
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
-SPICE_GTK_REQUIRES="${SPICE_GTK_REQUIRES} gtk+-$GTK_API_VERSION >= $GTK_REQUIRED"
-
-PKG_CHECK_EXISTS([gtk+-x11-$with_gtk], [have_x11=yes], [have_x11=no])
-AS_IF([test "x$have_x11" = "xyes"], [AC_DEFINE([HAVE_X11], 1, [Have x11?])])
-AM_CONDITIONAL([WITH_DISPLAY_X11], [test "x$have_x11" = "xyes"])
+SPICE_GTK_REQUIRES="${SPICE_GTK_REQUIRES} gtk+-3.0 >= $GTK_REQUIRED"
PKG_CHECK_EXISTS([gtk+-quartz-$with_gtk], [have_quartz=yes], [have_quartz=no])
AS_IF([test "x$have_quartz" = "xyes"], [AC_DEFINE([HAVE_QUARTZ], 1, [Have Quartz?])])
@@ -162,27 +147,7 @@ PKG_CHECK_EXISTS([gtk+-win32-$with_gtk], [have_win32=yes], [have_win32=no])
AS_IF([test "x$have_win32" = "xyes"], [AC_DEFINE([HAVE_WINDOWS], 1, [Have Win32?])])
AM_CONDITIONAL([WITH_DISPLAY_WINDOWS], [test "x$have_win32" = "xyes"])
-if [test "x$have_x11" = "xyes" ]
-then
- AC_CHECK_HEADERS([X11/XKBlib.h])
-fi
-
-AC_ARG_WITH([x11],
- AS_HELP_STRING([--with-x11], [Use x11/shm display backend instead of cairo @<:@default=no@:>@]))
-
-AC_MSG_CHECKING([What rendering backend to use..])
-if [test "x$with_x11" = "xyes" ]
-then
- if [test "$GTK_API_VERSION" = "3.0" ]
- then
- AC_MSG_ERROR([X11 SHM backend is not compatible with GTK3])
- fi
- AC_MSG_RESULT([x11])
- AC_DEFINE([WITH_X11], 1, [Use X11 backend?])
-else
- AC_MSG_RESULT([cairo])
-fi
-AM_CONDITIONAL([WITH_X11], [test "x$with_x11" = "xyes"])
+AC_CHECK_HEADERS([X11/XKBlib.h])
AC_ARG_WITH([pnp-ids-path],
AC_HELP_STRING([--with-pnp-ids-path],
@@ -567,82 +532,6 @@ AM_CONDITIONAL(WITH_VALA, [test "x$enable_vala" = "xyes"])
VAPIDIR="${datadir}/vala/vapi"
AC_SUBST(VAPIDIR)
-
-AC_ARG_WITH([python],
- AS_HELP_STRING([--with-python], [build python bindings @<:@default=auto@:>@]),
- [case "$withval" in
- yes|no|auto) with_python="$withval";;
- *) AC_MSG_ERROR([bad value $withval for python option]) ;;
- esac],
- [AS_IF([test "$with_gtk" != "2.0" || test "x$os_win32" = "xyes"],
- [with_python=no],[with_python=auto])]
-)
-
-if test "x$with_python" != "xno"; then
- PKG_CHECK_MODULES(PYGTK, [pygtk-2.0 >= 2.0.0], [have_pygtk=yes], [have_pygtk=no])
- AC_SUBST(PYGTK_CFLAGS)
- AC_SUBST(PYGTK_LIBS)
- if test "x$have_pygtk" != "xyes"
- then
- if test "x$with_python" = "xyes"
- then
- AC_MSG_ERROR("No pygtk found")
- else
- with_python=no
- fi
- fi
-fi
-
-if test "x$with_python" != "xno"; then
- AM_PATH_PYTHON([], [have_python=yes], [have_python=no])
- if test "x$have_python" != "xyes"
- then
- if test "x$with_python" = "xyes"
- then
- AC_MSG_ERROR("No python found")
- else
- with_python=no
- fi
- fi
-fi
-
-if test "x$with_python" != "xno"; then
- AC_MSG_CHECKING([whether $PYTHON version >= 2.0])
- HAVE_PYTHON_REQUIRED=no
- AM_PYTHON_CHECK_VERSION([$PYTHON], [2.0],
- [HAVE_PYTHON_REQUIRED="yes"],
- [HAVE_PYTHON_REQUIRED="no"])
-
- AC_MSG_RESULT($HAVE_PYTHON_REQUIRED)
-
- if test "x$HAVE_PYTHON_REQUIRED" != "xyes"
- then
- if test "x$with_python" = "xyes"
- then
- AC_MSG_ERROR("No suitable python found")
- else
- with_python=no
- fi
- fi
-fi
-
-if test "x$with_python" != "xno"; then
- AM_CHECK_PYTHON_HEADERS(have_python_headers=yes,have_python_headers=no)
-
- if test "x$have_python_headers" != "xyes"
- then
- if test "x$with_python" = "xyes"
- then
- AC_MSG_ERROR("No python development headers found")
- else
- with_python=no
- fi
- fi
-fi
-
-AM_CONDITIONAL(WITH_PYTHON, [test "x$with_python" != "xno"])
-
-
AC_ARG_ENABLE([dbus],
AS_HELP_STRING([--enable-dbus=@<:@auto/yes/no@:>@],
[Enable dbus support for desktop integration (disabling automount) @<:@default=auto@:>@]),
@@ -695,7 +584,6 @@ AM_CONDITIONAL([BUILD_TESTS], [test x"$enable_static" = xyes])
AC_OUTPUT([
Makefile
spice-client-glib-2.0.pc
-spice-client-gtk-2.0.pc
spice-client-gtk-3.0.pc
spice-controller.pc
data/Makefile
diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am
index 2d13863..b76a9cf 100644
--- a/doc/reference/Makefile.am
+++ b/doc/reference/Makefile.am
@@ -55,7 +55,7 @@ IGNORE_HFILES= \
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
GTKDOC_CFLAGS = -I$(top_srcdir) -I$(top_builddir) -I$(top_srcdir)/src -I$(top_builddir)/src $(SPICE_GLIB_CFLAGS) $(SPICE_GTK_CFLAGS) $(COMMON_CFLAGS) -DSPICE_COMPILATION
-GTKDOC_LIBS = $(top_builddir)/src/libspice-client-glib-2.0.la $(top_builddir)/src/libspice-client-gtk-$(SPICE_GTK_API_VERSION).la $(GTK_LIBS)
+GTKDOC_LIBS = $(top_builddir)/src/libspice-client-glib-2.0.la $(top_builddir)/src/libspice-client-gtk-3.0.la $(GTK_LIBS)
include $(top_srcdir)/gtk-doc.make
diff --git a/spice-client-gtk-2.0.pc.in b/spice-client-gtk-2.0.pc.in
deleted file mode 100644
index a5b96e2..0000000
--- a/spice-client-gtk-2.0.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
-
-Name: spice-client-gtk-2.0
-Description: SPICE Client Gtk 2.0 library
-Version: @VERSION@
-
-Requires: @SPICE_GTK_REQUIRES@ spice-client-glib-2.0
-Libs: -L${libdir} -lspice-client-gtk-2.0
-Cflags: -I${includedir}/spice-client-gtk-2.0
diff --git a/src/Makefile.am b/src/Makefile.am
index d6935cf..ffc98b9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,12 +57,8 @@ endif
lib_LTLIBRARIES = libspice-client-glib-2.0.la
if WITH_GTK
-if HAVE_GTK_2
-lib_LTLIBRARIES += libspice-client-gtk-2.0.la
-else
lib_LTLIBRARIES += libspice-client-gtk-3.0.la
endif
-endif
if HAVE_LD_VERSION_SCRIPT
GLIB_SYMBOLS_LDFLAGS = -Wl,--version-script=${srcdir}/map-file
@@ -151,15 +147,9 @@ nodist_SPICE_GTK_SOURCES_COMMON = \
spice-marshal.c \
$(NULL)
-if WITH_X11
-SPICE_GTK_SOURCES_COMMON += \
- spice-widget-x11.c \
- $(NULL)
-else
SPICE_GTK_SOURCES_COMMON += \
spice-widget-cairo.c \
$(NULL)
-endif
if WITH_GTK
if WITH_EPOXY
@@ -168,23 +158,14 @@ SPICE_GTK_SOURCES_COMMON += \
$(NULL)
endif
-if HAVE_GTK_2
-libspice_client_gtk_2_0_la_DEPEDENCIES = $(GTK_SYMBOLS_FILE)
-libspice_client_gtk_2_0_la_LDFLAGS = $(SPICE_GTK_LDFLAGS_COMMON)
-libspice_client_gtk_2_0_la_LIBADD = $(SPICE_GTK_LIBADD_COMMON)
-libspice_client_gtk_2_0_la_SOURCES = $(SPICE_GTK_SOURCES_COMMON)
-libspice_client_gtk_2_0_la_CFLAGS = $(EPOXY_CFLAGS)
-nodist_libspice_client_gtk_2_0_la_SOURCES = $(nodist_SPICE_GTK_SOURCES_COMMON)
-else
libspice_client_gtk_3_0_la_DEPEDENCIES = $(GTK_SYMBOLS_FILE)
libspice_client_gtk_3_0_la_LDFLAGS = $(SPICE_GTK_LDFLAGS_COMMON)
libspice_client_gtk_3_0_la_LIBADD = $(SPICE_GTK_LIBADD_COMMON)
libspice_client_gtk_3_0_la_SOURCES = $(SPICE_GTK_SOURCES_COMMON)
libspice_client_gtk_3_0_la_CFLAGS = $(EPOXY_CFLAGS)
nodist_libspice_client_gtk_3_0_la_SOURCES = $(nodist_SPICE_GTK_SOURCES_COMMON)
-endif
-libspice_client_gtkincludedir = $(includedir)/spice-client-gtk-$(SPICE_GTK_API_VERSION)
+libspice_client_gtkincludedir = $(includedir)/spice-client-gtk-3.0
libspice_client_gtkinclude_HEADERS = \
spice-client-gtk.h \
spice-gtk-session.h \
@@ -399,7 +380,7 @@ spicy_SOURCES = \
$(NULL)
spicy_LDADD = \
- libspice-client-gtk-$(SPICE_GTK_API_VERSION).la \
+ libspice-client-gtk-3.0.la \
libspice-client-glib-2.0.la \
$(GTHREAD_LIBS) \
$(GTK_LIBS) \
@@ -470,12 +451,8 @@ spicy_stats_LDADD = \
$(libspice_client_glib_2_0_la_SOURCES): spice-glib-enums.h spice-marshal.h
if WITH_GTK
-if HAVE_GTK_2
-$(libspice_client_gtk_2_0_la_SOURCES): spice-glib-enums.h spice-widget-enums.h
-else
$(libspice_client_gtk_3_0_la_SOURCES): spice-glib-enums.h spice-widget-enums.h
endif
-endif
spice-marshal.c: spice-marshal.h
spice-glib-enums.c: spice-glib-enums.h
@@ -576,40 +553,6 @@ vncdisplaykeymap_win322xtkbd.c:
vncdisplaykeymap_x112xtkbd.c:
$(AM_V_GEN)$(KEYMAP_GEN) $(srcdir)/keymaps.csv x11 xtkbd > $@ || rm $@
-if WITH_PYTHON
-pyexec_LTLIBRARIES = SpiceClientGtk.la
-
-# workaround for broken parallel install support in automake with LTLIBRARIES
-# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7328
-install_pyexecLTLIBRARIES = install-pyexecLTLIBRARIES
-$(install_pyexecLTLIBRARIES): install-libLTLIBRARIES
-
-SpiceClientGtk_la_LIBADD = libspice-client-gtk-2.0.la libspice-client-glib-2.0.la $(PYGTK_LIBS)
-SpiceClientGtk_la_CFLAGS = $(GTK_CFLAGS) $(PYTHON_INCLUDES) $(PYGTK_CFLAGS) $(WARN_PYFLAGS)
-SpiceClientGtk_la_LDFLAGS = -module -avoid-version -fPIC
-SpiceClientGtk_la_SOURCES = spice-client-gtk-module.c
-nodist_SpiceClientGtk_la_SOURCES = spice-client-gtk-module.defs.c
-
-CODEGENDIR = `pkg-config --variable=codegendir pygtk-2.0`
-DEFSDIR = `pkg-config --variable=defsdir pygtk-2.0`
-
-spice-client-gtk.defs: $(libspice_client_gtkinclude_HEADERS) $(nodist_libspice_client_gtkinclude_HEADERS) $(libspice_client_glibinclude_HEADERS) $(nodist_libspice_client_glibinclude_HEADERS)
- $(AM_V_GEN)$(PYTHON) $(CODEGENDIR)/h2def.py \
- -f $(srcdir)/spice-client-gtk-manual.defs \
- $^ > $@
-
-spice-client-gtk-module.defs.c: spice-client-gtk.override spice-client-gtk.defs spice-client-gtk-manual.defs
- @cat spice-client-gtk.defs $(srcdir)/spice-client-gtk-manual.defs > tmp.defs
- $(AM_V_GEN)pygobject-codegen-2.0 --prefix spice \
- --register $(DEFSDIR)/gdk-types.defs \
- --register $(DEFSDIR)/gtk-types.defs \
- --override $(srcdir)/spice-client-gtk.override \
- tmp.defs > $@
- @rm tmp.defs
-
-CLEANFILES += spice-client-gtk-module.defs.c spice-client-gtk.defs
-endif
-
-include $(INTROSPECTION_MAKEFILE)
if G_IR_SCANNER_SYMBOL_PREFIX
@@ -666,15 +609,6 @@ SpiceClientGLib_2_0_gir_SCANNERFLAGS = --c-include="spice-client.h"
INTROSPECTION_GIRS += SpiceClientGLib-2.0.gir
if WITH_GTK
-if HAVE_GTK_2
-SpiceClientGtk-2.0.gir: libspice-client-gtk-2.0.la SpiceClientGLib-2.0.gir
-SpiceClientGtk_2_0_gir_INCLUDES = GObject-2.0 Gtk-2.0 SpiceClientGLib-2.0
-SpiceClientGtk_2_0_gir_CFLAGS = $(SPICE_COMMON_CPPFLAGS)
-SpiceClientGtk_2_0_gir_LIBS = libspice-client-gtk-2.0.la libspice-client-glib-2.0.la
-SpiceClientGtk_2_0_gir_FILES = $(gtk_introspection_files)
-SpiceClientGtk_2_0_gir_EXPORT_PACKAGES = spice-client-gtk-2.0
-SpiceClientGtk_2_0_gir_SCANNERFLAGS = --c-include="spice-widget.h"
-else
SpiceClientGtk-3.0.gir: libspice-client-gtk-3.0.la SpiceClientGLib-2.0.gir
SpiceClientGtk_3_0_gir_INCLUDES = GObject-2.0 Gtk-3.0 SpiceClientGLib-2.0
SpiceClientGtk_3_0_gir_CFLAGS = $(SPICE_COMMON_CPPFLAGS)
@@ -682,8 +616,7 @@ SpiceClientGtk_3_0_gir_LIBS = libspice-client-gtk-3.0.la libspice-client-glib-2.
SpiceClientGtk_3_0_gir_FILES = $(gtk_introspection_files)
SpiceClientGtk_3_0_gir_EXPORT_PACKAGES = spice-client-gtk-3.0
SpiceClientGtk_3_0_gir_SCANNERFLAGS = --c-include="spice-widget.h"
-endif
-INTROSPECTION_GIRS += SpiceClientGtk-$(SPICE_GTK_API_VERSION).gir
+INTROSPECTION_GIRS += SpiceClientGtk-3.0.gir
endif
girdir = $(datadir)/gir-1.0
diff --git a/src/channel-display-priv.h b/src/channel-display-priv.h
index 71f5d17..f92477b 100644
--- a/src/channel-display-priv.h
+++ b/src/channel-display-priv.h
@@ -40,7 +40,6 @@ typedef struct display_surface {
bool primary;
enum SpiceSurfaceFmt format;
int width, height, stride, size;
- int shmid;
uint8_t *data;
SpiceCanvas *canvas;
SpiceGlzDecoder *glz_decoder;
diff --git a/src/channel-display.c b/src/channel-display.c
index 442642a..cdaba9d 100644
--- a/src/channel-display.c
+++ b/src/channel-display.c
@@ -21,14 +21,6 @@
#include <sys/types.h>
#endif
-#ifdef HAVE_SYS_SHM_H
-#include <sys/shm.h>
-#endif
-
-#ifdef HAVE_SYS_IPC_H
-#include <sys/ipc.h>
-#endif
-
#include "glib-compat.h"
#include "spice-client.h"
#include "spice-common.h"
@@ -497,7 +489,7 @@ gboolean spice_display_get_primary(SpiceChannel *channel, guint32 surface_id,
primary->width = surface->width;
primary->height = surface->height;
primary->stride = surface->stride;
- primary->shmid = surface->shmid;
+ primary->shmid = -1;
primary->data = surface->data;
primary->marked = c->mark;
CHANNEL_DEBUG(channel, "get primary %p", primary->data);
@@ -780,27 +772,11 @@ static int create_canvas(SpiceChannel *channel, display_surface *surface)
}
CHANNEL_DEBUG(channel, "Create primary canvas");
-#if defined(WITH_X11) && defined(HAVE_SYS_SHM_H)
- surface->shmid = shmget(IPC_PRIVATE, surface->size, IPC_CREAT | 0777);
- if (surface->shmid >= 0) {
- surface->data = shmat(surface->shmid, 0, 0);
- if (surface->data == NULL) {
- shmctl(surface->shmid, IPC_RMID, 0);
- surface->shmid = -1;
- }
- }
-#else
- surface->shmid = -1;
-#endif
- } else {
- surface->shmid = -1;
}
- if (surface->shmid == -1)
- surface->data = g_malloc0(surface->size);
+ surface->data = g_malloc0(surface->size);
g_return_val_if_fail(c->glz_window, 0);
-
g_warn_if_fail(surface->canvas == NULL);
g_warn_if_fail(surface->glz_decoder == NULL);
g_warn_if_fail(surface->zlib_decoder == NULL);
@@ -830,7 +806,7 @@ static int create_canvas(SpiceChannel *channel, display_surface *surface)
c->primary = surface;
g_coroutine_signal_emit(channel, signals[SPICE_DISPLAY_PRIMARY_CREATE], 0,
surface->format, surface->width, surface->height,
- surface->stride, surface->shmid, surface->data);
+ surface->stride, -1, surface->data);
if (!spice_channel_test_capability(channel, SPICE_DISPLAY_CAP_MONITORS_CONFIG)) {
g_array_set_size(c->monitors, 1);
@@ -854,16 +830,7 @@ static void destroy_canvas(display_surface *surface)
zlib_decoder_destroy(surface->zlib_decoder);
jpeg_decoder_destroy(surface->jpeg_decoder);
- if (surface->shmid == -1) {
- g_free(surface->data);
- }
-#ifdef HAVE_SYS_SHM_H
- else {
- shmdt(surface->data);
- shmctl(surface->shmid, IPC_RMID, 0);
- }
-#endif
- surface->shmid = -1;
+ g_free(surface->data);
surface->data = NULL;
surface->canvas->ops->destroy(surface->canvas);
diff --git a/src/gtk-compat.h b/src/gtk-compat.h
index aac3b55..b2cf6d6 100644
--- a/src/gtk-compat.h
+++ b/src/gtk-compat.h
@@ -22,12 +22,6 @@
#include <gtk/gtk.h>
-#if !GTK_CHECK_VERSION (2, 91, 0)
-#define GDK_IS_X11_DISPLAY(D) TRUE
-#define gdk_window_get_display(W) gdk_drawable_get_display(GDK_DRAWABLE(W))
-#define GDK_IS_X11_WINDOW(D) TRUE
-#endif
-
#if GTK_CHECK_VERSION (2, 91, 0)
static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
{
@@ -36,22 +30,4 @@ static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh)
}
#endif
-#if !GTK_CHECK_VERSION(2, 20, 0)
-static inline gboolean gtk_widget_get_realized(GtkWidget *widget)
-{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- return GTK_WIDGET_REALIZED(widget);
-}
-#endif
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
-#define cairo_rectangle_int_t GdkRectangle
-#define cairo_region_t GdkRegion
-#define cairo_region_create_rectangle gdk_region_rectangle
-#define cairo_region_subtract_rectangle(_dest,_rect) { GdkRegion *_region = gdk_region_rectangle (_rect); gdk_region_subtract (_dest, _region); gdk_region_destroy (_region); }
-#define cairo_region_destroy gdk_region_destroy
-
-#define gdk_window_get_display(W) gdk_drawable_get_display(GDK_DRAWABLE(W))
-#endif
-
#endif /* GTK_COMPAT_H */
diff --git a/src/spice-widget-cairo.c b/src/spice-widget-cairo.c
index 96af076..c92d4ec 100644
--- a/src/spice-widget-cairo.c
+++ b/src/spice-widget-cairo.c
@@ -132,26 +132,6 @@ void spicex_draw_event(SpiceDisplay *display, cairo_t *cr)
}
}
-#if ! GTK_CHECK_VERSION (2, 91, 0)
-G_GNUC_INTERNAL
-void spicex_expose_event(SpiceDisplay *display, GdkEventExpose *expose)
-{
- cairo_t *cr;
-
- cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(display)));
- cairo_rectangle(cr,
- expose->area.x,
- expose->area.y,
- expose->area.width,
- expose->area.height);
- cairo_clip(cr);
-
- spicex_draw_event(display, cr);
-
- cairo_destroy(cr);
-}
-#endif
-
G_GNUC_INTERNAL
gboolean spicex_is_scaled(SpiceDisplay *display)
{
diff --git a/src/spice-widget-priv.h b/src/spice-widget-priv.h
index 8ac0782..d28328d 100644
--- a/src/spice-widget-priv.h
+++ b/src/spice-widget-priv.h
@@ -20,12 +20,6 @@
#include "config.h"
-#ifdef WITH_X11
-#include <X11/Xlib.h>
-#include <X11/extensions/XShm.h>
-#include <gdk/gdkx.h>
-#endif
-
#ifdef WIN32
#include <windows.h>
#endif
@@ -73,7 +67,6 @@ struct _SpiceDisplayPrivate {
gboolean monitor_ready;
enum SpiceSurfaceFmt format;
gint width, height, stride;
- gint shmid;
gpointer data_origin; /* the original display image data */
gpointer data; /* converted if necessary to 32 bits */
@@ -82,21 +75,12 @@ struct _SpiceDisplayPrivate {
gint ww, wh, mx, my;
bool convert;
- bool have_mitshm;
gboolean allow_scaling;
gboolean only_downscale;
gboolean disable_inputs;
/* TODO: make a display object instead? */
-#ifdef WITH_X11
- Display *dpy;
- XVisualInfo *vi;
- XImage *ximage;
- XShmSegmentInfo *shminfo;
- GC gc;
-#else
cairo_surface_t *ximage;
-#endif
SpiceSession *session;
SpiceGtkSession *gtk_session;
@@ -163,11 +147,7 @@ struct _SpiceDisplayPrivate {
int spicex_image_create (SpiceDisplay *display);
void spicex_image_destroy (SpiceDisplay *display);
-#if GTK_CHECK_VERSION (2, 91, 0)
void spicex_draw_event (SpiceDisplay *display, cairo_t *cr);
-#else
-void spicex_expose_event (SpiceDisplay *display, GdkEventExpose *ev);
-#endif
gboolean spicex_is_scaled (SpiceDisplay *display);
void spice_display_get_scaling (SpiceDisplay *display, double *s, int *x, int *y, int *w, int *h);
gboolean spice_egl_init (SpiceDisplay *display, GError **err);
diff --git a/src/spice-widget-x11.c b/src/spice-widget-x11.c
deleted file mode 100644
index 3f2ce94..0000000
--- a/src/spice-widget-x11.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- Copyright (C) 2010 Red Hat, Inc.
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-#include "config.h"
-
-#include "spice-widget.h"
-#include "spice-widget-priv.h"
-
-#ifdef HAVE_SYS_SHM_H
-#include <sys/shm.h>
-#endif
-
-#ifdef HAVE_SYS_IPC_H
-#include <sys/ipc.h>
-#endif
-
-static bool no_mitshm;
-
-static struct format_table {
- enum SpiceSurfaceFmt spice;
- XVisualInfo xvisual;
-} format_table[] = {
- {
- .spice = SPICE_SURFACE_FMT_32_ARGB, /* FIXME: is that correct xvisual? */
- .xvisual = {
- .depth = 24,
- .red_mask = 0xff0000,
- .green_mask = 0x00ff00,
- .blue_mask = 0x0000ff,
- },
- },{
- .spice = SPICE_SURFACE_FMT_32_xRGB,
- .xvisual = {
- .depth = 24,
- .red_mask = 0xff0000,
- .green_mask = 0x00ff00,
- .blue_mask = 0x0000ff,
- },
- },{
- .spice = SPICE_SURFACE_FMT_16_555,
- .xvisual = {
- .depth = 16,
- .red_mask = 0x7c00,
- .green_mask = 0x03e0,
- .blue_mask = 0x001f,
- },
- },{
- .spice = SPICE_SURFACE_FMT_16_565,
- .xvisual = {
- .depth = 16,
- .red_mask = 0xf800,
- .green_mask = 0x07e0,
- .blue_mask = 0x001f,
- },
- }
-};
-
-static XVisualInfo *get_visual_for_format(GtkWidget *widget, enum SpiceSurfaceFmt format)
-{
- GdkDrawable *drawable = gtk_widget_get_window(widget);
- GdkDisplay *display = gdk_drawable_get_display(drawable);
- GdkScreen *screen = gdk_drawable_get_screen(drawable);
- XVisualInfo template;
- int found, i;
- XVisualInfo *vi;
-
- for (i = 0; i < SPICE_N_ELEMENTS(format_table); i++) {
- if (format == format_table[i].spice)
- break;
- }
- if (i == SPICE_N_ELEMENTS(format_table)) {
- g_warn_if_reached();
- return NULL;
- }
-
- template = format_table[i].xvisual;
- template.screen = gdk_x11_screen_get_screen_number(screen);
- vi = XGetVisualInfo(gdk_x11_display_get_xdisplay(display),
- VisualScreenMask | VisualDepthMask |
- VisualRedMaskMask | VisualGreenMaskMask | VisualBlueMaskMask,
- &template, &found);
- return vi;
-}
-
-static XVisualInfo *get_visual_default(GtkWidget *widget)
-{
- GdkDrawable *drawable = gtk_widget_get_window(widget);
- GdkDisplay *display = gdk_drawable_get_display(drawable);
- GdkScreen *screen = gdk_drawable_get_screen(drawable);
- XVisualInfo template;
- int found;
-
- template.screen = gdk_x11_screen_get_screen_number(screen);
- return XGetVisualInfo(gdk_x11_display_get_xdisplay(display),
- VisualScreenMask,
- &template, &found);
-}
-
-static int catch_no_mitshm(Display * dpy, XErrorEvent * event)
-{
- no_mitshm = true;
- return 0;
-}
-
-G_GNUC_INTERNAL
-int spicex_image_create(SpiceDisplay *display)
-{
- SpiceDisplayPrivate *d = display->priv;
-
- if (d->ximage != NULL)
- return 0;
-
- GdkDrawable *window = gtk_widget_get_window(GTK_WIDGET(display));
- GdkDisplay *gtkdpy = gdk_drawable_get_display(window);
- void *old_handler = NULL;
- XGCValues gcval = {
- .foreground = 0,
- .background = 0,
- };
-
- d->dpy = gdk_x11_display_get_xdisplay(gtkdpy);
- d->convert = false;
- d->vi = get_visual_for_format(GTK_WIDGET(display), d->format);
- if (d->vi == NULL) {
- d->convert = true;
- d->vi = get_visual_default(GTK_WIDGET(display));
- d->vi = get_visual_for_format(GTK_WIDGET(display), SPICE_SURFACE_FMT_32_xRGB);
- g_return_val_if_fail(d->vi != NULL, 1);
- }
- if (d->convert) {
- d->data = g_malloc0(d->height * d->stride); /* pixels are 32 bits */
- }
-
- d->gc = XCreateGC(d->dpy, gdk_x11_drawable_get_xid(window),
- GCForeground | GCBackground, &gcval);
-
- if (d->convert) /* do not use shm when doing color format conversion */
- goto xcreate;
-
- if (d->have_mitshm && d->shmid != -1) {
- if (!XShmQueryExtension(d->dpy)) {
- goto shm_fail;
- }
- no_mitshm = false;
- old_handler = XSetErrorHandler(catch_no_mitshm);
- d->shminfo = g_new0(XShmSegmentInfo, 1);
- d->ximage = XShmCreateImage(d->dpy, d->vi->visual, d->vi->depth,
- ZPixmap, d->data, d->shminfo, d->width, d->height);
- if (d->ximage == NULL)
- goto shm_fail;
- d->shminfo->shmaddr = d->data;
- d->shminfo->shmid = d->shmid;
- d->shminfo->readOnly = false;
- XShmAttach(d->dpy, d->shminfo);
- XSync(d->dpy, False);
- shmctl(d->shmid, IPC_RMID, 0);
- if (no_mitshm)
- goto shm_fail;
- XSetErrorHandler(old_handler);
- return 0;
- }
-
- shm_fail:
- d->have_mitshm = false;
- g_free(d->shminfo);
- d->shminfo = NULL;
- if (old_handler)
- XSetErrorHandler(old_handler);
- xcreate:
- d->ximage = XCreateImage(d->dpy, d->vi->visual, d->vi->depth, ZPixmap, 0,
- d->data, d->width, d->height, 32, d->stride);
- return 0;
-}
-
-G_GNUC_INTERNAL
-void spicex_image_destroy(SpiceDisplay *display)
-{
- SpiceDisplayPrivate *d = display->priv;
-
- if (d->ximage) {
- /* avoid XDestroy to free shared memory, owned and freed by
- channel-display itself */
- if (d->ximage->data == d->data_origin)
- d->ximage->data = NULL;
- XDestroyImage(d->ximage);
- d->ximage = NULL;
- if (d->convert)
- d->data = 0;
- }
- if (d->shminfo) {
- XShmDetach(d->dpy, d->shminfo);
- free(d->shminfo);
- d->shminfo = NULL;
- }
- if (d->gc) {
- XFreeGC(d->dpy, d->gc);
- d->gc = NULL;
- }
- if (d->convert && d->data) {
- g_free(d->data);
- d->data = NULL;
- }
-}
-
-G_GNUC_INTERNAL
-void spicex_expose_event(SpiceDisplay *display, GdkEventExpose *expose)
-{
- GdkDrawable *window = gtk_widget_get_window(GTK_WIDGET(display));
- SpiceDisplayPrivate *d = display->priv;
- int x, y, w, h;
-
- spice_display_get_scaling(display, NULL, &x, &y, &w, &h);
-
- if (expose->area.x >= x &&
- expose->area.y >= y &&
- expose->area.x + expose->area.width <= x + w &&
- expose->area.y + expose->area.height <= y + h) {
- /* area is completely inside the guest screen -- blit it */
- if (d->have_mitshm && d->shminfo) {
- XShmPutImage(d->dpy, gdk_x11_drawable_get_xid(window),
- d->gc, d->ximage,
- d->area.x + expose->area.x - x, d->area.y + expose->area.y - y,
- expose->area.x, expose->area.y,
- expose->area.width, expose->area.height,
- true);
- } else {
- XPutImage(d->dpy, gdk_x11_drawable_get_xid(window),
- d->gc, d->ximage,
- d->area.x + expose->area.x - x, d->area.y + expose->area.y - y,
- expose->area.x, expose->area.y,
- expose->area.width, expose->area.height);
- }
- } else {
- /* complete window update */
- if (d->ww > d->area.width || d->wh > d->area.height) {
- int x1 = x;
- int x2 = x + w;
- int y1 = y;
- int y2 = y + h;
- XFillRectangle(d->dpy, gdk_x11_drawable_get_xid(window),
- d->gc, 0, 0, x1, d->wh);
- XFillRectangle(d->dpy, gdk_x11_drawable_get_xid(window),
- d->gc, x2, 0, d->ww - x2, d->wh);
- XFillRectangle(d->dpy, gdk_x11_drawable_get_xid(window),
- d->gc, 0, 0, d->ww, y1);
- XFillRectangle(d->dpy, gdk_x11_drawable_get_xid(window),
- d->gc, 0, y2, d->ww, d->wh - y2);
- }
- if (d->have_mitshm && d->shminfo) {
- XShmPutImage(d->dpy, gdk_x11_drawable_get_xid(window),
- d->gc, d->ximage,
- d->area.x, d->area.y, x, y, w, h,
- true);
- } else {
- XPutImage(d->dpy, gdk_x11_drawable_get_xid(window),
- d->gc, d->ximage,
- d->area.x, d->area.y, x, y, w, h);
- }
- }
-}
-
-G_GNUC_INTERNAL
-gboolean spicex_is_scaled(SpiceDisplay *display)
-{
- return FALSE; /* backend doesn't support scaling yet */
-}
diff --git a/src/spice-widget.c b/src/spice-widget.c
index ef166cb..3e7a731 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -574,17 +574,12 @@ static void spice_display_init(SpiceDisplay *display)
GDK_LEAVE_NOTIFY_MASK |
GDK_KEY_PRESS_MASK |
GDK_SCROLL_MASK);
-#ifdef WITH_X11
- gtk_widget_set_double_buffered(widget, false);
-#else
gtk_widget_set_double_buffered(widget, true);
-#endif
gtk_widget_set_can_focus(widget, true);
d->grabseq = spice_grab_sequence_new_from_string("Control_L+Alt_L");
d->activeseq = g_new0(gboolean, d->grabseq->nkeysyms);
d->mouse_cursor = get_blank_cursor();
- d->have_mitshm = true;
#ifdef USE_EPOXY
if (!spice_egl_init(display, &err)) {
@@ -1156,7 +1151,6 @@ static void set_egl_enabled(SpiceDisplay *display, bool enabled)
#endif
}
-#if GTK_CHECK_VERSION (2, 91, 0)
static gboolean draw_event(GtkWidget *widget, cairo_t *cr)
{
SpiceDisplay *display = SPICE_DISPLAY(widget);
@@ -1180,24 +1174,6 @@ static gboolean draw_event(GtkWidget *widget, cairo_t *cr)
return true;
}
-#else
-static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose)
-{
- SpiceDisplay *display = SPICE_DISPLAY(widget);
- SpiceDisplayPrivate *d = display->priv;
- g_return_val_if_fail(d != NULL, false);
-
- if (d->mark == 0 || d->data == NULL ||
- d->area.width == 0 || d->area.height == 0)
- return false;
- g_return_val_if_fail(d->ximage != NULL, false);
-
- spicex_expose_event(display, expose);
- update_mouse_pointer(display);
-
- return true;
-}
-#endif
/* ---------------------------------------------------------------- */
typedef enum {
@@ -1855,11 +1831,7 @@ static void spice_display_class_init(SpiceDisplayClass *klass)
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS(klass);
-#if GTK_CHECK_VERSION (2, 91, 0)
gtkwidget_class->draw = draw_event;
-#else
- gtkwidget_class->expose_event = expose_event;
-#endif
gtkwidget_class->key_press_event = key_event;
gtkwidget_class->key_release_event = key_event;
gtkwidget_class->enter_notify_event = enter_event;
@@ -2213,7 +2185,6 @@ static void primary_create(SpiceChannel *channel, gint format,
d->format = format;
d->stride = stride;
- d->shmid = shmid;
d->width = width;
d->height = height;
d->data_origin = d->data = imgdata;
@@ -2230,7 +2201,6 @@ static void primary_destroy(SpiceChannel *channel, gpointer data)
d->width = 0;
d->height = 0;
d->stride = 0;
- d->shmid = 0;
d->data = NULL;
d->data_origin = NULL;
set_monitor_ready(display, false);
diff --git a/vapi/Makefile.am b/vapi/Makefile.am
index c66b1db..aaab848 100644
--- a/vapi/Makefile.am
+++ b/vapi/Makefile.am
@@ -10,12 +10,11 @@ dist_vapi_DATA = \
$(NULL)
if WITH_GTK
-vapi_DATA += spice-client-gtk-$(SPICE_GTK_API_VERSION).vapi
-dist_vapi_DATA += spice-client-gtk-$(SPICE_GTK_API_VERSION).deps
+vapi_DATA += spice-client-gtk-3.0.vapi
+dist_vapi_DATA += spice-client-gtk-3.0.deps
endif
EXTRA_DIST = \
- spice-client-gtk-2.0.deps \
spice-client-gtk-3.0.deps \
SpiceClientGLib-2.0.metadata \
$(NULL)
@@ -29,13 +28,13 @@ spice-client-glib-2.0.vapi: $(top_builddir)/src/SpiceClientGLib-2.0.gir SpiceCli
--pkg gio-2.0 \
$<
-spice-client-gtk-$(SPICE_GTK_API_VERSION).vapi: $(top_builddir)/src/SpiceClientGtk-$(SPICE_GTK_API_VERSION).gir spice-client-glib-2.0.vapi
+spice-client-gtk-3.0.vapi: $(top_builddir)/src/SpiceClientGtk-3.0.gir spice-client-glib-2.0.vapi
$(AM_V_GEN)$(VAPIGEN) -q \
--vapidir=$(builddir) \
--girdir=$(top_builddir)/src \
--pkg spice-client-glib-2.0 \
- --pkg gtk+-$(GTK_API_VERSION) \
- --library spice-client-gtk-$(SPICE_GTK_API_VERSION) \
+ --pkg gtk+-3.0 \
+ --library spice-client-gtk-3.0 \
$<
-include $(top_srcdir)/git.mk
--
2.5.0
More information about the Spice-devel
mailing list