wlroutputmanagement_generated.go RawHistoryFolder
1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: wlr_output_management_unstable_v1
3// Source: wlr-output-management-unstable-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2019 Purism SPC
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 wlroutputmanagement
30
31import (
32 "sync"
33
34 "github.com/bnema/wlturbo/wl"
35)
36
37// ADAPTIVE_SYNC_STATE_DISABLED is the adaptive_sync_state disabled value.
38const ADAPTIVE_SYNC_STATE_DISABLED = 0
39
40// ADAPTIVE_SYNC_STATE_ENABLED is the adaptive_sync_state enabled value.
41const ADAPTIVE_SYNC_STATE_ENABLED = 1
42
43// ERROR_ALREADY_CONFIGURED_HEAD is the error already_configured_head value.
44const ERROR_ALREADY_CONFIGURED_HEAD = 1
45
46// ERROR_UNCONFIGURED_HEAD is the error unconfigured_head value.
47const ERROR_UNCONFIGURED_HEAD = 2
48
49// ERROR_ALREADY_USED is the error already_used value.
50const ERROR_ALREADY_USED = 3
51
52// ERROR_ALREADY_SET is the error already_set value.
53const ERROR_ALREADY_SET = 1
54
55// ERROR_INVALID_MODE is the error invalid_mode value.
56const ERROR_INVALID_MODE = 2
57
58// ERROR_INVALID_CUSTOM_MODE is the error invalid_custom_mode value.
59const ERROR_INVALID_CUSTOM_MODE = 3
60
61// ERROR_INVALID_TRANSFORM is the error invalid_transform value.
62const ERROR_INVALID_TRANSFORM = 4
63
64// ERROR_INVALID_SCALE is the error invalid_scale value.
65const ERROR_INVALID_SCALE = 5
66
67// ERROR_INVALID_ADAPTIVE_SYNC_STATE is the error invalid_adaptive_sync_state value.
68const ERROR_INVALID_ADAPTIVE_SYNC_STATE = 6
69
70// OutputManagerInterface is the protocol interface name.
71const OutputManagerInterface = "zwlr_output_manager_v1"
72
73// OutputManager is the generated binding for zwlr_output_manager_v1 version 4.
74type OutputManager struct {
75 wl.BaseProxy
76 // handlersMu guards the handler slices: a client may register or replace
77 // handlers while another goroutine dispatches events.
78 handlersMu sync.Mutex
79 onHead []func(headObject *OutputHead)
80 onDone []func(serial uint32)
81 onFinished []func()
82}
83
84// NewOutputManager returns an unbound OutputManager.
85func NewOutputManager(ctx *wl.Context) *OutputManager {
86 obj := &OutputManager{}
87 obj.SetContext(ctx)
88 ctx.Register(obj)
89 return obj
90}
91
92// Create a new output configuration object. This allows to update head properties.
93func (o *OutputManager) CreateConfiguration(serial uint32) (*OutputConfiguration, error) {
94 child := &OutputConfiguration{}
95 child.SetContext(o.Context())
96 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_manager_v1.create_configuration", Child: child}, wl.ArgObject(child), wl.ArgUint(serial)); err != nil {
97 return nil, err
98 }
99 return child, nil
100}
101
102// Indicates the client no longer wishes to receive events for output configuration changes. However the compositor may emit further events, until the finished event is emitted. The client must not send any more requests after this one.
103func (o *OutputManager) Stop() error {
104 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_output_manager_v1.stop"}); err != nil {
105 return err
106 }
107 return nil
108}
109
110// OnHead registers a handler for the head event.
111//
112// Handlers are appended, so a second call adds another handler rather than
113// replacing the first. Registration is safe while another goroutine dispatches.
114func (o *OutputManager) OnHead(handler func(headObject *OutputHead)) {
115 if handler == nil {
116 return
117 }
118 o.handlersMu.Lock()
119 defer o.handlersMu.Unlock()
120 o.onHead = append(o.onHead, handler)
121}
122
123// handlersForHead returns the handlers registered for head, taken
124// under the lock so a handler may register another handler while events are
125// being dispatched.
126func (o *OutputManager) handlersForHead() []func(headObject *OutputHead) {
127 o.handlersMu.Lock()
128 defer o.handlersMu.Unlock()
129 return o.onHead
130}
131
132// OnDone registers a handler for the done event.
133//
134// Handlers are appended, so a second call adds another handler rather than
135// replacing the first. Registration is safe while another goroutine dispatches.
136func (o *OutputManager) OnDone(handler func(serial uint32)) {
137 if handler == nil {
138 return
139 }
140 o.handlersMu.Lock()
141 defer o.handlersMu.Unlock()
142 o.onDone = append(o.onDone, handler)
143}
144
145// handlersForDone returns the handlers registered for done, taken
146// under the lock so a handler may register another handler while events are
147// being dispatched.
148func (o *OutputManager) handlersForDone() []func(serial uint32) {
149 o.handlersMu.Lock()
150 defer o.handlersMu.Unlock()
151 return o.onDone
152}
153
154// OnFinished registers a handler for the finished event.
155//
156// Handlers are appended, so a second call adds another handler rather than
157// replacing the first. Registration is safe while another goroutine dispatches.
158func (o *OutputManager) OnFinished(handler func()) {
159 if handler == nil {
160 return
161 }
162 o.handlersMu.Lock()
163 defer o.handlersMu.Unlock()
164 o.onFinished = append(o.onFinished, handler)
165}
166
167// handlersForFinished returns the handlers registered for finished, taken
168// under the lock so a handler may register another handler while events are
169// being dispatched.
170func (o *OutputManager) handlersForFinished() []func() {
171 o.handlersMu.Lock()
172 defer o.handlersMu.Unlock()
173 return o.onFinished
174}
175
176// EventSignature returns the declared event argument types in wire order.
177func (o *OutputManager) EventSignature(opcode uint16) (string, bool) {
178 switch opcode {
179 case 0:
180 return "new_id,", true
181 case 1:
182 return "uint,", true
183 case 2:
184 return "", true
185 default:
186 return "", false
187 }
188}
189
190// Dispatch decodes one event on zwlr_output_manager_v1 and calls the registered handlers.
191func (o *OutputManager) Dispatch(event *wl.Event) {
192 switch event.Opcode {
193 case 0: // head
194 headID := event.Uint32()
195 headObject := &OutputHead{}
196 headObject.SetContext(o.Context())
197 headObject.SetID(headID)
198 headObject.SetVersion(o.Version())
199 o.Context().Register(headObject)
200
201 for i, handler := range o.handlersForHead() {
202 _ = i
203 handler(headObject)
204 }
205 case 1: // done
206 serial := event.Uint32()
207
208 for i, handler := range o.handlersForDone() {
209 _ = i
210 handler(serial)
211 }
212 case 2: // finished
213
214 for i, handler := range o.handlersForFinished() {
215 _ = i
216 handler()
217 }
218 o.Context().Unregister(o)
219 default:
220 }
221}
222
223// OutputHeadInterface is the protocol interface name.
224const OutputHeadInterface = "zwlr_output_head_v1"
225
226// OutputHead is the generated binding for zwlr_output_head_v1 version 4.
227type OutputHead struct {
228 wl.BaseProxy
229 // handlersMu guards the handler slices: a client may register or replace
230 // handlers while another goroutine dispatches events.
231 handlersMu sync.Mutex
232 onName []func(name string)
233 onDescription []func(description string)
234 onPhysicalSize []func(width int32, height int32)
235 onMode []func(modeObject *OutputMode)
236 onEnabled []func(enabled int32)
237 onCurrentMode []func(modeID uint32)
238 onPosition []func(x int32, y int32)
239 onTransform []func(transform int32)
240 onScale []func(scale wl.Fixed)
241 onFinished []func()
242 onMake []func(make string)
243 onModel []func(model string)
244 onSerialNumber []func(serialNumber string)
245 onAdaptiveSync []func(state uint32)
246}
247
248// NewOutputHead returns an unbound OutputHead.
249func NewOutputHead(ctx *wl.Context) *OutputHead {
250 obj := &OutputHead{}
251 obj.SetContext(ctx)
252 ctx.Register(obj)
253 return obj
254}
255
256// This request indicates that the client will no longer use this head object.
257func (o *OutputHead) Release() error {
258 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_head_v1.release", Since: 3, Destructor: true}); err != nil {
259 return err
260 }
261 return nil
262}
263
264// OnName registers a handler for the name event.
265//
266// Handlers are appended, so a second call adds another handler rather than
267// replacing the first. Registration is safe while another goroutine dispatches.
268func (o *OutputHead) OnName(handler func(name string)) {
269 if handler == nil {
270 return
271 }
272 o.handlersMu.Lock()
273 defer o.handlersMu.Unlock()
274 o.onName = append(o.onName, handler)
275}
276
277// handlersForName returns the handlers registered for name, taken
278// under the lock so a handler may register another handler while events are
279// being dispatched.
280func (o *OutputHead) handlersForName() []func(name string) {
281 o.handlersMu.Lock()
282 defer o.handlersMu.Unlock()
283 return o.onName
284}
285
286// OnDescription registers a handler for the description event.
287//
288// Handlers are appended, so a second call adds another handler rather than
289// replacing the first. Registration is safe while another goroutine dispatches.
290func (o *OutputHead) OnDescription(handler func(description string)) {
291 if handler == nil {
292 return
293 }
294 o.handlersMu.Lock()
295 defer o.handlersMu.Unlock()
296 o.onDescription = append(o.onDescription, handler)
297}
298
299// handlersForDescription returns the handlers registered for description, taken
300// under the lock so a handler may register another handler while events are
301// being dispatched.
302func (o *OutputHead) handlersForDescription() []func(description string) {
303 o.handlersMu.Lock()
304 defer o.handlersMu.Unlock()
305 return o.onDescription
306}
307
308// OnPhysicalSize registers a handler for the physical_size event.
309//
310// Handlers are appended, so a second call adds another handler rather than
311// replacing the first. Registration is safe while another goroutine dispatches.
312func (o *OutputHead) OnPhysicalSize(handler func(width int32, height int32)) {
313 if handler == nil {
314 return
315 }
316 o.handlersMu.Lock()
317 defer o.handlersMu.Unlock()
318 o.onPhysicalSize = append(o.onPhysicalSize, handler)
319}
320
321// handlersForPhysicalSize returns the handlers registered for physical_size, taken
322// under the lock so a handler may register another handler while events are
323// being dispatched.
324func (o *OutputHead) handlersForPhysicalSize() []func(width int32, height int32) {
325 o.handlersMu.Lock()
326 defer o.handlersMu.Unlock()
327 return o.onPhysicalSize
328}
329
330// OnMode registers a handler for the mode event.
331//
332// Handlers are appended, so a second call adds another handler rather than
333// replacing the first. Registration is safe while another goroutine dispatches.
334func (o *OutputHead) OnMode(handler func(modeObject *OutputMode)) {
335 if handler == nil {
336 return
337 }
338 o.handlersMu.Lock()
339 defer o.handlersMu.Unlock()
340 o.onMode = append(o.onMode, handler)
341}
342
343// handlersForMode returns the handlers registered for mode, taken
344// under the lock so a handler may register another handler while events are
345// being dispatched.
346func (o *OutputHead) handlersForMode() []func(modeObject *OutputMode) {
347 o.handlersMu.Lock()
348 defer o.handlersMu.Unlock()
349 return o.onMode
350}
351
352// OnEnabled registers a handler for the enabled event.
353//
354// Handlers are appended, so a second call adds another handler rather than
355// replacing the first. Registration is safe while another goroutine dispatches.
356func (o *OutputHead) OnEnabled(handler func(enabled int32)) {
357 if handler == nil {
358 return
359 }
360 o.handlersMu.Lock()
361 defer o.handlersMu.Unlock()
362 o.onEnabled = append(o.onEnabled, handler)
363}
364
365// handlersForEnabled returns the handlers registered for enabled, taken
366// under the lock so a handler may register another handler while events are
367// being dispatched.
368func (o *OutputHead) handlersForEnabled() []func(enabled int32) {
369 o.handlersMu.Lock()
370 defer o.handlersMu.Unlock()
371 return o.onEnabled
372}
373
374// OnCurrentMode registers a handler for the current_mode event.
375//
376// Handlers are appended, so a second call adds another handler rather than
377// replacing the first. Registration is safe while another goroutine dispatches.
378func (o *OutputHead) OnCurrentMode(handler func(modeID uint32)) {
379 if handler == nil {
380 return
381 }
382 o.handlersMu.Lock()
383 defer o.handlersMu.Unlock()
384 o.onCurrentMode = append(o.onCurrentMode, handler)
385}
386
387// handlersForCurrentMode returns the handlers registered for current_mode, taken
388// under the lock so a handler may register another handler while events are
389// being dispatched.
390func (o *OutputHead) handlersForCurrentMode() []func(modeID uint32) {
391 o.handlersMu.Lock()
392 defer o.handlersMu.Unlock()
393 return o.onCurrentMode
394}
395
396// OnPosition registers a handler for the position event.
397//
398// Handlers are appended, so a second call adds another handler rather than
399// replacing the first. Registration is safe while another goroutine dispatches.
400func (o *OutputHead) OnPosition(handler func(x int32, y int32)) {
401 if handler == nil {
402 return
403 }
404 o.handlersMu.Lock()
405 defer o.handlersMu.Unlock()
406 o.onPosition = append(o.onPosition, handler)
407}
408
409// handlersForPosition returns the handlers registered for position, taken
410// under the lock so a handler may register another handler while events are
411// being dispatched.
412func (o *OutputHead) handlersForPosition() []func(x int32, y int32) {
413 o.handlersMu.Lock()
414 defer o.handlersMu.Unlock()
415 return o.onPosition
416}
417
418// OnTransform registers a handler for the transform event.
419//
420// Handlers are appended, so a second call adds another handler rather than
421// replacing the first. Registration is safe while another goroutine dispatches.
422func (o *OutputHead) OnTransform(handler func(transform int32)) {
423 if handler == nil {
424 return
425 }
426 o.handlersMu.Lock()
427 defer o.handlersMu.Unlock()
428 o.onTransform = append(o.onTransform, handler)
429}
430
431// handlersForTransform returns the handlers registered for transform, taken
432// under the lock so a handler may register another handler while events are
433// being dispatched.
434func (o *OutputHead) handlersForTransform() []func(transform int32) {
435 o.handlersMu.Lock()
436 defer o.handlersMu.Unlock()
437 return o.onTransform
438}
439
440// OnScale registers a handler for the scale event.
441//
442// Handlers are appended, so a second call adds another handler rather than
443// replacing the first. Registration is safe while another goroutine dispatches.
444func (o *OutputHead) OnScale(handler func(scale wl.Fixed)) {
445 if handler == nil {
446 return
447 }
448 o.handlersMu.Lock()
449 defer o.handlersMu.Unlock()
450 o.onScale = append(o.onScale, handler)
451}
452
453// handlersForScale returns the handlers registered for scale, taken
454// under the lock so a handler may register another handler while events are
455// being dispatched.
456func (o *OutputHead) handlersForScale() []func(scale wl.Fixed) {
457 o.handlersMu.Lock()
458 defer o.handlersMu.Unlock()
459 return o.onScale
460}
461
462// OnFinished registers a handler for the finished event.
463//
464// Handlers are appended, so a second call adds another handler rather than
465// replacing the first. Registration is safe while another goroutine dispatches.
466func (o *OutputHead) OnFinished(handler func()) {
467 if handler == nil {
468 return
469 }
470 o.handlersMu.Lock()
471 defer o.handlersMu.Unlock()
472 o.onFinished = append(o.onFinished, handler)
473}
474
475// handlersForFinished returns the handlers registered for finished, taken
476// under the lock so a handler may register another handler while events are
477// being dispatched.
478func (o *OutputHead) handlersForFinished() []func() {
479 o.handlersMu.Lock()
480 defer o.handlersMu.Unlock()
481 return o.onFinished
482}
483
484// OnMake registers a handler for the make event.
485//
486// Handlers are appended, so a second call adds another handler rather than
487// replacing the first. Registration is safe while another goroutine dispatches.
488func (o *OutputHead) OnMake(handler func(make string)) {
489 if handler == nil {
490 return
491 }
492 o.handlersMu.Lock()
493 defer o.handlersMu.Unlock()
494 o.onMake = append(o.onMake, handler)
495}
496
497// handlersForMake returns the handlers registered for make, taken
498// under the lock so a handler may register another handler while events are
499// being dispatched.
500func (o *OutputHead) handlersForMake() []func(make string) {
501 o.handlersMu.Lock()
502 defer o.handlersMu.Unlock()
503 return o.onMake
504}
505
506// OnModel registers a handler for the model event.
507//
508// Handlers are appended, so a second call adds another handler rather than
509// replacing the first. Registration is safe while another goroutine dispatches.
510func (o *OutputHead) OnModel(handler func(model string)) {
511 if handler == nil {
512 return
513 }
514 o.handlersMu.Lock()
515 defer o.handlersMu.Unlock()
516 o.onModel = append(o.onModel, handler)
517}
518
519// handlersForModel returns the handlers registered for model, taken
520// under the lock so a handler may register another handler while events are
521// being dispatched.
522func (o *OutputHead) handlersForModel() []func(model string) {
523 o.handlersMu.Lock()
524 defer o.handlersMu.Unlock()
525 return o.onModel
526}
527
528// OnSerialNumber registers a handler for the serial_number event.
529//
530// Handlers are appended, so a second call adds another handler rather than
531// replacing the first. Registration is safe while another goroutine dispatches.
532func (o *OutputHead) OnSerialNumber(handler func(serialNumber string)) {
533 if handler == nil {
534 return
535 }
536 o.handlersMu.Lock()
537 defer o.handlersMu.Unlock()
538 o.onSerialNumber = append(o.onSerialNumber, handler)
539}
540
541// handlersForSerialNumber returns the handlers registered for serial_number, taken
542// under the lock so a handler may register another handler while events are
543// being dispatched.
544func (o *OutputHead) handlersForSerialNumber() []func(serialNumber string) {
545 o.handlersMu.Lock()
546 defer o.handlersMu.Unlock()
547 return o.onSerialNumber
548}
549
550// OnAdaptiveSync registers a handler for the adaptive_sync event.
551//
552// Handlers are appended, so a second call adds another handler rather than
553// replacing the first. Registration is safe while another goroutine dispatches.
554func (o *OutputHead) OnAdaptiveSync(handler func(state uint32)) {
555 if handler == nil {
556 return
557 }
558 o.handlersMu.Lock()
559 defer o.handlersMu.Unlock()
560 o.onAdaptiveSync = append(o.onAdaptiveSync, handler)
561}
562
563// handlersForAdaptiveSync returns the handlers registered for adaptive_sync, taken
564// under the lock so a handler may register another handler while events are
565// being dispatched.
566func (o *OutputHead) handlersForAdaptiveSync() []func(state uint32) {
567 o.handlersMu.Lock()
568 defer o.handlersMu.Unlock()
569 return o.onAdaptiveSync
570}
571
572// EventSignature returns the declared event argument types in wire order.
573func (o *OutputHead) EventSignature(opcode uint16) (string, bool) {
574 switch opcode {
575 case 0:
576 return "string,", true
577 case 1:
578 return "string,", true
579 case 2:
580 return "int,int,", true
581 case 3:
582 return "new_id,", true
583 case 4:
584 return "int,", true
585 case 5:
586 return "object,", true
587 case 6:
588 return "int,int,", true
589 case 7:
590 return "int,", true
591 case 8:
592 return "fixed,", true
593 case 9:
594 return "", true
595 case 10:
596 return "string,", true
597 case 11:
598 return "string,", true
599 case 12:
600 return "string,", true
601 case 13:
602 return "uint,", true
603 default:
604 return "", false
605 }
606}
607
608// Dispatch decodes one event on zwlr_output_head_v1 and calls the registered handlers.
609func (o *OutputHead) Dispatch(event *wl.Event) {
610 switch event.Opcode {
611 case 0: // name
612 name := event.String()
613
614 for i, handler := range o.handlersForName() {
615 _ = i
616 handler(name)
617 }
618 case 1: // description
619 description := event.String()
620
621 for i, handler := range o.handlersForDescription() {
622 _ = i
623 handler(description)
624 }
625 case 2: // physical_size
626 width := event.Int32()
627 height := event.Int32()
628
629 for i, handler := range o.handlersForPhysicalSize() {
630 _ = i
631 handler(width, height)
632 }
633 case 3: // mode
634 modeID := event.Uint32()
635 modeObject := &OutputMode{}
636 modeObject.SetContext(o.Context())
637 modeObject.SetID(modeID)
638 modeObject.SetVersion(o.Version())
639 o.Context().Register(modeObject)
640
641 for i, handler := range o.handlersForMode() {
642 _ = i
643 handler(modeObject)
644 }
645 case 4: // enabled
646 enabled := event.Int32()
647
648 for i, handler := range o.handlersForEnabled() {
649 _ = i
650 handler(enabled)
651 }
652 case 5: // current_mode
653 modeID := event.Uint32()
654
655 for i, handler := range o.handlersForCurrentMode() {
656 _ = i
657 handler(modeID)
658 }
659 case 6: // position
660 x := event.Int32()
661 y := event.Int32()
662
663 for i, handler := range o.handlersForPosition() {
664 _ = i
665 handler(x, y)
666 }
667 case 7: // transform
668 transform := event.Int32()
669
670 for i, handler := range o.handlersForTransform() {
671 _ = i
672 handler(transform)
673 }
674 case 8: // scale
675 scale := event.Fixed()
676
677 for i, handler := range o.handlersForScale() {
678 _ = i
679 handler(scale)
680 }
681 case 9: // finished
682
683 for i, handler := range o.handlersForFinished() {
684 _ = i
685 handler()
686 }
687 case 10: // make
688 make := event.String()
689
690 for i, handler := range o.handlersForMake() {
691 _ = i
692 handler(make)
693 }
694 case 11: // model
695 model := event.String()
696
697 for i, handler := range o.handlersForModel() {
698 _ = i
699 handler(model)
700 }
701 case 12: // serial_number
702 serialNumber := event.String()
703
704 for i, handler := range o.handlersForSerialNumber() {
705 _ = i
706 handler(serialNumber)
707 }
708 case 13: // adaptive_sync
709 state := event.Uint32()
710
711 for i, handler := range o.handlersForAdaptiveSync() {
712 _ = i
713 handler(state)
714 }
715 default:
716 }
717}
718
719// OutputModeInterface is the protocol interface name.
720const OutputModeInterface = "zwlr_output_mode_v1"
721
722// OutputMode is the generated binding for zwlr_output_mode_v1 version 3.
723type OutputMode struct {
724 wl.BaseProxy
725 // handlersMu guards the handler slices: a client may register or replace
726 // handlers while another goroutine dispatches events.
727 handlersMu sync.Mutex
728 onSize []func(width int32, height int32)
729 onRefresh []func(refresh int32)
730 onPreferred []func()
731 onFinished []func()
732}
733
734// NewOutputMode returns an unbound OutputMode.
735func NewOutputMode(ctx *wl.Context) *OutputMode {
736 obj := &OutputMode{}
737 obj.SetContext(ctx)
738 ctx.Register(obj)
739 return obj
740}
741
742// This request indicates that the client will no longer use this mode object.
743func (o *OutputMode) Release() error {
744 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_mode_v1.release", Since: 3, Destructor: true}); err != nil {
745 return err
746 }
747 return nil
748}
749
750// OnSize registers a handler for the size event.
751//
752// Handlers are appended, so a second call adds another handler rather than
753// replacing the first. Registration is safe while another goroutine dispatches.
754func (o *OutputMode) OnSize(handler func(width int32, height int32)) {
755 if handler == nil {
756 return
757 }
758 o.handlersMu.Lock()
759 defer o.handlersMu.Unlock()
760 o.onSize = append(o.onSize, handler)
761}
762
763// handlersForSize returns the handlers registered for size, taken
764// under the lock so a handler may register another handler while events are
765// being dispatched.
766func (o *OutputMode) handlersForSize() []func(width int32, height int32) {
767 o.handlersMu.Lock()
768 defer o.handlersMu.Unlock()
769 return o.onSize
770}
771
772// OnRefresh registers a handler for the refresh event.
773//
774// Handlers are appended, so a second call adds another handler rather than
775// replacing the first. Registration is safe while another goroutine dispatches.
776func (o *OutputMode) OnRefresh(handler func(refresh int32)) {
777 if handler == nil {
778 return
779 }
780 o.handlersMu.Lock()
781 defer o.handlersMu.Unlock()
782 o.onRefresh = append(o.onRefresh, handler)
783}
784
785// handlersForRefresh returns the handlers registered for refresh, taken
786// under the lock so a handler may register another handler while events are
787// being dispatched.
788func (o *OutputMode) handlersForRefresh() []func(refresh int32) {
789 o.handlersMu.Lock()
790 defer o.handlersMu.Unlock()
791 return o.onRefresh
792}
793
794// OnPreferred registers a handler for the preferred event.
795//
796// Handlers are appended, so a second call adds another handler rather than
797// replacing the first. Registration is safe while another goroutine dispatches.
798func (o *OutputMode) OnPreferred(handler func()) {
799 if handler == nil {
800 return
801 }
802 o.handlersMu.Lock()
803 defer o.handlersMu.Unlock()
804 o.onPreferred = append(o.onPreferred, handler)
805}
806
807// handlersForPreferred returns the handlers registered for preferred, taken
808// under the lock so a handler may register another handler while events are
809// being dispatched.
810func (o *OutputMode) handlersForPreferred() []func() {
811 o.handlersMu.Lock()
812 defer o.handlersMu.Unlock()
813 return o.onPreferred
814}
815
816// OnFinished registers a handler for the finished event.
817//
818// Handlers are appended, so a second call adds another handler rather than
819// replacing the first. Registration is safe while another goroutine dispatches.
820func (o *OutputMode) OnFinished(handler func()) {
821 if handler == nil {
822 return
823 }
824 o.handlersMu.Lock()
825 defer o.handlersMu.Unlock()
826 o.onFinished = append(o.onFinished, handler)
827}
828
829// handlersForFinished returns the handlers registered for finished, taken
830// under the lock so a handler may register another handler while events are
831// being dispatched.
832func (o *OutputMode) handlersForFinished() []func() {
833 o.handlersMu.Lock()
834 defer o.handlersMu.Unlock()
835 return o.onFinished
836}
837
838// EventSignature returns the declared event argument types in wire order.
839func (o *OutputMode) EventSignature(opcode uint16) (string, bool) {
840 switch opcode {
841 case 0:
842 return "int,int,", true
843 case 1:
844 return "int,", true
845 case 2:
846 return "", true
847 case 3:
848 return "", true
849 default:
850 return "", false
851 }
852}
853
854// Dispatch decodes one event on zwlr_output_mode_v1 and calls the registered handlers.
855func (o *OutputMode) Dispatch(event *wl.Event) {
856 switch event.Opcode {
857 case 0: // size
858 width := event.Int32()
859 height := event.Int32()
860
861 for i, handler := range o.handlersForSize() {
862 _ = i
863 handler(width, height)
864 }
865 case 1: // refresh
866 refresh := event.Int32()
867
868 for i, handler := range o.handlersForRefresh() {
869 _ = i
870 handler(refresh)
871 }
872 case 2: // preferred
873
874 for i, handler := range o.handlersForPreferred() {
875 _ = i
876 handler()
877 }
878 case 3: // finished
879
880 for i, handler := range o.handlersForFinished() {
881 _ = i
882 handler()
883 }
884 default:
885 }
886}
887
888// OutputConfigurationInterface is the protocol interface name.
889const OutputConfigurationInterface = "zwlr_output_configuration_v1"
890
891// OutputConfiguration is the generated binding for zwlr_output_configuration_v1 version 4.
892type OutputConfiguration struct {
893 wl.BaseProxy
894 // handlersMu guards the handler slices: a client may register or replace
895 // handlers while another goroutine dispatches events.
896 handlersMu sync.Mutex
897 onSucceeded []func()
898 onFailed []func()
899 onCancelled []func()
900}
901
902// NewOutputConfiguration returns an unbound OutputConfiguration.
903func NewOutputConfiguration(ctx *wl.Context) *OutputConfiguration {
904 obj := &OutputConfiguration{}
905 obj.SetContext(ctx)
906 ctx.Register(obj)
907 return obj
908}
909
910// Enable a head. This request creates a head configuration object that can be used to change the head's properties.
911func (o *OutputConfiguration) EnableHead(head *OutputHead) (*OutputConfigurationHead, error) {
912 var arg1 wl.Object
913 if head != nil {
914 arg1 = head
915 }
916 child := &OutputConfigurationHead{}
917 child.SetContext(o.Context())
918 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_configuration_v1.enable_head", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
919 return nil, err
920 }
921 return child, nil
922}
923
924// Disable a head.
925func (o *OutputConfiguration) DisableHead(head *OutputHead) error {
926 var arg0 wl.Object
927 if head != nil {
928 arg0 = head
929 }
930 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_output_configuration_v1.disable_head"}, wl.ArgObject(arg0)); err != nil {
931 return err
932 }
933 return nil
934}
935
936// Apply the new output configuration. In case the configuration is successfully applied, there is no guarantee that the new output state matches completely the requested configuration. For instance, a compositor might round the scale if it doesn't support fractional scaling. After this request has been sent, the compositor must respond with an succeeded, failed or cancelled event. Sending a request that isn't the destructor is a protocol error.
937func (o *OutputConfiguration) Apply() error {
938 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_output_configuration_v1.apply"}); err != nil {
939 return err
940 }
941 return nil
942}
943
944// Test the new output configuration. The configuration won't be applied, but will only be validated. Even if the compositor succeeds to test a configuration, applying it may fail. After this request has been sent, the compositor must respond with an succeeded, failed or cancelled event. Sending a request that isn't the destructor is a protocol error.
945func (o *OutputConfiguration) Test() error {
946 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwlr_output_configuration_v1.test"}); err != nil {
947 return err
948 }
949 return nil
950}
951
952// Using this request a client can tell the compositor that it is not going to use the configuration object anymore. Any changes to the outputs that have not been applied will be discarded. This request also destroys wlr_output_configuration_head objects created via this object.
953func (o *OutputConfiguration) Destroy() error {
954 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "zwlr_output_configuration_v1.destroy", Destructor: true}); err != nil {
955 return err
956 }
957 return nil
958}
959
960// OnSucceeded registers a handler for the succeeded event.
961//
962// Handlers are appended, so a second call adds another handler rather than
963// replacing the first. Registration is safe while another goroutine dispatches.
964func (o *OutputConfiguration) OnSucceeded(handler func()) {
965 if handler == nil {
966 return
967 }
968 o.handlersMu.Lock()
969 defer o.handlersMu.Unlock()
970 o.onSucceeded = append(o.onSucceeded, handler)
971}
972
973// handlersForSucceeded returns the handlers registered for succeeded, taken
974// under the lock so a handler may register another handler while events are
975// being dispatched.
976func (o *OutputConfiguration) handlersForSucceeded() []func() {
977 o.handlersMu.Lock()
978 defer o.handlersMu.Unlock()
979 return o.onSucceeded
980}
981
982// OnFailed registers a handler for the failed event.
983//
984// Handlers are appended, so a second call adds another handler rather than
985// replacing the first. Registration is safe while another goroutine dispatches.
986func (o *OutputConfiguration) OnFailed(handler func()) {
987 if handler == nil {
988 return
989 }
990 o.handlersMu.Lock()
991 defer o.handlersMu.Unlock()
992 o.onFailed = append(o.onFailed, handler)
993}
994
995// handlersForFailed returns the handlers registered for failed, taken
996// under the lock so a handler may register another handler while events are
997// being dispatched.
998func (o *OutputConfiguration) handlersForFailed() []func() {
999 o.handlersMu.Lock()
1000 defer o.handlersMu.Unlock()
1001 return o.onFailed
1002}
1003
1004// OnCancelled registers a handler for the cancelled event.
1005//
1006// Handlers are appended, so a second call adds another handler rather than
1007// replacing the first. Registration is safe while another goroutine dispatches.
1008func (o *OutputConfiguration) OnCancelled(handler func()) {
1009 if handler == nil {
1010 return
1011 }
1012 o.handlersMu.Lock()
1013 defer o.handlersMu.Unlock()
1014 o.onCancelled = append(o.onCancelled, handler)
1015}
1016
1017// handlersForCancelled returns the handlers registered for cancelled, taken
1018// under the lock so a handler may register another handler while events are
1019// being dispatched.
1020func (o *OutputConfiguration) handlersForCancelled() []func() {
1021 o.handlersMu.Lock()
1022 defer o.handlersMu.Unlock()
1023 return o.onCancelled
1024}
1025
1026// EventSignature returns the declared event argument types in wire order.
1027func (o *OutputConfiguration) EventSignature(opcode uint16) (string, bool) {
1028 switch opcode {
1029 case 0:
1030 return "", true
1031 case 1:
1032 return "", true
1033 case 2:
1034 return "", true
1035 default:
1036 return "", false
1037 }
1038}
1039
1040// Dispatch decodes one event on zwlr_output_configuration_v1 and calls the registered handlers.
1041func (o *OutputConfiguration) Dispatch(event *wl.Event) {
1042 switch event.Opcode {
1043 case 0: // succeeded
1044
1045 for i, handler := range o.handlersForSucceeded() {
1046 _ = i
1047 handler()
1048 }
1049 case 1: // failed
1050
1051 for i, handler := range o.handlersForFailed() {
1052 _ = i
1053 handler()
1054 }
1055 case 2: // cancelled
1056
1057 for i, handler := range o.handlersForCancelled() {
1058 _ = i
1059 handler()
1060 }
1061 default:
1062 }
1063}
1064
1065// OutputConfigurationHeadInterface is the protocol interface name.
1066const OutputConfigurationHeadInterface = "zwlr_output_configuration_head_v1"
1067
1068// OutputConfigurationHead is the generated binding for zwlr_output_configuration_head_v1 version 4.
1069type OutputConfigurationHead struct {
1070 wl.BaseProxy
1071}
1072
1073// NewOutputConfigurationHead returns an unbound OutputConfigurationHead.
1074func NewOutputConfigurationHead(ctx *wl.Context) *OutputConfigurationHead {
1075 obj := &OutputConfigurationHead{}
1076 obj.SetContext(ctx)
1077 ctx.Register(obj)
1078 return obj
1079}
1080
1081// This request sets the head's mode.
1082func (o *OutputConfigurationHead) SetMode(mode *OutputMode) error {
1083 var arg0 wl.Object
1084 if mode != nil {
1085 arg0 = mode
1086 }
1087 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_output_configuration_head_v1.set_mode"}, wl.ArgObject(arg0)); err != nil {
1088 return err
1089 }
1090 return nil
1091}
1092
1093// This request assigns a custom mode to the head. The size is given in physical hardware units of the output device. If set to zero, the refresh rate is unspecified. It is a protocol error to set both a mode and a custom mode.
1094func (o *OutputConfigurationHead) SetCustomMode(width int32, height int32, refresh int32) error {
1095 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_output_configuration_head_v1.set_custom_mode"}, wl.ArgInt(width), wl.ArgInt(height), wl.ArgInt(refresh)); err != nil {
1096 return err
1097 }
1098 return nil
1099}
1100
1101// This request sets the head's position in the global compositor space.
1102func (o *OutputConfigurationHead) SetPosition(x int32, y int32) error {
1103 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_output_configuration_head_v1.set_position"}, wl.ArgInt(x), wl.ArgInt(y)); err != nil {
1104 return err
1105 }
1106 return nil
1107}
1108
1109// This request sets the head's transform.
1110func (o *OutputConfigurationHead) SetTransform(transform int32) error {
1111 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwlr_output_configuration_head_v1.set_transform"}, wl.ArgInt(transform)); err != nil {
1112 return err
1113 }
1114 return nil
1115}
1116
1117// This request sets the head's scale.
1118func (o *OutputConfigurationHead) SetScale(scale wl.Fixed) error {
1119 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "zwlr_output_configuration_head_v1.set_scale"}, wl.ArgFixed(scale)); err != nil {
1120 return err
1121 }
1122 return nil
1123}
1124
1125// This request enables/disables adaptive sync. Adaptive sync is also known as Variable Refresh Rate or VRR.
1126func (o *OutputConfigurationHead) SetAdaptiveSync(state uint32) error {
1127 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 5, Name: "zwlr_output_configuration_head_v1.set_adaptive_sync", Since: 4}, wl.ArgUint(state)); err != nil {
1128 return err
1129 }
1130 return nil
1131}
1132
1133// EventSignature returns the declared event argument types in wire order.
1134func (o *OutputConfigurationHead) EventSignature(opcode uint16) (string, bool) {
1135 switch opcode {
1136 default:
1137 return "", false
1138 }
1139}
1140
1141// Dispatch decodes one event on zwlr_output_configuration_head_v1 and calls the registered handlers.
1142func (o *OutputConfigurationHead) Dispatch(event *wl.Event) {
1143 switch event.Opcode {
1144 default:
1145 }
1146}