<p dir="ltr">Yeah, Pekka pretty much covered it. I've just got one more observation to add. Are you doing one process per tab? Or do you have one process handling multiple tabs? If you have one process per tab, then you can easily differentiate by which wl_client the surface is attached to. You can know which client is which because (I assume) you should be launching them privately and manually creating the wl_client objects.</p>
<p dir="ltr">Thanks,<br>
--Jason Ekstrand</p>
<div class="gmail_quote">On Jan 30, 2014 5:35 AM, "Pekka Paalanen" <<a href="mailto:ppaalanen@gmail.com">ppaalanen@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, 30 Jan 2014 10:32:03 +0100<br>
Iago Toral <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> in the process of porting webkitgtk+ to wayland and following advise<br>
> provided here, I implemented a nested compositor to share surfaces<br>
> between the two processes that do the rendering. This works fine with<br>
> a single widget/surface, but things get a bit more complicated when<br>
> dealing with various widgets (browser tabs, windows).<br>
><br>
> I am trying to understand if I can solve my problem, which is<br>
> basically a problem of matching wayland surfaces created in the<br>
> nested compositor with their corresponding widgets in the UI, within<br>
> the scope of the wayland protocol or if I need to resort to ad-hoc<br>
> communications between the two processes outside the protocol. Below<br>
> I describe the problem in more detail together with the possible<br>
> solutions I looked into and my conclusions. I'd appreciate a lot if<br>
> someone could confirm whether these are correct:<br>
><br>
> As far as I understand the code in the nested client example from<br>
> Weston, when there is need to repaint the UI it goes through all the<br>
> surfaces in the compositor and paints them one by one. In our case,<br>
> when GTK needs to repaint it will go through the widgets in the UI<br>
> and ask them to repaint as needed. This means that we need to know,<br>
> for a given widget, which is the surface in the nested compositor<br>
> that provides the contents for it.<br>
><br>
> However, when the nested compositor receives a request to create a<br>
> surface it will not know for which widget it is creating it (obviously<br>
> information on things like UI widgets is outside the scope of the<br>
> wayland protocol), and as far as I can see, there is no way for the<br>
> client to provide this info to the compositor either when the surface<br>
> is created or after it has been created.<br>
><br>
> Assuming that this is not something I can so using available APIs, I<br>
> looked into adding this API to my nested compositor implementation,<br>
> so I can have a surface constructor like this:<br>
><br>
> wl_compositor_create_surface_for_widget(struct wl_compositor*, int);<br>
><br>
> where that additional 'int' parameter would be used on the<br>
> compositor's side to associate the new surface with a specific UI<br>
> widget.<br>
><br>
> Unfortunately, for this I would really want to reuse existing code and<br>
> APIs from wayland to do message communication between client and<br>
> compositor, but a good part of this is private to wayland (the<br>
> wl_closure stuff for example) so it feels like I would end up having<br>
> to duplicate quite some code from Wayland in WebKit, which I think is<br>
> really not a good idea. Also, the fact that these APIs have been kept<br>
> internal to Wayland means that this is not something that developers<br>
> are expected to do.<br>
><br>
> If the above is not a good solution either, I understand there would<br>
> be no solution for my problem within the wayland protocol and I would<br>
> need to add additional messages between the two processes outside the<br>
> protocol after the surface is created in order to associate the<br>
> surface and the widget on the compositor's side. In that case, I<br>
> would need to communicate the widget ID and the ID of the Wayland<br>
> object representing the surface (which I understand I'd get by<br>
> calling wl_proxy_get_id on the client for the surface).<br>
><br>
> Is my analysis of the problem correct or is there some way in which I<br>
> can achieve my objective within the wayland protocol?<br>
<br>
Hi,<br>
<br>
the short answer to your solution is "write a custom shell extension".<br>
<br>
That means that you would be writing your own private Wayland protocol<br>
extension in the same XML format as all Wayland protocol is already<br>
defined. Let's take xdg_shell as an example:<br>
<a href="http://cgit.freedesktop.org/wayland/weston/tree/protocol/xdg-shell.xml" target="_blank">http://cgit.freedesktop.org/wayland/weston/tree/protocol/xdg-shell.xml</a><br>
<br>
A compositor advertises a global object of type xdg_shell. The<br>
xdg_shell interface has two requests that allow you to add meaning to<br>
wl_surfaces: get_xdg_surface and get_xdg_popup. These requests<br>
associate additional information to the given wl_surface, and create a<br>
new protocol object to allow manipulating the new features added to the<br>
wl_surface object.<br>
<br>
If all you need to do is to associate an integer ID to a wl_surface,<br>
you could define a new global interface with a single request, that has<br>
a wl_surface and the ID as arguments. If you need more, you can add<br>
more like xdg_shell does. There are also many other examples of how<br>
wl_surface can be extended with the help of a new global interface.<br>
<br>
This new global interface would be advertised by the nested compositor<br>
only, and the clients of that compositor would be using it. No-one else<br>
would ever see it. The clients would use the standard wl_compositor to<br>
create standard wl_surface objects, and then add new meaning to them<br>
with your extension.<br>
<br>
Does this help?<br>
<br>
Btw. do not write an extension that has a new request to create<br>
wl_surface objects, or any objects that are already creatable via other<br>
interfaces. Doing so would lead to interface versioning problems, as<br>
explained in:<br>
<a href="http://wayland.freedesktop.org/docs/html/sect-Protocol-Versioning.html" target="_blank">http://wayland.freedesktop.org/docs/html/sect-Protocol-Versioning.html</a><br>
<br>
<br>
Thanks,<br>
pq<br>
_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</blockquote></div>