summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2015-12-16 17:36:02 +0100
committerMarc-André Lureau <marcandre.lureau@gmail.com>2016-03-14 12:02:52 +0100
commit0917002c48a0a5deb615d120a0e5997eefc89fd4 (patch)
tree13d4b13beb33872badb9b02cb5f99fbac9ac45c5 /src
parent693cef4eaa3d761c7d719dcbeae0df572fb26966 (diff)
Drop GTK+ 2.0
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@gmail.com> Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am73
-rw-r--r--src/channel-display-priv.h1
-rw-r--r--src/channel-display.c41
-rw-r--r--src/gtk-compat.h24
-rw-r--r--src/spice-widget-cairo.c20
-rw-r--r--src/spice-widget-priv.h20
-rw-r--r--src/spice-widget-x11.c280
-rw-r--r--src/spice-widget.c30
8 files changed, 7 insertions, 482 deletions
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);