Wayland and window position/size

Daniel Stone daniel at fooishbar.org
Wed May 26 09:38:42 UTC 2021


Hi,

On Wed, 26 May 2021 at 10:30, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> On Tue, 25 May 2021 22:10:38 -0500 Igor Korot <ikorot01 at gmail.com> wrote:
> > > Positioning - Don't position and Wayland discourages it by not having such an
> > > API. Sizing - do whatever you like.
> >
> > It just discourages it, so it is not completely impossible, correct?
>
> I'd say Wayland strongly discourages client dictated positioning.
>
> First, there is no Wayland protocol interface that would allow you to
> position a window (unless you invent a protocol extension to do it and
> then implement it also in any Wayland compositors you want to run on -
> some extensions like that exist and their support in different
> compositors varies, and they are mostly privileged or reserved for
> desktop components instead of apps). It might be possible to play
> tricks with existing generic interfaces to *maybe* eventually end up in
> some position, but that is extremely fragile and an outright abuse which
> might also cause strange UI behaviour.
>
> Second, Wayland does not define a coordinate system that would be
> useful for window positioning. Every window has its own local
> coordinate system, but they exist in a "vacuum" and independently of
> each other and of monitors. So at most you can position a window
> respective to another window, but not globally or per-monitor.
>
> Third, Wayland does not allow you to find out about other windows or
> desktop elements that you might want to stay clear of, nor about
> monitor edges (well... not for this purpose). So it's hard to choose
> your position properly.
>
> So, is it possible depends on how badly you are willing to break things
> to get there.
>
> As for sizing, I'd think the xdg-shell protocol extensions are mature.
> They allow you to freely size your window when the window state
> supports it, and they include the provision for the display server to
> tell you what size you should or must be, depending on window state. It
> also has an interface for positioning your popups such that they don't
> go out of view but also match where they should be respective to your
> window.

Pekka's answer is very thorough. As a much shorter version: just use
the XDG extensions which already exist for popup/dialog windows.

Your application is not the only one which needs to request
credentials - so do browsers, mail clients, file managers, and just
about everything else.

The X11 model is that every application has its own semantics for
doing this and decides exactly how to place the window. The client
tells the server: place this window at these co-ordinates, at this z
position, and give me all the input until I tell you otherwise.

The Wayland model is that you tell the Wayland server that you would
like to present a dialog or popup window, and which top-level window
it should be attached to. It then handles those windows in a
completely consistent and uniform way between all your applications,
including positioning, stacking, and focus.

So, just use that. It works. :)

Cheers,
Daniel


More information about the wayland-devel mailing list