// Code generated by wlbgen. DO NOT EDIT. // Protocol: wlr_output_management_unstable_v1 // Source: wlr-output-management-unstable-v1.xml // Upstream protocol copyright and license: // Copyright © 2019 Purism SPC // // Permission to use, copy, modify, distribute, and sell this // software and its documentation for any purpose is hereby granted // without fee, provided that the above copyright notice appear in // all copies and that both that copyright notice and this permission // notice appear in supporting documentation, and that the name of // the copyright holders not be used in advertising or publicity // pertaining to distribution of the software without specific, // written prior permission. The copyright holders make no // representations about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. // // THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS // SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY // SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, // ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF // THIS SOFTWARE. package wlroutputmanagement import ( "sync" "github.com/bnema/wlturbo/wl" ) // ADAPTIVE_SYNC_STATE_DISABLED is the adaptive_sync_state disabled value. const ADAPTIVE_SYNC_STATE_DISABLED = 0 // ADAPTIVE_SYNC_STATE_ENABLED is the adaptive_sync_state enabled value. const ADAPTIVE_SYNC_STATE_ENABLED = 1 // ERROR_ALREADY_CONFIGURED_HEAD is the error already_configured_head value. const ERROR_ALREADY_CONFIGURED_HEAD = 1 // ERROR_UNCONFIGURED_HEAD is the error unconfigured_head value. const ERROR_UNCONFIGURED_HEAD = 2 // ERROR_ALREADY_USED is the error already_used value. const ERROR_ALREADY_USED = 3 // ERROR_ALREADY_SET is the error already_set value. const ERROR_ALREADY_SET = 1 // ERROR_INVALID_MODE is the error invalid_mode value. const ERROR_INVALID_MODE = 2 // ERROR_INVALID_CUSTOM_MODE is the error invalid_custom_mode value. const ERROR_INVALID_CUSTOM_MODE = 3 // ERROR_INVALID_TRANSFORM is the error invalid_transform value. const ERROR_INVALID_TRANSFORM = 4 // ERROR_INVALID_SCALE is the error invalid_scale value. const ERROR_INVALID_SCALE = 5 // ERROR_INVALID_ADAPTIVE_SYNC_STATE is the error invalid_adaptive_sync_state value. const ERROR_INVALID_ADAPTIVE_SYNC_STATE = 6 // OutputManagerInterface is the protocol interface name. const OutputManagerInterface = "zwlr_output_manager_v1" // OutputManager is the generated binding for zwlr_output_manager_v1 version 4. type OutputManager struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onHead []func(headObject *OutputHead) onDone []func(serial uint32) onFinished []func() } // NewOutputManager returns an unbound OutputManager. func NewOutputManager(ctx *wl.Context) *OutputManager { obj := &OutputManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Create a new output configuration object. This allows to update head properties. func (o *OutputManager) CreateConfiguration(serial uint32) (*OutputConfiguration, error) { child := &OutputConfiguration{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_manager_v1.create_configuration", Child: child}, wl.ArgObject(child), wl.ArgUint(serial)); err != nil { return nil, err } return child, nil } // Indicates the client no longer wishes to receive events for output configuration changes. However the compositor may emit further events, until the finished event is emitted. The client must not send any more requests after this one. func (o *OutputManager) Stop() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_output_manager_v1.stop"}); err != nil { return err } return nil } // OnHead registers a handler for the head event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputManager) OnHead(handler func(headObject *OutputHead)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onHead = append(o.onHead, handler) } // handlersForHead returns the handlers registered for head, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputManager) handlersForHead() []func(headObject *OutputHead) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onHead } // OnDone registers a handler for the done event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputManager) OnDone(handler func(serial uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDone = append(o.onDone, handler) } // handlersForDone returns the handlers registered for done, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputManager) handlersForDone() []func(serial uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDone } // OnFinished registers a handler for the finished event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputManager) OnFinished(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFinished = append(o.onFinished, handler) } // handlersForFinished returns the handlers registered for finished, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputManager) handlersForFinished() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFinished } // EventSignature returns the declared event argument types in wire order. func (o *OutputManager) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "new_id,", true case 1: return "uint,", true case 2: return "", true default: return "", false } } // Dispatch decodes one event on zwlr_output_manager_v1 and calls the registered handlers. func (o *OutputManager) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // head headID := event.Uint32() headObject := &OutputHead{} headObject.SetContext(o.Context()) headObject.SetID(headID) headObject.SetVersion(o.Version()) o.Context().Register(headObject) for i, handler := range o.handlersForHead() { _ = i handler(headObject) } case 1: // done serial := event.Uint32() for i, handler := range o.handlersForDone() { _ = i handler(serial) } case 2: // finished for i, handler := range o.handlersForFinished() { _ = i handler() } o.Context().Unregister(o) default: } } // OutputHeadInterface is the protocol interface name. const OutputHeadInterface = "zwlr_output_head_v1" // OutputHead is the generated binding for zwlr_output_head_v1 version 4. type OutputHead struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onName []func(name string) onDescription []func(description string) onPhysicalSize []func(width int32, height int32) onMode []func(modeObject *OutputMode) onEnabled []func(enabled int32) onCurrentMode []func(modeID uint32) onPosition []func(x int32, y int32) onTransform []func(transform int32) onScale []func(scale wl.Fixed) onFinished []func() onMake []func(make string) onModel []func(model string) onSerialNumber []func(serialNumber string) onAdaptiveSync []func(state uint32) } // NewOutputHead returns an unbound OutputHead. func NewOutputHead(ctx *wl.Context) *OutputHead { obj := &OutputHead{} obj.SetContext(ctx) ctx.Register(obj) return obj } // This request indicates that the client will no longer use this head object. func (o *OutputHead) Release() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_head_v1.release", Since: 3, Destructor: true}); err != nil { return err } return nil } // OnName registers a handler for the name event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnName(handler func(name string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onName = append(o.onName, handler) } // handlersForName returns the handlers registered for name, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForName() []func(name string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onName } // OnDescription registers a handler for the description event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnDescription(handler func(description string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDescription = append(o.onDescription, handler) } // handlersForDescription returns the handlers registered for description, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForDescription() []func(description string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDescription } // OnPhysicalSize registers a handler for the physical_size event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnPhysicalSize(handler func(width int32, height int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPhysicalSize = append(o.onPhysicalSize, handler) } // handlersForPhysicalSize returns the handlers registered for physical_size, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForPhysicalSize() []func(width int32, height int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPhysicalSize } // OnMode registers a handler for the mode event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnMode(handler func(modeObject *OutputMode)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onMode = append(o.onMode, handler) } // handlersForMode returns the handlers registered for mode, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForMode() []func(modeObject *OutputMode) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onMode } // OnEnabled registers a handler for the enabled event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnEnabled(handler func(enabled int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onEnabled = append(o.onEnabled, handler) } // handlersForEnabled returns the handlers registered for enabled, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForEnabled() []func(enabled int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onEnabled } // OnCurrentMode registers a handler for the current_mode event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnCurrentMode(handler func(modeID uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onCurrentMode = append(o.onCurrentMode, handler) } // handlersForCurrentMode returns the handlers registered for current_mode, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForCurrentMode() []func(modeID uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onCurrentMode } // OnPosition registers a handler for the position event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnPosition(handler func(x int32, y int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPosition = append(o.onPosition, handler) } // handlersForPosition returns the handlers registered for position, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForPosition() []func(x int32, y int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPosition } // OnTransform registers a handler for the transform event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnTransform(handler func(transform int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onTransform = append(o.onTransform, handler) } // handlersForTransform returns the handlers registered for transform, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForTransform() []func(transform int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onTransform } // OnScale registers a handler for the scale event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnScale(handler func(scale wl.Fixed)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onScale = append(o.onScale, handler) } // handlersForScale returns the handlers registered for scale, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForScale() []func(scale wl.Fixed) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onScale } // OnFinished registers a handler for the finished event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnFinished(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFinished = append(o.onFinished, handler) } // handlersForFinished returns the handlers registered for finished, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForFinished() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFinished } // OnMake registers a handler for the make event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnMake(handler func(make string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onMake = append(o.onMake, handler) } // handlersForMake returns the handlers registered for make, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForMake() []func(make string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onMake } // OnModel registers a handler for the model event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnModel(handler func(model string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onModel = append(o.onModel, handler) } // handlersForModel returns the handlers registered for model, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForModel() []func(model string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onModel } // OnSerialNumber registers a handler for the serial_number event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnSerialNumber(handler func(serialNumber string)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSerialNumber = append(o.onSerialNumber, handler) } // handlersForSerialNumber returns the handlers registered for serial_number, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForSerialNumber() []func(serialNumber string) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSerialNumber } // OnAdaptiveSync registers a handler for the adaptive_sync event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputHead) OnAdaptiveSync(handler func(state uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onAdaptiveSync = append(o.onAdaptiveSync, handler) } // handlersForAdaptiveSync returns the handlers registered for adaptive_sync, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputHead) handlersForAdaptiveSync() []func(state uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onAdaptiveSync } // EventSignature returns the declared event argument types in wire order. func (o *OutputHead) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "string,", true case 1: return "string,", true case 2: return "int,int,", true case 3: return "new_id,", true case 4: return "int,", true case 5: return "object,", true case 6: return "int,int,", true case 7: return "int,", true case 8: return "fixed,", true case 9: return "", true case 10: return "string,", true case 11: return "string,", true case 12: return "string,", true case 13: return "uint,", true default: return "", false } } // Dispatch decodes one event on zwlr_output_head_v1 and calls the registered handlers. func (o *OutputHead) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // name name := event.String() for i, handler := range o.handlersForName() { _ = i handler(name) } case 1: // description description := event.String() for i, handler := range o.handlersForDescription() { _ = i handler(description) } case 2: // physical_size width := event.Int32() height := event.Int32() for i, handler := range o.handlersForPhysicalSize() { _ = i handler(width, height) } case 3: // mode modeID := event.Uint32() modeObject := &OutputMode{} modeObject.SetContext(o.Context()) modeObject.SetID(modeID) modeObject.SetVersion(o.Version()) o.Context().Register(modeObject) for i, handler := range o.handlersForMode() { _ = i handler(modeObject) } case 4: // enabled enabled := event.Int32() for i, handler := range o.handlersForEnabled() { _ = i handler(enabled) } case 5: // current_mode modeID := event.Uint32() for i, handler := range o.handlersForCurrentMode() { _ = i handler(modeID) } case 6: // position x := event.Int32() y := event.Int32() for i, handler := range o.handlersForPosition() { _ = i handler(x, y) } case 7: // transform transform := event.Int32() for i, handler := range o.handlersForTransform() { _ = i handler(transform) } case 8: // scale scale := event.Fixed() for i, handler := range o.handlersForScale() { _ = i handler(scale) } case 9: // finished for i, handler := range o.handlersForFinished() { _ = i handler() } case 10: // make make := event.String() for i, handler := range o.handlersForMake() { _ = i handler(make) } case 11: // model model := event.String() for i, handler := range o.handlersForModel() { _ = i handler(model) } case 12: // serial_number serialNumber := event.String() for i, handler := range o.handlersForSerialNumber() { _ = i handler(serialNumber) } case 13: // adaptive_sync state := event.Uint32() for i, handler := range o.handlersForAdaptiveSync() { _ = i handler(state) } default: } } // OutputModeInterface is the protocol interface name. const OutputModeInterface = "zwlr_output_mode_v1" // OutputMode is the generated binding for zwlr_output_mode_v1 version 3. type OutputMode struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onSize []func(width int32, height int32) onRefresh []func(refresh int32) onPreferred []func() onFinished []func() } // NewOutputMode returns an unbound OutputMode. func NewOutputMode(ctx *wl.Context) *OutputMode { obj := &OutputMode{} obj.SetContext(ctx) ctx.Register(obj) return obj } // This request indicates that the client will no longer use this mode object. func (o *OutputMode) Release() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_mode_v1.release", Since: 3, Destructor: true}); err != nil { return err } return nil } // OnSize registers a handler for the size event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputMode) OnSize(handler func(width int32, height int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSize = append(o.onSize, handler) } // handlersForSize returns the handlers registered for size, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputMode) handlersForSize() []func(width int32, height int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSize } // OnRefresh registers a handler for the refresh event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputMode) OnRefresh(handler func(refresh int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onRefresh = append(o.onRefresh, handler) } // handlersForRefresh returns the handlers registered for refresh, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputMode) handlersForRefresh() []func(refresh int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onRefresh } // OnPreferred registers a handler for the preferred event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputMode) OnPreferred(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onPreferred = append(o.onPreferred, handler) } // handlersForPreferred returns the handlers registered for preferred, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputMode) handlersForPreferred() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onPreferred } // OnFinished registers a handler for the finished event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputMode) OnFinished(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFinished = append(o.onFinished, handler) } // handlersForFinished returns the handlers registered for finished, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputMode) handlersForFinished() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFinished } // EventSignature returns the declared event argument types in wire order. func (o *OutputMode) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "int,int,", true case 1: return "int,", true case 2: return "", true case 3: return "", true default: return "", false } } // Dispatch decodes one event on zwlr_output_mode_v1 and calls the registered handlers. func (o *OutputMode) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // size width := event.Int32() height := event.Int32() for i, handler := range o.handlersForSize() { _ = i handler(width, height) } case 1: // refresh refresh := event.Int32() for i, handler := range o.handlersForRefresh() { _ = i handler(refresh) } case 2: // preferred for i, handler := range o.handlersForPreferred() { _ = i handler() } case 3: // finished for i, handler := range o.handlersForFinished() { _ = i handler() } default: } } // OutputConfigurationInterface is the protocol interface name. const OutputConfigurationInterface = "zwlr_output_configuration_v1" // OutputConfiguration is the generated binding for zwlr_output_configuration_v1 version 4. type OutputConfiguration struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onSucceeded []func() onFailed []func() onCancelled []func() } // NewOutputConfiguration returns an unbound OutputConfiguration. func NewOutputConfiguration(ctx *wl.Context) *OutputConfiguration { obj := &OutputConfiguration{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Enable a head. This request creates a head configuration object that can be used to change the head's properties. func (o *OutputConfiguration) EnableHead(head *OutputHead) (*OutputConfigurationHead, error) { var arg1 wl.Object if head != nil { arg1 = head } child := &OutputConfigurationHead{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_configuration_v1.enable_head", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil { return nil, err } return child, nil } // Disable a head. func (o *OutputConfiguration) DisableHead(head *OutputHead) error { var arg0 wl.Object if head != nil { arg0 = head } if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_output_configuration_v1.disable_head"}, wl.ArgObject(arg0)); err != nil { return err } return nil } // Apply the new output configuration. In case the configuration is successfully applied, there is no guarantee that the new output state matches completely the requested configuration. For instance, a compositor might round the scale if it doesn't support fractional scaling. After this request has been sent, the compositor must respond with an succeeded, failed or cancelled event. Sending a request that isn't the destructor is a protocol error. func (o *OutputConfiguration) Apply() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_output_configuration_v1.apply"}); err != nil { return err } return nil } // Test the new output configuration. The configuration won't be applied, but will only be validated. Even if the compositor succeeds to test a configuration, applying it may fail. After this request has been sent, the compositor must respond with an succeeded, failed or cancelled event. Sending a request that isn't the destructor is a protocol error. func (o *OutputConfiguration) Test() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwlr_output_configuration_v1.test"}); err != nil { return err } return nil } // Using this request a client can tell the compositor that it is not going to use the configuration object anymore. Any changes to the outputs that have not been applied will be discarded. This request also destroys wlr_output_configuration_head objects created via this object. func (o *OutputConfiguration) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "zwlr_output_configuration_v1.destroy", Destructor: true}); err != nil { return err } return nil } // OnSucceeded registers a handler for the succeeded event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputConfiguration) OnSucceeded(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onSucceeded = append(o.onSucceeded, handler) } // handlersForSucceeded returns the handlers registered for succeeded, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputConfiguration) handlersForSucceeded() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onSucceeded } // OnFailed registers a handler for the failed event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputConfiguration) OnFailed(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onFailed = append(o.onFailed, handler) } // handlersForFailed returns the handlers registered for failed, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputConfiguration) handlersForFailed() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFailed } // OnCancelled registers a handler for the cancelled event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *OutputConfiguration) OnCancelled(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onCancelled = append(o.onCancelled, handler) } // handlersForCancelled returns the handlers registered for cancelled, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *OutputConfiguration) handlersForCancelled() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onCancelled } // EventSignature returns the declared event argument types in wire order. func (o *OutputConfiguration) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "", true case 1: return "", true case 2: return "", true default: return "", false } } // Dispatch decodes one event on zwlr_output_configuration_v1 and calls the registered handlers. func (o *OutputConfiguration) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // succeeded for i, handler := range o.handlersForSucceeded() { _ = i handler() } case 1: // failed for i, handler := range o.handlersForFailed() { _ = i handler() } case 2: // cancelled for i, handler := range o.handlersForCancelled() { _ = i handler() } default: } } // OutputConfigurationHeadInterface is the protocol interface name. const OutputConfigurationHeadInterface = "zwlr_output_configuration_head_v1" // OutputConfigurationHead is the generated binding for zwlr_output_configuration_head_v1 version 4. type OutputConfigurationHead struct { wl.BaseProxy } // NewOutputConfigurationHead returns an unbound OutputConfigurationHead. func NewOutputConfigurationHead(ctx *wl.Context) *OutputConfigurationHead { obj := &OutputConfigurationHead{} obj.SetContext(ctx) ctx.Register(obj) return obj } // This request sets the head's mode. func (o *OutputConfigurationHead) SetMode(mode *OutputMode) error { var arg0 wl.Object if mode != nil { arg0 = mode } if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_configuration_head_v1.set_mode"}, wl.ArgObject(arg0)); err != nil { return err } return nil } // This request assigns a custom mode to the head. The size is given in physical hardware units of the output device. If set to zero, the refresh rate is unspecified. It is a protocol error to set both a mode and a custom mode. func (o *OutputConfigurationHead) SetCustomMode(width int32, height int32, refresh int32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_output_configuration_head_v1.set_custom_mode"}, wl.ArgInt(width), wl.ArgInt(height), wl.ArgInt(refresh)); err != nil { return err } return nil } // This request sets the head's position in the global compositor space. func (o *OutputConfigurationHead) SetPosition(x int32, y int32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_output_configuration_head_v1.set_position"}, wl.ArgInt(x), wl.ArgInt(y)); err != nil { return err } return nil } // This request sets the head's transform. func (o *OutputConfigurationHead) SetTransform(transform int32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwlr_output_configuration_head_v1.set_transform"}, wl.ArgInt(transform)); err != nil { return err } return nil } // This request sets the head's scale. func (o *OutputConfigurationHead) SetScale(scale wl.Fixed) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "zwlr_output_configuration_head_v1.set_scale"}, wl.ArgFixed(scale)); err != nil { return err } return nil } // This request enables/disables adaptive sync. Adaptive sync is also known as Variable Refresh Rate or VRR. func (o *OutputConfigurationHead) SetAdaptiveSync(state uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 5, Name: "zwlr_output_configuration_head_v1.set_adaptive_sync", Since: 4}, wl.ArgUint(state)); err != nil { return err } return nil } // EventSignature returns the declared event argument types in wire order. func (o *OutputConfigurationHead) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on zwlr_output_configuration_head_v1 and calls the registered handlers. func (o *OutputConfigurationHead) Dispatch(event *wl.Event) { switch event.Opcode { default: } }