1// Code generated by wlbgen; DO NOT EDIT.
2
3// Upstream protocol copyright and license:
4// Copyright 2021 Isaac Freund
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 shall be included in
14// all copies or substantial portions of the Software.
15//
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22// THE SOFTWARE.
23
24package extsessionlock
25
26import (
27 "fmt"
28 wayland "github.com/bnema/go-wayland-bindings/server/wayland"
29 "github.com/bnema/purego-libwayland/server"
30)
31
32var ExtSessionLockManagerV1Interface *server.Interface
33var ExtSessionLockV1Interface *server.Interface
34var ExtSessionLockSurfaceV1Interface *server.Interface
35
36func init() {
37 ExtSessionLockManagerV1Interface = &server.Interface{Name: "ext_session_lock_manager_v1", Version: 1}
38 ExtSessionLockV1Interface = &server.Interface{Name: "ext_session_lock_v1", Version: 1}
39 ExtSessionLockSurfaceV1Interface = &server.Interface{Name: "ext_session_lock_surface_v1", Version: 1}
40 ExtSessionLockManagerV1Interface.Requests = []server.Message{
41 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
42 {Name: "lock", Signature: "n", Types: []*server.Interface{ExtSessionLockV1Interface}},
43 }
44 ExtSessionLockManagerV1Interface.Events = []server.Message{}
45 ExtSessionLockV1Interface.Requests = []server.Message{
46 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
47 {Name: "get_lock_surface", Signature: "noo", Types: []*server.Interface{ExtSessionLockSurfaceV1Interface, wayland.SurfaceInterface, wayland.OutputInterface}},
48 {Name: "unlock_and_destroy", Signature: "", Types: []*server.Interface{}},
49 }
50 ExtSessionLockV1Interface.Events = []server.Message{
51 {Name: "locked", Signature: "", Types: []*server.Interface{}},
52 {Name: "finished", Signature: "", Types: []*server.Interface{}},
53 }
54 ExtSessionLockSurfaceV1Interface.Requests = []server.Message{
55 {Name: "destroy", Signature: "", Types: []*server.Interface{}},
56 {Name: "ack_configure", Signature: "u", Types: []*server.Interface{nil}},
57 }
58 ExtSessionLockSurfaceV1Interface.Events = []server.Message{
59 {Name: "configure", Signature: "uuu", Types: []*server.Interface{nil, nil, nil}},
60 }
61 if err := server.NewInterfaces(ExtSessionLockManagerV1Interface, ExtSessionLockV1Interface, ExtSessionLockSurfaceV1Interface); err != nil {
62 panic(err)
63 }
64}
65
66// ExtSessionLockManagerV1 used to lock the session.
67type ExtSessionLockManagerV1 struct{ *server.Resource }
68
69func WrapExtSessionLockManagerV1(r *server.Resource) *ExtSessionLockManagerV1 {
70 if r == nil {
71 return nil
72 }
73 return &ExtSessionLockManagerV1{r}
74}
75
76const ExtSessionLockManagerV1RequestDestroy uint32 = 0
77const ExtSessionLockManagerV1RequestLock uint32 = 1
78
79// ExtSessionLockManagerV1Handler handles ext_session_lock_manager_v1 requests.
80type ExtSessionLockManagerV1Handler interface {
81 Destroy(self *ExtSessionLockManagerV1)
82 Lock(self *ExtSessionLockManagerV1, id uint32)
83}
84
85func NewExtSessionLockManagerV1(c server.Client, version int32, id uint32, h ExtSessionLockManagerV1Handler) (*ExtSessionLockManagerV1, error) {
86 if h == nil {
87 return nil, fmt.Errorf("purego-libwayland: nil handler for ext_session_lock_manager_v1")
88 }
89 var self *ExtSessionLockManagerV1
90 r, err := c.CreateResource(ExtSessionLockManagerV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
91 switch opcode {
92 case 0:
93 h.Destroy(self)
94 self.Destroy()
95 case 1:
96 h.Lock(self, args[0].NewID())
97 }
98 })
99 if err != nil {
100 return nil, err
101 }
102 self = WrapExtSessionLockManagerV1(r)
103 r.Data = self
104 return self, nil
105}
106func NewExtSessionLockManagerV1Global(d *server.Display, version int32, bind server.BindFunc) error {
107 return d.CreateGlobal(ExtSessionLockManagerV1Interface, version, bind)
108}
109
110// ExtSessionLockV1 manage lock state and create lock surfaces.
111type ExtSessionLockV1 struct{ *server.Resource }
112
113func WrapExtSessionLockV1(r *server.Resource) *ExtSessionLockV1 {
114 if r == nil {
115 return nil
116 }
117 return &ExtSessionLockV1{r}
118}
119
120const ExtSessionLockV1RequestDestroy uint32 = 0
121const ExtSessionLockV1RequestGetLockSurface uint32 = 1
122const ExtSessionLockV1RequestUnlockAndDestroy uint32 = 2
123const ExtSessionLockV1EventLocked uint32 = 0
124const ExtSessionLockV1EventFinished uint32 = 1
125
126// ExtSessionLockV1Error .
127type ExtSessionLockV1Error uint32
128
129const (
130 ExtSessionLockV1ErrorInvalidDestroy ExtSessionLockV1Error = 0
131 ExtSessionLockV1ErrorInvalidUnlock ExtSessionLockV1Error = 1
132 ExtSessionLockV1ErrorRole ExtSessionLockV1Error = 2
133 ExtSessionLockV1ErrorDuplicateOutput ExtSessionLockV1Error = 3
134 ExtSessionLockV1ErrorAlreadyConstructed ExtSessionLockV1Error = 4
135)
136
137// ExtSessionLockV1Handler handles ext_session_lock_v1 requests.
138type ExtSessionLockV1Handler interface {
139 Destroy(self *ExtSessionLockV1)
140 GetLockSurface(self *ExtSessionLockV1, id uint32, surface *wayland.Surface, output *wayland.Output)
141 UnlockAndDestroy(self *ExtSessionLockV1)
142}
143
144func NewExtSessionLockV1(c server.Client, version int32, id uint32, h ExtSessionLockV1Handler) (*ExtSessionLockV1, error) {
145 if h == nil {
146 return nil, fmt.Errorf("purego-libwayland: nil handler for ext_session_lock_v1")
147 }
148 var self *ExtSessionLockV1
149 r, err := c.CreateResource(ExtSessionLockV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
150 switch opcode {
151 case 0:
152 h.Destroy(self)
153 self.Destroy()
154 case 1:
155 h.GetLockSurface(self, args[0].NewID(), wayland.WrapSurface(args[1].Resource()), wayland.WrapOutput(args[2].Resource()))
156 case 2:
157 h.UnlockAndDestroy(self)
158 self.Destroy()
159 }
160 })
161 if err != nil {
162 return nil, err
163 }
164 self = WrapExtSessionLockV1(r)
165 r.Data = self
166 return self, nil
167}
168
169// SendLocked session successfully locked.
170func (self *ExtSessionLockV1) SendLocked() {
171 self.PostEvent(ExtSessionLockV1EventLocked)
172}
173
174// SendFinished the session lock object should be destroyed.
175func (self *ExtSessionLockV1) SendFinished() {
176 self.PostEvent(ExtSessionLockV1EventFinished)
177}
178func NewExtSessionLockV1Global(d *server.Display, version int32, bind server.BindFunc) error {
179 return d.CreateGlobal(ExtSessionLockV1Interface, version, bind)
180}
181
182// ExtSessionLockSurfaceV1 a surface displayed while the session is locked.
183type ExtSessionLockSurfaceV1 struct{ *server.Resource }
184
185func WrapExtSessionLockSurfaceV1(r *server.Resource) *ExtSessionLockSurfaceV1 {
186 if r == nil {
187 return nil
188 }
189 return &ExtSessionLockSurfaceV1{r}
190}
191
192const ExtSessionLockSurfaceV1RequestDestroy uint32 = 0
193const ExtSessionLockSurfaceV1RequestAckConfigure uint32 = 1
194const ExtSessionLockSurfaceV1EventConfigure uint32 = 0
195
196// ExtSessionLockSurfaceV1Error .
197type ExtSessionLockSurfaceV1Error uint32
198
199const (
200 ExtSessionLockSurfaceV1ErrorCommitBeforeFirstAck ExtSessionLockSurfaceV1Error = 0
201 ExtSessionLockSurfaceV1ErrorNullBuffer ExtSessionLockSurfaceV1Error = 1
202 ExtSessionLockSurfaceV1ErrorDimensionsMismatch ExtSessionLockSurfaceV1Error = 2
203 ExtSessionLockSurfaceV1ErrorInvalidSerial ExtSessionLockSurfaceV1Error = 3
204)
205
206// ExtSessionLockSurfaceV1Handler handles ext_session_lock_surface_v1 requests.
207type ExtSessionLockSurfaceV1Handler interface {
208 Destroy(self *ExtSessionLockSurfaceV1)
209 AckConfigure(self *ExtSessionLockSurfaceV1, serial uint32)
210}
211
212func NewExtSessionLockSurfaceV1(c server.Client, version int32, id uint32, h ExtSessionLockSurfaceV1Handler) (*ExtSessionLockSurfaceV1, error) {
213 if h == nil {
214 return nil, fmt.Errorf("purego-libwayland: nil handler for ext_session_lock_surface_v1")
215 }
216 var self *ExtSessionLockSurfaceV1
217 r, err := c.CreateResource(ExtSessionLockSurfaceV1Interface, version, id, func(_ *server.Resource, opcode uint32, args []server.Arg) {
218 switch opcode {
219 case 0:
220 h.Destroy(self)
221 self.Destroy()
222 case 1:
223 h.AckConfigure(self, args[0].Uint())
224 }
225 })
226 if err != nil {
227 return nil, err
228 }
229 self = WrapExtSessionLockSurfaceV1(r)
230 r.Data = self
231 return self, nil
232}
233
234// SendConfigure the client should resize its surface.
235func (self *ExtSessionLockSurfaceV1) SendConfigure(serial uint32, width uint32, height uint32) {
236 self.PostEvent(ExtSessionLockSurfaceV1EventConfigure, server.Uint(serial), server.Uint(width), server.Uint(height))
237}
238func NewExtSessionLockSurfaceV1Global(d *server.Display, version int32, bind server.BindFunc) error {
239 return d.CreateGlobal(ExtSessionLockSurfaceV1Interface, version, bind)
240}
241func resourceOf(v interface{ GetResource() *server.Resource }) *server.Resource {
242 if v == nil {
243 return nil
244 }
245 return v.GetResource()
246}
247func (self *ExtSessionLockManagerV1) GetResource() *server.Resource {
248 if self == nil {
249 return nil
250 }
251 return self.Resource
252}
253func (self *ExtSessionLockV1) GetResource() *server.Resource {
254 if self == nil {
255 return nil
256 }
257 return self.Resource
258}
259func (self *ExtSessionLockSurfaceV1) GetResource() *server.Resource {
260 if self == nil {
261 return nil
262 }
263 return self.Resource
264}