How to pick the initial (output) scale for a surface?

Pekka Paalanen ppaalanen at
Fri Jul 29 09:16:20 UTC 2016

On Sat, 23 Jul 2016 18:03:59 +0200
Quentin Glidic <sardemff7+wayland at> wrote:

> Hi everyone,
> Today I played with a little protocol to supports docks, implementing a 
> simple client and a weston plugin to test it.
> Reusing code from another client of mine, I faced an issue I had 
> encountered already when creating a protocol for notifications:
> There is no way for a client to know the correct scale to render to 
> before pushing a buffer.
> Currently, a client wanting to support output scale will have to use the 
> wl_surface.enter and .leave events, track the different scale factors, 
> and render a buffer that will work for all of them.
> It works great for normal applications, and the toolkit will take care 
> of most of the work, if not all. The surface will (should) magically be 
> rendered at the correct scale when you move it from one output to 
> another, and everything look good.
> However, current implementation in Weston[1] and Mutter[2] do not allow 
> these events to be used for the *initial* buffer.
> While xdg_shell[3] is getting ready to allow clients to provide the 
> “perfect buffer” right from the start, this output scale issue is annoying.
> There are at least three possible solutions:
> A) Changing the code to send wl_surface.enter even if no buffer is attached.
> B) Add a specific event to wl_surface (or an extension like 
> wl_perfect_surface) to solve this specific issue, sending the output the 
> client should optimize its rendering for.
> C) Use per-role-protocol events, as I did in my notification-area 
> protocol[4].


without a buffer, the surface size is unknown. Even if the WM was able
to position a surface without knowing its size, the surface might span
more than the initial output if the size is large enough. This would be
a problem if the initial output has a scale less than the additional
output it will end up to. This problem is common to A, B, and some
cases in C.

Option B with its "optimize the surface for this output" event would
solve more than just the issue in question. A compositor could drive it
based on which output has e.g. at least 80% of the surface, or
otherwise send the occupied output with highest scale. But is that a
good thing?

> I see no big downside to either solution. Here are a few thoughts about 
> them:
> A) may break for some clients, but it should have at worst the same 
> effect it has now.
> B) and C) will need explicit client support, while A) could work already 
> for some clients.
> B) avoids the duplication in every role-specific protocols, but wording 
> could be hard to get right to sync the event with role-specific one 
> (where to put “wl_surface.perfect_scale will be sent before 
> xdg_surface.configure”?).
> C) allows a bit more fine-grained behaviour, e.g. in my 
> notification-area protocol, all surfaces are tied to one specific 
> output, thus only one event (before any surface creation) will carry the 
> information.
> Thanks for reading, I hope we can figure out a nice solution to make 
> even the first frame perfect. :-)

I think it might not be reasonably possible for all cases, but if we
ignore the unknown size issue, maybe then.

I don't have good suggestions.

Currently what clients already have is the list of all outputs. As the
initial scale, they could pick the highest scale present when they do
not know which output the window will appear on (e.g. do not start
fullscreened on specific output). It does not remove the possibility
for the glitch, but we can at least pick the direction which way the
scale will change if we guess wrong, and there is a good possibility to
also guess right.

That would be consistent with the heuristic of picking the highest
scale from the outputs a surface is on after it has been mapped. Don't
toolkits do that already?


> [1] 
> <>
> [2] 
> <>
> [3] 
> <>
> [4] 
> <>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the wayland-devel mailing list