wlrforeigntoplevelmanagement_generated.go RawHistoryFolder
1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: wlr_foreign_toplevel_management_unstable_v1
3// Source: wlr-foreign-toplevel-management-unstable-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2018 Ilia Bozhinov
7//
8// Permission to use, copy, modify, distribute, and sell this
9// software and its documentation for any purpose is hereby granted
10// without fee, provided that the above copyright notice appear in
11// all copies and that both that copyright notice and this permission
12// notice appear in supporting documentation, and that the name of
13// the copyright holders not be used in advertising or publicity
14// pertaining to distribution of the software without specific,
15// written prior permission. The copyright holders make no
16// representations about the suitability of this software for any
17// purpose. It is provided "as is" without express or implied
18// warranty.
19//
20// THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
21// SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
22// FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
23// SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
25// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
26// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
27// THIS SOFTWARE.
28
29package wlrforeigntoplevelmanagement
30
31import (
32 "sync"
33
34 cross_wl_output "github.com/bnema/go-wayland-bindings/client/wayland"
35 cross_wl_seat "github.com/bnema/go-wayland-bindings/client/wayland"
36 cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland"
37 "github.com/bnema/wlturbo/wl"
38)
39
40// STATE_MAXIMIZED is the state maximized value.
41const STATE_MAXIMIZED = 0
42
43// STATE_MINIMIZED is the state minimized value.
44const STATE_MINIMIZED = 1
45
46// STATE_ACTIVATED is the state activated value.
47const STATE_ACTIVATED = 2
48
49// STATE_FULLSCREEN is the state fullscreen value.
50const STATE_FULLSCREEN = 3
51
52// ERROR_INVALID_RECTANGLE is the error invalid_rectangle value.
53const ERROR_INVALID_RECTANGLE = 0
54
55// ForeignToplevelManagerInterface is the protocol interface name.
56const ForeignToplevelManagerInterface = "zwlr_foreign_toplevel_manager_v1"
57
58// ForeignToplevelManager is the generated binding for zwlr_foreign_toplevel_manager_v1 version 3.
59type ForeignToplevelManager struct {
60 wl.BaseProxy
61 // handlersMu guards the handler slices: a client may register or replace
62 // handlers while another goroutine dispatches events.
63 handlersMu sync.Mutex
64 onToplevel []func(toplevelObject *ForeignToplevelHandle)
65 onFinished []func()
66}
67
68// NewForeignToplevelManager returns an unbound ForeignToplevelManager.
69func NewForeignToplevelManager(ctx *wl.Context) *ForeignToplevelManager {
70 obj := &ForeignToplevelManager{}
71 obj.SetContext(ctx)
72 ctx.Register(obj)
73 return obj
74}
75
76// Indicates the client no longer wishes to receive events for new toplevels. However the compositor may emit further toplevel_created events, until the finished event is emitted. The client must not send any more requests after this one.
77func (o *ForeignToplevelManager) Stop() error {
78 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_foreign_toplevel_manager_v1.stop"}); err != nil {
79 return err
80 }
81 return nil
82}
83
84// OnToplevel registers a handler for the toplevel event.
85//
86// Handlers are appended, so a second call adds another handler rather than
87// replacing the first. Registration is safe while another goroutine dispatches.
88func (o *ForeignToplevelManager) OnToplevel(handler func(toplevelObject *ForeignToplevelHandle)) {
89 if handler == nil {
90 return
91 }
92 o.handlersMu.Lock()
93 defer o.handlersMu.Unlock()
94 o.onToplevel = append(o.onToplevel, handler)
95}
96
97// handlersForToplevel returns the handlers registered for toplevel, taken
98// under the lock so a handler may register another handler while events are
99// being dispatched.
100func (o *ForeignToplevelManager) handlersForToplevel() []func(toplevelObject *ForeignToplevelHandle) {
101 o.handlersMu.Lock()
102 defer o.handlersMu.Unlock()
103 return o.onToplevel
104}
105
106// OnFinished registers a handler for the finished event.
107//
108// Handlers are appended, so a second call adds another handler rather than
109// replacing the first. Registration is safe while another goroutine dispatches.
110func (o *ForeignToplevelManager) OnFinished(handler func()) {
111 if handler == nil {
112 return
113 }
114 o.handlersMu.Lock()
115 defer o.handlersMu.Unlock()
116 o.onFinished = append(o.onFinished, handler)
117}
118
119// handlersForFinished returns the handlers registered for finished, taken
120// under the lock so a handler may register another handler while events are
121// being dispatched.
122func (o *ForeignToplevelManager) handlersForFinished() []func() {
123 o.handlersMu.Lock()
124 defer o.handlersMu.Unlock()
125 return o.onFinished
126}
127
128// EventSignature returns the declared event argument types in wire order.
129func (o *ForeignToplevelManager) EventSignature(opcode uint16) (string, bool) {
130 switch opcode {
131 case 0:
132 return "new_id,", true
133 case 1:
134 return "", true
135 default:
136 return "", false
137 }
138}
139
140// Dispatch decodes one event on zwlr_foreign_toplevel_manager_v1 and calls the registered handlers.
141func (o *ForeignToplevelManager) Dispatch(event *wl.Event) {
142 switch event.Opcode {
143 case 0: // toplevel
144 toplevelID := event.Uint32()
145 toplevelObject := &ForeignToplevelHandle{}
146 toplevelObject.SetContext(o.Context())
147 toplevelObject.SetID(toplevelID)
148 toplevelObject.SetVersion(o.Version())
149 o.Context().Register(toplevelObject)
150
151 for i, handler := range o.handlersForToplevel() {
152 _ = i
153 handler(toplevelObject)
154 }
155 case 1: // finished
156
157 for i, handler := range o.handlersForFinished() {
158 _ = i
159 handler()
160 }
161 o.Context().Unregister(o)
162 default:
163 }
164}
165
166// ForeignToplevelHandleInterface is the protocol interface name.
167const ForeignToplevelHandleInterface = "zwlr_foreign_toplevel_handle_v1"
168
169// ForeignToplevelHandle is the generated binding for zwlr_foreign_toplevel_handle_v1 version 3.
170type ForeignToplevelHandle struct {
171 wl.BaseProxy
172 // handlersMu guards the handler slices: a client may register or replace
173 // handlers while another goroutine dispatches events.
174 handlersMu sync.Mutex
175 onTitle []func(title string)
176 onAppId []func(appId string)
177 onOutputEnter []func(outputID uint32)
178 onOutputLeave []func(outputID uint32)
179 onState []func(state []byte)
180 onDone []func()
181 onClosed []func()
182 onParent []func(parentID uint32)
183}
184
185// NewForeignToplevelHandle returns an unbound ForeignToplevelHandle.
186func NewForeignToplevelHandle(ctx *wl.Context) *ForeignToplevelHandle {
187 obj := &ForeignToplevelHandle{}
188 obj.SetContext(ctx)
189 ctx.Register(obj)
190 return obj
191}
192
193// Requests that the toplevel be maximized. If the maximized state actually changes, this will be indicated by the state event.
194func (o *ForeignToplevelHandle) SetMaximized() error {
195 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_foreign_toplevel_handle_v1.set_maximized"}); err != nil {
196 return err
197 }
198 return nil
199}
200
201// Requests that the toplevel be unmaximized. If the maximized state actually changes, this will be indicated by the state event.
202func (o *ForeignToplevelHandle) UnsetMaximized() error {
203 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_foreign_toplevel_handle_v1.unset_maximized"}); err != nil {
204 return err
205 }
206 return nil
207}
208
209// Requests that the toplevel be minimized. If the minimized state actually changes, this will be indicated by the state event.
210func (o *ForeignToplevelHandle) SetMinimized() error {
211 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_foreign_toplevel_handle_v1.set_minimized"}); err != nil {
212 return err
213 }
214 return nil
215}
216
217// Requests that the toplevel be unminimized. If the minimized state actually changes, this will be indicated by the state event.
218func (o *ForeignToplevelHandle) UnsetMinimized() error {
219 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwlr_foreign_toplevel_handle_v1.unset_minimized"}); err != nil {
220 return err
221 }
222 return nil
223}
224
225// Request that this toplevel be activated on the given seat. There is no guarantee the toplevel will be actually activated.
226func (o *ForeignToplevelHandle) Activate(seat *cross_wl_seat.Seat) error {
227 var arg0 wl.Object
228 if seat != nil {
229 arg0 = seat
230 }
231 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "zwlr_foreign_toplevel_handle_v1.activate"}, wl.ArgObject(arg0)); err != nil {
232 return err
233 }
234 return nil
235}
236
237// Send a request to the toplevel to close itself. The compositor would typically use a shell-specific method to carry out this request, for example by sending the xdg_toplevel.close event. However, this gives no guarantees the toplevel will actually be destroyed. If and when this happens, the zwlr_foreign_toplevel_handle_v1.closed event will be emitted.
238func (o *ForeignToplevelHandle) Close() error {
239 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 5, Name: "zwlr_foreign_toplevel_handle_v1.close"}); err != nil {
240 return err
241 }
242 return nil
243}
244
245// The rectangle of the surface specified in this request corresponds to the place where the app using this protocol represents the given toplevel. It can be used by the compositor as a hint for some operations, e.g minimizing. The client is however not required to set this, in which case the compositor is free to decide some default value. If the client specifies more than one rectangle, only the last one is considered. The dimensions are given in surface-local coordinates. Setting width=height=0 removes the already-set rectangle.
246func (o *ForeignToplevelHandle) SetRectangle(surface *cross_wl_surface.Surface, x int32, y int32, width int32, height int32) error {
247 var arg0 wl.Object
248 if surface != nil {
249 arg0 = surface
250 }
251 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 6, Name: "zwlr_foreign_toplevel_handle_v1.set_rectangle"}, wl.ArgObject(arg0), wl.ArgInt(x), wl.ArgInt(y), wl.ArgInt(width), wl.ArgInt(height)); err != nil {
252 return err
253 }
254 return nil
255}
256
257// Destroys the zwlr_foreign_toplevel_handle_v1 object. This request should be called either when the client does not want to use the toplevel anymore or after the closed event to finalize the destruction of the object.
258func (o *ForeignToplevelHandle) Destroy() error {
259 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 7, Name: "zwlr_foreign_toplevel_handle_v1.destroy", Destructor: true}); err != nil {
260 return err
261 }
262 return nil
263}
264
265// Requests that the toplevel be fullscreened on the given output. If the fullscreen state and/or the outputs the toplevel is visible on actually change, this will be indicated by the state and output_enter/leave events. The output parameter is only a hint to the compositor. Also, if output is NULL, the compositor should decide which output the toplevel will be fullscreened on, if at all.
266func (o *ForeignToplevelHandle) SetFullscreen(output *cross_wl_output.Output) error {
267 var arg0 wl.Object
268 if output != nil {
269 arg0 = output
270 }
271 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 8, Name: "zwlr_foreign_toplevel_handle_v1.set_fullscreen", Since: 2}, wl.ArgObject(arg0)); err != nil {
272 return err
273 }
274 return nil
275}
276
277// Requests that the toplevel be unfullscreened. If the fullscreen state actually changes, this will be indicated by the state event.
278func (o *ForeignToplevelHandle) UnsetFullscreen() error {
279 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 9, Name: "zwlr_foreign_toplevel_handle_v1.unset_fullscreen", Since: 2}); err != nil {
280 return err
281 }
282 return nil
283}
284
285// OnTitle registers a handler for the title event.
286//
287// Handlers are appended, so a second call adds another handler rather than
288// replacing the first. Registration is safe while another goroutine dispatches.
289func (o *ForeignToplevelHandle) OnTitle(handler func(title string)) {
290 if handler == nil {
291 return
292 }
293 o.handlersMu.Lock()
294 defer o.handlersMu.Unlock()
295 o.onTitle = append(o.onTitle, handler)
296}
297
298// handlersForTitle returns the handlers registered for title, taken
299// under the lock so a handler may register another handler while events are
300// being dispatched.
301func (o *ForeignToplevelHandle) handlersForTitle() []func(title string) {
302 o.handlersMu.Lock()
303 defer o.handlersMu.Unlock()
304 return o.onTitle
305}
306
307// OnAppId registers a handler for the app_id event.
308//
309// Handlers are appended, so a second call adds another handler rather than
310// replacing the first. Registration is safe while another goroutine dispatches.
311func (o *ForeignToplevelHandle) OnAppId(handler func(appId string)) {
312 if handler == nil {
313 return
314 }
315 o.handlersMu.Lock()
316 defer o.handlersMu.Unlock()
317 o.onAppId = append(o.onAppId, handler)
318}
319
320// handlersForAppId returns the handlers registered for app_id, taken
321// under the lock so a handler may register another handler while events are
322// being dispatched.
323func (o *ForeignToplevelHandle) handlersForAppId() []func(appId string) {
324 o.handlersMu.Lock()
325 defer o.handlersMu.Unlock()
326 return o.onAppId
327}
328
329// OnOutputEnter registers a handler for the output_enter event.
330//
331// Handlers are appended, so a second call adds another handler rather than
332// replacing the first. Registration is safe while another goroutine dispatches.
333func (o *ForeignToplevelHandle) OnOutputEnter(handler func(outputID uint32)) {
334 if handler == nil {
335 return
336 }
337 o.handlersMu.Lock()
338 defer o.handlersMu.Unlock()
339 o.onOutputEnter = append(o.onOutputEnter, handler)
340}
341
342// handlersForOutputEnter returns the handlers registered for output_enter, taken
343// under the lock so a handler may register another handler while events are
344// being dispatched.
345func (o *ForeignToplevelHandle) handlersForOutputEnter() []func(outputID uint32) {
346 o.handlersMu.Lock()
347 defer o.handlersMu.Unlock()
348 return o.onOutputEnter
349}
350
351// OnOutputLeave registers a handler for the output_leave event.
352//
353// Handlers are appended, so a second call adds another handler rather than
354// replacing the first. Registration is safe while another goroutine dispatches.
355func (o *ForeignToplevelHandle) OnOutputLeave(handler func(outputID uint32)) {
356 if handler == nil {
357 return
358 }
359 o.handlersMu.Lock()
360 defer o.handlersMu.Unlock()
361 o.onOutputLeave = append(o.onOutputLeave, handler)
362}
363
364// handlersForOutputLeave returns the handlers registered for output_leave, taken
365// under the lock so a handler may register another handler while events are
366// being dispatched.
367func (o *ForeignToplevelHandle) handlersForOutputLeave() []func(outputID uint32) {
368 o.handlersMu.Lock()
369 defer o.handlersMu.Unlock()
370 return o.onOutputLeave
371}
372
373// OnState registers a handler for the state event.
374//
375// Handlers are appended, so a second call adds another handler rather than
376// replacing the first. Registration is safe while another goroutine dispatches.
377func (o *ForeignToplevelHandle) OnState(handler func(state []byte)) {
378 if handler == nil {
379 return
380 }
381 o.handlersMu.Lock()
382 defer o.handlersMu.Unlock()
383 o.onState = append(o.onState, handler)
384}
385
386// handlersForState returns the handlers registered for state, taken
387// under the lock so a handler may register another handler while events are
388// being dispatched.
389func (o *ForeignToplevelHandle) handlersForState() []func(state []byte) {
390 o.handlersMu.Lock()
391 defer o.handlersMu.Unlock()
392 return o.onState
393}
394
395// OnDone registers a handler for the done event.
396//
397// Handlers are appended, so a second call adds another handler rather than
398// replacing the first. Registration is safe while another goroutine dispatches.
399func (o *ForeignToplevelHandle) OnDone(handler func()) {
400 if handler == nil {
401 return
402 }
403 o.handlersMu.Lock()
404 defer o.handlersMu.Unlock()
405 o.onDone = append(o.onDone, handler)
406}
407
408// handlersForDone returns the handlers registered for done, taken
409// under the lock so a handler may register another handler while events are
410// being dispatched.
411func (o *ForeignToplevelHandle) handlersForDone() []func() {
412 o.handlersMu.Lock()
413 defer o.handlersMu.Unlock()
414 return o.onDone
415}
416
417// OnClosed registers a handler for the closed event.
418//
419// Handlers are appended, so a second call adds another handler rather than
420// replacing the first. Registration is safe while another goroutine dispatches.
421func (o *ForeignToplevelHandle) OnClosed(handler func()) {
422 if handler == nil {
423 return
424 }
425 o.handlersMu.Lock()
426 defer o.handlersMu.Unlock()
427 o.onClosed = append(o.onClosed, handler)
428}
429
430// handlersForClosed returns the handlers registered for closed, taken
431// under the lock so a handler may register another handler while events are
432// being dispatched.
433func (o *ForeignToplevelHandle) handlersForClosed() []func() {
434 o.handlersMu.Lock()
435 defer o.handlersMu.Unlock()
436 return o.onClosed
437}
438
439// OnParent registers a handler for the parent event.
440//
441// Handlers are appended, so a second call adds another handler rather than
442// replacing the first. Registration is safe while another goroutine dispatches.
443func (o *ForeignToplevelHandle) OnParent(handler func(parentID uint32)) {
444 if handler == nil {
445 return
446 }
447 o.handlersMu.Lock()
448 defer o.handlersMu.Unlock()
449 o.onParent = append(o.onParent, handler)
450}
451
452// handlersForParent returns the handlers registered for parent, taken
453// under the lock so a handler may register another handler while events are
454// being dispatched.
455func (o *ForeignToplevelHandle) handlersForParent() []func(parentID uint32) {
456 o.handlersMu.Lock()
457 defer o.handlersMu.Unlock()
458 return o.onParent
459}
460
461// EventSignature returns the declared event argument types in wire order.
462func (o *ForeignToplevelHandle) EventSignature(opcode uint16) (string, bool) {
463 switch opcode {
464 case 0:
465 return "string,", true
466 case 1:
467 return "string,", true
468 case 2:
469 return "object,", true
470 case 3:
471 return "object,", true
472 case 4:
473 return "array,", true
474 case 5:
475 return "", true
476 case 6:
477 return "", true
478 case 7:
479 return "object,", true
480 default:
481 return "", false
482 }
483}
484
485// Dispatch decodes one event on zwlr_foreign_toplevel_handle_v1 and calls the registered handlers.
486func (o *ForeignToplevelHandle) Dispatch(event *wl.Event) {
487 switch event.Opcode {
488 case 0: // title
489 title := event.String()
490
491 for i, handler := range o.handlersForTitle() {
492 _ = i
493 handler(title)
494 }
495 case 1: // app_id
496 appId := event.String()
497
498 for i, handler := range o.handlersForAppId() {
499 _ = i
500 handler(appId)
501 }
502 case 2: // output_enter
503 outputID := event.Uint32()
504
505 for i, handler := range o.handlersForOutputEnter() {
506 _ = i
507 handler(outputID)
508 }
509 case 3: // output_leave
510 outputID := event.Uint32()
511
512 for i, handler := range o.handlersForOutputLeave() {
513 _ = i
514 handler(outputID)
515 }
516 case 4: // state
517 state := event.Array()
518
519 for i, handler := range o.handlersForState() {
520 _ = i
521 handler(state)
522 }
523 case 5: // done
524
525 for i, handler := range o.handlersForDone() {
526 _ = i
527 handler()
528 }
529 case 6: // closed
530
531 for i, handler := range o.handlersForClosed() {
532 _ = i
533 handler()
534 }
535 case 7: // parent
536 parentID := event.Uint32()
537
538 for i, handler := range o.handlersForParent() {
539 _ = i
540 handler(parentID)
541 }
542 default:
543 }
544}