frational-scale: Don't hard code denomainator

Using the denominator 120 artificially limits the way of implementing
fractional scaling that makes it impossible in certain situations to
describe a configuration where a fullscreen window covers the whole
monitor.

In practice, it means a compositor who always uses the whole monitor
resolution cannot agree on a common expected size of surface buffer
sizes, as too much precision is lost when transferring the scale over
the wire. This means compositors, in order to always be capable of
getting the same resulting buffer size as clients, must artificially
limit the scaling factor precision, which means it won't always be
possible to get a logical fullscreen integer size to match screen
resolution.

Fix this by not hard coding the denominator, and allow compositors to
transfer a factor without loosing precision. Compositors who want to
continue to use scaling factors with less precision can hard code 120 in
their own implementation to achieve the current behavior.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
Jonas Ådahl 2024-05-23 10:05:22 +02:00
parent 24e612f7d7
commit 16a3a05665

View file

@ -44,7 +44,7 @@
rounding algorithm for subsurface position and size is not defined. rounding algorithm for subsurface position and size is not defined.
</description> </description>
<interface name="wp_fractional_scale_manager_v1" version="1"> <interface name="wp_fractional_scale_manager_v2" version="1">
<description summary="fractional surface scale information"> <description summary="fractional surface scale information">
A global interface for requesting surfaces to use fractional scales. A global interface for requesting surfaces to use fractional scales.
</description> </description>
@ -76,7 +76,7 @@
</request> </request>
</interface> </interface>
<interface name="wp_fractional_scale_v1" version="1"> <interface name="wp_fractional_scale_v1" version="2">
<description summary="fractional scale interface to a wl_surface"> <description summary="fractional scale interface to a wl_surface">
An additional interface to a wl_surface object which allows the compositor An additional interface to a wl_surface object which allows the compositor
to inform the client of the preferred scale. to inform the client of the preferred scale.
@ -95,8 +95,24 @@
compositor suggests that the client should use. compositor suggests that the client should use.
The sent scale is the numerator of a fraction with a denominator of 120. The sent scale is the numerator of a fraction with a denominator of 120.
This event is deprecated in favor of preferred_scale2. It will not be
emitted when having bound version 2 or higher.
</description> </description>
<arg name="scale" type="uint" summary="the new preferred scale"/> <arg name="scale" type="uint" summary="the new preferred scale"/>
</event> </event>
<!-- Version 2 additions -->
<event name="preferred_scale2" since="2">
<description summary="notify of new preferred scale">
Notification of a new preferred scale for this surface that the
compositor suggests that the client should use.
The sent scale is the numerator and denomanator of a fraction.
</description>
<arg name="scale_num" type="uint" summary="the new preferred scale numerator"/>
<arg name="scale_denom" type="uint" summary="the new preferred scale denominator"/>
</event>
</interface> </interface>
</protocol> </protocol>