// Generated by go-wayland-scanner
// https://github.com/yaslama/go-wayland/cmd/go-wayland-scanner
// XML file : internal/proto/xml/color-management-v1.xml
//
// color_management_v1 Protocol Copyright:
//
// Copyright 2019 Sebastian Wick
// Copyright 2019 Erwin Burema
// Copyright 2020 AMD
// Copyright 2020-2024 Collabora, Ltd.
// Copyright 2024 Xaver Hugl
// Copyright 2022-2025 Red Hat, Inc.
//
// 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.

package wp_color_management

import (
	"github.com/AvengeMedia/dankgo/wayland/client"
	"golang.org/x/sys/unix"
)

// WpColorManagerV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpColorManagerV1InterfaceName = "wp_color_manager_v1"

// WpColorManagerV1 : color manager singleton
//
// A singleton global interface used for getting color management extensions
// for wl_surface and wl_output objects, and for creating client defined
// image description objects. The extension interfaces allow
// getting the image description of outputs and setting the image
// description of surfaces.
//
// Compositors should never remove this global.
type WpColorManagerV1 struct {
	client.BaseProxy
	supportedIntentHandler         WpColorManagerV1SupportedIntentHandlerFunc
	supportedFeatureHandler        WpColorManagerV1SupportedFeatureHandlerFunc
	supportedTfNamedHandler        WpColorManagerV1SupportedTfNamedHandlerFunc
	supportedPrimariesNamedHandler WpColorManagerV1SupportedPrimariesNamedHandlerFunc
	doneHandler                    WpColorManagerV1DoneHandlerFunc
}

// NewWpColorManagerV1 : color manager singleton
//
// A singleton global interface used for getting color management extensions
// for wl_surface and wl_output objects, and for creating client defined
// image description objects. The extension interfaces allow
// getting the image description of outputs and setting the image
// description of surfaces.
//
// Compositors should never remove this global.
func NewWpColorManagerV1(ctx *client.Context) *WpColorManagerV1 {
	wpColorManagerV1 := &WpColorManagerV1{}
	ctx.Register(wpColorManagerV1)
	return wpColorManagerV1
}

// Destroy : destroy the color manager
//
// Destroy the wp_color_manager_v1 object. This does not affect any other
// objects in any way.
func (i *WpColorManagerV1) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 0
	const _reqBufLen = 8
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// GetOutput : create a color management interface for a wl_output
//
// This creates a new wp_color_management_output_v1 object for the
// given wl_output.
//
// See the wp_color_management_output_v1 interface for more details.
func (i *WpColorManagerV1) GetOutput(output *client.Output) (*WpColorManagementOutputV1, error) {
	id := NewWpColorManagementOutputV1(i.Context())
	const opcode = 1
	const _reqBufLen = 8 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], id.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], output.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return id, err
}

// GetSurface : create a color management interface for a wl_surface
//
// If a wp_color_management_surface_v1 object already exists for the given
// wl_surface, the protocol error surface_exists is raised.
//
// This creates a new color wp_color_management_surface_v1 object for the
// given wl_surface.
//
// See the wp_color_management_surface_v1 interface for more details.
func (i *WpColorManagerV1) GetSurface(surface *client.Surface) (*WpColorManagementSurfaceV1, error) {
	id := NewWpColorManagementSurfaceV1(i.Context())
	const opcode = 2
	const _reqBufLen = 8 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], id.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], surface.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return id, err
}

// GetSurfaceFeedback : create a color management feedback interface
//
// This creates a new color wp_color_management_surface_feedback_v1 object
// for the given wl_surface.
//
// See the wp_color_management_surface_feedback_v1 interface for more
// details.
func (i *WpColorManagerV1) GetSurfaceFeedback(surface *client.Surface) (*WpColorManagementSurfaceFeedbackV1, error) {
	id := NewWpColorManagementSurfaceFeedbackV1(i.Context())
	const opcode = 3
	const _reqBufLen = 8 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], id.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], surface.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return id, err
}

// CreateIccCreator : make a new ICC-based image description creator object
//
// Makes a new ICC-based image description creator object with all
// properties initially unset. The client can then use the object's
// interface to define all the required properties for an image description
// and finally create a wp_image_description_v1 object.
//
// This request can be used when the compositor advertises
// wp_color_manager_v1.feature.icc_v2_v4.
// Otherwise this request raises the protocol error unsupported_feature.
func (i *WpColorManagerV1) CreateIccCreator() (*WpImageDescriptionCreatorIccV1, error) {
	obj := NewWpImageDescriptionCreatorIccV1(i.Context())
	const opcode = 4
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], obj.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return obj, err
}

// CreateParametricCreator : make a new parametric image description creator object
//
// Makes a new parametric image description creator object with all
// properties initially unset. The client can then use the object's
// interface to define all the required properties for an image description
// and finally create a wp_image_description_v1 object.
//
// This request can be used when the compositor advertises
// wp_color_manager_v1.feature.parametric.
// Otherwise this request raises the protocol error unsupported_feature.
func (i *WpColorManagerV1) CreateParametricCreator() (*WpImageDescriptionCreatorParamsV1, error) {
	obj := NewWpImageDescriptionCreatorParamsV1(i.Context())
	const opcode = 5
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], obj.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return obj, err
}

// CreateWindowsScrgb : create Windows-scRGB image description object
//
// This creates a pre-defined image description for the so-called
// Windows-scRGB stimulus encoding. This comes from the Windows 10 handling
// of its own definition of an scRGB color space for an HDR screen
// driven in BT.2100/PQ signalling mode.
//
// Windows-scRGB uses sRGB (BT.709) color primaries and white point.
// The transfer characteristic is extended linear.
//
// The nominal color channel value range is extended, meaning it includes
// negative and greater than 1.0 values. Negative values are used to
// escape the sRGB color gamut boundaries. To make use of the extended
// range, the client needs to use a pixel format that can represent those
// values, e.g. floating-point 16 bits per channel.
//
// Nominal color value R=G=B=0.0 corresponds to BT.2100/PQ system
// 0 cd/m², and R=G=B=1.0 corresponds to BT.2100/PQ system 80 cd/m².
// The maximum is R=G=B=125.0 corresponding to 10k cd/m².
//
// Windows-scRGB is displayed by Windows 10 by converting it to
// BT.2100/PQ, maintaining the CIE 1931 chromaticity and mapping the
// luminance as above. No adjustment is made to the signal to account
// for the viewing conditions.
//
// The reference white level of Windows-scRGB is unknown. If a
// reference white level must be assumed for compositor processing, it
// should be R=G=B=2.5375 corresponding to 203 cd/m² of Report ITU-R
// BT.2408-7.
//
// The target color volume of Windows-scRGB is unknown. The color gamut
// may be anything between sRGB and BT.2100.
//
// Note: EGL_EXT_gl_colorspace_scrgb_linear definition differs from
// Windows-scRGB by using R=G=B=1.0 as the reference white level, while
// Windows-scRGB reference white level is unknown or varies. However,
// it seems probable that Windows implements both
// EGL_EXT_gl_colorspace_scrgb_linear and Vulkan
// VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT as Windows-scRGB.
//
// This request can be used when the compositor advertises
// wp_color_manager_v1.feature.windows_scrgb.
// Otherwise this request raises the protocol error unsupported_feature.
//
// The resulting image description object does not allow get_information
// request. The wp_image_description_v1.ready event shall be sent.
func (i *WpColorManagerV1) CreateWindowsScrgb() (*WpImageDescriptionV1, error) {
	imageDescription := NewWpImageDescriptionV1(i.Context())
	const opcode = 6
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return imageDescription, err
}

// GetImageDescription : create an image description from a reference
//
// This request retrieves the image description backing a reference.
//
// The get_information request can be used if and only if the request that
// creates the reference allows it.
func (i *WpColorManagerV1) GetImageDescription(reference *WpImageDescriptionReferenceV1) (*WpImageDescriptionV1, error) {
	imageDescription := NewWpImageDescriptionV1(i.Context())
	const opcode = 7
	const _reqBufLen = 8 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], reference.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return imageDescription, err
}

// CreateWindowsBt2100 : create Windows-BT.2100 image description object
//
// This creates a pre-defined image description for the so-called
// Windows-BT.2100 stimulus encoding. This comes from the Windows 10
// handling of its own definition of a BT.2100 color space for an HDR
// screen driven in BT.2100/PQ signalling mode.
//
// Windows-BT.2100 uses BT.2020 color primaries and white point.
// The transfer characteristic is st2084_pq.
//
// Windows-BT.2100 is generally displayed by Windows 10 without any
// adjustments to the signal to account for viewing conditions.
//
// The reference white level of Windows-BT.2100 is unknown. If a
// reference white level must be assumed for compositor processing, it
// should be 203 cd/m² of Report ITU-R BT.2408-7.
//
// The target color volume of Windows-BT.2100 is unknown. The color gamut
// may be anything up to BT.2100.
//
// This request can be used when the compositor advertises
// wp_color_manager_v1.feature.windows_bt2100.
// Otherwise this request raises the protocol error unsupported_feature.
//
// The resulting image description object does not allow get_information
// request. The wp_image_description_v1.ready event shall be sent.
func (i *WpColorManagerV1) CreateWindowsBt2100() (*WpImageDescriptionV1, error) {
	imageDescription := NewWpImageDescriptionV1(i.Context())
	const opcode = 8
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return imageDescription, err
}

type WpColorManagerV1Error uint32

// WpColorManagerV1Error :
const (
	// WpColorManagerV1ErrorUnsupportedFeature : request not supported
	WpColorManagerV1ErrorUnsupportedFeature WpColorManagerV1Error = 0
	// WpColorManagerV1ErrorSurfaceExists : color management surface exists already
	WpColorManagerV1ErrorSurfaceExists WpColorManagerV1Error = 1
)

func (e WpColorManagerV1Error) Name() string {
	switch e {
	case WpColorManagerV1ErrorUnsupportedFeature:
		return "unsupported_feature"
	case WpColorManagerV1ErrorSurfaceExists:
		return "surface_exists"
	default:
		return ""
	}
}

func (e WpColorManagerV1Error) Value() string {
	switch e {
	case WpColorManagerV1ErrorUnsupportedFeature:
		return "0"
	case WpColorManagerV1ErrorSurfaceExists:
		return "1"
	default:
		return ""
	}
}

func (e WpColorManagerV1Error) String() string {
	return e.Name() + "=" + e.Value()
}

type WpColorManagerV1RenderIntent uint32

// WpColorManagerV1RenderIntent : rendering intents
//
// See the ICC.1:2022 specification from the International Color Consortium
// for more details about rendering intents.
//
// The principles of ICC defined rendering intents apply with all types of
// image descriptions, not only those with ICC file profiles.
//
// Compositors must support the perceptual rendering intent. Other
// rendering intents are optional.
const (
	// WpColorManagerV1RenderIntentPerceptual : perceptual
	WpColorManagerV1RenderIntentPerceptual WpColorManagerV1RenderIntent = 0
	// WpColorManagerV1RenderIntentRelative : media-relative colorimetric
	WpColorManagerV1RenderIntentRelative WpColorManagerV1RenderIntent = 1
	// WpColorManagerV1RenderIntentSaturation : saturation
	WpColorManagerV1RenderIntentSaturation WpColorManagerV1RenderIntent = 2
	// WpColorManagerV1RenderIntentAbsolute : ICC-absolute colorimetric
	WpColorManagerV1RenderIntentAbsolute WpColorManagerV1RenderIntent = 3
	// WpColorManagerV1RenderIntentRelativeBpc : media-relative colorimetric + black point compensation
	WpColorManagerV1RenderIntentRelativeBpc          WpColorManagerV1RenderIntent = 4
	WpColorManagerV1RenderIntentAbsoluteNoAdaptation WpColorManagerV1RenderIntent = 5
)

func (e WpColorManagerV1RenderIntent) Name() string {
	switch e {
	case WpColorManagerV1RenderIntentPerceptual:
		return "perceptual"
	case WpColorManagerV1RenderIntentRelative:
		return "relative"
	case WpColorManagerV1RenderIntentSaturation:
		return "saturation"
	case WpColorManagerV1RenderIntentAbsolute:
		return "absolute"
	case WpColorManagerV1RenderIntentRelativeBpc:
		return "relative_bpc"
	case WpColorManagerV1RenderIntentAbsoluteNoAdaptation:
		return "absolute_no_adaptation"
	default:
		return ""
	}
}

