1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: ext_transient_seat_v1
3// Source: ext-transient-seat-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2020 - 2023 Andri Yngvason
7//
8// Permission is hereby granted, free of charge, to any person obtaining a
9// copy of this software and associated documentation files (the "Software"),
10// to deal in the Software without restriction, including without limitation
11// the rights to use, copy, modify, merge, publish, distribute, sublicense,
12// and/or sell copies of the Software, and to permit persons to whom the
13// Software is furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice (including the next
16// paragraph) shall be included in all copies or substantial portions of the
17// Software.
18//
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25// DEALINGS IN THE SOFTWARE.
26
27package exttransientseat
28
29import (
30 "sync"
31
32 "github.com/bnema/wlturbo/wl"
33)
34
35// ExtTransientSeatManagerInterface is the protocol interface name.
36const ExtTransientSeatManagerInterface = "ext_transient_seat_manager_v1"
37
38// ExtTransientSeatManager is the generated binding for ext_transient_seat_manager_v1 version 1.
39type ExtTransientSeatManager struct {
40 wl.BaseProxy
41}
42
43// NewExtTransientSeatManager returns an unbound ExtTransientSeatManager.
44func NewExtTransientSeatManager(ctx *wl.Context) *ExtTransientSeatManager {
45 obj := &ExtTransientSeatManager{}
46 obj.SetContext(ctx)
47 ctx.Register(obj)
48 return obj
49}
50
51// 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.
52func (o *ExtTransientSeatManager) Create() (*ExtTransientSeat, error) {
53 child := &ExtTransientSeat{}
54 child.SetContext(o.Context())
55 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 {
56 return nil, err
57 }
58 return child, nil
59}
60
61// Destroy the manager. All objects created by the manager will remain valid until they are destroyed themselves.
62func (o *ExtTransientSeatManager) Destroy() error {
63 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_transient_seat_manager_v1.destroy", Destructor: true}); err != nil {
64 return err
65 }
66 return nil
67}
68
69// EventSignature returns the declared event argument types in wire order.
70func (o *ExtTransientSeatManager) EventSignature(opcode uint16) (string, bool) {
71 switch opcode {
72 default:
73 return "", false
74 }
75}
76
77// Dispatch decodes one event on ext_transient_seat_manager_v1 and calls the registered handlers.
78func (o *ExtTransientSeatManager) Dispatch(event *wl.Event) {
79 switch event.Opcode {
80 default:
81 }
82}
83
84// ExtTransientSeatInterface is the protocol interface name.
85const ExtTransientSeatInterface = "ext_transient_seat_v1"
86
87// ExtTransientSeat is the generated binding for ext_transient_seat_v1 version 1.
88type ExtTransientSeat struct {
89 wl.BaseProxy
90 // handlersMu guards the handler slices: a client may register or replace
91 // handlers while another goroutine dispatches events.
92 handlersMu sync.Mutex
93 onReady []func(globalName uint32)
94 onDenied []func()
95}
96
97// NewExtTransientSeat returns an unbound ExtTransientSeat.
98func NewExtTransientSeat(ctx *wl.Context) *ExtTransientSeat {
99 obj := &ExtTransientSeat{}
100 obj.SetContext(ctx)
101 ctx.Register(obj)
102 return obj
103}
104
105// When the transient seat object is destroyed by the client, the associated seat created by the compositor is also destroyed.
106func (o *ExtTransientSeat) Destroy() error {
107 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_transient_seat_v1.destroy", Destructor: true}); err != nil {
108 return err
109 }
110 return nil
111}
112
113// OnReady registers a handler for the ready event.
114//
115// Handlers are appended, so a second call adds another handler rather than
116// replacing the first. Registration is safe while another goroutine dispatches.
117func (o *ExtTransientSeat) OnReady(handler func(globalName uint32)) {
118 if handler == nil {
119 return
120 }
121 o.handlersMu.Lock()
122 defer o.handlersMu.Unlock()
123 o.onReady = append(o.onReady, handler)
124}
125
126// handlersForReady returns the handlers registered for ready, taken
127// under the lock so a handler may register another handler while events are
128// being dispatched.
129func (o *ExtTransientSeat) handlersForReady() []func(globalName uint32) {
130 o.handlersMu.Lock()
131 defer o.handlersMu.Unlock()
132 return o.onReady
133}
134
135// OnDenied registers a handler for the denied event.
136//
137// Handlers are appended, so a second call adds another handler rather than
138// replacing the first. Registration is safe while another goroutine dispatches.
139func (o *ExtTransientSeat) OnDenied(handler func()) {
140 if handler == nil {
141 return
142 }
143 o.handlersMu.Lock()
144 defer o.handlersMu.Unlock()
145 o.onDenied = append(o.onDenied, handler)
146}
147
148// handlersForDenied returns the handlers registered for denied, taken
149// under the lock so a handler may register another handler while events are
150// being dispatched.
151func (o *ExtTransientSeat) handlersForDenied() []func() {
152 o.handlersMu.Lock()
153 defer o.handlersMu.Unlock()
154 return o.onDenied
155}
156
157// EventSignature returns the declared event argument types in wire order.
158func (o *ExtTransientSeat) EventSignature(opcode uint16) (string, bool) {
159 switch opcode {
160 case 0:
161 return "uint,", true
162 case 1:
163 return "", true
164 default:
165 return "", false
166 }
167}
168
169// Dispatch decodes one event on ext_transient_seat_v1 and calls the registered handlers.
170func (o *ExtTransientSeat) Dispatch(event *wl.Event) {
171 switch event.Opcode {
172 case 0: // ready
173 globalName := event.Uint32()
174
175 for i, handler := range o.handlersForReady() {
176 _ = i
177 handler(globalName)
178 }
179 case 1: // denied
180
181 for i, handler := range o.handlersForDenied() {
182 _ = i
183 handler()
184 }
185 default:
186 }
187}