<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Hi Pekka,</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Some questions below:</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Thanks</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Terry<br>
</div>
<div class="moz-cite-prefix">On 26/02/2024 15:56, Pekka Paalanen
wrote:<br>
</div>
<blockquote type="cite" cite="mid:20240226175633.55e5ecee@eldfell">Ok.
What Wayland API requests cause a surface to actually be mapped
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">(Sorry don't really know Wayland protocol) ?
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Hi Terry,
the basic protocol object is wl_surface. The wl_surface needs to be
given a "role". This is a specific protocol term. xdg_surface and
xdg_toplevel can give a wl_surface the role of a top-level window,
which means it can get mapped when you play by the rules set in the
xdg_toplevel specification.
Sub-surface is another role.
So the rules are always role specific, but at some point they all
require content on the wl_surface, which is given with the attach
request followed by a commit request. Role rules specify when and how
that can be done.</pre>
</blockquote>
<p>Yes, I have heard that. But what I don't knoe is from the client:</p>
<ol>
<li>How do I find out the surfaces role ?</li>
<li>How would I set the surface to have a role such that it would
be mapped and thus visible ? Just wondering if I can work around
what I think is a QtWayland bug/issue/feature to make sure by
second Widgets surface is mapped/visible so that the waylandsink
subsurface can work. With X11 there were API calls to change the
Windows state and I was looking for something similar with
Wayland.</li>
</ol>
<p>I need to find some way to actually display video, simply and
efficiently on an embedded platform, in a Qt application in the
year 2024 :)</p>
<p>I have tried lots of work arounds but none have worked due to
either Qt issues, Wayland restrictions, Gstreamer restrictions,
Weston issues/restrictions, NXP hardware engine
issues/restrictions etc. Any ideas gratefully received!<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:20240226175633.55e5ecee@eldfell">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">The higher level surfaces are created/managed by QtWayland, but maybe I
can override somehow.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
That does not feel like a good idea to me. But I also cannot really
help you, because this all seems to be pointing at Qt which I know
nothing about.</pre>
</blockquote>
<p>Yes, thats probably true. But I need to get this to work somehow,
even if a kludge for now.</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:20240226175633.55e5ecee@eldfell">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">As mentioned before, If I use QPainter to draw into the video QWidget it
actually draws into the top QWidgets 16 surface using Wayland protocol.
I would have thought it would draw into its own QWidget surface 18 as it
has Qt::WA_NativeWindow set ?
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre class="moz-quote-pre" wrap="">
This question seems to be the essence. If Qt worked like you expected,
then I think the whole program would work.
However, there is no need (from Wayland perspective) to have a
wl_surface as "surface 18" in the middle. What would be best is if you
could somehow have that "middle" QWidget but without it's own
wl_surface. Have the QWidget control the GStreamer wl_surface position
through wl_subsurface interface, while GStreamer plays the video
through wl_surface interface.
Wayland does not relay sub-surface resizing or positioning between two
client-side components at all. There is not even a way query a
sub-surface position. So the positioning and sizing is all done in
Qt<->GStreamer somehow without Wayland in between. Only the end result
gets sent over Wayland to display: Qt sets up the position and
GStreamer sets up the size and content.</pre>
</blockquote>
<p>I think this middle surface is needed so that Qt can manage the
"Windows" at this level, like raise, lower, resize et. and Wayland
sink's subsurface that is below this is separate and can be
de-synced for the video display etc. I normally (on X11 and with
Qt5/Wayland), respond to QWidget resizes and use the Gstreamer API
calls to position/resize the waylandsink's sub-surface. This all
works quite nicely under X11 and worked (although not nicely)
under Qt5/Wayland.<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:20240226175633.55e5ecee@eldfell">
<pre class="moz-quote-pre" wrap="">
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">
I assume that Qtwayland is not "activating" the video QWidget's surface
or using it for some reason (send subsurface expose events ?) ?
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">If that's true, then it is very relevant. A sub-surface becomes mapped
and visible when:
- its parent surface is mapped and visible, and
- the parent surface is committed after the sub-surface has been
created and associated, and
- if the sub-surface is in synchronized mode, there also needs to be a
parent surface commit after every sub-surface commit you want to
become visible. So if you do the first sub-surface sync-mode commit
with a buffer after the parent has already committed the
sub-surface's creation, the parent surface needs too commit again.
This applies recursively, too, and you have a sub-sub-surface there.
Do you actually need to sub-surface in the middle? Have you tried
without it?
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
I am not doing anything with Wayland directly. Qt is managing the higher
level surfaces/subsurfaces and then GStreamers waylandsink is passed one
of these Qt managed surfaces and it creates the subsurface 44. Looking
at waylandsink it should set this subsurface to be desynced so it can
draw into this surface without synchronising to the parents surface
managed by Qt.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Right, and desync is not enough if its parent is not mapped.
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">All I am trying to do is use the technique as mentioned in various
forums/lists to get GStreamer to display a video such that it "appears"
where a QWidget is on the screen. Mind you all of this info is very
rough and ready. For X11 it appears stable, but for Qt/Wayland the info,
and it appears functionality, is not quite all there.
When you say a sub-surface in the middle I presume you mean the surface
18 of the lower QWidget ? Well I have tried using the top most QWidget's
surface 16 and the video is displayed, although all over the
application. I really need to manage this surface so it can be raised,
lowered and resizes amongst the other QWidgets somehow. I have tried
using direct Wayland API calls to create a subsurface manually from the
top surface but so far I have just got protocol errors while trying
this. It may be my bad Wayland client code or how it is interfering with
Qt's Wayland interface.
I have even tried using a separate top level surface. Unfortunately as
the standard Wayland protocols do not allow an application to move or
manage top level Windows this is not useful. I guess I could create an
extra Wayland/Weston server protocol to allow my app (embedded system)
to manage these windows, but I was trying to do things in as standard a
way as possible.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Rather than "more Wayland", I suspect you should look into "more Qt". I
think it would only get even more fragile if you attempted to override
what Qt does. They must have a way to make this work somehow.</pre>
</blockquote>
<p>Well I am coming to the conclusion that it doesn't currently work
under QtWayland. I will start delving into that, but again there
is not much documentation on how it works that I have found to
give me a pointer on where to look. The fact that QWidgets are not
drawing into their own surfaces is a bit worrying, maybe some
issue were actually found when trying to do that.<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:20240226175633.55e5ecee@eldfell">
<pre class="moz-quote-pre" wrap="">
Thanks,
pq
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">I note in the qtwayland change logs, for the earlier QT5 for subsurface
changes:
dist/changes-5.6.3: - [QTBUG-52118] Fixed subsurface positions sometimes
not being committed.
dist/changes-5.11.2: - [QTBUG-69643] Fixed a bug where subsurfaces would
not be rendered if clients added them before a WaylandQuickItem was
created for the parent surface
dist/changes-5.12.0: - [QTBUG-49809] Added support for
wl_subsurface.place_above and place_below in WaylandQuickItem.
dist/changes-5.15.2: - [QTBUG-86176] We now send subsurface expose
events when a different toplevel (such as a dialog) is configured.
Could any of these be related ?
Terry
</pre>
</blockquote>
</blockquote>
<pre class="moz-quote-pre" wrap="">
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>