1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2023 Valve Corporation
5//
6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation
9// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10// and/or sell copies of the Software, and to permit persons to whom the
11// Software is furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice (including the next
14// paragraph) shall be included in all copies or substantial portions of the
15// Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25package fifo
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var WpFifoManagerV1Interface *server.Interface
34var WpFifoV1Interface *server.Interface
35
36func init() {
37 WpFifoManagerV1Interface = &server.Interface{Name: "wp_fifo_manager_v1", Version: 1}
38 WpFifoV1Interface = &server.Interface{Name: "wp_fifo_v1", Version: 1}
39 WpFifoManagerV1Interface.Requests = []server.Message{
40 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
41 {Name: "get_fifo", Signature: "no", Types: []*server.Interface{WpFifoV1Interface, wayland.SurfaceInterface}},
42 }
43 WpFifoManagerV1Interface.Events = []server.Message{}
44 WpFifoV1Interface.Requests = []server.Message{
45 {Name: "set_barrier", Signature: "", Types: []*server.Interface{}},
46 {Name: "wait_barrier", Signature: "", Types: []*server.Interface{}},
47 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
48 }
49 WpFifoV1Interface.Events = []server.Message{}
50 if err := server.NewInterfaces(WpFifoManagerV1Interface, WpFifoV1Interface); err != nil {
51 panic(err)
52 }
53}
54
55// WpFifoManagerV1 protocol for fifo constraints.
56type WpFifoManagerV1 struct{ *server.Resource }
57
58func WrapWpFifoManagerV1(r *server.Resource) *WpFifoManagerV1 {
59 if r == nil {
60 return nil
61 }
62 return &WpFifoManagerV1{r}
63}
64
65const WpFifoManagerV1RequestDestroy uint32 = 0
66const WpFifoManagerV1RequestGetFifo uint32 = 1
67
68// WpFifoManagerV1Error fatal presentation error.
69type WpFifoManagerV1Error uint32
70
71const (
72 WpFifoManagerV1ErrorAlreadyExists WpFifoManagerV1Error = 0
73)
74
75// WpFifoManagerV1Handler handles wp_fifo_manager_v1 requests.
76type WpFifoManagerV1Handler interface {
77 Destroy(self *WpFifoManagerV1)
78 GetFifo(self *WpFifoManagerV1, id uint32, surface *wayland.Surface)
79}
80
81func NewWpFifoManagerV1(c server.Client, version int32, id uint32, h WpFifoManagerV1Handler) (*WpFifoManagerV1, error) {
82 if h == nil {
83 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_fifo_manager_v1")
84 }
85 var self *WpFifoManagerV1
86 r, err := c.CreateResource(WpFifoManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
87 switch opcode {
88 case 0:
89 h.Destroy(self)
90 self.Destroy()
91 case 1:
92 h.GetFifo(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()))
93 }
94 })
95 if err != nil {
96 return nil, err
97 }
98 self = WrapWpFifoManagerV1(r)
99 r.Data = self
100 return self, nil
101}
102func NewWpFifoManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
103 return d.CreateGlobal(WpFifoManagerV1Interface, version, bind)
104}
105
106// WpFifoV1 fifo interface.
107type WpFifoV1 struct{ *server.Resource }
108
109func WrapWpFifoV1(r *server.Resource) *WpFifoV1 {
110 if r == nil {
111 return nil
112 }
113 return &WpFifoV1{r}
114}
115
116const WpFifoV1RequestSetBarrier uint32 = 0
117const WpFifoV1RequestWaitBarrier uint32 = 1
118const WpFifoV1RequestDestroy uint32 = 2
119
120// WpFifoV1Error fatal error.
121type WpFifoV1Error uint32
122
123const (
124 WpFifoV1ErrorSurfaceDestroyed WpFifoV1Error = 0
125)
126
127// WpFifoV1Handler handles wp_fifo_v1 requests.
128type WpFifoV1Handler interface {
129 SetBarrier(self *WpFifoV1)
130 WaitBarrier(self *WpFifoV1)
131 Destroy(self *WpFifoV1)
132}
133
134func NewWpFifoV1(c server.Client, version int32, id uint32, h WpFifoV1Handler) (*WpFifoV1, error) {
135 if h == nil {
136 return nil, fmt.Errorf("purego-libwayland: nil handler for wp_fifo_v1")
137 }
138 var self *WpFifoV1
139 r, err := c.CreateResource(WpFifoV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
140 switch opcode {
141 case 0:
142 h.SetBarrier(self)
143 case 1:
144 h.WaitBarrier(self)
145 case 2:
146 h.Destroy(self)
147 self.Destroy()
148 }
149 })
150 if err != nil {
151 return nil, err
152 }
153 self = WrapWpFifoV1(r)
154 r.Data = self
155 return self, nil
156}
157func NewWpFifoV1Global(d *server.Display, version int32, bind server.BindFunc) error {
158 return d.CreateGlobal(WpFifoV1Interface, version, bind)
159}
160func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
161 if v == nil {
162 return nil
163 }
164 return v.GetResource()
165}
166func (self *WpFifoManagerV1) GetResource() *server.Resource {
167 if self == nil {
168 return nil
169 }
170 return self.Resource
171}
172func (self *WpFifoV1) GetResource() *server.Resource {
173 if self == nil {
174 return nil
175 }
176 return self.Resource
177}