func (e WpColorManagerV1RenderIntent) Value() string {
	switch e {
	case WpColorManagerV1RenderIntentPerceptual:
		return "0"
	case WpColorManagerV1RenderIntentRelative:
		return "1"
	case WpColorManagerV1RenderIntentSaturation:
		return "2"
	case WpColorManagerV1RenderIntentAbsolute:
		return "3"
	case WpColorManagerV1RenderIntentRelativeBpc:
		return "4"
	case WpColorManagerV1RenderIntentAbsoluteNoAdaptation:
		return "5"
	default:
		return ""
	}
}

func (e WpColorManagerV1RenderIntent) String() string {
	return e.Name() + "=" + e.Value()
}

type WpColorManagerV1Feature uint32

// WpColorManagerV1Feature : compositor supported features
const (
	// WpColorManagerV1FeatureIccV2V4 : create_icc_creator request
	WpColorManagerV1FeatureIccV2V4 WpColorManagerV1Feature = 0
	// WpColorManagerV1FeatureParametric : create_parametric_creator request
	WpColorManagerV1FeatureParametric WpColorManagerV1Feature = 1
	// WpColorManagerV1FeatureSetPrimaries : parametric set_primaries request
	WpColorManagerV1FeatureSetPrimaries WpColorManagerV1Feature = 2
	// WpColorManagerV1FeatureSetTfPower : parametric set_tf_power request
	WpColorManagerV1FeatureSetTfPower WpColorManagerV1Feature = 3
	// WpColorManagerV1FeatureSetLuminances : parametric set_luminances request
	WpColorManagerV1FeatureSetLuminances                WpColorManagerV1Feature = 4
	WpColorManagerV1FeatureSetMasteringDisplayPrimaries WpColorManagerV1Feature = 5
	WpColorManagerV1FeatureExtendedTargetVolume         WpColorManagerV1Feature = 6
	// WpColorManagerV1FeatureWindowsScrgb : create_windows_scrgb request
	WpColorManagerV1FeatureWindowsScrgb WpColorManagerV1Feature = 7
	// WpColorManagerV1FeatureWindowsBt2100 : create_windows_bt2100 request
	WpColorManagerV1FeatureWindowsBt2100 WpColorManagerV1Feature = 8
)

func (e WpColorManagerV1Feature) Name() string {
	switch e {
	case WpColorManagerV1FeatureIccV2V4:
		return "icc_v2_v4"
	case WpColorManagerV1FeatureParametric:
		return "parametric"
	case WpColorManagerV1FeatureSetPrimaries:
		return "set_primaries"
	case WpColorManagerV1FeatureSetTfPower:
		return "set_tf_power"
	case WpColorManagerV1FeatureSetLuminances:
		return "set_luminances"
	case WpColorManagerV1FeatureSetMasteringDisplayPrimaries:
		return "set_mastering_display_primaries"
	case WpColorManagerV1FeatureExtendedTargetVolume:
		return "extended_target_volume"
	case WpColorManagerV1FeatureWindowsScrgb:
		return "windows_scrgb"
	case WpColorManagerV1FeatureWindowsBt2100:
		return "windows_bt2100"
	default:
		return ""
	}
}

func (e WpColorManagerV1Feature) Value() string {
	switch e {
	case WpColorManagerV1FeatureIccV2V4:
		return "0"
	case WpColorManagerV1FeatureParametric:
		return "1"
	case WpColorManagerV1FeatureSetPrimaries:
		return "2"
	case WpColorManagerV1FeatureSetTfPower:
		return "3"
	case WpColorManagerV1FeatureSetLuminances:
		return "4"
	case WpColorManagerV1FeatureSetMasteringDisplayPrimaries:
		return "5"
	case WpColorManagerV1FeatureExtendedTargetVolume:
		return "6"
	case WpColorManagerV1FeatureWindowsScrgb:
		return "7"
	case WpColorManagerV1FeatureWindowsBt2100:
		return "8"
	default:
		return ""
	}
}

func (e WpColorManagerV1Feature) String() string {
	return e.Name() + "=" + e.Value()
}

type WpColorManagerV1Primaries uint32

// WpColorManagerV1Primaries : named color primaries
//
// Named color primaries used to encode well-known sets of primaries.
//
// A value of 0 is invalid and will never be present in the list of enums.
const (
	WpColorManagerV1PrimariesSrgb        WpColorManagerV1Primaries = 1
	WpColorManagerV1PrimariesPalM        WpColorManagerV1Primaries = 2
	WpColorManagerV1PrimariesPal         WpColorManagerV1Primaries = 3
	WpColorManagerV1PrimariesNtsc        WpColorManagerV1Primaries = 4
	WpColorManagerV1PrimariesGenericFilm WpColorManagerV1Primaries = 5
	WpColorManagerV1PrimariesBt2020      WpColorManagerV1Primaries = 6
	WpColorManagerV1PrimariesCie1931Xyz  WpColorManagerV1Primaries = 7
	WpColorManagerV1PrimariesDciP3       WpColorManagerV1Primaries = 8
	WpColorManagerV1PrimariesDisplayP3   WpColorManagerV1Primaries = 9
	WpColorManagerV1PrimariesAdobeRgb    WpColorManagerV1Primaries = 10
)

func (e WpColorManagerV1Primaries) Name() string {
	switch e {
	case WpColorManagerV1PrimariesSrgb:
		return "srgb"
	case WpColorManagerV1PrimariesPalM:
		return "pal_m"
	case WpColorManagerV1PrimariesPal:
		return "pal"
	case WpColorManagerV1PrimariesNtsc:
		return "ntsc"
	case WpColorManagerV1PrimariesGenericFilm:
		return "generic_film"
	case WpColorManagerV1PrimariesBt2020:
		return "bt2020"
	case WpColorManagerV1PrimariesCie1931Xyz:
		return "cie1931_xyz"
	case WpColorManagerV1PrimariesDciP3:
		return "dci_p3"
	case WpColorManagerV1PrimariesDisplayP3:
		return "display_p3"
	case WpColorManagerV1PrimariesAdobeRgb:
		return "adobe_rgb"
	default:
		return ""
	}
}

func (e WpColorManagerV1Primaries) Value() string {
	switch e {
	case WpColorManagerV1PrimariesSrgb:
		return "1"
	case WpColorManagerV1PrimariesPalM:
		return "2"
	case WpColorManagerV1PrimariesPal:
		return "3"
	case WpColorManagerV1PrimariesNtsc:
		return "4"
	case WpColorManagerV1PrimariesGenericFilm:
		return "5"
	case WpColorManagerV1PrimariesBt2020:
		return "6"
	case WpColorManagerV1PrimariesCie1931Xyz:
		return "7"
	case WpColorManagerV1PrimariesDciP3:
		return "8"
	case WpColorManagerV1PrimariesDisplayP3:
		return "9"
	case WpColorManagerV1PrimariesAdobeRgb:
		return "10"
	default:
		return ""
	}
}

func (e WpColorManagerV1Primaries) String() string {
	return e.Name() + "=" + e.Value()
}

type WpColorManagerV1TransferFunction uint32

// WpColorManagerV1TransferFunction : named transfer functions
//
// Named transfer functions used to represent well-known transfer
// characteristics of displays.
//
// A value of 0 is invalid and will never be present in the list of enums.
//
// See appendix.md for the formulae.
const (
	WpColorManagerV1TransferFunctionBt1886          WpColorManagerV1TransferFunction = 1
	WpColorManagerV1TransferFunctionGamma22         WpColorManagerV1TransferFunction = 2
	WpColorManagerV1TransferFunctionGamma28         WpColorManagerV1TransferFunction = 3
	WpColorManagerV1TransferFunctionSt240           WpColorManagerV1TransferFunction = 4
	WpColorManagerV1TransferFunctionExtLinear       WpColorManagerV1TransferFunction = 5
	WpColorManagerV1TransferFunctionLog100          WpColorManagerV1TransferFunction = 6
	WpColorManagerV1TransferFunctionLog316          WpColorManagerV1TransferFunction = 7
	WpColorManagerV1TransferFunctionXvycc           WpColorManagerV1TransferFunction = 8
	WpColorManagerV1TransferFunctionSrgb            WpColorManagerV1TransferFunction = 9
	WpColorManagerV1TransferFunctionExtSrgb         WpColorManagerV1TransferFunction = 10
	WpColorManagerV1TransferFunctionSt2084Pq        WpColorManagerV1TransferFunction = 11
	WpColorManagerV1TransferFunctionSt428           WpColorManagerV1TransferFunction = 12
	WpColorManagerV1TransferFunctionHlg             WpColorManagerV1TransferFunction = 13
	WpColorManagerV1TransferFunctionCompoundPower24 WpColorManagerV1TransferFunction = 14
)

func (e WpColorManagerV1TransferFunction) Name() string {
	switch e {
	case WpColorManagerV1TransferFunctionBt1886:
		return "bt1886"
	case WpColorManagerV1TransferFunctionGamma22:
		return "gamma22"
	case WpColorManagerV1TransferFunctionGamma28:
		return "gamma28"
	case WpColorManagerV1TransferFunctionSt240:
		return "st240"
	case WpColorManagerV1TransferFunctionExtLinear:
		return "ext_linear"
	case WpColorManagerV1TransferFunctionLog100:
		return "log_100"
	case WpColorManagerV1TransferFunctionLog316:
		return "log_316"
	case WpColorManagerV1TransferFunctionXvycc:
		return "xvycc"
	case WpColorManagerV1TransferFunctionSrgb:
		return "srgb"
	case WpColorManagerV1TransferFunctionExtSrgb:
		return "ext_srgb"
	case WpColorManagerV1TransferFunctionSt2084Pq:
		return "st2084_pq"
	case WpColorManagerV1TransferFunctionSt428:
		return "st428"
	case WpColorManagerV1TransferFunctionHlg:
		return "hlg"
	case WpColorManagerV1TransferFunctionCompoundPower24:
		return "compound_power_2_4"
	default:
		return ""
	}
}

func (e WpColorManagerV1TransferFunction) Value() string {
	switch e {
	case WpColorManagerV1TransferFunctionBt1886:
		return "1"
	case WpColorManagerV1TransferFunctionGamma22:
		return "2"
	case WpColorManagerV1TransferFunctionGamma28:
		return "3"
	case WpColorManagerV1TransferFunctionSt240:
		return "4"
	case WpColorManagerV1TransferFunctionExtLinear:
		return "5"
	case WpColorManagerV1TransferFunctionLog100:
		return "6"
	case WpColorManagerV1TransferFunctionLog316:
		return "7"
	case WpColorManagerV1TransferFunctionXvycc:
		return "8"
	case WpColorManagerV1TransferFunctionSrgb:
		return "9"
	case WpColorManagerV1TransferFunctionExtSrgb:
		return "10"
	case WpColorManagerV1TransferFunctionSt2084Pq:
		return "11"
	case WpColorManagerV1TransferFunctionSt428:
		return "12"
	case WpColorManagerV1TransferFunctionHlg:
		return "13"
	case WpColorManagerV1TransferFunctionCompoundPower24:
		return "14"
	default:
		return ""
	}
}

func (e WpColorManagerV1TransferFunction) String() string {
	return e.Name() + "=" + e.Value()
}

// WpColorManagerV1SupportedIntentEvent : supported rendering intent
//
// When this object is created, it shall immediately send this event once
// for each rendering intent the compositor supports.
//
// A compositor must not advertise intents that are deprecated in the
// bound version of the interface.
type WpColorManagerV1SupportedIntentEvent struct {
	RenderIntent uint32
}
type WpColorManagerV1SupportedIntentHandlerFunc func(WpColorManagerV1SupportedIntentEvent)

// SetSupportedIntentHandler : sets handler for WpColorManagerV1SupportedIntentEvent
func (i *WpColorManagerV1) SetSupportedIntentHandler(f WpColorManagerV1SupportedIntentHandlerFunc) {
	i.supportedIntentHandler = f
}

// WpColorManagerV1SupportedFeatureEvent : supported features
//
// When this object is created, it shall immediately send this event once
// for each compositor supported feature listed in the enumeration.
//
// A compositor must not advertise features that are deprecated in the
// bound version of the interface.
type WpColorManagerV1SupportedFeatureEvent struct {
	Feature uint32
}
type WpColorManagerV1SupportedFeatureHandlerFunc func(WpColorManagerV1SupportedFeatureEvent)

// SetSupportedFeatureHandler : sets handler for WpColorManagerV1SupportedFeatureEvent
func (i *WpColorManagerV1) SetSupportedFeatureHandler(f WpColorManagerV1SupportedFeatureHandlerFunc) {
	i.supportedFeatureHandler = f
}

