[UPDATED PATCH wayland] protocol: Add a request and event to identify the visible area for a surface

Bill Spitzak spitzak at gmail.com
Thu Apr 25 13:01:59 PDT 2013


Pekka Paalanen wrote:

> To which surface are these values relative to, the parent, or the
> hypothetical popup?

The implementation shows the parent surface. Also seems a lot easier for 
a client to handle that.

> "Distance to the edge" is a bit vague, I'm not sure how to use that
> based on this description alone. Can you write a formula on what
> coordinates to try next to make the area maximally visible?

The supplied code is not doing this (instead it returns the top-left of 
the requested area). But the intention is that if the width is zero then 
the returned x is the nearest position horizontally that is not clipped 
(either to the right or left of the requested position), and the same 
vertically.

This will figure out a non-clipped position to place a WxH window, 
assuming the clip is a rectangle larger than WxH:

    X,Y = client's preferred position
    x,y,w,h = probe(X,Y,W,H);
    if (w < W) { // clipped horizontally
        if (x > X) X = x; // move right
        else X = x + w - W; // move left
    }
    if (h < H) { // clipped vertically
        if (y > Y) Y = y; // move down
        else Y = y + h - H; // move up
    }
    X,Y,W,H is now where to place the window

> If width and/or height is zero, is it always both x and y, or just the
> corresponding x and/or y that is the distance?

I think it is very useful for the two to be independent.


More information about the wayland-devel mailing list