[PATCH] Add the KDE server decoration protocol

David Edmundson david at davidedmundson.co.uk
Wed Nov 15 12:57:05 UTC 2017


On Mon, Oct 30, 2017 at 5:03 AM, Jonas Ådahl <jadahl at gmail.com> wrote:

> On Fri, Oct 27, 2017 at 01:13:15PM +0100, David Edmundson wrote:
> > The server decoration protocol negotiates between the client and server
> > whether the client should default to drawing window decorations, and
> > informs the compositor what the client is doing.
> >
> > This is useful not just for a compostior that is doing decorations
> > itself, but much more importantly for a toolkit, such as Qt which
> > primarily targets embedded and IVI applications, not to have to modify
> > clients
> > to add a header bar which makes them usable on a desktop compositor.
> >
> > This file is currently copied in multiple places across GTK, Sway as well
> > as being needed in both Qt and KDE. We should have this in a shared
> > place.
>
> I think that this functionality is in scope for wayland-protocols, but
> wayland-protocols was AFAIK never meant as a distribution of arbitrary
> external protocols. In the beginning, a major reason why it was created
> at all was because wayland.xml was getting too large and it was too
> inconvenient to wait for wayland releases for adding a new protocol or
> protocol version would we instead add new XML files to the wayland repo.
>
> I'd expect protocols that aim to be included here to be willing to go
> through protocol review and adhere to the conventions we have set up.
> I have read through the protocol and will provide feedback as if the
> protocol aims to follow the conventions we have in place.
>

Sounds reasonable.
I understand you don't want to have a generic dumping ground.

Thanks for the very thorough review.

>
> > ---
> >  unstable/server-decoration/server-decoration.xml | 94
> > ++++++++++++++++++++++++
> >  1 file changed, 94 insertions(+)
> >  create mode 100644 unstable/server-decoration/server-decoration.xml
> >
> > diff --git a/unstable/server-decoration/server-decoration.xml
> > b/unstable/server-decoration/server-decoration.xml
> > new file mode 100644
> > index 0000000..8bc106c
> > --- /dev/null
> > +++ b/unstable/server-decoration/server-decoration.xml
> > @@ -0,0 +1,94 @@
> > +<?xml version="1.0" encoding="UTF-8"?>
> > +<protocol name="server_decoration">
> > +  <copyright><![CDATA[
> > +    Copyright (C) 2015 Martin Grنكlin
> > +
> > +    This program is free software: you can redistribute it and/or modify
> > +    it under the terms of the GNU Lesser General Public License as
> > published by
> > +    the Free Software Foundation, either version 2.1 of the License, or
> > +    (at your option) any later version.
> > +
> > +    This program is distributed in the hope that it will be useful,
> > +    but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > +    GNU Lesser General Public License for more details.
> > +
> > +    You should have received a copy of the GNU Lesser General Public
> > License
> > +    along with this program.  If not, see <http://www.gnu.org/licenses/
> >.
>
> As mentioned elsewhere, it mixing different licenses could be somewhat
> inconvenient.
>
> > +  ]]></copyright>
> > +  <interface  name="org_kde_kwin_server_decoration_manager"
> version="1">
>
> I believe a protocol related to window decorations belong in the "xdg"
> family of protocols, extending 'xdg_wm_base'. For example
> 'xdg_wm_window_decorations' could be the name of a window decoration
> extension to xdg_wm_base (that is the main interface of xdg_shell).
>

Sure, my initial intention was to share the spec that's currently being
used, rather than
define something "xdg official".

Long term the latter is probably better even if it is going to
be more work for all involved.


> > +      <description summary="Server side window decoration manager">
> > +        This interface allows to coordinate whether the server should
> > create
> > +        a server-side window decoration around a wl_surface
> representing a
> > +        shell surface (wl_shell_surface or similar). By announcing
> support
> > +        for this interface the server indicates that it supports server
> > +        side decorations.
> > +      </description>
> > +      <request name="create">
> > +        <description summary="Create a server-side decoration object
> for a
> > given surface">
> > +            When a client creates a server-side decoration object it
> > indicates
> > +            that it supports the protocol. The client is supposed to
> tell
> > the
> > +            server whether it wants server-side decorations or will
> provide
> > +            client-side decorations.
> > +
> > +            If the client does not create a server-side decoration
> object
> > for
> > +            a surface the server interprets this as lack of support for
> > this
> > +            protocol and considers it as client-side decorated.
> > Nevertheless a
> > +            client-side decorated surface should use this protocol to
> > indicate
> > +            to the server that it does not want a server-side deco.
>
> What is the purpose of a client not supporting server side decorations
> to create this object anyway? I assume functionality wise it shouldn't
> make any difference right?
>

It shouldn't.

>
> > +        </description>
> > +        <arg name="id" type="new_id"
> > interface="org_kde_kwin_server_decoration"/>
> > +        <arg name="surface" type="object" interface="wl_surface"/>
> > +      </request>
> > +      <enum name="mode">
> > +            <description summary="Possible values to use in request_mode
> > and the event mode."/>
> > +            <entry name="None" value="0" summary="Undecorated: The
> surface
> > is not decorated at all, neither server nor client-side. An example is a
> > popup surface which should not be decorated."/>
>
> Why would a popup surface create a window decoration object at all? It
> seems pointless. I might be missing something but it seems to only make
> any sense to only deal with toplevels. A request creating the window
> decoration object could for example require that a surface passed is 'an
> xdg_toplevel or equivalent'.
>

