1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2018 Simon Ser
5// Copyright © 2019 Ivan Molodetskikh
6//
7// Permission to use, copy, modify, distribute, and sell this
8// software and its documentation for any purpose is hereby granted
9// without fee, provided that the above copyright notice appear in
10// all copies and that both that copyright notice and this permission
11// notice appear in supporting documentation, and that the name of
12// the copyright holders not be used in advertising or publicity
13// pertaining to distribution of the software without specific,
14// written prior permission. The copyright holders make no
15// representations about the suitability of this software for any
16// purpose. It is provided "as is" without express or implied
17// warranty.
18//
19// THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
20// SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21// FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
22// SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
24// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
26// THIS SOFTWARE.
27
28package wlrdatacontrol
29
30import (
31 "fmt"
32 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
33 "github.com/bnema/purego-libwayland/server"
34 "runtime"
35)
36
37var ZwlrDataControlManagerV1Interface *server.Interface
38var ZwlrDataControlDeviceV1Interface *server.Interface
39var ZwlrDataControlSourceV1Interface *server.Interface
40var ZwlrDataControlOfferV1Interface *server.Interface
41
42func init() {
43 ZwlrDataControlManagerV1Interface = &server.Interface{Name: "zwlr_data_control_manager_v1", Version: 2}
44 ZwlrDataControlDeviceV1Interface = &server.Interface{Name: "zwlr_data_control_device_v1", Version: 2}
45 ZwlrDataControlSourceV1Interface = &server.Interface{Name: "zwlr_data_control_source_v1", Version: 1}
46 ZwlrDataControlOfferV1Interface = &server.Interface{Name: "zwlr_data_control_offer_v1", Version: 1}
47 ZwlrDataControlManagerV1Interface.Requests = []server.Message{
48 {Name: "create_data_source", Signature: "n", Types: []*server.Interface{ZwlrDataControlSourceV1Interface}},
49 {Name: "get_data_device", Signature: "no", Types: []*server.Interface{ZwlrDataControlDeviceV1Interface, wayland.SeatInterface}},
50 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
51 }
52 ZwlrDataControlManagerV1Interface.Events = []server.Message{}
53 ZwlrDataControlDeviceV1Interface.Requests = []server.Message{
54 {Name: "set_selection", Signature: "?o", Types: []*server.Interface{ZwlrDataControlSourceV1Interface}},
55 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
56 {Name: "set_primary_selection", Signature: "2?o", Types: []*server.Interface{ZwlrDataControlSourceV1Interface}},
57 }
58 ZwlrDataControlDeviceV1Interface.Events = []server.Message{
59 {Name: "data_offer", Signature: "n", Types: []*server.Interface{ZwlrDataControlOfferV1Interface}},
60 {Name: "selection", Signature: "?o", Types: []*server.Interface{ZwlrDataControlOfferV1Interface}},
61 {Name: "finished", Signature: "", Types: []*server.Interface{}},
62 {Name: "primary_selection", Signature: "2?o", Types: []*server.Interface{ZwlrDataControlOfferV1Interface}},
63 }
64 ZwlrDataControlSourceV1Interface.Requests = []server.Message{
65 {Name: "offer", Signature: "s", Types: []*server.Interface{nil}},
66 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
67 }
68 ZwlrDataControlSourceV1Interface.Events = []server.Message{
69 {Name: "send", Signature: "sh", Types: []*server.Interface{nil, nil}},
70 {Name: "cancelled", Signature: "", Types: []*server.Interface{}},
71 }
72 ZwlrDataControlOfferV1Interface.Requests = []server.Message{
73 {Name: "receive", Signature: "sh", Types: []*server.Interface{nil, nil}},
74 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
75 }
76 ZwlrDataControlOfferV1Interface.Events = []server.Message{
77 {Name: "offer", Signature: "s", Types: []*server.Interface{nil}},
78 }
79 if err := server.NewInterfaces(ZwlrDataControlManagerV1Interface, ZwlrDataControlDeviceV1Interface, ZwlrDataControlSourceV1Interface, ZwlrDataControlOfferV1Interface); err != nil {
80 panic(err)
81 }
82}
83
84// ZwlrDataControlManagerV1 manager to control data devices.
85type ZwlrDataControlManagerV1 struct{ *server.Resource }
86
87func WrapZwlrDataControlManagerV1(r *server.Resource) *ZwlrDataControlManagerV1 {
88 if r == nil {
89 return nil
90 }
91 return &ZwlrDataControlManagerV1{r}
92}
93
94const ZwlrDataControlManagerV1RequestCreateDataSource uint32 = 0
95const ZwlrDataControlManagerV1RequestGetDataDevice uint32 = 1
96const ZwlrDataControlManagerV1RequestDestroy uint32 = 2
97
98// ZwlrDataControlManagerV1Handler handles zwlr_data_control_manager_v1 requests.
99type ZwlrDataControlManagerV1Handler interface {
100 CreateDataSource(self *ZwlrDataControlManagerV1, id uint32)
101 GetDataDevice(self *ZwlrDataControlManagerV1, id uint32, seat *wayland.Seat)
102 Destroy(self *ZwlrDataControlManagerV1)
103}
104
105func NewZwlrDataControlManagerV1(c server.Client, version int32, id uint32, h ZwlrDataControlManagerV1Handler) (*ZwlrDataControlManagerV1, error) {
106 if h == nil {
107 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_data_control_manager_v1")
108 }
109 var self *ZwlrDataControlManagerV1
110 r, err := c.CreateResource(ZwlrDataControlManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
111 switch opcode {
112 case 0:
113 h.CreateDataSource(self, args[0].NewID())
114 case 1:
115 h.GetDataDevice(self, args[0].NewID(), wayland.WrapSeat(args[1].Resource()))
116 case 2:
117 h.Destroy(self)
118 self.Destroy()
119 }
120 })
121 if err != nil {
122 return nil, err
123 }
124 self = WrapZwlrDataControlManagerV1(r)
125 r.Data = self
126 return self, nil
127}
128func NewZwlrDataControlManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
129 return d.CreateGlobal(ZwlrDataControlManagerV1Interface, version, bind)
130}
131
132// ZwlrDataControlDeviceV1 manage a data device for a seat.
133type ZwlrDataControlDeviceV1 struct{ *server.Resource }
134
135func WrapZwlrDataControlDeviceV1(r *server.Resource) *ZwlrDataControlDeviceV1 {
136 if r == nil {
137 return nil
138 }
139 return &ZwlrDataControlDeviceV1{r}
140}
141
142const ZwlrDataControlDeviceV1RequestSetSelection uint32 = 0
143const ZwlrDataControlDeviceV1RequestDestroy uint32 = 1
144const ZwlrDataControlDeviceV1RequestSetPrimarySelection uint32 = 2
145const ZwlrDataControlDeviceV1EventDataOffer uint32 = 0
146const ZwlrDataControlDeviceV1EventSelection uint32 = 1
147const ZwlrDataControlDeviceV1EventFinished uint32 = 2
148const ZwlrDataControlDeviceV1EventPrimarySelection uint32 = 3
149
150// ZwlrDataControlDeviceV1Error .
151type ZwlrDataControlDeviceV1Error uint32
152
153const (
154 ZwlrDataControlDeviceV1ErrorUsedSource ZwlrDataControlDeviceV1Error = 1
155)
156
157// ZwlrDataControlDeviceV1Handler handles zwlr_data_control_device_v1 requests.
158type ZwlrDataControlDeviceV1Handler interface {
159 SetSelection(self *ZwlrDataControlDeviceV1, source *ZwlrDataControlSourceV1)
160 Destroy(self *ZwlrDataControlDeviceV1)
161 SetPrimarySelection(self *ZwlrDataControlDeviceV1, source *ZwlrDataControlSourceV1)
162}
163
164func NewZwlrDataControlDeviceV1(c server.Client, version int32, id uint32, h ZwlrDataControlDeviceV1Handler) (*ZwlrDataControlDeviceV1, error) {
165 if h == nil {
166 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_data_control_device_v1")
167 }
168 var self *ZwlrDataControlDeviceV1
169 r, err := c.CreateResource(ZwlrDataControlDeviceV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
170 switch opcode {
171 case 0:
172 h.SetSelection(self, WrapZwlrDataControlSourceV1(args[0].Resource()))
173 case 1:
174 h.Destroy(self)
175 self.Destroy()
176 case 2:
177 h.SetPrimarySelection(self, WrapZwlrDataControlSourceV1(args[0].Resource()))
178 }
179 })
180 if err != nil {
181 return nil, err
182 }
183 self = WrapZwlrDataControlDeviceV1(r)
184 r.Data = self
185 return self, nil
186}
187
188// SendDataOffer introduce a new wlr_data_control_offer.
189func (self *ZwlrDataControlDeviceV1) SendDataOffer(id *ZwlrDataControlOfferV1) {
190 self.PostEvent(ZwlrDataControlDeviceV1EventDataOffer, server.NewID(resourceOf(id)))
191}
192
193// SendSelection advertise new selection.
194func (self *ZwlrDataControlDeviceV1) SendSelection(id *ZwlrDataControlOfferV1) {
195 self.PostEvent(ZwlrDataControlDeviceV1EventSelection, server.Object(resourceOf(id)))
196}
197
198// SendFinished this data control is no longer valid.
199func (self *ZwlrDataControlDeviceV1) SendFinished() {
200 self.PostEvent(ZwlrDataControlDeviceV1EventFinished)
201}
202
203// SendPrimarySelection advertise new primary selection (since version 2).
204func (self *ZwlrDataControlDeviceV1) SendPrimarySelection(id *ZwlrDataControlOfferV1) {
205 self.PostEvent(ZwlrDataControlDeviceV1EventPrimarySelection, server.Object(resourceOf(id)))
206}
207func NewZwlrDataControlDeviceV1Global(d *server.Display, version int32, bind server.BindFunc) error {
208 return d.CreateGlobal(ZwlrDataControlDeviceV1Interface, version, bind)
209}
210
211// ZwlrDataControlSourceV1 offer to transfer data.
212type ZwlrDataControlSourceV1 struct{ *server.Resource }
213
214func WrapZwlrDataControlSourceV1(r *server.Resource) *ZwlrDataControlSourceV1 {
215 if r == nil {
216 return nil
217 }
218 return &ZwlrDataControlSourceV1{r}
219}
220
221const ZwlrDataControlSourceV1RequestOffer uint32 = 0
222const ZwlrDataControlSourceV1RequestDestroy uint32 = 1
223const ZwlrDataControlSourceV1EventSend uint32 = 0
224const ZwlrDataControlSourceV1EventCancelled uint32 = 1
225
226// ZwlrDataControlSourceV1Error .
227type ZwlrDataControlSourceV1Error uint32
228
229const (
230 ZwlrDataControlSourceV1ErrorInvalidOffer ZwlrDataControlSourceV1Error = 1
231)
232
233// ZwlrDataControlSourceV1Handler handles zwlr_data_control_source_v1 requests.
234type ZwlrDataControlSourceV1Handler interface {
235 Offer(self *ZwlrDataControlSourceV1, mimeType string)
236 Destroy(self *ZwlrDataControlSourceV1)
237}
238
239func NewZwlrDataControlSourceV1(c server.Client, version int32, id uint32, h ZwlrDataControlSourceV1Handler) (*ZwlrDataControlSourceV1, error) {
240 if h == nil {
241 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_data_control_source_v1")
242 }
243 var self *ZwlrDataControlSourceV1
244 r, err := c.CreateResource(ZwlrDataControlSourceV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
245 switch opcode {
246 case 0:
247 h.Offer(self, args[0].String())
248 case 1:
249 h.Destroy(self)
250 self.Destroy()
251 }
252 })
253 if err != nil {
254 return nil, err
255 }
256 self = WrapZwlrDataControlSourceV1(r)
257 r.Data = self
258 return self, nil
259}
260
261// SendSend send the data.
262func (self *ZwlrDataControlSourceV1) SendSend(mimeType string, fd int) {
263 var p runtime.Pinner
264 defer p.Unpin()
265 self.PostEvent(ZwlrDataControlSourceV1EventSend, server.String(&p, mimeType, false), server.Fd(fd))
266}
267
268// SendCancelled selection was cancelled.
269func (self *ZwlrDataControlSourceV1) SendCancelled() {
270 self.PostEvent(ZwlrDataControlSourceV1EventCancelled)
271}
272func NewZwlrDataControlSourceV1Global(d *server.Display, version int32, bind server.BindFunc) error {
273 return d.CreateGlobal(ZwlrDataControlSourceV1Interface, version, bind)
274}
275
276// ZwlrDataControlOfferV1 offer to transfer data.
277type ZwlrDataControlOfferV1 struct{ *server.Resource }
278
279func WrapZwlrDataControlOfferV1(r *server.Resource) *ZwlrDataControlOfferV1 {
280 if r == nil {
281 return nil
282 }
283 return &ZwlrDataControlOfferV1{r}
284}
285
286const ZwlrDataControlOfferV1RequestReceive uint32 = 0
287const ZwlrDataControlOfferV1RequestDestroy uint32 = 1
288const ZwlrDataControlOfferV1EventOffer uint32 = 0
289
290// ZwlrDataControlOfferV1Handler handles zwlr_data_control_offer_v1 requests.
291type ZwlrDataControlOfferV1Handler interface {
292 Receive(self *ZwlrDataControlOfferV1, mimeType string, fd int)
293 Destroy(self *ZwlrDataControlOfferV1)
294}
295
296func NewZwlrDataControlOfferV1(c server.Client, version int32, id uint32, h ZwlrDataControlOfferV1Handler) (*ZwlrDataControlOfferV1, error) {
297 if h == nil {
298 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_data_control_offer_v1")
299 }
300 var self *ZwlrDataControlOfferV1
301 r, err := c.CreateResource(ZwlrDataControlOfferV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
302 switch opcode {
303 case 0:
304 h.Receive(self, args[0].String(), args[1].Fd())
305 case 1:
306 h.Destroy(self)
307 self.Destroy()
308 }
309 })
310 if err != nil {
311 return nil, err
312 }
313 self = WrapZwlrDataControlOfferV1(r)
314 r.Data = self
315 return self, nil
316}
317
318// SendOffer advertise offered MIME type.
319func (self *ZwlrDataControlOfferV1) SendOffer(mimeType string) {
320 var p runtime.Pinner
321 defer p.Unpin()
322 self.PostEvent(ZwlrDataControlOfferV1EventOffer, server.String(&p, mimeType, false))
323}
324func NewZwlrDataControlOfferV1Global(d *server.Display, version int32, bind server.BindFunc) error {
325 return d.CreateGlobal(ZwlrDataControlOfferV1Interface, version, bind)
326}
327func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
328 if v == nil {
329 return nil
330 }
331 return v.GetResource()
332}
333func (self *ZwlrDataControlManagerV1) GetResource() *server.Resource {
334 if self == nil {
335 return nil
336 }
337 return self.Resource
338}
339func (self *ZwlrDataControlDeviceV1) GetResource() *server.Resource {
340 if self == nil {
341 return nil
342 }
343 return self.Resource
344}
345func (self *ZwlrDataControlSourceV1) GetResource() *server.Resource {
346 if self == nil {
347 return nil
348 }
349 return self.Resource
350}
351func (self *ZwlrDataControlOfferV1) GetResource() *server.Resource {
352 if self == nil {
353 return nil
354 }
355 return self.Resource
356}