[RFC] Drag and drop icons

Kristian Høgsberg krh at bitplanet.net
Fri Feb 10 11:35:59 PST 2012


On Fri, Feb 10, 2012 at 11:31 AM, Ander Conselvan de Oliveira
<ander.conselvan.de.oliveira at intel.com> wrote:
> Hi,
>
> I have cooked up these patches for implementing the display of a
> drag'n'drop surface. I think there are a lot of issues with them (see
> below) and getting some feedback now would be good.

I attached a patch with what the protocol could be like.  The key
difference from what you've done is that we let the user create the
surface and pass it in in the start_drag request.  This way we avoid
all the code to wrap surface requests in wayland-server and we leave
it to the user to destroy the surface again.  When the drag ends, just
set the drag_surface to NULL.  On the client side you would do:

  icon = wl_compositor_create_surface(compositor);
  /* render icon */
  wl_data_device_start_drag(data_device, source, origin, icon, time);

render to the surface as needed during the dnd and then destroy the
surface once the dnd is over.

There should be very little code in wayland-server.so.

Kristian

> This is implemented by adding data_device.set_surface request that
> creates a surface that follows the cursor when it moves, keeping the
> distance of the top-left corner of the surface to the cursor hotspot
> unchanged. The name set_surface is misleading, and I don't know what
> name the similar request for cursor surfaces will have. But I guess we
> should be consistent here. This request receives two parameters, x and
> y, that defines the initial distance between the surface and the cursor
> hotspot.
>
> One thing that is not clear is what is the behavior if a client calls
> this request twice for the same grab. What happens if attach is
> alternated between the two returned surfaces?
>
> I was also wondering if we should add a drag icon surface type to
> shell. The use case I'm thinking is in a touch screen scenario, where
> we might want to display the icon above the user's finger. So maybe
> we should define (x,y) as a hotspot instead of a delta from the cursor
> hotspot and have the shell define what it means. This would also solve
> the problem of mapping the drag surface under the shell panels.
>
> Since data_device is implemented in libwayland-server, moving the icon
> surface to the right position was a little tricky. When set_surface is
> called, it stores the delta on the wl_input_device. On the compositor
> side, whenever the surface's position needs to be udpated, this delta
> will be checked and used if necessary. The problem is that when the
> drag starts, the first attach will happen before any mouse movement,
> so it was necessary to check it also in output_repaint().
>
> libwayland-server will also force an attach with a null buffer when the
> drag ends. This may causes flicker in the dnd demo.
>
>
> Wayland changes:
>
> Ander Conselvan de Oliveira (1):
>  data_device: use a regular surface for drag icons
>
>  protocol/wayland.xml |   18 +++++--
>  src/data-device.c    |  142 +++++++++++++++++++++++++++++++++++++++++++++++---
>  src/wayland-server.h |    5 ++
>  3 files changed, 152 insertions(+), 13 deletions(-)
>
>
> Weston changes:
>
> Ander Conselvan de Oliveira (4):
>  shell: don't crash on get_shell_surface with non-client surfaces
>  compositor: fix two crashs on surface_attach() with null buffer
>  compositor: implement new data_device.set_surface protocol
>  clients/dnd: use new data_device.set_surface protocol
>
>  clients/dnd.c    |   15 ++++++++++--
>  src/compositor.c |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/compositor.h |    1 +
>  src/shell.c      |    3 ++
>  4 files changed, 80 insertions(+), 3 deletions(-)
>
> --
> 1.7.4.1
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dnd-attach.patch
Type: text/x-patch
Size: 1621 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20120210/cf82a30b/attachment-0001.bin>


More information about the wayland-devel mailing list