// Code generated by wlbgen. DO NOT EDIT. // Protocol: ext_transient_seat_v1 // Source: ext-transient-seat-v1.xml // Upstream protocol copyright and license: // Copyright © 2020 - 2023 Andri Yngvason // // 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 exttransientseat import ( "sync" "github.com/bnema/wlturbo/wl" ) // ExtTransientSeatManagerInterface is the protocol interface name. const ExtTransientSeatManagerInterface = "ext_transient_seat_manager_v1" // ExtTransientSeatManager is the generated binding for ext_transient_seat_manager_v1 version 1. type ExtTransientSeatManager struct { wl.BaseProxy } // NewExtTransientSeatManager returns an unbound ExtTransientSeatManager. func NewExtTransientSeatManager(ctx *wl.Context) *ExtTransientSeatManager { obj := &ExtTransientSeatManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Create a new seat that is removed when the client side transient seat object is destroyed. The actual seat may be removed sooner, in which case the transient seat object shall become inert. func (o *ExtTransientSeatManager) Create() (*ExtTransientSeat, error) { child := &ExtTransientSeat{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_transient_seat_manager_v1.create", Child: child}, wl.ArgObject(child)); err != nil { return nil, err } return child, nil } // Destroy the manager. All objects created by the manager will remain valid until they are destroyed themselves. func (o *ExtTransientSeatManager) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_transient_seat_manager_v1.destroy", Destructor: true}); err != nil { return err } return nil } // EventSignature returns the declared event argument types in wire order. func (o *ExtTransientSeatManager) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on ext_transient_seat_manager_v1 and calls the registered handlers. func (o *ExtTransientSeatManager) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // ExtTransientSeatInterface is the protocol interface name. const ExtTransientSeatInterface = "ext_transient_seat_v1" // ExtTransientSeat is the generated binding for ext_transient_seat_v1 version 1. type ExtTransientSeat struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onReady []func(globalName uint32) onDenied []func() } // NewExtTransientSeat returns an unbound ExtTransientSeat. func NewExtTransientSeat(ctx *wl.Context) *ExtTransientSeat { obj := &ExtTransientSeat{} obj.SetContext(ctx) ctx.Register(obj) return obj } // When the transient seat object is destroyed by the client, the associated seat created by the compositor is also destroyed. func (o *ExtTransientSeat) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_transient_seat_v1.destroy", Destructor: true}); err != nil { return err } return nil } // OnReady registers a handler for the ready 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 *ExtTransientSeat) OnReady(handler func(globalName uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onReady = append(o.onReady, handler) } // handlersForReady returns the handlers registered for ready, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtTransientSeat) handlersForReady() []func(globalName uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onReady } // OnDenied registers a handler for the denied 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 *ExtTransientSeat) OnDenied(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onDenied = append(o.onDenied, handler) } // handlersForDenied returns the handlers registered for denied, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtTransientSeat) handlersForDenied() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onDenied } // EventSignature returns the declared event argument types in wire order. func (o *ExtTransientSeat) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,", true case 1: return "", true default: return "", false } } // Dispatch decodes one event on ext_transient_seat_v1 and calls the registered handlers. func (o *ExtTransientSeat) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // ready globalName := event.Uint32() for i, handler := range o.handlersForReady() { _ = i handler(globalName) } case 1: // denied for i, handler := range o.handlersForDenied() { _ = i handler() } default: } }