// WpColorManagerV1SupportedTfNamedEvent : supported named transfer characteristic
//
// When this object is created, it shall immediately send this event once
// for each named transfer function the compositor supports with the
// parametric image description creator.
//
// A compositor must not advertise transfer functions that are deprecated
// in the bound version of the interface.
type WpColorManagerV1SupportedTfNamedEvent struct {
	Tf uint32
}
type WpColorManagerV1SupportedTfNamedHandlerFunc func(WpColorManagerV1SupportedTfNamedEvent)

// SetSupportedTfNamedHandler : sets handler for WpColorManagerV1SupportedTfNamedEvent
func (i *WpColorManagerV1) SetSupportedTfNamedHandler(f WpColorManagerV1SupportedTfNamedHandlerFunc) {
	i.supportedTfNamedHandler = f
}

// WpColorManagerV1SupportedPrimariesNamedEvent : supported named primaries
//
// When this object is created, it shall immediately send this event once
// for each named set of primaries the compositor supports with the
// parametric image description creator.
//
// A compositor must not advertise names that are deprecated in the
// bound version of the interface.
type WpColorManagerV1SupportedPrimariesNamedEvent struct {
	Primaries uint32
}
type WpColorManagerV1SupportedPrimariesNamedHandlerFunc func(WpColorManagerV1SupportedPrimariesNamedEvent)

// SetSupportedPrimariesNamedHandler : sets handler for WpColorManagerV1SupportedPrimariesNamedEvent
func (i *WpColorManagerV1) SetSupportedPrimariesNamedHandler(f WpColorManagerV1SupportedPrimariesNamedHandlerFunc) {
	i.supportedPrimariesNamedHandler = f
}

// WpColorManagerV1DoneEvent : all features have been sent
//
// This event is sent when all supported rendering intents, features,
// transfer functions and named primaries have been sent.
type WpColorManagerV1DoneEvent struct{}
type WpColorManagerV1DoneHandlerFunc func(WpColorManagerV1DoneEvent)

// SetDoneHandler : sets handler for WpColorManagerV1DoneEvent
func (i *WpColorManagerV1) SetDoneHandler(f WpColorManagerV1DoneHandlerFunc) {
	i.doneHandler = f
}

func (i *WpColorManagerV1) Dispatch(opcode uint32, fd int, data []byte) {
	switch opcode {
	case 0:
		if i.supportedIntentHandler == nil {
			return
		}
		var e WpColorManagerV1SupportedIntentEvent
		l := 0
		e.RenderIntent = client.Uint32(data[l : l+4])
		l += 4

		i.supportedIntentHandler(e)
	case 1:
		if i.supportedFeatureHandler == nil {
			return
		}
		var e WpColorManagerV1SupportedFeatureEvent
		l := 0
		e.Feature = client.Uint32(data[l : l+4])
		l += 4

		i.supportedFeatureHandler(e)
	case 2:
		if i.supportedTfNamedHandler == nil {
			return
		}
		var e WpColorManagerV1SupportedTfNamedEvent
		l := 0
		e.Tf = client.Uint32(data[l : l+4])
		l += 4

		i.supportedTfNamedHandler(e)
	case 3:
		if i.supportedPrimariesNamedHandler == nil {
			return
		}
		var e WpColorManagerV1SupportedPrimariesNamedEvent
		l := 0
		e.Primaries = client.Uint32(data[l : l+4])
		l += 4

		i.supportedPrimariesNamedHandler(e)
	case 4:
		if i.doneHandler == nil {
			return
		}
		var e WpColorManagerV1DoneEvent

		i.doneHandler(e)
	}
}

// WpColorManagementOutputV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpColorManagementOutputV1InterfaceName = "wp_color_management_output_v1"

// WpColorManagementOutputV1 : output color properties
//
// A wp_color_management_output_v1 describes the color properties of an
// output.
//
// The wp_color_management_output_v1 is associated with the wl_output global
// underlying the wl_output object. Therefore the client destroying the
// wl_output object has no impact, but the compositor removing the output
// global makes the wp_color_management_output_v1 object inert.
type WpColorManagementOutputV1 struct {
	client.BaseProxy
	imageDescriptionChangedHandler WpColorManagementOutputV1ImageDescriptionChangedHandlerFunc
}

// NewWpColorManagementOutputV1 : output color properties
//
// A wp_color_management_output_v1 describes the color properties of an
// output.
//
// The wp_color_management_output_v1 is associated with the wl_output global
// underlying the wl_output object. Therefore the client destroying the
// wl_output object has no impact, but the compositor removing the output
// global makes the wp_color_management_output_v1 object inert.
func NewWpColorManagementOutputV1(ctx *client.Context) *WpColorManagementOutputV1 {
	wpColorManagementOutputV1 := &WpColorManagementOutputV1{}
	ctx.Register(wpColorManagementOutputV1)
	return wpColorManagementOutputV1
}

// Destroy : destroy the color management output
//
// Destroy the color wp_color_management_output_v1 object. This does not
// affect any remaining protocol objects.
func (i *WpColorManagementOutputV1) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 0
	const _reqBufLen = 8
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// GetImageDescription : get the image description of the output
//
// This creates a new wp_image_description_v1 object for the current image
// description of the output. There always is exactly one image description
// active for an output so the client should destroy the image description
// created by earlier invocations of this request. This request is usually
// sent as a reaction to the image_description_changed event or when
// creating a wp_color_management_output_v1 object.
//
// The image description of an output represents the color encoding the
// output expects. There might be performance and power advantages, as well
// as improved color reproduction, if a content update matches the image
// description of the output it is being shown on. If a content update is
// shown on any other output than the one it matches the image description
// of, then the color reproduction on those outputs might be considerably
// worse.
//
// The created wp_image_description_v1 object preserves the image
// description of the output from the time the object was created.
//
// The resulting image description object allows get_information request.
//
// If this protocol object is inert, the resulting image description object
// shall immediately deliver the wp_image_description_v1.failed event with
// the no_output cause.
//
// If the interface version is inadequate for the output's image
// description, meaning that the client does not support all the events
// needed to deliver the crucial information, the resulting image
// description object shall immediately deliver the
// wp_image_description_v1.failed event with the low_version cause.
//
// Otherwise the object shall immediately deliver the ready event.
func (i *WpColorManagementOutputV1) GetImageDescription() (*WpImageDescriptionV1, error) {
	imageDescription := NewWpImageDescriptionV1(i.Context())
	const opcode = 1
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return imageDescription, err
}

// WpColorManagementOutputV1ImageDescriptionChangedEvent : image description changed
//
// This event is sent whenever the image description of the output changed,
// followed by one wl_output.done event common to output events across all
// extensions.
//
// If the client wants to use the updated image description, it needs to do
// get_image_description again, because image description objects are
// immutable.
type WpColorManagementOutputV1ImageDescriptionChangedEvent struct{}
type WpColorManagementOutputV1ImageDescriptionChangedHandlerFunc func(WpColorManagementOutputV1ImageDescriptionChangedEvent)

// SetImageDescriptionChangedHandler : sets handler for WpColorManagementOutputV1ImageDescriptionChangedEvent
func (i *WpColorManagementOutputV1) SetImageDescriptionChangedHandler(f WpColorManagementOutputV1ImageDescriptionChangedHandlerFunc) {
	i.imageDescriptionChangedHandler = f
}

func (i *WpColorManagementOutputV1) Dispatch(opcode uint32, fd int, data []byte) {
	switch opcode {
	case 0:
		if i.imageDescriptionChangedHandler == nil {
			return
		}
		var e WpColorManagementOutputV1ImageDescriptionChangedEvent

		i.imageDescriptionChangedHandler(e)
	}
}

// WpColorManagementSurfaceV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpColorManagementSurfaceV1InterfaceName = "wp_color_management_surface_v1"

// WpColorManagementSurfaceV1 : color management extension to a surface
//
// A wp_color_management_surface_v1 allows the client to set the color
// space and HDR properties of a surface.
//
// If the wl_surface associated with the wp_color_management_surface_v1 is
// destroyed, the wp_color_management_surface_v1 object becomes inert.
type WpColorManagementSurfaceV1 struct {
	client.BaseProxy
}

// NewWpColorManagementSurfaceV1 : color management extension to a surface
//
// A wp_color_management_surface_v1 allows the client to set the color
// space and HDR properties of a surface.
//
// If the wl_surface associated with the wp_color_management_surface_v1 is
// destroyed, the wp_color_management_surface_v1 object becomes inert.
func NewWpColorManagementSurfaceV1(ctx *client.Context) *WpColorManagementSurfaceV1 {
	wpColorManagementSurfaceV1 := &WpColorManagementSurfaceV1{}
	ctx.Register(wpColorManagementSurfaceV1)
	return wpColorManagementSurfaceV1
}

// Destroy : destroy the color management interface for a surface
//
// Destroy the wp_color_management_surface_v1 object and do the same as
// unset_image_description.
func (i *WpColorManagementSurfaceV1) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 0
	const _reqBufLen = 8
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetImageDescription : set the surface image description
//
// If this protocol object is inert, the protocol error inert is raised.
//
// Set the image description of the underlying surface. The image
// description and rendering intent are double-buffered state, see
// wl_surface.commit.
//
// It is the client's responsibility to understand the image description
// it sets on a surface, and to provide content that matches that image
// description. Compositors might convert images to match their own or any
// other image descriptions.
//
// Image descriptions which are not ready (see wp_image_description_v1)
// are forbidden in this request, and in such case the protocol error
// image_description is raised.
//
// All image descriptions which are ready (see wp_image_description_v1)
// are allowed and must always be accepted by the compositor.
//
// When an image description is set on a surface, it establishes an
// explicit link between surface pixel values and surface colorimetry.
// This link may be undefined for some pixel values, see the image
// description creator interfaces for the conditions. Non-finite
// floating-point values (NaN, Inf) always have an undefined colorimetry.
//
// A rendering intent provides the client's preference on how surface
// colorimetry should be mapped to each output. The render_intent value
// must be one advertised by the compositor with
// wp_color_manager_v1.render_intent event, otherwise the protocol error
// render_intent is raised.
//
// By default, a surface does not have an associated image description
// nor a rendering intent. The handling of color on such surfaces is
// compositor implementation defined. Compositors should handle such
// surfaces as sRGB, but may handle them differently if they have specific
// requirements.
//
// Setting the image description has copy semantics; after this request,
// the image description can be immediately destroyed without affecting
// the pending state of the surface.
//
//	renderIntent: rendering intent
func (i *WpColorManagementSurfaceV1) SetImageDescription(imageDescription *WpImageDescriptionV1, renderIntent uint32) error {
	const opcode = 1
	const _reqBufLen = 8 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(renderIntent))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// UnsetImageDescription : remove the surface image description
