[PATCH 2/2 weston] clickdot: Only draw line on click.
Scott Moreau
oreaus at gmail.com
Fri Nov 9 00:11:34 PST 2012
---
clients/clickdot.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/clients/clickdot.c b/clients/clickdot.c
index 7358656..b04db6b 100644
--- a/clients/clickdot.c
+++ b/clients/clickdot.c
@@ -52,7 +52,7 @@ struct clickdot {
int32_t old_x, old_y;
} line;
- int reset;
+ int reset, clicked;
};
static void
@@ -153,7 +153,15 @@ redraw_handler(struct widget *widget, void *data)
cairo_set_source_rgba(cr, 0, 0, 0, 0.8);
cairo_fill(cr);
- draw_line(clickdot, cr, &allocation);
+ if (clickdot->clicked)
+ draw_line(clickdot, cr, &allocation);
+ else if (clickdot->buffer) {
+ cairo_surface_destroy(clickdot->buffer);
+ clickdot->buffer =
+ cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
+ allocation.width,
+ allocation.height);
+ }
window_get_allocation(clickdot->window, &window);
clickdot->dot.x = window.width * clickdot->dot.rw;
@@ -215,6 +223,10 @@ button_handler(struct widget *widget,
input_get_position(input, &clickdot->dot.x, &clickdot->dot.y);
clickdot->dot.rw = (float) clickdot->dot.x / allocation.width;
clickdot->dot.rh = (float) clickdot->dot.y / allocation.height;
+ clickdot->clicked = 1;
+ } else {
+ clickdot->reset = 1;
+ clickdot->clicked = 0;
}
widget_schedule_redraw(widget);
--
1.7.11.7
More information about the wayland-devel
mailing list