You're right that a popup wouldn't need to.
There are top levels that need it setting to 0. Like splash screens.

The other issue we have is this doesn't attach to an xdg_toplevel/popup but
to the
wl_surface. A surface has no concept of toplevels/popups and that becomes
messy to define cross specs.

This was primarily due to the timeframe when it was made as we were
actively supporting wl_shell_surface and xdg_shell is still changing.

If we have to do the rename, and thus an API break, then I think it would
make sense to attach to the stable toplevel and then that goes away.


> > +            <entry name="Client" value="1" summary="Client-side
> > decoration: The decoration is part of the surface and the client."/>
> > +            <entry name="Server" value="2" summary="Server-side
> > decoration: The server embeds the surface into a decoration frame."/>
>
> style nit: For consistency, use lower case for all entry names. They'll
> become upper case anyway in the C file.
>
> > +      </enum>
> > +      <event name="default_mode">
> > +          <description summary="The default mode used on the server">
> > +              This event is emitted directly after binding the
> interface.
> > It contains
> > +              the default mode for the decoration. When a new server
> > decoration object
> > +              is created this new object will be in the default mode
> until
> > the first
> > +              request_mode is requested.
> > +
> > +              The server may change the default mode at any time.
> > +          </description>
> > +          <arg name="mode" type="uint" summary="The default decoration
> > mode applied to newly created server decorations."/>
> > +      </event>
>
> Using a potentially changing 'default_mode' seems racy to me, especially
> if the protocol allows a client to rely on what is default to choose.
> Exposing a 'preferred_mode' that doesn't actually affect the state seems
> less prone to races, as a client will then actively take the
> 'preferred_mode' into consideration when setting up its state.
>
> I think that's pretty much the intention. Seems sensible.



> > +  </interface>
> > +  <interface name="org_kde_kwin_server_decoration" version="1">
>
> Correct me if I'm wrong, but this is an object about decorating a
> toplevel (i.e. non-popup/non-tooltip) window right? A suggestion of what
> to call it is "xdg_toplevel_window_decorator", to indicate that it
> extends the xdg_toplevel (or an equivalent).
>

> > +      <request name="release" type="destructor">
>
> This should be "destroy", as otherwise wayland-scanner will create a
> _destroy() function that doesn't actually destroy the server side
> object.
>
> > +        <description summary="release the server decoration object"/>
> > +      </request>
> > +      <enum name="mode">
> > +            <description summary="Possible values to use in request_mode
> > and the event mode."/>
> > +            <entry name="None" value="0" summary="Undecorated: The
> surface
> > is not decorated at all, neither server nor client-side. An example is a
> > popup surface which should not be decorated."/>
> > +            <entry name="Client" value="1" summary="Client-side
> > decoration: The decoration is part of the surface and the client."/>
> > +            <entry name="Server" value="2" summary="Server-side
> > decoration: The server embeds the surface into a decoration frame."/>
> > +      </enum>
>
> No need to redefine the same mode enum here. Just use the one in the
> parent interface.
>
> > +      <request name="request_mode">
> > +          <description summary="The decoration mode the surface wants to
> > use."/>
> > +          <arg name="mode" type="uint" summary="The mode this surface
> > wants to use."/>
> > +      </request>
>
> For consistency with other xdg_* protocols, I'd suggest calling this
> "set_mode" instead.
>
> > +      <event name="mode">
> > +          <description summary="The new decoration mode applied by the
> > server">
> > +              This event is emitted directly after the decoration is
> > created and
> > +              represents the base decoration policy by the server. E.g.
> a
> > server
> > +              which wants all surfaces to be client-side decorated will
> > send Client,
> > +              a server which wants server-side decoration will send
> Server.
> > +
> > +              The client can request a different mode through the
> > decoration request.
> > +              The server will acknowledge this by another event with the
> > same mode. So
> > +              even if a server prefers server-side decoration it's
> > possible to force a
> > +              client-side decoration.
> > +
> > +              The server may emit this event at any time. In this case
> the
> > client can
> > +              again request a different mode. It's the responsibility of
> > the server to
> > +              prevent a feedback loop.
>
> The way this seem to work seems racy, as it doesn't contain any
> information about how to guarantee that a window is displayed properly
> every frame. I think it should instead make use of the mechanism we now
> have in place that is meant to fix exactly this type of problems:
> xdg_surface.configure & xdg_surface.ack_configure. By using extending
> that functionality, a client and compositor can negotiate a state while
> guaranteeing that when a client sends a surface state, the compositor
> will know exactly what its configuration is. xdg_toplevel and xdg_popup
> already extends this functionality for negotiating state, and a
> decoration protocol should do the same.
>

You're right the spec doesn't specify this very well at all, which needs
fixing.
We definitely want to enforce the client's mode to be in sync with the
buffer.

Personally I'd just change the docs to force servers and surfaces to be
static set on bind and before the first commit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20171115/f29a3a77/attachment-0001.html>


More information about the wayland-devel mailing list