//
// If this protocol object is inert, the protocol error inert is raised.
//
// This request removes any image description from the surface. See
// set_image_description for how a compositor handles a surface without
// an image description. This is double-buffered state, see
// wl_surface.commit.
func (i *WpColorManagementSurfaceV1) UnsetImageDescription() error {
	const opcode = 2
	const _reqBufLen = 8
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

type WpColorManagementSurfaceV1Error uint32

// WpColorManagementSurfaceV1Error : protocol errors
const (
	// WpColorManagementSurfaceV1ErrorRenderIntent : unsupported rendering intent
	WpColorManagementSurfaceV1ErrorRenderIntent WpColorManagementSurfaceV1Error = 0
	// WpColorManagementSurfaceV1ErrorImageDescription : invalid image description
	WpColorManagementSurfaceV1ErrorImageDescription WpColorManagementSurfaceV1Error = 1
	// WpColorManagementSurfaceV1ErrorInert : forbidden request on inert object
	WpColorManagementSurfaceV1ErrorInert WpColorManagementSurfaceV1Error = 2
)

func (e WpColorManagementSurfaceV1Error) Name() string {
	switch e {
	case WpColorManagementSurfaceV1ErrorRenderIntent:
		return "render_intent"
	case WpColorManagementSurfaceV1ErrorImageDescription:
		return "image_description"
	case WpColorManagementSurfaceV1ErrorInert:
		return "inert"
	default:
		return ""
	}
}

func (e WpColorManagementSurfaceV1Error) Value() string {
	switch e {
	case WpColorManagementSurfaceV1ErrorRenderIntent:
		return "0"
	case WpColorManagementSurfaceV1ErrorImageDescription:
		return "1"
	case WpColorManagementSurfaceV1ErrorInert:
		return "2"
	default:
		return ""
	}
}

func (e WpColorManagementSurfaceV1Error) String() string {
	return e.Name() + "=" + e.Value()
}

// WpColorManagementSurfaceFeedbackV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpColorManagementSurfaceFeedbackV1InterfaceName = "wp_color_management_surface_feedback_v1"

// WpColorManagementSurfaceFeedbackV1 : color management extension to a surface
//
// A wp_color_management_surface_feedback_v1 allows the client to get the
// preferred image description of a surface.
//
// If the wl_surface associated with this object is destroyed, the
// wp_color_management_surface_feedback_v1 object becomes inert.
type WpColorManagementSurfaceFeedbackV1 struct {
	client.BaseProxy
	preferredChangedHandler  WpColorManagementSurfaceFeedbackV1PreferredChangedHandlerFunc
	preferredChanged2Handler WpColorManagementSurfaceFeedbackV1PreferredChanged2HandlerFunc
}

// NewWpColorManagementSurfaceFeedbackV1 : color management extension to a surface
//
// A wp_color_management_surface_feedback_v1 allows the client to get the
// preferred image description of a surface.
//
// If the wl_surface associated with this object is destroyed, the
// wp_color_management_surface_feedback_v1 object becomes inert.
func NewWpColorManagementSurfaceFeedbackV1(ctx *client.Context) *WpColorManagementSurfaceFeedbackV1 {
	wpColorManagementSurfaceFeedbackV1 := &WpColorManagementSurfaceFeedbackV1{}
	ctx.Register(wpColorManagementSurfaceFeedbackV1)
	return wpColorManagementSurfaceFeedbackV1
}

// Destroy : destroy the color management interface for a surface
//
// Destroy the wp_color_management_surface_feedback_v1 object.
func (i *WpColorManagementSurfaceFeedbackV1) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 0
	const _reqBufLen = 8
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// GetPreferred : get the preferred image description
//
// If this protocol object is inert, the protocol error inert is raised.
//
// The preferred image description represents the compositor's preferred
// color encoding for this wl_surface at the current time. There might be
// performance and power advantages, as well as improved color
// reproduction, if the image description of a content update matches the
// preferred image description.
//
// This creates a new wp_image_description_v1 object for the currently
// preferred image description for the wl_surface. The client should
// stop using and destroy the image descriptions created by earlier
// invocations of this request for the associated wl_surface.
// This request is usually sent as a reaction to the preferred_changed
// event or when creating a wp_color_management_surface_feedback_v1 object
// if the client is capable of adapting to image descriptions.
//
// The created wp_image_description_v1 object preserves the preferred image
// description of the wl_surface from the time the object was created.
//
// The resulting image description object allows get_information request.
//
// If the image description is parametric, the client should set it on its
// wl_surface only if the image description is an exact match with the
// client content. Particularly if everything else matches, but the target
// color volume is greater than what the client needs, the client should
// create its own parameric image description with its exact parameters.
//
// If the interface version is inadequate for the preferred image
// description, meaning that the client does not support all the
// events needed to deliver the crucial information, the resulting image
// description object shall immediately deliver the
// wp_image_description_v1.failed event with the low_version cause,
// otherwise the object shall immediately deliver the ready event.
func (i *WpColorManagementSurfaceFeedbackV1) GetPreferred() (*WpImageDescriptionV1, error) {
	imageDescription := NewWpImageDescriptionV1(i.Context())
	const opcode = 1
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return imageDescription, err
}

// GetPreferredParametric : get the preferred image description
//
// The same description as for get_preferred applies, except the returned
// image description is guaranteed to be parametric. This is meant for
// clients that can only deal with parametric image descriptions.
//
// If the compositor doesn't support parametric image descriptions, the
// unsupported_feature error is emitted.
func (i *WpColorManagementSurfaceFeedbackV1) GetPreferredParametric() (*WpImageDescriptionV1, error) {
	imageDescription := NewWpImageDescriptionV1(i.Context())
	const opcode = 2
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return imageDescription, err
}

type WpColorManagementSurfaceFeedbackV1Error uint32

// WpColorManagementSurfaceFeedbackV1Error : protocol errors
const (
	// WpColorManagementSurfaceFeedbackV1ErrorInert : forbidden request on inert object
	WpColorManagementSurfaceFeedbackV1ErrorInert WpColorManagementSurfaceFeedbackV1Error = 0
	// WpColorManagementSurfaceFeedbackV1ErrorUnsupportedFeature : attempted to use an unsupported feature
	WpColorManagementSurfaceFeedbackV1ErrorUnsupportedFeature WpColorManagementSurfaceFeedbackV1Error = 1
)

func (e WpColorManagementSurfaceFeedbackV1Error) Name() string {
	switch e {
	case WpColorManagementSurfaceFeedbackV1ErrorInert:
		return "inert"
	case WpColorManagementSurfaceFeedbackV1ErrorUnsupportedFeature:
		return "unsupported_feature"
	default:
		return ""
	}
}

func (e WpColorManagementSurfaceFeedbackV1Error) Value() string {
	switch e {
	case WpColorManagementSurfaceFeedbackV1ErrorInert:
		return "0"
	case WpColorManagementSurfaceFeedbackV1ErrorUnsupportedFeature:
		return "1"
	default:
		return ""
	}
}

func (e WpColorManagementSurfaceFeedbackV1Error) String() string {
	return e.Name() + "=" + e.Value()
}

// WpColorManagementSurfaceFeedbackV1PreferredChangedEvent : the preferred image description changed (32-bit)
//
// Starting from interface version 2, 'preferred_changed2' is sent instead
// of this event. See the 'preferred_changed2' event for the definition.
type WpColorManagementSurfaceFeedbackV1PreferredChangedEvent struct {
	Identity uint32
}
type WpColorManagementSurfaceFeedbackV1PreferredChangedHandlerFunc func(WpColorManagementSurfaceFeedbackV1PreferredChangedEvent)

// SetPreferredChangedHandler : sets handler for WpColorManagementSurfaceFeedbackV1PreferredChangedEvent
func (i *WpColorManagementSurfaceFeedbackV1) SetPreferredChangedHandler(f WpColorManagementSurfaceFeedbackV1PreferredChangedHandlerFunc) {
	i.preferredChangedHandler = f
}

// WpColorManagementSurfaceFeedbackV1PreferredChanged2Event : the preferred image description changed
//
// The preferred image description is the one which likely has the most
// performance and/or quality benefits for the compositor if used by the
// client for its wl_surface contents. This event is sent whenever the
// compositor changes the wl_surface's preferred image description.
//
// This event sends the identity of the new preferred state as the argument,
// so clients who are aware of the image description already can reuse it.
// Otherwise, if the client client wants to know what the preferred image
// description is, it shall use the get_preferred request.
//
// The preferred image description is not automatically used for anything.
// It is only a hint, and clients may set any valid image description with
// set_image_description, but there might be performance and color accuracy
// improvements by providing the wl_surface contents in the preferred
// image description. Therefore clients that can, should render according
// to the preferred image description
type WpColorManagementSurfaceFeedbackV1PreferredChanged2Event struct {
	IdentityHi uint32
	IdentityLo uint32
}
type WpColorManagementSurfaceFeedbackV1PreferredChanged2HandlerFunc func(WpColorManagementSurfaceFeedbackV1PreferredChanged2Event)

// SetPreferredChanged2Handler : sets handler for WpColorManagementSurfaceFeedbackV1PreferredChanged2Event
func (i *WpColorManagementSurfaceFeedbackV1) SetPreferredChanged2Handler(f WpColorManagementSurfaceFeedbackV1PreferredChanged2HandlerFunc) {
	i.preferredChanged2Handler = f
}

func (i *WpColorManagementSurfaceFeedbackV1) Dispatch(opcode uint32, fd int, data []byte) {
	switch opcode {
	case 0:
		if i.preferredChangedHandler == nil {
			return
		}
		var e WpColorManagementSurfaceFeedbackV1PreferredChangedEvent
		l := 0
		e.Identity = client.Uint32(data[l : l+4])
		l += 4

		i.preferredChangedHandler(e)
	case 1:
		if i.preferredChanged2Handler == nil {
			return
		}
		var e WpColorManagementSurfaceFeedbackV1PreferredChanged2Event
		l := 0
		e.IdentityHi = client.Uint32(data[l : l+4])
		l += 4
		e.IdentityLo = client.Uint32(data[l : l+4])
		l += 4

		i.preferredChanged2Handler(e)
	}
}

// WpImageDescriptionCreatorIccV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpImageDescriptionCreatorIccV1InterfaceName = "wp_image_description_creator_icc_v1"

// WpImageDescriptionCreatorIccV1 : holder of image description ICC information
//
// This type of object is used for collecting all the information required
// to create a wp_image_description_v1 object from an ICC file. A complete
// set of required parameters consists of these properties:
// - ICC file
//
// Each required property must be set exactly once if the client is to create
// an image description. The set requests verify that a property was not
// already set. The create request verifies that all required properties are
// set. There may be several alternative requests for setting each property,
// and in that case the client must choose one of them.
//
// Once all properties have been set, the create request must be used to
// create the image description object, destroying the creator in the
// process.
//
// The link between a pixel value (a device value in ICC) and its respective
// colorimetry is defined by the details of the particular ICC profile.
// Those details also determine when colorimetry becomes undefined.
type WpImageDescriptionCreatorIccV1 struct {
	client.BaseProxy
}

// NewWpImageDescriptionCreatorIccV1 : holder of image description ICC information
//
// This type of object is used for collecting all the information required
// to create a wp_image_description_v1 object from an ICC file. A complete
// set of required parameters consists of these properties:
// - ICC file
//
// Each required property must be set exactly once if the client is to create
// an image description. The set requests verify that a property was not
// already set. The create request verifies that all required properties are
// set. There may be several alternative requests for setting each property,
// and in that case the client must choose one of them.
//
// Once all properties have been set, the create request must be used to
// create the image description object, destroying the creator in the
// process.
//
// The link between a pixel value (a device value in ICC) and its respective
// colorimetry is defined by the details of the particular ICC profile.
// Those details also determine when colorimetry becomes undefined.
func NewWpImageDescriptionCreatorIccV1(ctx *client.Context) *WpImageDescriptionCreatorIccV1 {
	wpImageDescriptionCreatorIccV1 := &WpImageDescriptionCreatorIccV1{}
	ctx.Register(wpImageDescriptionCreatorIccV1)
	return wpImageDescriptionCreatorIccV1
}

// Create : Create the image description object from ICC data
//
// Create an image description object based on the ICC information
// previously set on this object. A compositor must parse the ICC data in
// some undefined but finite amount of time.
//
// The completeness of the parameter set is verified. If the set is not
// complete, the protocol error incomplete_set is raised. For the
// definition of a complete set, see the description of this interface.
//
// If the particular combination of the information is not supported
// by the compositor, the resulting image description object shall
// immediately deliver the wp_image_description_v1.failed event with the
// 'unsupported' cause. If a valid image description was created from the
// information, the wp_image_description_v1.ready event will eventually
// be sent instead.
//
// This request destroys the wp_image_description_creator_icc_v1 object.
//
// The resulting image description object does not allow get_information
// request.
func (i *WpImageDescriptionCreatorIccV1) Create() (*WpImageDescriptionV1, error) {
	defer i.Context().Unregister(i)
	imageDescription := NewWpImageDescriptionV1(i.Context())
	const opcode = 0
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return imageDescription, err
}

// SetIccFile : set the ICC profile file
//
// Sets the ICC profile file to be used as the basis of the image
// description.
//
// The data shall be found through the given fd at the given offset, having
// the given length. The fd must be seekable and readable. Violating these
// requirements raises the bad_fd protocol error.
//
// If reading the data fails due to an error independent of the client, the
// compositor shall send the wp_image_description_v1.failed event on the
// created wp_image_description_v1 with the 'operating_system' cause.
//
// The maximum size of the ICC profile is 32 MB. If length is greater than
// that or zero, the protocol error bad_size is raised. If offset + length
// exceeds the file size, the protocol error out_of_file is raised.
//
// A compositor may read the file at any time starting from this request
// and only until whichever happens first:
// - If create request was issued, the wp_image_description_v1 object
// delivers either failed or ready event; or
// - if create request was not issued, this
// wp_image_description_creator_icc_v1 object is destroyed.
//
// A compositor shall not modify the contents of the file, and the fd may
// be sealed for writes and size changes. The client must ensure to its
// best ability that the data does not change while the compositor is
// reading it.
//
// The data must represent a valid ICC profile. The ICC profile version
// must be 2 or 4, it must be a 3 channel profile and the class must be
// Display or ColorSpace. Violating these requirements will not result in a
// protocol error, but will eventually send the
// wp_image_description_v1.failed event on the created
// wp_image_description_v1 with the 'unsupported' cause.
//
// See the International Color Consortium specification ICC.1:2022 for more
// details about ICC profiles.
//
// If ICC file has already been set on this object, the protocol error
// already_set is raised.
//
//	iccProfile: ICC profile
//	offset: byte offset in fd to start of ICC data
//	length: length of ICC data in bytes
func (i *WpImageDescriptionCreatorIccV1) SetIccFile(iccProfile int, offset, length uint32) error {
	const opcode = 1
	const _reqBufLen = 8 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(offset))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(length))
	l += 4
	oob := unix.UnixRights(int(iccProfile))
	err := i.Context().WriteMsg(_reqBuf[:], oob)
	return err
}

