[PATCH] toytoolkit: Recalculate input region if client has modified it's size.

Kristian Høgsberg hoegsberg at gmail.com
Mon May 14 06:58:36 PDT 2012


On Mon, May 14, 2012 at 01:19:34AM -0600, Scott Moreau wrote:
> If a client changes it's width/height values in it's widget resize handler,
> the input region will be wrong because of the assumptions toytoolkit makes
> in frame_resize_handler(). So far, gears is the only client that does this.

Ah, yup, I've seen that now that I think about it.  Can we just move
the code that sets the input region down from the if (!TYPE_FULLSCREEN)
case instead and just always set it after running the child resize handler.

Kristian

> ---
>  clients/window.c |   19 ++++++++++++++++---
>  1 files changed, 16 insertions(+), 3 deletions(-)
> 
> diff --git a/clients/window.c b/clients/window.c
> index e14edb0..0687d65 100644
> --- a/clients/window.c
> +++ b/clients/window.c
> @@ -1163,6 +1163,7 @@ frame_resize_handler(struct widget *widget,
>  	struct frame_button * button;
>  	int x_l, x_r, y, w, h;
>  	int decoration_width, decoration_height;
> +	int child_width, child_height;
>  	int opaque_margin;
>  
>  	if (widget->window->type != TYPE_FULLSCREEN) {
> @@ -1209,9 +1210,21 @@ frame_resize_handler(struct widget *widget,
>  				      allocation.height,
>  				      child->user_data);
>  
> -	widget_set_allocation(widget, 0, 0,
> -			      child->allocation.width + decoration_width,
> -			      child->allocation.height + decoration_height);
> +	child_width = child->allocation.width + decoration_width;
> +	child_height = child->allocation.height + decoration_height;

Just reuse width and height here.  You're computing the new width and
height of the frame widget, not the width and height of the child.

> +	if (child_width != allocation.width || child_height != allocation.height) {
> +		if (widget->window->input_region)
> +			wl_region_destroy(widget->window->input_region);
> +		widget->window->input_region =
> +			wl_compositor_create_region(display->compositor);
> +		wl_region_add(widget->window->input_region,
> +			      frame->margin, frame->margin,
> +			      child_width - 2 * frame->margin,
> +			      child_height - 2 * frame->margin);
> +	}
> +
> +	widget_set_allocation(widget, 0, 0, child_width, child_height);
>  
>  	if (child->opaque) {
>  		widget->window->opaque_region =
> -- 
> 1.7.7.6
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list