[PATCH weston 3/3] shell: constrain resize grabs so titlebars don't go under the panel

Boyan Ding stu_dby at 126.com
Wed Aug 20 03:31:50 PDT 2014


Well, there's been quite a few patches seeking to solve this problem.
I'm okay with any of these. Actually the ability of rotating windows in
weston makes resizing window out of screen quite easily regardless of
how you constrain pointer position but resizing it easily under the
panel is really annoying.

Cheers,
Boyan Ding

On Wed, 2014-08-20 at 10:37 +0200, Jonny Lamb wrote:
> https://bugs.freedesktop.org/show_bug.cgi?id=80228
> ---
>  desktop-shell/shell.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
> index 9cb81d5..b9d5f39 100644
> --- a/desktop-shell/shell.c
> +++ b/desktop-shell/shell.c
> @@ -1758,6 +1758,30 @@ struct weston_resize_grab {
>  };
>  
>  static void
> +constrain_resize_grab(struct weston_pointer_grab *grab,
> +		      int32_t *width, int32_t *height)
> +{
> +	struct weston_resize_grab *resize = (struct weston_resize_grab *) grab;
> +	struct shell_surface *shsurf = resize->base.shsurf;
> +
> +	int32_t height_difference;
> +
> +	height_difference = *height - shsurf->geometry.height;
> +
> +	/* we're only trying to make sure titlebars don't go under the panel */
> +	if (shsurf->shell->panel_position == DESKTOP_SHELL_PANEL_POSITION_TOP &&
> +	    resize->edges & WL_SHELL_SURFACE_RESIZE_TOP &&
> +	    height_difference > 0) {
> +		int32_t top;
> +
> +		top = shsurf->view->geometry.y - height_difference;
> +
> +		if (top < 0)
> +			*height = shsurf->geometry.height;
> +	}
> +}
> +
> +static void
>  resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
>  		   wl_fixed_t x, wl_fixed_t y)
>  {
> @@ -1793,6 +1817,8 @@ resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time,
>  		height += wl_fixed_to_int(to_y - from_y);
>  	}
>  
> +	constrain_resize_grab(grab, &width, &height);
> +
>  	shsurf->client->send_configure(shsurf->surface, width, height);
>  }
>  





More information about the wayland-devel mailing list