// Generated by go-wayland-scanner // https://github.com/rajveermalviya/go-wayland/cmd/go-wayland-scanner // XML file : protocol/ext-image-copy-capture-v1.xml // // ext_image_copy_capture_v1 Protocol Copyright: // // Copyright © 2021-2023 Andri Yngvason // Copyright © 2024 Simon Ser // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice (including the next // paragraph) shall be included in all copies or substantial portions of the // Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. package proto import "github.com/rajveermalviya/go-wayland/wayland/client" // ExtImageCopyCaptureManager : manager to inform clients and begin capturing // // This object is a manager which offers requests to start capturing from a // source. type ExtImageCopyCaptureManager struct { client.BaseProxy } // NewExtImageCopyCaptureManager : manager to inform clients and begin capturing // // This object is a manager which offers requests to start capturing from a // source. func NewExtImageCopyCaptureManager(ctx *client.Context) *ExtImageCopyCaptureManager { extImageCopyCaptureManagerV1 := &ExtImageCopyCaptureManager{} ctx.Register(extImageCopyCaptureManagerV1) return extImageCopyCaptureManagerV1 } // CreateSession : capture an image capture source // // 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. func (i *ExtImageCopyCaptureManager) CreateSession(source *ExtImageCaptureSource, options uint32) (*ExtImageCopyCaptureSession, error) { session := NewExtImageCopyCaptureSession(i.Context()) const opcode = 0 const _reqBufLen = 8 + 4 + 4 + 4 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 client.PutUint32(_reqBuf[l:l+4], session.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], source.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(options)) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return session, err } // CreatePointerCursorSession : capture the pointer cursor of an image capture source // // Create a cursor capturing session for the pointer of an image capture // source. func (i *ExtImageCopyCaptureManager) CreatePointerCursorSession(source *ExtImageCaptureSource, pointer *client.Pointer) (*ExtImageCopyCaptureCursorSession, error) { session := NewExtImageCopyCaptureCursorSession(i.Context()) const opcode = 1 const _reqBufLen = 8 + 4 + 4 + 4 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 client.PutUint32(_reqBuf[l:l+4], session.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], source.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], pointer.ID()) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return session, err } // Destroy : destroy the manager // // Destroy the manager object. // // Other objects created via this interface are unaffected. func (i *ExtImageCopyCaptureManager) Destroy() error { defer i.Context().Unregister(i) const opcode = 2 const _reqBufLen = 8 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return err } type ExtImageCopyCaptureManagerError uint32 // ExtImageCopyCaptureManagerError : const ( // ExtImageCopyCaptureManagerErrorInvalidOption : invalid option flag ExtImageCopyCaptureManagerErrorInvalidOption ExtImageCopyCaptureManagerError = 1 ) func (e ExtImageCopyCaptureManagerError) Name() string { switch e { case ExtImageCopyCaptureManagerErrorInvalidOption: return "invalid_option" default: return "" } } func (e ExtImageCopyCaptureManagerError) Value() string { switch e { case ExtImageCopyCaptureManagerErrorInvalidOption: return "1" default: return "" } } func (e ExtImageCopyCaptureManagerError) String() string { return e.Name() + "=" + e.Value() } type ExtImageCopyCaptureManagerOptions uint32 // ExtImageCopyCaptureManagerOptions : const ( // ExtImageCopyCaptureManagerOptionsPaintCursors : paint cursors onto captured frames ExtImageCopyCaptureManagerOptionsPaintCursors ExtImageCopyCaptureManagerOptions = 1 ) func (e ExtImageCopyCaptureManagerOptions) Name() string { switch e { case ExtImageCopyCaptureManagerOptionsPaintCursors: return "paint_cursors" default: return "" } } func (e ExtImageCopyCaptureManagerOptions) Value() string { switch e { case ExtImageCopyCaptureManagerOptionsPaintCursors: return "1" default: return "" } } func (e ExtImageCopyCaptureManagerOptions) String() string { return e.Name() + "=" + e.Value() } // ExtImageCopyCaptureSession : image copy capture session // // This object represents an active image copy capture session. // // After a capture session is created, buffer constraint events will be // emitted from the compositor to tell the client which buffer types and // formats are supported for reading from the session. The compositor may // re-send buffer constraint events whenever they change. // // To advertise buffer constraints, the compositor must send in no // particular order: zero or more shm_format and dmabuf_format events, zero // or one dmabuf_device event, and exactly one buffer_size event. Then the // compositor must send a done event. // // When the client has received all the buffer constraints, it can create a // buffer accordingly, attach it to the capture session using the // attach_buffer request, set the buffer damage using the damage_buffer // request and then send the capture request. type ExtImageCopyCaptureSession struct { client.BaseProxy bufferSizeHandler ExtImageCopyCaptureSessionBufferSizeHandlerFunc shmFormatHandler ExtImageCopyCaptureSessionShmFormatHandlerFunc dmabufDeviceHandler ExtImageCopyCaptureSessionDmabufDeviceHandlerFunc dmabufFormatHandler ExtImageCopyCaptureSessionDmabufFormatHandlerFunc doneHandler ExtImageCopyCaptureSessionDoneHandlerFunc stoppedHandler ExtImageCopyCaptureSessionStoppedHandlerFunc } // NewExtImageCopyCaptureSession : image copy capture session // // This object represents an active image copy capture session. // // After a capture session is created, buffer constraint events will be // emitted from the compositor to tell the client which buffer types and // formats are supported for reading from the session. The compositor may // re-send buffer constraint events whenever they change. // // To advertise buffer constraints, the compositor must send in no // particular order: zero or more shm_format and dmabuf_format events, zero // or one dmabuf_device event, and exactly one buffer_size event. Then the // compositor must send a done event. // // When the client has received all the buffer constraints, it can create a // buffer accordingly, attach it to the capture session using the // attach_buffer request, set the buffer damage using the damage_buffer // request and then send the capture request. func NewExtImageCopyCaptureSession(ctx *client.Context) *ExtImageCopyCaptureSession { extImageCopyCaptureSessionV1 := &ExtImageCopyCaptureSession{} ctx.Register(extImageCopyCaptureSessionV1) return extImageCopyCaptureSessionV1 } // CreateFrame : create a frame // // 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. func (i *ExtImageCopyCaptureSession) CreateFrame() (*ExtImageCopyCaptureFrame, error) { frame := NewExtImageCopyCaptureFrame(i.Context()) const opcode = 0 const _reqBufLen = 8 + 4 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 client.PutUint32(_reqBuf[l:l+4], frame.ID()) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return frame, err } // Destroy : delete this object // // 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. func (i *ExtImageCopyCaptureSession) Destroy() error { defer i.Context().Unregister(i) const opcode = 1 const _reqBufLen = 8 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return err } type ExtImageCopyCaptureSessionError uint32 // ExtImageCopyCaptureSessionError : const ( // ExtImageCopyCaptureSessionErrorDuplicateFrame : create_frame sent before destroying previous frame ExtImageCopyCaptureSessionErrorDuplicateFrame ExtImageCopyCaptureSessionError = 1 ) func (e ExtImageCopyCaptureSessionError) Name() string { switch e { case ExtImageCopyCaptureSessionErrorDuplicateFrame: return "duplicate_frame" default: return "" } } func (e ExtImageCopyCaptureSessionError) Value() string { switch e { case ExtImageCopyCaptureSessionErrorDuplicateFrame: return "1" default: return "" } } func (e ExtImageCopyCaptureSessionError) String() string { return e.Name() + "=" + e.Value() } // ExtImageCopyCaptureSessionBufferSizeEvent : image capture source dimensions // // Provides the dimensions of the source image in buffer pixel coordinates. // // The client must attach buffers that match this size. type ExtImageCopyCaptureSessionBufferSizeEvent struct { Width uint32 Height uint32 } type ExtImageCopyCaptureSessionBufferSizeHandlerFunc func(ExtImageCopyCaptureSessionBufferSizeEvent) // SetBufferSizeHandler : sets handler for ExtImageCopyCaptureSessionBufferSizeEvent func (i *ExtImageCopyCaptureSession) SetBufferSizeHandler(f ExtImageCopyCaptureSessionBufferSizeHandlerFunc) { i.bufferSizeHandler = f } // ExtImageCopyCaptureSessionShmFormatEvent : shm buffer format // // Provides the format that must be used for shared-memory buffers. // // This event may be emitted multiple times, in which case the client may // choose any given format. type ExtImageCopyCaptureSessionShmFormatEvent struct { Format uint32 } type ExtImageCopyCaptureSessionShmFormatHandlerFunc func(ExtImageCopyCaptureSessionShmFormatEvent) // SetShmFormatHandler : sets handler for ExtImageCopyCaptureSessionShmFormatEvent func (i *ExtImageCopyCaptureSession) SetShmFormatHandler(f ExtImageCopyCaptureSessionShmFormatHandlerFunc) { i.shmFormatHandler = f } // ExtImageCopyCaptureSessionDmabufDeviceEvent : dma-buf device // // This event advertises the device buffers must be allocated on for // dma-buf buffers. // // In general the device is a DRM node. The DRM node type (primary vs. // render) is unspecified. Clients must not rely on the compositor sending // a particular node type. Clients cannot check two devices for equality // by comparing the dev_t value. type ExtImageCopyCaptureSessionDmabufDeviceEvent struct { Device []byte } type ExtImageCopyCaptureSessionDmabufDeviceHandlerFunc func(ExtImageCopyCaptureSessionDmabufDeviceEvent) // SetDmabufDeviceHandler : sets handler for ExtImageCopyCaptureSessionDmabufDeviceEvent func (i *ExtImageCopyCaptureSession) SetDmabufDeviceHandler(f ExtImageCopyCaptureSessionDmabufDeviceHandlerFunc) { i.dmabufDeviceHandler = f } // ExtImageCopyCaptureSessionDmabufFormatEvent : dma-buf format // // Provides the format that must be used for dma-buf buffers. // // The client may choose any of the modifiers advertised in the array of // 64-bit unsigned integers. // // This event may be emitted multiple times, in which case the client may // choose any given format. type ExtImageCopyCaptureSessionDmabufFormatEvent struct { Format uint32 Modifiers []byte } type ExtImageCopyCaptureSessionDmabufFormatHandlerFunc func(ExtImageCopyCaptureSessionDmabufFormatEvent) // SetDmabufFormatHandler : sets handler for ExtImageCopyCaptureSessionDmabufFormatEvent func (i *ExtImageCopyCaptureSession) SetDmabufFormatHandler(f ExtImageCopyCaptureSessionDmabufFormatHandlerFunc) { i.dmabufFormatHandler = f } // ExtImageCopyCaptureSessionDoneEvent : all constraints have been sent // // This event is sent once when all buffer constraint events have been // sent. // // The compositor must always end a batch of buffer constraint events with // this event, regardless of whether it sends the initial constraints or // an update. type ExtImageCopyCaptureSessionDoneEvent struct{} type ExtImageCopyCaptureSessionDoneHandlerFunc func(ExtImageCopyCaptureSessionDoneEvent) // SetDoneHandler : sets handler for ExtImageCopyCaptureSessionDoneEvent func (i *ExtImageCopyCaptureSession) SetDoneHandler(f ExtImageCopyCaptureSessionDoneHandlerFunc) { i.doneHandler = f } // ExtImageCopyCaptureSessionStoppedEvent : session is no longer available // // This event indicates that the capture session has stopped and is no // longer available. This can happen in a number of cases, e.g. when the // underlying source is destroyed, if the user decides to end the image // capture, or if an unrecoverable runtime error has occurred. // // The client should destroy the session after receiving this event. type ExtImageCopyCaptureSessionStoppedEvent struct{} type ExtImageCopyCaptureSessionStoppedHandlerFunc func(ExtImageCopyCaptureSessionStoppedEvent) // SetStoppedHandler : sets handler for ExtImageCopyCaptureSessionStoppedEvent func (i *ExtImageCopyCaptureSession) SetStoppedHandler(f ExtImageCopyCaptureSessionStoppedHandlerFunc) { i.stoppedHandler = f } func (i *ExtImageCopyCaptureSession) Dispatch(opcode uint32, fd int, data []byte) { switch opcode { case 0: if i.bufferSizeHandler == nil { return } var e ExtImageCopyCaptureSessionBufferSizeEvent l := 0 e.Width = client.Uint32(data[l : l+4]) l += 4 e.Height = client.Uint32(data[l : l+4]) l += 4 i.bufferSizeHandler(e) case 1: if i.shmFormatHandler == nil { return } var e ExtImageCopyCaptureSessionShmFormatEvent l := 0 e.Format = client.Uint32(data[l : l+4]) l += 4 i.shmFormatHandler(e) case 2: if i.dmabufDeviceHandler == nil { return } var e ExtImageCopyCaptureSessionDmabufDeviceEvent l := 0 deviceLen := int(client.Uint32(data[l : l+4])) l += 4 e.Device = make([]byte, deviceLen) copy(e.Device, data[l:l+deviceLen]) l += deviceLen i.dmabufDeviceHandler(e) case 3: if i.dmabufFormatHandler == nil { return } var e ExtImageCopyCaptureSessionDmabufFormatEvent l := 0 e.Format = client.Uint32(data[l : l+4]) l += 4 modifiersLen := int(client.Uint32(data[l : l+4])) l += 4 e.Modifiers = make([]byte, modifiersLen) copy(e.Modifiers, data[l:l+modifiersLen]) l += modifiersLen i.dmabufFormatHandler(e) case 4: if i.doneHandler == nil { return } var e ExtImageCopyCaptureSessionDoneEvent i.doneHandler(e) case 5: if i.stoppedHandler == nil { return } var e ExtImageCopyCaptureSessionStoppedEvent i.stoppedHandler(e) } } // ExtImageCopyCaptureFrame : image capture frame // // This object represents an image capture frame. // // The client should attach a buffer, damage the buffer, and then send a // capture request. // // If the capture is successful, the compositor must send the frame metadata // (transform, damage, presentation_time in any order) followed by the ready // event. // // If the capture fails, the compositor must send the failed event. type ExtImageCopyCaptureFrame struct { client.BaseProxy transformHandler ExtImageCopyCaptureFrameTransformHandlerFunc damageHandler ExtImageCopyCaptureFrameDamageHandlerFunc presentationTimeHandler ExtImageCopyCaptureFramePresentationTimeHandlerFunc readyHandler ExtImageCopyCaptureFrameReadyHandlerFunc failedHandler ExtImageCopyCaptureFrameFailedHandlerFunc } // NewExtImageCopyCaptureFrame : image capture frame // // This object represents an image capture frame. // // The client should attach a buffer, damage the buffer, and then send a // capture request. // // If the capture is successful, the compositor must send the frame metadata // (transform, damage, presentation_time in any order) followed by the ready // event. // // If the capture fails, the compositor must send the failed event. func NewExtImageCopyCaptureFrame(ctx *client.Context) *ExtImageCopyCaptureFrame { extImageCopyCaptureFrameV1 := &ExtImageCopyCaptureFrame{} ctx.Register(extImageCopyCaptureFrameV1) return extImageCopyCaptureFrameV1 } // Destroy : destroy this object // // Destroys the frame. This request can be sent at any time by the // client. func (i *ExtImageCopyCaptureFrame) Destroy() error { defer i.Context().Unregister(i) const opcode = 0 const _reqBufLen = 8 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return err } // AttachBuffer : attach buffer to session // // 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. func (i *ExtImageCopyCaptureFrame) AttachBuffer(buffer *client.Buffer) error { const opcode = 1 const _reqBufLen = 8 + 4 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 client.PutUint32(_reqBuf[l:l+4], buffer.ID()) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return err } // DamageBuffer : damage buffer // // 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. // // x: region x coordinate // y: region y coordinate // width: region width // height: region height func (i *ExtImageCopyCaptureFrame) DamageBuffer(x, y, width, height int32) error { const opcode = 2 const _reqBufLen = 8 + 4 + 4 + 4 + 4 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(x)) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(y)) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(width)) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(height)) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return err } // Capture : capture a frame // // 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. func (i *ExtImageCopyCaptureFrame) Capture() error { const opcode = 3 const _reqBufLen = 8 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return err } type ExtImageCopyCaptureFrameError uint32 // ExtImageCopyCaptureFrameError : const ( // ExtImageCopyCaptureFrameErrorNoBuffer : capture sent without attach_buffer ExtImageCopyCaptureFrameErrorNoBuffer ExtImageCopyCaptureFrameError = 1 // ExtImageCopyCaptureFrameErrorInvalidBufferDamage : invalid buffer damage ExtImageCopyCaptureFrameErrorInvalidBufferDamage ExtImageCopyCaptureFrameError = 2 // ExtImageCopyCaptureFrameErrorAlreadyCaptured : capture request has been sent ExtImageCopyCaptureFrameErrorAlreadyCaptured ExtImageCopyCaptureFrameError = 3 ) func (e ExtImageCopyCaptureFrameError) Name() string { switch e { case ExtImageCopyCaptureFrameErrorNoBuffer: return "no_buffer" case ExtImageCopyCaptureFrameErrorInvalidBufferDamage: return "invalid_buffer_damage" case ExtImageCopyCaptureFrameErrorAlreadyCaptured: return "already_captured" default: return "" } } func (e ExtImageCopyCaptureFrameError) Value() string { switch e { case ExtImageCopyCaptureFrameErrorNoBuffer: return "1" case ExtImageCopyCaptureFrameErrorInvalidBufferDamage: return "2" case ExtImageCopyCaptureFrameErrorAlreadyCaptured: return "3" default: return "" } } func (e ExtImageCopyCaptureFrameError) String() string { return e.Name() + "=" + e.Value() } type ExtImageCopyCaptureFrameFailureReason uint32 // ExtImageCopyCaptureFrameFailureReason : const ( ExtImageCopyCaptureFrameFailureReasonUnknown ExtImageCopyCaptureFrameFailureReason = 0 ExtImageCopyCaptureFrameFailureReasonBufferConstraints ExtImageCopyCaptureFrameFailureReason = 1 ExtImageCopyCaptureFrameFailureReasonStopped ExtImageCopyCaptureFrameFailureReason = 2 ) func (e ExtImageCopyCaptureFrameFailureReason) Name() string { switch e { case ExtImageCopyCaptureFrameFailureReasonUnknown: return "unknown" case ExtImageCopyCaptureFrameFailureReasonBufferConstraints: return "buffer_constraints" case ExtImageCopyCaptureFrameFailureReasonStopped: return "stopped" default: return "" } } func (e ExtImageCopyCaptureFrameFailureReason) Value() string { switch e { case ExtImageCopyCaptureFrameFailureReasonUnknown: return "0" case ExtImageCopyCaptureFrameFailureReasonBufferConstraints: return "1" case ExtImageCopyCaptureFrameFailureReasonStopped: return "2" default: return "" } } func (e ExtImageCopyCaptureFrameFailureReason) String() string { return e.Name() + "=" + e.Value() } // ExtImageCopyCaptureFrameTransformEvent : buffer transform // // This event is sent before the ready event and holds the transform that // the compositor has applied to the buffer contents. type ExtImageCopyCaptureFrameTransformEvent struct { Transform uint32 } type ExtImageCopyCaptureFrameTransformHandlerFunc func(ExtImageCopyCaptureFrameTransformEvent) // SetTransformHandler : sets handler for ExtImageCopyCaptureFrameTransformEvent func (i *ExtImageCopyCaptureFrame) SetTransformHandler(f ExtImageCopyCaptureFrameTransformHandlerFunc) { i.transformHandler = f } // ExtImageCopyCaptureFrameDamageEvent : buffer damaged region // // This event is sent before the ready event. It may be generated multiple // times to describe a region. // // The first captured frame in a session will always carry full damage. // Subsequent frames' damaged regions describe which parts of the buffer // have changed since the last ready event. // // These coordinates originate in the upper left corner of the buffer. type ExtImageCopyCaptureFrameDamageEvent struct { X int32 Y int32 Width int32 Height int32 } type ExtImageCopyCaptureFrameDamageHandlerFunc func(ExtImageCopyCaptureFrameDamageEvent) // SetDamageHandler : sets handler for ExtImageCopyCaptureFrameDamageEvent func (i *ExtImageCopyCaptureFrame) SetDamageHandler(f ExtImageCopyCaptureFrameDamageHandlerFunc) { i.damageHandler = f } // ExtImageCopyCaptureFramePresentationTimeEvent : presentation time of the frame // // This event indicates the time at which the frame is presented to the // output in system monotonic time. This event is sent before the ready // event. // // The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples, // each component being an unsigned 32-bit value. Whole seconds are in // tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo, // and the additional fractional part in tv_nsec as nanoseconds. Hence, // for valid timestamps tv_nsec must be in [0, 999999999]. type ExtImageCopyCaptureFramePresentationTimeEvent struct { TvSecHi uint32 TvSecLo uint32 TvNsec uint32 } type ExtImageCopyCaptureFramePresentationTimeHandlerFunc func(ExtImageCopyCaptureFramePresentationTimeEvent) // SetPresentationTimeHandler : sets handler for ExtImageCopyCaptureFramePresentationTimeEvent func (i *ExtImageCopyCaptureFrame) SetPresentationTimeHandler(f ExtImageCopyCaptureFramePresentationTimeHandlerFunc) { i.presentationTimeHandler = f } // ExtImageCopyCaptureFrameReadyEvent : frame is available for reading // // Called as soon as the frame is copied, indicating it is available // for reading. // // The buffer may be re-used by the client after this event. // // After receiving this event, the client must destroy the object. type ExtImageCopyCaptureFrameReadyEvent struct{} type ExtImageCopyCaptureFrameReadyHandlerFunc func(ExtImageCopyCaptureFrameReadyEvent) // SetReadyHandler : sets handler for ExtImageCopyCaptureFrameReadyEvent func (i *ExtImageCopyCaptureFrame) SetReadyHandler(f ExtImageCopyCaptureFrameReadyHandlerFunc) { i.readyHandler = f } // ExtImageCopyCaptureFrameFailedEvent : capture failed // // This event indicates that the attempted frame copy has failed. // // After receiving this event, the client must destroy the object. type ExtImageCopyCaptureFrameFailedEvent struct { Reason uint32 } type ExtImageCopyCaptureFrameFailedHandlerFunc func(ExtImageCopyCaptureFrameFailedEvent) // SetFailedHandler : sets handler for ExtImageCopyCaptureFrameFailedEvent func (i *ExtImageCopyCaptureFrame) SetFailedHandler(f ExtImageCopyCaptureFrameFailedHandlerFunc) { i.failedHandler = f } func (i *ExtImageCopyCaptureFrame) Dispatch(opcode uint32, fd int, data []byte) { switch opcode { case 0: if i.transformHandler == nil { return } var e ExtImageCopyCaptureFrameTransformEvent l := 0 e.Transform = client.Uint32(data[l : l+4]) l += 4 i.transformHandler(e) case 1: if i.damageHandler == nil { return } var e ExtImageCopyCaptureFrameDamageEvent l := 0 e.X = int32(client.Uint32(data[l : l+4])) l += 4 e.Y = int32(client.Uint32(data[l : l+4])) l += 4 e.Width = int32(client.Uint32(data[l : l+4])) l += 4 e.Height = int32(client.Uint32(data[l : l+4])) l += 4 i.damageHandler(e) case 2: if i.presentationTimeHandler == nil { return } var e ExtImageCopyCaptureFramePresentationTimeEvent l := 0 e.TvSecHi = client.Uint32(data[l : l+4]) l += 4 e.TvSecLo = client.Uint32(data[l : l+4]) l += 4 e.TvNsec = client.Uint32(data[l : l+4]) l += 4 i.presentationTimeHandler(e) case 3: if i.readyHandler == nil { return } var e ExtImageCopyCaptureFrameReadyEvent i.readyHandler(e) case 4: if i.failedHandler == nil { return } var e ExtImageCopyCaptureFrameFailedEvent l := 0 e.Reason = client.Uint32(data[l : l+4]) l += 4 i.failedHandler(e) } } // ExtImageCopyCaptureCursorSession : cursor capture session // // This object represents a cursor capture session. It extends the base // capture session with cursor-specific metadata. type ExtImageCopyCaptureCursorSession struct { client.BaseProxy enterHandler ExtImageCopyCaptureCursorSessionEnterHandlerFunc leaveHandler ExtImageCopyCaptureCursorSessionLeaveHandlerFunc positionHandler ExtImageCopyCaptureCursorSessionPositionHandlerFunc hotspotHandler ExtImageCopyCaptureCursorSessionHotspotHandlerFunc } // NewExtImageCopyCaptureCursorSession : cursor capture session // // This object represents a cursor capture session. It extends the base // capture session with cursor-specific metadata. func NewExtImageCopyCaptureCursorSession(ctx *client.Context) *ExtImageCopyCaptureCursorSession { extImageCopyCaptureCursorSessionV1 := &ExtImageCopyCaptureCursorSession{} ctx.Register(extImageCopyCaptureCursorSessionV1) return extImageCopyCaptureCursorSessionV1 } // Destroy : delete this object // // 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. func (i *ExtImageCopyCaptureCursorSession) Destroy() error { defer i.Context().Unregister(i) const opcode = 0 const _reqBufLen = 8 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return err } // GetCaptureSession : get image copy capturer session // // 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. func (i *ExtImageCopyCaptureCursorSession) GetCaptureSession() (*ExtImageCopyCaptureSession, error) { session := NewExtImageCopyCaptureSession(i.Context()) const opcode = 1 const _reqBufLen = 8 + 4 var _reqBuf [_reqBufLen]byte l := 0 client.PutUint32(_reqBuf[l:4], i.ID()) l += 4 client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff)) l += 4 client.PutUint32(_reqBuf[l:l+4], session.ID()) l += 4 err := i.Context().WriteMsg(_reqBuf[:], nil) return session, err } type ExtImageCopyCaptureCursorSessionError uint32 // ExtImageCopyCaptureCursorSessionError : const ( // ExtImageCopyCaptureCursorSessionErrorDuplicateSession : get_capture_session sent twice ExtImageCopyCaptureCursorSessionErrorDuplicateSession ExtImageCopyCaptureCursorSessionError = 1 ) func (e ExtImageCopyCaptureCursorSessionError) Name() string { switch e { case ExtImageCopyCaptureCursorSessionErrorDuplicateSession: return "duplicate_session" default: return "" } } func (e ExtImageCopyCaptureCursorSessionError) Value() string { switch e { case ExtImageCopyCaptureCursorSessionErrorDuplicateSession: return "1" default: return "" } } func (e ExtImageCopyCaptureCursorSessionError) String() string { return e.Name() + "=" + e.Value() } // ExtImageCopyCaptureCursorSessionEnterEvent : cursor entered captured area // // Sent when a cursor enters the captured area. It shall be generated // before the "position" and "hotspot" events when and only when a cursor // enters the area. // // The cursor enters the captured area when the cursor image intersects // with the captured area. Note, this is different from e.g. // wl_pointer.enter. type ExtImageCopyCaptureCursorSessionEnterEvent struct{} type ExtImageCopyCaptureCursorSessionEnterHandlerFunc func(ExtImageCopyCaptureCursorSessionEnterEvent) // SetEnterHandler : sets handler for ExtImageCopyCaptureCursorSessionEnterEvent func (i *ExtImageCopyCaptureCursorSession) SetEnterHandler(f ExtImageCopyCaptureCursorSessionEnterHandlerFunc) { i.enterHandler = f } // ExtImageCopyCaptureCursorSessionLeaveEvent : cursor left captured area // // Sent when a cursor leaves the captured area. No "position" or "hotspot" // event is generated for the cursor until the cursor enters the captured // area again. type ExtImageCopyCaptureCursorSessionLeaveEvent struct{} type ExtImageCopyCaptureCursorSessionLeaveHandlerFunc func(ExtImageCopyCaptureCursorSessionLeaveEvent) // SetLeaveHandler : sets handler for ExtImageCopyCaptureCursorSessionLeaveEvent func (i *ExtImageCopyCaptureCursorSession) SetLeaveHandler(f ExtImageCopyCaptureCursorSessionLeaveHandlerFunc) { i.leaveHandler = f } // ExtImageCopyCaptureCursorSessionPositionEvent : position changed // // Cursors outside the image capture source do not get captured and no // event will be generated for them. // // The given position is the position of the cursor's hotspot and it is // relative to the main buffer's top left corner in transformed buffer // pixel coordinates. The coordinates may be negative or greater than the // main buffer size. type ExtImageCopyCaptureCursorSessionPositionEvent struct { X int32 Y int32 } type ExtImageCopyCaptureCursorSessionPositionHandlerFunc func(ExtImageCopyCaptureCursorSessionPositionEvent) // SetPositionHandler : sets handler for ExtImageCopyCaptureCursorSessionPositionEvent func (i *ExtImageCopyCaptureCursorSession) SetPositionHandler(f ExtImageCopyCaptureCursorSessionPositionHandlerFunc) { i.positionHandler = f } // ExtImageCopyCaptureCursorSessionHotspotEvent : hotspot changed // // The hotspot describes the offset between the cursor image and the // position of the input device. // // The given coordinates are the hotspot's offset from the origin in // buffer coordinates. // // Clients should not apply the hotspot immediately: the hotspot becomes // effective when the next ext_image_copy_capture_frame_v1.ready event is received. // // Compositors may delay this event until the client captures a new frame. type ExtImageCopyCaptureCursorSessionHotspotEvent struct { X int32 Y int32 } type ExtImageCopyCaptureCursorSessionHotspotHandlerFunc func(ExtImageCopyCaptureCursorSessionHotspotEvent) // SetHotspotHandler : sets handler for ExtImageCopyCaptureCursorSessionHotspotEvent func (i *ExtImageCopyCaptureCursorSession) SetHotspotHandler(f ExtImageCopyCaptureCursorSessionHotspotHandlerFunc) { i.hotspotHandler = f } func (i *ExtImageCopyCaptureCursorSession) Dispatch(opcode uint32, fd int, data []byte) { switch opcode { case 0: if i.enterHandler == nil { return } var e ExtImageCopyCaptureCursorSessionEnterEvent i.enterHandler(e) case 1: if i.leaveHandler == nil { return } var e ExtImageCopyCaptureCursorSessionLeaveEvent i.leaveHandler(e) case 2: if i.positionHandler == nil { return } var e ExtImageCopyCaptureCursorSessionPositionEvent l := 0 e.X = int32(client.Uint32(data[l : l+4])) l += 4 e.Y = int32(client.Uint32(data[l : l+4])) l += 4 i.positionHandler(e) case 3: if i.hotspotHandler == nil { return } var e ExtImageCopyCaptureCursorSessionHotspotEvent l := 0 e.X = int32(client.Uint32(data[l : l+4])) l += 4 e.Y = int32(client.Uint32(data[l : l+4])) l += 4 i.hotspotHandler(e) } }