// Code generated by wlbgen. DO NOT EDIT. // Protocol: pointer_gestures_unstable_v1 // Source: pointer-gestures-unstable-v1.xml // Upstream protocol copyright and license: // Copyright © 2015, 2021 Red Hat Inc. // // Permission to use, copy, modify, distribute, and sell this // software and its documentation for any purpose is hereby granted // without fee, provided that the above copyright notice appear in // all copies and that both that copyright notice and this permission // notice appear in supporting documentation, and that the name of // the copyright holders not be used in advertising or publicity // pertaining to distribution of the software without specific, // written prior permission. The copyright holders make no // representations about the suitability of this software for any // purpose. It is provided "as is" without express or implied // warranty. // // THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS // SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND // FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY // SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN // AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, // ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF // THIS SOFTWARE. package pointergestures import ( "sync" cross_wl_pointer "github.com/bnema/go-wayland-bindings/client/wayland" "github.com/bnema/wlturbo/wl" ) // PointerGesturesInterface is the protocol interface name. const PointerGesturesInterface = "zwp_pointer_gestures_v1" // PointerGestures is the generated binding for zwp_pointer_gestures_v1 version 3. type PointerGestures struct { wl.BaseProxy } // NewPointerGestures returns an unbound PointerGestures. func NewPointerGestures(ctx *wl.Context) *PointerGestures { obj := &PointerGestures{} obj.SetContext(ctx) ctx.Register(obj) return obj } // Create a swipe gesture object. See the wl_pointer_gesture_swipe interface for details. func (o *PointerGestures) GetSwipeGesture(pointer *cross_wl_pointer.Pointer) (*PointerGestureSwipe, error) { var arg1 wl.Object if pointer != nil { arg1 = pointer } child := &PointerGestureSwipe{} child.SetContext(o.Context()) 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 { return nil, err } return child, nil } // Create a pinch gesture object. See the wl_pointer_gesture_pinch interface for details. func (o *PointerGestures) GetPinchGesture(pointer *cross_wl_pointer.Pointer) (*PointerGesturePinch, error) { var arg1 wl.Object if pointer != nil { arg1 = pointer } child := &PointerGesturePinch{} child.SetContext(o.Context()) 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 { return nil, err } return child, nil } // Destroy the pointer gesture object. Swipe, pinch and hold objects created via this gesture object remain valid. func (o *PointerGestures) Release() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwp_pointer_gestures_v1.release", Since: 2, Destructor: true}); err != nil { return err } return nil } // Create a hold gesture object. See the wl_pointer_gesture_hold interface for details. func (o *PointerGestures) GetHoldGesture(pointer *cross_wl_pointer.Pointer) (*PointerGestureHold, error) { var arg1 wl.Object if pointer != nil { arg1 = pointer } child := &PointerGestureHold{} child.SetContext(o.Context()) 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 { return nil, err } return child, nil } // EventSignature returns the declared event argument types in wire order. func (o *PointerGestures) EventSignature(opcode uint16) (string, bool) { switch opcode { default: return "", false } } // Dispatch decodes one event on zwp_pointer_gestures_v1 and calls the registered handlers. func (o *PointerGestures) Dispatch(event *wl.Event) { switch event.Opcode { default: } } // PointerGestureSwipeInterface is the protocol interface name. const PointerGestureSwipeInterface = "zwp_pointer_gesture_swipe_v1" // PointerGestureSwipe is the generated binding for zwp_pointer_gesture_swipe_v1 version 3. type PointerGestureSwipe struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onBegin []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) onUpdate []func(time uint32, dx wl.Fixed, dy wl.Fixed) onEnd []func(serial uint32, time uint32, cancelled int32) } // NewPointerGestureSwipe returns an unbound PointerGestureSwipe. func NewPointerGestureSwipe(ctx *wl.Context) *PointerGestureSwipe { obj := &PointerGestureSwipe{} obj.SetContext(ctx) ctx.Register(obj) return obj } // destroy the pointer swipe gesture object func (o *PointerGestureSwipe) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_pointer_gesture_swipe_v1.destroy", Destructor: true}); err != nil { return err } return nil } // OnBegin registers a handler for the begin event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *PointerGestureSwipe) OnBegin(handler func(serial uint32, time uint32, surfaceID uint32, fingers uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onBegin = append(o.onBegin, handler) } // handlersForBegin returns the handlers registered for begin, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *PointerGestureSwipe) handlersForBegin() []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onBegin } // OnUpdate registers a handler for the update event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *PointerGestureSwipe) OnUpdate(handler func(time uint32, dx wl.Fixed, dy wl.Fixed)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onUpdate = append(o.onUpdate, handler) } // handlersForUpdate returns the handlers registered for update, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *PointerGestureSwipe) handlersForUpdate() []func(time uint32, dx wl.Fixed, dy wl.Fixed) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onUpdate } // OnEnd registers a handler for the end event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *PointerGestureSwipe) OnEnd(handler func(serial uint32, time uint32, cancelled int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onEnd = append(o.onEnd, handler) } // handlersForEnd returns the handlers registered for end, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *PointerGestureSwipe) handlersForEnd() []func(serial uint32, time uint32, cancelled int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onEnd } // EventSignature returns the declared event argument types in wire order. func (o *PointerGestureSwipe) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,uint,object,uint,", true case 1: return "uint,fixed,fixed,", true case 2: return "uint,uint,int,", true default: return "", false } } // Dispatch decodes one event on zwp_pointer_gesture_swipe_v1 and calls the registered handlers. func (o *PointerGestureSwipe) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // begin serial := event.Uint32() time := event.Uint32() surfaceID := event.Uint32() fingers := event.Uint32() for i, handler := range o.handlersForBegin() { _ = i handler(serial, time, surfaceID, fingers) } case 1: // update time := event.Uint32() dx := event.Fixed() dy := event.Fixed() for i, handler := range o.handlersForUpdate() { _ = i handler(time, dx, dy) } case 2: // end serial := event.Uint32() time := event.Uint32() cancelled := event.Int32() for i, handler := range o.handlersForEnd() { _ = i handler(serial, time, cancelled) } default: } } // PointerGesturePinchInterface is the protocol interface name. const PointerGesturePinchInterface = "zwp_pointer_gesture_pinch_v1" // PointerGesturePinch is the generated binding for zwp_pointer_gesture_pinch_v1 version 3. type PointerGesturePinch struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onBegin []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) onUpdate []func(time uint32, dx wl.Fixed, dy wl.Fixed, scale wl.Fixed, rotation wl.Fixed) onEnd []func(serial uint32, time uint32, cancelled int32) } // NewPointerGesturePinch returns an unbound PointerGesturePinch. func NewPointerGesturePinch(ctx *wl.Context) *PointerGesturePinch { obj := &PointerGesturePinch{} obj.SetContext(ctx) ctx.Register(obj) return obj } // destroy the pinch gesture object func (o *PointerGesturePinch) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_pointer_gesture_pinch_v1.destroy", Destructor: true}); err != nil { return err } return nil } // OnBegin registers a handler for the begin event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *PointerGesturePinch) OnBegin(handler func(serial uint32, time uint32, surfaceID uint32, fingers uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onBegin = append(o.onBegin, handler) } // handlersForBegin returns the handlers registered for begin, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *PointerGesturePinch) handlersForBegin() []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onBegin } // OnUpdate registers a handler for the update event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *PointerGesturePinch) OnUpdate(handler func(time uint32, dx wl.Fixed, dy wl.Fixed, scale wl.Fixed, rotation wl.Fixed)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onUpdate = append(o.onUpdate, handler) } // handlersForUpdate returns the handlers registered for update, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *PointerGesturePinch) handlersForUpdate() []func(time uint32, dx wl.Fixed, dy wl.Fixed, scale wl.Fixed, rotation wl.Fixed) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onUpdate } // OnEnd registers a handler for the end event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *PointerGesturePinch) OnEnd(handler func(serial uint32, time uint32, cancelled int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onEnd = append(o.onEnd, handler) } // handlersForEnd returns the handlers registered for end, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *PointerGesturePinch) handlersForEnd() []func(serial uint32, time uint32, cancelled int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onEnd } // EventSignature returns the declared event argument types in wire order. func (o *PointerGesturePinch) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,uint,object,uint,", true case 1: return "uint,fixed,fixed,fixed,fixed,", true case 2: return "uint,uint,int,", true default: return "", false } } // Dispatch decodes one event on zwp_pointer_gesture_pinch_v1 and calls the registered handlers. func (o *PointerGesturePinch) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // begin serial := event.Uint32() time := event.Uint32() surfaceID := event.Uint32() fingers := event.Uint32() for i, handler := range o.handlersForBegin() { _ = i handler(serial, time, surfaceID, fingers) } case 1: // update time := event.Uint32() dx := event.Fixed() dy := event.Fixed() scale := event.Fixed() rotation := event.Fixed() for i, handler := range o.handlersForUpdate() { _ = i handler(time, dx, dy, scale, rotation) } case 2: // end serial := event.Uint32() time := event.Uint32() cancelled := event.Int32() for i, handler := range o.handlersForEnd() { _ = i handler(serial, time, cancelled) } default: } } // PointerGestureHoldInterface is the protocol interface name. const PointerGestureHoldInterface = "zwp_pointer_gesture_hold_v1" // PointerGestureHold is the generated binding for zwp_pointer_gesture_hold_v1 version 3. type PointerGestureHold struct { wl.BaseProxy // handlersMu guards the handler slices: a client may register or replace // handlers while another goroutine dispatches events. handlersMu sync.Mutex onBegin []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) onEnd []func(serial uint32, time uint32, cancelled int32) } // NewPointerGestureHold returns an unbound PointerGestureHold. func NewPointerGestureHold(ctx *wl.Context) *PointerGestureHold { obj := &PointerGestureHold{} obj.SetContext(ctx) ctx.Register(obj) return obj } // destroy the hold gesture object func (o *PointerGestureHold) Destroy() error { if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_pointer_gesture_hold_v1.destroy", Since: 3, Destructor: true}); err != nil { return err } return nil } // OnBegin registers a handler for the begin event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *PointerGestureHold) OnBegin(handler func(serial uint32, time uint32, surfaceID uint32, fingers uint32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onBegin = append(o.onBegin, handler) } // handlersForBegin returns the handlers registered for begin, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *PointerGestureHold) handlersForBegin() []func(serial uint32, time uint32, surfaceID uint32, fingers uint32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onBegin } // OnEnd registers a handler for the end event. // // Handlers are appended, so a second call adds another handler rather than // replacing the first. Registration is safe while another goroutine dispatches. func (o *PointerGestureHold) OnEnd(handler func(serial uint32, time uint32, cancelled int32)) { if handler == nil { return } o.handlersMu.Lock() defer o.handlersMu.Unlock() o.onEnd = append(o.onEnd, handler) } // handlersForEnd returns the handlers registered for end, taken // under the lock so a handler may register another handler while events are // being dispatched. func (o *PointerGestureHold) handlersForEnd() []func(serial uint32, time uint32, cancelled int32) { o.handlersMu.Lock() defer o.handlersMu.Unlock() return o.onEnd } // EventSignature returns the declared event argument types in wire order. func (o *PointerGestureHold) EventSignature(opcode uint16) (string, bool) { switch opcode { case 0: return "uint,uint,object,uint,", true case 1: return "uint,uint,int,", true default: return "", false } } // Dispatch decodes one event on zwp_pointer_gesture_hold_v1 and calls the registered handlers. func (o *PointerGestureHold) Dispatch(event *wl.Event) { switch event.Opcode { case 0: // begin serial := event.Uint32() time := event.Uint32() surfaceID := event.Uint32() fingers := event.Uint32() for i, handler := range o.handlersForBegin() { _ = i handler(serial, time, surfaceID, fingers) } case 1: // end serial := event.Uint32() time := event.Uint32() cancelled := event.Int32() for i, handler := range o.handlersForEnd() { _ = i handler(serial, time, cancelled) } default: } }