diff options
-rw-r--r-- | src/themes/standard/theme.c | 80 |
1 files changed, 41 insertions, 39 deletions
diff --git a/src/themes/standard/theme.c b/src/themes/standard/theme.c index cc80a81..a61a0d9 100644 --- a/src/themes/standard/theme.c +++ b/src/themes/standard/theme.c @@ -480,11 +480,11 @@ static gboolean paint_window(GtkWidget* widget, cairo_t* cr, WindowData* windata static gboolean paint_window(GtkWidget* widget, GdkEventExpose* event, WindowData* windata) #endif { - cairo_t* context; + cairo_t* cr2; cairo_surface_t* surface; GtkAllocation allocation; #if !GTK_CHECK_VERSION(3, 0, 0) - cairo_t* cr; + cairo_t* cr = gdk_cairo_create (event->window); #endif gtk_widget_get_allocation(windata->win, &allocation); @@ -495,32 +495,30 @@ static gboolean paint_window(GtkWidget* widget, GdkEventExpose* event, WindowDat windata->height = allocation.height; } - context = gdk_cairo_create(gtk_widget_get_window(widget)); - - cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); gtk_widget_get_allocation(widget, &allocation); - surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height); + surface = cairo_surface_create_similar (cairo_get_target (cr), + CAIRO_CONTENT_COLOR_ALPHA, + allocation.width, + allocation.height); -#if GTK_CHECK_VERSION (3, 0, 0) - cairo_set_source_surface(cr, surface, 0, 0); -#else - cr = cairo_create(surface); -#endif + cr2 = cairo_create (surface); - fill_background(widget, windata, cr); - draw_border(widget, windata, cr); - draw_stripe(widget, windata, cr); + fill_background(widget, windata, cr2); + draw_border(widget, windata, cr2); + draw_stripe(widget, windata, cr2); + cairo_fill (cr2); + cairo_destroy (cr2); + + cairo_set_source_surface (cr, surface, 0, 0); + cairo_paint(cr); + cairo_surface_destroy(surface); #if !GTK_CHECK_VERSION (3, 0, 0) cairo_destroy(cr); #endif - cairo_set_source_surface(context, surface, 0, 0); - cairo_paint(context); - cairo_surface_destroy(surface); - cairo_destroy(context); - return FALSE; } @@ -939,45 +937,49 @@ static gboolean countdown_expose_cb(GtkWidget* pie, GdkEventExpose* event, Windo #endif { GtkStyle* style; - cairo_t* context; + cairo_t* cr2; cairo_surface_t* surface; #if !GTK_CHECK_VERSION(3, 0, 0) - cairo_t* cr; + cairo_t* cr = gdk_cairo_create (event->window); #endif style = gtk_widget_get_style(windata->win); - context = gdk_cairo_create(GDK_WINDOW(gtk_widget_get_window(windata->pie_countdown))); GtkAllocation alloc; gtk_widget_get_allocation(pie, &alloc); - cairo_set_operator(context, CAIRO_OPERATOR_SOURCE); - surface = cairo_surface_create_similar(cairo_get_target(context), CAIRO_CONTENT_COLOR_ALPHA, alloc.width, alloc.height); -#if GTK_CHECK_VERSION(3, 0, 0) - cairo_set_source_surface(cr, surface, 0, 0); -#else - cr = cairo_create(surface); -#endif + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + surface = cairo_surface_create_similar (cairo_get_target(cr), + CAIRO_CONTENT_COLOR_ALPHA, + alloc.width, + alloc.height); + + cr2 = cairo_create (surface); - fill_background(pie, windata, cr); + fill_background (pie, windata, cr2); if (windata->timeout > 0) { gdouble pct = (gdouble) windata->remaining / (gdouble) windata->timeout; - gdk_cairo_set_source_color(cr, &style->bg[GTK_STATE_ACTIVE]); + gdk_cairo_set_source_color (cr2, &style->bg[GTK_STATE_ACTIVE]); - cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS); - cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS, -G_PI_2, -(pct * G_PI * 2) - G_PI_2); - cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS); - cairo_fill(cr); + cairo_move_to (cr2, PIE_RADIUS, PIE_RADIUS); + cairo_arc_negative (cr2, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS, -G_PI_2, -(pct * G_PI * 2) - G_PI_2); + cairo_line_to (cr2, PIE_RADIUS, PIE_RADIUS); + cairo_fill (cr2); } + cairo_destroy(cr2); + + cairo_save (cr); + cairo_set_source_surface (cr, surface, 0, 0); + cairo_paint (cr); + cairo_restore (cr); + + cairo_surface_destroy(surface); + #if !GTK_CHECK_VERSION (3, 0, 0) cairo_destroy(cr); #endif - cairo_set_source_surface(context, surface, 0, 0); - cairo_paint(context); - cairo_surface_destroy(surface); - cairo_destroy(context); return TRUE; } |