v0.5.0 089fa12

drm-lease-v1_generated.go RawHistoryFolder

1// Code generated by wlturbo-scanner. DO NOT EDIT.
2// Protocol: drm_lease_v1
3// Source: drm-lease-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2018 NXP
7// Copyright © 2019 Status Research & Development GmbH.
8// Copyright © 2021 Xaver Hugl
9//
10// Permission is hereby granted, free of charge, to any person obtaining a
11// copy of this software and associated documentation files (the "Software"),
12// to deal in the Software without restriction, including without limitation
13// the rights to use, copy, modify, merge, publish, distribute, sublicense,
14// and/or sell copies of the Software, and to permit persons to whom the
15// Software is furnished to do so, subject to the following conditions:
16//
17// The above copyright notice and this permission notice (including the next
18// paragraph) shall be included in all copies or substantial portions of the
19// Software.
20//
21// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27// DEALINGS IN THE SOFTWARE.
28
29package drmlease
30
31import (
32	"sync"
33
34	"github.com/bnema/wlturbo/wl"
35)
36
37// ERROR_WRONG_DEVICE is the error wrong_device value.
38const ERROR_WRONG_DEVICE = 0
39
40// ERROR_DUPLICATE_CONNECTOR is the error duplicate_connector value.
41const ERROR_DUPLICATE_CONNECTOR = 1
42
43// ERROR_EMPTY_LEASE is the error empty_lease value.
44const ERROR_EMPTY_LEASE = 2
45
46// WpDrmLeaseDeviceInterface is the protocol interface name.
47const WpDrmLeaseDeviceInterface = "wp_drm_lease_device_v1"
48
49// WpDrmLeaseDevice is the generated binding for wp_drm_lease_device_v1 version 1.
50type WpDrmLeaseDevice struct {
51	wl.BaseProxy
52	// handlersMu guards the handler slices: a client may register or replace
53	// handlers while another goroutine dispatches events.
54	handlersMu  sync.Mutex
55	onDrmFd     []func(fd *wl.OwnedFD)
56	onConnector []func(idObject *WpDrmLeaseConnector)
57	onDone      []func()
58	onReleased  []func()
59}
60
61// NewWpDrmLeaseDevice returns an unbound WpDrmLeaseDevice.
62func NewWpDrmLeaseDevice(ctx *wl.Context) *WpDrmLeaseDevice {
63	obj := &WpDrmLeaseDevice{}
64	obj.SetContext(ctx)
65	ctx.Register(obj)
66	return obj
67}
68
69// Creates a lease request object. See the documentation for wp_drm_lease_request_v1 for details.
70func (o *WpDrmLeaseDevice) CreateLeaseRequest() (*WpDrmLeaseRequest, error) {
71	child := &WpDrmLeaseRequest{}
72	child.SetContext(o.Context())
73	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_drm_lease_device_v1.create_lease_request", Child: child}, wl.ArgObject(child)); err != nil {
74		return nil, err
75	}
76	return child, nil
77}
78
79// Indicates the client no longer wishes to use this object. In response the compositor will immediately send the released event and destroy this object. It can however not guarantee that the client won't receive connector events before the released event. The client must not send any requests after this one, doing so will raise a wl_display error. Existing connectors, lease request and leases will not be affected.
80func (o *WpDrmLeaseDevice) Release() error {
81	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_drm_lease_device_v1.release"}); err != nil {
82		return err
83	}
84	return nil
85}
86
87// OnDrmFd registers a handler for the drm_fd event.
88//
89// Handlers are appended, so a second call adds another handler rather than
90// replacing the first. Registration is safe while another goroutine dispatches.
91func (o *WpDrmLeaseDevice) OnDrmFd(handler func(fd *wl.OwnedFD)) {
92	if handler == nil {
93		return
94	}
95	o.handlersMu.Lock()
96	defer o.handlersMu.Unlock()
97	o.onDrmFd = append(o.onDrmFd, handler)
98}
99
100// handlersForDrmFd returns the handlers registered for drm_fd, taken
101// under the lock so a handler may register another handler while events are
102// being dispatched.
103func (o *WpDrmLeaseDevice) handlersForDrmFd() []func(fd *wl.OwnedFD) {
104	o.handlersMu.Lock()
105	defer o.handlersMu.Unlock()
106	return o.onDrmFd
107}
108
109// OnConnector registers a handler for the connector event.
110//
111// Handlers are appended, so a second call adds another handler rather than
112// replacing the first. Registration is safe while another goroutine dispatches.
113func (o *WpDrmLeaseDevice) OnConnector(handler func(idObject *WpDrmLeaseConnector)) {
114	if handler == nil {
115		return
116	}
117	o.handlersMu.Lock()
118	defer o.handlersMu.Unlock()
119	o.onConnector = append(o.onConnector, handler)
120}
121
122// handlersForConnector returns the handlers registered for connector, taken
123// under the lock so a handler may register another handler while events are
124// being dispatched.
125func (o *WpDrmLeaseDevice) handlersForConnector() []func(idObject *WpDrmLeaseConnector) {
126	o.handlersMu.Lock()
127	defer o.handlersMu.Unlock()
128	return o.onConnector
129}
130
131// OnDone registers a handler for the done event.
132//
133// Handlers are appended, so a second call adds another handler rather than
134// replacing the first. Registration is safe while another goroutine dispatches.
135func (o *WpDrmLeaseDevice) OnDone(handler func()) {
136	if handler == nil {
137		return
138	}
139	o.handlersMu.Lock()
140	defer o.handlersMu.Unlock()
141	o.onDone = append(o.onDone, handler)
142}
143
144// handlersForDone returns the handlers registered for done, taken
145// under the lock so a handler may register another handler while events are
146// being dispatched.
147func (o *WpDrmLeaseDevice) handlersForDone() []func() {
148	o.handlersMu.Lock()
149	defer o.handlersMu.Unlock()
150	return o.onDone
151}
152
153// OnReleased registers a handler for the released event.
154//
155// Handlers are appended, so a second call adds another handler rather than
156// replacing the first. Registration is safe while another goroutine dispatches.
157func (o *WpDrmLeaseDevice) OnReleased(handler func()) {
158	if handler == nil {
159		return
160	}
161	o.handlersMu.Lock()
162	defer o.handlersMu.Unlock()
163	o.onReleased = append(o.onReleased, handler)
164}
165
166// handlersForReleased returns the handlers registered for released, taken
167// under the lock so a handler may register another handler while events are
168// being dispatched.
169func (o *WpDrmLeaseDevice) handlersForReleased() []func() {
170	o.handlersMu.Lock()
171	defer o.handlersMu.Unlock()
172	return o.onReleased
173}
174
175// EventSignature returns the declared event argument types in wire order.
176func (o *WpDrmLeaseDevice) EventSignature(opcode uint16) (string, bool) {
177	switch opcode {
178	case 0:
179		return "fd,", true
180	case 1:
181		return "new_id,", true
182	case 2:
183		return "", true
184	case 3:
185		return "", true
186	default:
187		return "", false
188	}
189}
190
191// Dispatch decodes one event on wp_drm_lease_device_v1 and calls the registered handlers.
192func (o *WpDrmLeaseDevice) Dispatch(event *wl.Event) {
193	switch event.Opcode {
194	case 0: // drm_fd
195		fd := event.FD()
196		ownedfd := fd
197		defer ownedfd.Close()
198
199		for i, handler := range o.handlersForDrmFd() {
200			if i > 0 {
201				fd = nil
202			}
203			handler(fd)
204		}
205	case 1: // connector
206		idID := event.Uint32()
207		idObject := &WpDrmLeaseConnector{}
208		idObject.SetContext(o.Context())
209		idObject.SetID(idID)
210		idObject.SetVersion(o.Version())
211		o.Context().Register(idObject)
212
213		for i, handler := range o.handlersForConnector() {
214			_ = i
215			handler(idObject)
216		}
217	case 2: // done
218
219		for i, handler := range o.handlersForDone() {
220			_ = i
221			handler()
222		}
223	case 3: // released
224
225		for i, handler := range o.handlersForReleased() {
226			_ = i
227			handler()
228		}
229		o.Context().Unregister(o)
230	default:
231	}
232}
233
234// WpDrmLeaseConnectorInterface is the protocol interface name.
235const WpDrmLeaseConnectorInterface = "wp_drm_lease_connector_v1"
236
237// WpDrmLeaseConnector is the generated binding for wp_drm_lease_connector_v1 version 1.
238type WpDrmLeaseConnector struct {
239	wl.BaseProxy
240	// handlersMu guards the handler slices: a client may register or replace
241	// handlers while another goroutine dispatches events.
242	handlersMu    sync.Mutex
243	onName        []func(name string)
244	onDescription []func(description string)
245	onConnectorId []func(connectorId uint32)
246	onDone        []func()
247	onWithdrawn   []func()
248}
249
250// NewWpDrmLeaseConnector returns an unbound WpDrmLeaseConnector.
251func NewWpDrmLeaseConnector(ctx *wl.Context) *WpDrmLeaseConnector {
252	obj := &WpDrmLeaseConnector{}
253	obj.SetContext(ctx)
254	ctx.Register(obj)
255	return obj
256}
257
258// The client may send this request to indicate that it will not use this connector. Clients are encouraged to send this after receiving the "withdrawn" event so that the server can release the resources associated with this connector offer. Neither existing lease requests nor leases will be affected.
259func (o *WpDrmLeaseConnector) Destroy() error {
260	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_drm_lease_connector_v1.destroy", Destructor: true}); err != nil {
261		return err
262	}
263	return nil
264}
265
266// OnName registers a handler for the name event.
267//
268// Handlers are appended, so a second call adds another handler rather than
269// replacing the first. Registration is safe while another goroutine dispatches.
270func (o *WpDrmLeaseConnector) OnName(handler func(name string)) {
271	if handler == nil {
272		return
273	}
274	o.handlersMu.Lock()
275	defer o.handlersMu.Unlock()
276	o.onName = append(o.onName, handler)
277}
278
279// handlersForName returns the handlers registered for name, taken
280// under the lock so a handler may register another handler while events are
281// being dispatched.
282func (o *WpDrmLeaseConnector) handlersForName() []func(name string) {
283	o.handlersMu.Lock()
284	defer o.handlersMu.Unlock()
285	return o.onName
286}
287
288// OnDescription registers a handler for the description event.
289//
290// Handlers are appended, so a second call adds another handler rather than
291// replacing the first. Registration is safe while another goroutine dispatches.
292func (o *WpDrmLeaseConnector) OnDescription(handler func(description string)) {
293	if handler == nil {
294		return
295	}
296	o.handlersMu.Lock()
297	defer o.handlersMu.Unlock()
298	o.onDescription = append(o.onDescription, handler)
299}
300
301// handlersForDescription returns the handlers registered for description, taken
302// under the lock so a handler may register another handler while events are
303// being dispatched.
304func (o *WpDrmLeaseConnector) handlersForDescription() []func(description string) {
305	o.handlersMu.Lock()
306	defer o.handlersMu.Unlock()
307	return o.onDescription
308}
309
310// OnConnectorId registers a handler for the connector_id event.
311//
312// Handlers are appended, so a second call adds another handler rather than
313// replacing the first. Registration is safe while another goroutine dispatches.
314func (o *WpDrmLeaseConnector) OnConnectorId(handler func(connectorId uint32)) {
315	if handler == nil {
316		return
317	}
318	o.handlersMu.Lock()
319	defer o.handlersMu.Unlock()
320	o.onConnectorId = append(o.onConnectorId, handler)
321}
322
323// handlersForConnectorId returns the handlers registered for connector_id, taken
324// under the lock so a handler may register another handler while events are
325// being dispatched.
326func (o *WpDrmLeaseConnector) handlersForConnectorId() []func(connectorId uint32) {
327	o.handlersMu.Lock()
328	defer o.handlersMu.Unlock()
329	return o.onConnectorId
330}
331
332// OnDone registers a handler for the done event.
333//
334// Handlers are appended, so a second call adds another handler rather than
335// replacing the first. Registration is safe while another goroutine dispatches.
336func (o *WpDrmLeaseConnector) OnDone(handler func()) {
337	if handler == nil {
338		return
339	}
340	o.handlersMu.Lock()
341	defer o.handlersMu.Unlock()
342	o.onDone = append(o.onDone, handler)
343}
344
345// handlersForDone returns the handlers registered for done, taken
346// under the lock so a handler may register another handler while events are
347// being dispatched.
348func (o *WpDrmLeaseConnector) handlersForDone() []func() {
349	o.handlersMu.Lock()
350	defer o.handlersMu.Unlock()
351	return o.onDone
352}
353
354// OnWithdrawn registers a handler for the withdrawn event.
355//
356// Handlers are appended, so a second call adds another handler rather than
357// replacing the first. Registration is safe while another goroutine dispatches.
358func (o *WpDrmLeaseConnector) OnWithdrawn(handler func()) {
359	if handler == nil {
360		return
361	}
362	o.handlersMu.Lock()
363	defer o.handlersMu.Unlock()
364	o.onWithdrawn = append(o.onWithdrawn, handler)
365}
366
367// handlersForWithdrawn returns the handlers registered for withdrawn, taken
368// under the lock so a handler may register another handler while events are
369// being dispatched.
370func (o *WpDrmLeaseConnector) handlersForWithdrawn() []func() {
371	o.handlersMu.Lock()
372	defer o.handlersMu.Unlock()
373	return o.onWithdrawn
374}
375
376// EventSignature returns the declared event argument types in wire order.
377func (o *WpDrmLeaseConnector) EventSignature(opcode uint16) (string, bool) {
378	switch opcode {
379	case 0:
380		return "string,", true
381	case 1:
382		return "string,", true
383	case 2:
384		return "uint,", true
385	case 3:
386		return "", true
387	case 4:
388		return "", true
389	default:
390		return "", false
391	}
392}
393
394// Dispatch decodes one event on wp_drm_lease_connector_v1 and calls the registered handlers.
395func (o *WpDrmLeaseConnector) Dispatch(event *wl.Event) {
396	switch event.Opcode {
397	case 0: // name
398		name := event.String()
399
400		for i, handler := range o.handlersForName() {
401			_ = i
402			handler(name)
403		}
404	case 1: // description
405		description := event.String()
406
407		for i, handler := range o.handlersForDescription() {
408			_ = i
409			handler(description)
410		}
411	case 2: // connector_id
412		connectorId := event.Uint32()
413
414		for i, handler := range o.handlersForConnectorId() {
415			_ = i
416			handler(connectorId)
417		}
418	case 3: // done
419
420		for i, handler := range o.handlersForDone() {
421			_ = i
422			handler()
423		}
424	case 4: // withdrawn
425
426		for i, handler := range o.handlersForWithdrawn() {
427			_ = i
428			handler()
429		}
430	default:
431	}
432}
433
434// WpDrmLeaseRequestInterface is the protocol interface name.
435const WpDrmLeaseRequestInterface = "wp_drm_lease_request_v1"
436
437// WpDrmLeaseRequest is the generated binding for wp_drm_lease_request_v1 version 1.
438type WpDrmLeaseRequest struct {
439	wl.BaseProxy
440}
441
442// NewWpDrmLeaseRequest returns an unbound WpDrmLeaseRequest.
443func NewWpDrmLeaseRequest(ctx *wl.Context) *WpDrmLeaseRequest {
444	obj := &WpDrmLeaseRequest{}
445	obj.SetContext(ctx)
446	ctx.Register(obj)
447	return obj
448}
449
450// Indicates that the client would like to lease the given connector. This is only used as a suggestion, the compositor may choose to include any resources in the lease it issues, or change the set of leased resources at any time. Compositors are however encouraged to include the requested connector and other resources necessary to drive the connected output in the lease. Requesting a connector that was created from a different lease device than this lease request raises the wrong_device error. Requesting a connector twice will raise the duplicate_connector error.
451func (o *WpDrmLeaseRequest) RequestConnector(connector *WpDrmLeaseConnector) error {
452	var arg0 wl.Object
453	if connector != nil {
454		arg0 = connector
455	}
456	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_drm_lease_request_v1.request_connector"}, wl.ArgObject(arg0)); err != nil {
457		return err
458	}
459	return nil
460}
461
462// Submits the lease request and creates a new wp_drm_lease_v1 object. After calling submit the compositor will immediately destroy this object, issuing any more requests will cause a wl_display error. The compositor doesn't make any guarantees about the events of the lease object, clients cannot expect an immediate response. Not requesting any connectors before submitting the lease request will raise the empty_lease error.
463func (o *WpDrmLeaseRequest) Submit() (*WpDrmLease, error) {
464	child := &WpDrmLease{}
465	child.SetContext(o.Context())
466	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wp_drm_lease_request_v1.submit", Destructor: true, Child: child}, wl.ArgObject(child)); err != nil {
467		return nil, err
468	}
469	return child, nil
470}
471
472// EventSignature returns the declared event argument types in wire order.
473func (o *WpDrmLeaseRequest) EventSignature(opcode uint16) (string, bool) {
474	switch opcode {
475	default:
476		return "", false
477	}
478}
479
480// Dispatch decodes one event on wp_drm_lease_request_v1 and calls the registered handlers.
481func (o *WpDrmLeaseRequest) Dispatch(event *wl.Event) {
482	switch event.Opcode {
483	default:
484	}
485}
486
487// WpDrmLeaseInterface is the protocol interface name.
488const WpDrmLeaseInterface = "wp_drm_lease_v1"
489
490// WpDrmLease is the generated binding for wp_drm_lease_v1 version 1.
491type WpDrmLease struct {
492	wl.BaseProxy
493	// handlersMu guards the handler slices: a client may register or replace
494	// handlers while another goroutine dispatches events.
495	handlersMu sync.Mutex
496	onLeaseFd  []func(leasedFd *wl.OwnedFD)
497	onFinished []func()
498}
499
500// NewWpDrmLease returns an unbound WpDrmLease.
501func NewWpDrmLease(ctx *wl.Context) *WpDrmLease {
502	obj := &WpDrmLease{}
503	obj.SetContext(ctx)
504	ctx.Register(obj)
505	return obj
506}
507
508// The client should send this to indicate that it no longer wishes to use this lease. The compositor should use drmModeRevokeLease on the appropriate file descriptor, if necessary. Upon destruction, the compositor should advertise the connector for leasing again by sending the connector event through the wp_drm_lease_device_v1 interface.
509func (o *WpDrmLease) Destroy() error {
510	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wp_drm_lease_v1.destroy", Destructor: true}); err != nil {
511		return err
512	}
513	return nil
514}
515
516// OnLeaseFd registers a handler for the lease_fd event.
517//
518// Handlers are appended, so a second call adds another handler rather than
519// replacing the first. Registration is safe while another goroutine dispatches.
520func (o *WpDrmLease) OnLeaseFd(handler func(leasedFd *wl.OwnedFD)) {
521	if handler == nil {
522		return
523	}
524	o.handlersMu.Lock()
525	defer o.handlersMu.Unlock()
526	o.onLeaseFd = append(o.onLeaseFd, handler)
527}
528
529// handlersForLeaseFd returns the handlers registered for lease_fd, taken
530// under the lock so a handler may register another handler while events are
531// being dispatched.
532func (o *WpDrmLease) handlersForLeaseFd() []func(leasedFd *wl.OwnedFD) {
533	o.handlersMu.Lock()
534	defer o.handlersMu.Unlock()
535	return o.onLeaseFd
536}
537
538// OnFinished registers a handler for the finished event.
539//
540// Handlers are appended, so a second call adds another handler rather than
541// replacing the first. Registration is safe while another goroutine dispatches.
542func (o *WpDrmLease) OnFinished(handler func()) {
543	if handler == nil {
544		return
545	}
546	o.handlersMu.Lock()
547	defer o.handlersMu.Unlock()
548	o.onFinished = append(o.onFinished, handler)
549}
550
551// handlersForFinished returns the handlers registered for finished, taken
552// under the lock so a handler may register another handler while events are
553// being dispatched.
554func (o *WpDrmLease) handlersForFinished() []func() {
555	o.handlersMu.Lock()
556	defer o.handlersMu.Unlock()
557	return o.onFinished
558}
559
560// EventSignature returns the declared event argument types in wire order.
561func (o *WpDrmLease) EventSignature(opcode uint16) (string, bool) {
562	switch opcode {
563	case 0:
564		return "fd,", true
565	case 1:
566		return "", true
567	default:
568		return "", false
569	}
570}
571
572// Dispatch decodes one event on wp_drm_lease_v1 and calls the registered handlers.
573func (o *WpDrmLease) Dispatch(event *wl.Event) {
574	switch event.Opcode {
575	case 0: // lease_fd
576		leasedFd := event.FD()
577		ownedleasedFd := leasedFd
578		defer ownedleasedFd.Close()
579
580		for i, handler := range o.handlersForLeaseFd() {
581			if i > 0 {
582				leasedFd = nil
583			}
584			handler(leasedFd)
585		}
586	case 1: // finished
587
588		for i, handler := range o.handlersForFinished() {
589			_ = i
590			handler()
591		}
592	default:
593	}
594}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 8

↑↓ moveenter openesc close