Copyright © 2022 Kenny Levinsen
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
This protocol allows a compositor to suggest for surfaces to render at
fractional scales.
A client can submit scaled content by utilizing wp_viewport. This is done by
creating a wp_viewport object for the surface and setting the destination
rectangle set to the surface size before the scale factor is applied.
If the surface is not a subsurface, then the buffer size is calculated by
multiplying the surface size by the intended scale, rounding the result
halfway away from zero.
If the surface is a subsurface, then the calculation must account for the
surface position when rounding the buffer size. First, add the subsurface
position relative to its parent to the surface size, multiplying them by the
intended scale and rounding the result halfway away from zero. Second, take
the subsurface position relative to its parent, multiplying it by the
intended scale and rounding the result halfway away from zero. Finally,
subtract the result of the second calculation from the first calculation to
get the buffer size.
The wl_surface buffer scale should remain set to 1 in both cases.
In the compositor, final subsurface positions are calculated by multiplying
the position of the subsurface relative to its parent by the intended scale,
and rounding the result halfway away from zero. The positions of the parent
surfaces, calculated using the same mechanism, are then recursively added to
the result. This ensures that position and size rounding is not affected by
the movement of parent surfaces.
If a surface has a surface-local size of 100 px by 50 px and wishes to
submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should
be used and the wp_viewport destination rectangle should be 100 px by 50 px.
A global interface for requesting surfaces to use fractional scales.
Informs the server that the client will not be using this protocol
object anymore. This does not affect any other objects,
wp_fractional_scale_v1 objects included.
Create an add-on object for the the wl_surface to let the compositor
request fractional scales. If the given wl_surface already has a
wp_fractional_scale_v1 object associated, the fractional_scale_exists
protocol error is raised.
An additional interface to a wl_surface object which allows the compositor
to inform the client of the preferred scale.
The associated wl_surface's fractional scale object is destroyed.
Notification of a new preferred scale for this surface that the
compositor suggests that the client should use.