[PATCH weston] shell: the move, resize, rotate bindings work on the parent of popups

Kristian Høgsberg hoegsberg at gmail.com
Wed Apr 3 11:41:09 PDT 2013


On Wed, Apr 03, 2013 at 05:20:41PM +0200, Giulio Camuffo wrote:
> this makes the move, resize and rotate bindings check whenever the
> focus surface is a popup, and if it is it will walk the surface
> hierarchy unitil it finds a non-popup one, and will apply the
> effect on that
> ---
>  src/shell.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)

Just to sum up our IRC discussion: the behavior that this patch
implements is a little surprising.  Open a menu on the right edge of a
window and move to the right side of the menu.  Then press mod-click
to move the window.  The menu disappears and you're now moving the
window with the cursor 200px to the right of the window.

Instead I think we can just reject the move in move_binding() (resize
and rotate too).  If we just reject the action, like we do for
fullscreen and maximized windows now, the button press and release
will get passed through to the popup.  That's similar to what happens
under X, since the client has the pointer and kb grabbed and the wm
doesn't have a say in this.  Under wayland we have the option to
swallow the press-release by installing a pointer grab that just
throws away events and then terminates when all buttons are released.

The stale cursor problem we talked about was caused by the missing
destroy_listener for wl_pointer.current, and is fixed by Rob Bradfords
patch.

Kristian

> diff --git a/src/shell.c b/src/shell.c
> index de5d6f6..eaa2123 100644
> --- a/src/shell.c
> +++ b/src/shell.c
> @@ -2505,6 +2505,21 @@ get_shell_surface_type(struct weston_surface *surface)
>  	return shsurf->type;
>  }
>  
> +static struct shell_surface *
> +get_top_level_parent(struct shell_surface *shsurf)
> +{
> +	while (!wl_list_empty(&shsurf->popup.grab_link)) {
> +		if (shsurf->parent)
> +			shsurf = get_shell_surface(shsurf->parent);
> +		else
> +			return NULL;
> +
> +		if (shsurf == NULL)
> +			return NULL;
> +	}
> +	return shsurf;
> +}
> +
>  static void
>  move_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
>  {
> @@ -2520,6 +2535,10 @@ move_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
>  	    shsurf->type == SHELL_SURFACE_MAXIMIZED)
>  		return;
>  
> +	shsurf = get_top_level_parent(shsurf);
> +	if (shsurf == NULL)
> +		return;
> +
>  	surface_move(shsurf, (struct weston_seat *) seat);
>  }
>  
> @@ -2540,6 +2559,10 @@ resize_binding(struct wl_seat *seat, uint32_t time, uint32_t button, void *data)
>  	    shsurf->type == SHELL_SURFACE_MAXIMIZED)
>  		return;
>  
> +	shsurf = get_top_level_parent(shsurf);
> +	if (shsurf == NULL)
> +		return;
> +
>  	weston_surface_from_global(surface,
>  				   wl_fixed_to_int(seat->pointer->grab_x),
>  				   wl_fixed_to_int(seat->pointer->grab_y),
> @@ -2800,6 +2823,10 @@ rotate_binding(struct wl_seat *seat, uint32_t time, uint32_t button,
>  	    surface->type == SHELL_SURFACE_MAXIMIZED)
>  		return;
>  
> +	surface = get_top_level_parent(surface);
> +	if (surface == NULL)
> +		return;
> +
>  	surface_rotate(surface, seat);
>  }
>  
> -- 
> 1.8.2
> 
> _______________________________________________
> 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