[PATCH 2/2 weston] clickdot: Only draw line on click.

Pekka Paalanen ppaalanen at gmail.com
Fri Nov 9 00:37:27 PST 2012


On Fri,  9 Nov 2012 01:11:34 -0700
Scott Moreau <oreaus at gmail.com> wrote:

> ---
>  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);

Hi Scott,

I'd like to NAK this particular patch. It is nice to have a demo
client, that reacts to pointer events by drawing even without the
keyboard focus. If you require a mouse button to be held down, weston
assings keyboard focus, and even raises the window. Raising the window
makes testing input regions harder, since one cannot use a partially
overlapping surface to observe how input is clipped. Also I think having
a button pressed causes the client to have a grab on it, so the pointer
cannot leave the surface while drawing.


Thanks,
pq


More information about the wayland-devel mailing list