detached 1a6c6c9

wlrdatacontrol_generated.go RawHistoryFolder

1// Code generated by wlbgen. DO NOT EDIT.
2// Protocol: wlr_data_control_unstable_v1
3// Source: wlr-data-control-unstable-v1.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2018 Simon Ser
7// Copyright © 2019 Ivan Molodetskikh
8//
9// Permission to use, copy, modify, distribute, and sell this
10// software and its documentation for any purpose is hereby granted
11// without fee, provided that the above copyright notice appear in
12// all copies and that both that copyright notice and this permission
13// notice appear in supporting documentation, and that the name of
14// the copyright holders not be used in advertising or publicity
15// pertaining to distribution of the software without specific,
16// written prior permission.  The copyright holders make no
17// representations about the suitability of this software for any
18// purpose.  It is provided "as is" without express or implied
19// warranty.
20//
21// THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
22// SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
23// FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
24// SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
25// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
26// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
27// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
28// THIS SOFTWARE.
29
30package wlrdatacontrol
31
32import (
33	"sync"
34
35	cross_wl_seat "github.com/bnema/go-wayland-bindings/client/wayland"
36	"github.com/bnema/wlturbo/wl"
37)
38
39// ERROR_USED_SOURCE is the error used_source value.
40const ERROR_USED_SOURCE = 1
41
42// ERROR_INVALID_OFFER is the error invalid_offer value.
43const ERROR_INVALID_OFFER = 1
44
45// DataControlManagerInterface is the protocol interface name.
46const DataControlManagerInterface = "zwlr_data_control_manager_v1"
47
48// DataControlManager is the generated binding for zwlr_data_control_manager_v1 version 2.
49type DataControlManager struct {
50	wl.BaseProxy
51}
52
53// NewDataControlManager returns an unbound DataControlManager.
54func NewDataControlManager(ctx *wl.Context) *DataControlManager {
55	obj := &DataControlManager{}
56	obj.SetContext(ctx)
57	ctx.Register(obj)
58	return obj
59}
60
61// Create a new data source.
62func (o *DataControlManager) CreateDataSource() (*DataControlSource, error) {
63	child := &DataControlSource{}
64	child.SetContext(o.Context())
65	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_data_control_manager_v1.create_data_source", Child: child}, wl.ArgObject(child)); err != nil {
66		return nil, err
67	}
68	return child, nil
69}
70
71// Create a data device that can be used to manage a seat's selection.
72func (o *DataControlManager) GetDataDevice(seat *cross_wl_seat.Seat) (*DataControlDevice, error) {
73	var arg1 wl.Object
74	if seat != nil {
75		arg1 = seat
76	}
77	child := &DataControlDevice{}
78	child.SetContext(o.Context())
79	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_data_control_manager_v1.get_data_device", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
80		return nil, err
81	}
82	return child, nil
83}
84
85// All objects created by the manager will still remain valid, until their appropriate destroy request has been called.
86func (o *DataControlManager) Destroy() error {
87	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_data_control_manager_v1.destroy", Destructor: true}); err != nil {
88		return err
89	}
90	return nil
91}
92
93// EventSignature returns the declared event argument types in wire order.
94func (o *DataControlManager) EventSignature(opcode uint16) (string, bool) {
95	switch opcode {
96	default:
97		return "", false
98	}
99}
100
101// Dispatch decodes one event on zwlr_data_control_manager_v1 and calls the registered handlers.
102func (o *DataControlManager) Dispatch(event *wl.Event) {
103	switch event.Opcode {
104	default:
105	}
106}
107
108// DataControlDeviceInterface is the protocol interface name.
109const DataControlDeviceInterface = "zwlr_data_control_device_v1"
110
111// DataControlDevice is the generated binding for zwlr_data_control_device_v1 version 2.
112type DataControlDevice struct {
113	wl.BaseProxy
114	// handlersMu guards the handler slices: a client may register or replace
115	// handlers while another goroutine dispatches events.
116	handlersMu         sync.Mutex
117	onDataOffer        []func(idObject *DataControlOffer)
118	onSelection        []func(idID uint32)
119	onFinished         []func()
120	onPrimarySelection []func(idID uint32)
121}
122
123// NewDataControlDevice returns an unbound DataControlDevice.
124func NewDataControlDevice(ctx *wl.Context) *DataControlDevice {
125	obj := &DataControlDevice{}
126	obj.SetContext(ctx)
127	ctx.Register(obj)
128	return obj
129}
130
131// This request asks the compositor to set the selection to the data from the source on behalf of the client. The given source may not be used in any further set_selection or set_primary_selection requests. Attempting to use a previously used source is a protocol error. To unset the selection, set the source to NULL.
132func (o *DataControlDevice) SetSelection(source *DataControlSource) error {
133	var arg0 wl.Object
134	if source != nil {
135		arg0 = source
136	}
137	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_data_control_device_v1.set_selection"}, wl.ArgObject(arg0)); err != nil {
138		return err
139	}
140	return nil
141}
142
143// Destroys the data device object.
144func (o *DataControlDevice) Destroy() error {
145	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_data_control_device_v1.destroy", Destructor: true}); err != nil {
146		return err
147	}
148	return nil
149}
150
151// This request asks the compositor to set the primary selection to the data from the source on behalf of the client. The given source may not be used in any further set_selection or set_primary_selection requests. Attempting to use a previously used source is a protocol error. To unset the primary selection, set the source to NULL. The compositor will ignore this request if it does not support primary selection.
152func (o *DataControlDevice) SetPrimarySelection(source *DataControlSource) error {
153	var arg0 wl.Object
154	if source != nil {
155		arg0 = source
156	}
157	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "zwlr_data_control_device_v1.set_primary_selection", Since: 2}, wl.ArgObject(arg0)); err != nil {
158		return err
159	}
160	return nil
161}
162
163// OnDataOffer registers a handler for the data_offer event.
164//
165// Handlers are appended, so a second call adds another handler rather than
166// replacing the first. Registration is safe while another goroutine dispatches.
167func (o *DataControlDevice) OnDataOffer(handler func(idObject *DataControlOffer)) {
168	if handler == nil {
169		return
170	}
171	o.handlersMu.Lock()
172	defer o.handlersMu.Unlock()
173	o.onDataOffer = append(o.onDataOffer, handler)
174}
175
176// handlersForDataOffer returns the handlers registered for data_offer, taken
177// under the lock so a handler may register another handler while events are
178// being dispatched.
179func (o *DataControlDevice) handlersForDataOffer() []func(idObject *DataControlOffer) {
180	o.handlersMu.Lock()
181	defer o.handlersMu.Unlock()
182	return o.onDataOffer
183}
184
185// OnSelection registers a handler for the selection event.
186//
187// Handlers are appended, so a second call adds another handler rather than
188// replacing the first. Registration is safe while another goroutine dispatches.
189func (o *DataControlDevice) OnSelection(handler func(idID uint32)) {
190	if handler == nil {
191		return
192	}
193	o.handlersMu.Lock()
194	defer o.handlersMu.Unlock()
195	o.onSelection = append(o.onSelection, handler)
196}
197
198// handlersForSelection returns the handlers registered for selection, taken
199// under the lock so a handler may register another handler while events are
200// being dispatched.
201func (o *DataControlDevice) handlersForSelection() []func(idID uint32) {
202	o.handlersMu.Lock()
203	defer o.handlersMu.Unlock()
204	return o.onSelection
205}
206
207// OnFinished registers a handler for the finished event.
208//
209// Handlers are appended, so a second call adds another handler rather than
210// replacing the first. Registration is safe while another goroutine dispatches.
211func (o *DataControlDevice) OnFinished(handler func()) {
212	if handler == nil {
213		return
214	}
215	o.handlersMu.Lock()
216	defer o.handlersMu.Unlock()
217	o.onFinished = append(o.onFinished, handler)
218}
219
220// handlersForFinished returns the handlers registered for finished, taken
221// under the lock so a handler may register another handler while events are
222// being dispatched.
223func (o *DataControlDevice) handlersForFinished() []func() {
224	o.handlersMu.Lock()
225	defer o.handlersMu.Unlock()
226	return o.onFinished
227}
228
229// OnPrimarySelection registers a handler for the primary_selection event.
230//
231// Handlers are appended, so a second call adds another handler rather than
232// replacing the first. Registration is safe while another goroutine dispatches.
233func (o *DataControlDevice) OnPrimarySelection(handler func(idID uint32)) {
234	if handler == nil {
235		return
236	}
237	o.handlersMu.Lock()
238	defer o.handlersMu.Unlock()
239	o.onPrimarySelection = append(o.onPrimarySelection, handler)
240}
241
242// handlersForPrimarySelection returns the handlers registered for primary_selection, taken
243// under the lock so a handler may register another handler while events are
244// being dispatched.
245func (o *DataControlDevice) handlersForPrimarySelection() []func(idID uint32) {
246	o.handlersMu.Lock()
247	defer o.handlersMu.Unlock()
248	return o.onPrimarySelection
249}
250
251// EventSignature returns the declared event argument types in wire order.
252func (o *DataControlDevice) EventSignature(opcode uint16) (string, bool) {
253	switch opcode {
254	case 0:
255		return "new_id,", true
256	case 1:
257		return "object,", true
258	case 2:
259		return "", true
260	case 3:
261		return "object,", true
262	default:
263		return "", false
264	}
265}
266
267// Dispatch decodes one event on zwlr_data_control_device_v1 and calls the registered handlers.
268func (o *DataControlDevice) Dispatch(event *wl.Event) {
269	switch event.Opcode {
270	case 0: // data_offer
271		idID := event.Uint32()
272		idObject := &DataControlOffer{}
273		idObject.SetContext(o.Context())
274		idObject.SetID(idID)
275		idObject.SetVersion(o.Version())
276		o.Context().Register(idObject)
277
278		for i, handler := range o.handlersForDataOffer() {
279			_ = i
280			handler(idObject)
281		}
282	case 1: // selection
283		idID := event.Uint32()
284
285		for i, handler := range o.handlersForSelection() {
286			_ = i
287			handler(idID)
288		}
289	case 2: // finished
290
291		for i, handler := range o.handlersForFinished() {
292			_ = i
293			handler()
294		}
295	case 3: // primary_selection
296		idID := event.Uint32()
297
298		for i, handler := range o.handlersForPrimarySelection() {
299			_ = i
300			handler(idID)
301		}
302	default:
303	}
304}
305
306// DataControlSourceInterface is the protocol interface name.
307const DataControlSourceInterface = "zwlr_data_control_source_v1"
308
309// DataControlSource is the generated binding for zwlr_data_control_source_v1 version 1.
310type DataControlSource struct {
311	wl.BaseProxy
312	// handlersMu guards the handler slices: a client may register or replace
313	// handlers while another goroutine dispatches events.
314	handlersMu  sync.Mutex
315	onSend      []func(mimeType string, fd *wl.OwnedFD)
316	onCancelled []func()
317}
318
319// NewDataControlSource returns an unbound DataControlSource.
320func NewDataControlSource(ctx *wl.Context) *DataControlSource {
321	obj := &DataControlSource{}
322	obj.SetContext(ctx)
323	ctx.Register(obj)
324	return obj
325}
326
327// This request adds a MIME type to the set of MIME types advertised to targets. Can be called several times to offer multiple types. Calling this after wlr_data_control_device.set_selection is a protocol error.
328func (o *DataControlSource) Offer(mimeType string) error {
329	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_data_control_source_v1.offer"}, wl.ArgString(mimeType)); err != nil {
330		return err
331	}
332	return nil
333}
334
335// Destroys the data source object.
336func (o *DataControlSource) Destroy() error {
337	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_data_control_source_v1.destroy", Destructor: true}); err != nil {
338		return err
339	}
340	return nil
341}
342
343// OnSend registers a handler for the send event.
344//
345// Handlers are appended, so a second call adds another handler rather than
346// replacing the first. Registration is safe while another goroutine dispatches.
347func (o *DataControlSource) OnSend(handler func(mimeType string, fd *wl.OwnedFD)) {
348	if handler == nil {
349		return
350	}
351	o.handlersMu.Lock()
352	defer o.handlersMu.Unlock()
353	o.onSend = append(o.onSend, handler)
354}
355
356// handlersForSend returns the handlers registered for send, taken
357// under the lock so a handler may register another handler while events are
358// being dispatched.
359func (o *DataControlSource) handlersForSend() []func(mimeType string, fd *wl.OwnedFD) {
360	o.handlersMu.Lock()
361	defer o.handlersMu.Unlock()
362	return o.onSend
363}
364
365// OnCancelled registers a handler for the cancelled event.
366//
367// Handlers are appended, so a second call adds another handler rather than
368// replacing the first. Registration is safe while another goroutine dispatches.
369func (o *DataControlSource) OnCancelled(handler func()) {
370	if handler == nil {
371		return
372	}
373	o.handlersMu.Lock()
374	defer o.handlersMu.Unlock()
375	o.onCancelled = append(o.onCancelled, handler)
376}
377
378// handlersForCancelled returns the handlers registered for cancelled, taken
379// under the lock so a handler may register another handler while events are
380// being dispatched.
381func (o *DataControlSource) handlersForCancelled() []func() {
382	o.handlersMu.Lock()
383	defer o.handlersMu.Unlock()
384	return o.onCancelled
385}
386
387// EventSignature returns the declared event argument types in wire order.
388func (o *DataControlSource) EventSignature(opcode uint16) (string, bool) {
389	switch opcode {
390	case 0:
391		return "string,fd,", true
392	case 1:
393		return "", true
394	default:
395		return "", false
396	}
397}
398
399// Dispatch decodes one event on zwlr_data_control_source_v1 and calls the registered handlers.
400func (o *DataControlSource) Dispatch(event *wl.Event) {
401	switch event.Opcode {
402	case 0: // send
403		mimeType := event.String()
404		fd := event.FD()
405		ownedfd := fd
406		defer ownedfd.Close()
407
408		for i, handler := range o.handlersForSend() {
409			if i > 0 {
410				fd = nil
411			}
412			handler(mimeType, fd)
413		}
414	case 1: // cancelled
415
416		for i, handler := range o.handlersForCancelled() {
417			_ = i
418			handler()
419		}
420	default:
421	}
422}
423
424// DataControlOfferInterface is the protocol interface name.
425const DataControlOfferInterface = "zwlr_data_control_offer_v1"
426
427// DataControlOffer is the generated binding for zwlr_data_control_offer_v1 version 1.
428type DataControlOffer struct {
429	wl.BaseProxy
430	// handlersMu guards the handler slices: a client may register or replace
431	// handlers while another goroutine dispatches events.
432	handlersMu sync.Mutex
433	onOffer    []func(mimeType string)
434}
435
436// NewDataControlOffer returns an unbound DataControlOffer.
437func NewDataControlOffer(ctx *wl.Context) *DataControlOffer {
438	obj := &DataControlOffer{}
439	obj.SetContext(ctx)
440	ctx.Register(obj)
441	return obj
442}
443
444// To transfer the offered data, the client issues this request and indicates the MIME type it wants to receive. The transfer happens through the passed file descriptor (typically created with the pipe system call). The source client writes the data in the MIME type representation requested and then closes the file descriptor. The receiving client reads from the read end of the pipe until EOF and then closes its end, at which point the transfer is complete. This request may happen multiple times for different MIME types.
445func (o *DataControlOffer) Receive(mimeType string, fd int) error {
446	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "zwlr_data_control_offer_v1.receive", FDs: []int{fd}}, wl.ArgString(mimeType), wl.ArgFD()); err != nil {
447		return err
448	}
449	return nil
450}
451
452// Destroys the data offer object.
453func (o *DataControlOffer) Destroy() error {
454	if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "zwlr_data_control_offer_v1.destroy", Destructor: true}); err != nil {
455		return err
456	}
457	return nil
458}
459
460// OnOffer registers a handler for the offer event.
461//
462// Handlers are appended, so a second call adds another handler rather than
463// replacing the first. Registration is safe while another goroutine dispatches.
464func (o *DataControlOffer) OnOffer(handler func(mimeType string)) {
465	if handler == nil {
466		return
467	}
468	o.handlersMu.Lock()
469	defer o.handlersMu.Unlock()
470	o.onOffer = append(o.onOffer, handler)
471}
472
473// handlersForOffer returns the handlers registered for offer, taken
474// under the lock so a handler may register another handler while events are
475// being dispatched.
476func (o *DataControlOffer) handlersForOffer() []func(mimeType string) {
477	o.handlersMu.Lock()
478	defer o.handlersMu.Unlock()
479	return o.onOffer
480}
481
482// EventSignature returns the declared event argument types in wire order.
483func (o *DataControlOffer) EventSignature(opcode uint16) (string, bool) {
484	switch opcode {
485	case 0:
486		return "string,", true
487	default:
488		return "", false
489	}
490}
491
492// Dispatch decodes one event on zwlr_data_control_offer_v1 and calls the registered handlers.
493func (o *DataControlOffer) Dispatch(event *wl.Event) {
494	switch event.Opcode {
495	case 0: // offer
496		mimeType := event.String()
497
498		for i, handler := range o.handlersForOffer() {
499			_ = i
500			handler(mimeType)
501		}
502	default:
503	}
504}

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 1

↑↓ moveenter openesc close