type WpImageDescriptionCreatorIccV1Error uint32

// WpImageDescriptionCreatorIccV1Error : protocol errors
const (
	// WpImageDescriptionCreatorIccV1ErrorIncompleteSet : incomplete parameter set
	WpImageDescriptionCreatorIccV1ErrorIncompleteSet WpImageDescriptionCreatorIccV1Error = 0
	// WpImageDescriptionCreatorIccV1ErrorAlreadySet : property already set
	WpImageDescriptionCreatorIccV1ErrorAlreadySet WpImageDescriptionCreatorIccV1Error = 1
	// WpImageDescriptionCreatorIccV1ErrorBadFd : fd not seekable and readable
	WpImageDescriptionCreatorIccV1ErrorBadFd WpImageDescriptionCreatorIccV1Error = 2
	// WpImageDescriptionCreatorIccV1ErrorBadSize : no or too much data
	WpImageDescriptionCreatorIccV1ErrorBadSize WpImageDescriptionCreatorIccV1Error = 3
	// WpImageDescriptionCreatorIccV1ErrorOutOfFile : offset + length exceeds file size
	WpImageDescriptionCreatorIccV1ErrorOutOfFile WpImageDescriptionCreatorIccV1Error = 4
)

func (e WpImageDescriptionCreatorIccV1Error) Name() string {
	switch e {
	case WpImageDescriptionCreatorIccV1ErrorIncompleteSet:
		return "incomplete_set"
	case WpImageDescriptionCreatorIccV1ErrorAlreadySet:
		return "already_set"
	case WpImageDescriptionCreatorIccV1ErrorBadFd:
		return "bad_fd"
	case WpImageDescriptionCreatorIccV1ErrorBadSize:
		return "bad_size"
	case WpImageDescriptionCreatorIccV1ErrorOutOfFile:
		return "out_of_file"
	default:
		return ""
	}
}

func (e WpImageDescriptionCreatorIccV1Error) Value() string {
	switch e {
	case WpImageDescriptionCreatorIccV1ErrorIncompleteSet:
		return "0"
	case WpImageDescriptionCreatorIccV1ErrorAlreadySet:
		return "1"
	case WpImageDescriptionCreatorIccV1ErrorBadFd:
		return "2"
	case WpImageDescriptionCreatorIccV1ErrorBadSize:
		return "3"
	case WpImageDescriptionCreatorIccV1ErrorOutOfFile:
		return "4"
	default:
		return ""
	}
}

func (e WpImageDescriptionCreatorIccV1Error) String() string {
	return e.Name() + "=" + e.Value()
}

// WpImageDescriptionCreatorParamsV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpImageDescriptionCreatorParamsV1InterfaceName = "wp_image_description_creator_params_v1"

// WpImageDescriptionCreatorParamsV1 : holder of image description parameters
//
// This type of object is used for collecting all the parameters required
// to create a wp_image_description_v1 object. A complete set of required
// parameters consists of these properties:
// - transfer characteristic function (tf)
// - chromaticities of primaries and white point (primary color volume)
//
// The following properties are optional and have a well-defined default
// if not explicitly set:
// - primary color volume luminance range
// - reference white luminance level
// - mastering display primaries and white point (target color volume)
// - mastering luminance range
//
// The following properties are optional and will be ignored
// if not explicitly set:
// - maximum content light level
// - maximum frame-average light level
//
// Each required property must be set exactly once if the client is to create
// an image description. The set requests verify that a property was not
// already set. The create request verifies that all required properties are
// set. There may be several alternative requests for setting each property,
// and in that case the client must choose one of them.
//
// Once all properties have been set, the create request must be used to
// create the image description object, destroying the creator in the
// process.
//
// A viewer, who is viewing the display defined by the resulting image
// description (the viewing environment included), is assumed to be fully
// adapted to the primary color volume's white point.
//
// Any of the following conditions will cause the colorimetry of a pixel
// to become undefined:
// - Values outside of the defined range of the transfer characteristic.
// - Tristimulus that exceeds the target color volume.
// - If extended_target_volume is not supported: tristimulus that exceeds
// the primary color volume.
//
// The closest correspondence to an image description created through this
// interface is the Display class of profiles in ICC.
type WpImageDescriptionCreatorParamsV1 struct {
	client.BaseProxy
}

// NewWpImageDescriptionCreatorParamsV1 : holder of image description parameters
//
// This type of object is used for collecting all the parameters required
// to create a wp_image_description_v1 object. A complete set of required
// parameters consists of these properties:
// - transfer characteristic function (tf)
// - chromaticities of primaries and white point (primary color volume)
//
// The following properties are optional and have a well-defined default
// if not explicitly set:
// - primary color volume luminance range
// - reference white luminance level
// - mastering display primaries and white point (target color volume)
// - mastering luminance range
//
// The following properties are optional and will be ignored
// if not explicitly set:
// - maximum content light level
// - maximum frame-average light level
//
// Each required property must be set exactly once if the client is to create
// an image description. The set requests verify that a property was not
// already set. The create request verifies that all required properties are
// set. There may be several alternative requests for setting each property,
// and in that case the client must choose one of them.
//
// Once all properties have been set, the create request must be used to
// create the image description object, destroying the creator in the
// process.
//
// A viewer, who is viewing the display defined by the resulting image
// description (the viewing environment included), is assumed to be fully
// adapted to the primary color volume's white point.
//
// Any of the following conditions will cause the colorimetry of a pixel
// to become undefined:
// - Values outside of the defined range of the transfer characteristic.
// - Tristimulus that exceeds the target color volume.
// - If extended_target_volume is not supported: tristimulus that exceeds
// the primary color volume.
//
// The closest correspondence to an image description created through this
// interface is the Display class of profiles in ICC.
func NewWpImageDescriptionCreatorParamsV1(ctx *client.Context) *WpImageDescriptionCreatorParamsV1 {
	wpImageDescriptionCreatorParamsV1 := &WpImageDescriptionCreatorParamsV1{}
	ctx.Register(wpImageDescriptionCreatorParamsV1)
	return wpImageDescriptionCreatorParamsV1
}

// Create : Create the image description object using params
//
// Create an image description object based on the parameters previously
// set on this object.
//
// The completeness of the parameter set is verified. If the set is not
// complete, the protocol error incomplete_set is raised. For the
// definition of a complete set, see the description of this interface.
//
// When both max_cll and max_fall are set, max_fall must be less or equal
// to max_cll otherwise the invalid_luminance protocol error is raised.
//
// In version 1, these following conditions also result in the
// invalid_luminance protocol error. Version 2 and later do not have this
// requirement.
// - When max_cll is set, it must be greater than min L and less or equal
// to max L of the mastering luminance range.
// - When max_fall is set, it must be greater than min L and less or equal
// to max L of the mastering luminance range.
//
// If the particular combination of the parameter set is not supported
// by the compositor, the resulting image description object shall
// immediately deliver the wp_image_description_v1.failed event with the
// 'unsupported' cause. If a valid image description was created from the
// parameter set, the wp_image_description_v1.ready event will eventually
// be sent instead.
//
// This request destroys the wp_image_description_creator_params_v1
// object.
//
// The resulting image description object does not allow get_information
// request.
func (i *WpImageDescriptionCreatorParamsV1) Create() (*WpImageDescriptionV1, error) {
	defer i.Context().Unregister(i)
	imageDescription := NewWpImageDescriptionV1(i.Context())
	const opcode = 0
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], imageDescription.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return imageDescription, err
}

// SetTfNamed : named transfer characteristic
//
// Sets the transfer characteristic using explicitly enumerated named
// functions.
//
// When the resulting image description is attached to an image, the
// content should be decoded according to the industry standard
// practices for the transfer characteristic.
//
// Only names advertised with wp_color_manager_v1 event supported_tf_named
// are allowed. Other values shall raise the protocol error invalid_tf.
//
// If transfer characteristic has already been set on this object, the
// protocol error already_set is raised.
//
//	tf: named transfer function
func (i *WpImageDescriptionCreatorParamsV1) SetTfNamed(tf uint32) error {
	const opcode = 1
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(tf))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetTfPower : transfer characteristic as a power curve
//
// Sets the color component transfer characteristic to a power curve with
// the given exponent. Negative values are handled by mirroring the
// positive half of the curve through the origin. The valid domain and
// range of the curve are all finite real numbers. This curve represents
// the conversion from electrical to optical color channel values.
//
// The curve exponent shall be multiplied by 10000 to get the argument eexp
// value to carry the precision of 4 decimals.
//
// The curve exponent must be at least 1.0 and at most 10.0. Otherwise the
// protocol error invalid_tf is raised.
//
// If transfer characteristic has already been set on this object, the
// protocol error already_set is raised.
//
// This request can be used when the compositor advertises
// wp_color_manager_v1.feature.set_tf_power. Otherwise this request raises
// the protocol error unsupported_feature.
//
//	eexp: the exponent * 10000
func (i *WpImageDescriptionCreatorParamsV1) SetTfPower(eexp uint32) error {
	const opcode = 2
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(eexp))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetPrimariesNamed : named primaries
//
// Sets the color primaries and white point using explicitly named sets.
// This describes the primary color volume which is the basis for color
// value encoding.
//
// Only names advertised with wp_color_manager_v1 event
// supported_primaries_named are allowed. Other values shall raise the
// protocol error invalid_primaries_named.
//
// If primaries have already been set on this object, the protocol error
// already_set is raised.
//
//	primaries: named primaries
func (i *WpImageDescriptionCreatorParamsV1) SetPrimariesNamed(primaries uint32) error {
	const opcode = 3
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(primaries))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetPrimaries : primaries as chromaticity coordinates
//
// Sets the color primaries and white point using CIE 1931 xy chromaticity
// coordinates. This describes the primary color volume which is the basis
// for color value encoding.
//
// Each coordinate value is multiplied by 1 million to get the argument
// value to carry precision of 6 decimals.
//
// If primaries have already been set on this object, the protocol error
// already_set is raised.
//
// This request can be used if the compositor advertises
// wp_color_manager_v1.feature.set_primaries. Otherwise this request raises
// the protocol error unsupported_feature.
//
//	rX: Red x * 1M
//	rY: Red y * 1M
//	gX: Green x * 1M
//	gY: Green y * 1M
//	bX: Blue x * 1M
//	bY: Blue y * 1M
//	wX: White x * 1M
//	wY: White y * 1M
func (i *WpImageDescriptionCreatorParamsV1) SetPrimaries(rX, rY, gX, gY, bX, bY, wX, wY int32) error {
	const opcode = 4
	const _reqBufLen = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(rX))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(rY))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(gX))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(gY))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(bX))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(bY))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(wX))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(wY))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetLuminances : primary color volume luminance range and reference white
