relative-pointer-unstable-v1_generated.go RawHistoryFolder
1// Code generated by wlturbo-scanner. DO NOT EDIT.
2// Protocol: relative_pointer_unstable_v1
3// Source: relative-pointer-unstable-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2014 Jonas Ådahl
7// Copyright © 2015 Red Hat Inc.
8//
9// Permission is hereby granted, free of charge, to any person obtaining a
10// copy of this software and associated documentation files (the "Software"),
11// to deal in the Software without restriction, including without limitation
12// the rights to use, copy, modify, merge, publish, distribute, sublicense,
13// and/or sell copies of the Software, and to permit persons to whom the
14// Software is furnished to do so, subject to the following conditions:
15//
16// The above copyright notice and this permission notice (including the next
17// paragraph) shall be included in all copies or substantial portions of the
18// Software.
19//
20// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26// DEALINGS IN THE SOFTWARE.
27
28package relativepointer
29
30import (
31 "sync"
32
33 cross_wl_pointer "github.com/bnema/wlturbo/protocol/core"
34 "github.com/bnema/wlturbo/wl"
35)
36
37// RelativePointerManagerInterface is the protocol interface name.
38const RelativePointerManagerInterface = "zwp_relative_pointer_manager_v1"
39
40// RelativePointerManager is the generated binding for zwp_relative_pointer_manager_v1 version 1.
41type RelativePointerManager struct {
42 wl.BaseProxy
43}
44
45// NewRelativePointerManager returns an unbound RelativePointerManager.
46func NewRelativePointerManager(ctx *wl.Context) *RelativePointerManager {
47 obj := &RelativePointerManager{}
48 obj.SetContext(ctx)
49 ctx.Register(obj)
50 return obj
51}
52
53// Used by the client to notify the server that it will no longer use this relative pointer manager object.
54func (o *RelativePointerManager) Destroy() error {
55 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_relative_pointer_manager_v1.destroy", Destructor: true}); err != nil {
56 return err
57 }
58 return nil
59}
60
61// Create a relative pointer interface given a wl_pointer object. See the wp_relative_pointer interface for more details.
62func (o *RelativePointerManager) GetRelativePointer(pointer *cross_wl_pointer.Pointer) (*RelativePointer, error) {
63 var arg1 wl.Object
64 if pointer != nil {
65 arg1 = pointer
66 }
67 child := &RelativePointer{}
68 child.SetContext(o.Context())
69 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_relative_pointer_manager_v1.get_relative_pointer", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
70 return nil, err
71 }
72 return child, nil
73}
74
75// EventSignature returns the declared event argument types in wire order.
76func (o *RelativePointerManager) EventSignature(opcode uint16) (string, bool) {
77 switch opcode {
78 default:
79 return "", false
80 }
81}
82
83// Dispatch decodes one event on zwp_relative_pointer_manager_v1 and calls the registered handlers.
84func (o *RelativePointerManager) Dispatch(event *wl.Event) {
85 switch event.Opcode {
86 default:
87 }
88}
89
90// RelativePointerInterface is the protocol interface name.
91const RelativePointerInterface = "zwp_relative_pointer_v1"
92
93// RelativePointer is the generated binding for zwp_relative_pointer_v1 version 1.
94type RelativePointer struct {
95 wl.BaseProxy
96 // handlersMu guards the handler slices: a client may register or replace
97 // handlers while another goroutine dispatches events.
98 handlersMu sync.Mutex
99 onRelativeMotion []func(utimeHi uint32, utimeLo uint32, dx wl.Fixed, dy wl.Fixed, dxUnaccel wl.Fixed, dyUnaccel wl.Fixed)
100}
101
102// NewRelativePointer returns an unbound RelativePointer.
103func NewRelativePointer(ctx *wl.Context) *RelativePointer {
104 obj := &RelativePointer{}
105 obj.SetContext(ctx)
106 ctx.Register(obj)
107 return obj
108}
109
110// release the relative pointer object
111func (o *RelativePointer) Destroy() error {
112 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_relative_pointer_v1.destroy", Destructor: true}); err != nil {
113 return err
114 }
115 return nil
116}
117
118// OnRelativeMotion registers a handler for the relative_motion event.
119//
120// Handlers are appended, so a second call adds another handler rather than
121// replacing the first. Registration is safe while another goroutine dispatches.
122func (o *RelativePointer) OnRelativeMotion(handler func(utimeHi uint32, utimeLo uint32, dx wl.Fixed, dy wl.Fixed, dxUnaccel wl.Fixed, dyUnaccel wl.Fixed)) {
123 if handler == nil {
124 return
125 }
126 o.handlersMu.Lock()
127 defer o.handlersMu.Unlock()
128 o.onRelativeMotion = append(o.onRelativeMotion, handler)
129}
130
131// handlersForRelativeMotion returns the handlers registered for relative_motion, taken
132// under the lock so a handler may register another handler while events are
133// being dispatched.
134func (o *RelativePointer) handlersForRelativeMotion() []func(utimeHi uint32, utimeLo uint32, dx wl.Fixed, dy wl.Fixed, dxUnaccel wl.Fixed, dyUnaccel wl.Fixed) {
135 o.handlersMu.Lock()
136 defer o.handlersMu.Unlock()
137 return o.onRelativeMotion
138}
139
140// EventSignature returns the declared event argument types in wire order.
141func (o *RelativePointer) EventSignature(opcode uint16) (string, bool) {
142 switch opcode {
143 case 0:
144 return "uint,uint,fixed,fixed,fixed,fixed,", true
145 default:
146 return "", false
147 }
148}
149
150// Dispatch decodes one event on zwp_relative_pointer_v1 and calls the registered handlers.
151func (o *RelativePointer) Dispatch(event *wl.Event) {
152 switch event.Opcode {
153 case 0: // relative_motion
154 utimeHi := event.Uint32()
155 utimeLo := event.Uint32()
156 dx := event.Fixed()
157 dy := event.Fixed()
158 dxUnaccel := event.Fixed()
159 dyUnaccel := event.Fixed()
160
161 for i, handler := range o.handlersForRelativeMotion() {
162 _ = i
163 handler(utimeHi, utimeLo, dx, dy, dxUnaccel, dyUnaccel)
164 }
165 default:
166 }
167}