Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorServiceNightLight Namespace Reference

Namespaces

namespace  ColorTemperature
 The colour temperatures the library works in, in kelvin.

Classes

struct  WhitePoint
 The colour of white at a temperature, as per-channel factors. More...
class  GammaBackend
 What NightLight drives: something that can tint every output. More...
class  NightLight
 A compositor-neutral night light. More...

Functions

PHOSPHORSERVICENIGHTLIGHT_EXPORT WhitePoint whitePoint (int kelvin)
 The white point of a black body at kelvin, relative to 6500 K.
PHOSPHORSERVICENIGHTLIGHT_EXPORT QByteArray gammaTable (const WhitePoint &white, quint32 size)
 A wlr-gamma-control table for white with size entries per channel.
PHOSPHORSERVICENIGHTLIGHT_EXPORT void registerQmlTypes ()
 Register every PhosphorServiceNightLight QML type under the Phosphor.Service.NightLight module at version 1.0.

Function Documentation

◆ gammaTable()

PHOSPHORSERVICENIGHTLIGHT_EXPORT QByteArray PhosphorServiceNightLight::gammaTable ( const WhitePoint & white,
quint32 size )
nodiscard

A wlr-gamma-control table for white with size entries per channel.

The layout the protocol's set_gamma expects: size native-endian 16-bit red values, then green, then blue (6 * size bytes). Entry i is i / (size - 1) * 65535 * channel, the identity ramp scaled by the white point. A size below 2 gives an empty array.

◆ registerQmlTypes()

PHOSPHORSERVICENIGHTLIGHT_EXPORT void PhosphorServiceNightLight::registerQmlTypes ( )

Register every PhosphorServiceNightLight QML type under the Phosphor.Service.NightLight module at version 1.0.

Idempotent on repeat calls: internally guarded by std::call_once so a hot-reloading shell that builds a fresh QQmlEngine per reload can call this from every engine setup without triggering Qt's duplicate-registration warning.

Called from the consuming binary before any QQmlEngine loads a .qml file.

◆ whitePoint()

PHOSPHORSERVICENIGHTLIGHT_EXPORT WhitePoint PhosphorServiceNightLight::whitePoint ( int kelvin)
nodiscard

The white point of a black body at kelvin, relative to 6500 K.

The black body's chromaticity comes from Planck's law integrated over the CIE 1931 2° standard observer, the observer approximated by the multi-lobe Gaussian fit of Wyman, Sloan and Shirley ("Simple Analytic Approximations to the CIE XYZ Color Matching Functions", JCGT 2(2), 2013). XYZ goes to linear sRGB through the IEC 61966-2-1 matrix. The result is divided by the same computation at 6500 K, so 6500 K is exactly white and the scale is continuous on both sides of it, then normalised so the largest channel is 1.

kelvin is clamped to [ColorTemperature::Minimum, ColorTemperature::Maximum].