//
// Sets the primary color volume luminance range and the reference white
// luminance level. These values include the minimum display emission, but
// not external flare. The minimum display emission is assumed to have
// the chromaticity of the primary color volume white point.
//
// The default luminances from
// https://www.color.org/chardata/rgb/srgb.xalter are
// - primary color volume minimum: 0.2 cd/m²
// - primary color volume maximum: 80 cd/m²
// - reference white: 80 cd/m²
//
// Setting a named transfer characteristic can imply other default
// luminances.
//
// The default luminances get overwritten when this request is used.
// With transfer_function.st2084_pq the given 'max_lum' value is ignored,
// and 'max_lum' is taken as 'min_lum' + 10000 cd/m².
//
// 'min_lum' and 'max_lum' specify the minimum and maximum luminances of
// the primary color volume as reproduced by the targeted display.
//
// 'reference_lum' specifies the luminance of the reference white as
// reproduced by the targeted display, and reflects the targeted viewing
// environment.
//
// Compositors should make sure that all content is anchored, meaning that
// an input signal level of 'reference_lum' on one image description and
// another input signal level of 'reference_lum' on another image
// description should produce the same output level, even though the
// 'reference_lum' on both image representations can be different.
//
// 'reference_lum' may be higher than 'max_lum'. In that case reaching
// the reference white output level in image content requires the
// 'extended_target_volume' feature support.
//
// If 'max_lum' or 'reference_lum' are less than or equal to 'min_lum',
// the protocol error invalid_luminance is raised.
//
// The minimum luminance is multiplied by 10000 to get the argument
// 'min_lum' value and carries precision of 4 decimals. The maximum
// luminance and reference white luminance values are unscaled.
//
// If the primary color volume luminance range and the reference white
// luminance level have already been set on this object, the protocol error
// already_set is raised.
//
// This request can be used if the compositor advertises
// wp_color_manager_v1.feature.set_luminances. Otherwise this request
// raises the protocol error unsupported_feature.
//
//	minLum: minimum luminance (cd/m²) * 10000
//	maxLum: maximum luminance (cd/m²)
//	referenceLum: reference white luminance (cd/m²)
func (i *WpImageDescriptionCreatorParamsV1) SetLuminances(minLum, maxLum, referenceLum uint32) error {
	const opcode = 5
	const _reqBufLen = 8 + 4 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(minLum))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(maxLum))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(referenceLum))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetMasteringDisplayPrimaries : mastering display primaries as chromaticity coordinates
//
// Provides the color primaries and white point of the mastering display
// using CIE 1931 xy chromaticity coordinates. This is compatible with the
// SMPTE ST 2086 definition of HDR static metadata.
//
// The mastering display primaries and mastering display luminances define
// the target color volume.
//
// If mastering display primaries are not explicitly set, the target color
// volume is assumed to have the same primaries as the primary color volume.
//
// The target color volume is defined by all tristimulus values between 0.0
// and 1.0 (inclusive) of the color space defined by the given mastering
// display primaries and white point. The colorimetry is identical between
// the container color space and the mastering display color space,
// including that no chromatic adaptation is applied even if the white
// points differ.
//
// The target color volume can exceed the primary color volume to allow for
// a greater color volume with an existing color space definition (for
// example scRGB). It can be smaller than the primary color volume to
// minimize gamut and tone mapping distances for big color spaces (HDR
// metadata).
//
// To make use of the entire target color volume a suitable pixel format
// has to be chosen (e.g. floating point to exceed the primary color
// volume, or abusing limited quantization range as with xvYCC).
//
// Each coordinate value is multiplied by 1 million to get the argument
// value to carry precision of 6 decimals.
//
// If mastering display primaries have already been set on this object, the
// protocol error already_set is raised.
//
// This request can be used if the compositor advertises
// wp_color_manager_v1.feature.set_mastering_display_primaries. Otherwise
// this request raises the protocol error unsupported_feature. The
// advertisement implies support only for target color volumes fully
// contained within the primary color volume.
//
// If a compositor additionally supports target color volume exceeding the
// primary color volume, it must advertise
// wp_color_manager_v1.feature.extended_target_volume. If a client uses
// target color volume exceeding the primary color volume and the
// compositor does not support it, the result is implementation defined.
// Compositors are recommended to detect this case and fail the image
// description gracefully, but it may as well result in color artifacts.
//
//	rX: Red x * 1M
//	rY: Red y * 1M
//	gX: Green x * 1M
//	gY: Green y * 1M
//	bX: Blue x * 1M
//	bY: Blue y * 1M
//	wX: White x * 1M
//	wY: White y * 1M
func (i *WpImageDescriptionCreatorParamsV1) SetMasteringDisplayPrimaries(rX, rY, gX, gY, bX, bY, wX, wY int32) error {
	const opcode = 6
	const _reqBufLen = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(rX))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(rY))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(gX))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(gY))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(bX))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(bY))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(wX))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(wY))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetMasteringLuminance : display mastering luminance range
//
// Sets the luminance range that was used during the content mastering
// process as the minimum and maximum absolute luminance L. These values
// include the minimum display emission and ambient flare luminances,
// assumed to be optically additive and have the chromaticity of the
// primary color volume white point. This should be
// compatible with the SMPTE ST 2086 definition of HDR static metadata.
//
// The mastering display primaries and mastering display luminances define
// the target color volume.
//
// If mastering luminances are not explicitly set, the target color volume
// is assumed to have the same min and max luminances as the primary color
// volume.
//
// If max L is less than or equal to min L, the protocol error
// invalid_luminance is raised.
//
// Min L value is multiplied by 10000 to get the argument min_lum value
// and carry precision of 4 decimals. Max L value is unscaled for max_lum.
//
// This request can be used if the compositor advertises
// wp_color_manager_v1.feature.set_mastering_display_primaries. Otherwise
// this request raises the protocol error unsupported_feature. The
// advertisement implies support only for target color volumes fully
// contained within the primary color volume.
//
// If a compositor additionally supports target color volume exceeding the
// primary color volume, it must advertise
// wp_color_manager_v1.feature.extended_target_volume. If a client uses
// target color volume exceeding the primary color volume and the
// compositor does not support it, the result is implementation defined.
// Compositors are recommended to detect this case and fail the image
// description gracefully, but it may as well result in color artifacts.
//
//	minLum: min L (cd/m²) * 10000
//	maxLum: max L (cd/m²)
func (i *WpImageDescriptionCreatorParamsV1) SetMasteringLuminance(minLum, maxLum uint32) error {
	const opcode = 7
	const _reqBufLen = 8 + 4 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(minLum))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(maxLum))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetMaxCll : maximum content light level
//
// Sets the maximum content light level (max_cll) as defined by CTA-861-H.
//
// max_cll is undefined by default.
//
//	maxCll: Maximum content light level (cd/m²)
func (i *WpImageDescriptionCreatorParamsV1) SetMaxCll(maxCll uint32) error {
	const opcode = 8
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(maxCll))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// SetMaxFall : maximum frame-average light level
//
// Sets the maximum frame-average light level (max_fall) as defined by
// CTA-861-H.
//
// max_fall is undefined by default.
//
//	maxFall: Maximum frame-average light level (cd/m²)
func (i *WpImageDescriptionCreatorParamsV1) SetMaxFall(maxFall uint32) error {
	const opcode = 9
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(maxFall))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

type WpImageDescriptionCreatorParamsV1Error uint32

// WpImageDescriptionCreatorParamsV1Error : protocol errors
const (
	// WpImageDescriptionCreatorParamsV1ErrorIncompleteSet : incomplete parameter set
	WpImageDescriptionCreatorParamsV1ErrorIncompleteSet WpImageDescriptionCreatorParamsV1Error = 0
	// WpImageDescriptionCreatorParamsV1ErrorAlreadySet : property already set
	WpImageDescriptionCreatorParamsV1ErrorAlreadySet WpImageDescriptionCreatorParamsV1Error = 1
	// WpImageDescriptionCreatorParamsV1ErrorUnsupportedFeature : request not supported
	WpImageDescriptionCreatorParamsV1ErrorUnsupportedFeature WpImageDescriptionCreatorParamsV1Error = 2
	// WpImageDescriptionCreatorParamsV1ErrorInvalidTf : invalid transfer characteristic
	WpImageDescriptionCreatorParamsV1ErrorInvalidTf WpImageDescriptionCreatorParamsV1Error = 3
	// WpImageDescriptionCreatorParamsV1ErrorInvalidPrimariesNamed : invalid primaries named
	WpImageDescriptionCreatorParamsV1ErrorInvalidPrimariesNamed WpImageDescriptionCreatorParamsV1Error = 4
	// WpImageDescriptionCreatorParamsV1ErrorInvalidLuminance : invalid luminance value or range
	WpImageDescriptionCreatorParamsV1ErrorInvalidLuminance WpImageDescriptionCreatorParamsV1Error = 5
)

func (e WpImageDescriptionCreatorParamsV1Error) Name() string {
	switch e {
	case WpImageDescriptionCreatorParamsV1ErrorIncompleteSet:
		return "incomplete_set"
	case WpImageDescriptionCreatorParamsV1ErrorAlreadySet:
		return "already_set"
	case WpImageDescriptionCreatorParamsV1ErrorUnsupportedFeature:
		return "unsupported_feature"
	case WpImageDescriptionCreatorParamsV1ErrorInvalidTf:
		return "invalid_tf"
	case WpImageDescriptionCreatorParamsV1ErrorInvalidPrimariesNamed:
		return "invalid_primaries_named"
	case WpImageDescriptionCreatorParamsV1ErrorInvalidLuminance:
		return "invalid_luminance"
	default:
		return ""
	}
}

func (e WpImageDescriptionCreatorParamsV1Error) Value() string {
	switch e {
	case WpImageDescriptionCreatorParamsV1ErrorIncompleteSet:
		return "0"
	case WpImageDescriptionCreatorParamsV1ErrorAlreadySet:
		return "1"
	case WpImageDescriptionCreatorParamsV1ErrorUnsupportedFeature:
		return "2"
	case WpImageDescriptionCreatorParamsV1ErrorInvalidTf:
		return "3"
	case WpImageDescriptionCreatorParamsV1ErrorInvalidPrimariesNamed:
		return "4"
	case WpImageDescriptionCreatorParamsV1ErrorInvalidLuminance:
		return "5"
	default:
		return ""
	}
}

func (e WpImageDescriptionCreatorParamsV1Error) String() string {
	return e.Name() + "=" + e.Value()
}

// WpImageDescriptionV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpImageDescriptionV1InterfaceName = "wp_image_description_v1"

// WpImageDescriptionV1 : Colorimetric image description
//
// An image description carries information about the pixel color encoding
// and its intended display and viewing environment. The image description is
// attached to a wl_surface via
// wp_color_management_surface_v1.set_image_description. A compositor can use
// this information to decode pixel values into colorimetrically meaningful
// quantities, which allows the compositor to transform the surface contents
// to become suitable for various displays and viewing environments.
//
// Note, that the wp_image_description_v1 object is not ready to be used
// immediately after creation. The object eventually delivers either the
// 'ready' or the 'failed' event, specified in all requests creating it. The
// object is deemed "ready" after receiving the 'ready' event.
//
// An object which is not ready is illegal to use, it can only be destroyed.
// Any other request in this interface shall result in the 'not_ready'
// protocol error. Attempts to use an object which is not ready through other
// interfaces shall raise protocol errors defined there.
//
// Once created and regardless of how it was created, a
// wp_image_description_v1 object always refers to one fixed image
// description. It cannot change after creation.
type WpImageDescriptionV1 struct {
	client.BaseProxy
	failedHandler WpImageDescriptionV1FailedHandlerFunc
	readyHandler  WpImageDescriptionV1ReadyHandlerFunc
	ready2Handler WpImageDescriptionV1Ready2HandlerFunc
}

// NewWpImageDescriptionV1 : Colorimetric image description
//
// An image description carries information about the pixel color encoding
// and its intended display and viewing environment. The image description is
// attached to a wl_surface via
// wp_color_management_surface_v1.set_image_description. A compositor can use
// this information to decode pixel values into colorimetrically meaningful
// quantities, which allows the compositor to transform the surface contents
// to become suitable for various displays and viewing environments.
//
// Note, that the wp_image_description_v1 object is not ready to be used
// immediately after creation. The object eventually delivers either the
// 'ready' or the 'failed' event, specified in all requests creating it. The
// object is deemed "ready" after receiving the 'ready' event.
//
// An object which is not ready is illegal to use, it can only be destroyed.
// Any other request in this interface shall result in the 'not_ready'
// protocol error. Attempts to use an object which is not ready through other
// interfaces shall raise protocol errors defined there.
//
// Once created and regardless of how it was created, a
// wp_image_description_v1 object always refers to one fixed image
// description. It cannot change after creation.
func NewWpImageDescriptionV1(ctx *client.Context) *WpImageDescriptionV1 {
	wpImageDescriptionV1 := &WpImageDescriptionV1{}
	ctx.Register(wpImageDescriptionV1)
	return wpImageDescriptionV1
}

// Destroy : destroy the image description
//
// Destroy this object. It is safe to destroy an object which is not ready.
//
// Destroying a wp_image_description_v1 object has no side-effects, not
// even if a wp_color_management_surface_v1.set_image_description has not
// yet been followed by a wl_surface.commit.
func (i *WpImageDescriptionV1) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 0
	const _reqBufLen = 8
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}

