diff options
Diffstat (limited to 'capplets/display/scrollarea.c')
-rw-r--r-- | capplets/display/scrollarea.c | 81 |
1 files changed, 35 insertions, 46 deletions
diff --git a/capplets/display/scrollarea.c b/capplets/display/scrollarea.c index 5dfd2e7f..711984a4 100644 --- a/capplets/display/scrollarea.c +++ b/capplets/display/scrollarea.c @@ -325,9 +325,14 @@ foo_scroll_area_class_init (FooScrollAreaClass *class) paint), NULL, NULL, foo_marshal_VOID__POINTER_BOXED_POINTER, - G_TYPE_NONE, 3, + G_TYPE_NONE, +#if GTK_CHECK_VERSION (3, 0, 0) + 1, +#else + 3, G_TYPE_POINTER, GDK_TYPE_RECTANGLE, +#endif G_TYPE_POINTER); #if !GTK_CHECK_VERSION (3, 0, 0) @@ -598,38 +603,18 @@ clip_to_region (cairo_t *cr, GdkRegion *region) } #endif -#if !GTK_CHECK_VERSION (3, 0, 0) -static void -simple_draw_drawable (GdkDrawable *dst, - GdkDrawable *src, - int src_x, - int src_y, - int dst_x, - int dst_y, - int width, - int height) -{ - GdkGC *gc = gdk_gc_new (dst); - - gdk_draw_drawable (dst, gc, src, src_x, src_y, dst_x, dst_y, width, height); - - g_object_unref (gc); -} -#endif - static gboolean #if GTK_CHECK_VERSION (3, 0, 0) foo_scroll_area_draw (GtkWidget *widget, - cairo_t *cr) + cairo_t *widget_cr) #else foo_scroll_area_expose (GtkWidget *widget, GdkEventExpose *expose) #endif { FooScrollArea *scroll_area = FOO_SCROLL_AREA (widget); -#if !GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr; - GdkGC *gc; +#if !GTK_CHECK_VERSION (3, 0, 0) GdkRectangle extents; GdkWindow *window = gtk_widget_get_window (widget); #endif @@ -661,7 +646,7 @@ foo_scroll_area_expose (GtkWidget *widget, /* Setup input areas */ clear_exposed_input_region (scroll_area, scroll_area->priv->update_region); - + scroll_area->priv->current_input = g_new0 (InputRegion, 1); scroll_area->priv->current_input->region = gdk_region_copy (scroll_area->priv->update_region); scroll_area->priv->current_input->paths = NULL; @@ -676,6 +661,8 @@ foo_scroll_area_expose (GtkWidget *widget, cr = gdk_cairo_create (scroll_area->priv->pixmap); translate_cairo_device (cr, -x_offset, -y_offset); clip_to_region (cr, region); +#else + cr = cairo_create (scroll_area->priv->surface); #endif initialize_background (widget, cr); @@ -690,10 +677,8 @@ foo_scroll_area_expose (GtkWidget *widget, g_signal_emit (widget, signals[PAINT], 0, cr, &extents, region); #endif -#if !GTK_CHECK_VERSION (3, 0, 0) /* Destroy stuff */ cairo_destroy (cr); -#endif #if !GTK_CHECK_VERSION (3, 0, 0) scroll_area->priv->expose_region = NULL; @@ -702,19 +687,17 @@ foo_scroll_area_expose (GtkWidget *widget, /* Finally draw the backing pixmap */ #if GTK_CHECK_VERSION (3, 0, 0) - cairo_set_source_surface (cr, scroll_area->priv->surface, widget_allocation.x, widget_allocation.y); - cairo_paint (cr); + cairo_set_source_surface (widget_cr, scroll_area->priv->surface, widget_allocation.x, widget_allocation.y); + cairo_paint (widget_cr); #else - gc = gdk_gc_new (window); - - gdk_gc_set_clip_region (gc, expose->region); - gtk_widget_get_allocation (widget, &widget_allocation); - gdk_draw_drawable (window, gc, scroll_area->priv->pixmap, - 0, 0, widget_allocation.x, widget_allocation.y, - widget_allocation.width, widget_allocation.height); - g_object_unref (gc); + cr = gdk_cairo_create (window); + gdk_cairo_set_source_pixmap (cr, scroll_area->priv->pixmap, + widget_allocation.x, widget_allocation.y); + gdk_cairo_region (cr, expose->region); + cairo_fill (cr); + cairo_destroy (cr); #endif gdk_region_destroy (region); @@ -889,6 +872,7 @@ create_new_pixmap (GtkWidget *widget, cairo_surface_t *new; #else GdkPixmap *new; + cairo_t *cr; #endif gtk_widget_get_allocation (widget, &widget_allocation); @@ -913,15 +897,17 @@ create_new_pixmap (GtkWidget *widget, * That might just work, actually. We need to make sure marco uses * static gravity for the window before this will be useful. */ + #if GTK_CHECK_VERSION (3, 0, 0) cr = cairo_create (new); cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_surface (cr, old, 0, 0); - cairo_paint (cr); - cairo_destroy (cr); #else - simple_draw_drawable (new, old, 0, 0, 0, 0, -1, -1); + cr = gdk_cairo_create (new); + gdk_cairo_set_source_pixmap (cr, old, 0, 0); #endif + cairo_paint (cr); + cairo_destroy (cr); return new; } @@ -1259,9 +1245,13 @@ foo_scroll_area_scroll (FooScrollArea *area, if (gdk_rectangle_intersect (&allocation, &src_area, &move_area)) { GdkRegion *move_region; + cairo_t *cr; #if GTK_CHECK_VERSION (3, 0, 0) - cairo_t *cr = cairo_create (area->priv->surface); + cr = cairo_create (area->priv->surface); +#else + cr = gdk_cairo_create (area->priv->pixmap); +#endif /* Cairo doesn't allow self-copies, so we do this little trick instead: * 1) Clip so the group size is small. @@ -1271,7 +1261,11 @@ foo_scroll_area_scroll (FooScrollArea *area, cairo_clip (cr); cairo_push_group (cr); +#if GTK_CHECK_VERSION (3, 0, 0) cairo_set_source_surface (cr, area->priv->surface, dx, dy); +#else + gdk_cairo_set_source_pixmap (cr, area->priv->pixmap, dx, dy); +#endif gdk_cairo_rectangle (cr, &move_area); cairo_fill (cr); @@ -1279,12 +1273,7 @@ foo_scroll_area_scroll (FooScrollArea *area, cairo_paint (cr); cairo_destroy (cr); -#else - simple_draw_drawable (area->priv->pixmap, area->priv->pixmap, - move_area.x, move_area.y, - move_area.x + dx, move_area.y + dy, - move_area.width, move_area.height); -#endif + gtk_widget_queue_draw (GTK_WIDGET (area)); move_region = gdk_region_rectangle (&move_area); |