extimagecopycapture_generated.go RawHistoryFolder
1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: ext_image_copy_capture_v1
3// Source: ext-image-copy-capture-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2021-2023 Andri Yngvason
7// Copyright © 2024 Simon Ser
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 extimagecopycapture
29
30import (
31 "sync"
32
33 cross_ext_image_capture_source_v1 "github.com/bnema/go-wayland-bindings/client/extimagecapturesource"
34 cross_wl_buffer "github.com/bnema/go-wayland-bindings/client/wayland"
35 cross_wl_pointer "github.com/bnema/go-wayland-bindings/client/wayland"
36 "github.com/bnema/wlturbo/wl"
37)
38
39// ERROR_INVALID_OPTION is the error invalid_option value.
40const ERROR_INVALID_OPTION = 1
41
42// OPTIONS_PAINT_CURSORS is the options paint_cursors value.
43const OPTIONS_PAINT_CURSORS = 1
44
45// ERROR_DUPLICATE_FRAME is the error duplicate_frame value.
46const ERROR_DUPLICATE_FRAME = 1
47
48// ERROR_NO_BUFFER is the error no_buffer value.
49const ERROR_NO_BUFFER = 1
50
51// ERROR_INVALID_BUFFER_DAMAGE is the error invalid_buffer_damage value.
52const ERROR_INVALID_BUFFER_DAMAGE = 2
53
54// ERROR_ALREADY_CAPTURED is the error already_captured value.
55const ERROR_ALREADY_CAPTURED = 3
56
57// FAILURE_REASON_UNKNOWN is the failure_reason unknown value.
58const FAILURE_REASON_UNKNOWN = 0
59
60// FAILURE_REASON_BUFFER_CONSTRAINTS is the failure_reason buffer_constraints value.
61const FAILURE_REASON_BUFFER_CONSTRAINTS = 1
62
63// FAILURE_REASON_STOPPED is the failure_reason stopped value.
64const FAILURE_REASON_STOPPED = 2
65
66// ERROR_DUPLICATE_SESSION is the error duplicate_session value.
67const ERROR_DUPLICATE_SESSION = 1
68
69// ExtImageCopyCaptureManagerInterface is the protocol interface name.
70const ExtImageCopyCaptureManagerInterface = "ext_image_copy_capture_manager_v1"
71
72// ExtImageCopyCaptureManager is the generated binding for ext_image_copy_capture_manager_v1 version 1.
73type ExtImageCopyCaptureManager struct {
74 wl.BaseProxy
75}
76
77// NewExtImageCopyCaptureManager returns an unbound ExtImageCopyCaptureManager.
78func NewExtImageCopyCaptureManager(ctx *wl.Context) *ExtImageCopyCaptureManager {
79 obj := &ExtImageCopyCaptureManager{}
80 obj.SetContext(ctx)
81 ctx.Register(obj)
82 return obj
83}
84
85// Create a capturing session for an image capture source. If the paint_cursors option is set, cursors shall be composited onto the captured frame. The cursor must not be composited onto the frame if this flag is not set. If the options bitfield is invalid, the invalid_option protocol error is sent.
86func (o *ExtImageCopyCaptureManager) CreateSession(source *cross_ext_image_capture_source_v1.ExtImageCaptureSource, options uint32) (*ExtImageCopyCaptureSession, error) {
87 var arg1 wl.Object
88 if source != nil {
89 arg1 = source
90 }
91 child := &ExtImageCopyCaptureSession{}
92 child.SetContext(o.Context())
93 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_image_copy_capture_manager_v1.create_session", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1), wl.ArgUint(options)); err != nil {
94 return nil, err
95 }
96 return child, nil
97}
98
99// Create a cursor capturing session for the pointer of an image capture source.
100func (o *ExtImageCopyCaptureManager) CreatePointerCursorSession(source *cross_ext_image_capture_source_v1.ExtImageCaptureSource, pointer *cross_wl_pointer.Pointer) (*ExtImageCopyCaptureCursorSession, error) {
101 var arg1 wl.Object
102 if source != nil {
103 arg1 = source
104 }
105 var arg2 wl.Object
106 if pointer != nil {
107 arg2 = pointer
108 }
109 child := &ExtImageCopyCaptureCursorSession{}
110 child.SetContext(o.Context())
111 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_image_copy_capture_manager_v1.create_pointer_cursor_session", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1), wl.ArgObject(arg2)); err != nil {
112 return nil, err
113 }
114 return child, nil
115}
116
117// Destroy the manager object. Other objects created via this interface are unaffected.
118func (o *ExtImageCopyCaptureManager) Destroy() error {
119 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "ext_image_copy_capture_manager_v1.destroy", Destructor: true}); err != nil {
120 return err
121 }
122 return nil
123}
124
125// EventSignature returns the declared event argument types in wire order.
126func (o *ExtImageCopyCaptureManager) EventSignature(opcode uint16) (string, bool) {
127 switch opcode {
128 default:
129 return "", false
130 }
131}
132
133// Dispatch decodes one event on ext_image_copy_capture_manager_v1 and calls the registered handlers.
134func (o *ExtImageCopyCaptureManager) Dispatch(event *wl.Event) {
135 switch event.Opcode {
136 default:
137 }
138}
139
140// ExtImageCopyCaptureSessionInterface is the protocol interface name.
141const ExtImageCopyCaptureSessionInterface = "ext_image_copy_capture_session_v1"
142
143// ExtImageCopyCaptureSession is the generated binding for ext_image_copy_capture_session_v1 version 1.
144type ExtImageCopyCaptureSession struct {
145 wl.BaseProxy
146 // handlersMu guards the handler slices: a client may register or replace
147 // handlers while another goroutine dispatches events.
148 handlersMu sync.Mutex
149 onBufferSize []func(width uint32, height uint32)
150 onShmFormat []func(format uint32)
151 onDmabufDevice []func(device []byte)
152 onDmabufFormat []func(format uint32, modifiers []byte)
153 onDone []func()
154 onStopped []func()
155}
156
157// NewExtImageCopyCaptureSession returns an unbound ExtImageCopyCaptureSession.
158func NewExtImageCopyCaptureSession(ctx *wl.Context) *ExtImageCopyCaptureSession {
159 obj := &ExtImageCopyCaptureSession{}
160 obj.SetContext(ctx)
161 ctx.Register(obj)
162 return obj
163}
164
165// Create a capture frame for this session. At most one frame object can exist for a given session at any time. If a client sends a create_frame request before a previous frame object has been destroyed, the duplicate_frame protocol error is raised.
166func (o *ExtImageCopyCaptureSession) CreateFrame() (*ExtImageCopyCaptureFrame, error) {
167 child := &ExtImageCopyCaptureFrame{}
168 child.SetContext(o.Context())
169 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_image_copy_capture_session_v1.create_frame", Child: child}, wl.ArgObject(child)); err != nil {
170 return nil, err
171 }
172 return child, nil
173}
174
175// Destroys the session. This request can be sent at any time by the client. This request doesn't affect ext_image_copy_capture_frame_v1 objects created by this object.
176func (o *ExtImageCopyCaptureSession) Destroy() error {
177 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_image_copy_capture_session_v1.destroy", Destructor: true}); err != nil {
178 return err
179 }
180 return nil
181}
182
183// OnBufferSize registers a handler for the buffer_size event.
184//
185// Handlers are appended, so a second call adds another handler rather than
186// replacing the first. Registration is safe while another goroutine dispatches.
187func (o *ExtImageCopyCaptureSession) OnBufferSize(handler func(width uint32, height uint32)) {
188 if handler == nil {
189 return
190 }
191 o.handlersMu.Lock()
192 defer o.handlersMu.Unlock()
193 o.onBufferSize = append(o.onBufferSize, handler)
194}
195
196// handlersForBufferSize returns the handlers registered for buffer_size, taken
197// under the lock so a handler may register another handler while events are
198// being dispatched.
199func (o *ExtImageCopyCaptureSession) handlersForBufferSize() []func(width uint32, height uint32) {
200 o.handlersMu.Lock()
201 defer o.handlersMu.Unlock()
202 return o.onBufferSize
203}
204
205// OnShmFormat registers a handler for the shm_format event.
206//
207// Handlers are appended, so a second call adds another handler rather than
208// replacing the first. Registration is safe while another goroutine dispatches.
209func (o *ExtImageCopyCaptureSession) OnShmFormat(handler func(format uint32)) {
210 if handler == nil {
211 return
212 }
213 o.handlersMu.Lock()
214 defer o.handlersMu.Unlock()
215 o.onShmFormat = append(o.onShmFormat, handler)
216}
217
218// handlersForShmFormat returns the handlers registered for shm_format, taken
219// under the lock so a handler may register another handler while events are
220// being dispatched.
221func (o *ExtImageCopyCaptureSession) handlersForShmFormat() []func(format uint32) {
222 o.handlersMu.Lock()
223 defer o.handlersMu.Unlock()
224 return o.onShmFormat
225}
226
227// OnDmabufDevice registers a handler for the dmabuf_device event.
228//
229// Handlers are appended, so a second call adds another handler rather than
230// replacing the first. Registration is safe while another goroutine dispatches.
231func (o *ExtImageCopyCaptureSession) OnDmabufDevice(handler func(device []byte)) {
232 if handler == nil {
233 return
234 }
235 o.handlersMu.Lock()
236 defer o.handlersMu.Unlock()
237 o.onDmabufDevice = append(o.onDmabufDevice, handler)
238}
239
240// handlersForDmabufDevice returns the handlers registered for dmabuf_device, taken
241// under the lock so a handler may register another handler while events are
242// being dispatched.
243func (o *ExtImageCopyCaptureSession) handlersForDmabufDevice() []func(device []byte) {
244 o.handlersMu.Lock()
245 defer o.handlersMu.Unlock()
246 return o.onDmabufDevice
247}
248
249// OnDmabufFormat registers a handler for the dmabuf_format event.
250//
251// Handlers are appended, so a second call adds another handler rather than
252// replacing the first. Registration is safe while another goroutine dispatches.
253func (o *ExtImageCopyCaptureSession) OnDmabufFormat(handler func(format uint32, modifiers []byte)) {
254 if handler == nil {
255 return
256 }
257 o.handlersMu.Lock()
258 defer o.handlersMu.Unlock()
259 o.onDmabufFormat = append(o.onDmabufFormat, handler)
260}
261
262// handlersForDmabufFormat returns the handlers registered for dmabuf_format, taken
263// under the lock so a handler may register another handler while events are
264// being dispatched.
265func (o *ExtImageCopyCaptureSession) handlersForDmabufFormat() []func(format uint32, modifiers []byte) {
266 o.handlersMu.Lock()
267 defer o.handlersMu.Unlock()
268 return o.onDmabufFormat
269}
270
271// OnDone registers a handler for the done event.
272//
273// Handlers are appended, so a second call adds another handler rather than
274// replacing the first. Registration is safe while another goroutine dispatches.
275func (o *ExtImageCopyCaptureSession) OnDone(handler func()) {
276 if handler == nil {
277 return
278 }
279 o.handlersMu.Lock()
280 defer o.handlersMu.Unlock()
281 o.onDone = append(o.onDone, handler)
282}
283
284// handlersForDone returns the handlers registered for done, taken
285// under the lock so a handler may register another handler while events are
286// being dispatched.
287func (o *ExtImageCopyCaptureSession) handlersForDone() []func() {
288 o.handlersMu.Lock()
289 defer o.handlersMu.Unlock()
290 return o.onDone
291}
292
293// OnStopped registers a handler for the stopped event.
294//
295// Handlers are appended, so a second call adds another handler rather than
296// replacing the first. Registration is safe while another goroutine dispatches.
297func (o *ExtImageCopyCaptureSession) OnStopped(handler func()) {
298 if handler == nil {
299 return
300 }
301 o.handlersMu.Lock()
302 defer o.handlersMu.Unlock()
303 o.onStopped = append(o.onStopped, handler)
304}
305
306// handlersForStopped returns the handlers registered for stopped, taken
307// under the lock so a handler may register another handler while events are
308// being dispatched.
309func (o *ExtImageCopyCaptureSession) handlersForStopped() []func() {
310 o.handlersMu.Lock()
311 defer o.handlersMu.Unlock()
312 return o.onStopped
313}
314
315// EventSignature returns the declared event argument types in wire order.
316func (o *ExtImageCopyCaptureSession) EventSignature(opcode uint16) (string, bool) {
317 switch opcode {
318 case 0:
319 return "uint,uint,", true
320 case 1:
321 return "uint,", true
322 case 2:
323 return "array,", true
324 case 3:
325 return "uint,array,", true
326 case 4:
327 return "", true
328 case 5:
329 return "", true
330 default:
331 return "", false
332 }
333}
334
335// Dispatch decodes one event on ext_image_copy_capture_session_v1 and calls the registered handlers.
336func (o *ExtImageCopyCaptureSession) Dispatch(event *wl.Event) {
337 switch event.Opcode {
338 case 0: // buffer_size
339 width := event.Uint32()
340 height := event.Uint32()
341
342 for i, handler := range o.handlersForBufferSize() {
343 _ = i
344 handler(width, height)
345 }
346 case 1: // shm_format
347 format := event.Uint32()
348
349 for i, handler := range o.handlersForShmFormat() {
350 _ = i
351 handler(format)
352 }
353 case 2: // dmabuf_device
354 device := event.Array()
355
356 for i, handler := range o.handlersForDmabufDevice() {
357 _ = i
358 handler(device)
359 }
360 case 3: // dmabuf_format
361 format := event.Uint32()
362 modifiers := event.Array()
363
364 for i, handler := range o.handlersForDmabufFormat() {
365 _ = i
366 handler(format, modifiers)
367 }
368 case 4: // done
369
370 for i, handler := range o.handlersForDone() {
371 _ = i
372 handler()
373 }
374 case 5: // stopped
375
376 for i, handler := range o.handlersForStopped() {
377 _ = i
378 handler()
379 }
380 default:
381 }
382}
383
384// ExtImageCopyCaptureFrameInterface is the protocol interface name.
385const ExtImageCopyCaptureFrameInterface = "ext_image_copy_capture_frame_v1"
386
387// ExtImageCopyCaptureFrame is the generated binding for ext_image_copy_capture_frame_v1 version 1.
388type ExtImageCopyCaptureFrame struct {
389 wl.BaseProxy
390 // handlersMu guards the handler slices: a client may register or replace
391 // handlers while another goroutine dispatches events.
392 handlersMu sync.Mutex
393 onTransform []func(transform uint32)
394 onDamage []func(x int32, y int32, width int32, height int32)
395 onPresentationTime []func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32)
396 onReady []func()
397 onFailed []func(reason uint32)
398}
399
400// NewExtImageCopyCaptureFrame returns an unbound ExtImageCopyCaptureFrame.
401func NewExtImageCopyCaptureFrame(ctx *wl.Context) *ExtImageCopyCaptureFrame {
402 obj := &ExtImageCopyCaptureFrame{}
403 obj.SetContext(ctx)
404 ctx.Register(obj)
405 return obj
406}
407
408// Destroys the frame. This request can be sent at any time by the client.
409func (o *ExtImageCopyCaptureFrame) Destroy() error {
410 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_image_copy_capture_frame_v1.destroy", Destructor: true}); err != nil {
411 return err
412 }
413 return nil
414}
415
416// Attach a buffer to the session. The wl_buffer.release request is unused. The new buffer replaces any previously attached buffer. This request must not be sent after capture, or else the already_captured protocol error is raised.
417func (o *ExtImageCopyCaptureFrame) AttachBuffer(buffer *cross_wl_buffer.Buffer) error {
418 var arg0 wl.Object
419 if buffer != nil {
420 arg0 = buffer
421 }
422 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_image_copy_capture_frame_v1.attach_buffer"}, wl.ArgObject(arg0)); err != nil {
423 return err
424 }
425 return nil
426}
427
428// Apply damage to the buffer which is to be captured next. This request may be sent multiple times to describe a region. The client indicates the accumulated damage since this wl_buffer was last captured. During capture, the compositor will update the buffer with at least the union of the region passed by the client and the region advertised by ext_image_copy_capture_frame_v1.damage. When a wl_buffer is captured for the first time, or when the client doesn't track damage, the client must damage the whole buffer. This is for optimisation purposes. The compositor may use this information to reduce copying. These coordinates originate from the upper left corner of the buffer. If x or y are strictly negative, or if width or height are negative or zero, the invalid_buffer_damage protocol error is raised. This request must not be sent after capture, or else the already_captured protocol error is raised.
429func (o *ExtImageCopyCaptureFrame) DamageBuffer(x int32, y int32, width int32, height int32) error {
430 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "ext_image_copy_capture_frame_v1.damage_buffer"}, wl.ArgInt(x), wl.ArgInt(y), wl.ArgInt(width), wl.ArgInt(height)); err != nil {
431 return err
432 }
433 return nil
434}
435
436// Capture a frame. Unless this is the first successful captured frame performed in this session, the compositor may wait an indefinite amount of time for the source content to change before performing the copy. This request may only be sent once, or else the already_captured protocol error is raised. A buffer must be attached before this request is sent, or else the no_buffer protocol error is raised.
437func (o *ExtImageCopyCaptureFrame) Capture() error {
438 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "ext_image_copy_capture_frame_v1.capture"}); err != nil {
439 return err
440 }
441 return nil
442}
443
444// OnTransform registers a handler for the transform event.
445//
446// Handlers are appended, so a second call adds another handler rather than
447// replacing the first. Registration is safe while another goroutine dispatches.
448func (o *ExtImageCopyCaptureFrame) OnTransform(handler func(transform uint32)) {
449 if handler == nil {
450 return
451 }
452 o.handlersMu.Lock()
453 defer o.handlersMu.Unlock()
454 o.onTransform = append(o.onTransform, handler)
455}
456
457// handlersForTransform returns the handlers registered for transform, taken
458// under the lock so a handler may register another handler while events are
459// being dispatched.
460func (o *ExtImageCopyCaptureFrame) handlersForTransform() []func(transform uint32) {
461 o.handlersMu.Lock()
462 defer o.handlersMu.Unlock()
463 return o.onTransform
464}
465
466// OnDamage registers a handler for the damage event.
467//
468// Handlers are appended, so a second call adds another handler rather than
469// replacing the first. Registration is safe while another goroutine dispatches.
470func (o *ExtImageCopyCaptureFrame) OnDamage(handler func(x int32, y int32, width int32, height int32)) {
471 if handler == nil {
472 return
473 }
474 o.handlersMu.Lock()
475 defer o.handlersMu.Unlock()
476 o.onDamage = append(o.onDamage, handler)
477}
478
479// handlersForDamage returns the handlers registered for damage, taken
480// under the lock so a handler may register another handler while events are
481// being dispatched.
482func (o *ExtImageCopyCaptureFrame) handlersForDamage() []func(x int32, y int32, width int32, height int32) {
483 o.handlersMu.Lock()
484 defer o.handlersMu.Unlock()
485 return o.onDamage
486}
487
488// OnPresentationTime registers a handler for the presentation_time event.
489//
490// Handlers are appended, so a second call adds another handler rather than
491// replacing the first. Registration is safe while another goroutine dispatches.
492func (o *ExtImageCopyCaptureFrame) OnPresentationTime(handler func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32)) {
493 if handler == nil {
494 return
495 }
496 o.handlersMu.Lock()
497 defer o.handlersMu.Unlock()
498 o.onPresentationTime = append(o.onPresentationTime, handler)
499}
500
501// handlersForPresentationTime returns the handlers registered for presentation_time, taken
502// under the lock so a handler may register another handler while events are
503// being dispatched.
504func (o *ExtImageCopyCaptureFrame) handlersForPresentationTime() []func(tvSecHi uint32, tvSecLo uint32, tvNsec uint32) {
505 o.handlersMu.Lock()
506 defer o.handlersMu.Unlock()
507 return o.onPresentationTime
508}
509
510// OnReady registers a handler for the ready event.
511//
512// Handlers are appended, so a second call adds another handler rather than
513// replacing the first. Registration is safe while another goroutine dispatches.
514func (o *ExtImageCopyCaptureFrame) OnReady(handler func()) {
515 if handler == nil {
516 return
517 }
518 o.handlersMu.Lock()
519 defer o.handlersMu.Unlock()
520 o.onReady = append(o.onReady, handler)
521}
522
523// handlersForReady returns the handlers registered for ready, taken
524// under the lock so a handler may register another handler while events are
525// being dispatched.
526func (o *ExtImageCopyCaptureFrame) handlersForReady() []func() {
527 o.handlersMu.Lock()
528 defer o.handlersMu.Unlock()
529 return o.onReady
530}
531
532// OnFailed registers a handler for the failed event.
533//
534// Handlers are appended, so a second call adds another handler rather than
535// replacing the first. Registration is safe while another goroutine dispatches.
536func (o *ExtImageCopyCaptureFrame) OnFailed(handler func(reason uint32)) {
537 if handler == nil {
538 return
539 }
540 o.handlersMu.Lock()
541 defer o.handlersMu.Unlock()
542 o.onFailed = append(o.onFailed, handler)
543}
544
545// handlersForFailed returns the handlers registered for failed, taken
546// under the lock so a handler may register another handler while events are
547// being dispatched.
548func (o *ExtImageCopyCaptureFrame) handlersForFailed() []func(reason uint32) {
549 o.handlersMu.Lock()
550 defer o.handlersMu.Unlock()
551 return o.onFailed
552}
553
554// EventSignature returns the declared event argument types in wire order.
555func (o *ExtImageCopyCaptureFrame) EventSignature(opcode uint16) (string, bool) {
556 switch opcode {
557 case 0:
558 return "uint,", true
559 case 1:
560 return "int,int,int,int,", true
561 case 2:
562 return "uint,uint,uint,", true
563 case 3:
564 return "", true
565 case 4:
566 return "uint,", true
567 default:
568 return "", false
569 }
570}
571
572// Dispatch decodes one event on ext_image_copy_capture_frame_v1 and calls the registered handlers.
573func (o *ExtImageCopyCaptureFrame) Dispatch(event *wl.Event) {
574 switch event.Opcode {
575 case 0: // transform
576 transform := event.Uint32()
577
578 for i, handler := range o.handlersForTransform() {
579 _ = i
580 handler(transform)
581 }
582 case 1: // damage
583 x := event.Int32()
584 y := event.Int32()
585 width := event.Int32()
586 height := event.Int32()
587
588 for i, handler := range o.handlersForDamage() {
589 _ = i
590 handler(x, y, width, height)
591 }
592 case 2: // presentation_time
593 tvSecHi := event.Uint32()
594 tvSecLo := event.Uint32()
595 tvNsec := event.Uint32()
596
597 for i, handler := range o.handlersForPresentationTime() {
598 _ = i
599 handler(tvSecHi, tvSecLo, tvNsec)
600 }
601 case 3: // ready
602
603 for i, handler := range o.handlersForReady() {
604 _ = i
605 handler()
606 }
607 case 4: // failed
608 reason := event.Uint32()
609
610 for i, handler := range o.handlersForFailed() {
611 _ = i
612 handler(reason)
613 }
614 default:
615 }
616}
617
618// ExtImageCopyCaptureCursorSessionInterface is the protocol interface name.
619const ExtImageCopyCaptureCursorSessionInterface = "ext_image_copy_capture_cursor_session_v1"
620
621// ExtImageCopyCaptureCursorSession is the generated binding for ext_image_copy_capture_cursor_session_v1 version 1.
622type ExtImageCopyCaptureCursorSession struct {
623 wl.BaseProxy
624 // handlersMu guards the handler slices: a client may register or replace
625 // handlers while another goroutine dispatches events.
626 handlersMu sync.Mutex
627 onEnter []func()
628 onLeave []func()
629 onPosition []func(x int32, y int32)
630 onHotspot []func(x int32, y int32)
631}
632
633// NewExtImageCopyCaptureCursorSession returns an unbound ExtImageCopyCaptureCursorSession.
634func NewExtImageCopyCaptureCursorSession(ctx *wl.Context) *ExtImageCopyCaptureCursorSession {
635 obj := &ExtImageCopyCaptureCursorSession{}
636 obj.SetContext(ctx)
637 ctx.Register(obj)
638 return obj
639}
640
641// Destroys the session. This request can be sent at any time by the client. This request doesn't affect ext_image_copy_capture_frame_v1 objects created by this object.
642func (o *ExtImageCopyCaptureCursorSession) Destroy() error {
643 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "ext_image_copy_capture_cursor_session_v1.destroy", Destructor: true}); err != nil {
644 return err
645 }
646 return nil
647}
648
649// Gets the image copy capture session for this cursor session. The session will produce frames of the cursor image. The compositor may pause the session when the cursor leaves the captured area. This request must not be sent more than once, or else the duplicate_session protocol error is raised.
650func (o *ExtImageCopyCaptureCursorSession) GetCaptureSession() (*ExtImageCopyCaptureSession, error) {
651 child := &ExtImageCopyCaptureSession{}
652 child.SetContext(o.Context())
653 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "ext_image_copy_capture_cursor_session_v1.get_capture_session", Child: child}, wl.ArgObject(child)); err != nil {
654 return nil, err
655 }
656 return child, nil
657}
658
659// OnEnter registers a handler for the enter event.
660//
661// Handlers are appended, so a second call adds another handler rather than
662// replacing the first. Registration is safe while another goroutine dispatches.
663func (o *ExtImageCopyCaptureCursorSession) OnEnter(handler func()) {
664 if handler == nil {
665 return
666 }
667 o.handlersMu.Lock()
668 defer o.handlersMu.Unlock()
669 o.onEnter = append(o.onEnter, handler)
670}
671
672// handlersForEnter returns the handlers registered for enter, taken
673// under the lock so a handler may register another handler while events are
674// being dispatched.
675func (o *ExtImageCopyCaptureCursorSession) handlersForEnter() []func() {
676 o.handlersMu.Lock()
677 defer o.handlersMu.Unlock()
678 return o.onEnter
679}
680
681// OnLeave registers a handler for the leave event.
682//
683// Handlers are appended, so a second call adds another handler rather than
684// replacing the first. Registration is safe while another goroutine dispatches.
685func (o *ExtImageCopyCaptureCursorSession) OnLeave(handler func()) {
686 if handler == nil {
687 return
688 }
689 o.handlersMu.Lock()
690 defer o.handlersMu.Unlock()
691 o.onLeave = append(o.onLeave, handler)
692}
693
694// handlersForLeave returns the handlers registered for leave, taken
695// under the lock so a handler may register another handler while events are
696// being dispatched.
697func (o *ExtImageCopyCaptureCursorSession) handlersForLeave() []func() {
698 o.handlersMu.Lock()
699 defer o.handlersMu.Unlock()
700 return o.onLeave
701}
702
703// OnPosition registers a handler for the position event.
704//
705// Handlers are appended, so a second call adds another handler rather than
706// replacing the first. Registration is safe while another goroutine dispatches.
707func (o *ExtImageCopyCaptureCursorSession) OnPosition(handler func(x int32, y int32)) {
708 if handler == nil {
709 return
710 }
711 o.handlersMu.Lock()
712 defer o.handlersMu.Unlock()
713 o.onPosition = append(o.onPosition, handler)
714}
715
716// handlersForPosition returns the handlers registered for position, taken
717// under the lock so a handler may register another handler while events are
718// being dispatched.
719func (o *ExtImageCopyCaptureCursorSession) handlersForPosition() []func(x int32, y int32) {
720 o.handlersMu.Lock()
721 defer o.handlersMu.Unlock()
722 return o.onPosition
723}
724
725// OnHotspot registers a handler for the hotspot event.
726//
727// Handlers are appended, so a second call adds another handler rather than
728// replacing the first. Registration is safe while another goroutine dispatches.
729func (o *ExtImageCopyCaptureCursorSession) OnHotspot(handler func(x int32, y int32)) {
730 if handler == nil {
731 return
732 }
733 o.handlersMu.Lock()
734 defer o.handlersMu.Unlock()
735 o.onHotspot = append(o.onHotspot, handler)
736}
737
738// handlersForHotspot returns the handlers registered for hotspot, taken
739// under the lock so a handler may register another handler while events are
740// being dispatched.
741func (o *ExtImageCopyCaptureCursorSession) handlersForHotspot() []func(x int32, y int32) {
742 o.handlersMu.Lock()
743 defer o.handlersMu.Unlock()
744 return o.onHotspot
745}
746
747// EventSignature returns the declared event argument types in wire order.
748func (o *ExtImageCopyCaptureCursorSession) EventSignature(opcode uint16) (string, bool) {
749 switch opcode {
750 case 0:
751 return "", true
752 case 1:
753 return "", true
754 case 2:
755 return "int,int,", true
756 case 3:
757 return "int,int,", true
758 default:
759 return "", false
760 }
761}
762
763// Dispatch decodes one event on ext_image_copy_capture_cursor_session_v1 and calls the registered handlers.
764func (o *ExtImageCopyCaptureCursorSession) Dispatch(event *wl.Event) {
765 switch event.Opcode {
766 case 0: // enter
767
768 for i, handler := range o.handlersForEnter() {
769 _ = i
770 handler()
771 }
772 case 1: // leave
773
774 for i, handler := range o.handlersForLeave() {
775 _ = i
776 handler()
777 }
778 case 2: // position
779 x := event.Int32()
780 y := event.Int32()
781
782 for i, handler := range o.handlersForPosition() {
783 _ = i
784 handler(x, y)
785 }
786 case 3: // hotspot
787 x := event.Int32()
788 y := event.Int32()
789
790 for i, handler := range o.handlersForHotspot() {
791 _ = i
792 handler(x, y)
793 }
794 default:
795 }
796}