diff options
author | Benjamin Otte <otte@redhat.com> | 2010-07-15 18:37:08 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2010-07-26 16:42:48 +0200 |
commit | 0a451f508b6c6256a57ab79db5791bf140593f4a (patch) | |
tree | 69a29fbfc50988c5f317ad84e0a9ec045e975a44 /tests/testinput.c | |
parent | 6dd7e5af083577e0b138a3e2f9fe3738a717f50c (diff) | |
download | gtk+-0a451f508b6c6256a57ab79db5791bf140593f4a.tar.gz |
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.
Diffstat (limited to 'tests/testinput.c')
-rw-r--r-- | tests/testinput.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/tests/testinput.c b/tests/testinput.c index 5a81b8eb26..16ad3ee7e6 100644 --- a/tests/testinput.c +++ b/tests/testinput.c @@ -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); |