Documentation
¶
Overview ¶
Package scale owns one surface's buffer scaling: the integer wl_surface fallback, the optional wp_viewporter and wp_fractional_scale_v1 objects, and the output transform. Compositors without the fractional-scale protocols keep the exact integer behavior; feature detection happens at bind time in internal/wlsession.
With the protocols present, a surface scales fractionally by giving the compositor a wp_viewport destination in logical pixels and attaching buffers of ceil(logical * preferred/120) device pixels; the wl_surface buffer scale stays 1, per the fractional-scale protocol. preferred_scale is 120-based: 150 is 1.25, 240 is 2.
Index ¶
Constants ¶
const Denom = 120
Denom is the fixed denominator of the 120-based fractional-scale wire units.
Variables ¶
This section is empty.
Functions ¶
func DeviceSize ¶
DeviceSize rounds the logical size v up to device pixels at the 120-based scale frac120, so the buffer always fully covers the destination.
func IntegerScale ¶
IntegerScale rounds a 120-based scale up to the integer fallback: 150 (1.25) needs a 2x integer buffer scale without the viewporter.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is one surface's scale state. The zero value is unusable; build with New.
func New ¶
New wires surf for scaling on sess. With the fractional-scale protocol it attaches wp_viewport and wp_fractional_scale objects and reports every preferred_scale event through fn; without them the controller falls back to integer wl_surface.set_buffer_scale and fn never fires. A missing protocol object (bind or creation failure) degrades the same way, per-feature.
Only one Controller may exist per surface: wp_viewporter allows a single wp_viewport per wl_surface, and a second get_viewport is a fatal protocol error that kills the connection (it once took down every tooltip, via a duplicate controller on the popup surface). Surfaces owned by popup.Popup get their controller from Popup.Scale.
func (*Controller) Apply ¶
func (c *Controller) Apply(frac120 uint32, w, h int) error
Apply publishes device scale frac120 (120-based) for a surface of logical size w x h. Fractional surfaces get their viewport destination set (the buffer scale stays 1); integer surfaces get the rounded-up buffer scale. It is a no-op while the surface has no size yet - the destination must be positive - so callers re-apply once the first configure arrived.
func (*Controller) Destroy ¶
func (c *Controller) Destroy() error
Destroy releases the surface's wp_viewport and wp_fractional_scale objects, which the client otherwise keeps registered, with their handler, for as long as the connection lives. The controller is inert afterwards; a nil controller and a second Destroy are no-ops.
func (*Controller) Fractional ¶
func (c *Controller) Fractional() bool
Fractional reports whether the surface follows the fractional-scale protocol; false means the integer set_buffer_scale fallback.
func (*Controller) HandleWpScaleV1PreferredScale ¶
func (c *Controller) HandleWpScaleV1PreferredScale(ev wlr.WpScaleV1PreferredScaleEvent)
HandleWpScaleV1PreferredScale implements the wp_fractional_scale_v1 preferred_scale handler.
func (*Controller) SetTransform ¶
func (c *Controller) SetTransform(transform int32) error
SetTransform publishes the buffer transform (an output's rotation, as wl_output.geometry reports it) the surface's buffers are submitted for. It is double-buffered state, applied at the next commit.