1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright © 2018 Simon Ser
5// Copyright © 2019 Andri Yngvason
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice (including the next
15// paragraph) shall be included in all copies or substantial portions of the
16// Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24// DEALINGS IN THE SOFTWARE.
25
26package wlrscreencopy
27
28import (
29 "fmt"
30 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
31 "github.com/bnema/purego-libwayland/server"
32)
33
34var ZwlrScreencopyManagerV1Interface *server.Interface
35var ZwlrScreencopyFrameV1Interface *server.Interface
36
37func init() {
38 ZwlrScreencopyManagerV1Interface = &server.Interface{Name: "zwlr_screencopy_manager_v1", Version: 3}
39 ZwlrScreencopyFrameV1Interface = &server.Interface{Name: "zwlr_screencopy_frame_v1", Version: 3}
40 ZwlrScreencopyManagerV1Interface.Requests = []server.Message{
41 {Name: "capture_output", Signature: "nio", Types: []*server.Interface{ZwlrScreencopyFrameV1Interface, nil, wayland.OutputInterface}},
42 {Name: "capture_output_region", Signature: "nioiiii", Types: []*server.Interface{ZwlrScreencopyFrameV1Interface, nil, wayland.OutputInterface, nil, nil, nil, nil}},
43 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
44 }
45 ZwlrScreencopyManagerV1Interface.Events = []server.Message{}
46 ZwlrScreencopyFrameV1Interface.Requests = []server.Message{
47 {Name: "copy", Signature: "o", Types: []*server.Interface{wayland.BufferInterface}},
48 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
49 {Name: "copy_with_damage", Signature: "2o", Types: []*server.Interface{wayland.BufferInterface}},
50 }
51 ZwlrScreencopyFrameV1Interface.Events = []server.Message{
52 {Name: "buffer", Signature: "uuuu", Types: []*server.Interface{nil, nil, nil, nil}},
53 {Name: "flags", Signature: "u", Types: []*server.Interface{nil}},
54 {Name: "ready", Signature: "uuu", Types: []*server.Interface{nil, nil, nil}},
55 {Name: "failed", Signature: "", Types: []*server.Interface{}},
56 {Name: "damage", Signature: "2uuuu", Types: []*server.Interface{nil, nil, nil, nil}},
57 {Name: "linux_dmabuf", Signature: "3uuu", Types: []*server.Interface{nil, nil, nil}},
58 {Name: "buffer_done", Signature: "3", Types: []*server.Interface{}},
59 }
60 if err := server.NewInterfaces(ZwlrScreencopyManagerV1Interface, ZwlrScreencopyFrameV1Interface); err != nil {
61 panic(err)
62 }
63}
64
65// ZwlrScreencopyManagerV1 manager to inform clients and begin capturing.
66type ZwlrScreencopyManagerV1 struct{ *server.Resource }
67
68func WrapZwlrScreencopyManagerV1(r *server.Resource) *ZwlrScreencopyManagerV1 {
69 if r == nil {
70 return nil
71 }
72 return &ZwlrScreencopyManagerV1{r}
73}
74
75const ZwlrScreencopyManagerV1RequestCaptureOutput uint32 = 0
76const ZwlrScreencopyManagerV1RequestCaptureOutputRegion uint32 = 1
77const ZwlrScreencopyManagerV1RequestDestroy uint32 = 2
78
79// ZwlrScreencopyManagerV1Handler handles zwlr_screencopy_manager_v1 requests.
80type ZwlrScreencopyManagerV1Handler interface {
81 CaptureOutput(self *ZwlrScreencopyManagerV1, frame uint32, overlayCursor int32, output *wayland.Output)
82 CaptureOutputRegion(self *ZwlrScreencopyManagerV1, frame uint32, overlayCursor int32, output *wayland.Output, x int32, y int32, width int32, height int32)
83 Destroy(self *ZwlrScreencopyManagerV1)
84}
85
86func NewZwlrScreencopyManagerV1(c server.Client, version int32, id uint32, h ZwlrScreencopyManagerV1Handler) (*ZwlrScreencopyManagerV1, error) {
87 if h == nil {
88 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_screencopy_manager_v1")
89 }
90 var self *ZwlrScreencopyManagerV1
91 r, err := c.CreateResource(ZwlrScreencopyManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
92 switch opcode {
93 case 0:
94 h.CaptureOutput(self, args[0].NewID(), args[1].Int(), wayland.WrapOutput(args[2].Resource()))
95 case 1:
96 h.CaptureOutputRegion(self, args[0].NewID(), args[1].Int(), wayland.WrapOutput(args[2].Resource()), args[3].Int(), args[4].Int(), args[5].Int(), args[6].Int())
97 case 2:
98 h.Destroy(self)
99 self.Destroy()
100 }
101 })
102 if err != nil {
103 return nil, err
104 }
105 self = WrapZwlrScreencopyManagerV1(r)
106 r.Data = self
107 return self, nil
108}
109func NewZwlrScreencopyManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
110 return d.CreateGlobal(ZwlrScreencopyManagerV1Interface, version, bind)
111}
112
113// ZwlrScreencopyFrameV1 a frame ready for copy.
114type ZwlrScreencopyFrameV1 struct{ *server.Resource }
115
116func WrapZwlrScreencopyFrameV1(r *server.Resource) *ZwlrScreencopyFrameV1 {
117 if r == nil {
118 return nil
119 }
120 return &ZwlrScreencopyFrameV1{r}
121}
122
123const ZwlrScreencopyFrameV1RequestCopy uint32 = 0
124const ZwlrScreencopyFrameV1RequestDestroy uint32 = 1
125const ZwlrScreencopyFrameV1RequestCopyWithDamage uint32 = 2
126const ZwlrScreencopyFrameV1EventBuffer uint32 = 0
127const ZwlrScreencopyFrameV1EventFlags uint32 = 1
128const ZwlrScreencopyFrameV1EventReady uint32 = 2
129const ZwlrScreencopyFrameV1EventFailed uint32 = 3
130const ZwlrScreencopyFrameV1EventDamage uint32 = 4
131const ZwlrScreencopyFrameV1EventLinuxDmabuf uint32 = 5
132const ZwlrScreencopyFrameV1EventBufferDone uint32 = 6
133
134// ZwlrScreencopyFrameV1Error .
135type ZwlrScreencopyFrameV1Error uint32
136
137const (
138 ZwlrScreencopyFrameV1ErrorAlreadyUsed ZwlrScreencopyFrameV1Error = 0
139 ZwlrScreencopyFrameV1ErrorInvalidBuffer ZwlrScreencopyFrameV1Error = 1
140)
141
142// ZwlrScreencopyFrameV1Flags (bitfield).
143type ZwlrScreencopyFrameV1Flags uint32
144
145const (
146 ZwlrScreencopyFrameV1FlagsYInvert ZwlrScreencopyFrameV1Flags = 1
147)
148
149// ZwlrScreencopyFrameV1Handler handles zwlr_screencopy_frame_v1 requests.
150type ZwlrScreencopyFrameV1Handler interface {
151 Copy(self *ZwlrScreencopyFrameV1, buffer *wayland.Buffer)
152 Destroy(self *ZwlrScreencopyFrameV1)
153 CopyWithDamage(self *ZwlrScreencopyFrameV1, buffer *wayland.Buffer)
154}
155
156func NewZwlrScreencopyFrameV1(c server.Client, version int32, id uint32, h ZwlrScreencopyFrameV1Handler) (*ZwlrScreencopyFrameV1, error) {
157 if h == nil {
158 return nil, fmt.Errorf("purego-libwayland: nil handler for zwlr_screencopy_frame_v1")
159 }
160 var self *ZwlrScreencopyFrameV1
161 r, err := c.CreateResource(ZwlrScreencopyFrameV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
162 switch opcode {
163 case 0:
164 h.Copy(self, wayland.WrapBuffer(args[0].Resource()))
165 case 1:
166 h.Destroy(self)
167 self.Destroy()
168 case 2:
169 h.CopyWithDamage(self, wayland.WrapBuffer(args[0].Resource()))
170 }
171 })
172 if err != nil {
173 return nil, err
174 }
175 self = WrapZwlrScreencopyFrameV1(r)
176 r.Data = self
177 return self, nil
178}
179
180// SendBuffer wl_shm buffer information.
181func (self *ZwlrScreencopyFrameV1) SendBuffer(format uint32, width uint32, height uint32, stride uint32) {
182 self.PostEvent(ZwlrScreencopyFrameV1EventBuffer, server.Uint(format), server.Uint(width), server.Uint(height), server.Uint(stride))
183}
184
185// SendFlags frame flags.
186func (self *ZwlrScreencopyFrameV1) SendFlags(flags uint32) {
187 self.PostEvent(ZwlrScreencopyFrameV1EventFlags, server.Uint(flags))
188}
189
190// SendReady indicates frame is available for reading.
191func (self *ZwlrScreencopyFrameV1) SendReady(tvSecHi uint32, tvSecLo uint32, tvNsec uint32) {
192 self.PostEvent(ZwlrScreencopyFrameV1EventReady, server.Uint(tvSecHi), server.Uint(tvSecLo), server.Uint(tvNsec))
193}
194
195// SendFailed frame copy failed.
196func (self *ZwlrScreencopyFrameV1) SendFailed() {
197 self.PostEvent(ZwlrScreencopyFrameV1EventFailed)
198}
199
200// SendDamage carries the coordinates of the damaged region (since version 2).
201func (self *ZwlrScreencopyFrameV1) SendDamage(x uint32, y uint32, width uint32, height uint32) {
202 self.PostEvent(ZwlrScreencopyFrameV1EventDamage, server.Uint(x), server.Uint(y), server.Uint(width), server.Uint(height))
203}
204
205// SendLinuxDmabuf linux-dmabuf buffer information (since version 3).
206func (self *ZwlrScreencopyFrameV1) SendLinuxDmabuf(format uint32, width uint32, height uint32) {
207 self.PostEvent(ZwlrScreencopyFrameV1EventLinuxDmabuf, server.Uint(format), server.Uint(width), server.Uint(height))
208}
209
210// SendBufferDone all buffer types reported (since version 3).
211func (self *ZwlrScreencopyFrameV1) SendBufferDone() {
212 self.PostEvent(ZwlrScreencopyFrameV1EventBufferDone)
213}
214func NewZwlrScreencopyFrameV1Global(d *server.Display, version int32, bind server.BindFunc) error {
215 return d.CreateGlobal(ZwlrScreencopyFrameV1Interface, version, bind)
216}
217func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
218 if v == nil {
219 return nil
220 }
221 return v.GetResource()
222}
223func (self *ZwlrScreencopyManagerV1) GetResource() *server.Resource {
224 if self == nil {
225 return nil
226 }
227 return self.Resource
228}
229func (self *ZwlrScreencopyFrameV1) GetResource() *server.Resource {
230 if self == nil {
231 return nil
232 }
233 return self.Resource
234}