// GetInformation : get information about the image description
//
// Creates a wp_image_description_info_v1 object which delivers the
// information that makes up the image description.
//
// Not all image description protocol objects allow get_information
// request. Whether it is allowed or not is defined by the request that
// created the object. If get_information is not allowed, the protocol
// error no_information is raised.
func (i *WpImageDescriptionV1) GetInformation() (*WpImageDescriptionInfoV1, error) {
	information := NewWpImageDescriptionInfoV1(i.Context())
	const opcode = 1
	const _reqBufLen = 8 + 4
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	client.PutUint32(_reqBuf[l:l+4], information.ID())
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return information, err
}

type WpImageDescriptionV1Error uint32

// WpImageDescriptionV1Error : protocol errors
const (
	// WpImageDescriptionV1ErrorNotReady : attempted to use an object which is not ready
	WpImageDescriptionV1ErrorNotReady WpImageDescriptionV1Error = 0
	// WpImageDescriptionV1ErrorNoInformation : get_information not allowed
	WpImageDescriptionV1ErrorNoInformation WpImageDescriptionV1Error = 1
)

func (e WpImageDescriptionV1Error) Name() string {
	switch e {
	case WpImageDescriptionV1ErrorNotReady:
		return "not_ready"
	case WpImageDescriptionV1ErrorNoInformation:
		return "no_information"
	default:
		return ""
	}
}

func (e WpImageDescriptionV1Error) Value() string {
	switch e {
	case WpImageDescriptionV1ErrorNotReady:
		return "0"
	case WpImageDescriptionV1ErrorNoInformation:
		return "1"
	default:
		return ""
	}
}

func (e WpImageDescriptionV1Error) String() string {
	return e.Name() + "=" + e.Value()
}

type WpImageDescriptionV1Cause uint32

// WpImageDescriptionV1Cause : generic reason for failure
const (
	// WpImageDescriptionV1CauseLowVersion : interface version too low
	WpImageDescriptionV1CauseLowVersion WpImageDescriptionV1Cause = 0
	// WpImageDescriptionV1CauseUnsupported : unsupported image description data
	WpImageDescriptionV1CauseUnsupported WpImageDescriptionV1Cause = 1
	// WpImageDescriptionV1CauseOperatingSystem : error independent of the client
	WpImageDescriptionV1CauseOperatingSystem WpImageDescriptionV1Cause = 2
	// WpImageDescriptionV1CauseNoOutput : the relevant output no longer exists
	WpImageDescriptionV1CauseNoOutput WpImageDescriptionV1Cause = 3
)

func (e WpImageDescriptionV1Cause) Name() string {
	switch e {
	case WpImageDescriptionV1CauseLowVersion:
		return "low_version"
	case WpImageDescriptionV1CauseUnsupported:
		return "unsupported"
	case WpImageDescriptionV1CauseOperatingSystem:
		return "operating_system"
	case WpImageDescriptionV1CauseNoOutput:
		return "no_output"
	default:
		return ""
	}
}

func (e WpImageDescriptionV1Cause) Value() string {
	switch e {
	case WpImageDescriptionV1CauseLowVersion:
		return "0"
	case WpImageDescriptionV1CauseUnsupported:
		return "1"
	case WpImageDescriptionV1CauseOperatingSystem:
		return "2"
	case WpImageDescriptionV1CauseNoOutput:
		return "3"
	default:
		return ""
	}
}

func (e WpImageDescriptionV1Cause) String() string {
	return e.Name() + "=" + e.Value()
}

// WpImageDescriptionV1FailedEvent : graceful error on creating the image description
//
// If creating a wp_image_description_v1 object fails for a reason that is
// not defined as a protocol error, this event is sent.
//
// The requests that create image description objects define whether and
// when this can occur. Only such creation requests can trigger this event.
// This event cannot be triggered after the image description was
// successfully formed.
//
// Once this event has been sent, the wp_image_description_v1 object will
// never become ready and it can only be destroyed.
type WpImageDescriptionV1FailedEvent struct {
	Cause uint32
	Msg   string
}
type WpImageDescriptionV1FailedHandlerFunc func(WpImageDescriptionV1FailedEvent)

// SetFailedHandler : sets handler for WpImageDescriptionV1FailedEvent
func (i *WpImageDescriptionV1) SetFailedHandler(f WpImageDescriptionV1FailedHandlerFunc) {
	i.failedHandler = f
}

// WpImageDescriptionV1ReadyEvent : the object is ready to be used (32-bit)
//
// Starting from interface version 2, the 'ready2' event is sent instead
// of this event.
//
// For the definition of this event, see the 'ready2' event. The
// difference to this event is as follows.
//
// The id number is valid only as long as the protocol object is alive. If
// all protocol objects referring to the same image description record are
// destroyed, the id number may be recycled for a different image
// description record.
type WpImageDescriptionV1ReadyEvent struct {
	Identity uint32
}
type WpImageDescriptionV1ReadyHandlerFunc func(WpImageDescriptionV1ReadyEvent)

// SetReadyHandler : sets handler for WpImageDescriptionV1ReadyEvent
func (i *WpImageDescriptionV1) SetReadyHandler(f WpImageDescriptionV1ReadyHandlerFunc) {
	i.readyHandler = f
}

// WpImageDescriptionV1Ready2Event : the object is ready to be used
//
// Once this event has been sent, the wp_image_description_v1 object is
// deemed "ready". Ready objects can be used to send requests and can be
// used through other interfaces.
//
// Every ready wp_image_description_v1 protocol object refers to an
// underlying image description record in the compositor. Multiple protocol
// objects may end up referring to the same record. Clients may identify
// these "copies" by comparing their id numbers: if the numbers from two
// protocol objects are identical, the protocol objects refer to the same
// image description record. Two different image description records
// cannot have the same id number simultaneously. The id number does not
// change during the lifetime of the image description record.
//
// Image description id number is not a protocol object id. Zero is
// reserved as an invalid id number. It shall not be possible for a client
// to refer to an image description by its id number in protocol. The id
// numbers might not be portable between Wayland connections. A compositor
// shall not send an invalid id number.
//
// Compositors must not recycle image description id numbers.
//
// This identity allows clients to de-duplicate image description records
// and avoid get_information request if they already have the image
// description information.
type WpImageDescriptionV1Ready2Event struct {
	IdentityHi uint32
	IdentityLo uint32
}
type WpImageDescriptionV1Ready2HandlerFunc func(WpImageDescriptionV1Ready2Event)

// SetReady2Handler : sets handler for WpImageDescriptionV1Ready2Event
func (i *WpImageDescriptionV1) SetReady2Handler(f WpImageDescriptionV1Ready2HandlerFunc) {
	i.ready2Handler = f
}

func (i *WpImageDescriptionV1) Dispatch(opcode uint32, fd int, data []byte) {
	switch opcode {
	case 0:
		if i.failedHandler == nil {
			return
		}
		var e WpImageDescriptionV1FailedEvent
		l := 0
		e.Cause = client.Uint32(data[l : l+4])
		l += 4
		msgLen := client.PaddedLen(int(client.Uint32(data[l : l+4])))
		l += 4
		e.Msg = client.String(data[l : l+msgLen])
		l += msgLen

		i.failedHandler(e)
	case 1:
		if i.readyHandler == nil {
			return
		}
		var e WpImageDescriptionV1ReadyEvent
		l := 0
		e.Identity = client.Uint32(data[l : l+4])
		l += 4

		i.readyHandler(e)
	case 2:
		if i.ready2Handler == nil {
			return
		}
		var e WpImageDescriptionV1Ready2Event
		l := 0
		e.IdentityHi = client.Uint32(data[l : l+4])
		l += 4
		e.IdentityLo = client.Uint32(data[l : l+4])
		l += 4

		i.ready2Handler(e)
	}
}

// WpImageDescriptionInfoV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpImageDescriptionInfoV1InterfaceName = "wp_image_description_info_v1"

// WpImageDescriptionInfoV1 : Colorimetric image description information
//
// Sends all matching events describing an image description object exactly
// once and finally sends the 'done' event.
//
// This means
// - if the image description is parametric, it must send
// - primaries
// - named_primaries, if applicable
// - at least one of tf_power and tf_named, as applicable
// - luminances
// - target_primaries
// - target_luminance
// - if the image description is parametric, it may send, if applicable,
// - target_max_cll
// - target_max_fall
// - if the image description contains an ICC profile, it must send the
// icc_file event
//
// Once a wp_image_description_info_v1 object has delivered a 'done' event it
// is automatically destroyed.
//
// Every wp_image_description_info_v1 created from the same
// wp_image_description_v1 shall always return the exact same data.
type WpImageDescriptionInfoV1 struct {
	client.BaseProxy
	doneHandler            WpImageDescriptionInfoV1DoneHandlerFunc
	iccFileHandler         WpImageDescriptionInfoV1IccFileHandlerFunc
	primariesHandler       WpImageDescriptionInfoV1PrimariesHandlerFunc
	primariesNamedHandler  WpImageDescriptionInfoV1PrimariesNamedHandlerFunc
	tfPowerHandler         WpImageDescriptionInfoV1TfPowerHandlerFunc
	tfNamedHandler         WpImageDescriptionInfoV1TfNamedHandlerFunc
	luminancesHandler      WpImageDescriptionInfoV1LuminancesHandlerFunc
	targetPrimariesHandler WpImageDescriptionInfoV1TargetPrimariesHandlerFunc
	targetLuminanceHandler WpImageDescriptionInfoV1TargetLuminanceHandlerFunc
	targetMaxCllHandler    WpImageDescriptionInfoV1TargetMaxCllHandlerFunc
	targetMaxFallHandler   WpImageDescriptionInfoV1TargetMaxFallHandlerFunc
}

// NewWpImageDescriptionInfoV1 : Colorimetric image description information
//
// Sends all matching events describing an image description object exactly
// once and finally sends the 'done' event.
//
// This means
// - if the image description is parametric, it must send
// - primaries
// - named_primaries, if applicable
// - at least one of tf_power and tf_named, as applicable
// - luminances
// - target_primaries
// - target_luminance
// - if the image description is parametric, it may send, if applicable,
// - target_max_cll
// - target_max_fall
// - if the image description contains an ICC profile, it must send the
// icc_file event
//
// Once a wp_image_description_info_v1 object has delivered a 'done' event it
// is automatically destroyed.
//
// Every wp_image_description_info_v1 created from the same
// wp_image_description_v1 shall always return the exact same data.
func NewWpImageDescriptionInfoV1(ctx *client.Context) *WpImageDescriptionInfoV1 {
	wpImageDescriptionInfoV1 := &WpImageDescriptionInfoV1{}
	ctx.Register(wpImageDescriptionInfoV1)
	return wpImageDescriptionInfoV1
}

func (i *WpImageDescriptionInfoV1) Destroy() error {
	i.Context().Unregister(i)
	return nil
}

// WpImageDescriptionInfoV1DoneEvent : end of information
//
// Signals the end of information events and destroys the object.
type WpImageDescriptionInfoV1DoneEvent struct{}
type WpImageDescriptionInfoV1DoneHandlerFunc func(WpImageDescriptionInfoV1DoneEvent)

// SetDoneHandler : sets handler for WpImageDescriptionInfoV1DoneEvent
func (i *WpImageDescriptionInfoV1) SetDoneHandler(f WpImageDescriptionInfoV1DoneHandlerFunc) {
	i.doneHandler = f
}

// WpImageDescriptionInfoV1IccFileEvent : ICC profile matching the image description
//
// The icc argument provides a file descriptor to the client which may be
// memory-mapped to provide the ICC profile matching the image description.
// The fd is read-only, and if mapped then it must be mapped with
// MAP_PRIVATE by the client.
//
// The ICC profile version and other details are determined by the
// compositor. There is no provision for a client to ask for a specific
// kind of a profile.
type WpImageDescriptionInfoV1IccFileEvent struct {
	Icc     int
	IccSize uint32
}
type WpImageDescriptionInfoV1IccFileHandlerFunc func(WpImageDescriptionInfoV1IccFileEvent)

// SetIccFileHandler : sets handler for WpImageDescriptionInfoV1IccFileEvent
func (i *WpImageDescriptionInfoV1) SetIccFileHandler(f WpImageDescriptionInfoV1IccFileHandlerFunc) {
	i.iccFileHandler = f
}

// WpImageDescriptionInfoV1PrimariesEvent : primaries as chromaticity coordinates
//
// Delivers the primary color volume primaries and white point using CIE
// 1931 xy chromaticity coordinates.
//
// Each coordinate value is multiplied by 1 million to get the argument
// value to carry precision of 6 decimals.
type WpImageDescriptionInfoV1PrimariesEvent struct {
	RX int32
	RY int32
	GX int32
	GY int32
	BX int32
	BY int32
	WX int32
	WY int32
}
type WpImageDescriptionInfoV1PrimariesHandlerFunc func(WpImageDescriptionInfoV1PrimariesEvent)

