summaryrefslogtreecommitdiff
path: root/gtk/spice-widget-cairo.c
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2011-01-14 18:07:15 +0000
committerMarc-André Lureau <marcandre.lureau@redhat.com>2011-01-14 21:13:33 +0100
commit67d5b2e6933447ece9350e851888603e02daf7ce (patch)
tree90d711d633e86e10c837d96f4ffa0306eb246f4e /gtk/spice-widget-cairo.c
parent96f8ca3b4216e83165828eebc9d0252f032786f8 (diff)
Fix rendering with GTK3
In GTK2 world there is an expose_event handler, so a choice of the X11 or cairo backends can be used. In GTK3 world only the draw_event exists, which must use cairo
Diffstat (limited to 'gtk/spice-widget-cairo.c')
-rw-r--r--gtk/spice-widget-cairo.c19
1 files changed, 15 insertions, 4 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,