extforeigntoplevellist_generated.go RawHistoryFolder
1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: ext_foreign_toplevel_list_v1
3// Source: ext-foreign-toplevel-list-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2018 Ilia Bozhinov
7// Copyright © 2020 Isaac Freund
8// Copyright © 2022 wb9688
9// Copyright © 2023 i509VCB
10//
11// Permission to use, copy, modify, distribute, and sell this
12// software and its documentation for any purpose is hereby granted
13// without fee, provided that the above copyright notice appear in
14// all copies and that both that copyright notice and this permission
15// notice appear in supporting documentation, and that the name of
16// the copyright holders not be used in advertising or publicity
17// pertaining to distribution of the software without specific,
18// written prior permission. The copyright holders make no
19// representations about the suitability of this software for any
20// purpose. It is provided "as is" without express or implied
21// warranty.
22//
23// THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
24// SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
25// FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
26// SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
27// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
28// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
29// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
30// THIS SOFTWARE.
31
32package extforeigntoplevellist
33
34import (
35 "sync"
36
37 "github.com/bnema/wlturbo/wl"
38)
39
40// ExtForeignToplevelListInterface is the protocol interface name.
41const ExtForeignToplevelListInterface = "ext_foreign_toplevel_list_v1"
42
43// ExtForeignToplevelList is the generated binding for ext_foreign_toplevel_list_v1 version 1.
44type ExtForeignToplevelList struct {
45 wl.BaseProxy
46 // handlersMu guards the handler slices: a client may register or replace
47 // handlers while another goroutine dispatches events.
48 handlersMu sync.Mutex
49 onToplevel []func(toplevelObject *ExtForeignToplevelHandle)
50 onFinished []func()
51}
52
53// NewExtForeignToplevelList returns an unbound ExtForeignToplevelList.
54func NewExtForeignToplevelList(ctx *wl.Context) *ExtForeignToplevelList {
55 obj := &ExtForeignToplevelList{}
56 obj.SetContext(ctx)
57 ctx.Register(obj)
58 return obj
59}
60
61// This request indicates that the client no longer wishes to receive events for new toplevels. The Wayland protocol is asynchronous, meaning the compositor may send further toplevel events until the stop request is processed. The client should wait for a ext_foreign_toplevel_list_v1.finished event before destroying this object.
62func (o *ExtForeignToplevelList) Stop() error {
63 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_foreign_toplevel_list_v1.stop"}); err != nil {
64 return err
65 }
66 return nil
67}
68
69// This request should be called either when the client will no longer use the ext_foreign_toplevel_list_v1 or after the finished event has been received to allow destruction of the object. If a client wishes to destroy this object it should send a ext_foreign_toplevel_list_v1.stop request and wait for a ext_foreign_toplevel_list_v1.finished event, then destroy the handles and then this object.
70func (o *ExtForeignToplevelList) Destroy() error {
71 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_foreign_toplevel_list_v1.destroy", Destructor: true}); err != nil {
72 return err
73 }
74 return nil
75}
76
77// OnToplevel registers a handler for the toplevel event.
78//
79// Handlers are appended, so a second call adds another handler rather than
80// replacing the first. Registration is safe while another goroutine dispatches.
81func (o *ExtForeignToplevelList) OnToplevel(handler func(toplevelObject *ExtForeignToplevelHandle)) {
82 if handler == nil {
83 return
84 }
85 o.handlersMu.Lock()
86 defer o.handlersMu.Unlock()
87 o.onToplevel = append(o.onToplevel, handler)
88}
89
90// handlersForToplevel returns the handlers registered for toplevel, taken
91// under the lock so a handler may register another handler while events are
92// being dispatched.
93func (o *ExtForeignToplevelList) handlersForToplevel() []func(toplevelObject *ExtForeignToplevelHandle) {
94 o.handlersMu.Lock()
95 defer o.handlersMu.Unlock()
96 return o.onToplevel
97}
98
99// OnFinished registers a handler for the finished event.
100//
101// Handlers are appended, so a second call adds another handler rather than
102// replacing the first. Registration is safe while another goroutine dispatches.
103func (o *ExtForeignToplevelList) OnFinished(handler func()) {
104 if handler == nil {
105 return
106 }
107 o.handlersMu.Lock()
108 defer o.handlersMu.Unlock()
109 o.onFinished = append(o.onFinished, handler)
110}
111
112// handlersForFinished returns the handlers registered for finished, taken
113// under the lock so a handler may register another handler while events are
114// being dispatched.
115func (o *ExtForeignToplevelList) handlersForFinished() []func() {
116 o.handlersMu.Lock()
117 defer o.handlersMu.Unlock()
118 return o.onFinished
119}
120
121// EventSignature returns the declared event argument types in wire order.
122func (o *ExtForeignToplevelList) EventSignature(opcode uint16) (string, bool) {
123 switch opcode {
124 case 0:
125 return "new_id,", true
126 case 1:
127 return "", true
128 default:
129 return "", false
130 }
131}
132
133// Dispatch decodes one event on ext_foreign_toplevel_list_v1 and calls the registered handlers.
134func (o *ExtForeignToplevelList) Dispatch(event *wl.Event) {
135 switch event.Opcode {
136 case 0: // toplevel
137 toplevelID := event.Uint32()
138 toplevelObject := &ExtForeignToplevelHandle{}
139 toplevelObject.SetContext(o.Context())
140 toplevelObject.SetID(toplevelID)
141 toplevelObject.SetVersion(o.Version())
142 o.Context().Register(toplevelObject)
143
144 for i, handler := range o.handlersForToplevel() {
145 _ = i
146 handler(toplevelObject)
147 }
148 case 1: // finished
149
150 for i, handler := range o.handlersForFinished() {
151 _ = i
152 handler()
153 }
154 default:
155 }
156}
157
158// ExtForeignToplevelHandleInterface is the protocol interface name.
159const ExtForeignToplevelHandleInterface = "ext_foreign_toplevel_handle_v1"
160
161// ExtForeignToplevelHandle is the generated binding for ext_foreign_toplevel_handle_v1 version 1.
162type ExtForeignToplevelHandle struct {
163 wl.BaseProxy
164 // handlersMu guards the handler slices: a client may register or replace
165 // handlers while another goroutine dispatches events.
166 handlersMu sync.Mutex
167 onClosed []func()
168 onDone []func()
169 onTitle []func(title string)
170 onAppId []func(appId string)
171 onIdentifier []func(identifier string)
172}
173
174// NewExtForeignToplevelHandle returns an unbound ExtForeignToplevelHandle.
175func NewExtForeignToplevelHandle(ctx *wl.Context) *ExtForeignToplevelHandle {
176 obj := &ExtForeignToplevelHandle{}
177 obj.SetContext(ctx)
178 ctx.Register(obj)
179 return obj
180}
181
182// This request should be used when the client will no longer use the handle or after the closed event has been received to allow destruction of the object. When a handle is destroyed, a new handle may not be created by the server until the toplevel is unmapped and then remapped. Destroying a toplevel handle is not recommended unless the client is cleaning up child objects before destroying the ext_foreign_toplevel_list_v1 object, the toplevel was closed or the toplevel handle will not be used in the future. Other protocols which extend the ext_foreign_toplevel_handle_v1 interface should require destructors for extension interfaces be called before allowing the toplevel handle to be destroyed.
183func (o *ExtForeignToplevelHandle) Destroy() error {
184 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_foreign_toplevel_handle_v1.destroy", Destructor: true}); err != nil {
185 return err
186 }
187 return nil
188}
189
190// OnClosed registers a handler for the closed event.
191//
192// Handlers are appended, so a second call adds another handler rather than
193// replacing the first. Registration is safe while another goroutine dispatches.
194func (o *ExtForeignToplevelHandle) OnClosed(handler func()) {
195 if handler == nil {
196 return
197 }
198 o.handlersMu.Lock()
199 defer o.handlersMu.Unlock()
200 o.onClosed = append(o.onClosed, handler)
201}
202
203// handlersForClosed returns the handlers registered for closed, taken
204// under the lock so a handler may register another handler while events are
205// being dispatched.
206func (o *ExtForeignToplevelHandle) handlersForClosed() []func() {
207 o.handlersMu.Lock()
208 defer o.handlersMu.Unlock()
209 return o.onClosed
210}
211
212// OnDone registers a handler for the done event.
213//
214// Handlers are appended, so a second call adds another handler rather than
215// replacing the first. Registration is safe while another goroutine dispatches.
216func (o *ExtForeignToplevelHandle) OnDone(handler func()) {
217 if handler == nil {
218 return
219 }
220 o.handlersMu.Lock()
221 defer o.handlersMu.Unlock()
222 o.onDone = append(o.onDone, handler)
223}
224
225// handlersForDone returns the handlers registered for done, taken
226// under the lock so a handler may register another handler while events are
227// being dispatched.
228func (o *ExtForeignToplevelHandle) handlersForDone() []func() {
229 o.handlersMu.Lock()
230 defer o.handlersMu.Unlock()
231 return o.onDone
232}
233
234// OnTitle registers a handler for the title event.
235//
236// Handlers are appended, so a second call adds another handler rather than
237// replacing the first. Registration is safe while another goroutine dispatches.
238func (o *ExtForeignToplevelHandle) OnTitle(handler func(title string)) {
239 if handler == nil {
240 return
241 }
242 o.handlersMu.Lock()
243 defer o.handlersMu.Unlock()
244 o.onTitle = append(o.onTitle, handler)
245}
246
247// handlersForTitle returns the handlers registered for title, taken
248// under the lock so a handler may register another handler while events are
249// being dispatched.
250func (o *ExtForeignToplevelHandle) handlersForTitle() []func(title string) {
251 o.handlersMu.Lock()
252 defer o.handlersMu.Unlock()
253 return o.onTitle
254}
255
256// OnAppId registers a handler for the app_id event.
257//
258// Handlers are appended, so a second call adds another handler rather than
259// replacing the first. Registration is safe while another goroutine dispatches.
260func (o *ExtForeignToplevelHandle) OnAppId(handler func(appId string)) {
261 if handler == nil {
262 return
263 }
264 o.handlersMu.Lock()
265 defer o.handlersMu.Unlock()
266 o.onAppId = append(o.onAppId, handler)
267}
268
269// handlersForAppId returns the handlers registered for app_id, taken
270// under the lock so a handler may register another handler while events are
271// being dispatched.
272func (o *ExtForeignToplevelHandle) handlersForAppId() []func(appId string) {
273 o.handlersMu.Lock()
274 defer o.handlersMu.Unlock()
275 return o.onAppId
276}
277
278// OnIdentifier registers a handler for the identifier event.
279//
280// Handlers are appended, so a second call adds another handler rather than
281// replacing the first. Registration is safe while another goroutine dispatches.
282func (o *ExtForeignToplevelHandle) OnIdentifier(handler func(identifier string)) {
283 if handler == nil {
284 return
285 }
286 o.handlersMu.Lock()
287 defer o.handlersMu.Unlock()
288 o.onIdentifier = append(o.onIdentifier, handler)
289}
290
291// handlersForIdentifier returns the handlers registered for identifier, taken
292// under the lock so a handler may register another handler while events are
293// being dispatched.
294func (o *ExtForeignToplevelHandle) handlersForIdentifier() []func(identifier string) {
295 o.handlersMu.Lock()
296 defer o.handlersMu.Unlock()
297 return o.onIdentifier
298}
299
300// EventSignature returns the declared event argument types in wire order.
301func (o *ExtForeignToplevelHandle) EventSignature(opcode uint16) (string, bool) {
302 switch opcode {
303 case 0:
304 return "", true
305 case 1:
306 return "", true
307 case 2:
308 return "string,", true
309 case 3:
310 return "string,", true
311 case 4:
312 return "string,", true
313 default:
314 return "", false
315 }
316}
317
318// Dispatch decodes one event on ext_foreign_toplevel_handle_v1 and calls the registered handlers.
319func (o *ExtForeignToplevelHandle) Dispatch(event *wl.Event) {
320 switch event.Opcode {
321 case 0: // closed
322
323 for i, handler := range o.handlersForClosed() {
324 _ = i
325 handler()
326 }
327 case 1: // done
328
329 for i, handler := range o.handlersForDone() {
330 _ = i
331 handler()
332 }
333 case 2: // title
334 title := event.String()
335
336 for i, handler := range o.handlersForTitle() {
337 _ = i
338 handler(title)
339 }
340 case 3: // app_id
341 appId := event.String()
342
343 for i, handler := range o.handlersForAppId() {
344 _ = i
345 handler(appId)
346 }
347 case 4: // identifier
348 identifier := event.String()
349
350 for i, handler := range o.handlersForIdentifier() {
351 _ = i
352 handler(identifier)
353 }
354 default:
355 }
356}