// SetPrimariesHandler : sets handler for WpImageDescriptionInfoV1PrimariesEvent
func (i *WpImageDescriptionInfoV1) SetPrimariesHandler(f WpImageDescriptionInfoV1PrimariesHandlerFunc) {
	i.primariesHandler = f
}

// WpImageDescriptionInfoV1PrimariesNamedEvent : named primaries
//
// Delivers the primary color volume primaries and white point using an
// explicitly enumerated named set.
type WpImageDescriptionInfoV1PrimariesNamedEvent struct {
	Primaries uint32
}
type WpImageDescriptionInfoV1PrimariesNamedHandlerFunc func(WpImageDescriptionInfoV1PrimariesNamedEvent)

// SetPrimariesNamedHandler : sets handler for WpImageDescriptionInfoV1PrimariesNamedEvent
func (i *WpImageDescriptionInfoV1) SetPrimariesNamedHandler(f WpImageDescriptionInfoV1PrimariesNamedHandlerFunc) {
	i.primariesNamedHandler = f
}

// WpImageDescriptionInfoV1TfPowerEvent : transfer characteristic as a power curve
//
// The color component transfer characteristic of this image description is
// a pure power curve. This event provides the exponent of the power
// function. This curve represents the conversion from electrical to
// optical pixel or color values.
//
// The curve exponent has been multiplied by 10000 to get the argument eexp
// value to carry the precision of 4 decimals.
type WpImageDescriptionInfoV1TfPowerEvent struct {
	Eexp uint32
}
type WpImageDescriptionInfoV1TfPowerHandlerFunc func(WpImageDescriptionInfoV1TfPowerEvent)

// SetTfPowerHandler : sets handler for WpImageDescriptionInfoV1TfPowerEvent
func (i *WpImageDescriptionInfoV1) SetTfPowerHandler(f WpImageDescriptionInfoV1TfPowerHandlerFunc) {
	i.tfPowerHandler = f
}

// WpImageDescriptionInfoV1TfNamedEvent : named transfer characteristic
//
// Delivers the transfer characteristic using an explicitly enumerated
// named function.
type WpImageDescriptionInfoV1TfNamedEvent struct {
	Tf uint32
}
type WpImageDescriptionInfoV1TfNamedHandlerFunc func(WpImageDescriptionInfoV1TfNamedEvent)

// SetTfNamedHandler : sets handler for WpImageDescriptionInfoV1TfNamedEvent
func (i *WpImageDescriptionInfoV1) SetTfNamedHandler(f WpImageDescriptionInfoV1TfNamedHandlerFunc) {
	i.tfNamedHandler = f
}

// WpImageDescriptionInfoV1LuminancesEvent : primary color volume luminance range and reference white
//
// Delivers the primary color volume luminance range and the reference
// white luminance level. These values include the minimum display emission
// and ambient flare luminances, assumed to be optically additive and have
// the chromaticity of the primary color volume white point.
//
// The minimum luminance is multiplied by 10000 to get the argument
// 'min_lum' value and carries precision of 4 decimals. The maximum
// luminance and reference white luminance values are unscaled.
type WpImageDescriptionInfoV1LuminancesEvent struct {
	MinLum       uint32
	MaxLum       uint32
	ReferenceLum uint32
}
type WpImageDescriptionInfoV1LuminancesHandlerFunc func(WpImageDescriptionInfoV1LuminancesEvent)

// SetLuminancesHandler : sets handler for WpImageDescriptionInfoV1LuminancesEvent
func (i *WpImageDescriptionInfoV1) SetLuminancesHandler(f WpImageDescriptionInfoV1LuminancesHandlerFunc) {
	i.luminancesHandler = f
}

// WpImageDescriptionInfoV1TargetPrimariesEvent : target primaries as chromaticity coordinates
//
// Provides the color primaries and white point of the target color volume
// using CIE 1931 xy chromaticity coordinates. This is compatible with the
// SMPTE ST 2086 definition of HDR static metadata for mastering displays.
//
// While primary color volume is about how color is encoded, the target
// color volume is the actually displayable color volume.
//
// Each coordinate value is multiplied by 1 million to get the argument
// value to carry precision of 6 decimals.
type WpImageDescriptionInfoV1TargetPrimariesEvent struct {
	RX int32
	RY int32
	GX int32
	GY int32
	BX int32
	BY int32
	WX int32
	WY int32
}
type WpImageDescriptionInfoV1TargetPrimariesHandlerFunc func(WpImageDescriptionInfoV1TargetPrimariesEvent)

// SetTargetPrimariesHandler : sets handler for WpImageDescriptionInfoV1TargetPrimariesEvent
func (i *WpImageDescriptionInfoV1) SetTargetPrimariesHandler(f WpImageDescriptionInfoV1TargetPrimariesHandlerFunc) {
	i.targetPrimariesHandler = f
}

// WpImageDescriptionInfoV1TargetLuminanceEvent : target luminance range
//
// Provides the luminance range that the image description is targeting as
// the minimum and maximum absolute luminance L. These values include the
// minimum display emission and ambient flare luminances, assumed to be
// optically additive and have the chromaticity of the primary color
// volume white point. This should be compatible with the SMPTE ST 2086
// definition of HDR static metadata.
//
// This luminance range is only theoretical and may not correspond to the
// luminance of light emitted on an actual display.
//
// Min L value is multiplied by 10000 to get the argument min_lum value and
// carry precision of 4 decimals. Max L value is unscaled for max_lum.
type WpImageDescriptionInfoV1TargetLuminanceEvent struct {
	MinLum uint32
	MaxLum uint32
}
type WpImageDescriptionInfoV1TargetLuminanceHandlerFunc func(WpImageDescriptionInfoV1TargetLuminanceEvent)

// SetTargetLuminanceHandler : sets handler for WpImageDescriptionInfoV1TargetLuminanceEvent
func (i *WpImageDescriptionInfoV1) SetTargetLuminanceHandler(f WpImageDescriptionInfoV1TargetLuminanceHandlerFunc) {
	i.targetLuminanceHandler = f
}

// WpImageDescriptionInfoV1TargetMaxCllEvent : target maximum content light level
//
// Provides the targeted max_cll of the image description. max_cll is
// defined by CTA-861-H.
//
// This luminance is only theoretical and may not correspond to the
// luminance of light emitted on an actual display.
type WpImageDescriptionInfoV1TargetMaxCllEvent struct {
	MaxCll uint32
}
type WpImageDescriptionInfoV1TargetMaxCllHandlerFunc func(WpImageDescriptionInfoV1TargetMaxCllEvent)

// SetTargetMaxCllHandler : sets handler for WpImageDescriptionInfoV1TargetMaxCllEvent
func (i *WpImageDescriptionInfoV1) SetTargetMaxCllHandler(f WpImageDescriptionInfoV1TargetMaxCllHandlerFunc) {
	i.targetMaxCllHandler = f
}

// WpImageDescriptionInfoV1TargetMaxFallEvent : target maximum frame-average light level
//
// Provides the targeted max_fall of the image description. max_fall is
// defined by CTA-861-H.
//
// This luminance is only theoretical and may not correspond to the
// luminance of light emitted on an actual display.
type WpImageDescriptionInfoV1TargetMaxFallEvent struct {
	MaxFall uint32
}
type WpImageDescriptionInfoV1TargetMaxFallHandlerFunc func(WpImageDescriptionInfoV1TargetMaxFallEvent)

// SetTargetMaxFallHandler : sets handler for WpImageDescriptionInfoV1TargetMaxFallEvent
func (i *WpImageDescriptionInfoV1) SetTargetMaxFallHandler(f WpImageDescriptionInfoV1TargetMaxFallHandlerFunc) {
	i.targetMaxFallHandler = f
}

func (i *WpImageDescriptionInfoV1) Dispatch(opcode uint32, fd int, data []byte) {
	switch opcode {
	case 0:
		if i.doneHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1DoneEvent

		i.doneHandler(e)
	case 1:
		if i.iccFileHandler == nil {
			if fd != -1 {
				unix.Close(fd)
			}
			return
		}
		var e WpImageDescriptionInfoV1IccFileEvent
		l := 0
		e.Icc = fd
		e.IccSize = client.Uint32(data[l : l+4])
		l += 4

		i.iccFileHandler(e)
	case 2:
		if i.primariesHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1PrimariesEvent
		l := 0
		e.RX = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.RY = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.GX = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.GY = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.BX = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.BY = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.WX = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.WY = int32(client.Uint32(data[l : l+4]))
		l += 4

		i.primariesHandler(e)
	case 3:
		if i.primariesNamedHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1PrimariesNamedEvent
		l := 0
		e.Primaries = client.Uint32(data[l : l+4])
		l += 4

		i.primariesNamedHandler(e)
	case 4:
		if i.tfPowerHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1TfPowerEvent
		l := 0
		e.Eexp = client.Uint32(data[l : l+4])
		l += 4

		i.tfPowerHandler(e)
	case 5:
		if i.tfNamedHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1TfNamedEvent
		l := 0
		e.Tf = client.Uint32(data[l : l+4])
		l += 4

		i.tfNamedHandler(e)
	case 6:
		if i.luminancesHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1LuminancesEvent
		l := 0
		e.MinLum = client.Uint32(data[l : l+4])
		l += 4
		e.MaxLum = client.Uint32(data[l : l+4])
		l += 4
		e.ReferenceLum = client.Uint32(data[l : l+4])
		l += 4

		i.luminancesHandler(e)
	case 7:
		if i.targetPrimariesHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1TargetPrimariesEvent
		l := 0
		e.RX = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.RY = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.GX = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.GY = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.BX = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.BY = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.WX = int32(client.Uint32(data[l : l+4]))
		l += 4
		e.WY = int32(client.Uint32(data[l : l+4]))
		l += 4

		i.targetPrimariesHandler(e)
	case 8:
		if i.targetLuminanceHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1TargetLuminanceEvent
		l := 0
		e.MinLum = client.Uint32(data[l : l+4])
		l += 4
		e.MaxLum = client.Uint32(data[l : l+4])
		l += 4

		i.targetLuminanceHandler(e)
	case 9:
		if i.targetMaxCllHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1TargetMaxCllEvent
		l := 0
		e.MaxCll = client.Uint32(data[l : l+4])
		l += 4

		i.targetMaxCllHandler(e)
	case 10:
		if i.targetMaxFallHandler == nil {
			return
		}
		var e WpImageDescriptionInfoV1TargetMaxFallEvent
		l := 0
		e.MaxFall = client.Uint32(data[l : l+4])
		l += 4

		i.targetMaxFallHandler(e)
	}
}

// WpImageDescriptionReferenceV1InterfaceName is the name of the interface as it appears in the [client.Registry].
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
const WpImageDescriptionReferenceV1InterfaceName = "wp_image_description_reference_v1"

// WpImageDescriptionReferenceV1 : Reference to an image description
//
// This object is a reference to an image description. This interface is
// frozen at version 1 to allow other protocols to create
// wp_image_description_v1 objects.
//
// The wp_color_manager_v1.get_image_description request can be used to
// retrieve the underlying image description.
type WpImageDescriptionReferenceV1 struct {
	client.BaseProxy
}

// NewWpImageDescriptionReferenceV1 : Reference to an image description
//
// This object is a reference to an image description. This interface is
// frozen at version 1 to allow other protocols to create
// wp_image_description_v1 objects.
//
// The wp_color_manager_v1.get_image_description request can be used to
// retrieve the underlying image description.
func NewWpImageDescriptionReferenceV1(ctx *client.Context) *WpImageDescriptionReferenceV1 {
	wpImageDescriptionReferenceV1 := &WpImageDescriptionReferenceV1{}
	ctx.Register(wpImageDescriptionReferenceV1)
	return wpImageDescriptionReferenceV1
}

// Destroy : destroy the reference
//
// Destroy this object. This has no effect on the referenced image
// description.
func (i *WpImageDescriptionReferenceV1) Destroy() error {
	defer i.Context().Unregister(i)
	const opcode = 0
	const _reqBufLen = 8
	var _reqBuf [_reqBufLen]byte
	l := 0
	client.PutUint32(_reqBuf[l:4], i.ID())
	l += 4
	client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
	l += 4
	err := i.Context().WriteMsg(_reqBuf[:], nil)
	return err
}
