// Code generated by wlbgen. DO NOT EDIT. // Protocol: ext_session_lock_v1 // Source: ext-session-lock-v1.xml // Upstream protocol copyright and license: // Copyright 2021 Isaac Freund // // 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 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 extsessionlock import ( "sync" cross_wl_output "github.com/bnema/go-wayland-bindings/client/wayland" cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // ERROR_INVALID_DESTROY is the error invalid_destroy value. const ERROR_INVALID_DESTROY = 0 // ERROR_INVALID_UNLOCK is the error invalid_unlock value. const ERROR_INVALID_UNLOCK = 1 // ERROR_ROLE is the error role value. const ERROR_ROLE = 2 // ERROR_DUPLICATE_OUTPUT is the error duplicate_output value. const ERROR_DUPLICATE_OUTPUT = 3 // ERROR_ALREADY_CONSTRUCTED is the error already_constructed value. const ERROR_ALREADY_CONSTRUCTED = 4 // ERROR_COMMIT_BEFORE_FIRST_ACK is the error commit_before_first_ack value. const ERROR_COMMIT_BEFORE_FIRST_ACK = 0 // ERROR_NULL_BUFFER is the error null_buffer value. const ERROR_NULL_BUFFER = 1 // ERROR_DIMENSIONS_MISMATCH is the error dimensions_mismatch value. const ERROR_DIMENSIONS_MISMATCH = 2 // ERROR_INVALID_SERIAL is the error invalid_serial value. const ERROR_INVALID_SERIAL = 3 // ExtSessionLockManagerInterface is the protocol interface name. const ExtSessionLockManagerInterface = "ext_session_lock_manager_v1" // ExtSessionLockManager is the generated binding for ext_session_lock_manager_v1 version 1. type ExtSessionLockManager struct { wl.BaseProxy } // NewExtSessionLockManager returns an unbound ExtSessionLockManager. func NewExtSessionLockManager(ctx *wl.Context) *ExtSessionLockManager { obj := &ExtSessionLockManager{} obj.SetContext(ctx) ctx.Register(obj) return obj } // This informs the compositor that the session lock manager object will no longer be used. Existing objects created through this interface remain valid. func (o *ExtSessionLockManager) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_session_lock_manager_v1.destroy", Destructor: true}); err != nil { return err } return nil } // This request creates a session lock and asks the compositor to lock the session. The compositor will send either the ext_session_lock_v1.locked or ext_session_lock_v1.finished event on the created object in response to this request. func (o *ExtSessionLockManager) Lock() (*ExtSessionLock, error) { child := &ExtSessionLock{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_session_lock_manager_v1.lock", Child: child}, wl.ArgObject(child)); err != nil { return nil, err } return child, nil } // EventSignature returns the declared event argument types in wire order. func (o *ExtSessionLockManager) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on ext_session_lock_manager_v1 and calls the registered handlers. func (o *ExtSessionLockManager) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // ExtSessionLockInterface is the protocol interface name. const ExtSessionLockInterface = "ext_session_lock_v1" // ExtSessionLock is the generated binding for ext_session_lock_v1 version 1. type ExtSessionLock struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onLocked []func() onFinished []func() } // NewExtSessionLock returns an unbound ExtSessionLock. func NewExtSessionLock(ctx *wl.Context) *ExtSessionLock { obj := &ExtSessionLock{} obj.SetContext(ctx) ctx.Register(obj) return obj } // This informs the compositor that the lock object will no longer be used. Existing objects created through this interface remain valid. After this request is made, lock surfaces created through this object should be destroyed by the client as they will no longer be used by the compositor. It is a protocol error to make this request if the locked event was sent, the unlock_and_destroy request must be used instead. func (o *ExtSessionLock) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_session_lock_v1.destroy", Destructor: true}); err != nil { return err } return nil } // The client is expected to create lock surfaces for all outputs currently present and any new outputs as they are advertised. These won't be displayed by the compositor unless the lock is successful and the locked event is sent. Providing a wl_surface which already has a role or already has a buffer attached or committed is a protocol error, as is attaching/committing a buffer before the first ext_session_lock_surface_v1.configure event. Attempting to create more than one lock surface for a given output is a duplicate_output protocol error. func (o *ExtSessionLock) GetLockSurface(surface *cross_wl_surface.Surface, output *cross_wl_output.Output) (*ExtSessionLockSurface, error) { var arg1 wl.Object if surface != nil { arg1 = surface } var arg2 wl.Object if output != nil { arg2 = output } child := &ExtSessionLockSurface{} child.SetContext(o.Context()) if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_session_lock_v1.get_lock_surface", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1), wl.ArgObject(arg2)); err != nil { return nil, err } return child, nil } // This request indicates that the session should be unlocked, for example because the user has entered their password and it has been verified by the client. This request also informs the compositor that the lock object will no longer be used and should be destroyed. Existing objects created through this interface remain valid. After this request is made, lock surfaces created through this object should be destroyed by the client as they will no longer be used by the compositor. It is a protocol error to make this request if the locked event has not been sent. In that case, the lock object must be destroyed using the destroy request. Note that a correct client that wishes to exit directly after unlocking the session must use the wl_display.sync request to ensure the server receives and processes the unlock_and_destroy request. Otherwise there is no guarantee that the server has unlocked the session due to the asynchronous nature of the Wayland protocol. For example, the server might terminate the client with a protocol error before it processes the unlock_and_destroy request. func (o *ExtSessionLock) UnlockAndDestroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "ext_session_lock_v1.unlock_and_destroy", Destructor: true}); err != nil { return err } return nil } // OnLocked registers a handler for the locked 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 *ExtSessionLock) OnLocked(handler func()) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onLocked = append(o.onLocked, handler) } // handlersForLocked returns the handlers registered for locked, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtSessionLock) handlersForLocked() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onLocked } // 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 *ExtSessionLock) 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 *ExtSessionLock) handlersForFinished() []func() { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onFinished } // EventSignature returns the declared event argument types in wire order. func (o *ExtSessionLock) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "", true case 1: return "", true default: return "", false } } // Dispatch decodes one event on ext_session_lock_v1 and calls the registered handlers. func (o *ExtSessionLock) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // locked for i, handler := range o.handlersForLocked() { _ = i handler() } case 1: // finished for i, handler := range o.handlersForFinished() { _ = i handler() } default: } } // ExtSessionLockSurfaceInterface is the protocol interface name. const ExtSessionLockSurfaceInterface = "ext_session_lock_surface_v1" // ExtSessionLockSurface is the generated binding for ext_session_lock_surface_v1 version 1. type ExtSessionLockSurface struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onConfigure []func(serial uint32, width uint32, height uint32) } // NewExtSessionLockSurface returns an unbound ExtSessionLockSurface. func NewExtSessionLockSurface(ctx *wl.Context) *ExtSessionLockSurface { obj := &ExtSessionLockSurface{} obj.SetContext(ctx) ctx.Register(obj) return obj } // This informs the compositor that the lock surface object will no longer be used. It is recommended for a lock client to destroy lock surfaces if their corresponding wl_output global is removed. If a lock surface on an active output is destroyed before the ext_session_lock_v1.unlock_and_destroy event is sent, the compositor must fall back to rendering a solid color. func (o *ExtSessionLockSurface) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_session_lock_surface_v1.destroy", Destructor: true}); err != nil { return err } return nil } // When a configure event is received, if a client commits the surface in response to the configure event, then the client must make an ack_configure request sometime before the commit request, passing along the serial of the configure event. If the client receives multiple configure events before it can respond to one, it only has to ack the last configure event. A client is not required to commit immediately after sending an ack_configure request - it may even ack_configure several times before its next surface commit. A client may send multiple ack_configure requests before committing, but only the last request sent before a commit indicates which configure event the client really is responding to. Sending an ack_configure request consumes the configure event referenced by the given serial, as well as all older configure events sent on this object. It is a protocol error to issue multiple ack_configure requests referencing the same configure event or to issue an ack_configure request referencing a configure event older than the last configure event acked for a given lock surface. func (o *ExtSessionLockSurface) AckConfigure(serial uint32) error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_session_lock_surface_v1.ack_configure"}, wl.ArgUint(serial)); err != nil { return err } return nil } // OnConfigure registers a handler for the configure 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 *ExtSessionLockSurface) OnConfigure(handler func(serial uint32, width uint32, height uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onConfigure = append(o.onConfigure, handler) } // handlersForConfigure returns the handlers registered for configure, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *ExtSessionLockSurface) handlersForConfigure() []func(serial uint32, width uint32, height uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onConfigure } // EventSignature returns the declared event argument types in wire order. func (o *ExtSessionLockSurface) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,uint,uint,", true default: return "", false } } // Dispatch decodes one event on ext_session_lock_surface_v1 and calls the registered handlers. func (o *ExtSessionLockSurface) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // configure serial := event.Uint32() width := event.Uint32() height := event.Uint32() for i, handler := range o.handlersForConfigure() { _ = i handler(serial, width, height) } default: } }