1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: pointer_constraints_unstable_v1
3// Source: pointer-constraints-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 pointerconstraints
29
30import (
31 "sync"
32
33 cross_wl_pointer "github.com/bnema/go-wayland-bindings/client/wayland"
34 cross_wl_region "github.com/bnema/go-wayland-bindings/client/wayland"
35 cross_wl_surface "github.com/bnema/go-wayland-bindings/client/wayland"
36 "github.com/bnema/wlturbo/wl"
37)
38
39// ERROR_ALREADY_CONSTRAINED is the error already_constrained value.
40const ERROR_ALREADY_CONSTRAINED = 1
41
42// LIFETIME_ONESHOT is the lifetime oneshot value.
43const LIFETIME_ONESHOT = 1
44
45// LIFETIME_PERSISTENT is the lifetime persistent value.
46const LIFETIME_PERSISTENT = 2
47
48// PointerConstraintsInterface is the protocol interface name.
49const PointerConstraintsInterface = "zwp_pointer_constraints_v1"
50
51// PointerConstraints is the generated binding for zwp_pointer_constraints_v1 version 1.
52type PointerConstraints struct {
53 wl.BaseProxy
54}
55
56// NewPointerConstraints returns an unbound PointerConstraints.
57func NewPointerConstraints(ctx *wl.Context) *PointerConstraints {
58 obj := &PointerConstraints{}
59 obj.SetContext(ctx)
60 ctx.Register(obj)
61 return obj
62}
63
64// Used by the client to notify the server that it will no longer use this pointer constraints object.
65func (o *PointerConstraints) Destroy() error {
66 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_pointer_constraints_v1.destroy", Destructor: true}); err != nil {
67 return err
68 }
69 return nil
70}
71
72// The lock_pointer request lets the client request to disable movements of the virtual pointer (i.e. the cursor), effectively locking the pointer to a position. This request may not take effect immediately; in the future, when the compositor deems implementation-specific constraints are satisfied, the pointer lock will be activated and the compositor sends a locked event. The protocol provides no guarantee that the constraints are ever satisfied, and does not require the compositor to send an error if the constraints cannot ever be satisfied. It is thus possible to request a lock that will never activate. There may not be another pointer constraint of any kind requested or active on the surface for any of the wl_pointer objects of the seat of the passed pointer when requesting a lock. If there is, an error will be raised. See general pointer lock documentation for more details. The intersection of the region passed with this request and the input region of the surface is used to determine where the pointer must be in order for the lock to activate. It is up to the compositor whether to warp the pointer or require some kind of user interaction for the lock to activate. If the region is null the surface input region is used. A surface may receive pointer focus without the lock being activated. The request creates a new object wp_locked_pointer which is used to interact with the lock as well as receive updates about its state. See the the description of wp_locked_pointer for further information. Note that while a pointer is locked, the wl_pointer objects of the corresponding seat will not emit any wl_pointer.motion events, but relative motion events will still be emitted via wp_relative_pointer objects of the same seat. wl_pointer.axis and wl_pointer.button events are unaffected.
73func (o *PointerConstraints) LockPointer(surface *cross_wl_surface.Surface, pointer *cross_wl_pointer.Pointer, region *cross_wl_region.Region, lifetime uint32) (*LockedPointer, error) {
74 var arg1 wl.Object
75 if surface != nil {
76 arg1 = surface
77 }
78 var arg2 wl.Object
79 if pointer != nil {
80 arg2 = pointer
81 }
82 var arg3 wl.Object
83 if region != nil {
84 arg3 = region
85 }
86 child := &LockedPointer{}
87 child.SetContext(o.Context())
88 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_pointer_constraints_v1.lock_pointer", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1), wl.ArgObject(arg2), wl.ArgObject(arg3), wl.ArgUint(lifetime)); err != nil {
89 return nil, err
90 }
91 return child, nil
92}
93
94// The confine_pointer request lets the client request to confine the pointer cursor to a given region. This request may not take effect immediately; in the future, when the compositor deems implementation- specific constraints are satisfied, the pointer confinement will be activated and the compositor sends a confined event. The intersection of the region passed with this request and the input region of the surface is used to determine where the pointer must be in order for the confinement to activate. It is up to the compositor whether to warp the pointer or require some kind of user interaction for the confinement to activate. If the region is null the surface input region is used. The request will create a new object wp_confined_pointer which is used to interact with the confinement as well as receive updates about its state. See the the description of wp_confined_pointer for further information.
95func (o *PointerConstraints) ConfinePointer(surface *cross_wl_surface.Surface, pointer *cross_wl_pointer.Pointer, region *cross_wl_region.Region, lifetime uint32) (*ConfinedPointer, error) {
96 var arg1 wl.Object
97 if surface != nil {
98 arg1 = surface
99 }
100 var arg2 wl.Object
101 if pointer != nil {
102 arg2 = pointer
103 }
104 var arg3 wl.Object
105 if region != nil {
106 arg3 = region
107 }
108 child := &ConfinedPointer{}
109 child.SetContext(o.Context())
110 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwp_pointer_constraints_v1.confine_pointer", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1), wl.ArgObject(arg2), wl.ArgObject(arg3), wl.ArgUint(lifetime)); err != nil {
111 return nil, err
112 }
113 return child, nil
114}
115
116// EventSignature returns the declared event argument types in wire order.
117func (o *PointerConstraints) EventSignature(opcode uint16) (string, bool) {
118 switch opcode {
119 default:
120 return "", false
121 }
122}
123
124// Dispatch decodes one event on zwp_pointer_constraints_v1 and calls the registered handlers.
125func (o *PointerConstraints) Dispatch(event *wl.Event) {
126 switch event.Opcode {
127 default:
128 }
129}
130
131// LockedPointerInterface is the protocol interface name.
132const LockedPointerInterface = "zwp_locked_pointer_v1"
133
134// LockedPointer is the generated binding for zwp_locked_pointer_v1 version 1.
135type LockedPointer struct {
136 wl.BaseProxy
137 // handlersMu guards the handler slices: a client may register or replace
138 // handlers while another goroutine dispatches events.
139 handlersMu sync.Mutex
140 onLocked []func()
141 onUnlocked []func()
142}
143
144// NewLockedPointer returns an unbound LockedPointer.
145func NewLockedPointer(ctx *wl.Context) *LockedPointer {
146 obj := &LockedPointer{}
147 obj.SetContext(ctx)
148 ctx.Register(obj)
149 return obj
150}
151
152// Destroy the locked pointer object. If applicable, the compositor will unlock the pointer.
153func (o *LockedPointer) Destroy() error {
154 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_locked_pointer_v1.destroy", Destructor: true}); err != nil {
155 return err
156 }
157 return nil
158}
159
160// Set the cursor position hint relative to the top left corner of the surface. If the client is drawing its own cursor, it should update the position hint to the position of its own cursor. A compositor may use this information to warp the pointer upon unlock in order to avoid pointer jumps. The cursor position hint is double-buffered state, see wl_surface.commit.
161func (o *LockedPointer) SetCursorPositionHint(surfaceX wl.Fixed, surfaceY wl.Fixed) error {
162 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_locked_pointer_v1.set_cursor_position_hint"}, wl.ArgFixed(surfaceX), wl.ArgFixed(surfaceY)); err != nil {
163 return err
164 }
165 return nil
166}
167
168// Set a new region used to lock the pointer. The new lock region is double-buffered, see wl_surface.commit. For details about the lock region, see wp_locked_pointer.
169func (o *LockedPointer) SetRegion(region *cross_wl_region.Region) error {
170 var arg0 wl.Object
171 if region != nil {
172 arg0 = region
173 }
174 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwp_locked_pointer_v1.set_region"}, wl.ArgObject(arg0)); err != nil {
175 return err
176 }
177 return nil
178}
179
180// OnLocked registers a handler for the locked event.
181//
182// Handlers are appended, so a second call adds another handler rather than
183// replacing the first. Registration is safe while another goroutine dispatches.
184func (o *LockedPointer) OnLocked(handler func()) {
185 if handler == nil {
186 return
187 }
188 o.handlersMu.Lock()
189 defer o.handlersMu.Unlock()
190 o.onLocked = append(o.onLocked, handler)
191}
192
193// handlersForLocked returns the handlers registered for locked, taken
194// under the lock so a handler may register another handler while events are
195// being dispatched.
196func (o *LockedPointer) handlersForLocked() []func() {
197 o.handlersMu.Lock()
198 defer o.handlersMu.Unlock()
199 return o.onLocked
200}
201
202// OnUnlocked registers a handler for the unlocked event.
203//
204// Handlers are appended, so a second call adds another handler rather than
205// replacing the first. Registration is safe while another goroutine dispatches.
206func (o *LockedPointer) OnUnlocked(handler func()) {
207 if handler == nil {
208 return
209 }
210 o.handlersMu.Lock()
211 defer o.handlersMu.Unlock()
212 o.onUnlocked = append(o.onUnlocked, handler)
213}
214
215// handlersForUnlocked returns the handlers registered for unlocked, taken
216// under the lock so a handler may register another handler while events are
217// being dispatched.
218func (o *LockedPointer) handlersForUnlocked() []func() {
219 o.handlersMu.Lock()
220 defer o.handlersMu.Unlock()
221 return o.onUnlocked
222}
223
224// EventSignature returns the declared event argument types in wire order.
225func (o *LockedPointer) EventSignature(opcode uint16) (string, bool) {
226 switch opcode {
227 case 0:
228 return "", true
229 case 1:
230 return "", true
231 default:
232 return "", false
233 }
234}
235
236// Dispatch decodes one event on zwp_locked_pointer_v1 and calls the registered handlers.
237func (o *LockedPointer) Dispatch(event *wl.Event) {
238 switch event.Opcode {
239 case 0: // locked
240
241 for i, handler := range o.handlersForLocked() {
242 _ = i
243 handler()
244 }
245 case 1: // unlocked
246
247 for i, handler := range o.handlersForUnlocked() {
248 _ = i
249 handler()
250 }
251 default:
252 }
253}
254
255// ConfinedPointerInterface is the protocol interface name.
256const ConfinedPointerInterface = "zwp_confined_pointer_v1"
257
258// ConfinedPointer is the generated binding for zwp_confined_pointer_v1 version 1.
259type ConfinedPointer struct {
260 wl.BaseProxy
261 // handlersMu guards the handler slices: a client may register or replace
262 // handlers while another goroutine dispatches events.
263 handlersMu sync.Mutex
264 onConfined []func()
265 onUnconfined []func()
266}
267
268// NewConfinedPointer returns an unbound ConfinedPointer.
269func NewConfinedPointer(ctx *wl.Context) *ConfinedPointer {
270 obj := &ConfinedPointer{}
271 obj.SetContext(ctx)
272 ctx.Register(obj)
273 return obj
274}
275
276// Destroy the confined pointer object. If applicable, the compositor will unconfine the pointer.
277func (o *ConfinedPointer) Destroy() error {
278 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwp_confined_pointer_v1.destroy", Destructor: true}); err != nil {
279 return err
280 }
281 return nil
282}
283
284// Set a new region used to confine the pointer. The new confine region is double-buffered, see wl_surface.commit. If the confinement is active when the new confinement region is applied and the pointer ends up outside of newly applied region, the pointer may warped to a position within the new confinement region. If warped, a wl_pointer.motion event will be emitted, but no wp_relative_pointer.relative_motion event. The compositor may also, instead of using the new region, unconfine the pointer. For details about the confine region, see wp_confined_pointer.
285func (o *ConfinedPointer) SetRegion(region *cross_wl_region.Region) error {
286 var arg0 wl.Object
287 if region != nil {
288 arg0 = region
289 }
290 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwp_confined_pointer_v1.set_region"}, wl.ArgObject(arg0)); err != nil {
291 return err
292 }
293 return nil
294}
295
296// OnConfined registers a handler for the confined event.
297//
298// Handlers are appended, so a second call adds another handler rather than
299// replacing the first. Registration is safe while another goroutine dispatches.
300func (o *ConfinedPointer) OnConfined(handler func()) {
301 if handler == nil {
302 return
303 }
304 o.handlersMu.Lock()
305 defer o.handlersMu.Unlock()
306 o.onConfined = append(o.onConfined, handler)
307}
308
309// handlersForConfined returns the handlers registered for confined, taken
310// under the lock so a handler may register another handler while events are
311// being dispatched.
312func (o *ConfinedPointer) handlersForConfined() []func() {
313 o.handlersMu.Lock()
314 defer o.handlersMu.Unlock()
315 return o.onConfined
316}
317
318// OnUnconfined registers a handler for the unconfined event.
319//
320// Handlers are appended, so a second call adds another handler rather than
321// replacing the first. Registration is safe while another goroutine dispatches.
322func (o *ConfinedPointer) OnUnconfined(handler func()) {
323 if handler == nil {
324 return
325 }
326 o.handlersMu.Lock()
327 defer o.handlersMu.Unlock()
328 o.onUnconfined = append(o.onUnconfined, handler)
329}
330
331// handlersForUnconfined returns the handlers registered for unconfined, taken
332// under the lock so a handler may register another handler while events are
333// being dispatched.
334func (o *ConfinedPointer) handlersForUnconfined() []func() {
335 o.handlersMu.Lock()
336 defer o.handlersMu.Unlock()
337 return o.onUnconfined
338}
339
340// EventSignature returns the declared event argument types in wire order.
341func (o *ConfinedPointer) EventSignature(opcode uint16) (string, bool) {
342 switch opcode {
343 case 0:
344 return "", true
345 case 1:
346 return "", true
347 default:
348 return "", false
349 }
350}
351
352// Dispatch decodes one event on zwp_confined_pointer_v1 and calls the registered handlers.
353func (o *ConfinedPointer) Dispatch(event *wl.Event) {
354 switch event.Opcode {
355 case 0: // confined
356
357 for i, handler := range o.handlersForConfined() {
358 _ = i
359 handler()
360 }
361 case 1: // unconfined
362
363 for i, handler := range o.handlersForUnconfined() {
364 _ = i
365 handler()
366 }
367 default:
368 }
369}