diff options
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/spice-widget-cairo.c | 19 | ||||
-rw-r--r-- | gtk/spice-widget-priv.h | 6 | ||||
-rw-r--r-- | gtk/spice-widget.c | 24 |
3 files changed, 44 insertions, 5 deletions
diff --git a/gtk/spice-widget-cairo.c b/gtk/spice-widget-cairo.c index dfbd570..8744f8c 100644 --- a/gtk/spice-widget-cairo.c +++ b/gtk/spice-widget-cairo.c @@ -22,6 +22,16 @@ #include "config.h" #endif +/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */ +#if GTK_CHECK_VERSION (2, 91, 0) + +static inline void gdk_drawable_get_size(GdkWindow *w, gint *ww, gint *wh) +{ + *ww = gdk_window_get_width(w); + *wh = gdk_window_get_height(w); +} +#endif + G_GNUC_INTERNAL int spicex_image_create(SpiceDisplay *display) { @@ -84,7 +94,8 @@ static void setup_surface_cache(spice_display *d, cairo_t *crWin) cairo_destroy(crCache); } -static gboolean draw_event(SpiceDisplay *display, cairo_t *cr) +G_GNUC_INTERNAL +void spicex_draw_event(SpiceDisplay *display, cairo_t *cr) { spice_display *d = SPICE_DISPLAY_GET_PRIVATE(display); int fbw = d->width, fbh = d->height; @@ -132,14 +143,13 @@ static gboolean draw_event(SpiceDisplay *display, cairo_t *cr) } cairo_paint(cr); } - return TRUE; } +#if ! GTK_CHECK_VERSION (2, 91, 0) G_GNUC_INTERNAL void spicex_expose_event(SpiceDisplay *display, GdkEventExpose *expose) { cairo_t *cr; - gboolean ret; cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(display))); cairo_rectangle(cr, @@ -149,10 +159,11 @@ void spicex_expose_event(SpiceDisplay *display, GdkEventExpose *expose) expose->area.height); cairo_clip(cr); - ret = draw_event(display, cr); + spicex_draw_event(display, cr); cairo_destroy(cr); } +#endif G_GNUC_INTERNAL void spicex_image_invalidate(SpiceDisplay *display, diff --git a/gtk/spice-widget-priv.h b/gtk/spice-widget-priv.h index c4ba385..e90603a 100644 --- a/gtk/spice-widget-priv.h +++ b/gtk/spice-widget-priv.h @@ -109,7 +109,11 @@ struct spice_display { int spicex_image_create (SpiceDisplay *display); void spicex_image_destroy (SpiceDisplay *display); void spicex_image_invalidate (SpiceDisplay *display, gint *x, gint *y, gint *w, gint *h); -void spicex_expose_event (SpiceDisplay *display, GdkEventExpose *expose); +#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); G_END_DECLS diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c index cffcac4..448ecf8 100644 --- a/gtk/spice-widget.c +++ b/gtk/spice-widget.c @@ -566,6 +566,25 @@ static gboolean do_color_convert(SpiceDisplay *display, return true; } + +#if GTK_CHECK_VERSION (2, 91, 0) +static gboolean draw_event(GtkWidget *widget, cairo_t *cr) +{ + SpiceDisplay *display = SPICE_DISPLAY(widget); + spice_display *d = SPICE_DISPLAY_GET_PRIVATE(display); + + if (d->mark == 0 || d->data == NULL) + return false; + + if (!d->ximage) { + spicex_image_create(display); + } + + spicex_draw_event(display, cr); + + return true; +} +#else static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose) { SpiceDisplay *display = SPICE_DISPLAY(widget); @@ -587,6 +606,7 @@ static gboolean expose_event(GtkWidget *widget, GdkEventExpose *expose) spicex_expose_event(display, expose); return true; } +#endif /* ---------------------------------------------------------------- */ @@ -1058,7 +1078,11 @@ static void spice_display_class_init(SpiceDisplayClass *klass) GtkObjectClass *gtkobject_class = GTK_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; |