1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2018 Rostislav Pehlivanov
5//
6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation
9// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10// and/or sell copies of the Software, and to permit persons to whom the
11// Software is furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice (including the next
14// paragraph) shall be included in all copies or substantial portions of the
15// Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25package wlrexportdmabuf
26
27import (
28 "fmt"
29 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
30 "github.com/bnema/purego-libwayland/server"
31)
32
33var ZwlrExportDmabufManagerV1Interface *server.Interface
34var ZwlrExportDmabufFrameV1Interface *server.Interface
35
36func init() {
37 ZwlrExportDmabufManagerV1Interface = &server.Interface{Name: "zwlr_export_dmabuf_manager_v1", Version: 1}
38 ZwlrExportDmabufFrameV1Interface = &server.Interface{Name: "zwlr_export_dmabuf_frame_v1", Version: 1}
39 ZwlrExportDmabufManagerV1Interface.Requests = []server.Message{
40 {Name: "capture_output", Signature: "nio", Types: []*server.Interface{ZwlrExportDmabufFrameV1Interface, nil, wayland.OutputInterface}},
41 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
42 }
43 ZwlrExportDmabufManagerV1Interface.Events = []server.Message{}
44 ZwlrExportDmabufFrameV1Interface.Requests = []server.Message{
45 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
46 }
47 ZwlrExportDmabufFrameV1Interface.Events = []server.Message{
48 {Name: "frame", Signature: "uuuuuuuuuu", Types: []*server.Interface{nil, nil, nil, nil, nil, nil, nil, nil, nil, nil}},
49 {Name: "object", Signature: "uhuuuu", Types: []*server.Interface{nil, nil, nil, nil, nil, nil}},
50 {Name: "ready", Signature: "uuu", Types: []*server.Interface{nil, nil, nil}},
51 {Name: "cancel", Signature: "u", Types: []*server.Interface{nil}},
52 }
53 if err := server.NewInterfaces(ZwlrExportDmabufManagerV1Interface, ZwlrExportDmabufFrameV1Interface); err != nil {
54 panic(err)
55 }
56}
57
58// ZwlrExportDmabufManagerV1 manager to inform clients and begin capturing.
59type ZwlrExportDmabufManagerV1 struct{ *server.Resource }
60
61func WrapZwlrExportDmabufManagerV1(r *server.Resource) *ZwlrExportDmabufManagerV1 {
62 if r == nil {
63 return nil
64 }
65 return &ZwlrExportDmabufManagerV1{r}
66}
67
68const ZwlrExportDmabufManagerV1RequestCaptureOutput uint32 = 0
69const ZwlrExportDmabufManagerV1RequestDestroy uint32 = 1
70
71// ZwlrExportDmabufManagerV1Handler handles zwlr_export_dmabuf_manager_v1 requests.
72type ZwlrExportDmabufManagerV1Handler interface {
73 CaptureOutput(self *ZwlrExportDmabufManagerV1, frame uint32, overlayCursor int32, output *wayland.Output)
74 Destroy(self *ZwlrExportDmabufManagerV1)
75}
76
77func NewZwlrExportDmabufManagerV1(c server.Client, version int32, id uint32, h ZwlrExportDmabufManagerV1Handler) (*ZwlrExportDmabufManagerV1, error) {
78 if h == nil {
79 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_export_dmabuf_manager_v1")
80 }
81 var self *ZwlrExportDmabufManagerV1
82 r, err := c.CreateResource(ZwlrExportDmabufManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
83 switch opcode {
84 case 0:
85 h.CaptureOutput(self, args[0].NewID(), args[1].Int(), wayland.WrapOutput(args[2].Resource()))
86 case 1:
87 h.Destroy(self)
88 self.Destroy()
89 }
90 })
91 if err != nil {
92 return nil, err
93 }
94 self = WrapZwlrExportDmabufManagerV1(r)
95 r.Data = self
96 return self, nil
97}
98func NewZwlrExportDmabufManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
99 return d.CreateGlobal(ZwlrExportDmabufManagerV1Interface, version, bind)
100}
101
102// ZwlrExportDmabufFrameV1 a DMA-BUF frame.
103type ZwlrExportDmabufFrameV1 struct{ *server.Resource }
104
105func WrapZwlrExportDmabufFrameV1(r *server.Resource) *ZwlrExportDmabufFrameV1 {
106 if r == nil {
107 return nil
108 }
109 return &ZwlrExportDmabufFrameV1{r}
110}
111
112const ZwlrExportDmabufFrameV1RequestDestroy uint32 = 0
113const ZwlrExportDmabufFrameV1EventFrame uint32 = 0
114const ZwlrExportDmabufFrameV1EventObject uint32 = 1
115const ZwlrExportDmabufFrameV1EventReady uint32 = 2
116const ZwlrExportDmabufFrameV1EventCancel uint32 = 3
117
118// ZwlrExportDmabufFrameV1Flags frame flags.
119type ZwlrExportDmabufFrameV1Flags uint32
120
121const (
122 ZwlrExportDmabufFrameV1FlagsTransient ZwlrExportDmabufFrameV1Flags = 0x1
123)
124
125// ZwlrExportDmabufFrameV1CancelReason cancel reason.
126type ZwlrExportDmabufFrameV1CancelReason uint32
127
128const (
129 ZwlrExportDmabufFrameV1CancelReasonTemporary ZwlrExportDmabufFrameV1CancelReason = 0
130 ZwlrExportDmabufFrameV1CancelReasonPermanent ZwlrExportDmabufFrameV1CancelReason = 1
131 ZwlrExportDmabufFrameV1CancelReasonResizing ZwlrExportDmabufFrameV1CancelReason = 2
132)
133
134// ZwlrExportDmabufFrameV1Handler handles zwlr_export_dmabuf_frame_v1 requests.
135type ZwlrExportDmabufFrameV1Handler interface {
136 Destroy(self *ZwlrExportDmabufFrameV1)
137}
138
139func NewZwlrExportDmabufFrameV1(c server.Client, version int32, id uint32, h ZwlrExportDmabufFrameV1Handler) (*ZwlrExportDmabufFrameV1, error) {
140 if h == nil {
141 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_export_dmabuf_frame_v1")
142 }
143 var self *ZwlrExportDmabufFrameV1
144 r, err := c.CreateResource(ZwlrExportDmabufFrameV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
145 switch opcode {
146 case 0:
147 h.Destroy(self)
148 self.Destroy()
149 }
150 })
151 if err != nil {
152 return nil, err
153 }
154 self = WrapZwlrExportDmabufFrameV1(r)
155 r.Data = self
156 return self, nil
157}
158
159// SendFrame a frame description.
160func (self *ZwlrExportDmabufFrameV1) SendFrame(width uint32, height uint32, offsetX uint32, offsetY uint32, bufferFlags uint32, flags uint32, format uint32, modHigh uint32, modLow uint32, numObjects uint32) {
161 self.PostEvent(ZwlrExportDmabufFrameV1EventFrame, server.Uint(width), server.Uint(height), server.Uint(offsetX), server.Uint(offsetY), server.Uint(bufferFlags), server.Uint(flags), server.Uint(format), server.Uint(modHigh), server.Uint(modLow), server.Uint(numObjects))
162}
163
164// SendObject an object description.
165func (self *ZwlrExportDmabufFrameV1) SendObject(index uint32, fd int, size uint32, offset uint32, stride uint32, planeIndex uint32) {
166 self.PostEvent(ZwlrExportDmabufFrameV1EventObject, server.Uint(index), server.Fd(fd), server.Uint(size), server.Uint(offset), server.Uint(stride), server.Uint(planeIndex))
167}
168
169// SendReady indicates frame is available for reading.
170func (self *ZwlrExportDmabufFrameV1) SendReady(tvSecHi uint32, tvSecLo uint32, tvNsec uint32) {
171 self.PostEvent(ZwlrExportDmabufFrameV1EventReady, server.Uint(tvSecHi), server.Uint(tvSecLo), server.Uint(tvNsec))
172}
173
174// SendCancel indicates the frame is no longer valid.
175func (self *ZwlrExportDmabufFrameV1) SendCancel(reason uint32) {
176 self.PostEvent(ZwlrExportDmabufFrameV1EventCancel, server.Uint(reason))
177}
178func NewZwlrExportDmabufFrameV1Global(d *server.Display, version int32, bind server.BindFunc) error {
179 return d.CreateGlobal(ZwlrExportDmabufFrameV1Interface, version, bind)
180}
181func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
182 if v == nil {
183 return nil
184 }
185 return v.GetResource()
186}
187func (self *ZwlrExportDmabufManagerV1) GetResource() *server.Resource {
188 if self == nil {
189 return nil
190 }
191 return self.Resource
192}
193func (self *ZwlrExportDmabufFrameV1) GetResource() *server.Resource {
194 if self == nil {
195 return nil
196 }
197 return self.Resource
198}