1// Code generated by wlgen; DO NOT EDIT.
2package pointerconstraints
3
4import (
5 "fmt"
6 wayland "github.com/bnema/purego-libwayland/protocol/wayland"
7 "github.com/bnema/purego-libwayland/server"
8)
9
10var ZwpPointerConstraintsV1Interface *server.Interface
11var ZwpLockedPointerV1Interface *server.Interface
12var ZwpConfinedPointerV1Interface *server.Interface
13
14func init() {
15 ZwpPointerConstraintsV1Interface = &server.Interface{Name: "zwp_pointer_constraints_v1", Version: 1}
16 ZwpLockedPointerV1Interface = &server.Interface{Name: "zwp_locked_pointer_v1", Version: 1}
17 ZwpConfinedPointerV1Interface = &server.Interface{Name: "zwp_confined_pointer_v1", Version: 1}
18 ZwpPointerConstraintsV1Interface.Requests = []server.Message{
19 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
20 {Name: "lock_pointer", Signature: "noo?ou", Types: []*server.Interface{ZwpLockedPointerV1Interface, wayland.SurfaceInterface, wayland.PointerInterface, wayland.RegionInterface, nil}},
21 {Name: "confine_pointer", Signature: "noo?ou", Types: []*server.Interface{ZwpConfinedPointerV1Interface, wayland.SurfaceInterface, wayland.PointerInterface, wayland.RegionInterface, nil}},
22 }
23 ZwpPointerConstraintsV1Interface.Events = []server.Message{}
24 ZwpLockedPointerV1Interface.Requests = []server.Message{
25 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
26 {Name: "set_cursor_position_hint", Signature: "ff", Types: []*server.Interface{nil, nil}},
27 {Name: "set_region", Signature: "?o", Types: []*server.Interface{wayland.RegionInterface}},
28 }
29 ZwpLockedPointerV1Interface.Events = []server.Message{
30 {Name: "locked", Signature: "", Types: []*server.Interface{}},
31 {Name: "unlocked", Signature: "", Types: []*server.Interface{}},
32 }
33 ZwpConfinedPointerV1Interface.Requests = []server.Message{
34 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
35 {Name: "set_region", Signature: "?o", Types: []*server.Interface{wayland.RegionInterface}},
36 }
37 ZwpConfinedPointerV1Interface.Events = []server.Message{
38 {Name: "confined", Signature: "", Types: []*server.Interface{}},
39 {Name: "unconfined", Signature: "", Types: []*server.Interface{}},
40 }
41 if err := server.NewInterfaces(ZwpPointerConstraintsV1Interface, ZwpLockedPointerV1Interface, ZwpConfinedPointerV1Interface); err != nil {
42 panic(err)
43 }
44}
45
46// ZwpPointerConstraintsV1 constrain the movement of a pointer.
47type ZwpPointerConstraintsV1 struct{ *server.Resource }
48
49func WrapZwpPointerConstraintsV1(r *server.Resource) *ZwpPointerConstraintsV1 {
50 if r == nil {
51 return nil
52 }
53 return &ZwpPointerConstraintsV1{r}
54}
55
56const ZwpPointerConstraintsV1RequestDestroy uint32 = 0
57const ZwpPointerConstraintsV1RequestLockPointer uint32 = 1
58const ZwpPointerConstraintsV1RequestConfinePointer uint32 = 2
59
60// ZwpPointerConstraintsV1Error wp_pointer_constraints error values.
61type ZwpPointerConstraintsV1Error uint32
62
63const (
64 ZwpPointerConstraintsV1ErrorAlreadyConstrained ZwpPointerConstraintsV1Error = 1
65)
66
67// ZwpPointerConstraintsV1Lifetime constraint lifetime.
68type ZwpPointerConstraintsV1Lifetime uint32
69
70const (
71 ZwpPointerConstraintsV1LifetimeOneshot ZwpPointerConstraintsV1Lifetime = 1
72 ZwpPointerConstraintsV1LifetimePersistent ZwpPointerConstraintsV1Lifetime = 2
73)
74
75// ZwpPointerConstraintsV1Handler handles zwp_pointer_constraints_v1 requests.
76type ZwpPointerConstraintsV1Handler interface {
77 Destroy(self *ZwpPointerConstraintsV1)
78 LockPointer(self *ZwpPointerConstraintsV1, id uint32, surface *wayland.Surface, pointer *wayland.Pointer, region *wayland.Region, lifetime uint32)
79 ConfinePointer(self *ZwpPointerConstraintsV1, id uint32, surface *wayland.Surface, pointer *wayland.Pointer, region *wayland.Region, lifetime uint32)
80}
81
82func NewZwpPointerConstraintsV1(c server.Client, version int32, id uint32, h ZwpPointerConstraintsV1Handler) (*ZwpPointerConstraintsV1, error) {
83 if h == nil {
84 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_pointer_constraints_v1")
85 }
86 var self *ZwpPointerConstraintsV1
87 r, err := c.CreateResource(ZwpPointerConstraintsV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
88 switch opcode {
89 case 0:
90 h.Destroy(self)
91 self.Destroy()
92 case 1:
93 h.LockPointer(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()), wayland.WrapPointer(args[2].Resource()), wayland.WrapRegion(args[3].Resource()), args[4].Uint())
94 case 2:
95 h.ConfinePointer(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()), wayland.WrapPointer(args[2].Resource()), wayland.WrapRegion(args[3].Resource()), args[4].Uint())
96 }
97 })
98 if err != nil {
99 return nil, err
100 }
101 self = WrapZwpPointerConstraintsV1(r)
102 r.Data = self
103 return self, nil
104}
105func NewZwpPointerConstraintsV1Global(d *server.Display, version int32, bind server.BindFunc) error {
106 return d.CreateGlobal(ZwpPointerConstraintsV1Interface, version, bind)
107}
108
109// ZwpLockedPointerV1 receive relative pointer motion events.
110type ZwpLockedPointerV1 struct{ *server.Resource }
111
112func WrapZwpLockedPointerV1(r *server.Resource) *ZwpLockedPointerV1 {
113 if r == nil {
114 return nil
115 }
116 return &ZwpLockedPointerV1{r}
117}
118
119const ZwpLockedPointerV1RequestDestroy uint32 = 0
120const ZwpLockedPointerV1RequestSetCursorPositionHint uint32 = 1
121const ZwpLockedPointerV1RequestSetRegion uint32 = 2
122const ZwpLockedPointerV1EventLocked uint32 = 0
123const ZwpLockedPointerV1EventUnlocked uint32 = 1
124
125// ZwpLockedPointerV1Handler handles zwp_locked_pointer_v1 requests.
126type ZwpLockedPointerV1Handler interface {
127 Destroy(self *ZwpLockedPointerV1)
128 SetCursorPositionHint(self *ZwpLockedPointerV1, surfaceX server.Fixed, surfaceY server.Fixed)
129 SetRegion(self *ZwpLockedPointerV1, region *wayland.Region)
130}
131
132func NewZwpLockedPointerV1(c server.Client, version int32, id uint32, h ZwpLockedPointerV1Handler) (*ZwpLockedPointerV1, error) {
133 if h == nil {
134 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_locked_pointer_v1")
135 }
136 var self *ZwpLockedPointerV1
137 r, err := c.CreateResource(ZwpLockedPointerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
138 switch opcode {
139 case 0:
140 h.Destroy(self)
141 self.Destroy()
142 case 1:
143 h.SetCursorPositionHint(self, args[0].Fixed(), args[1].Fixed())
144 case 2:
145 h.SetRegion(self, wayland.WrapRegion(args[0].Resource()))
146 }
147 })
148 if err != nil {
149 return nil, err
150 }
151 self = WrapZwpLockedPointerV1(r)
152 r.Data = self
153 return self, nil
154}
155
156// SendLocked lock activation event.
157func (self *ZwpLockedPointerV1) SendLocked() {
158 self.PostEvent(ZwpLockedPointerV1EventLocked)
159}
160
161// SendUnlocked lock deactivation event.
162func (self *ZwpLockedPointerV1) SendUnlocked() {
163 self.PostEvent(ZwpLockedPointerV1EventUnlocked)
164}
165func NewZwpLockedPointerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
166 return d.CreateGlobal(ZwpLockedPointerV1Interface, version, bind)
167}
168
169// ZwpConfinedPointerV1 confined pointer object.
170type ZwpConfinedPointerV1 struct{ *server.Resource }
171
172func WrapZwpConfinedPointerV1(r *server.Resource) *ZwpConfinedPointerV1 {
173 if r == nil {
174 return nil
175 }
176 return &ZwpConfinedPointerV1{r}
177}
178
179const ZwpConfinedPointerV1RequestDestroy uint32 = 0
180const ZwpConfinedPointerV1RequestSetRegion uint32 = 1
181const ZwpConfinedPointerV1EventConfined uint32 = 0
182const ZwpConfinedPointerV1EventUnconfined uint32 = 1
183
184// ZwpConfinedPointerV1Handler handles zwp_confined_pointer_v1 requests.
185type ZwpConfinedPointerV1Handler interface {
186 Destroy(self *ZwpConfinedPointerV1)
187 SetRegion(self *ZwpConfinedPointerV1, region *wayland.Region)
188}
189
190func NewZwpConfinedPointerV1(c server.Client, version int32, id uint32, h ZwpConfinedPointerV1Handler) (*ZwpConfinedPointerV1, error) {
191 if h == nil {
192 return nil, fmt.Errorf("purego-libwayland: nil handler for zwp_confined_pointer_v1")
193 }
194 var self *ZwpConfinedPointerV1
195 r, err := c.CreateResource(ZwpConfinedPointerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
196 switch opcode {
197 case 0:
198 h.Destroy(self)
199 self.Destroy()
200 case 1:
201 h.SetRegion(self, wayland.WrapRegion(args[0].Resource()))
202 }
203 })
204 if err != nil {
205 return nil, err
206 }
207 self = WrapZwpConfinedPointerV1(r)
208 r.Data = self
209 return self, nil
210}
211
212// SendConfined pointer confined.
213func (self *ZwpConfinedPointerV1) SendConfined() {
214 self.PostEvent(ZwpConfinedPointerV1EventConfined)
215}
216
217// SendUnconfined pointer unconfined.
218func (self *ZwpConfinedPointerV1) SendUnconfined() {
219 self.PostEvent(ZwpConfinedPointerV1EventUnconfined)
220}
221func NewZwpConfinedPointerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
222 return d.CreateGlobal(ZwpConfinedPointerV1Interface, version, bind)
223}
224func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
225 if v == nil {
226 return nil
227 }
228 return v.GetResource()
229}
230func (self *ZwpPointerConstraintsV1) GetResource() *server.Resource {
231 if self == nil {
232 return nil
233 }
234 return self.Resource
235}
236func (self *ZwpLockedPointerV1) GetResource() *server.Resource {
237 if self == nil {
238 return nil
239 }
240 return self.Resource
241}
242func (self *ZwpConfinedPointerV1) GetResource() *server.Resource {
243 if self == nil {
244 return nil
245 }
246 return self.Resource
247}