<div dir="ltr">Hi,<div><br></div><div>I started a discussion a while ago about the possibility of adding position set/get abilities to wayland, but since then I'd learned alot about how wayland works. I had heard that wayland combines the WM and server into one "compositor", but I thought wayland itself still managed some things. Since then I've learned that the compositor manages every event that a wayland client sends, and I think this makes the ability to set/get a position even more necessary. The reasons are:<div><ol><li>Apps can send both the position they want for a window and and the type of window, and a compositor can choose which one to follow. (for example, a client can send (width/2, height/2) and "popup" for a popup surface, and compositors that prefer to follow the descriptive design will follow "popup" and ones that prefer prescriptive design will follow the coordinates).</li><li>Waylands asynchronous event system means that a compositor can ask users if they would like to give an app permission to move itself and/or other windows, similar to how android asks before giving apps camera/GPS permissions.</li></ol><div>I've looked at existing wayland protocols and used them to create a simple one for position set/get.</div></div><div><pre class="gmail-code gmail-highlight" lang="xml">------------------------------------------------------------------------------------------</pre><br class="gmail-Apple-interchange-newline"></div><div><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC1" lang="xml" class="gmail-line"><span class="gmail-hljs-meta"><?xml version=<span class="gmail-hljs-string">"1.0"</span> encoding=<span class="gmail-hljs-string">"UTF-8"</span>?></span></span>
<span id="gmail-LC2" lang="xml" class="gmail-line"><span class="gmail-hljs-tag"><<span class="gmail-hljs-name">protocol</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"pos_unstable_v1"</span>></span></span>
<span id="gmail-LC4" lang="xml" class="gmail-line">  <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">copyright</span>></span></span>
<span id="gmail-LC5" lang="xml" class="gmail-line">    Copyright © 2022 Samuel Ammonius</span>
<span id="gmail-LC6" lang="xml" class="gmail-line"></span>
<span id="gmail-LC7" lang="xml" class="gmail-line">    Permission is hereby granted, free of charge, to any person obtaining a</span>
<span id="gmail-LC8" lang="xml" class="gmail-line">    copy of this software and associated documentation files (the "Software"),</span>
<span id="gmail-LC9" lang="xml" class="gmail-line">    to deal in the Software without restriction, including without limitation</span>
<span id="gmail-LC10" lang="xml" class="gmail-line">    the rights to use, copy, modify, merge, publish, distribute, sublicense,</span>
<span id="gmail-LC11" lang="xml" class="gmail-line">    and/or sell copies of the Software, and to permit persons to whom the</span>
<span id="gmail-LC12" lang="xml" class="gmail-line">    Software is furnished to do so, subject to the following conditions:</span>
<span id="gmail-LC13" lang="xml" class="gmail-line"></span>
<span id="gmail-LC14" lang="xml" class="gmail-line">    The above copyright notice and this permission notice (including the next</span>
<span id="gmail-LC15" lang="xml" class="gmail-line">    paragraph) shall be included in all copies or substantial portions of the</span>
<span id="gmail-LC16" lang="xml" class="gmail-line">    Software.</span>
<span id="gmail-LC17" lang="xml" class="gmail-line"></span>
<span id="gmail-LC18" lang="xml" class="gmail-line">    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span id="gmail-LC19" lang="xml" class="gmail-line">    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span id="gmail-LC20" lang="xml" class="gmail-line">    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL</span>
<span id="gmail-LC21" lang="xml" class="gmail-line">    THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span id="gmail-LC22" lang="xml" class="gmail-line">    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING</span>
<span id="gmail-LC23" lang="xml" class="gmail-line">    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER</span>
<span id="gmail-LC24" lang="xml" class="gmail-line">    DEALINGS IN THE SOFTWARE.</span>
<span id="gmail-LC25" lang="xml" class="gmail-line">  <span class="gmail-hljs-tag"></<span class="gmail-hljs-name">copyright</span>></span></span></pre><pre class="gmail-code gmail-highlight" lang="xml"><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC27" lang="xml" class="gmail-line"><span class="gmail-hljs-tag"><<span class="gmail-hljs-name">interface</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"zwp_pos_v1"</span> <span class="gmail-hljs-attr">version</span>=<span class="gmail-hljs-string">"1"</span>></span></span>
<span id="gmail-LC28" lang="xml" class="gmail-line">    <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">description</span> <span class="gmail-hljs-attr">summary</span>=<span class="gmail-hljs-string">"position management protocol"</span>></span></span>
<span id="gmail-LC29" lang="xml" class="gmail-line">      Used to set/get the position of a surface. The ability to set the monitor that a surface is on is not available yet.</span></pre><pre class="gmail-code gmail-highlight" lang="xml"><span lang="xml" class="gmail-line"><br></span></pre><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC44" lang="xml" class="gmail-line">      Warning! The protocol described in this file is experimental and</span>
<span id="gmail-LC45" lang="xml" class="gmail-line">      backward incompatible changes may be made. Backward compatible changes</span>
<span id="gmail-LC46" lang="xml" class="gmail-line">      may be added together with the corresponding interface version bump.</span>
<span id="gmail-LC47" lang="xml" class="gmail-line">      Backward incompatible changes are done by bumping the version number in</span>
<span id="gmail-LC48" lang="xml" class="gmail-line">      the protocol and interface names and resetting the interface version.</span>
<span id="gmail-LC49" lang="xml" class="gmail-line">      Once the protocol is to be declared stable, the 'z' prefix and the</span>
<span id="gmail-LC50" lang="xml" class="gmail-line">      version number in the protocol and interface names are removed and the</span>
<span id="gmail-LC51" lang="xml" class="gmail-line">      interface version number is reset.</span>
<span id="gmail-LC52" lang="xml" class="gmail-line">    <span class="gmail-hljs-tag"></<span class="gmail-hljs-name">description</span>></span></span>
<pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC238" lang="xml" class="gmail-line">    <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">request</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"set_pos"</span>></span></span>
<span id="gmail-LC239" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">description</span> <span class="gmail-hljs-attr">summary</span>=<span class="gmail-hljs-string">"position setter"</span>></span></span>
<span id="gmail-LC240" lang="xml" class="gmail-line">       </span>Set the position of a surface
<span id="gmail-LC247" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"></<span class="gmail-hljs-name">description</span>></span></span>
<pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC144" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">arg</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"surface"</span> <span class="gmail-hljs-attr">type</span>=<span class="gmail-hljs-string">"object"</span> <span class="gmail-hljs-attr">interface</span>=<span class="gmail-hljs-string">"wl_surface"</span></span></span>
<span id="gmail-LC145" lang="xml" class="gmail-line">          <span class="gmail-hljs-attr">summary</span>=<span class="gmail-hljs-string">"target surface"</span>/></span>
</pre><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC144" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">arg</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"x"</span> <span class="gmail-hljs-attr">type</span>=<span class="gmail-hljs-string">"int"</span></span></span><span id="gmail-LC145" lang="xml" class="gmail-line">/></span></pre><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC144" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">arg</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"y"</span> <span class="gmail-hljs-attr">type</span>=<span class="gmail-hljs-string">"int</span></span></span><span id="gmail-LC145" lang="xml" class="gmail-line"><span class="gmail-hljs-string">"</span>/></span></pre><span id="gmail-LC250" lang="xml" class="gmail-line">    <span class="gmail-hljs-tag"></<span class="gmail-hljs-name">request</span>></span></span>
<span id="gmail-LC251" lang="xml" class="gmail-line"></span>
<span id="gmail-LC252" lang="xml" class="gmail-line">    <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">event</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"pos_changed"</span>></span></span>
<span id="gmail-LC253" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">description</span> <span class="gmail-hljs-attr">summary</span>=<span class="gmail-hljs-string">"position changed event"</span>></span></span>
<span id="gmail-LC254" lang="xml" class="gmail-line">       </span>Notification that a surface has been moved, either by itself, another program, or the compositor.</pre><pre class="gmail-code gmail-highlight" lang="xml">        WARNING: Do not use this event to force a surface to a certain position. If multiple apps want the surface in a different position, then the computer may freeze or glitch.</pre><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC255" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"></<span class="gmail-hljs-name">description</span>></span></span></pre><pre class="gmail-code gmail-highlight" lang="xml"><span lang="xml" class="gmail-line"><span class="gmail-hljs-tag"><pre class="gmail-code gmail-highlight" lang="xml"><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC144" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">arg</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"x"</span> <span class="gmail-hljs-attr">type</span>=<span class="gmail-hljs-string">"int"</span></span></span><span id="gmail-LC145" lang="xml" class="gmail-line">/></span></pre><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC144" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">arg</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"y"</span> <span class="gmail-hljs-attr">type</span>=<span class="gmail-hljs-string">"int</span></span></span><span id="gmail-LC145" lang="xml" class="gmail-line"><span class="gmail-hljs-string">"</span>/></span></pre></pre></span></span></pre><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC256" lang="xml" class="gmail-line">    <span class="gmail-hljs-tag"></<span class="gmail-hljs-name">event</span>></span></span>
</pre><pre class="gmail-code gmail-highlight" lang="xml"><span lang="xml" class="gmail-line"><span class="gmail-hljs-tag"><pre class="gmail-code gmail-highlight" lang="xml"><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC252" lang="xml" class="gmail-line">    <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">event</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"get_pos"</span>></span></span><br></pre><pre class="gmail-code gmail-highlight" lang="xml"><span lang="xml" class="gmail-line"><span class="gmail-hljs-tag"><pre class="gmail-code gmail-highlight" lang="xml"><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC144" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">arg</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"x"</span> <span class="gmail-hljs-attr">type</span>=<span class="gmail-hljs-string">"int"</span></span></span><span id="gmail-LC145" lang="xml" class="gmail-line">/></span></pre><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC144" lang="xml" class="gmail-line">      <span class="gmail-hljs-tag"><<span class="gmail-hljs-name">arg</span> <span class="gmail-hljs-attr">name</span>=<span class="gmail-hljs-string">"y"</span> <span class="gmail-hljs-attr">type</span>=<span class="gmail-hljs-string">"int</span></span></span><span id="gmail-LC145" lang="xml" class="gmail-line"><span class="gmail-hljs-string">"</span>/></span></pre></pre></span></span></pre><pre class="gmail-code gmail-highlight" lang="xml"><span id="gmail-LC256" lang="xml" class="gmail-line">    <span class="gmail-hljs-tag"></<span class="gmail-hljs-name">event</span>></span></span></pre></pre></span></span></pre>  </interface></pre><pre class="gmail-code gmail-highlight" lang="xml"></protocol></pre><pre class="gmail-code gmail-highlight" lang="xml">------------------------------------------------------------------------------------------</pre><pre class="gmail-code gmail-highlight" lang="xml">Should I just send it or is my reasoning (or XML syntax) wrong?</pre></pre></div></div></div>