1// Code generated by wlturbo-scanner. DO NOT EDIT.
2// Protocol: wayland
3// Source: wayland.xml
4
5// Upstream protocol copyright and license:
6// Copyright © 2008-2011 Kristian Høgsberg
7// Copyright © 2010-2011 Intel Corporation
8// Copyright © 2012-2013 Collabora, Ltd.
9//
10// Permission is hereby granted, free of charge, to any person
11// obtaining a copy of this software and associated documentation files
12// (the "Software"), to deal in the Software without restriction,
13// including without limitation the rights to use, copy, modify, merge,
14// publish, distribute, sublicense, and/or sell copies of the Software,
15// and to permit persons to whom the Software is furnished to do so,
16// subject to the following conditions:
17//
18// The above copyright notice and this permission notice (including the
19// next paragraph) shall be included in all copies or substantial
20// portions of the Software.
21//
22// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
26// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
28// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29// SOFTWARE.
30
31package core
32
33import (
34 "sync"
35
36 "github.com/bnema/wlturbo/wl"
37)
38
39// WL_SHM_POOL_ERROR_INVALID_FORMAT is the error invalid_format value.
40const WL_SHM_POOL_ERROR_INVALID_FORMAT = 0
41
42// WL_SHM_POOL_ERROR_INVALID_STRIDE is the error invalid_stride value.
43const WL_SHM_POOL_ERROR_INVALID_STRIDE = 1
44
45// WL_SHM_ERROR_INVALID_FORMAT is the error invalid_format value.
46const WL_SHM_ERROR_INVALID_FORMAT = 0
47
48// WL_SHM_ERROR_INVALID_STRIDE is the error invalid_stride value.
49const WL_SHM_ERROR_INVALID_STRIDE = 1
50
51// ERROR_INVALID_FD is the error invalid_fd value.
52const ERROR_INVALID_FD = 2
53
54// FORMAT_ARGB8888 is the format argb8888 value.
55const FORMAT_ARGB8888 = 0
56
57// FORMAT_XRGB8888 is the format xrgb8888 value.
58const FORMAT_XRGB8888 = 1
59
60// FORMAT_C8 is the format c8 value.
61const FORMAT_C8 = 0x20203843
62
63// FORMAT_RGB332 is the format rgb332 value.
64const FORMAT_RGB332 = 0x38424752
65
66// FORMAT_BGR233 is the format bgr233 value.
67const FORMAT_BGR233 = 0x38524742
68
69// FORMAT_XRGB4444 is the format xrgb4444 value.
70const FORMAT_XRGB4444 = 0x32315258
71
72// FORMAT_XBGR4444 is the format xbgr4444 value.
73const FORMAT_XBGR4444 = 0x32314258
74
75// FORMAT_RGBX4444 is the format rgbx4444 value.
76const FORMAT_RGBX4444 = 0x32315852
77
78// FORMAT_BGRX4444 is the format bgrx4444 value.
79const FORMAT_BGRX4444 = 0x32315842
80
81// FORMAT_ARGB4444 is the format argb4444 value.
82const FORMAT_ARGB4444 = 0x32315241
83
84// FORMAT_ABGR4444 is the format abgr4444 value.
85const FORMAT_ABGR4444 = 0x32314241
86
87// FORMAT_RGBA4444 is the format rgba4444 value.
88const FORMAT_RGBA4444 = 0x32314152
89
90// FORMAT_BGRA4444 is the format bgra4444 value.
91const FORMAT_BGRA4444 = 0x32314142
92
93// FORMAT_XRGB1555 is the format xrgb1555 value.
94const FORMAT_XRGB1555 = 0x35315258
95
96// FORMAT_XBGR1555 is the format xbgr1555 value.
97const FORMAT_XBGR1555 = 0x35314258
98
99// FORMAT_RGBX5551 is the format rgbx5551 value.
100const FORMAT_RGBX5551 = 0x35315852
101
102// FORMAT_BGRX5551 is the format bgrx5551 value.
103const FORMAT_BGRX5551 = 0x35315842
104
105// FORMAT_ARGB1555 is the format argb1555 value.
106const FORMAT_ARGB1555 = 0x35315241
107
108// FORMAT_ABGR1555 is the format abgr1555 value.
109const FORMAT_ABGR1555 = 0x35314241
110
111// FORMAT_RGBA5551 is the format rgba5551 value.
112const FORMAT_RGBA5551 = 0x35314152
113
114// FORMAT_BGRA5551 is the format bgra5551 value.
115const FORMAT_BGRA5551 = 0x35314142
116
117// FORMAT_RGB565 is the format rgb565 value.
118const FORMAT_RGB565 = 0x36314752
119
120// FORMAT_BGR565 is the format bgr565 value.
121const FORMAT_BGR565 = 0x36314742
122
123// FORMAT_RGB888 is the format rgb888 value.
124const FORMAT_RGB888 = 0x34324752
125
126// FORMAT_BGR888 is the format bgr888 value.
127const FORMAT_BGR888 = 0x34324742
128
129// FORMAT_XBGR8888 is the format xbgr8888 value.
130const FORMAT_XBGR8888 = 0x34324258
131
132// FORMAT_RGBX8888 is the format rgbx8888 value.
133const FORMAT_RGBX8888 = 0x34325852
134
135// FORMAT_BGRX8888 is the format bgrx8888 value.
136const FORMAT_BGRX8888 = 0x34325842
137
138// FORMAT_ABGR8888 is the format abgr8888 value.
139const FORMAT_ABGR8888 = 0x34324241
140
141// FORMAT_RGBA8888 is the format rgba8888 value.
142const FORMAT_RGBA8888 = 0x34324152
143
144// FORMAT_BGRA8888 is the format bgra8888 value.
145const FORMAT_BGRA8888 = 0x34324142
146
147// FORMAT_XRGB2101010 is the format xrgb2101010 value.
148const FORMAT_XRGB2101010 = 0x30335258
149
150// FORMAT_XBGR2101010 is the format xbgr2101010 value.
151const FORMAT_XBGR2101010 = 0x30334258
152
153// FORMAT_RGBX1010102 is the format rgbx1010102 value.
154const FORMAT_RGBX1010102 = 0x30335852
155
156// FORMAT_BGRX1010102 is the format bgrx1010102 value.
157const FORMAT_BGRX1010102 = 0x30335842
158
159// FORMAT_ARGB2101010 is the format argb2101010 value.
160const FORMAT_ARGB2101010 = 0x30335241
161
162// FORMAT_ABGR2101010 is the format abgr2101010 value.
163const FORMAT_ABGR2101010 = 0x30334241
164
165// FORMAT_RGBA1010102 is the format rgba1010102 value.
166const FORMAT_RGBA1010102 = 0x30334152
167
168// FORMAT_BGRA1010102 is the format bgra1010102 value.
169const FORMAT_BGRA1010102 = 0x30334142
170
171// FORMAT_YUYV is the format yuyv value.
172const FORMAT_YUYV = 0x56595559
173
174// FORMAT_YVYU is the format yvyu value.
175const FORMAT_YVYU = 0x55595659
176
177// FORMAT_UYVY is the format uyvy value.
178const FORMAT_UYVY = 0x59565955
179
180// FORMAT_VYUY is the format vyuy value.
181const FORMAT_VYUY = 0x59555956
182
183// FORMAT_AYUV is the format ayuv value.
184const FORMAT_AYUV = 0x56555941
185
186// FORMAT_NV12 is the format nv12 value.
187const FORMAT_NV12 = 0x3231564e
188
189// FORMAT_NV21 is the format nv21 value.
190const FORMAT_NV21 = 0x3132564e
191
192// FORMAT_NV16 is the format nv16 value.
193const FORMAT_NV16 = 0x3631564e
194
195// FORMAT_NV61 is the format nv61 value.
196const FORMAT_NV61 = 0x3136564e
197
198// FORMAT_YUV410 is the format yuv410 value.
199const FORMAT_YUV410 = 0x39565559
200
201// FORMAT_YVU410 is the format yvu410 value.
202const FORMAT_YVU410 = 0x39555659
203
204// FORMAT_YUV411 is the format yuv411 value.
205const FORMAT_YUV411 = 0x31315559
206
207// FORMAT_YVU411 is the format yvu411 value.
208const FORMAT_YVU411 = 0x31315659
209
210// FORMAT_YUV420 is the format yuv420 value.
211const FORMAT_YUV420 = 0x32315559
212
213// FORMAT_YVU420 is the format yvu420 value.
214const FORMAT_YVU420 = 0x32315659
215
216// FORMAT_YUV422 is the format yuv422 value.
217const FORMAT_YUV422 = 0x36315559
218
219// FORMAT_YVU422 is the format yvu422 value.
220const FORMAT_YVU422 = 0x36315659
221
222// FORMAT_YUV444 is the format yuv444 value.
223const FORMAT_YUV444 = 0x34325559
224
225// FORMAT_YVU444 is the format yvu444 value.
226const FORMAT_YVU444 = 0x34325659
227
228// FORMAT_R8 is the format r8 value.
229const FORMAT_R8 = 0x20203852
230
231// FORMAT_R16 is the format r16 value.
232const FORMAT_R16 = 0x20363152
233
234// FORMAT_RG88 is the format rg88 value.
235const FORMAT_RG88 = 0x38384752
236
237// FORMAT_GR88 is the format gr88 value.
238const FORMAT_GR88 = 0x38385247
239
240// FORMAT_RG1616 is the format rg1616 value.
241const FORMAT_RG1616 = 0x32334752
242
243// FORMAT_GR1616 is the format gr1616 value.
244const FORMAT_GR1616 = 0x32335247
245
246// FORMAT_XRGB16161616F is the format xrgb16161616f value.
247const FORMAT_XRGB16161616F = 0x48345258
248
249// FORMAT_XBGR16161616F is the format xbgr16161616f value.
250const FORMAT_XBGR16161616F = 0x48344258
251
252// FORMAT_ARGB16161616F is the format argb16161616f value.
253const FORMAT_ARGB16161616F = 0x48345241
254
255// FORMAT_ABGR16161616F is the format abgr16161616f value.
256const FORMAT_ABGR16161616F = 0x48344241
257
258// FORMAT_XYUV8888 is the format xyuv8888 value.
259const FORMAT_XYUV8888 = 0x56555958
260
261// FORMAT_VUY888 is the format vuy888 value.
262const FORMAT_VUY888 = 0x34325556
263
264// FORMAT_VUY101010 is the format vuy101010 value.
265const FORMAT_VUY101010 = 0x30335556
266
267// FORMAT_Y210 is the format y210 value.
268const FORMAT_Y210 = 0x30313259
269
270// FORMAT_Y212 is the format y212 value.
271const FORMAT_Y212 = 0x32313259
272
273// FORMAT_Y216 is the format y216 value.
274const FORMAT_Y216 = 0x36313259
275
276// FORMAT_Y410 is the format y410 value.
277const FORMAT_Y410 = 0x30313459
278
279// FORMAT_Y412 is the format y412 value.
280const FORMAT_Y412 = 0x32313459
281
282// FORMAT_Y416 is the format y416 value.
283const FORMAT_Y416 = 0x36313459
284
285// FORMAT_XVYU2101010 is the format xvyu2101010 value.
286const FORMAT_XVYU2101010 = 0x30335658
287
288// FORMAT_XVYU12_16161616 is the format xvyu12_16161616 value.
289const FORMAT_XVYU12_16161616 = 0x36335658
290
291// FORMAT_XVYU16161616 is the format xvyu16161616 value.
292const FORMAT_XVYU16161616 = 0x38345658
293
294// FORMAT_Y0L0 is the format y0l0 value.
295const FORMAT_Y0L0 = 0x304c3059
296
297// FORMAT_X0L0 is the format x0l0 value.
298const FORMAT_X0L0 = 0x304c3058
299
300// FORMAT_Y0L2 is the format y0l2 value.
301const FORMAT_Y0L2 = 0x324c3059
302
303// FORMAT_X0L2 is the format x0l2 value.
304const FORMAT_X0L2 = 0x324c3058
305
306// FORMAT_YUV420_8BIT is the format yuv420_8bit value.
307const FORMAT_YUV420_8BIT = 0x38305559
308
309// FORMAT_YUV420_10BIT is the format yuv420_10bit value.
310const FORMAT_YUV420_10BIT = 0x30315559
311
312// FORMAT_XRGB8888_A8 is the format xrgb8888_a8 value.
313const FORMAT_XRGB8888_A8 = 0x38415258
314
315// FORMAT_XBGR8888_A8 is the format xbgr8888_a8 value.
316const FORMAT_XBGR8888_A8 = 0x38414258
317
318// FORMAT_RGBX8888_A8 is the format rgbx8888_a8 value.
319const FORMAT_RGBX8888_A8 = 0x38415852
320
321// FORMAT_BGRX8888_A8 is the format bgrx8888_a8 value.
322const FORMAT_BGRX8888_A8 = 0x38415842
323
324// FORMAT_RGB888_A8 is the format rgb888_a8 value.
325const FORMAT_RGB888_A8 = 0x38413852
326
327// FORMAT_BGR888_A8 is the format bgr888_a8 value.
328const FORMAT_BGR888_A8 = 0x38413842
329
330// FORMAT_RGB565_A8 is the format rgb565_a8 value.
331const FORMAT_RGB565_A8 = 0x38413552
332
333// FORMAT_BGR565_A8 is the format bgr565_a8 value.
334const FORMAT_BGR565_A8 = 0x38413542
335
336// FORMAT_NV24 is the format nv24 value.
337const FORMAT_NV24 = 0x3432564e
338
339// FORMAT_NV42 is the format nv42 value.
340const FORMAT_NV42 = 0x3234564e
341
342// FORMAT_P210 is the format p210 value.
343const FORMAT_P210 = 0x30313250
344
345// FORMAT_P010 is the format p010 value.
346const FORMAT_P010 = 0x30313050
347
348// FORMAT_P012 is the format p012 value.
349const FORMAT_P012 = 0x32313050
350
351// FORMAT_P016 is the format p016 value.
352const FORMAT_P016 = 0x36313050
353
354// FORMAT_AXBXGXRX106106106106 is the format axbxgxrx106106106106 value.
355const FORMAT_AXBXGXRX106106106106 = 0x30314241
356
357// FORMAT_NV15 is the format nv15 value.
358const FORMAT_NV15 = 0x3531564e
359
360// FORMAT_Q410 is the format q410 value.
361const FORMAT_Q410 = 0x30313451
362
363// FORMAT_Q401 is the format q401 value.
364const FORMAT_Q401 = 0x31303451
365
366// FORMAT_XRGB16161616 is the format xrgb16161616 value.
367const FORMAT_XRGB16161616 = 0x38345258
368
369// FORMAT_XBGR16161616 is the format xbgr16161616 value.
370const FORMAT_XBGR16161616 = 0x38344258
371
372// FORMAT_ARGB16161616 is the format argb16161616 value.
373const FORMAT_ARGB16161616 = 0x38345241
374
375// FORMAT_ABGR16161616 is the format abgr16161616 value.
376const FORMAT_ABGR16161616 = 0x38344241
377
378// FORMAT_C1 is the format c1 value.
379const FORMAT_C1 = 0x20203143
380
381// FORMAT_C2 is the format c2 value.
382const FORMAT_C2 = 0x20203243
383
384// FORMAT_C4 is the format c4 value.
385const FORMAT_C4 = 0x20203443
386
387// FORMAT_D1 is the format d1 value.
388const FORMAT_D1 = 0x20203144
389
390// FORMAT_D2 is the format d2 value.
391const FORMAT_D2 = 0x20203244
392
393// FORMAT_D4 is the format d4 value.
394const FORMAT_D4 = 0x20203444
395
396// FORMAT_D8 is the format d8 value.
397const FORMAT_D8 = 0x20203844
398
399// FORMAT_R1 is the format r1 value.
400const FORMAT_R1 = 0x20203152
401
402// FORMAT_R2 is the format r2 value.
403const FORMAT_R2 = 0x20203252
404
405// FORMAT_R4 is the format r4 value.
406const FORMAT_R4 = 0x20203452
407
408// FORMAT_R10 is the format r10 value.
409const FORMAT_R10 = 0x20303152
410
411// FORMAT_R12 is the format r12 value.
412const FORMAT_R12 = 0x20323152
413
414// FORMAT_AVUY8888 is the format avuy8888 value.
415const FORMAT_AVUY8888 = 0x59555641
416
417// FORMAT_XVUY8888 is the format xvuy8888 value.
418const FORMAT_XVUY8888 = 0x59555658
419
420// FORMAT_P030 is the format p030 value.
421const FORMAT_P030 = 0x30333050
422
423// FORMAT_RGB161616 is the format rgb161616 value.
424const FORMAT_RGB161616 = 0x38344752
425
426// FORMAT_BGR161616 is the format bgr161616 value.
427const FORMAT_BGR161616 = 0x38344742
428
429// FORMAT_R16F is the format r16f value.
430const FORMAT_R16F = 0x48202052
431
432// FORMAT_GR1616F is the format gr1616f value.
433const FORMAT_GR1616F = 0x48205247
434
435// FORMAT_BGR161616F is the format bgr161616f value.
436const FORMAT_BGR161616F = 0x48524742
437
438// FORMAT_R32F is the format r32f value.
439const FORMAT_R32F = 0x46202052
440
441// FORMAT_GR3232F is the format gr3232f value.
442const FORMAT_GR3232F = 0x46205247
443
444// FORMAT_BGR323232F is the format bgr323232f value.
445const FORMAT_BGR323232F = 0x46524742
446
447// FORMAT_ABGR32323232F is the format abgr32323232f value.
448const FORMAT_ABGR32323232F = 0x46384241
449
450// FORMAT_NV20 is the format nv20 value.
451const FORMAT_NV20 = 0x3032564e
452
453// FORMAT_NV30 is the format nv30 value.
454const FORMAT_NV30 = 0x3033564e
455
456// FORMAT_S010 is the format s010 value.
457const FORMAT_S010 = 0x30313053
458
459// FORMAT_S210 is the format s210 value.
460const FORMAT_S210 = 0x30313253
461
462// FORMAT_S410 is the format s410 value.
463const FORMAT_S410 = 0x30313453
464
465// FORMAT_S012 is the format s012 value.
466const FORMAT_S012 = 0x32313053
467
468// FORMAT_S212 is the format s212 value.
469const FORMAT_S212 = 0x32313253
470
471// FORMAT_S412 is the format s412 value.
472const FORMAT_S412 = 0x32313453
473
474// FORMAT_S016 is the format s016 value.
475const FORMAT_S016 = 0x36313053
476
477// FORMAT_S216 is the format s216 value.
478const FORMAT_S216 = 0x36313253
479
480// FORMAT_S416 is the format s416 value.
481const FORMAT_S416 = 0x36313453
482
483// FORMAT_XVUY2101010 is the format xvuy2101010 value.
484const FORMAT_XVUY2101010 = 0x30335958
485
486// FORMAT_P230 is the format p230 value.
487const FORMAT_P230 = 0x30333250
488
489// FORMAT_T430 is the format t430 value.
490const FORMAT_T430 = 0x30333454
491
492// FORMAT_Y8 is the format y8 value.
493const FORMAT_Y8 = 0x59455247
494
495// FORMAT_XYYY2101010 is the format xyyy2101010 value.
496const FORMAT_XYYY2101010 = 0x34415059
497
498// ERROR_INVALID_FINISH is the error invalid_finish value.
499const ERROR_INVALID_FINISH = 0
500
501// WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK is the error invalid_action_mask value.
502const WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK = 1
503
504// ERROR_INVALID_ACTION is the error invalid_action value.
505const ERROR_INVALID_ACTION = 2
506
507// ERROR_INVALID_OFFER is the error invalid_offer value.
508const ERROR_INVALID_OFFER = 3
509
510// WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK is the error invalid_action_mask value.
511const WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK = 0
512
513// ERROR_INVALID_SOURCE is the error invalid_source value.
514const ERROR_INVALID_SOURCE = 1
515
516// WL_DATA_DEVICE_ERROR_ROLE is the error role value.
517const WL_DATA_DEVICE_ERROR_ROLE = 0
518
519// ERROR_USED_SOURCE is the error used_source value.
520const ERROR_USED_SOURCE = 1
521
522// DND_ACTION_NONE is the dnd_action none value.
523const DND_ACTION_NONE = 0
524
525// DND_ACTION_COPY is the dnd_action copy value.
526const DND_ACTION_COPY = 1
527
528// DND_ACTION_MOVE is the dnd_action move value.
529const DND_ACTION_MOVE = 2
530
531// DND_ACTION_ASK is the dnd_action ask value.
532const DND_ACTION_ASK = 4
533
534// WL_SHELL_ERROR_ROLE is the error role value.
535const WL_SHELL_ERROR_ROLE = 0
536
537// RESIZE_NONE is the resize none value.
538const RESIZE_NONE = 0
539
540// RESIZE_TOP is the resize top value.
541const RESIZE_TOP = 1
542
543// RESIZE_BOTTOM is the resize bottom value.
544const RESIZE_BOTTOM = 2
545
546// RESIZE_LEFT is the resize left value.
547const RESIZE_LEFT = 4
548
549// RESIZE_TOP_LEFT is the resize top_left value.
550const RESIZE_TOP_LEFT = 5
551
552// RESIZE_BOTTOM_LEFT is the resize bottom_left value.
553const RESIZE_BOTTOM_LEFT = 6
554
555// RESIZE_RIGHT is the resize right value.
556const RESIZE_RIGHT = 8
557
558// RESIZE_TOP_RIGHT is the resize top_right value.
559const RESIZE_TOP_RIGHT = 9
560
561// RESIZE_BOTTOM_RIGHT is the resize bottom_right value.
562const RESIZE_BOTTOM_RIGHT = 10
563
564// TRANSIENT_INACTIVE is the transient inactive value.
565const TRANSIENT_INACTIVE = 0x1
566
567// FULLSCREEN_METHOD_DEFAULT is the fullscreen_method default value.
568const FULLSCREEN_METHOD_DEFAULT = 0
569
570// FULLSCREEN_METHOD_SCALE is the fullscreen_method scale value.
571const FULLSCREEN_METHOD_SCALE = 1
572
573// FULLSCREEN_METHOD_DRIVER is the fullscreen_method driver value.
574const FULLSCREEN_METHOD_DRIVER = 2
575
576// FULLSCREEN_METHOD_FILL is the fullscreen_method fill value.
577const FULLSCREEN_METHOD_FILL = 3
578
579// ERROR_INVALID_SCALE is the error invalid_scale value.
580const ERROR_INVALID_SCALE = 0
581
582// ERROR_INVALID_TRANSFORM is the error invalid_transform value.
583const ERROR_INVALID_TRANSFORM = 1
584
585// ERROR_INVALID_SIZE is the error invalid_size value.
586const ERROR_INVALID_SIZE = 2
587
588// ERROR_INVALID_OFFSET is the error invalid_offset value.
589const ERROR_INVALID_OFFSET = 3
590
591// ERROR_DEFUNCT_ROLE_OBJECT is the error defunct_role_object value.
592const ERROR_DEFUNCT_ROLE_OBJECT = 4
593
594// ERROR_NO_BUFFER is the error no_buffer value.
595const ERROR_NO_BUFFER = 5
596
597// CAPABILITY_POINTER is the capability pointer value.
598const CAPABILITY_POINTER = 1
599
600// CAPABILITY_KEYBOARD is the capability keyboard value.
601const CAPABILITY_KEYBOARD = 2
602
603// CAPABILITY_TOUCH is the capability touch value.
604const CAPABILITY_TOUCH = 4
605
606// ERROR_MISSING_CAPABILITY is the error missing_capability value.
607const ERROR_MISSING_CAPABILITY = 0
608
609// WL_POINTER_ERROR_ROLE is the error role value.
610const WL_POINTER_ERROR_ROLE = 0
611
612// BUTTON_STATE_RELEASED is the button_state released value.
613const BUTTON_STATE_RELEASED = 0
614
615// BUTTON_STATE_PRESSED is the button_state pressed value.
616const BUTTON_STATE_PRESSED = 1
617
618// AXIS_VERTICAL_SCROLL is the axis vertical_scroll value.
619const AXIS_VERTICAL_SCROLL = 0
620
621// AXIS_HORIZONTAL_SCROLL is the axis horizontal_scroll value.
622const AXIS_HORIZONTAL_SCROLL = 1
623
624// AXIS_SOURCE_WHEEL is the axis_source wheel value.
625const AXIS_SOURCE_WHEEL = 0
626
627// AXIS_SOURCE_FINGER is the axis_source finger value.
628const AXIS_SOURCE_FINGER = 1
629
630// AXIS_SOURCE_CONTINUOUS is the axis_source continuous value.
631const AXIS_SOURCE_CONTINUOUS = 2
632
633// AXIS_SOURCE_WHEEL_TILT is the axis_source wheel_tilt value.
634const AXIS_SOURCE_WHEEL_TILT = 3
635
636// AXIS_RELATIVE_DIRECTION_IDENTICAL is the axis_relative_direction identical value.
637const AXIS_RELATIVE_DIRECTION_IDENTICAL = 0
638
639// AXIS_RELATIVE_DIRECTION_INVERTED is the axis_relative_direction inverted value.
640const AXIS_RELATIVE_DIRECTION_INVERTED = 1
641
642// KEYMAP_FORMAT_NO_KEYMAP is the keymap_format no_keymap value.
643const KEYMAP_FORMAT_NO_KEYMAP = 0
644
645// KEYMAP_FORMAT_XKB_V1 is the keymap_format xkb_v1 value.
646const KEYMAP_FORMAT_XKB_V1 = 1
647
648// KEY_STATE_RELEASED is the key_state released value.
649const KEY_STATE_RELEASED = 0
650
651// KEY_STATE_PRESSED is the key_state pressed value.
652const KEY_STATE_PRESSED = 1
653
654// KEY_STATE_REPEATED is the key_state repeated value.
655const KEY_STATE_REPEATED = 2
656
657// SUBPIXEL_UNKNOWN is the subpixel unknown value.
658const SUBPIXEL_UNKNOWN = 0
659
660// SUBPIXEL_NONE is the subpixel none value.
661const SUBPIXEL_NONE = 1
662
663// SUBPIXEL_HORIZONTAL_RGB is the subpixel horizontal_rgb value.
664const SUBPIXEL_HORIZONTAL_RGB = 2
665
666// SUBPIXEL_HORIZONTAL_BGR is the subpixel horizontal_bgr value.
667const SUBPIXEL_HORIZONTAL_BGR = 3
668
669// SUBPIXEL_VERTICAL_RGB is the subpixel vertical_rgb value.
670const SUBPIXEL_VERTICAL_RGB = 4
671
672// SUBPIXEL_VERTICAL_BGR is the subpixel vertical_bgr value.
673const SUBPIXEL_VERTICAL_BGR = 5
674
675// TRANSFORM_NORMAL is the transform normal value.
676const TRANSFORM_NORMAL = 0
677
678// TRANSFORM_90 is the transform 90 value.
679const TRANSFORM_90 = 1
680
681// TRANSFORM_180 is the transform 180 value.
682const TRANSFORM_180 = 2
683
684// TRANSFORM_270 is the transform 270 value.
685const TRANSFORM_270 = 3
686
687// TRANSFORM_FLIPPED is the transform flipped value.
688const TRANSFORM_FLIPPED = 4
689
690// TRANSFORM_FLIPPED_90 is the transform flipped_90 value.
691const TRANSFORM_FLIPPED_90 = 5
692
693// TRANSFORM_FLIPPED_180 is the transform flipped_180 value.
694const TRANSFORM_FLIPPED_180 = 6
695
696// TRANSFORM_FLIPPED_270 is the transform flipped_270 value.
697const TRANSFORM_FLIPPED_270 = 7
698
699// MODE_CURRENT is the mode current value.
700const MODE_CURRENT = 0x1
701
702// MODE_PREFERRED is the mode preferred value.
703const MODE_PREFERRED = 0x2
704
705// WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE is the error bad_surface value.
706const WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE = 0
707
708// ERROR_BAD_PARENT is the error bad_parent value.
709const ERROR_BAD_PARENT = 1
710
711// WL_SUBSURFACE_ERROR_BAD_SURFACE is the error bad_surface value.
712const WL_SUBSURFACE_ERROR_BAD_SURFACE = 0
713
714// ERROR_INVALID_ACK_REMOVE is the error invalid_ack_remove value.
715const ERROR_INVALID_ACK_REMOVE = 0
716
717// CallbackInterface is the protocol interface name.
718const CallbackInterface = "wl_callback"
719
720// Callback is the generated binding for wl_callback version 1.
721type Callback struct {
722 wl.BaseProxy
723 // handlersMu guards the handler slices: a client may register or replace
724 // handlers while another goroutine dispatches events.
725 handlersMu sync.Mutex
726 onDone []func(callbackData uint32)
727}
728
729// NewCallback returns an unbound Callback.
730func NewCallback(ctx *wl.Context) *Callback {
731 obj := &Callback{}
732 obj.SetContext(ctx)
733 ctx.Register(obj)
734 return obj
735}
736
737// OnDone registers a handler for the done event.
738//
739// Handlers are appended, so a second call adds another handler rather than
740// replacing the first. Registration is safe while another goroutine dispatches.
741func (o *Callback) OnDone(handler func(callbackData uint32)) {
742 if handler == nil {
743 return
744 }
745 o.handlersMu.Lock()
746 defer o.handlersMu.Unlock()
747 o.onDone = append(o.onDone, handler)
748}
749
750// handlersForDone returns the handlers registered for done, taken
751// under the lock so a handler may register another handler while events are
752// being dispatched.
753func (o *Callback) handlersForDone() []func(callbackData uint32) {
754 o.handlersMu.Lock()
755 defer o.handlersMu.Unlock()
756 return o.onDone
757}
758
759// EventSignature returns the declared event argument types in wire order.
760func (o *Callback) EventSignature(opcode uint16) (string, bool) {
761 switch opcode {
762 case 0:
763 return "uint,", true
764 default:
765 return "", false
766 }
767}
768
769// Dispatch decodes one event on wl_callback and calls the registered handlers.
770func (o *Callback) Dispatch(event *wl.Event) {
771 switch event.Opcode {
772 case 0: // done
773 callbackData := event.Uint32()
774
775 for i, handler := range o.handlersForDone() {
776 _ = i
777 handler(callbackData)
778 }
779 o.Context().Unregister(o)
780 default:
781 }
782}
783
784// CompositorInterface is the protocol interface name.
785const CompositorInterface = "wl_compositor"
786
787// Compositor is the generated binding for wl_compositor version 7.
788type Compositor struct {
789 wl.BaseProxy
790}
791
792// NewCompositor returns an unbound Compositor.
793func NewCompositor(ctx *wl.Context) *Compositor {
794 obj := &Compositor{}
795 obj.SetContext(ctx)
796 ctx.Register(obj)
797 return obj
798}
799
800// Ask the compositor to create a new surface.
801func (o *Compositor) CreateSurface() (*Surface, error) {
802 child := &Surface{}
803 child.SetContext(o.Context())
804 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_compositor.create_surface", Child: child}, wl.ArgObject(child)); err != nil {
805 return nil, err
806 }
807 return child, nil
808}
809
810// Ask the compositor to create a new region.
811func (o *Compositor) CreateRegion() (*Region, error) {
812 child := &Region{}
813 child.SetContext(o.Context())
814 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_compositor.create_region", Child: child}, wl.ArgObject(child)); err != nil {
815 return nil, err
816 }
817 return child, nil
818}
819
820// This request destroys the wl_compositor. This has no effect on any other objects.
821func (o *Compositor) Release() error {
822 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_compositor.release", Since: 7, Destructor: true}); err != nil {
823 return err
824 }
825 return nil
826}
827
828// EventSignature returns the declared event argument types in wire order.
829func (o *Compositor) EventSignature(opcode uint16) (string, bool) {
830 switch opcode {
831 default:
832 return "", false
833 }
834}
835
836// Dispatch decodes one event on wl_compositor and calls the registered handlers.
837func (o *Compositor) Dispatch(event *wl.Event) {
838 switch event.Opcode {
839 default:
840 }
841}
842
843// ShmPoolInterface is the protocol interface name.
844const ShmPoolInterface = "wl_shm_pool"
845
846// ShmPool is the generated binding for wl_shm_pool version 3.
847type ShmPool struct {
848 wl.BaseProxy
849}
850
851// NewShmPool returns an unbound ShmPool.
852func NewShmPool(ctx *wl.Context) *ShmPool {
853 obj := &ShmPool{}
854 obj.SetContext(ctx)
855 ctx.Register(obj)
856 return obj
857}
858
859// Create a wl_buffer object from the pool. The buffer is created offset bytes into the pool and has width and height as specified. The stride argument specifies the number of bytes from the beginning of one row to the beginning of the next. The format is the pixel format of the buffer and must be one of those advertised through the wl_shm.format event. A buffer will keep a reference to the pool it was created from so it is valid to destroy the pool immediately after creating a buffer from it.
860func (o *ShmPool) CreateBuffer(offset int32, width int32, height int32, stride int32, format uint32) (*Buffer, error) {
861 child := &Buffer{}
862 child.SetContext(o.Context())
863 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_shm_pool.create_buffer", Child: child}, wl.ArgObject(child), wl.ArgInt(offset), wl.ArgInt(width), wl.ArgInt(height), wl.ArgInt(stride), wl.ArgUint(format)); err != nil {
864 return nil, err
865 }
866 return child, nil
867}
868
869// Destroy the shared memory pool. The mmapped memory will be released when all buffers that have been created from this pool are gone.
870func (o *ShmPool) Destroy() error {
871 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_shm_pool.destroy", Destructor: true}); err != nil {
872 return err
873 }
874 return nil
875}
876
877// This request will cause the server to remap the backing memory for the pool from the file descriptor passed when the pool was created, but using the new size. This request can only be used to make the pool bigger. This request only changes the amount of bytes that are mmapped by the server and does not touch the file corresponding to the file descriptor passed at creation time. It is the client's responsibility to ensure that the file is at least as big as the new pool size.
878func (o *ShmPool) Resize(size int32) error {
879 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_shm_pool.resize"}, wl.ArgInt(size)); err != nil {
880 return err
881 }
882 return nil
883}
884
885// EventSignature returns the declared event argument types in wire order.
886func (o *ShmPool) EventSignature(opcode uint16) (string, bool) {
887 switch opcode {
888 default:
889 return "", false
890 }
891}
892
893// Dispatch decodes one event on wl_shm_pool and calls the registered handlers.
894func (o *ShmPool) Dispatch(event *wl.Event) {
895 switch event.Opcode {
896 default:
897 }
898}
899
900// ShmInterface is the protocol interface name.
901const ShmInterface = "wl_shm"
902
903// Shm is the generated binding for wl_shm version 3.
904type Shm struct {
905 wl.BaseProxy
906 // handlersMu guards the handler slices: a client may register or replace
907 // handlers while another goroutine dispatches events.
908 handlersMu sync.Mutex
909 onFormat []func(format uint32)
910}
911
912// NewShm returns an unbound Shm.
913func NewShm(ctx *wl.Context) *Shm {
914 obj := &Shm{}
915 obj.SetContext(ctx)
916 ctx.Register(obj)
917 return obj
918}
919
920// Create a new wl_shm_pool object. The pool can be used to create shared memory based buffer objects. The server will mmap size bytes of the passed file descriptor, to use as backing memory for the pool.
921func (o *Shm) CreatePool(fd int, size int32) (*ShmPool, error) {
922 child := &ShmPool{}
923 child.SetContext(o.Context())
924 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_shm.create_pool", Child: child, FDs: []int{fd}}, wl.ArgObject(child), wl.ArgFD(), wl.ArgInt(size)); err != nil {
925 return nil, err
926 }
927 return child, nil
928}
929
930// Using this request a client can tell the server that it is not going to use the shm object anymore. Objects created via this interface remain unaffected.
931func (o *Shm) Release() error {
932 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_shm.release", Since: 2, Destructor: true}); err != nil {
933 return err
934 }
935 return nil
936}
937
938// OnFormat registers a handler for the format event.
939//
940// Handlers are appended, so a second call adds another handler rather than
941// replacing the first. Registration is safe while another goroutine dispatches.
942func (o *Shm) OnFormat(handler func(format uint32)) {
943 if handler == nil {
944 return
945 }
946 o.handlersMu.Lock()
947 defer o.handlersMu.Unlock()
948 o.onFormat = append(o.onFormat, handler)
949}
950
951// handlersForFormat returns the handlers registered for format, taken
952// under the lock so a handler may register another handler while events are
953// being dispatched.
954func (o *Shm) handlersForFormat() []func(format uint32) {
955 o.handlersMu.Lock()
956 defer o.handlersMu.Unlock()
957 return o.onFormat
958}
959
960// EventSignature returns the declared event argument types in wire order.
961func (o *Shm) EventSignature(opcode uint16) (string, bool) {
962 switch opcode {
963 case 0:
964 return "uint,", true
965 default:
966 return "", false
967 }
968}
969
970// Dispatch decodes one event on wl_shm and calls the registered handlers.
971func (o *Shm) Dispatch(event *wl.Event) {
972 switch event.Opcode {
973 case 0: // format
974 format := event.Uint32()
975
976 for i, handler := range o.handlersForFormat() {
977 _ = i
978 handler(format)
979 }
980 default:
981 }
982}
983
984// BufferInterface is the protocol interface name.
985const BufferInterface = "wl_buffer"
986
987// Buffer is the generated binding for wl_buffer version 1.
988type Buffer struct {
989 wl.BaseProxy
990 // handlersMu guards the handler slices: a client may register or replace
991 // handlers while another goroutine dispatches events.
992 handlersMu sync.Mutex
993 onRelease []func()
994}
995
996// NewBuffer returns an unbound Buffer.
997func NewBuffer(ctx *wl.Context) *Buffer {
998 obj := &Buffer{}
999 obj.SetContext(ctx)
1000 ctx.Register(obj)
1001 return obj
1002}
1003
1004// Destroy a buffer. If and how you need to release the backing storage is defined by the buffer factory interface. For possible side-effects to a surface, see wl_surface.attach.
1005func (o *Buffer) Destroy() error {
1006 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_buffer.destroy", Destructor: true}); err != nil {
1007 return err
1008 }
1009 return nil
1010}
1011
1012// OnRelease registers a handler for the release event.
1013//
1014// Handlers are appended, so a second call adds another handler rather than
1015// replacing the first. Registration is safe while another goroutine dispatches.
1016func (o *Buffer) OnRelease(handler func()) {
1017 if handler == nil {
1018 return
1019 }
1020 o.handlersMu.Lock()
1021 defer o.handlersMu.Unlock()
1022 o.onRelease = append(o.onRelease, handler)
1023}
1024
1025// handlersForRelease returns the handlers registered for release, taken
1026// under the lock so a handler may register another handler while events are
1027// being dispatched.
1028func (o *Buffer) handlersForRelease() []func() {
1029 o.handlersMu.Lock()
1030 defer o.handlersMu.Unlock()
1031 return o.onRelease
1032}
1033
1034// EventSignature returns the declared event argument types in wire order.
1035func (o *Buffer) EventSignature(opcode uint16) (string, bool) {
1036 switch opcode {
1037 case 0:
1038 return "", true
1039 default:
1040 return "", false
1041 }
1042}
1043
1044// Dispatch decodes one event on wl_buffer and calls the registered handlers.
1045func (o *Buffer) Dispatch(event *wl.Event) {
1046 switch event.Opcode {
1047 case 0: // release
1048
1049 for i, handler := range o.handlersForRelease() {
1050 _ = i
1051 handler()
1052 }
1053 default:
1054 }
1055}
1056
1057// DataOfferInterface is the protocol interface name.
1058const DataOfferInterface = "wl_data_offer"
1059
1060// DataOffer is the generated binding for wl_data_offer version 4.
1061type DataOffer struct {
1062 wl.BaseProxy
1063 // handlersMu guards the handler slices: a client may register or replace
1064 // handlers while another goroutine dispatches events.
1065 handlersMu sync.Mutex
1066 onOffer []func(mimeType string)
1067 onSourceActions []func(sourceActions uint32)
1068 onAction []func(dndAction uint32)
1069}
1070
1071// NewDataOffer returns an unbound DataOffer.
1072func NewDataOffer(ctx *wl.Context) *DataOffer {
1073 obj := &DataOffer{}
1074 obj.SetContext(ctx)
1075 ctx.Register(obj)
1076 return obj
1077}
1078
1079// Indicate that the client can accept the given mime type, or NULL for not accepted. For objects of version 2 or older, this request is used by the client to give feedback whether the client can receive the given mime type, or NULL if none is accepted; the feedback does not determine whether the drag-and-drop operation succeeds or not. For objects of version 3 or newer, this request determines the final result of the drag-and-drop operation. If the end result is that no mime types were accepted, the drag-and-drop operation will be cancelled and the corresponding drag source will receive wl_data_source.cancelled. Clients may still use this event in conjunction with wl_data_source.action for feedback.
1080func (o *DataOffer) Accept(serial uint32, mimeType string) error {
1081 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_data_offer.accept"}, wl.ArgUint(serial), wl.ArgString(mimeType)); err != nil {
1082 return err
1083 }
1084 return nil
1085}
1086
1087// 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, both before and after wl_data_device.drop. Drag-and-drop destination clients may preemptively fetch data or examine it more closely to determine acceptance.
1088func (o *DataOffer) Receive(mimeType string, fd int) error {
1089 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_data_offer.receive", FDs: []int{fd}}, wl.ArgString(mimeType), wl.ArgFD()); err != nil {
1090 return err
1091 }
1092 return nil
1093}
1094
1095// Destroy the data offer.
1096func (o *DataOffer) Destroy() error {
1097 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_data_offer.destroy", Destructor: true}); err != nil {
1098 return err
1099 }
1100 return nil
1101}
1102
1103// Notifies the compositor that the drag destination successfully finished the drag-and-drop operation. Upon receiving this request, the compositor will emit wl_data_source.dnd_finished on the drag source client. It is a client error to perform other requests than wl_data_offer.destroy after this one. It is also an error to perform this request after a NULL mime type has been set in wl_data_offer.accept or no action was received through wl_data_offer.action. If wl_data_offer.finish request is received for a non drag and drop operation, the invalid_finish protocol error is raised.
1104func (o *DataOffer) Finish() error {
1105 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "wl_data_offer.finish", Since: 3}); err != nil {
1106 return err
1107 }
1108 return nil
1109}
1110
1111// Sets the actions that the destination side client supports for this operation. This request may trigger the emission of wl_data_source.action and wl_data_offer.action events if the compositor needs to change the selected action. This request can be called multiple times throughout the drag-and-drop operation, typically in response to wl_data_device.enter or wl_data_device.motion events. This request determines the final result of the drag-and-drop operation. If the end result is that no action is accepted, the drag source will receive wl_data_source.cancelled. The dnd_actions argument must contain only values expressed in the wl_data_device_manager.dnd_actions enum, and the preferred_action argument must only contain one of those values set, otherwise it will result in a protocol error. While managing an "ask" action, the destination drag-and-drop client may perform further wl_data_offer.receive requests, and is expected to perform one last wl_data_offer.set_actions request with a preferred action other than "ask" (and optionally wl_data_offer.accept) before requesting wl_data_offer.finish, in order to convey the action selected by the user. If the preferred action is not in the wl_data_offer.source_actions mask, an error will be raised. If the "ask" action is dismissed (e.g. user cancellation), the client is expected to perform wl_data_offer.destroy right away. This request can only be made on drag-and-drop offers, a protocol error will be raised otherwise.
1112func (o *DataOffer) SetActions(dndActions uint32, preferredAction uint32) error {
1113 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "wl_data_offer.set_actions", Since: 3}, wl.ArgUint(dndActions), wl.ArgUint(preferredAction)); err != nil {
1114 return err
1115 }
1116 return nil
1117}
1118
1119// OnOffer registers a handler for the offer event.
1120//
1121// Handlers are appended, so a second call adds another handler rather than
1122// replacing the first. Registration is safe while another goroutine dispatches.
1123func (o *DataOffer) OnOffer(handler func(mimeType string)) {
1124 if handler == nil {
1125 return
1126 }
1127 o.handlersMu.Lock()
1128 defer o.handlersMu.Unlock()
1129 o.onOffer = append(o.onOffer, handler)
1130}
1131
1132// handlersForOffer returns the handlers registered for offer, taken
1133// under the lock so a handler may register another handler while events are
1134// being dispatched.
1135func (o *DataOffer) handlersForOffer() []func(mimeType string) {
1136 o.handlersMu.Lock()
1137 defer o.handlersMu.Unlock()
1138 return o.onOffer
1139}
1140
1141// OnSourceActions registers a handler for the source_actions event.
1142//
1143// Handlers are appended, so a second call adds another handler rather than
1144// replacing the first. Registration is safe while another goroutine dispatches.
1145func (o *DataOffer) OnSourceActions(handler func(sourceActions uint32)) {
1146 if handler == nil {
1147 return
1148 }
1149 o.handlersMu.Lock()
1150 defer o.handlersMu.Unlock()
1151 o.onSourceActions = append(o.onSourceActions, handler)
1152}
1153
1154// handlersForSourceActions returns the handlers registered for source_actions, taken
1155// under the lock so a handler may register another handler while events are
1156// being dispatched.
1157func (o *DataOffer) handlersForSourceActions() []func(sourceActions uint32) {
1158 o.handlersMu.Lock()
1159 defer o.handlersMu.Unlock()
1160 return o.onSourceActions
1161}
1162
1163// OnAction registers a handler for the action event.
1164//
1165// Handlers are appended, so a second call adds another handler rather than
1166// replacing the first. Registration is safe while another goroutine dispatches.
1167func (o *DataOffer) OnAction(handler func(dndAction uint32)) {
1168 if handler == nil {
1169 return
1170 }
1171 o.handlersMu.Lock()
1172 defer o.handlersMu.Unlock()
1173 o.onAction = append(o.onAction, handler)
1174}
1175
1176// handlersForAction returns the handlers registered for action, taken
1177// under the lock so a handler may register another handler while events are
1178// being dispatched.
1179func (o *DataOffer) handlersForAction() []func(dndAction uint32) {
1180 o.handlersMu.Lock()
1181 defer o.handlersMu.Unlock()
1182 return o.onAction
1183}
1184
1185// EventSignature returns the declared event argument types in wire order.
1186func (o *DataOffer) EventSignature(opcode uint16) (string, bool) {
1187 switch opcode {
1188 case 0:
1189 return "string,", true
1190 case 1:
1191 return "uint,", true
1192 case 2:
1193 return "uint,", true
1194 default:
1195 return "", false
1196 }
1197}
1198
1199// Dispatch decodes one event on wl_data_offer and calls the registered handlers.
1200func (o *DataOffer) Dispatch(event *wl.Event) {
1201 switch event.Opcode {
1202 case 0: // offer
1203 mimeType := event.String()
1204
1205 for i, handler := range o.handlersForOffer() {
1206 _ = i
1207 handler(mimeType)
1208 }
1209 case 1: // source_actions
1210 sourceActions := event.Uint32()
1211
1212 for i, handler := range o.handlersForSourceActions() {
1213 _ = i
1214 handler(sourceActions)
1215 }
1216 case 2: // action
1217 dndAction := event.Uint32()
1218
1219 for i, handler := range o.handlersForAction() {
1220 _ = i
1221 handler(dndAction)
1222 }
1223 default:
1224 }
1225}
1226
1227// DataSourceInterface is the protocol interface name.
1228const DataSourceInterface = "wl_data_source"
1229
1230// DataSource is the generated binding for wl_data_source version 4.
1231type DataSource struct {
1232 wl.BaseProxy
1233 // handlersMu guards the handler slices: a client may register or replace
1234 // handlers while another goroutine dispatches events.
1235 handlersMu sync.Mutex
1236 onTarget []func(mimeType string)
1237 onSend []func(mimeType string, fd *wl.OwnedFD)
1238 onCancelled []func()
1239 onDndDropPerformed []func()
1240 onDndFinished []func()
1241 onAction []func(dndAction uint32)
1242}
1243
1244// NewDataSource returns an unbound DataSource.
1245func NewDataSource(ctx *wl.Context) *DataSource {
1246 obj := &DataSource{}
1247 obj.SetContext(ctx)
1248 ctx.Register(obj)
1249 return obj
1250}
1251
1252// This request adds a mime type to the set of mime types advertised to targets. Can be called several times to offer multiple types.
1253func (o *DataSource) Offer(mimeType string) error {
1254 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_data_source.offer"}, wl.ArgString(mimeType)); err != nil {
1255 return err
1256 }
1257 return nil
1258}
1259
1260// Destroy the data source.
1261func (o *DataSource) Destroy() error {
1262 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_data_source.destroy", Destructor: true}); err != nil {
1263 return err
1264 }
1265 return nil
1266}
1267
1268// Sets the actions that the source side client supports for this operation. This request may trigger wl_data_source.action and wl_data_offer.action events if the compositor needs to change the selected action. The dnd_actions argument must contain only values expressed in the wl_data_device_manager.dnd_actions enum, otherwise it will result in a protocol error. This request must be made once only, and can only be made on sources used in drag-and-drop, so it must be performed before wl_data_device.start_drag. Attempting to use the source other than for drag-and-drop will raise a protocol error.
1269func (o *DataSource) SetActions(dndActions uint32) error {
1270 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_data_source.set_actions", Since: 3}, wl.ArgUint(dndActions)); err != nil {
1271 return err
1272 }
1273 return nil
1274}
1275
1276// OnTarget registers a handler for the target event.
1277//
1278// Handlers are appended, so a second call adds another handler rather than
1279// replacing the first. Registration is safe while another goroutine dispatches.
1280func (o *DataSource) OnTarget(handler func(mimeType string)) {
1281 if handler == nil {
1282 return
1283 }
1284 o.handlersMu.Lock()
1285 defer o.handlersMu.Unlock()
1286 o.onTarget = append(o.onTarget, handler)
1287}
1288
1289// handlersForTarget returns the handlers registered for target, taken
1290// under the lock so a handler may register another handler while events are
1291// being dispatched.
1292func (o *DataSource) handlersForTarget() []func(mimeType string) {
1293 o.handlersMu.Lock()
1294 defer o.handlersMu.Unlock()
1295 return o.onTarget
1296}
1297
1298// OnSend registers a handler for the send event.
1299//
1300// Handlers are appended, so a second call adds another handler rather than
1301// replacing the first. Registration is safe while another goroutine dispatches.
1302func (o *DataSource) OnSend(handler func(mimeType string, fd *wl.OwnedFD)) {
1303 if handler == nil {
1304 return
1305 }
1306 o.handlersMu.Lock()
1307 defer o.handlersMu.Unlock()
1308 o.onSend = append(o.onSend, handler)
1309}
1310
1311// handlersForSend returns the handlers registered for send, taken
1312// under the lock so a handler may register another handler while events are
1313// being dispatched.
1314func (o *DataSource) handlersForSend() []func(mimeType string, fd *wl.OwnedFD) {
1315 o.handlersMu.Lock()
1316 defer o.handlersMu.Unlock()
1317 return o.onSend
1318}
1319
1320// OnCancelled registers a handler for the cancelled event.
1321//
1322// Handlers are appended, so a second call adds another handler rather than
1323// replacing the first. Registration is safe while another goroutine dispatches.
1324func (o *DataSource) OnCancelled(handler func()) {
1325 if handler == nil {
1326 return
1327 }
1328 o.handlersMu.Lock()
1329 defer o.handlersMu.Unlock()
1330 o.onCancelled = append(o.onCancelled, handler)
1331}
1332
1333// handlersForCancelled returns the handlers registered for cancelled, taken
1334// under the lock so a handler may register another handler while events are
1335// being dispatched.
1336func (o *DataSource) handlersForCancelled() []func() {
1337 o.handlersMu.Lock()
1338 defer o.handlersMu.Unlock()
1339 return o.onCancelled
1340}
1341
1342// OnDndDropPerformed registers a handler for the dnd_drop_performed event.
1343//
1344// Handlers are appended, so a second call adds another handler rather than
1345// replacing the first. Registration is safe while another goroutine dispatches.
1346func (o *DataSource) OnDndDropPerformed(handler func()) {
1347 if handler == nil {
1348 return
1349 }
1350 o.handlersMu.Lock()
1351 defer o.handlersMu.Unlock()
1352 o.onDndDropPerformed = append(o.onDndDropPerformed, handler)
1353}
1354
1355// handlersForDndDropPerformed returns the handlers registered for dnd_drop_performed, taken
1356// under the lock so a handler may register another handler while events are
1357// being dispatched.
1358func (o *DataSource) handlersForDndDropPerformed() []func() {
1359 o.handlersMu.Lock()
1360 defer o.handlersMu.Unlock()
1361 return o.onDndDropPerformed
1362}
1363
1364// OnDndFinished registers a handler for the dnd_finished event.
1365//
1366// Handlers are appended, so a second call adds another handler rather than
1367// replacing the first. Registration is safe while another goroutine dispatches.
1368func (o *DataSource) OnDndFinished(handler func()) {
1369 if handler == nil {
1370 return
1371 }
1372 o.handlersMu.Lock()
1373 defer o.handlersMu.Unlock()
1374 o.onDndFinished = append(o.onDndFinished, handler)
1375}
1376
1377// handlersForDndFinished returns the handlers registered for dnd_finished, taken
1378// under the lock so a handler may register another handler while events are
1379// being dispatched.
1380func (o *DataSource) handlersForDndFinished() []func() {
1381 o.handlersMu.Lock()
1382 defer o.handlersMu.Unlock()
1383 return o.onDndFinished
1384}
1385
1386// OnAction registers a handler for the action event.
1387//
1388// Handlers are appended, so a second call adds another handler rather than
1389// replacing the first. Registration is safe while another goroutine dispatches.
1390func (o *DataSource) OnAction(handler func(dndAction uint32)) {
1391 if handler == nil {
1392 return
1393 }
1394 o.handlersMu.Lock()
1395 defer o.handlersMu.Unlock()
1396 o.onAction = append(o.onAction, handler)
1397}
1398
1399// handlersForAction returns the handlers registered for action, taken
1400// under the lock so a handler may register another handler while events are
1401// being dispatched.
1402func (o *DataSource) handlersForAction() []func(dndAction uint32) {
1403 o.handlersMu.Lock()
1404 defer o.handlersMu.Unlock()
1405 return o.onAction
1406}
1407
1408// EventSignature returns the declared event argument types in wire order.
1409func (o *DataSource) EventSignature(opcode uint16) (string, bool) {
1410 switch opcode {
1411 case 0:
1412 return "string,", true
1413 case 1:
1414 return "string,fd,", true
1415 case 2:
1416 return "", true
1417 case 3:
1418 return "", true
1419 case 4:
1420 return "", true
1421 case 5:
1422 return "uint,", true
1423 default:
1424 return "", false
1425 }
1426}
1427
1428// Dispatch decodes one event on wl_data_source and calls the registered handlers.
1429func (o *DataSource) Dispatch(event *wl.Event) {
1430 switch event.Opcode {
1431 case 0: // target
1432 mimeType := event.String()
1433
1434 for i, handler := range o.handlersForTarget() {
1435 _ = i
1436 handler(mimeType)
1437 }
1438 case 1: // send
1439 mimeType := event.String()
1440 fd := event.FD()
1441 ownedfd := fd
1442 defer ownedfd.Close()
1443
1444 for i, handler := range o.handlersForSend() {
1445 if i > 0 {
1446 fd = nil
1447 }
1448 handler(mimeType, fd)
1449 }
1450 case 2: // cancelled
1451
1452 for i, handler := range o.handlersForCancelled() {
1453 _ = i
1454 handler()
1455 }
1456 case 3: // dnd_drop_performed
1457
1458 for i, handler := range o.handlersForDndDropPerformed() {
1459 _ = i
1460 handler()
1461 }
1462 case 4: // dnd_finished
1463
1464 for i, handler := range o.handlersForDndFinished() {
1465 _ = i
1466 handler()
1467 }
1468 case 5: // action
1469 dndAction := event.Uint32()
1470
1471 for i, handler := range o.handlersForAction() {
1472 _ = i
1473 handler(dndAction)
1474 }
1475 default:
1476 }
1477}
1478
1479// DataDeviceInterface is the protocol interface name.
1480const DataDeviceInterface = "wl_data_device"
1481
1482// DataDevice is the generated binding for wl_data_device version 4.
1483type DataDevice struct {
1484 wl.BaseProxy
1485 // handlersMu guards the handler slices: a client may register or replace
1486 // handlers while another goroutine dispatches events.
1487 handlersMu sync.Mutex
1488 onDataOffer []func(idObject *DataOffer)
1489 onEnter []func(serial uint32, surfaceID uint32, x wl.Fixed, y wl.Fixed, idID uint32)
1490 onLeave []func()
1491 onMotion []func(time uint32, x wl.Fixed, y wl.Fixed)
1492 onDrop []func()
1493 onSelection []func(idID uint32)
1494}
1495
1496// NewDataDevice returns an unbound DataDevice.
1497func NewDataDevice(ctx *wl.Context) *DataDevice {
1498 obj := &DataDevice{}
1499 obj.SetContext(ctx)
1500 ctx.Register(obj)
1501 return obj
1502}
1503
1504// This request asks the compositor to start a drag-and-drop operation on behalf of the client. The source argument is the data source that provides the data for the eventual data transfer. If source is NULL, enter, leave and motion events are sent only to the client that initiated the drag and the client is expected to handle the data passing internally. If source is destroyed, the drag-and-drop session will be cancelled. The origin surface is the surface where the drag originates and the client must have an active implicit grab that matches the serial. The icon surface is an optional (can be NULL) surface that provides an icon to be moved around with the cursor. Initially, the top-left corner of the icon surface is placed at the cursor hotspot, but subsequent wl_surface.offset requests can move the relative position. Attach requests must be confirmed with wl_surface.commit as usual. The icon surface is given the role of a drag-and-drop icon. If the icon surface already has another role, it raises a protocol error. The input region is ignored for wl_surfaces with the role of a drag-and-drop icon. The given source may not be used in any further set_selection or start_drag requests. Attempting to reuse a previously-used source may send a used_source error.
1505func (o *DataDevice) StartDrag(source *DataSource, origin *Surface, icon *Surface, serial uint32) error {
1506 var arg0 wl.Object
1507 if source != nil {
1508 arg0 = source
1509 }
1510 var arg1 wl.Object
1511 if origin != nil {
1512 arg1 = origin
1513 }
1514 var arg2 wl.Object
1515 if icon != nil {
1516 arg2 = icon
1517 }
1518 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_data_device.start_drag"}, wl.ArgObject(arg0), wl.ArgObject(arg1), wl.ArgObject(arg2), wl.ArgUint(serial)); err != nil {
1519 return err
1520 }
1521 return nil
1522}
1523
1524// This request asks the compositor to set the selection to the data from the source on behalf of the client. To unset the selection, set the source to NULL. The given source may not be used in any further set_selection or start_drag requests. Attempting to reuse a previously-used source may send a used_source error.
1525func (o *DataDevice) SetSelection(source *DataSource, serial uint32) error {
1526 var arg0 wl.Object
1527 if source != nil {
1528 arg0 = source
1529 }
1530 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_data_device.set_selection"}, wl.ArgObject(arg0), wl.ArgUint(serial)); err != nil {
1531 return err
1532 }
1533 return nil
1534}
1535
1536// This request destroys the data device.
1537func (o *DataDevice) Release() error {
1538 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_data_device.release", Since: 2, Destructor: true}); err != nil {
1539 return err
1540 }
1541 return nil
1542}
1543
1544// OnDataOffer registers a handler for the data_offer event.
1545//
1546// Handlers are appended, so a second call adds another handler rather than
1547// replacing the first. Registration is safe while another goroutine dispatches.
1548func (o *DataDevice) OnDataOffer(handler func(idObject *DataOffer)) {
1549 if handler == nil {
1550 return
1551 }
1552 o.handlersMu.Lock()
1553 defer o.handlersMu.Unlock()
1554 o.onDataOffer = append(o.onDataOffer, handler)
1555}
1556
1557// handlersForDataOffer returns the handlers registered for data_offer, taken
1558// under the lock so a handler may register another handler while events are
1559// being dispatched.
1560func (o *DataDevice) handlersForDataOffer() []func(idObject *DataOffer) {
1561 o.handlersMu.Lock()
1562 defer o.handlersMu.Unlock()
1563 return o.onDataOffer
1564}
1565
1566// OnEnter registers a handler for the enter event.
1567//
1568// Handlers are appended, so a second call adds another handler rather than
1569// replacing the first. Registration is safe while another goroutine dispatches.
1570func (o *DataDevice) OnEnter(handler func(serial uint32, surfaceID uint32, x wl.Fixed, y wl.Fixed, idID uint32)) {
1571 if handler == nil {
1572 return
1573 }
1574 o.handlersMu.Lock()
1575 defer o.handlersMu.Unlock()
1576 o.onEnter = append(o.onEnter, handler)
1577}
1578
1579// handlersForEnter returns the handlers registered for enter, taken
1580// under the lock so a handler may register another handler while events are
1581// being dispatched.
1582func (o *DataDevice) handlersForEnter() []func(serial uint32, surfaceID uint32, x wl.Fixed, y wl.Fixed, idID uint32) {
1583 o.handlersMu.Lock()
1584 defer o.handlersMu.Unlock()
1585 return o.onEnter
1586}
1587
1588// OnLeave registers a handler for the leave event.
1589//
1590// Handlers are appended, so a second call adds another handler rather than
1591// replacing the first. Registration is safe while another goroutine dispatches.
1592func (o *DataDevice) OnLeave(handler func()) {
1593 if handler == nil {
1594 return
1595 }
1596 o.handlersMu.Lock()
1597 defer o.handlersMu.Unlock()
1598 o.onLeave = append(o.onLeave, handler)
1599}
1600
1601// handlersForLeave returns the handlers registered for leave, taken
1602// under the lock so a handler may register another handler while events are
1603// being dispatched.
1604func (o *DataDevice) handlersForLeave() []func() {
1605 o.handlersMu.Lock()
1606 defer o.handlersMu.Unlock()
1607 return o.onLeave
1608}
1609
1610// OnMotion registers a handler for the motion event.
1611//
1612// Handlers are appended, so a second call adds another handler rather than
1613// replacing the first. Registration is safe while another goroutine dispatches.
1614func (o *DataDevice) OnMotion(handler func(time uint32, x wl.Fixed, y wl.Fixed)) {
1615 if handler == nil {
1616 return
1617 }
1618 o.handlersMu.Lock()
1619 defer o.handlersMu.Unlock()
1620 o.onMotion = append(o.onMotion, handler)
1621}
1622
1623// handlersForMotion returns the handlers registered for motion, taken
1624// under the lock so a handler may register another handler while events are
1625// being dispatched.
1626func (o *DataDevice) handlersForMotion() []func(time uint32, x wl.Fixed, y wl.Fixed) {
1627 o.handlersMu.Lock()
1628 defer o.handlersMu.Unlock()
1629 return o.onMotion
1630}
1631
1632// OnDrop registers a handler for the drop event.
1633//
1634// Handlers are appended, so a second call adds another handler rather than
1635// replacing the first. Registration is safe while another goroutine dispatches.
1636func (o *DataDevice) OnDrop(handler func()) {
1637 if handler == nil {
1638 return
1639 }
1640 o.handlersMu.Lock()
1641 defer o.handlersMu.Unlock()
1642 o.onDrop = append(o.onDrop, handler)
1643}
1644
1645// handlersForDrop returns the handlers registered for drop, taken
1646// under the lock so a handler may register another handler while events are
1647// being dispatched.
1648func (o *DataDevice) handlersForDrop() []func() {
1649 o.handlersMu.Lock()
1650 defer o.handlersMu.Unlock()
1651 return o.onDrop
1652}
1653
1654// OnSelection registers a handler for the selection event.
1655//
1656// Handlers are appended, so a second call adds another handler rather than
1657// replacing the first. Registration is safe while another goroutine dispatches.
1658func (o *DataDevice) OnSelection(handler func(idID uint32)) {
1659 if handler == nil {
1660 return
1661 }
1662 o.handlersMu.Lock()
1663 defer o.handlersMu.Unlock()
1664 o.onSelection = append(o.onSelection, handler)
1665}
1666
1667// handlersForSelection returns the handlers registered for selection, taken
1668// under the lock so a handler may register another handler while events are
1669// being dispatched.
1670func (o *DataDevice) handlersForSelection() []func(idID uint32) {
1671 o.handlersMu.Lock()
1672 defer o.handlersMu.Unlock()
1673 return o.onSelection
1674}
1675
1676// EventSignature returns the declared event argument types in wire order.
1677func (o *DataDevice) EventSignature(opcode uint16) (string, bool) {
1678 switch opcode {
1679 case 0:
1680 return "new_id,", true
1681 case 1:
1682 return "uint,object,fixed,fixed,object,", true
1683 case 2:
1684 return "", true
1685 case 3:
1686 return "uint,fixed,fixed,", true
1687 case 4:
1688 return "", true
1689 case 5:
1690 return "object,", true
1691 default:
1692 return "", false
1693 }
1694}
1695
1696// Dispatch decodes one event on wl_data_device and calls the registered handlers.
1697func (o *DataDevice) Dispatch(event *wl.Event) {
1698 switch event.Opcode {
1699 case 0: // data_offer
1700 idID := event.Uint32()
1701 idObject := &DataOffer{}
1702 idObject.SetContext(o.Context())
1703 idObject.SetID(idID)
1704 idObject.SetVersion(o.Version())
1705 o.Context().Register(idObject)
1706
1707 for i, handler := range o.handlersForDataOffer() {
1708 _ = i
1709 handler(idObject)
1710 }
1711 case 1: // enter
1712 serial := event.Uint32()
1713 surfaceID := event.Uint32()
1714 x := event.Fixed()
1715 y := event.Fixed()
1716 idID := event.Uint32()
1717
1718 for i, handler := range o.handlersForEnter() {
1719 _ = i
1720 handler(serial, surfaceID, x, y, idID)
1721 }
1722 case 2: // leave
1723
1724 for i, handler := range o.handlersForLeave() {
1725 _ = i
1726 handler()
1727 }
1728 case 3: // motion
1729 time := event.Uint32()
1730 x := event.Fixed()
1731 y := event.Fixed()
1732
1733 for i, handler := range o.handlersForMotion() {
1734 _ = i
1735 handler(time, x, y)
1736 }
1737 case 4: // drop
1738
1739 for i, handler := range o.handlersForDrop() {
1740 _ = i
1741 handler()
1742 }
1743 case 5: // selection
1744 idID := event.Uint32()
1745
1746 for i, handler := range o.handlersForSelection() {
1747 _ = i
1748 handler(idID)
1749 }
1750 default:
1751 }
1752}
1753
1754// DataDeviceManagerInterface is the protocol interface name.
1755const DataDeviceManagerInterface = "wl_data_device_manager"
1756
1757// DataDeviceManager is the generated binding for wl_data_device_manager version 4.
1758type DataDeviceManager struct {
1759 wl.BaseProxy
1760}
1761
1762// NewDataDeviceManager returns an unbound DataDeviceManager.
1763func NewDataDeviceManager(ctx *wl.Context) *DataDeviceManager {
1764 obj := &DataDeviceManager{}
1765 obj.SetContext(ctx)
1766 ctx.Register(obj)
1767 return obj
1768}
1769
1770// Create a new data source.
1771func (o *DataDeviceManager) CreateDataSource() (*DataSource, error) {
1772 child := &DataSource{}
1773 child.SetContext(o.Context())
1774 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_data_device_manager.create_data_source", Child: child}, wl.ArgObject(child)); err != nil {
1775 return nil, err
1776 }
1777 return child, nil
1778}
1779
1780// Create a new data device for a given seat.
1781func (o *DataDeviceManager) GetDataDevice(seat *Seat) (*DataDevice, error) {
1782 var arg1 wl.Object
1783 if seat != nil {
1784 arg1 = seat
1785 }
1786 child := &DataDevice{}
1787 child.SetContext(o.Context())
1788 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_data_device_manager.get_data_device", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
1789 return nil, err
1790 }
1791 return child, nil
1792}
1793
1794// This request destroys the wl_data_device_manager. This has no effect on any other objects.
1795func (o *DataDeviceManager) Release() error {
1796 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_data_device_manager.release", Since: 4, Destructor: true}); err != nil {
1797 return err
1798 }
1799 return nil
1800}
1801
1802// EventSignature returns the declared event argument types in wire order.
1803func (o *DataDeviceManager) EventSignature(opcode uint16) (string, bool) {
1804 switch opcode {
1805 default:
1806 return "", false
1807 }
1808}
1809
1810// Dispatch decodes one event on wl_data_device_manager and calls the registered handlers.
1811func (o *DataDeviceManager) Dispatch(event *wl.Event) {
1812 switch event.Opcode {
1813 default:
1814 }
1815}
1816
1817// ShellInterface is the protocol interface name.
1818const ShellInterface = "wl_shell"
1819
1820// Shell is the generated binding for wl_shell version 1.
1821type Shell struct {
1822 wl.BaseProxy
1823}
1824
1825// NewShell returns an unbound Shell.
1826func NewShell(ctx *wl.Context) *Shell {
1827 obj := &Shell{}
1828 obj.SetContext(ctx)
1829 ctx.Register(obj)
1830 return obj
1831}
1832
1833// Create a shell surface for an existing surface. This gives the wl_surface the role of a shell surface. If the wl_surface already has another role, it raises a protocol error. Only one shell surface can be associated with a given surface.
1834func (o *Shell) GetShellSurface(surface *Surface) (*ShellSurface, error) {
1835 var arg1 wl.Object
1836 if surface != nil {
1837 arg1 = surface
1838 }
1839 child := &ShellSurface{}
1840 child.SetContext(o.Context())
1841 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_shell.get_shell_surface", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1)); err != nil {
1842 return nil, err
1843 }
1844 return child, nil
1845}
1846
1847// EventSignature returns the declared event argument types in wire order.
1848func (o *Shell) EventSignature(opcode uint16) (string, bool) {
1849 switch opcode {
1850 default:
1851 return "", false
1852 }
1853}
1854
1855// Dispatch decodes one event on wl_shell and calls the registered handlers.
1856func (o *Shell) Dispatch(event *wl.Event) {
1857 switch event.Opcode {
1858 default:
1859 }
1860}
1861
1862// ShellSurfaceInterface is the protocol interface name.
1863const ShellSurfaceInterface = "wl_shell_surface"
1864
1865// ShellSurface is the generated binding for wl_shell_surface version 1.
1866type ShellSurface struct {
1867 wl.BaseProxy
1868 // handlersMu guards the handler slices: a client may register or replace
1869 // handlers while another goroutine dispatches events.
1870 handlersMu sync.Mutex
1871 onPing []func(serial uint32)
1872 onConfigure []func(edges uint32, width int32, height int32)
1873 onPopupDone []func()
1874}
1875
1876// NewShellSurface returns an unbound ShellSurface.
1877func NewShellSurface(ctx *wl.Context) *ShellSurface {
1878 obj := &ShellSurface{}
1879 obj.SetContext(ctx)
1880 ctx.Register(obj)
1881 return obj
1882}
1883
1884// A client must respond to a ping event with a pong request or the client may be deemed unresponsive.
1885func (o *ShellSurface) Pong(serial uint32) error {
1886 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_shell_surface.pong"}, wl.ArgUint(serial)); err != nil {
1887 return err
1888 }
1889 return nil
1890}
1891
1892// Start a pointer-driven move of the surface. This request must be used in response to a button press event. The server may ignore move requests depending on the state of the surface (e.g. fullscreen or maximized).
1893func (o *ShellSurface) Move(seat *Seat, serial uint32) error {
1894 var arg0 wl.Object
1895 if seat != nil {
1896 arg0 = seat
1897 }
1898 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_shell_surface.move"}, wl.ArgObject(arg0), wl.ArgUint(serial)); err != nil {
1899 return err
1900 }
1901 return nil
1902}
1903
1904// Start a pointer-driven resizing of the surface. This request must be used in response to a button press event. The server may ignore resize requests depending on the state of the surface (e.g. fullscreen or maximized).
1905func (o *ShellSurface) Resize(seat *Seat, serial uint32, edges uint32) error {
1906 var arg0 wl.Object
1907 if seat != nil {
1908 arg0 = seat
1909 }
1910 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_shell_surface.resize"}, wl.ArgObject(arg0), wl.ArgUint(serial), wl.ArgUint(edges)); err != nil {
1911 return err
1912 }
1913 return nil
1914}
1915
1916// Map the surface as a toplevel surface. A toplevel surface is not fullscreen, maximized or transient.
1917func (o *ShellSurface) SetToplevel() error {
1918 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "wl_shell_surface.set_toplevel"}); err != nil {
1919 return err
1920 }
1921 return nil
1922}
1923
1924// Map the surface relative to an existing surface. The x and y arguments specify the location of the upper left corner of the surface relative to the upper left corner of the parent surface, in surface-local coordinates. The flags argument controls details of the transient behaviour.
1925func (o *ShellSurface) SetTransient(parent *Surface, x int32, y int32, flags uint32) error {
1926 var arg0 wl.Object
1927 if parent != nil {
1928 arg0 = parent
1929 }
1930 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "wl_shell_surface.set_transient"}, wl.ArgObject(arg0), wl.ArgInt(x), wl.ArgInt(y), wl.ArgUint(flags)); err != nil {
1931 return err
1932 }
1933 return nil
1934}
1935
1936// Map the surface as a fullscreen surface. If an output parameter is given then the surface will be made fullscreen on that output. If the client does not specify the output then the compositor will apply its policy - usually choosing the output on which the surface has the biggest surface area. The client may specify a method to resolve a size conflict between the output size and the surface size - this is provided through the method parameter. The framerate parameter is used only when the method is set to "driver", to indicate the preferred framerate. A value of 0 indicates that the client does not care about framerate. The framerate is specified in mHz, that is framerate of 60000 is 60Hz. A method of "scale" or "driver" implies a scaling operation of the surface, either via a direct scaling operation or a change of the output mode. This will override any kind of output scaling, so that mapping a surface with a buffer size equal to the mode can fill the screen independent of buffer_scale. A method of "fill" means we don't scale up the buffer, however any output scale is applied. This means that you may run into an edge case where the application maps a buffer with the same size of the output mode but buffer_scale 1 (thus making a surface larger than the output). In this case it is allowed to downscale the results to fit the screen. The compositor must reply to this request with a configure event with the dimensions for the output on which the surface will be made fullscreen.
1937func (o *ShellSurface) SetFullscreen(method uint32, framerate uint32, output *Output) error {
1938 var arg2 wl.Object
1939 if output != nil {
1940 arg2 = output
1941 }
1942 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 5, Name: "wl_shell_surface.set_fullscreen"}, wl.ArgUint(method), wl.ArgUint(framerate), wl.ArgObject(arg2)); err != nil {
1943 return err
1944 }
1945 return nil
1946}
1947
1948// Map the surface as a popup. A popup surface is a transient surface with an added pointer grab. An existing implicit grab will be changed to owner-events mode, and the popup grab will continue after the implicit grab ends (i.e. releasing the mouse button does not cause the popup to be unmapped). The popup grab continues until the window is destroyed or a mouse button is pressed in any other client's window. A click in any of the client's surfaces is reported as normal, however, clicks in other clients' surfaces will be discarded and trigger the callback. The x and y arguments specify the location of the upper left corner of the surface relative to the upper left corner of the parent surface, in surface-local coordinates.
1949func (o *ShellSurface) SetPopup(seat *Seat, serial uint32, parent *Surface, x int32, y int32, flags uint32) error {
1950 var arg0 wl.Object
1951 if seat != nil {
1952 arg0 = seat
1953 }
1954 var arg2 wl.Object
1955 if parent != nil {
1956 arg2 = parent
1957 }
1958 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 6, Name: "wl_shell_surface.set_popup"}, wl.ArgObject(arg0), wl.ArgUint(serial), wl.ArgObject(arg2), wl.ArgInt(x), wl.ArgInt(y), wl.ArgUint(flags)); err != nil {
1959 return err
1960 }
1961 return nil
1962}
1963
1964// Map the surface as a maximized surface. If an output parameter is given then the surface will be maximized on that output. If the client does not specify the output then the compositor will apply its policy - usually choosing the output on which the surface has the biggest surface area. The compositor will reply with a configure event telling the expected new surface size. The operation is completed on the next buffer attach to this surface. A maximized surface typically fills the entire output it is bound to, except for desktop elements such as panels. This is the main difference between a maximized shell surface and a fullscreen shell surface. The details depend on the compositor implementation.
1965func (o *ShellSurface) SetMaximized(output *Output) error {
1966 var arg0 wl.Object
1967 if output != nil {
1968 arg0 = output
1969 }
1970 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 7, Name: "wl_shell_surface.set_maximized"}, wl.ArgObject(arg0)); err != nil {
1971 return err
1972 }
1973 return nil
1974}
1975
1976// Set a short title for the surface. This string may be used to identify the surface in a task bar, window list, or other user interface elements provided by the compositor. The string must be encoded in UTF-8.
1977func (o *ShellSurface) SetTitle(title string) error {
1978 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 8, Name: "wl_shell_surface.set_title"}, wl.ArgString(title)); err != nil {
1979 return err
1980 }
1981 return nil
1982}
1983
1984// Set a class for the surface. The surface class identifies the general class of applications to which the surface belongs. A common convention is to use the file name (or the full path if it is a non-standard location) of the application's .desktop file as the class.
1985func (o *ShellSurface) SetClass(class string) error {
1986 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 9, Name: "wl_shell_surface.set_class"}, wl.ArgString(class)); err != nil {
1987 return err
1988 }
1989 return nil
1990}
1991
1992// OnPing registers a handler for the ping event.
1993//
1994// Handlers are appended, so a second call adds another handler rather than
1995// replacing the first. Registration is safe while another goroutine dispatches.
1996func (o *ShellSurface) OnPing(handler func(serial uint32)) {
1997 if handler == nil {
1998 return
1999 }
2000 o.handlersMu.Lock()
2001 defer o.handlersMu.Unlock()
2002 o.onPing = append(o.onPing, handler)
2003}
2004
2005// handlersForPing returns the handlers registered for ping, taken
2006// under the lock so a handler may register another handler while events are
2007// being dispatched.
2008func (o *ShellSurface) handlersForPing() []func(serial uint32) {
2009 o.handlersMu.Lock()
2010 defer o.handlersMu.Unlock()
2011 return o.onPing
2012}
2013
2014// OnConfigure registers a handler for the configure event.
2015//
2016// Handlers are appended, so a second call adds another handler rather than
2017// replacing the first. Registration is safe while another goroutine dispatches.
2018func (o *ShellSurface) OnConfigure(handler func(edges uint32, width int32, height int32)) {
2019 if handler == nil {
2020 return
2021 }
2022 o.handlersMu.Lock()
2023 defer o.handlersMu.Unlock()
2024 o.onConfigure = append(o.onConfigure, handler)
2025}
2026
2027// handlersForConfigure returns the handlers registered for configure, taken
2028// under the lock so a handler may register another handler while events are
2029// being dispatched.
2030func (o *ShellSurface) handlersForConfigure() []func(edges uint32, width int32, height int32) {
2031 o.handlersMu.Lock()
2032 defer o.handlersMu.Unlock()
2033 return o.onConfigure
2034}
2035
2036// OnPopupDone registers a handler for the popup_done event.
2037//
2038// Handlers are appended, so a second call adds another handler rather than
2039// replacing the first. Registration is safe while another goroutine dispatches.
2040func (o *ShellSurface) OnPopupDone(handler func()) {
2041 if handler == nil {
2042 return
2043 }
2044 o.handlersMu.Lock()
2045 defer o.handlersMu.Unlock()
2046 o.onPopupDone = append(o.onPopupDone, handler)
2047}
2048
2049// handlersForPopupDone returns the handlers registered for popup_done, taken
2050// under the lock so a handler may register another handler while events are
2051// being dispatched.
2052func (o *ShellSurface) handlersForPopupDone() []func() {
2053 o.handlersMu.Lock()
2054 defer o.handlersMu.Unlock()
2055 return o.onPopupDone
2056}
2057
2058// EventSignature returns the declared event argument types in wire order.
2059func (o *ShellSurface) EventSignature(opcode uint16) (string, bool) {
2060 switch opcode {
2061 case 0:
2062 return "uint,", true
2063 case 1:
2064 return "uint,int,int,", true
2065 case 2:
2066 return "", true
2067 default:
2068 return "", false
2069 }
2070}
2071
2072// Dispatch decodes one event on wl_shell_surface and calls the registered handlers.
2073func (o *ShellSurface) Dispatch(event *wl.Event) {
2074 switch event.Opcode {
2075 case 0: // ping
2076 serial := event.Uint32()
2077
2078 for i, handler := range o.handlersForPing() {
2079 _ = i
2080 handler(serial)
2081 }
2082 case 1: // configure
2083 edges := event.Uint32()
2084 width := event.Int32()
2085 height := event.Int32()
2086
2087 for i, handler := range o.handlersForConfigure() {
2088 _ = i
2089 handler(edges, width, height)
2090 }
2091 case 2: // popup_done
2092
2093 for i, handler := range o.handlersForPopupDone() {
2094 _ = i
2095 handler()
2096 }
2097 default:
2098 }
2099}
2100
2101// SurfaceInterface is the protocol interface name.
2102const SurfaceInterface = "wl_surface"
2103
2104// Surface is the generated binding for wl_surface version 7.
2105type Surface struct {
2106 wl.BaseProxy
2107 // handlersMu guards the handler slices: a client may register or replace
2108 // handlers while another goroutine dispatches events.
2109 handlersMu sync.Mutex
2110 onEnter []func(outputID uint32)
2111 onLeave []func(outputID uint32)
2112 onPreferredBufferScale []func(factor int32)
2113 onPreferredBufferTransform []func(transform uint32)
2114}
2115
2116// NewSurface returns an unbound Surface.
2117func NewSurface(ctx *wl.Context) *Surface {
2118 obj := &Surface{}
2119 obj.SetContext(ctx)
2120 ctx.Register(obj)
2121 return obj
2122}
2123
2124// Deletes the surface and invalidates its object ID.
2125func (o *Surface) Destroy() error {
2126 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_surface.destroy", Destructor: true}); err != nil {
2127 return err
2128 }
2129 return nil
2130}
2131
2132// Set a buffer as the content of this surface. The new size of the surface is calculated based on the buffer size transformed by the inverse buffer_transform and the inverse buffer_scale. This means that at commit time the supplied buffer size must be an integer multiple of the buffer_scale. If that's not the case, an invalid_size error is sent. The x and y arguments specify the location of the new pending buffer's upper left corner, relative to the current buffer's upper left corner, in surface-local coordinates. In other words, the x and y, combined with the new surface size define in which directions the surface's size changes. Setting anything other than 0 as x and y arguments is discouraged, and should instead be replaced with using the separate wl_surface.offset request. When the bound wl_surface version is 5 or higher, passing any non-zero x or y is a protocol violation, and will result in an 'invalid_offset' error being raised. The x and y arguments are ignored and do not change the pending state. To achieve equivalent semantics, use wl_surface.offset. Surface contents are double-buffered state, see wl_surface.commit. The initial surface contents are void; there is no content. wl_surface.attach assigns the given wl_buffer as the pending wl_buffer. wl_surface.commit makes the pending wl_buffer the new surface contents, and the size of the surface becomes the size calculated from the wl_buffer, as described above. After commit, there is no pending buffer until the next attach. Committing a pending wl_buffer allows the compositor to read the pixels in the wl_buffer. The compositor may access the pixels at any time after the wl_surface.commit request. When the compositor will not access the pixels anymore, it will send the wl_buffer.release event. Only after receiving wl_buffer.release, the client may reuse the wl_buffer. A wl_buffer that has been attached and then replaced by another attach instead of committed will not receive a release event, and is not used by the compositor. If a pending wl_buffer has been committed to more than one wl_surface, the delivery of wl_buffer.release events becomes undefined. A well behaved client should not rely on wl_buffer.release events in this case. Instead, clients hitting this case should use wl_surface.get_release or use a protocol extension providing per-commit release notifications (if none of these options are available, a fallback can be implemented by creating multiple wl_buffer objects from the same backing storage). Destroying the wl_buffer after wl_buffer.release does not change the surface contents. Destroying the wl_buffer before wl_buffer.release is allowed as long as the underlying buffer storage isn't re-used (this can happen e.g. on client process termination). However, if the client destroys the wl_buffer before receiving the wl_buffer.release event and mutates the underlying buffer storage, the surface contents become undefined immediately. If wl_surface.attach is sent with a NULL wl_buffer, the following wl_surface.commit will remove the surface content. If a pending wl_buffer has been destroyed, the result is not specified. Many compositors are known to remove the surface content on the following wl_surface.commit, but this behaviour is not universal. Clients seeking to maximise compatibility should not destroy pending buffers and should ensure that they explicitly remove content from surfaces, even after destroying buffers.
2133func (o *Surface) Attach(buffer *Buffer, x int32, y int32) error {
2134 var arg0 wl.Object
2135 if buffer != nil {
2136 arg0 = buffer
2137 }
2138 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_surface.attach"}, wl.ArgObject(arg0), wl.ArgInt(x), wl.ArgInt(y)); err != nil {
2139 return err
2140 }
2141 return nil
2142}
2143
2144// This request is used to describe the regions where the pending buffer is different from the current surface contents, and where the surface therefore needs to be repainted. The compositor ignores the parts of the damage that fall outside of the surface. Damage is double-buffered state, see wl_surface.commit. The damage rectangle is specified in surface-local coordinates, where x and y specify the upper left corner of the damage rectangle. The initial value for pending damage is empty: no damage. wl_surface.damage adds pending damage: the new pending damage is the union of old pending damage and the given rectangle. wl_surface.commit assigns pending damage as the current damage, and clears pending damage. The server will clear the current damage as it repaints the surface. Note! New clients should not use this request. Instead damage can be posted with wl_surface.damage_buffer which uses buffer coordinates instead of surface coordinates.
2145func (o *Surface) Damage(x int32, y int32, width int32, height int32) error {
2146 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_surface.damage"}, wl.ArgInt(x), wl.ArgInt(y), wl.ArgInt(width), wl.ArgInt(height)); err != nil {
2147 return err
2148 }
2149 return nil
2150}
2151
2152// Request a notification when it is a good time to start drawing a new frame, by creating a frame callback. This is useful for throttling redrawing operations, and driving animations. When a client is animating on a wl_surface, it can use the 'frame' request to get notified when it is a good time to draw and commit the next frame of animation. If the client commits an update earlier than that, it is likely that some updates will not make it to the display, and the client is wasting resources by drawing too often. The frame request will take effect on the next wl_surface.commit. The notification will only be posted for one frame unless requested again. For a wl_surface, the notifications are posted in the order the frame requests were committed. The server must send the notifications so that a client will not send excessive updates, while still allowing the highest possible update rate for clients that wait for the reply before drawing again. The server should give some time for the client to draw and commit after sending the frame callback events to let it hit the next output refresh. A server should avoid signaling the frame callbacks if the surface is not visible in any way, e.g. the surface is off-screen, or completely obscured by other opaque surfaces. The object returned by this request will be destroyed by the compositor after the callback is fired and as such the client must not attempt to use it after that point. The callback_data passed in the callback is the current time, in milliseconds, with an undefined base.
2153func (o *Surface) Frame() (*Callback, error) {
2154 child := &Callback{}
2155 child.SetContext(o.Context())
2156 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "wl_surface.frame", Child: child}, wl.ArgObject(child)); err != nil {
2157 return nil, err
2158 }
2159 return child, nil
2160}
2161
2162// This request sets the region of the surface that contains opaque content. The opaque region is an optimization hint for the compositor that lets it optimize the redrawing of content behind opaque regions. Setting an opaque region is not required for correct behaviour, but marking transparent content as opaque will result in repaint artifacts. The opaque region is specified in surface-local coordinates. The compositor ignores the parts of the opaque region that fall outside of the surface. Opaque region is double-buffered state, see wl_surface.commit. wl_surface.set_opaque_region changes the pending opaque region. wl_surface.commit copies the pending region to the current region. Otherwise, the pending and current regions are never changed. The initial value for an opaque region is empty. Setting the pending opaque region has copy semantics, and the wl_region object can be destroyed immediately. A NULL wl_region causes the pending opaque region to be set to empty.
2163func (o *Surface) SetOpaqueRegion(region *Region) error {
2164 var arg0 wl.Object
2165 if region != nil {
2166 arg0 = region
2167 }
2168 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "wl_surface.set_opaque_region"}, wl.ArgObject(arg0)); err != nil {
2169 return err
2170 }
2171 return nil
2172}
2173
2174// This request sets the region of the surface that can receive pointer and touch events. Input events happening outside of this region will try the next surface in the server surface stack. The compositor ignores the parts of the input region that fall outside of the surface. The input region is specified in surface-local coordinates. Input region is double-buffered state, see wl_surface.commit. wl_surface.set_input_region changes the pending input region. wl_surface.commit copies the pending region to the current region. Otherwise the pending and current regions are never changed, except cursor and icon surfaces are special cases, see wl_pointer.set_cursor and wl_data_device.start_drag. The initial value for an input region is infinite. That means the whole surface will accept input. Setting the pending input region has copy semantics, and the wl_region object can be destroyed immediately. A NULL wl_region causes the input region to be set to infinite.
2175func (o *Surface) SetInputRegion(region *Region) error {
2176 var arg0 wl.Object
2177 if region != nil {
2178 arg0 = region
2179 }
2180 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 5, Name: "wl_surface.set_input_region"}, wl.ArgObject(arg0)); err != nil {
2181 return err
2182 }
2183 return nil
2184}
2185
2186// Surface state (input, opaque, and damage regions, attached buffers, etc.) is double-buffered. Protocol requests modify the pending state, as opposed to the active state in use by the compositor. All requests that need a commit to become effective are documented to affect double-buffered state. Other interfaces may add further double-buffered surface state. A commit request atomically creates a Content Update (CU) from the pending state, even if the pending state has not been touched. The content update is placed at the end of a per-surface queue until it becomes active. After commit, the new pending state is as documented for each related request. A CU is either a Desync Content Update (DCU) or a Sync Content Update (SCU). If the surface is effectively synchronized at the commit request, it is a SCU, otherwise a DCU. When a surface transitions from effectively synchronized to effectively desynchronized, all SCUs in its queue which are not reachable by any DCU become DCUs and dependency edges from outside the queue to these CUs are removed. See wl_subsurface for the definition of 'effectively synchronized' and 'effectively desynchronized'. When a CU is placed in the queue, the CU has a dependency on the CU in front of it and to the SCU at end of the queue of every direct child surface if that SCU exists and does not have another dependent. This can form a directed acyclic graph of CUs with dependencies as edges. In addition to surface state, the CU can have constraints that must be satisfied before it can be applied. Other interfaces may add CU constraints. All DCUs which do not have a SCU in front of themselves in their queue, are candidates. If the graph that's reachable by a candidate does not have any unsatisfied constraints, the entire graph must be applied atomically. When a CU is applied, the wl_buffer is applied before all other state. This means that all coordinates in double-buffered state are relative to the newly attached wl_buffers, except for wl_surface.attach itself. If there is no newly attached wl_buffer, the coordinates are relative to the previous content update.
2187func (o *Surface) Commit() error {
2188 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 6, Name: "wl_surface.commit"}); err != nil {
2189 return err
2190 }
2191 return nil
2192}
2193
2194// This request sets the transformation that the client has already applied to the content of the buffer. The accepted values for the transform parameter are the values for wl_output.transform. The compositor applies the inverse of this transformation whenever it uses the buffer contents. Buffer transform is double-buffered state, see wl_surface.commit. A newly created surface has its buffer transformation set to normal. wl_surface.set_buffer_transform changes the pending buffer transformation. wl_surface.commit copies the pending buffer transformation to the current one. Otherwise, the pending and current values are never changed. The purpose of this request is to allow clients to render content according to the output transform, thus permitting the compositor to use certain optimizations even if the display is rotated. Using hardware overlays and scanning out a client buffer for fullscreen surfaces are examples of such optimizations. Those optimizations are highly dependent on the compositor implementation, so the use of this request should be considered on a case-by-case basis. Note that if the transform value includes 90 or 270 degree rotation, the width of the buffer will become the surface height and the height of the buffer will become the surface width. If transform is not one of the values from the wl_output.transform enum the invalid_transform protocol error is raised.
2195func (o *Surface) SetBufferTransform(transform int32) error {
2196 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 7, Name: "wl_surface.set_buffer_transform", Since: 2}, wl.ArgInt(transform)); err != nil {
2197 return err
2198 }
2199 return nil
2200}
2201
2202// This request sets an optional scaling factor on how the compositor interprets the contents of the buffer attached to the window. Buffer scale is double-buffered state, see wl_surface.commit. A newly created surface has its buffer scale set to 1. wl_surface.set_buffer_scale changes the pending buffer scale. wl_surface.commit copies the pending buffer scale to the current one. Otherwise, the pending and current values are never changed. The purpose of this request is to allow clients to supply higher resolution buffer data for use on high resolution outputs. It is intended that you pick the same buffer scale as the scale of the output that the surface is displayed on. This means the compositor can avoid scaling when rendering the surface on that output. Note that if the scale is larger than 1, then you have to attach a buffer that is larger (by a factor of scale in each dimension) than the desired surface size. If scale is not greater than 0 the invalid_scale protocol error is raised.
2203func (o *Surface) SetBufferScale(scale int32) error {
2204 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 8, Name: "wl_surface.set_buffer_scale", Since: 3}, wl.ArgInt(scale)); err != nil {
2205 return err
2206 }
2207 return nil
2208}
2209
2210// This request is used to describe the regions where the pending buffer is different from the current surface contents, and where the surface therefore needs to be repainted. The compositor ignores the parts of the damage that fall outside of the surface. Damage is double-buffered state, see wl_surface.commit. The damage rectangle is specified in buffer coordinates, where x and y specify the upper left corner of the damage rectangle. The initial value for pending damage is empty: no damage. wl_surface.damage_buffer adds pending damage: the new pending damage is the union of old pending damage and the given rectangle. wl_surface.commit assigns pending damage as the current damage, and clears pending damage. The server will clear the current damage as it repaints the surface. This request differs from wl_surface.damage in only one way - it takes damage in buffer coordinates instead of surface-local coordinates. While this generally is more intuitive than surface coordinates, it is especially desirable when using wp_viewport or when a drawing library (like EGL) is unaware of buffer scale and buffer transform. Note: Because buffer transformation changes and damage requests may be interleaved in the protocol stream, it is impossible to determine the actual mapping between surface and buffer damage until wl_surface.commit time. Therefore, compositors wishing to take both kinds of damage into account will have to accumulate damage from the two requests separately and only transform from one to the other after receiving the wl_surface.commit.
2211func (o *Surface) DamageBuffer(x int32, y int32, width int32, height int32) error {
2212 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 9, Name: "wl_surface.damage_buffer", Since: 4}, wl.ArgInt(x), wl.ArgInt(y), wl.ArgInt(width), wl.ArgInt(height)); err != nil {
2213 return err
2214 }
2215 return nil
2216}
2217
2218// The x and y arguments specify the location of the new pending buffer's upper left corner, relative to the current buffer's upper left corner, in surface-local coordinates. In other words, the x and y, combined with the new surface size define in which directions the surface's size changes. The exact semantics of wl_surface.offset are role-specific. Refer to the documentation of specific roles for more information. Surface location offset is double-buffered state, see wl_surface.commit. This request is semantically equivalent to and the replaces the x and y arguments in the wl_surface.attach request in wl_surface versions prior to 5. See wl_surface.attach for details.
2219func (o *Surface) Offset(x int32, y int32) error {
2220 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 10, Name: "wl_surface.offset", Since: 5}, wl.ArgInt(x), wl.ArgInt(y)); err != nil {
2221 return err
2222 }
2223 return nil
2224}
2225
2226// Create a callback for the release of the buffer attached by the client with wl_surface.attach. The compositor will release the buffer when it has finished its usage of the underlying storage for the relevant commit. Once the client receives this event, and assuming the associated buffer is not pending release from other wl_surface.commit requests, the client can safely re-use the buffer. Release callbacks are double-buffered state, and will be associated with the pending buffer at wl_surface.commit time. The callback_data passed in the wl_callback.done event is unused and is always zero. Sending this request without attaching a non-null buffer in the same content update is a protocol error. The compositor will send the no_buffer error in this case.
2227func (o *Surface) GetRelease() (*Callback, error) {
2228 child := &Callback{}
2229 child.SetContext(o.Context())
2230 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 11, Name: "wl_surface.get_release", Since: 7, Child: child}, wl.ArgObject(child)); err != nil {
2231 return nil, err
2232 }
2233 return child, nil
2234}
2235
2236// OnEnter registers a handler for the enter event.
2237//
2238// Handlers are appended, so a second call adds another handler rather than
2239// replacing the first. Registration is safe while another goroutine dispatches.
2240func (o *Surface) OnEnter(handler func(outputID uint32)) {
2241 if handler == nil {
2242 return
2243 }
2244 o.handlersMu.Lock()
2245 defer o.handlersMu.Unlock()
2246 o.onEnter = append(o.onEnter, handler)
2247}
2248
2249// handlersForEnter returns the handlers registered for enter, taken
2250// under the lock so a handler may register another handler while events are
2251// being dispatched.
2252func (o *Surface) handlersForEnter() []func(outputID uint32) {
2253 o.handlersMu.Lock()
2254 defer o.handlersMu.Unlock()
2255 return o.onEnter
2256}
2257
2258// OnLeave registers a handler for the leave event.
2259//
2260// Handlers are appended, so a second call adds another handler rather than
2261// replacing the first. Registration is safe while another goroutine dispatches.
2262func (o *Surface) OnLeave(handler func(outputID uint32)) {
2263 if handler == nil {
2264 return
2265 }
2266 o.handlersMu.Lock()
2267 defer o.handlersMu.Unlock()
2268 o.onLeave = append(o.onLeave, handler)
2269}
2270
2271// handlersForLeave returns the handlers registered for leave, taken
2272// under the lock so a handler may register another handler while events are
2273// being dispatched.
2274func (o *Surface) handlersForLeave() []func(outputID uint32) {
2275 o.handlersMu.Lock()
2276 defer o.handlersMu.Unlock()
2277 return o.onLeave
2278}
2279
2280// OnPreferredBufferScale registers a handler for the preferred_buffer_scale event.
2281//
2282// Handlers are appended, so a second call adds another handler rather than
2283// replacing the first. Registration is safe while another goroutine dispatches.
2284func (o *Surface) OnPreferredBufferScale(handler func(factor int32)) {
2285 if handler == nil {
2286 return
2287 }
2288 o.handlersMu.Lock()
2289 defer o.handlersMu.Unlock()
2290 o.onPreferredBufferScale = append(o.onPreferredBufferScale, handler)
2291}
2292
2293// handlersForPreferredBufferScale returns the handlers registered for preferred_buffer_scale, taken
2294// under the lock so a handler may register another handler while events are
2295// being dispatched.
2296func (o *Surface) handlersForPreferredBufferScale() []func(factor int32) {
2297 o.handlersMu.Lock()
2298 defer o.handlersMu.Unlock()
2299 return o.onPreferredBufferScale
2300}
2301
2302// OnPreferredBufferTransform registers a handler for the preferred_buffer_transform event.
2303//
2304// Handlers are appended, so a second call adds another handler rather than
2305// replacing the first. Registration is safe while another goroutine dispatches.
2306func (o *Surface) OnPreferredBufferTransform(handler func(transform uint32)) {
2307 if handler == nil {
2308 return
2309 }
2310 o.handlersMu.Lock()
2311 defer o.handlersMu.Unlock()
2312 o.onPreferredBufferTransform = append(o.onPreferredBufferTransform, handler)
2313}
2314
2315// handlersForPreferredBufferTransform returns the handlers registered for preferred_buffer_transform, taken
2316// under the lock so a handler may register another handler while events are
2317// being dispatched.
2318func (o *Surface) handlersForPreferredBufferTransform() []func(transform uint32) {
2319 o.handlersMu.Lock()
2320 defer o.handlersMu.Unlock()
2321 return o.onPreferredBufferTransform
2322}
2323
2324// EventSignature returns the declared event argument types in wire order.
2325func (o *Surface) EventSignature(opcode uint16) (string, bool) {
2326 switch opcode {
2327 case 0:
2328 return "object,", true
2329 case 1:
2330 return "object,", true
2331 case 2:
2332 return "int,", true
2333 case 3:
2334 return "uint,", true
2335 default:
2336 return "", false
2337 }
2338}
2339
2340// Dispatch decodes one event on wl_surface and calls the registered handlers.
2341func (o *Surface) Dispatch(event *wl.Event) {
2342 switch event.Opcode {
2343 case 0: // enter
2344 outputID := event.Uint32()
2345
2346 for i, handler := range o.handlersForEnter() {
2347 _ = i
2348 handler(outputID)
2349 }
2350 case 1: // leave
2351 outputID := event.Uint32()
2352
2353 for i, handler := range o.handlersForLeave() {
2354 _ = i
2355 handler(outputID)
2356 }
2357 case 2: // preferred_buffer_scale
2358 factor := event.Int32()
2359
2360 for i, handler := range o.handlersForPreferredBufferScale() {
2361 _ = i
2362 handler(factor)
2363 }
2364 case 3: // preferred_buffer_transform
2365 transform := event.Uint32()
2366
2367 for i, handler := range o.handlersForPreferredBufferTransform() {
2368 _ = i
2369 handler(transform)
2370 }
2371 default:
2372 }
2373}
2374
2375// SeatInterface is the protocol interface name.
2376const SeatInterface = "wl_seat"
2377
2378// Seat is the generated binding for wl_seat version 11.
2379type Seat struct {
2380 wl.BaseProxy
2381 // handlersMu guards the handler slices: a client may register or replace
2382 // handlers while another goroutine dispatches events.
2383 handlersMu sync.Mutex
2384 onCapabilities []func(capabilities uint32)
2385 onName []func(name string)
2386}
2387
2388// NewSeat returns an unbound Seat.
2389func NewSeat(ctx *wl.Context) *Seat {
2390 obj := &Seat{}
2391 obj.SetContext(ctx)
2392 ctx.Register(obj)
2393 return obj
2394}
2395
2396// The ID provided will be initialized to the wl_pointer interface for this seat. This request only takes effect if the seat has the pointer capability, or has had the pointer capability in the past. It is a protocol violation to issue this request on a seat that has never had the pointer capability. The missing_capability error will be sent in this case.
2397func (o *Seat) GetPointer() (*Pointer, error) {
2398 child := &Pointer{}
2399 child.SetContext(o.Context())
2400 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_seat.get_pointer", Child: child}, wl.ArgObject(child)); err != nil {
2401 return nil, err
2402 }
2403 return child, nil
2404}
2405
2406// The ID provided will be initialized to the wl_keyboard interface for this seat. This request only takes effect if the seat has the keyboard capability, or has had the keyboard capability in the past. It is a protocol violation to issue this request on a seat that has never had the keyboard capability. The missing_capability error will be sent in this case.
2407func (o *Seat) GetKeyboard() (*Keyboard, error) {
2408 child := &Keyboard{}
2409 child.SetContext(o.Context())
2410 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_seat.get_keyboard", Child: child}, wl.ArgObject(child)); err != nil {
2411 return nil, err
2412 }
2413 return child, nil
2414}
2415
2416// The ID provided will be initialized to the wl_touch interface for this seat. This request only takes effect if the seat has the touch capability, or has had the touch capability in the past. It is a protocol violation to issue this request on a seat that has never had the touch capability. The missing_capability error will be sent in this case.
2417func (o *Seat) GetTouch() (*Touch, error) {
2418 child := &Touch{}
2419 child.SetContext(o.Context())
2420 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_seat.get_touch", Child: child}, wl.ArgObject(child)); err != nil {
2421 return nil, err
2422 }
2423 return child, nil
2424}
2425
2426// Using this request a client can tell the server that it is not going to use the seat object anymore.
2427func (o *Seat) Release() error {
2428 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "wl_seat.release", Since: 5, Destructor: true}); err != nil {
2429 return err
2430 }
2431 return nil
2432}
2433
2434// OnCapabilities registers a handler for the capabilities event.
2435//
2436// Handlers are appended, so a second call adds another handler rather than
2437// replacing the first. Registration is safe while another goroutine dispatches.
2438func (o *Seat) OnCapabilities(handler func(capabilities uint32)) {
2439 if handler == nil {
2440 return
2441 }
2442 o.handlersMu.Lock()
2443 defer o.handlersMu.Unlock()
2444 o.onCapabilities = append(o.onCapabilities, handler)
2445}
2446
2447// handlersForCapabilities returns the handlers registered for capabilities, taken
2448// under the lock so a handler may register another handler while events are
2449// being dispatched.
2450func (o *Seat) handlersForCapabilities() []func(capabilities uint32) {
2451 o.handlersMu.Lock()
2452 defer o.handlersMu.Unlock()
2453 return o.onCapabilities
2454}
2455
2456// OnName registers a handler for the name event.
2457//
2458// Handlers are appended, so a second call adds another handler rather than
2459// replacing the first. Registration is safe while another goroutine dispatches.
2460func (o *Seat) OnName(handler func(name string)) {
2461 if handler == nil {
2462 return
2463 }
2464 o.handlersMu.Lock()
2465 defer o.handlersMu.Unlock()
2466 o.onName = append(o.onName, handler)
2467}
2468
2469// handlersForName returns the handlers registered for name, taken
2470// under the lock so a handler may register another handler while events are
2471// being dispatched.
2472func (o *Seat) handlersForName() []func(name string) {
2473 o.handlersMu.Lock()
2474 defer o.handlersMu.Unlock()
2475 return o.onName
2476}
2477
2478// EventSignature returns the declared event argument types in wire order.
2479func (o *Seat) EventSignature(opcode uint16) (string, bool) {
2480 switch opcode {
2481 case 0:
2482 return "uint,", true
2483 case 1:
2484 return "string,", true
2485 default:
2486 return "", false
2487 }
2488}
2489
2490// Dispatch decodes one event on wl_seat and calls the registered handlers.
2491func (o *Seat) Dispatch(event *wl.Event) {
2492 switch event.Opcode {
2493 case 0: // capabilities
2494 capabilities := event.Uint32()
2495
2496 for i, handler := range o.handlersForCapabilities() {
2497 _ = i
2498 handler(capabilities)
2499 }
2500 case 1: // name
2501 name := event.String()
2502
2503 for i, handler := range o.handlersForName() {
2504 _ = i
2505 handler(name)
2506 }
2507 default:
2508 }
2509}
2510
2511// PointerInterface is the protocol interface name.
2512const PointerInterface = "wl_pointer"
2513
2514// Pointer is the generated binding for wl_pointer version 11.
2515type Pointer struct {
2516 wl.BaseProxy
2517 // handlersMu guards the handler slices: a client may register or replace
2518 // handlers while another goroutine dispatches events.
2519 handlersMu sync.Mutex
2520 onEnter []func(serial uint32, surfaceID uint32, surfaceX wl.Fixed, surfaceY wl.Fixed)
2521 onLeave []func(serial uint32, surfaceID uint32)
2522 onMotion []func(time uint32, surfaceX wl.Fixed, surfaceY wl.Fixed)
2523 onButton []func(serial uint32, time uint32, button uint32, state uint32)
2524 onAxis []func(time uint32, axis uint32, value wl.Fixed)
2525 onFrame []func()
2526 onAxisSource []func(axisSource uint32)
2527 onAxisStop []func(time uint32, axis uint32)
2528 onAxisDiscrete []func(axis uint32, discrete int32)
2529 onAxisValue120 []func(axis uint32, value120 int32)
2530 onAxisRelativeDirection []func(axis uint32, direction uint32)
2531 onWarp []func(surfaceX wl.Fixed, surfaceY wl.Fixed)
2532}
2533
2534// NewPointer returns an unbound Pointer.
2535func NewPointer(ctx *wl.Context) *Pointer {
2536 obj := &Pointer{}
2537 obj.SetContext(ctx)
2538 ctx.Register(obj)
2539 return obj
2540}
2541
2542// Set the pointer surface, i.e., the surface that contains the pointer image (cursor). This request gives the surface the role of a cursor. If the surface already has another role, it raises a protocol error. The cursor actually changes only if the pointer focus for this device is one of the requesting client's surfaces or the surface parameter is the current pointer surface. If there was a previous surface set with this request it is replaced. If surface is NULL, the pointer image is hidden. The parameters hotspot_x and hotspot_y define the position of the pointer surface relative to the pointer location. Its top-left corner is always at (x, y) - (hotspot_x, hotspot_y), where (x, y) are the coordinates of the pointer location, in surface-local coordinates. On wl_surface.offset requests to the pointer surface, hotspot_x and hotspot_y are decremented by the x and y parameters passed to the request. The offset must be applied by wl_surface.commit as usual. The hotspot can also be updated by passing the currently set pointer surface to this request with new values for hotspot_x and hotspot_y. The input region is ignored for wl_surfaces with the role of a cursor. When the use as a cursor ends, the wl_surface is unmapped. The serial parameter must match the latest wl_pointer.enter serial number sent to the client. Otherwise the request will be ignored.
2543func (o *Pointer) SetCursor(serial uint32, surface *Surface, hotspotX int32, hotspotY int32) error {
2544 var arg1 wl.Object
2545 if surface != nil {
2546 arg1 = surface
2547 }
2548 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_pointer.set_cursor"}, wl.ArgUint(serial), wl.ArgObject(arg1), wl.ArgInt(hotspotX), wl.ArgInt(hotspotY)); err != nil {
2549 return err
2550 }
2551 return nil
2552}
2553
2554// Using this request a client can tell the server that it is not going to use the pointer object anymore. This request destroys the pointer proxy object, so clients must not call wl_pointer_destroy() after using this request.
2555func (o *Pointer) Release() error {
2556 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_pointer.release", Since: 3, Destructor: true}); err != nil {
2557 return err
2558 }
2559 return nil
2560}
2561
2562// OnEnter registers a handler for the enter event.
2563//
2564// Handlers are appended, so a second call adds another handler rather than
2565// replacing the first. Registration is safe while another goroutine dispatches.
2566func (o *Pointer) OnEnter(handler func(serial uint32, surfaceID uint32, surfaceX wl.Fixed, surfaceY wl.Fixed)) {
2567 if handler == nil {
2568 return
2569 }
2570 o.handlersMu.Lock()
2571 defer o.handlersMu.Unlock()
2572 o.onEnter = append(o.onEnter, handler)
2573}
2574
2575// handlersForEnter returns the handlers registered for enter, taken
2576// under the lock so a handler may register another handler while events are
2577// being dispatched.
2578func (o *Pointer) handlersForEnter() []func(serial uint32, surfaceID uint32, surfaceX wl.Fixed, surfaceY wl.Fixed) {
2579 o.handlersMu.Lock()
2580 defer o.handlersMu.Unlock()
2581 return o.onEnter
2582}
2583
2584// OnLeave registers a handler for the leave event.
2585//
2586// Handlers are appended, so a second call adds another handler rather than
2587// replacing the first. Registration is safe while another goroutine dispatches.
2588func (o *Pointer) OnLeave(handler func(serial uint32, surfaceID uint32)) {
2589 if handler == nil {
2590 return
2591 }
2592 o.handlersMu.Lock()
2593 defer o.handlersMu.Unlock()
2594 o.onLeave = append(o.onLeave, handler)
2595}
2596
2597// handlersForLeave returns the handlers registered for leave, taken
2598// under the lock so a handler may register another handler while events are
2599// being dispatched.
2600func (o *Pointer) handlersForLeave() []func(serial uint32, surfaceID uint32) {
2601 o.handlersMu.Lock()
2602 defer o.handlersMu.Unlock()
2603 return o.onLeave
2604}
2605
2606// OnMotion registers a handler for the motion event.
2607//
2608// Handlers are appended, so a second call adds another handler rather than
2609// replacing the first. Registration is safe while another goroutine dispatches.
2610func (o *Pointer) OnMotion(handler func(time uint32, surfaceX wl.Fixed, surfaceY wl.Fixed)) {
2611 if handler == nil {
2612 return
2613 }
2614 o.handlersMu.Lock()
2615 defer o.handlersMu.Unlock()
2616 o.onMotion = append(o.onMotion, handler)
2617}
2618
2619// handlersForMotion returns the handlers registered for motion, taken
2620// under the lock so a handler may register another handler while events are
2621// being dispatched.
2622func (o *Pointer) handlersForMotion() []func(time uint32, surfaceX wl.Fixed, surfaceY wl.Fixed) {
2623 o.handlersMu.Lock()
2624 defer o.handlersMu.Unlock()
2625 return o.onMotion
2626}
2627
2628// OnButton registers a handler for the button event.
2629//
2630// Handlers are appended, so a second call adds another handler rather than
2631// replacing the first. Registration is safe while another goroutine dispatches.
2632func (o *Pointer) OnButton(handler func(serial uint32, time uint32, button uint32, state uint32)) {
2633 if handler == nil {
2634 return
2635 }
2636 o.handlersMu.Lock()
2637 defer o.handlersMu.Unlock()
2638 o.onButton = append(o.onButton, handler)
2639}
2640
2641// handlersForButton returns the handlers registered for button, taken
2642// under the lock so a handler may register another handler while events are
2643// being dispatched.
2644func (o *Pointer) handlersForButton() []func(serial uint32, time uint32, button uint32, state uint32) {
2645 o.handlersMu.Lock()
2646 defer o.handlersMu.Unlock()
2647 return o.onButton
2648}
2649
2650// OnAxis registers a handler for the axis event.
2651//
2652// Handlers are appended, so a second call adds another handler rather than
2653// replacing the first. Registration is safe while another goroutine dispatches.
2654func (o *Pointer) OnAxis(handler func(time uint32, axis uint32, value wl.Fixed)) {
2655 if handler == nil {
2656 return
2657 }
2658 o.handlersMu.Lock()
2659 defer o.handlersMu.Unlock()
2660 o.onAxis = append(o.onAxis, handler)
2661}
2662
2663// handlersForAxis returns the handlers registered for axis, taken
2664// under the lock so a handler may register another handler while events are
2665// being dispatched.
2666func (o *Pointer) handlersForAxis() []func(time uint32, axis uint32, value wl.Fixed) {
2667 o.handlersMu.Lock()
2668 defer o.handlersMu.Unlock()
2669 return o.onAxis
2670}
2671
2672// OnFrame registers a handler for the frame event.
2673//
2674// Handlers are appended, so a second call adds another handler rather than
2675// replacing the first. Registration is safe while another goroutine dispatches.
2676func (o *Pointer) OnFrame(handler func()) {
2677 if handler == nil {
2678 return
2679 }
2680 o.handlersMu.Lock()
2681 defer o.handlersMu.Unlock()
2682 o.onFrame = append(o.onFrame, handler)
2683}
2684
2685// handlersForFrame returns the handlers registered for frame, taken
2686// under the lock so a handler may register another handler while events are
2687// being dispatched.
2688func (o *Pointer) handlersForFrame() []func() {
2689 o.handlersMu.Lock()
2690 defer o.handlersMu.Unlock()
2691 return o.onFrame
2692}
2693
2694// OnAxisSource registers a handler for the axis_source event.
2695//
2696// Handlers are appended, so a second call adds another handler rather than
2697// replacing the first. Registration is safe while another goroutine dispatches.
2698func (o *Pointer) OnAxisSource(handler func(axisSource uint32)) {
2699 if handler == nil {
2700 return
2701 }
2702 o.handlersMu.Lock()
2703 defer o.handlersMu.Unlock()
2704 o.onAxisSource = append(o.onAxisSource, handler)
2705}
2706
2707// handlersForAxisSource returns the handlers registered for axis_source, taken
2708// under the lock so a handler may register another handler while events are
2709// being dispatched.
2710func (o *Pointer) handlersForAxisSource() []func(axisSource uint32) {
2711 o.handlersMu.Lock()
2712 defer o.handlersMu.Unlock()
2713 return o.onAxisSource
2714}
2715
2716// OnAxisStop registers a handler for the axis_stop event.
2717//
2718// Handlers are appended, so a second call adds another handler rather than
2719// replacing the first. Registration is safe while another goroutine dispatches.
2720func (o *Pointer) OnAxisStop(handler func(time uint32, axis uint32)) {
2721 if handler == nil {
2722 return
2723 }
2724 o.handlersMu.Lock()
2725 defer o.handlersMu.Unlock()
2726 o.onAxisStop = append(o.onAxisStop, handler)
2727}
2728
2729// handlersForAxisStop returns the handlers registered for axis_stop, taken
2730// under the lock so a handler may register another handler while events are
2731// being dispatched.
2732func (o *Pointer) handlersForAxisStop() []func(time uint32, axis uint32) {
2733 o.handlersMu.Lock()
2734 defer o.handlersMu.Unlock()
2735 return o.onAxisStop
2736}
2737
2738// OnAxisDiscrete registers a handler for the axis_discrete event.
2739//
2740// Handlers are appended, so a second call adds another handler rather than
2741// replacing the first. Registration is safe while another goroutine dispatches.
2742func (o *Pointer) OnAxisDiscrete(handler func(axis uint32, discrete int32)) {
2743 if handler == nil {
2744 return
2745 }
2746 o.handlersMu.Lock()
2747 defer o.handlersMu.Unlock()
2748 o.onAxisDiscrete = append(o.onAxisDiscrete, handler)
2749}
2750
2751// handlersForAxisDiscrete returns the handlers registered for axis_discrete, taken
2752// under the lock so a handler may register another handler while events are
2753// being dispatched.
2754func (o *Pointer) handlersForAxisDiscrete() []func(axis uint32, discrete int32) {
2755 o.handlersMu.Lock()
2756 defer o.handlersMu.Unlock()
2757 return o.onAxisDiscrete
2758}
2759
2760// OnAxisValue120 registers a handler for the axis_value120 event.
2761//
2762// Handlers are appended, so a second call adds another handler rather than
2763// replacing the first. Registration is safe while another goroutine dispatches.
2764func (o *Pointer) OnAxisValue120(handler func(axis uint32, value120 int32)) {
2765 if handler == nil {
2766 return
2767 }
2768 o.handlersMu.Lock()
2769 defer o.handlersMu.Unlock()
2770 o.onAxisValue120 = append(o.onAxisValue120, handler)
2771}
2772
2773// handlersForAxisValue120 returns the handlers registered for axis_value120, taken
2774// under the lock so a handler may register another handler while events are
2775// being dispatched.
2776func (o *Pointer) handlersForAxisValue120() []func(axis uint32, value120 int32) {
2777 o.handlersMu.Lock()
2778 defer o.handlersMu.Unlock()
2779 return o.onAxisValue120
2780}
2781
2782// OnAxisRelativeDirection registers a handler for the axis_relative_direction event.
2783//
2784// Handlers are appended, so a second call adds another handler rather than
2785// replacing the first. Registration is safe while another goroutine dispatches.
2786func (o *Pointer) OnAxisRelativeDirection(handler func(axis uint32, direction uint32)) {
2787 if handler == nil {
2788 return
2789 }
2790 o.handlersMu.Lock()
2791 defer o.handlersMu.Unlock()
2792 o.onAxisRelativeDirection = append(o.onAxisRelativeDirection, handler)
2793}
2794
2795// handlersForAxisRelativeDirection returns the handlers registered for axis_relative_direction, taken
2796// under the lock so a handler may register another handler while events are
2797// being dispatched.
2798func (o *Pointer) handlersForAxisRelativeDirection() []func(axis uint32, direction uint32) {
2799 o.handlersMu.Lock()
2800 defer o.handlersMu.Unlock()
2801 return o.onAxisRelativeDirection
2802}
2803
2804// OnWarp registers a handler for the warp event.
2805//
2806// Handlers are appended, so a second call adds another handler rather than
2807// replacing the first. Registration is safe while another goroutine dispatches.
2808func (o *Pointer) OnWarp(handler func(surfaceX wl.Fixed, surfaceY wl.Fixed)) {
2809 if handler == nil {
2810 return
2811 }
2812 o.handlersMu.Lock()
2813 defer o.handlersMu.Unlock()
2814 o.onWarp = append(o.onWarp, handler)
2815}
2816
2817// handlersForWarp returns the handlers registered for warp, taken
2818// under the lock so a handler may register another handler while events are
2819// being dispatched.
2820func (o *Pointer) handlersForWarp() []func(surfaceX wl.Fixed, surfaceY wl.Fixed) {
2821 o.handlersMu.Lock()
2822 defer o.handlersMu.Unlock()
2823 return o.onWarp
2824}
2825
2826// EventSignature returns the declared event argument types in wire order.
2827func (o *Pointer) EventSignature(opcode uint16) (string, bool) {
2828 switch opcode {
2829 case 0:
2830 return "uint,object,fixed,fixed,", true
2831 case 1:
2832 return "uint,object,", true
2833 case 2:
2834 return "uint,fixed,fixed,", true
2835 case 3:
2836 return "uint,uint,uint,uint,", true
2837 case 4:
2838 return "uint,uint,fixed,", true
2839 case 5:
2840 return "", true
2841 case 6:
2842 return "uint,", true
2843 case 7:
2844 return "uint,uint,", true
2845 case 8:
2846 return "uint,int,", true
2847 case 9:
2848 return "uint,int,", true
2849 case 10:
2850 return "uint,uint,", true
2851 case 11:
2852 return "fixed,fixed,", true
2853 default:
2854 return "", false
2855 }
2856}
2857
2858// Dispatch decodes one event on wl_pointer and calls the registered handlers.
2859func (o *Pointer) Dispatch(event *wl.Event) {
2860 switch event.Opcode {
2861 case 0: // enter
2862 serial := event.Uint32()
2863 surfaceID := event.Uint32()
2864 surfaceX := event.Fixed()
2865 surfaceY := event.Fixed()
2866
2867 for i, handler := range o.handlersForEnter() {
2868 _ = i
2869 handler(serial, surfaceID, surfaceX, surfaceY)
2870 }
2871 case 1: // leave
2872 serial := event.Uint32()
2873 surfaceID := event.Uint32()
2874
2875 for i, handler := range o.handlersForLeave() {
2876 _ = i
2877 handler(serial, surfaceID)
2878 }
2879 case 2: // motion
2880 time := event.Uint32()
2881 surfaceX := event.Fixed()
2882 surfaceY := event.Fixed()
2883
2884 for i, handler := range o.handlersForMotion() {
2885 _ = i
2886 handler(time, surfaceX, surfaceY)
2887 }
2888 case 3: // button
2889 serial := event.Uint32()
2890 time := event.Uint32()
2891 button := event.Uint32()
2892 state := event.Uint32()
2893
2894 for i, handler := range o.handlersForButton() {
2895 _ = i
2896 handler(serial, time, button, state)
2897 }
2898 case 4: // axis
2899 time := event.Uint32()
2900 axis := event.Uint32()
2901 value := event.Fixed()
2902
2903 for i, handler := range o.handlersForAxis() {
2904 _ = i
2905 handler(time, axis, value)
2906 }
2907 case 5: // frame
2908
2909 for i, handler := range o.handlersForFrame() {
2910 _ = i
2911 handler()
2912 }
2913 case 6: // axis_source
2914 axisSource := event.Uint32()
2915
2916 for i, handler := range o.handlersForAxisSource() {
2917 _ = i
2918 handler(axisSource)
2919 }
2920 case 7: // axis_stop
2921 time := event.Uint32()
2922 axis := event.Uint32()
2923
2924 for i, handler := range o.handlersForAxisStop() {
2925 _ = i
2926 handler(time, axis)
2927 }
2928 case 8: // axis_discrete
2929 axis := event.Uint32()
2930 discrete := event.Int32()
2931
2932 for i, handler := range o.handlersForAxisDiscrete() {
2933 _ = i
2934 handler(axis, discrete)
2935 }
2936 case 9: // axis_value120
2937 axis := event.Uint32()
2938 value120 := event.Int32()
2939
2940 for i, handler := range o.handlersForAxisValue120() {
2941 _ = i
2942 handler(axis, value120)
2943 }
2944 case 10: // axis_relative_direction
2945 axis := event.Uint32()
2946 direction := event.Uint32()
2947
2948 for i, handler := range o.handlersForAxisRelativeDirection() {
2949 _ = i
2950 handler(axis, direction)
2951 }
2952 case 11: // warp
2953 surfaceX := event.Fixed()
2954 surfaceY := event.Fixed()
2955
2956 for i, handler := range o.handlersForWarp() {
2957 _ = i
2958 handler(surfaceX, surfaceY)
2959 }
2960 default:
2961 }
2962}
2963
2964// KeyboardInterface is the protocol interface name.
2965const KeyboardInterface = "wl_keyboard"
2966
2967// Keyboard is the generated binding for wl_keyboard version 11.
2968type Keyboard struct {
2969 wl.BaseProxy
2970 // handlersMu guards the handler slices: a client may register or replace
2971 // handlers while another goroutine dispatches events.
2972 handlersMu sync.Mutex
2973 onKeymap []func(format uint32, fd *wl.OwnedFD, size uint32)
2974 onEnter []func(serial uint32, surfaceID uint32, keys []byte)
2975 onLeave []func(serial uint32, surfaceID uint32)
2976 onKey []func(serial uint32, time uint32, key uint32, state uint32)
2977 onModifiers []func(serial uint32, modsDepressed uint32, modsLatched uint32, modsLocked uint32, group uint32)
2978 onRepeatInfo []func(rate int32, delay int32)
2979}
2980
2981// NewKeyboard returns an unbound Keyboard.
2982func NewKeyboard(ctx *wl.Context) *Keyboard {
2983 obj := &Keyboard{}
2984 obj.SetContext(ctx)
2985 ctx.Register(obj)
2986 return obj
2987}
2988
2989// release the keyboard object
2990func (o *Keyboard) Release() error {
2991 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_keyboard.release", Since: 3, Destructor: true}); err != nil {
2992 return err
2993 }
2994 return nil
2995}
2996
2997// OnKeymap registers a handler for the keymap event.
2998//
2999// Handlers are appended, so a second call adds another handler rather than
3000// replacing the first. Registration is safe while another goroutine dispatches.
3001func (o *Keyboard) OnKeymap(handler func(format uint32, fd *wl.OwnedFD, size uint32)) {
3002 if handler == nil {
3003 return
3004 }
3005 o.handlersMu.Lock()
3006 defer o.handlersMu.Unlock()
3007 o.onKeymap = append(o.onKeymap, handler)
3008}
3009
3010// handlersForKeymap returns the handlers registered for keymap, taken
3011// under the lock so a handler may register another handler while events are
3012// being dispatched.
3013func (o *Keyboard) handlersForKeymap() []func(format uint32, fd *wl.OwnedFD, size uint32) {
3014 o.handlersMu.Lock()
3015 defer o.handlersMu.Unlock()
3016 return o.onKeymap
3017}
3018
3019// OnEnter registers a handler for the enter event.
3020//
3021// Handlers are appended, so a second call adds another handler rather than
3022// replacing the first. Registration is safe while another goroutine dispatches.
3023func (o *Keyboard) OnEnter(handler func(serial uint32, surfaceID uint32, keys []byte)) {
3024 if handler == nil {
3025 return
3026 }
3027 o.handlersMu.Lock()
3028 defer o.handlersMu.Unlock()
3029 o.onEnter = append(o.onEnter, handler)
3030}
3031
3032// handlersForEnter returns the handlers registered for enter, taken
3033// under the lock so a handler may register another handler while events are
3034// being dispatched.
3035func (o *Keyboard) handlersForEnter() []func(serial uint32, surfaceID uint32, keys []byte) {
3036 o.handlersMu.Lock()
3037 defer o.handlersMu.Unlock()
3038 return o.onEnter
3039}
3040
3041// OnLeave registers a handler for the leave event.
3042//
3043// Handlers are appended, so a second call adds another handler rather than
3044// replacing the first. Registration is safe while another goroutine dispatches.
3045func (o *Keyboard) OnLeave(handler func(serial uint32, surfaceID uint32)) {
3046 if handler == nil {
3047 return
3048 }
3049 o.handlersMu.Lock()
3050 defer o.handlersMu.Unlock()
3051 o.onLeave = append(o.onLeave, handler)
3052}
3053
3054// handlersForLeave returns the handlers registered for leave, taken
3055// under the lock so a handler may register another handler while events are
3056// being dispatched.
3057func (o *Keyboard) handlersForLeave() []func(serial uint32, surfaceID uint32) {
3058 o.handlersMu.Lock()
3059 defer o.handlersMu.Unlock()
3060 return o.onLeave
3061}
3062
3063// OnKey registers a handler for the key event.
3064//
3065// Handlers are appended, so a second call adds another handler rather than
3066// replacing the first. Registration is safe while another goroutine dispatches.
3067func (o *Keyboard) OnKey(handler func(serial uint32, time uint32, key uint32, state uint32)) {
3068 if handler == nil {
3069 return
3070 }
3071 o.handlersMu.Lock()
3072 defer o.handlersMu.Unlock()
3073 o.onKey = append(o.onKey, handler)
3074}
3075
3076// handlersForKey returns the handlers registered for key, taken
3077// under the lock so a handler may register another handler while events are
3078// being dispatched.
3079func (o *Keyboard) handlersForKey() []func(serial uint32, time uint32, key uint32, state uint32) {
3080 o.handlersMu.Lock()
3081 defer o.handlersMu.Unlock()
3082 return o.onKey
3083}
3084
3085// OnModifiers registers a handler for the modifiers event.
3086//
3087// Handlers are appended, so a second call adds another handler rather than
3088// replacing the first. Registration is safe while another goroutine dispatches.
3089func (o *Keyboard) OnModifiers(handler func(serial uint32, modsDepressed uint32, modsLatched uint32, modsLocked uint32, group uint32)) {
3090 if handler == nil {
3091 return
3092 }
3093 o.handlersMu.Lock()
3094 defer o.handlersMu.Unlock()
3095 o.onModifiers = append(o.onModifiers, handler)
3096}
3097
3098// handlersForModifiers returns the handlers registered for modifiers, taken
3099// under the lock so a handler may register another handler while events are
3100// being dispatched.
3101func (o *Keyboard) handlersForModifiers() []func(serial uint32, modsDepressed uint32, modsLatched uint32, modsLocked uint32, group uint32) {
3102 o.handlersMu.Lock()
3103 defer o.handlersMu.Unlock()
3104 return o.onModifiers
3105}
3106
3107// OnRepeatInfo registers a handler for the repeat_info event.
3108//
3109// Handlers are appended, so a second call adds another handler rather than
3110// replacing the first. Registration is safe while another goroutine dispatches.
3111func (o *Keyboard) OnRepeatInfo(handler func(rate int32, delay int32)) {
3112 if handler == nil {
3113 return
3114 }
3115 o.handlersMu.Lock()
3116 defer o.handlersMu.Unlock()
3117 o.onRepeatInfo = append(o.onRepeatInfo, handler)
3118}
3119
3120// handlersForRepeatInfo returns the handlers registered for repeat_info, taken
3121// under the lock so a handler may register another handler while events are
3122// being dispatched.
3123func (o *Keyboard) handlersForRepeatInfo() []func(rate int32, delay int32) {
3124 o.handlersMu.Lock()
3125 defer o.handlersMu.Unlock()
3126 return o.onRepeatInfo
3127}
3128
3129// EventSignature returns the declared event argument types in wire order.
3130func (o *Keyboard) EventSignature(opcode uint16) (string, bool) {
3131 switch opcode {
3132 case 0:
3133 return "uint,fd,uint,", true
3134 case 1:
3135 return "uint,object,array,", true
3136 case 2:
3137 return "uint,object,", true
3138 case 3:
3139 return "uint,uint,uint,uint,", true
3140 case 4:
3141 return "uint,uint,uint,uint,uint,", true
3142 case 5:
3143 return "int,int,", true
3144 default:
3145 return "", false
3146 }
3147}
3148
3149// Dispatch decodes one event on wl_keyboard and calls the registered handlers.
3150func (o *Keyboard) Dispatch(event *wl.Event) {
3151 switch event.Opcode {
3152 case 0: // keymap
3153 format := event.Uint32()
3154 fd := event.FD()
3155 size := event.Uint32()
3156 ownedfd := fd
3157 defer ownedfd.Close()
3158
3159 for i, handler := range o.handlersForKeymap() {
3160 if i > 0 {
3161 fd = nil
3162 }
3163 handler(format, fd, size)
3164 }
3165 case 1: // enter
3166 serial := event.Uint32()
3167 surfaceID := event.Uint32()
3168 keys := event.Array()
3169
3170 for i, handler := range o.handlersForEnter() {
3171 _ = i
3172 handler(serial, surfaceID, keys)
3173 }
3174 case 2: // leave
3175 serial := event.Uint32()
3176 surfaceID := event.Uint32()
3177
3178 for i, handler := range o.handlersForLeave() {
3179 _ = i
3180 handler(serial, surfaceID)
3181 }
3182 case 3: // key
3183 serial := event.Uint32()
3184 time := event.Uint32()
3185 key := event.Uint32()
3186 state := event.Uint32()
3187
3188 for i, handler := range o.handlersForKey() {
3189 _ = i
3190 handler(serial, time, key, state)
3191 }
3192 case 4: // modifiers
3193 serial := event.Uint32()
3194 modsDepressed := event.Uint32()
3195 modsLatched := event.Uint32()
3196 modsLocked := event.Uint32()
3197 group := event.Uint32()
3198
3199 for i, handler := range o.handlersForModifiers() {
3200 _ = i
3201 handler(serial, modsDepressed, modsLatched, modsLocked, group)
3202 }
3203 case 5: // repeat_info
3204 rate := event.Int32()
3205 delay := event.Int32()
3206
3207 for i, handler := range o.handlersForRepeatInfo() {
3208 _ = i
3209 handler(rate, delay)
3210 }
3211 default:
3212 }
3213}
3214
3215// TouchInterface is the protocol interface name.
3216const TouchInterface = "wl_touch"
3217
3218// Touch is the generated binding for wl_touch version 11.
3219type Touch struct {
3220 wl.BaseProxy
3221 // handlersMu guards the handler slices: a client may register or replace
3222 // handlers while another goroutine dispatches events.
3223 handlersMu sync.Mutex
3224 onDown []func(serial uint32, time uint32, surfaceID uint32, id int32, x wl.Fixed, y wl.Fixed)
3225 onUp []func(serial uint32, time uint32, id int32)
3226 onMotion []func(time uint32, id int32, x wl.Fixed, y wl.Fixed)
3227 onFrame []func()
3228 onCancel []func()
3229 onShape []func(id int32, major wl.Fixed, minor wl.Fixed)
3230 onOrientation []func(id int32, orientation wl.Fixed)
3231}
3232
3233// NewTouch returns an unbound Touch.
3234func NewTouch(ctx *wl.Context) *Touch {
3235 obj := &Touch{}
3236 obj.SetContext(ctx)
3237 ctx.Register(obj)
3238 return obj
3239}
3240
3241// release the touch object
3242func (o *Touch) Release() error {
3243 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_touch.release", Since: 3, Destructor: true}); err != nil {
3244 return err
3245 }
3246 return nil
3247}
3248
3249// OnDown registers a handler for the down event.
3250//
3251// Handlers are appended, so a second call adds another handler rather than
3252// replacing the first. Registration is safe while another goroutine dispatches.
3253func (o *Touch) OnDown(handler func(serial uint32, time uint32, surfaceID uint32, id int32, x wl.Fixed, y wl.Fixed)) {
3254 if handler == nil {
3255 return
3256 }
3257 o.handlersMu.Lock()
3258 defer o.handlersMu.Unlock()
3259 o.onDown = append(o.onDown, handler)
3260}
3261
3262// handlersForDown returns the handlers registered for down, taken
3263// under the lock so a handler may register another handler while events are
3264// being dispatched.
3265func (o *Touch) handlersForDown() []func(serial uint32, time uint32, surfaceID uint32, id int32, x wl.Fixed, y wl.Fixed) {
3266 o.handlersMu.Lock()
3267 defer o.handlersMu.Unlock()
3268 return o.onDown
3269}
3270
3271// OnUp registers a handler for the up event.
3272//
3273// Handlers are appended, so a second call adds another handler rather than
3274// replacing the first. Registration is safe while another goroutine dispatches.
3275func (o *Touch) OnUp(handler func(serial uint32, time uint32, id int32)) {
3276 if handler == nil {
3277 return
3278 }
3279 o.handlersMu.Lock()
3280 defer o.handlersMu.Unlock()
3281 o.onUp = append(o.onUp, handler)
3282}
3283
3284// handlersForUp returns the handlers registered for up, taken
3285// under the lock so a handler may register another handler while events are
3286// being dispatched.
3287func (o *Touch) handlersForUp() []func(serial uint32, time uint32, id int32) {
3288 o.handlersMu.Lock()
3289 defer o.handlersMu.Unlock()
3290 return o.onUp
3291}
3292
3293// OnMotion registers a handler for the motion event.
3294//
3295// Handlers are appended, so a second call adds another handler rather than
3296// replacing the first. Registration is safe while another goroutine dispatches.
3297func (o *Touch) OnMotion(handler func(time uint32, id int32, x wl.Fixed, y wl.Fixed)) {
3298 if handler == nil {
3299 return
3300 }
3301 o.handlersMu.Lock()
3302 defer o.handlersMu.Unlock()
3303 o.onMotion = append(o.onMotion, handler)
3304}
3305
3306// handlersForMotion returns the handlers registered for motion, taken
3307// under the lock so a handler may register another handler while events are
3308// being dispatched.
3309func (o *Touch) handlersForMotion() []func(time uint32, id int32, x wl.Fixed, y wl.Fixed) {
3310 o.handlersMu.Lock()
3311 defer o.handlersMu.Unlock()
3312 return o.onMotion
3313}
3314
3315// OnFrame registers a handler for the frame event.
3316//
3317// Handlers are appended, so a second call adds another handler rather than
3318// replacing the first. Registration is safe while another goroutine dispatches.
3319func (o *Touch) OnFrame(handler func()) {
3320 if handler == nil {
3321 return
3322 }
3323 o.handlersMu.Lock()
3324 defer o.handlersMu.Unlock()
3325 o.onFrame = append(o.onFrame, handler)
3326}
3327
3328// handlersForFrame returns the handlers registered for frame, taken
3329// under the lock so a handler may register another handler while events are
3330// being dispatched.
3331func (o *Touch) handlersForFrame() []func() {
3332 o.handlersMu.Lock()
3333 defer o.handlersMu.Unlock()
3334 return o.onFrame
3335}
3336
3337// OnCancel registers a handler for the cancel event.
3338//
3339// Handlers are appended, so a second call adds another handler rather than
3340// replacing the first. Registration is safe while another goroutine dispatches.
3341func (o *Touch) OnCancel(handler func()) {
3342 if handler == nil {
3343 return
3344 }
3345 o.handlersMu.Lock()
3346 defer o.handlersMu.Unlock()
3347 o.onCancel = append(o.onCancel, handler)
3348}
3349
3350// handlersForCancel returns the handlers registered for cancel, taken
3351// under the lock so a handler may register another handler while events are
3352// being dispatched.
3353func (o *Touch) handlersForCancel() []func() {
3354 o.handlersMu.Lock()
3355 defer o.handlersMu.Unlock()
3356 return o.onCancel
3357}
3358
3359// OnShape registers a handler for the shape event.
3360//
3361// Handlers are appended, so a second call adds another handler rather than
3362// replacing the first. Registration is safe while another goroutine dispatches.
3363func (o *Touch) OnShape(handler func(id int32, major wl.Fixed, minor wl.Fixed)) {
3364 if handler == nil {
3365 return
3366 }
3367 o.handlersMu.Lock()
3368 defer o.handlersMu.Unlock()
3369 o.onShape = append(o.onShape, handler)
3370}
3371
3372// handlersForShape returns the handlers registered for shape, taken
3373// under the lock so a handler may register another handler while events are
3374// being dispatched.
3375func (o *Touch) handlersForShape() []func(id int32, major wl.Fixed, minor wl.Fixed) {
3376 o.handlersMu.Lock()
3377 defer o.handlersMu.Unlock()
3378 return o.onShape
3379}
3380
3381// OnOrientation registers a handler for the orientation event.
3382//
3383// Handlers are appended, so a second call adds another handler rather than
3384// replacing the first. Registration is safe while another goroutine dispatches.
3385func (o *Touch) OnOrientation(handler func(id int32, orientation wl.Fixed)) {
3386 if handler == nil {
3387 return
3388 }
3389 o.handlersMu.Lock()
3390 defer o.handlersMu.Unlock()
3391 o.onOrientation = append(o.onOrientation, handler)
3392}
3393
3394// handlersForOrientation returns the handlers registered for orientation, taken
3395// under the lock so a handler may register another handler while events are
3396// being dispatched.
3397func (o *Touch) handlersForOrientation() []func(id int32, orientation wl.Fixed) {
3398 o.handlersMu.Lock()
3399 defer o.handlersMu.Unlock()
3400 return o.onOrientation
3401}
3402
3403// EventSignature returns the declared event argument types in wire order.
3404func (o *Touch) EventSignature(opcode uint16) (string, bool) {
3405 switch opcode {
3406 case 0:
3407 return "uint,uint,object,int,fixed,fixed,", true
3408 case 1:
3409 return "uint,uint,int,", true
3410 case 2:
3411 return "uint,int,fixed,fixed,", true
3412 case 3:
3413 return "", true
3414 case 4:
3415 return "", true
3416 case 5:
3417 return "int,fixed,fixed,", true
3418 case 6:
3419 return "int,fixed,", true
3420 default:
3421 return "", false
3422 }
3423}
3424
3425// Dispatch decodes one event on wl_touch and calls the registered handlers.
3426func (o *Touch) Dispatch(event *wl.Event) {
3427 switch event.Opcode {
3428 case 0: // down
3429 serial := event.Uint32()
3430 time := event.Uint32()
3431 surfaceID := event.Uint32()
3432 id := event.Int32()
3433 x := event.Fixed()
3434 y := event.Fixed()
3435
3436 for i, handler := range o.handlersForDown() {
3437 _ = i
3438 handler(serial, time, surfaceID, id, x, y)
3439 }
3440 case 1: // up
3441 serial := event.Uint32()
3442 time := event.Uint32()
3443 id := event.Int32()
3444
3445 for i, handler := range o.handlersForUp() {
3446 _ = i
3447 handler(serial, time, id)
3448 }
3449 case 2: // motion
3450 time := event.Uint32()
3451 id := event.Int32()
3452 x := event.Fixed()
3453 y := event.Fixed()
3454
3455 for i, handler := range o.handlersForMotion() {
3456 _ = i
3457 handler(time, id, x, y)
3458 }
3459 case 3: // frame
3460
3461 for i, handler := range o.handlersForFrame() {
3462 _ = i
3463 handler()
3464 }
3465 case 4: // cancel
3466
3467 for i, handler := range o.handlersForCancel() {
3468 _ = i
3469 handler()
3470 }
3471 case 5: // shape
3472 id := event.Int32()
3473 major := event.Fixed()
3474 minor := event.Fixed()
3475
3476 for i, handler := range o.handlersForShape() {
3477 _ = i
3478 handler(id, major, minor)
3479 }
3480 case 6: // orientation
3481 id := event.Int32()
3482 orientation := event.Fixed()
3483
3484 for i, handler := range o.handlersForOrientation() {
3485 _ = i
3486 handler(id, orientation)
3487 }
3488 default:
3489 }
3490}
3491
3492// OutputInterface is the protocol interface name.
3493const OutputInterface = "wl_output"
3494
3495// Output is the generated binding for wl_output version 4.
3496type Output struct {
3497 wl.BaseProxy
3498 // handlersMu guards the handler slices: a client may register or replace
3499 // handlers while another goroutine dispatches events.
3500 handlersMu sync.Mutex
3501 onGeometry []func(x int32, y int32, physicalWidth int32, physicalHeight int32, subpixel int32, make string, model string, transform int32)
3502 onMode []func(flags uint32, width int32, height int32, refresh int32)
3503 onDone []func()
3504 onScale []func(factor int32)
3505 onName []func(name string)
3506 onDescription []func(description string)
3507}
3508
3509// NewOutput returns an unbound Output.
3510func NewOutput(ctx *wl.Context) *Output {
3511 obj := &Output{}
3512 obj.SetContext(ctx)
3513 ctx.Register(obj)
3514 return obj
3515}
3516
3517// Using this request a client can tell the server that it is not going to use the output object anymore.
3518func (o *Output) Release() error {
3519 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_output.release", Since: 3, Destructor: true}); err != nil {
3520 return err
3521 }
3522 return nil
3523}
3524
3525// OnGeometry registers a handler for the geometry event.
3526//
3527// Handlers are appended, so a second call adds another handler rather than
3528// replacing the first. Registration is safe while another goroutine dispatches.
3529func (o *Output) OnGeometry(handler func(x int32, y int32, physicalWidth int32, physicalHeight int32, subpixel int32, make string, model string, transform int32)) {
3530 if handler == nil {
3531 return
3532 }
3533 o.handlersMu.Lock()
3534 defer o.handlersMu.Unlock()
3535 o.onGeometry = append(o.onGeometry, handler)
3536}
3537
3538// handlersForGeometry returns the handlers registered for geometry, taken
3539// under the lock so a handler may register another handler while events are
3540// being dispatched.
3541func (o *Output) handlersForGeometry() []func(x int32, y int32, physicalWidth int32, physicalHeight int32, subpixel int32, make string, model string, transform int32) {
3542 o.handlersMu.Lock()
3543 defer o.handlersMu.Unlock()
3544 return o.onGeometry
3545}
3546
3547// OnMode registers a handler for the mode event.
3548//
3549// Handlers are appended, so a second call adds another handler rather than
3550// replacing the first. Registration is safe while another goroutine dispatches.
3551func (o *Output) OnMode(handler func(flags uint32, width int32, height int32, refresh int32)) {
3552 if handler == nil {
3553 return
3554 }
3555 o.handlersMu.Lock()
3556 defer o.handlersMu.Unlock()
3557 o.onMode = append(o.onMode, handler)
3558}
3559
3560// handlersForMode returns the handlers registered for mode, taken
3561// under the lock so a handler may register another handler while events are
3562// being dispatched.
3563func (o *Output) handlersForMode() []func(flags uint32, width int32, height int32, refresh int32) {
3564 o.handlersMu.Lock()
3565 defer o.handlersMu.Unlock()
3566 return o.onMode
3567}
3568
3569// OnDone registers a handler for the done event.
3570//
3571// Handlers are appended, so a second call adds another handler rather than
3572// replacing the first. Registration is safe while another goroutine dispatches.
3573func (o *Output) OnDone(handler func()) {
3574 if handler == nil {
3575 return
3576 }
3577 o.handlersMu.Lock()
3578 defer o.handlersMu.Unlock()
3579 o.onDone = append(o.onDone, handler)
3580}
3581
3582// handlersForDone returns the handlers registered for done, taken
3583// under the lock so a handler may register another handler while events are
3584// being dispatched.
3585func (o *Output) handlersForDone() []func() {
3586 o.handlersMu.Lock()
3587 defer o.handlersMu.Unlock()
3588 return o.onDone
3589}
3590
3591// OnScale registers a handler for the scale event.
3592//
3593// Handlers are appended, so a second call adds another handler rather than
3594// replacing the first. Registration is safe while another goroutine dispatches.
3595func (o *Output) OnScale(handler func(factor int32)) {
3596 if handler == nil {
3597 return
3598 }
3599 o.handlersMu.Lock()
3600 defer o.handlersMu.Unlock()
3601 o.onScale = append(o.onScale, handler)
3602}
3603
3604// handlersForScale returns the handlers registered for scale, taken
3605// under the lock so a handler may register another handler while events are
3606// being dispatched.
3607func (o *Output) handlersForScale() []func(factor int32) {
3608 o.handlersMu.Lock()
3609 defer o.handlersMu.Unlock()
3610 return o.onScale
3611}
3612
3613// OnName registers a handler for the name event.
3614//
3615// Handlers are appended, so a second call adds another handler rather than
3616// replacing the first. Registration is safe while another goroutine dispatches.
3617func (o *Output) OnName(handler func(name string)) {
3618 if handler == nil {
3619 return
3620 }
3621 o.handlersMu.Lock()
3622 defer o.handlersMu.Unlock()
3623 o.onName = append(o.onName, handler)
3624}
3625
3626// handlersForName returns the handlers registered for name, taken
3627// under the lock so a handler may register another handler while events are
3628// being dispatched.
3629func (o *Output) handlersForName() []func(name string) {
3630 o.handlersMu.Lock()
3631 defer o.handlersMu.Unlock()
3632 return o.onName
3633}
3634
3635// OnDescription registers a handler for the description event.
3636//
3637// Handlers are appended, so a second call adds another handler rather than
3638// replacing the first. Registration is safe while another goroutine dispatches.
3639func (o *Output) OnDescription(handler func(description string)) {
3640 if handler == nil {
3641 return
3642 }
3643 o.handlersMu.Lock()
3644 defer o.handlersMu.Unlock()
3645 o.onDescription = append(o.onDescription, handler)
3646}
3647
3648// handlersForDescription returns the handlers registered for description, taken
3649// under the lock so a handler may register another handler while events are
3650// being dispatched.
3651func (o *Output) handlersForDescription() []func(description string) {
3652 o.handlersMu.Lock()
3653 defer o.handlersMu.Unlock()
3654 return o.onDescription
3655}
3656
3657// EventSignature returns the declared event argument types in wire order.
3658func (o *Output) EventSignature(opcode uint16) (string, bool) {
3659 switch opcode {
3660 case 0:
3661 return "int,int,int,int,int,string,string,int,", true
3662 case 1:
3663 return "uint,int,int,int,", true
3664 case 2:
3665 return "", true
3666 case 3:
3667 return "int,", true
3668 case 4:
3669 return "string,", true
3670 case 5:
3671 return "string,", true
3672 default:
3673 return "", false
3674 }
3675}
3676
3677// Dispatch decodes one event on wl_output and calls the registered handlers.
3678func (o *Output) Dispatch(event *wl.Event) {
3679 switch event.Opcode {
3680 case 0: // geometry
3681 x := event.Int32()
3682 y := event.Int32()
3683 physicalWidth := event.Int32()
3684 physicalHeight := event.Int32()
3685 subpixel := event.Int32()
3686 make := event.String()
3687 model := event.String()
3688 transform := event.Int32()
3689
3690 for i, handler := range o.handlersForGeometry() {
3691 _ = i
3692 handler(x, y, physicalWidth, physicalHeight, subpixel, make, model, transform)
3693 }
3694 case 1: // mode
3695 flags := event.Uint32()
3696 width := event.Int32()
3697 height := event.Int32()
3698 refresh := event.Int32()
3699
3700 for i, handler := range o.handlersForMode() {
3701 _ = i
3702 handler(flags, width, height, refresh)
3703 }
3704 case 2: // done
3705
3706 for i, handler := range o.handlersForDone() {
3707 _ = i
3708 handler()
3709 }
3710 case 3: // scale
3711 factor := event.Int32()
3712
3713 for i, handler := range o.handlersForScale() {
3714 _ = i
3715 handler(factor)
3716 }
3717 case 4: // name
3718 name := event.String()
3719
3720 for i, handler := range o.handlersForName() {
3721 _ = i
3722 handler(name)
3723 }
3724 case 5: // description
3725 description := event.String()
3726
3727 for i, handler := range o.handlersForDescription() {
3728 _ = i
3729 handler(description)
3730 }
3731 default:
3732 }
3733}
3734
3735// RegionInterface is the protocol interface name.
3736const RegionInterface = "wl_region"
3737
3738// Region is the generated binding for wl_region version 7.
3739type Region struct {
3740 wl.BaseProxy
3741}
3742
3743// NewRegion returns an unbound Region.
3744func NewRegion(ctx *wl.Context) *Region {
3745 obj := &Region{}
3746 obj.SetContext(ctx)
3747 ctx.Register(obj)
3748 return obj
3749}
3750
3751// Destroy the region. This will invalidate the object ID.
3752func (o *Region) Destroy() error {
3753 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_region.destroy", Destructor: true}); err != nil {
3754 return err
3755 }
3756 return nil
3757}
3758
3759// Add the specified rectangle to the region.
3760func (o *Region) Add(x int32, y int32, width int32, height int32) error {
3761 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_region.add"}, wl.ArgInt(x), wl.ArgInt(y), wl.ArgInt(width), wl.ArgInt(height)); err != nil {
3762 return err
3763 }
3764 return nil
3765}
3766
3767// Subtract the specified rectangle from the region.
3768func (o *Region) Subtract(x int32, y int32, width int32, height int32) error {
3769 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_region.subtract"}, wl.ArgInt(x), wl.ArgInt(y), wl.ArgInt(width), wl.ArgInt(height)); err != nil {
3770 return err
3771 }
3772 return nil
3773}
3774
3775// EventSignature returns the declared event argument types in wire order.
3776func (o *Region) EventSignature(opcode uint16) (string, bool) {
3777 switch opcode {
3778 default:
3779 return "", false
3780 }
3781}
3782
3783// Dispatch decodes one event on wl_region and calls the registered handlers.
3784func (o *Region) Dispatch(event *wl.Event) {
3785 switch event.Opcode {
3786 default:
3787 }
3788}
3789
3790// SubcompositorInterface is the protocol interface name.
3791const SubcompositorInterface = "wl_subcompositor"
3792
3793// Subcompositor is the generated binding for wl_subcompositor version 1.
3794type Subcompositor struct {
3795 wl.BaseProxy
3796}
3797
3798// NewSubcompositor returns an unbound Subcompositor.
3799func NewSubcompositor(ctx *wl.Context) *Subcompositor {
3800 obj := &Subcompositor{}
3801 obj.SetContext(ctx)
3802 ctx.Register(obj)
3803 return obj
3804}
3805
3806// Informs the server that the client will not be using this protocol object anymore. This does not affect any other objects, wl_subsurface objects included.
3807func (o *Subcompositor) Destroy() error {
3808 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_subcompositor.destroy", Destructor: true}); err != nil {
3809 return err
3810 }
3811 return nil
3812}
3813
3814// Create a sub-surface interface for the given surface, and associate it with the given parent surface. This turns a plain wl_surface into a sub-surface. The to-be sub-surface must not already have another role, and it must not have an existing wl_subsurface object. Otherwise the bad_surface protocol error is raised. Adding sub-surfaces to a parent is a double-buffered operation on the parent (see wl_surface.commit). The effect of adding a sub-surface becomes visible on the next time the state of the parent surface is applied. The parent surface must not be one of the child surface's descendants, and the parent must be different from the child surface, otherwise the bad_parent protocol error is raised. This request modifies the behaviour of wl_surface.commit request on the sub-surface, see the documentation on wl_subsurface interface.
3815func (o *Subcompositor) GetSubsurface(surface *Surface, parent *Surface) (*Subsurface, error) {
3816 var arg1 wl.Object
3817 if surface != nil {
3818 arg1 = surface
3819 }
3820 var arg2 wl.Object
3821 if parent != nil {
3822 arg2 = parent
3823 }
3824 child := &Subsurface{}
3825 child.SetContext(o.Context())
3826 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_subcompositor.get_subsurface", Child: child}, wl.ArgObject(child), wl.ArgObject(arg1), wl.ArgObject(arg2)); err != nil {
3827 return nil, err
3828 }
3829 return child, nil
3830}
3831
3832// EventSignature returns the declared event argument types in wire order.
3833func (o *Subcompositor) EventSignature(opcode uint16) (string, bool) {
3834 switch opcode {
3835 default:
3836 return "", false
3837 }
3838}
3839
3840// Dispatch decodes one event on wl_subcompositor and calls the registered handlers.
3841func (o *Subcompositor) Dispatch(event *wl.Event) {
3842 switch event.Opcode {
3843 default:
3844 }
3845}
3846
3847// SubsurfaceInterface is the protocol interface name.
3848const SubsurfaceInterface = "wl_subsurface"
3849
3850// Subsurface is the generated binding for wl_subsurface version 1.
3851type Subsurface struct {
3852 wl.BaseProxy
3853}
3854
3855// NewSubsurface returns an unbound Subsurface.
3856func NewSubsurface(ctx *wl.Context) *Subsurface {
3857 obj := &Subsurface{}
3858 obj.SetContext(ctx)
3859 ctx.Register(obj)
3860 return obj
3861}
3862
3863// The sub-surface interface is removed from the wl_surface object that was turned into a sub-surface with a wl_subcompositor.get_subsurface request. The wl_surface's association to the parent is deleted. The wl_surface is unmapped immediately.
3864func (o *Subsurface) Destroy() error {
3865 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_subsurface.destroy", Destructor: true}); err != nil {
3866 return err
3867 }
3868 return nil
3869}
3870
3871// This sets the position of the sub-surface, relative to the parent surface. The sub-surface will be moved so that its origin (top left corner pixel) will be at the location x, y of the parent surface coordinate system. The coordinates are not restricted to the parent surface area. Negative values are allowed. The initial position is 0, 0. Position is double-buffered state on the parent surface, see wl_subsurface and wl_surface.commit for more information.
3872func (o *Subsurface) SetPosition(x int32, y int32) error {
3873 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_subsurface.set_position"}, wl.ArgInt(x), wl.ArgInt(y)); err != nil {
3874 return err
3875 }
3876 return nil
3877}
3878
3879// This sub-surface is taken from the stack, and put back just above the reference surface, changing the z-order of the sub-surfaces. The reference surface must be one of the sibling surfaces, or the parent surface. Using any other surface, including this sub-surface, will cause a protocol error. A new sub-surface is initially added as the top-most in the stack of its siblings and parent. Z-order is double-buffered state on the parent surface, see wl_subsurface and wl_surface.commit for more information.
3880func (o *Subsurface) PlaceAbove(sibling *Surface) error {
3881 var arg0 wl.Object
3882 if sibling != nil {
3883 arg0 = sibling
3884 }
3885 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_subsurface.place_above"}, wl.ArgObject(arg0)); err != nil {
3886 return err
3887 }
3888 return nil
3889}
3890
3891// The sub-surface is placed just below the reference surface. See wl_subsurface.place_above.
3892func (o *Subsurface) PlaceBelow(sibling *Surface) error {
3893 var arg0 wl.Object
3894 if sibling != nil {
3895 arg0 = sibling
3896 }
3897 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 3, Name: "wl_subsurface.place_below"}, wl.ArgObject(arg0)); err != nil {
3898 return err
3899 }
3900 return nil
3901}
3902
3903// Change the commit behaviour of the sub-surface to synchronized mode. See wl_subsurface and wl_surface.commit for more information.
3904func (o *Subsurface) SetSync() error {
3905 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 4, Name: "wl_subsurface.set_sync"}); err != nil {
3906 return err
3907 }
3908 return nil
3909}
3910
3911// Change the commit behaviour of the sub-surface to desynchronized mode. See wl_subsurface and wl_surface.commit for more information.
3912func (o *Subsurface) SetDesync() error {
3913 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 5, Name: "wl_subsurface.set_desync"}); err != nil {
3914 return err
3915 }
3916 return nil
3917}
3918
3919// EventSignature returns the declared event argument types in wire order.
3920func (o *Subsurface) EventSignature(opcode uint16) (string, bool) {
3921 switch opcode {
3922 default:
3923 return "", false
3924 }
3925}
3926
3927// Dispatch decodes one event on wl_subsurface and calls the registered handlers.
3928func (o *Subsurface) Dispatch(event *wl.Event) {
3929 switch event.Opcode {
3930 default:
3931 }
3932}
3933
3934// FixesInterface is the protocol interface name.
3935const FixesInterface = "wl_fixes"
3936
3937// Fixes is the generated binding for wl_fixes version 2.
3938type Fixes struct {
3939 wl.BaseProxy
3940}
3941
3942// NewFixes returns an unbound Fixes.
3943func NewFixes(ctx *wl.Context) *Fixes {
3944 obj := &Fixes{}
3945 obj.SetContext(ctx)
3946 ctx.Register(obj)
3947 return obj
3948}
3949
3950// destroys this object
3951func (o *Fixes) Destroy() error {
3952 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 0, Name: "wl_fixes.destroy", Destructor: true}); err != nil {
3953 return err
3954 }
3955 return nil
3956}
3957
3958// This request destroys a wl_registry object. The client should no longer use the wl_registry after making this request. The compositor will emit a wl_display.delete_id event with the object ID of the registry and will no longer emit any events on the registry. The client should re-use the object ID once it receives the wl_display.delete_id event.
3959func (o *Fixes) DestroyRegistry(registry *wl.Registry) error {
3960 var arg0 wl.Object
3961 if registry != nil {
3962 arg0 = registry
3963 }
3964 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 1, Name: "wl_fixes.destroy_registry"}, wl.ArgObject(arg0)); err != nil {
3965 return err
3966 }
3967 return nil
3968}
3969
3970// Acknowledge the removal of the specified global. If no global with the specified name exists or the global is not removed, the wl_fixes.invalid_ack_remove protocol error will be posted. Due to the Wayland protocol being asynchronous, the wl_global objects cannot be destroyed immediately. For example, if a wl_global is removed and a client attempts to bind that global around same time, it can result in a protocol error due to an unknown global name in the bind request. In order to avoid crashing clients, the compositor should remove the wl_global once it is guaranteed that no more bind requests will come. The wl_fixes.ack_global_remove() request is used to signal to the compositor that the client will not bind the given global anymore. After all clients acknowledge the removal of the global, the compositor can safely destroy it. The client must call the wl_fixes.ack_global_remove() request in response to a wl_registry.global_remove() event even if it did not bind the corresponding global.
3971func (o *Fixes) AckGlobalRemove(registry *wl.Registry, name uint32) error {
3972 var arg0 wl.Object
3973 if registry != nil {
3974 arg0 = registry
3975 }
3976 if err := o.Context().RequestArgs(wl.Request{Proxy: o, Opcode: 2, Name: "wl_fixes.ack_global_remove", Since: 2}, wl.ArgObject(arg0), wl.ArgUint(name)); err != nil {
3977 return err
3978 }
3979 return nil
3980}
3981
3982// EventSignature returns the declared event argument types in wire order.
3983func (o *Fixes) EventSignature(opcode uint16) (string, bool) {
3984 switch opcode {
3985 default:
3986 return "", false
3987 }
3988}
3989
3990// Dispatch decodes one event on wl_fixes and calls the registered handlers.
3991func (o *Fixes) Dispatch(event *wl.Event) {
3992 switch event.Opcode {
3993 default:
3994 }
3995}