test: Convert testinput to Cairo

The test is broken though as it draws onto windows outside of expose
events.
And we all know you shouldn't do that.
This commit is contained in:
Benjamin Otte 2010-07-15 18:37:08 +02:00
parent 6dd7e5af08
commit 0a451f508b

View File

@ -52,16 +52,14 @@ update_cursor (GtkWidget *widget, gdouble x, gdouble y)
if (pixmap != NULL)
{
cairo_t *cr = gdk_cairo_create (widget->window);
if (cursor_present && (cursor_present != state ||
x != cursor_x || y != cursor_y))
{
cairo_t *cr = gdk_cairo_create (widget->window);
gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0);
cairo_rectangle (cr, cursor_x - 5, cursor_y - 5, 10, 10);
cairo_fill (cr);
cairo_destroy (cr);
}
cursor_present = state;
@ -70,12 +68,14 @@ update_cursor (GtkWidget *widget, gdouble x, gdouble y)
if (cursor_present)
{
gdk_draw_rectangle (widget->window,
widget->style->black_gc,
TRUE,
cursor_x - 5, cursor_y -5,
10, 10);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr,
cursor_x - 5, cursor_y -5,
10, 10);
cairo_fill (cr);
}
cairo_destroy (cr);
}
}
@ -122,31 +122,36 @@ static void
draw_brush (GtkWidget *widget, GdkInputSource source,
gdouble x, gdouble y, gdouble pressure)
{
GdkGC *gc;
GdkColor color;
GdkRectangle update_rect;
cairo_t *cr;
switch (source)
{
case GDK_SOURCE_MOUSE:
gc = widget->style->dark_gc[gtk_widget_get_state (widget)];
color = widget->style->dark[gtk_widget_get_state (widget)];
break;
case GDK_SOURCE_PEN:
gc = widget->style->black_gc;
color.red = color.green = color.blue = 0;
break;
case GDK_SOURCE_ERASER:
gc = widget->style->white_gc;
color.red = color.green = color.blue = 65535;
break;
default:
gc = widget->style->light_gc[gtk_widget_get_state (widget)];
color = widget->style->light[gtk_widget_get_state (widget)];
}
update_rect.x = x - 10 * pressure;
update_rect.y = y - 10 * pressure;
update_rect.width = 20 * pressure;
update_rect.height = 20 * pressure;
gdk_draw_rectangle (pixmap, gc, TRUE,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);
cr = gdk_cairo_create (pixmap);
gdk_cairo_set_source_color (cr, &color);
gdk_cairo_rectangle (cr, &update_rect);
cairo_fill (cr);
cairo_destroy (cr);
gtk_widget_queue_draw_area (widget,
update_rect.x, update_rect.y,
update_rect.width, update_rect.height);