Re: Inter-client surface embedding

2014-02-18 Thread Mark Thomas

On Tue, 18 Feb 2014, Bill Spitzak wrote:


On 02/18/2014 11:09 AM, Mark Thomas wrote:


The hole and plug are meaningful objects and are needed, at least
server-side, for some associated state.  They're also helpful for
limiting the amount of uid-dipping a client can do, as only holes and
plugs have uids.


I proposed that the uid be an encrypted number so clients can't guess them 
(or dipping as you call it). Basically if the server is asked for the 
object for a given uid it fails if it is not a number recently delivered by 
it to another client.


I've essentially done that, although the uid is more of a nonce.  Even a 
random number can be guessed or snooped.


Otherwise you are going to have to create a hole and 
plug object for every single Wayland object.


Only the ones you want to embed.  It's a rare occurrence.  Plus creating 
objects is easy because the wayland protocol is very lightweight.



Also you can't create a subsurface without both
surfaces available, so there is a chicken-and-egg issue, too.


I don't understand this. Obviously when the subsurface is created there is 
only one surface available (the parent) because the subsurface is not created 
yet. That is why I have A create the subsurface. B is still in charge of the 
buffers so there seems to be no problem here.


I suggest you read up on the subsurface protocol.  A subsurface object 
takes two surface arguments, one is the parent to attach to, and the 
other is the child surface that becomes the subsurface.



Having thought about it, I think I'm in agreement with Pekka and the
others that a generic interface is probably not appropriate, as the
requirements change depending on the use case.  What's probably more
useful is making it easy for shell plugins to do it the way they want.
So that's my plan.


I don't like the idea that we are saying that things like Firefox have to be 
shell plugins.


I think things like firefox are potentially better served by passing 
through the buffers from the plugin, rather than the plugin connecting to 
wayland itself -- a parent-child relationship rather than a sibling one. 
That way it gets to do things to the buffer synchronously as it passes 
through (like crop or scale it)*.  I think this is what is meant by the 
subcompositor model.


It sounds like it could work, though I expect there would be lots of edge 
cases to work through.


Until someone actually tries it, though, this is all just hot air.


* - I had an idea for smooth, synchronized resizing and scrolling, where 
the outer client requests the inner client provide it a buffer with an 
extra amount of rendered data around the outside of the subwindow that it 
is providing.  The outer window crops this buffer to the correct 
dimensions (by asking the compositor to do so) and also draws the border 
of the subwindow and its scroll bars.  Then the outer client can scroll 
and resize synchronously by repainting the existing buffer it has with a 
differenct crop region, whilst asynchronously requesting a new buffer from 
the inner client with the new geometry.  I think this would work pretty 
well for the document viewer class of use case.  Just an idea, though. 
I don't plan to do anything with it.


--
Mark.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Inter-client surface embedding

2014-02-16 Thread Mark Thomas


As part of my current attempts to get MATE fully working on Wayland, I was 
planning to take a look at porting mate-panel this weekend.  However, I 
pretty quickly hit the first snag, which is that Gtk on Wayland doesn't 
support the GtkSocket/GtkPlug interface, which mate-panel relies heavily 
upon.


This is because Wayland doesn't understand the idea of linking different 
clients' surfaces together, so I've had a first pass at implementing an 
interface that lets you do that.


My changes are available in github at

https://github.com/markbt/weston/tree/embed

I'd be interested to hear what people think.

I've got it working with a couple of toy clients, so I think the theory is 
sound, but there are a few niggles to work through.


What works:

  - Clients can create one or more hole objects on a surface.  This 
gives them a uid (32-bit number) which they can pass to other clients of 
the same wayland server (e.g. via a socket, D-Bus, etc.).  For the toy 
apps you do this manually.


  - Other clients with the uid in hand can create a plug that attaches 
to that hole.  This effectively creates a subsurface of the other client's 
surface.  (In fact, internally a plug is a weston_subsurface with a couple 
of extra fields in use).


  - The hole can have a position and size set.  The size is notified 
to the plug client who is expected to conform to it.  Currently there's 
no policing of this, but I expect a more robust implementation would want 
to.


  - Either side can tear down the connection between the two.  If the 
hole goes away, or the hole's client calls remove on the hole, then the 
plug client receives a removed event.



What needs some work:

  - The subsurface has to be unsynchronized, otherwise the plug client's 
updates don't render unless the hole client is also updating.  Not sure 
how this will work with nested subsurfaces if synchronization is 
inherited.


  - The subsurface has separate focus from the main window surface.  For 
the usual use cases of embedding like this, you'd prefer the parent 
surface to remain focused (or at least, appear focused) while the embedded 
surface is being interacted with.   Not sure if this is a general feature 
of subsurfaces, nor what could be done about it.


  - The toy examples are quite rapidly thrown together and so aren't 
particularly good.  Improvements gladly welcomed.


  - The interfaces are incomplete (and undocumented, sorry).

  - There's probably a bunch of other things I've not thought about.

--
Mark.
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel