1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: pointer_gestures_unstable_v1
3// Source: pointer-gestures-unstable-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2015, 2021 Red Hat Inc.
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 pointergestures
30
31import (
32 "sync"
33
34 cross_wl_pointer "github.com/bnema/go-wayland-bindings/client/wayland"
35 "github.com/bnema/wlturbo/wl"
36)
37
38// PointerGesturesInterface is the protocol interface name.
39const PointerGesturesInterface = "zwp_pointer_gestures_v1"
40
41// PointerGestures is the generated binding for zwp_pointer_gestures_v1 version 3.
42type PointerGestures struct {
43 wl.BaseProxy
44}
45
46// NewPointerGestures returns an unbound PointerGestures.
47func NewPointerGestures(ctx *wl.Context) *PointerGestures {
48 obj := &PointerGestures{}
49 obj.SetContext(ctx)
50 ctx.Register(obj)
51 return obj
52}
53
54// Create a swipe gesture object. See the wl_pointer_gesture_swipe interface for details.
55func (o *PointerGestures) GetSwipeGesture(pointer *cross_wl_pointer.Pointer) (*PointerGestureSwipe, error) {
56 var arg1 wl.Object
57 if pointer != nil {
58 arg1 = pointer
59 }
60 child := &PointerGestureSwipe{}
61 child.SetContext(o.Context())
62 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_pointer_gestures_v1.get_swipe_gesture", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
63 return nil, err
64 }
65 return child, nil
66}
67
68// Create a pinch gesture object. See the wl_pointer_gesture_pinch interface for details.
69func (o *PointerGestures) GetPinchGesture(pointer *cross_wl_pointer.Pointer) (*PointerGesturePinch, error) {
70 var arg1 wl.Object
71 if pointer != nil {
72 arg1 = pointer
73 }
74 child := &PointerGesturePinch{}
75 child.SetContext(o.Context())
76 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_pointer_gestures_v1.get_pinch_gesture", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
77 return nil, err
78 }
79 return child, nil
80}
81
82// Destroy the pointer gesture object. Swipe, pinch and hold objects created via this gesture object remain valid.
83func (o *PointerGestures) Release() error {
84 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwp_pointer_gestures_v1.release", Since: 2, Destructor: true}); err != nil {
85 return err
86 }
87 return nil
88}
89
90// Create a hold gesture object. See the wl_pointer_gesture_hold interface for details.
91func (o *PointerGestures) GetHoldGesture(pointer *cross_wl_pointer.Pointer) (*PointerGestureHold, error) {
92 var arg1 wl.Object
93 if pointer != nil {
94 arg1 = pointer
95 }
96 child := &PointerGestureHold{}
97 child.SetContext(o.Context())
98 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "zwp_pointer_gestures_v1.get_hold_gesture", Since: 3, Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
99 return nil, err
100 }
101 return child, nil
102}
103
104// EventSignature returns the declared event argument types in wire order.
105func (o *PointerGestures) EventSignature(opcode uint16) (string, bool) {
106 switch opcode {
107 default:
108 return "", false
109 }
110}
111
112// Dispatch decodes one event on zwp_pointer_gestures_v1 and calls the registered handlers.
113func (o *PointerGestures) Dispatch(event *wl.Event) {
114 switch event.Opcode {
115 default:
116 }
117}
118
119// PointerGestureSwipeInterface is the protocol interface name.
120const PointerGestureSwipeInterface = "zwp_pointer_gesture_swipe_v1"
121
122// PointerGestureSwipe is the generated binding for zwp_pointer_gesture_swipe_v1 version 3.
123type PointerGestureSwipe struct {
124 wl.BaseProxy
125 // handlersMu guards the handler slices: a client may register or replace
126 // handlers while another goroutine dispatches events.
127 handlersMu sync.Mutex
128 onBegin []func(serial uint32, time uint32, surfaceID uint32, fingers uint32)
129 onUpdate []func(time uint32, dx wl.Fixed, dy wl.Fixed)
130 onEnd []func(serial uint32, time uint32, cancelled int32)
131}
132
133// NewPointerGestureSwipe returns an unbound PointerGestureSwipe.
134func NewPointerGestureSwipe(ctx *wl.Context) *PointerGestureSwipe {
135 obj := &PointerGestureSwipe{}
136 obj.SetContext(ctx)
137 ctx.Register(obj)
138 return obj
139}
140
141// destroy the pointer swipe gesture object
142func (o *PointerGestureSwipe) Destroy() error {
143 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_pointer_gesture_swipe_v1.destroy", Destructor: true}); err != nil {
144 return err
145 }
146 return nil
147}
148
149// OnBegin registers a handler for the begin event.
150//
151// Handlers are appended, so a second call adds another handler rather than
152// replacing the first. Registration is safe while another goroutine dispatches.
153func (o *PointerGestureSwipe) OnBegin(handler func(serial uint32, time uint32, surfaceID uint32, fingers uint32)) {
154 if handler == nil {
155 return
156 }
157 o.handlersMu.Lock()
158 defer o.handlersMu.Unlock()
159 o.onBegin = append(o.onBegin, handler)
160}
161
162// handlersForBegin returns the handlers registered for begin, taken
163// under the lock so a handler may register another handler while events are
164// being dispatched.
165func (o *PointerGestureSwipe) handlersForBegin() []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) {
166 o.handlersMu.Lock()
167 defer o.handlersMu.Unlock()
168 return o.onBegin
169}
170
171// OnUpdate registers a handler for the update event.
172//
173// Handlers are appended, so a second call adds another handler rather than
174// replacing the first. Registration is safe while another goroutine dispatches.
175func (o *PointerGestureSwipe) OnUpdate(handler func(time uint32, dx wl.Fixed, dy wl.Fixed)) {
176 if handler == nil {
177 return
178 }
179 o.handlersMu.Lock()
180 defer o.handlersMu.Unlock()
181 o.onUpdate = append(o.onUpdate, handler)
182}
183
184// handlersForUpdate returns the handlers registered for update, taken
185// under the lock so a handler may register another handler while events are
186// being dispatched.
187func (o *PointerGestureSwipe) handlersForUpdate() []func(time uint32, dx wl.Fixed, dy wl.Fixed) {
188 o.handlersMu.Lock()
189 defer o.handlersMu.Unlock()
190 return o.onUpdate
191}
192
193// OnEnd registers a handler for the end event.
194//
195// Handlers are appended, so a second call adds another handler rather than
196// replacing the first. Registration is safe while another goroutine dispatches.
197func (o *PointerGestureSwipe) OnEnd(handler func(serial uint32, time uint32, cancelled int32)) {
198 if handler == nil {
199 return
200 }
201 o.handlersMu.Lock()
202 defer o.handlersMu.Unlock()
203 o.onEnd = append(o.onEnd, handler)
204}
205
206// handlersForEnd returns the handlers registered for end, taken
207// under the lock so a handler may register another handler while events are
208// being dispatched.
209func (o *PointerGestureSwipe) handlersForEnd() []func(serial uint32, time uint32, cancelled int32) {
210 o.handlersMu.Lock()
211 defer o.handlersMu.Unlock()
212 return o.onEnd
213}
214
215// EventSignature returns the declared event argument types in wire order.
216func (o *PointerGestureSwipe) EventSignature(opcode uint16) (string, bool) {
217 switch opcode {
218 case 0:
219 return "uint,uint,object,uint,", true
220 case 1:
221 return "uint,fixed,fixed,", true
222 case 2:
223 return "uint,uint,int,", true
224 default:
225 return "", false
226 }
227}
228
229// Dispatch decodes one event on zwp_pointer_gesture_swipe_v1 and calls the registered handlers.
230func (o *PointerGestureSwipe) Dispatch(event *wl.Event) {
231 switch event.Opcode {
232 case 0: // begin
233 serial := event.Uint32()
234 time := event.Uint32()
235 surfaceID := event.Uint32()
236 fingers := event.Uint32()
237
238 for i, handler := range o.handlersForBegin() {
239 _ = i
240 handler(serial, time, surfaceID, fingers)
241 }
242 case 1: // update
243 time := event.Uint32()
244 dx := event.Fixed()
245 dy := event.Fixed()
246
247 for i, handler := range o.handlersForUpdate() {
248 _ = i
249 handler(time, dx, dy)
250 }
251 case 2: // end
252 serial := event.Uint32()
253 time := event.Uint32()
254 cancelled := event.Int32()
255
256 for i, handler := range o.handlersForEnd() {
257 _ = i
258 handler(serial, time, cancelled)
259 }
260 default:
261 }
262}
263
264// PointerGesturePinchInterface is the protocol interface name.
265const PointerGesturePinchInterface = "zwp_pointer_gesture_pinch_v1"
266
267// PointerGesturePinch is the generated binding for zwp_pointer_gesture_pinch_v1 version 3.
268type PointerGesturePinch struct {
269 wl.BaseProxy
270 // handlersMu guards the handler slices: a client may register or replace
271 // handlers while another goroutine dispatches events.
272 handlersMu sync.Mutex
273 onBegin []func(serial uint32, time uint32, surfaceID uint32, fingers uint32)
274 onUpdate []func(time uint32, dx wl.Fixed, dy wl.Fixed, scale wl.Fixed, rotation wl.Fixed)
275 onEnd []func(serial uint32, time uint32, cancelled int32)
276}
277
278// NewPointerGesturePinch returns an unbound PointerGesturePinch.
279func NewPointerGesturePinch(ctx *wl.Context) *PointerGesturePinch {
280 obj := &PointerGesturePinch{}
281 obj.SetContext(ctx)
282 ctx.Register(obj)
283 return obj
284}
285
286// destroy the pinch gesture object
287func (o *PointerGesturePinch) Destroy() error {
288 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_pointer_gesture_pinch_v1.destroy", Destructor: true}); err != nil {
289 return err
290 }
291 return nil
292}
293
294// OnBegin registers a handler for the begin event.
295//
296// Handlers are appended, so a second call adds another handler rather than
297// replacing the first. Registration is safe while another goroutine dispatches.
298func (o *PointerGesturePinch) OnBegin(handler func(serial uint32, time uint32, surfaceID uint32, fingers uint32)) {
299 if handler == nil {
300 return
301 }
302 o.handlersMu.Lock()
303 defer o.handlersMu.Unlock()
304 o.onBegin = append(o.onBegin, handler)
305}
306
307// handlersForBegin returns the handlers registered for begin, taken
308// under the lock so a handler may register another handler while events are
309// being dispatched.
310func (o *PointerGesturePinch) handlersForBegin() []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) {
311 o.handlersMu.Lock()
312 defer o.handlersMu.Unlock()
313 return o.onBegin
314}
315
316// OnUpdate registers a handler for the update event.
317//
318// Handlers are appended, so a second call adds another handler rather than
319// replacing the first. Registration is safe while another goroutine dispatches.
320func (o *PointerGesturePinch) OnUpdate(handler func(time uint32, dx wl.Fixed, dy wl.Fixed, scale wl.Fixed, rotation wl.Fixed)) {
321 if handler == nil {
322 return
323 }
324 o.handlersMu.Lock()
325 defer o.handlersMu.Unlock()
326 o.onUpdate = append(o.onUpdate, handler)
327}
328
329// handlersForUpdate returns the handlers registered for update, taken
330// under the lock so a handler may register another handler while events are
331// being dispatched.
332func (o *PointerGesturePinch) handlersForUpdate() []func(time uint32, dx wl.Fixed, dy wl.Fixed, scale wl.Fixed, rotation wl.Fixed) {
333 o.handlersMu.Lock()
334 defer o.handlersMu.Unlock()
335 return o.onUpdate
336}
337
338// OnEnd registers a handler for the end event.
339//
340// Handlers are appended, so a second call adds another handler rather than
341// replacing the first. Registration is safe while another goroutine dispatches.
342func (o *PointerGesturePinch) OnEnd(handler func(serial uint32, time uint32, cancelled int32)) {
343 if handler == nil {
344 return
345 }
346 o.handlersMu.Lock()
347 defer o.handlersMu.Unlock()
348 o.onEnd = append(o.onEnd, handler)
349}
350
351// handlersForEnd returns the handlers registered for end, taken
352// under the lock so a handler may register another handler while events are
353// being dispatched.
354func (o *PointerGesturePinch) handlersForEnd() []func(serial uint32, time uint32, cancelled int32) {
355 o.handlersMu.Lock()
356 defer o.handlersMu.Unlock()
357 return o.onEnd
358}
359
360// EventSignature returns the declared event argument types in wire order.
361func (o *PointerGesturePinch) EventSignature(opcode uint16) (string, bool) {
362 switch opcode {
363 case 0:
364 return "uint,uint,object,uint,", true
365 case 1:
366 return "uint,fixed,fixed,fixed,fixed,", true
367 case 2:
368 return "uint,uint,int,", true
369 default:
370 return "", false
371 }
372}
373
374// Dispatch decodes one event on zwp_pointer_gesture_pinch_v1 and calls the registered handlers.
375func (o *PointerGesturePinch) Dispatch(event *wl.Event) {
376 switch event.Opcode {
377 case 0: // begin
378 serial := event.Uint32()
379 time := event.Uint32()
380 surfaceID := event.Uint32()
381 fingers := event.Uint32()
382
383 for i, handler := range o.handlersForBegin() {
384 _ = i
385 handler(serial, time, surfaceID, fingers)
386 }
387 case 1: // update
388 time := event.Uint32()
389 dx := event.Fixed()
390 dy := event.Fixed()
391 scale := event.Fixed()
392 rotation := event.Fixed()
393
394 for i, handler := range o.handlersForUpdate() {
395 _ = i
396 handler(time, dx, dy, scale, rotation)
397 }
398 case 2: // end
399 serial := event.Uint32()
400 time := event.Uint32()
401 cancelled := event.Int32()
402
403 for i, handler := range o.handlersForEnd() {
404 _ = i
405 handler(serial, time, cancelled)
406 }
407 default:
408 }
409}
410
411// PointerGestureHoldInterface is the protocol interface name.
412const PointerGestureHoldInterface = "zwp_pointer_gesture_hold_v1"
413
414// PointerGestureHold is the generated binding for zwp_pointer_gesture_hold_v1 version 3.
415type PointerGestureHold struct {
416 wl.BaseProxy
417 // handlersMu guards the handler slices: a client may register or replace
418 // handlers while another goroutine dispatches events.
419 handlersMu sync.Mutex
420 onBegin []func(serial uint32, time uint32, surfaceID uint32, fingers uint32)
421 onEnd []func(serial uint32, time uint32, cancelled int32)
422}
423
424// NewPointerGestureHold returns an unbound PointerGestureHold.
425func NewPointerGestureHold(ctx *wl.Context) *PointerGestureHold {
426 obj := &PointerGestureHold{}
427 obj.SetContext(ctx)
428 ctx.Register(obj)
429 return obj
430}
431
432// destroy the hold gesture object
433func (o *PointerGestureHold) Destroy() error {
434 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_pointer_gesture_hold_v1.destroy", Since: 3, Destructor: true}); err != nil {
435 return err
436 }
437 return nil
438}
439
440// OnBegin registers a handler for the begin 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 *PointerGestureHold) OnBegin(handler func(serial uint32, time uint32, surfaceID uint32, fingers uint32)) {
445 if handler == nil {
446 return
447 }
448 o.handlersMu.Lock()
449 defer o.handlersMu.Unlock()
450 o.onBegin = append(o.onBegin, handler)
451}
452
453// handlersForBegin returns the handlers registered for begin, taken
454// under the lock so a handler may register another handler while events are
455// being dispatched.
456func (o *PointerGestureHold) handlersForBegin() []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) {
457 o.handlersMu.Lock()
458 defer o.handlersMu.Unlock()
459 return o.onBegin
460}
461
462// OnEnd registers a handler for the end 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 *PointerGestureHold) OnEnd(handler func(serial uint32, time uint32, cancelled int32)) {
467 if handler == nil {
468 return
469 }
470 o.handlersMu.Lock()
471 defer o.handlersMu.Unlock()
472 o.onEnd = append(o.onEnd, handler)
473}
474
475// handlersForEnd returns the handlers registered for end, taken
476// under the lock so a handler may register another handler while events are
477// being dispatched.
478func (o *PointerGestureHold) handlersForEnd() []func(serial uint32, time uint32, cancelled int32) {
479 o.handlersMu.Lock()
480 defer o.handlersMu.Unlock()
481 return o.onEnd
482}
483
484// EventSignature returns the declared event argument types in wire order.
485func (o *PointerGestureHold) EventSignature(opcode uint16) (string, bool) {
486 switch opcode {
487 case 0:
488 return "uint,uint,object,uint,", true
489 case 1:
490 return "uint,uint,int,", true
491 default:
492 return "", false
493 }
494}
495
496// Dispatch decodes one event on zwp_pointer_gesture_hold_v1 and calls the registered handlers.
497func (o *PointerGestureHold) Dispatch(event *wl.Event) {
498 switch event.Opcode {
499 case 0: // begin
500 serial := event.Uint32()
501 time := event.Uint32()
502 surfaceID := event.Uint32()
503 fingers := event.Uint32()
504
505 for i, handler := range o.handlersForBegin() {
506 _ = i
507 handler(serial, time, surfaceID, fingers)
508 }
509 case 1: // end
510 serial := event.Uint32()
511 time := event.Uint32()
512 cancelled := event.Int32()
513
514 for i, handler := range o.handlersForEnd() {
515 _ = i
516 handler(serial, time, cancelled)
517 }
518 default:
519 }
520}