1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2014 Jonas Ådahl
5// Copyright © 2015 Red Hat Inc.
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice (including the next
15// paragraph) shall be included in all copies or substantial portions of the
16// Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24// DEALINGS IN THE SOFTWARE.
25
26package pointerconstraints
27
28import (
29 "fmt"
30 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
31 "github.com/bnema/purego-libwayland/server"
32)
33
34var ZwpPointerConstraintsV1Interface *server.Interface
35var ZwpLockedPointerV1Interface *server.Interface
36var ZwpConfinedPointerV1Interface *server.Interface
37
38func init() {
39 ZwpPointerConstraintsV1Interface = &server.Interface{Name: "zwp_pointer_constraints_v1", Version: 1}
40 ZwpLockedPointerV1Interface = &server.Interface{Name: "zwp_locked_pointer_v1", Version: 1}
41 ZwpConfinedPointerV1Interface = &server.Interface{Name: "zwp_confined_pointer_v1", Version: 1}
42 ZwpPointerConstraintsV1Interface.Requests = []server.Message{
43 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
44 {Name: "lock_pointer", Signature: "noo?ou", Types: []*server.Interface{ZwpLockedPointerV1Interface, wayland.SurfaceInterface, wayland.PointerInterface, wayland.RegionInterface, nil}},
45 {Name: "confine_pointer", Signature: "noo?ou", Types: []*server.Interface{ZwpConfinedPointerV1Interface, wayland.SurfaceInterface, wayland.PointerInterface, wayland.RegionInterface, nil}},
46 }
47 ZwpPointerConstraintsV1Interface.Events = []server.Message{}
48 ZwpLockedPointerV1Interface.Requests = []server.Message{
49 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
50 {Name: "set_cursor_position_hint", Signature: "ff", Types: []*server.Interface{nil, nil}},
51 {Name: "set_region", Signature: "?o", Types: []*server.Interface{wayland.RegionInterface}},
52 }
53 ZwpLockedPointerV1Interface.Events = []server.Message{
54 {Name: "locked", Signature: "", Types: []*server.Interface{}},
55 {Name: "unlocked", Signature: "", Types: []*server.Interface{}},
56 }
57 ZwpConfinedPointerV1Interface.Requests = []server.Message{
58 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
59 {Name: "set_region", Signature: "?o", Types: []*server.Interface{wayland.RegionInterface}},
60 }
61 ZwpConfinedPointerV1Interface.Events = []server.Message{
62 {Name: "confined", Signature: "", Types: []*server.Interface{}},
63 {Name: "unconfined", Signature: "", Types: []*server.Interface{}},
64 }
65 if err := server.NewInterfaces(ZwpPointerConstraintsV1Interface, ZwpLockedPointerV1Interface, ZwpConfinedPointerV1Interface); err != nil {
66 panic(err)
67 }
68}
69
70// ZwpPointerConstraintsV1 constrain the movement of a pointer.
71type ZwpPointerConstraintsV1 struct{ *server.Resource }
72
73func WrapZwpPointerConstraintsV1(r *server.Resource) *ZwpPointerConstraintsV1 {
74 if r == nil {
75 return nil
76 }
77 return &ZwpPointerConstraintsV1{r}
78}
79
80const ZwpPointerConstraintsV1RequestDestroy uint32 = 0
81const ZwpPointerConstraintsV1RequestLockPointer uint32 = 1
82const ZwpPointerConstraintsV1RequestConfinePointer uint32 = 2
83
84// ZwpPointerConstraintsV1Error wp_pointer_constraints error values.
85type ZwpPointerConstraintsV1Error uint32
86
87const (
88 ZwpPointerConstraintsV1ErrorAlreadyConstrained ZwpPointerConstraintsV1Error = 1
89)
90
91// ZwpPointerConstraintsV1Lifetime constraint lifetime.
92type ZwpPointerConstraintsV1Lifetime uint32
93
94const (
95 ZwpPointerConstraintsV1LifetimeOneshot ZwpPointerConstraintsV1Lifetime = 1
96 ZwpPointerConstraintsV1LifetimePersistent ZwpPointerConstraintsV1Lifetime = 2
97)
98
99// ZwpPointerConstraintsV1Handler handles zwp_pointer_constraints_v1 requests.
100type ZwpPointerConstraintsV1Handler interface {
101 Destroy(self *ZwpPointerConstraintsV1)
102 LockPointer(self *ZwpPointerConstraintsV1, id uint32, surface *wayland.Surface, pointer *wayland.Pointer, region *wayland.Region, lifetime uint32)
103 ConfinePointer(self *ZwpPointerConstraintsV1, id uint32, surface *wayland.Surface, pointer *wayland.Pointer, region *wayland.Region, lifetime uint32)
104}
105
106func NewZwpPointerConstraintsV1(c server.Client, version int32, id uint32, h ZwpPointerConstraintsV1Handler) (*ZwpPointerConstraintsV1, error) {
107 if h == nil {
108 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_pointer_constraints_v1")
109 }
110 var self *ZwpPointerConstraintsV1
111 r, err := c.CreateResource(ZwpPointerConstraintsV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
112 switch opcode {
113 case 0:
114 h.Destroy(self)
115 self.Destroy()
116 case 1:
117 h.LockPointer(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()), wayland.WrapPointer(args[2].Resource()), wayland.WrapRegion(args[3].Resource()), args[4].Uint())
118 case 2:
119 h.ConfinePointer(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()), wayland.WrapPointer(args[2].Resource()), wayland.WrapRegion(args[3].Resource()), args[4].Uint())
120 }
121 })
122 if err != nil {
123 return nil, err
124 }
125 self = WrapZwpPointerConstraintsV1(r)
126 r.Data = self
127 return self, nil
128}
129func NewZwpPointerConstraintsV1Global(d *server.Display, version int32, bind server.BindFunc) error {
130 return d.CreateGlobal(ZwpPointerConstraintsV1Interface, version, bind)
131}
132
133// ZwpLockedPointerV1 receive relative pointer motion events.
134type ZwpLockedPointerV1 struct{ *server.Resource }
135
136func WrapZwpLockedPointerV1(r *server.Resource) *ZwpLockedPointerV1 {
137 if r == nil {
138 return nil
139 }
140 return &ZwpLockedPointerV1{r}
141}
142
143const ZwpLockedPointerV1RequestDestroy uint32 = 0
144const ZwpLockedPointerV1RequestSetCursorPositionHint uint32 = 1
145const ZwpLockedPointerV1RequestSetRegion uint32 = 2
146const ZwpLockedPointerV1EventLocked uint32 = 0
147const ZwpLockedPointerV1EventUnlocked uint32 = 1
148
149// ZwpLockedPointerV1Handler handles zwp_locked_pointer_v1 requests.
150type ZwpLockedPointerV1Handler interface {
151 Destroy(self *ZwpLockedPointerV1)
152 SetCursorPositionHint(self *ZwpLockedPointerV1, surfaceX server.Fixed, surfaceY server.Fixed)
153 SetRegion(self *ZwpLockedPointerV1, region *wayland.Region)
154}
155
156func NewZwpLockedPointerV1(c server.Client, version int32, id uint32, h ZwpLockedPointerV1Handler) (*ZwpLockedPointerV1, error) {
157 if h == nil {
158 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_locked_pointer_v1")
159 }
160 var self *ZwpLockedPointerV1
161 r, err := c.CreateResource(ZwpLockedPointerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
162 switch opcode {
163 case 0:
164 h.Destroy(self)
165 self.Destroy()
166 case 1:
167 h.SetCursorPositionHint(self, args[0].Fixed(), args[1].Fixed())
168 case 2:
169 h.SetRegion(self, wayland.WrapRegion(args[0].Resource()))
170 }
171 })
172 if err != nil {
173 return nil, err
174 }
175 self = WrapZwpLockedPointerV1(r)
176 r.Data = self
177 return self, nil
178}
179
180// SendLocked lock activation event.
181func (self *ZwpLockedPointerV1) SendLocked() {
182 self.PostEvent(ZwpLockedPointerV1EventLocked)
183}
184
185// SendUnlocked lock deactivation event.
186func (self *ZwpLockedPointerV1) SendUnlocked() {
187 self.PostEvent(ZwpLockedPointerV1EventUnlocked)
188}
189func NewZwpLockedPointerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
190 return d.CreateGlobal(ZwpLockedPointerV1Interface, version, bind)
191}
192
193// ZwpConfinedPointerV1 confined pointer object.
194type ZwpConfinedPointerV1 struct{ *server.Resource }
195
196func WrapZwpConfinedPointerV1(r *server.Resource) *ZwpConfinedPointerV1 {
197 if r == nil {
198 return nil
199 }
200 return &ZwpConfinedPointerV1{r}
201}
202
203const ZwpConfinedPointerV1RequestDestroy uint32 = 0
204const ZwpConfinedPointerV1RequestSetRegion uint32 = 1
205const ZwpConfinedPointerV1EventConfined uint32 = 0
206const ZwpConfinedPointerV1EventUnconfined uint32 = 1
207
208// ZwpConfinedPointerV1Handler handles zwp_confined_pointer_v1 requests.
209type ZwpConfinedPointerV1Handler interface {
210 Destroy(self *ZwpConfinedPointerV1)
211 SetRegion(self *ZwpConfinedPointerV1, region *wayland.Region)
212}
213
214func NewZwpConfinedPointerV1(c server.Client, version int32, id uint32, h ZwpConfinedPointerV1Handler) (*ZwpConfinedPointerV1, error) {
215 if h == nil {
216 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_confined_pointer_v1")
217 }
218 var self *ZwpConfinedPointerV1
219 r, err := c.CreateResource(ZwpConfinedPointerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
220 switch opcode {
221 case 0:
222 h.Destroy(self)
223 self.Destroy()
224 case 1:
225 h.SetRegion(self, wayland.WrapRegion(args[0].Resource()))
226 }
227 })
228 if err != nil {
229 return nil, err
230 }
231 self = WrapZwpConfinedPointerV1(r)
232 r.Data = self
233 return self, nil
234}
235
236// SendConfined pointer confined.
237func (self *ZwpConfinedPointerV1) SendConfined() {
238 self.PostEvent(ZwpConfinedPointerV1EventConfined)
239}
240
241// SendUnconfined pointer unconfined.
242func (self *ZwpConfinedPointerV1) SendUnconfined() {
243 self.PostEvent(ZwpConfinedPointerV1EventUnconfined)
244}
245func NewZwpConfinedPointerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
246 return d.CreateGlobal(ZwpConfinedPointerV1Interface, version, bind)
247}
248func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
249 if v == nil {
250 return nil
251 }
252 return v.GetResource()
253}
254func (self *ZwpPointerConstraintsV1) GetResource() *server.Resource {
255 if self == nil {
256 return nil
257 }
258 return self.Resource
259}
260func (self *ZwpLockedPointerV1) GetResource() *server.Resource {
261 if self == nil {
262 return nil
263 }
264 return self.Resource
265}
266func (self *ZwpConfinedPointerV1) GetResource() *server.Resource {
267 if self == nil {
268 return nil
269 }
270 return self.Resource
271}