forked from sebastianskejoe/gowl
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprotocol.go
1506 lines (1347 loc) · 56.2 KB
/
protocol.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package gowl
// The core global object. This is a special singleton object. It
// is used for internal Wayland protocol features.
type Display interface {
// The sync request asks the server to emit the 'done' event
// on the returned Callback object. Since requests are
// handled in-order and events are delivered in-order, this can
// be used as a barrier to ensure all previous requests and the
// resulting events have been handled.
//
// 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 callbackData passed in the callback is the event serial.
Sync(callback NewId)
// This request creates a registry object that allows the client
// to list and bind the global objects available from the
// compositor.
GetRegistry(registry NewId)
// The error event is sent out when a fatal (non-recoverable)
// error has occurred. The objectId argument is the object
// where the error occurred, most often in response to a request
// to that object. The code identifies the error and is defined
// by the object interface. As such, each interface defines its
// own set of error codes. The message is an brief description
// of the error, for (debugging) convenience.
Error(objectId Object, code uint32, message string)
// This event is used internally by the object ID management
// logic. When a client deletes an object, the server will send
// this event to acknowledge that it has seen the delete request.
// When the client receive this event, it will know that it can
// safely reuse the object ID.
DeleteId(id uint32)
}
// These errors are global and can be emitted in response to any
// server request.
type DisplayErr uint
const (
InvalidObj DisplayErr = iota
InvaliddMethod
OOM
)
func (e DisplayErr) Error() string {
switch e {
case InvalidObj:
return "server couldn't find object"
case InvalidMethod:
return "method doesn't exist on the specified interface"
case OOM:
return "server is out of memory"
default:
return "unrecognized error value"
}
}
// The global registry object. The server has a number of global
// objects that are available to all clients. These objects
// typically represent an actual object in the server (for example,
// an input device)
// or they are singleton objects that provide
// extension functionality.
//
// When a client creates a registry object, the registry object
// will emit a global event for each global currently in the
// registry. Globals come and go as a result of device or
// monitor hotplugs, reconfiguration or other events, and the
// registry will send out global and global_remove events to
// keep the client up to date with the changes. To mark the end
// of the initial burst of events, the client can use the
// Display.Sync request immediately after calling
// Display.GetRegistry.
//
// A client can bind to a global object by using the bind
// request. This creates a client-side handle that lets the object
// emit events to the client and lets the client invoke requests on
// the object.
type Registry interface {
// Binds a new, client-created object to the server using the
// specified name as the identifier.
Bind(name uint32, id NewId)
// Notify the client of global objects.
//
// The event notifies the client that a global object with
// the given name is now available, and it implements the
// given version of the given interface.
Global(name uint32, interface_ string, version uint32)
// Notify the client of removed global objects.
//
// This event notifies the client that the global identified
// by name is no longer available. If the client bound to
// the global using the bind request, the client should now
// destroy that object.
//
// The object remains valid and requests to the object will be
// ignored until the client destroys it, to avoid races between
// the global going away and a client sending a request to it.
GlobalRemove(name uint32)
}
// Clients can handle the 'done' event to get notified when
// the related request is done.
type Callback interface {
// Notify the client when the related request is done.
Done(callbackData uint32)
}
// A compositor. This object is a singleton global. The
// compositor is in charge of combining the contents of multiple
// surfaces into one displayable output.
type Compositor interface {
// Ask the compositor to create a new surface.
CreateSurface(id NewId)
// Ask the compositor to create a new region.
CreateRegion(id NewId)
}
// The ShmPool object encapsulates a piece of memory shared
// between the compositor and client. Through the ShmPool
// object, the client can allocate shared memory Buffer objects.
// All objects created through the same pool share the same
// underlying mapped memory. Reusing the mapped memory avoids the
// setup/teardown overhead and is useful when interactively resizing
// a surface or for many small buffers.
type ShmPool interface {
// Create a Buffer object from the pool.
//
// The buffer is created offset bytes into the pool and has
// width and height as specified. The stride arguments specifies
// the number of bytes from 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 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.
CreateBuffer(id NewId, offset int32, width int32, height int32, stride int32, format uint32)
// Destroy the shared memory poo
//
// The mmapped memory will be released when all
// buffers that have been created from this pool
// are gone.
Destroy()
// 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.
Resize(size int32)
}
// A global singleton object that provides support for shared
// memory.
// Clients can create ShmPool objects using the createPool
// request.
// At connection setup time, the Shm object emits one or more
// format events to inform clients about the valid pixel formats
// that can be used for buffers.
type Shm interface {
// Create a new ShmPool 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.
CreatePool(id NewId, fd Fd, size int32)
// Informs the client about a valid pixel format that
// can be used for buffers. Known formats include
// argb8888 and xrgb8888.
Format(format uint32)
}
// These errors can be emitted in response to Shm requests.
type ShmErr uint
const (
InvalidFormat ShmErr = iota
InvalidStride
InvalidFd
)
func (e ShmErr) Error() string {
switch e {
case InvalidFormat:
return "buffer format is not known"
case InvalidStride:
return "invalid size or stride during pool or buffer creation"
case InvalidFd:
return "mmapping the file descriptor failed"
default:
return "unrecognized error value"
}
}
// This describes the memory layout of an individual pixel.
// All renderers should support argb8888 and xrgb8888 but any other
// formats are optional and may not be supported by the particular
// renderer in use.
type ShmFormat uint
const (
ARGB8888 ShmFormat = 0
XRGB8888 ShmFormat = 1
C8 ShmFormat = 0x20203843
RGB332 ShmFormat = 0x38424752
BGR233 ShmFormat = 0x38524742
XRGB4444 ShmFormat = 0x32315258
XBGR4444 ShmFormat = 0x32314258
RGBX4444 ShmFormat = 0x32315852
BGRX4444 ShmFormat = 0x32315842
ARGB4444 ShmFormat = 0x32315241
ABGR4444 ShmFormat = 0x32314241
RGBA4444 ShmFormat = 0x32314152
BGRA4444 ShmFormat = 0x32314142
XRGB1555 ShmFormat = 0x35315258
XBGR1555 ShmFormat = 0x35314258
RGBX5551 ShmFormat = 0x35315852
BGRX5551 ShmFormat = 0x35315842
ARGB1555 ShmFormat = 0x35315241
ABGR1555 ShmFormat = 0x35314241
RGBA5551 ShmFormat = 0x35314152
BGRA5551 ShmFormat = 0x35314142
RGB565 ShmFormat = 0x36314752
BGR565 ShmFormat = 0x36314742
RGB888 ShmFormat = 0x34324752
BGR888 ShmFormat = 0x34324742
XBGR8888 ShmFormat = 0x34324258
RGBX8888 ShmFormat = 0x34325852
BGRX8888 ShmFormat = 0x34325842
ABGR8888 ShmFormat = 0x34324241
RGBA8888 ShmFormat = 0x34324152
BGRA8888 ShmFormat = 0x34324142
XRGB2101010 ShmFormat = 0x30335258
XBGR2101010 ShmFormat = 0x30334258
RGBX1010102 ShmFormat = 0x30335852
BGRX1010102 ShmFormat = 0x30335842
ARGB2101010 ShmFormat = 0x30335241
ABGR2101010 ShmFormat = 0x30334241
RGBA1010102 ShmFormat = 0x30334152
BGRA1010102 ShmFormat = 0x30334142
YUYV ShmFormat = 0x56595559
YVYU ShmFormat = 0x55595659
UYVY ShmFormat = 0x59565955
VYUY ShmFormat = 0x59555956
AYUV ShmFormat = 0x56555941
NV12 ShmFormat = 0x3231564e
NV21 ShmFormat = 0x3132564e
NV16 ShmFormat = 0x3631564e
NV61 ShmFormat = 0x3136564e
YUV410 ShmFormat = 0x39565559
YVU410 ShmFormat = 0x39555659
YUV411 ShmFormat = 0x31315559
YVU411 ShmFormat = 0x31315659
YUV420 ShmFormat = 0x32315559
YVU420 ShmFormat = 0x32315659
YUV422 ShmFormat = 0x36315559
YVU422 ShmFormat = 0x36315659
YUV444 ShmFormat = 0x34325559
YVU444 ShmFormat = 0x34325659
)
// A buffer provides the content for a Surface. Buffers are
// created through factory interfaces such as Drm, Shm or
// similar. It has a width and a height and can be attached to a
// Surface, but the mechanism by which a client provides and
// updates the contents is defined by the buffer factory interface.
type Buffer interface {
// 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 Surface.Attach.
Destroy()
// Sent when this Buffer is no longer used by the compositor.
// The client is now free to re-use or destroy this buffer and its
// backing storage.
//
// If a client receives a release event before the frame callback
// requested in the same Surface.Commit that attaches this
// Buffer to a surface, then the client is immediately free to
// re-use the buffer and its backing storage, and does not need a
// second buffer for the next surface content update. Typically
// this is possible, when the compositor maintains a copy of the
// Surface contents, e.g. as a GL texture. This is an important
// optimization for GL(ES) compositors with Shm clients.
Release()
}
// A DataOffer represents a piece of data offered for transfer
// by another client (the source client). It is used by the
// copy-and-paste and drag-and-drop mechanisms. The offer
// describes the different mime types that the data can be
// converted to and provides the mechanism for transferring the
// data directly from the source client.
type DataOffer interface {
// Indicate that the client can accept the given mime type, or
// NULL for not accepted.
//
// Used for feedback during drag-and-drop.
Accept(serial uint32, mimeType string)
// 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 the closes its end, at which point the transfer is
// complete.
Receive(mimeType string, fd Fd)
// Destroy the data offer.
Destroy()
// Sent immediately after creating the DataOffer object. One
// event per offered mime type.
Offer(mimeType string)
}
// The DataSource object is the source side of a DataOffer.
// It is created by the source client in a data transfer and
// provides a way to describe the offered data and a way to respond
// to requests to transfer the data.
type DataSource interface {
// This request adds a mime type to the set of mime types
// advertised to targets. Can be called several times to offer
// multiple types.
Offer(mimeType string)
// Destroy the data source.
Destroy()
// Sent when a target accepts pointerFocus or motion events. If
// a target does not accept any of the offered types, type is NULL.
//
// Used for feedback during drag-and-drop.
Target(mimeType string)
// Request for data from the client. Send the data as the
// specified mime type over the passed file descriptor, then
// close it.
Send(mimeType string, fd Fd)
// This data source has been replaced by another data source.
// The client should clean up and destroy this data source.
Cancelled()
}
// There is one DataDevice per seat which can be obtained
// from the global DataDeviceManager singleton.
//
// A DataDevice provides access to inter-client data transfer
// mechanisms such as copy-and-paste and drag-and-drop.
type DataDevice interface {
// 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.
//
// 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 Surface.Attach request can move the
// relative position. Attach requests must be confirmed with
// Surface.Commit as usual.
//
// The current and pending input regions of the icon Surface are
// cleared, and Surface.SetInputRegion is ignored until the
// Surface is no longer used as the icon surface. When the use
// as an icon ends, the current and pending input regions become
// undefined, and the Surface is unmapped.
StartDrag(source Object, origin Object, icon Object, serial uint32)
// 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.
SetSelection(source Object, serial uint32)
// The dataOffer event introduces a new DataOffer object,
// which will subsequently be used in either the
// dataDevice.Enter event (for drag-and-drop)or the
// dataDevice.Selection event (for selections). Immediately
// following the dataDeviceDataOffer event, the new dataOffer
// object will send out dataOffer.Offer events to describe the
// mime types it offers.
DataOffer(id NewId)
// This event is sent when an active drag-and-drop pointer enters
// a surface owned by the client. The position of the pointer at
// enter time is provided by the x and y arguments, in surface
// local coordinates.
Enter(serial uint32, surface Object, x Fixed, y Fixed, id Object)
// This event is sent when the drag-and-drop pointer leaves the
// surface and the session ends. The client must destroy the
// DataOffer introduced at enter time at this point.
Leave()
// This event is sent when the drag-and-drop pointer moves within
// the currently focused surface. The new position of the pointer
// is provided by the x and y arguments, in surface local
// coordinates.
Motion(time uint32, x Fixed, y Fixed)
// The event is sent when a drag-and-drop operation is ended
// because the implicit grab is removed.
Drop()
// The selection event is sent out to notify the client of a new
// DataOffer for the selection for this device. The
// dataDevice.DataOffer and the dataOffer.Offer events are
// sent out immediately before this event to introduce the data
// offer object. The selection event is sent to a client
// immediately before receiving keyboard focus and when a new
// selection is set while the client has keyboard focus. The
// dataOffer is valid until a new dataOffer or NULL is received
// or until the client loses keyboard focus.
Selection(id Object)
}
// The DataDeviceManager is a singleton global object that
// provides access to inter-client data transfer mechanisms such as
// copy-and-paste and drag-and-drop. These mechanisms are tied to
// a Seat and this interface lets a client get a DataDevice
// corresponding to a Seat.
type DataDeviceManager interface {
// Create a new data source.
CreateDataSource(id NewId)
// Create a new data device for a given seat.
GetDataDevice(id NewId, seat Object)
}
// This interface is implemented by servers that provide
// desktop-style user interfaces.
//
// It allows clients to associate a ShellSurface with
// a basic surface.
type Shell interface {
// Create a shell surface for an existing surface.
//
// Only one shell surface can be associated with a given surface.
GetShellSurface(id NewId, surface Object)
}
// An interface that may be implemented by a Surface, for
// implementations that provide a desktop-style user interface.
//
// It provides requests to treat surfaces like toplevel, fullscreen
// or popup windows, move, resize or maximize them, associate
// metadata like title and class, etc.
//
// On the server side the object is automatically destroyed when
// the related Surface is destroyed. On client side,
// ShellSurface.Destroy() must be called before destroying
// the Surface object.
type ShellSurface interface {
// A client must respond to a ping event with a pong request or
// the client may be deemed unresponsive.
Pong(serial uint32)
// 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).
Move(seat Object, serial uint32)
// 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).
Resize(seat Object, serial uint32, edges uint32)
// Map the surface as a toplevel surface.
//
// A toplevel surface is not fullscreen, maximized or transient.
SetToplevel()
// Map the surface relative to an existing surface.
//
// The x and y arguments specify the locations 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.
SetTransient(parent Object, x int32, y int32, flags uint32)
// 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 app 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 bufferScale.
//
// 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 bufferScale 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.
SetFullscreen(method uint32, framerate uint32, output Object)
// 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 clients window. A click
// in any of the clients 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 locations of the upper left
// corner of the surface relative to the upper left corner of the
// parent surface, in surface local coordinates.
SetPopup(seat Object, serial uint32, parent Object, x int32, y int32, flags uint32)
// 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 element 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.
SetMaximized(output Object)
// 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.
SetTitle(title string)
// 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.
SetClass(class string)
// Ping a client to check if it is receiving events and sending
// requests. A client is expected to reply with a pong request.
Ping(serial uint32)
// The Configure event asks the client to resize its surface.
//
// The size is a hint, in the sense that the client is free to
// ignore it if it doesn't resize, pick a smaller size (to
// satisfy aspect ratio or resize in steps of NxM pixels).
//
// The edges parameter provides a hint about how the surface
// was resized. The client may use this information to decide
// how to adjust its content to the new size (e.g. a scrolling
// area might adjust its content position to leave the viewable
// content unmoved).
//
// The client is free to dismiss all but the last configure
// event it received.
//
// The width and height arguments specify the size of the window
// in surface local coordinates.
Configure(edges uint32, width int32, height int32)
// The PopupDone event is sent out when a popup grab is broken,
// that is, when the user clicks a surface that doesn't belong
// to the client owning the popup surface.
PopupDone()
}
// These values are used to indicate which edge of a surface
// is being dragged in a resize operation. The server may
// use this information to adapt its behavior, e.g. choose
// an appropriate cursor image.
type Resize uint
const (
None Resize = 0
Top Resize = 1
Bottom Resize = 2
Left Resize = 4
TopLeft Resize = 5
BottomLeft Resize = 6
Right Resize = 8
TopRight Resize = 9
BottomRight Resize = 10
)
// These flags specify details of the expected behaviour
// of transient surfaces. Used in the settransient request.
type Transient uint
const (
Inactive Transient = 0x1
)
// Hints to indicate to the compositor how to deal with a conflict
// between the dimensions of the surface and the dimensions of the
// output. The compositor is free to ignore this parameter.
type FullScreenMethod uint
const (
Default FullScreenMethod = iota
Scale
Driver
Fill
)
// A surface is a rectangular area that is displayed on the screen.
// It has a location, size and pixel contents.
//
// The size of a surface (and relative positions on it) is described
// in surface local coordinates, which may differ from the buffer
// local coordinates of the pixel content, in case a Buffer.Transform
// or a Buffer.Scale is used.
//
// Surfaces are also used for some special purposes, e.g. as
// cursor images for pointers, drag icons, etc.
type Surface interface {
// Deletes the surface and invalidates its object ID.
Destroy()
// 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 the supplied buffer
// must be an integer multiple of the bufferScale.
//
// 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.
//
// Surface contents are double-buffered state, see Surface.Commit.
//
// The initial surface contents are void; there is no content.
// Surface.Attach assigns the given Buffer as the pending
// Buffer. Surface.Commit makes the pending Buffer the new
// surface contents, and the size of the surface becomes the size
// calculated from the Buffer, as described above. After commit,
// there is no pending buffer until the next attach.
//
// Committing a pending Buffer allows the compositor to read the
// pixels in the Buffer. The compositor may access the pixels at
// any time after the Surface.Commit request. When the compositor
// will not access the pixels anymore, it will send the
// Buffer.Release event. Only after receiving Buffer.Release,
// the client may re-use the Buffer. A 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.
//
// Destroying the Buffer after Buffer.Release does not change
// the surface contents. However, if the client destroys the
// Buffer before receiving the Buffer.Release event, the surface
// contents become undefined immediately.
//
// If Surface.Attach is sent with a NULL Buffer, the
// following Surface.Commit will remove the surface content.
Attach(buffer Object, x int32, y int32)
// 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 pending buffer
// must be set by Surface.Attach before sending damage. The
// compositor ignores the parts of the damage that fall outside of
// the surface.
//
// Damage is double-buffered state, see Surface.Commit.
//
// The damage rectangle is specified in surface local coordinates.
//
// The initial value for pending damage is empty: no damage.
// Surface.Damage adds pending damage: the new pending damage
// is the union of old pending damage and the given rectangle.
//
// 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.
Damage(x int32, y int32, width int32, height int32)
// Request a notification when it is a good time 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 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 Surface.Commit.
// The notification will only be posted for one frame unless
// requested again. For a 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 them
// hit the next output refresh.
//
// A server should avoid signalling 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 callbackData passed in the callback is the current time, in
// milliseconds.
Frame(callback NewId)
// 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 out 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 Surface.Commit.
//
// Surface.SetOpaqueRegion changes the pending opaque region.
// Surface.Commit copies the pending region to the current region.
// Otherwise, the pending and current regions are never changed.
//
// The initial value for opaque region is empty. Setting the pending
// opaque region has copy semantics, and the Region object can be
// destroyed immediately. A NULL Region causes the pending opaque
// region to be set to empty.
SetOpaqueRegion(region Object)
// 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 Surface.Commit.
//
// Surface.SetInputRegion changes the pending input region.
// 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
// Pointer.SetCursor and DataDevice.StartDrag.
//
// The initial value for input region is infinite. That means the
// whole surface will accept input. Setting the pending input region
// has copy semantics, and the Region object can be destroyed
// immediately. A NULL Region causes the input region to be set
// to infinite.
SetInputRegion(region Object)
// Surface state (input, opaque, and damage regions, attached buffers,
// etc.) is double-buffered. Protocol requests modify the pending
// state, as opposed to current state in use by the compositor. Commit
// request atomically applies all pending state, replacing the current
// state. After commit, the new pending state is as documented for each
// related request.
//
// On commit, a pending Buffer is applied first, all other state
// second. This means that all coordinates in double-buffered state are
// relative to the new Buffer coming into use, except for
// Surface.Attach itself. If there is no pending Buffer, the
// coordinates are relative to the current surface contents.
//
// 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.
Commit()
// This request sets an optional transformation on how the compositor
// interprets the contents of the buffer attached to the surface. The
// accepted values for the transform parameter are the values for
// Output.Transform.
//
// Buffer transform is double-buffered state, see Surface.Commit.
//
// A newly created surface has its buffer transformation set to normal.
//
// Surface.SetBufferTransform changes the pending buffer
// transformation. 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 permiting 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
// Output.Transform enum the invalidTransform protocol error
// is raised.
SetBufferTransform(transform int32)
// 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 Surface.Commit.
//
// A newly created surface has its buffer scale set to 1.
//
// Surface.SetBufferScale changes the pending buffer scale.
// 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. Its
// 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 positive the invalidScale protocol error is
// raised.
SetBufferScale(scale int32)
// This is emitted whenever a surface's creation, movement, or resizing
// results in some part of it being within the scanout region of an
// output.
//
// Note that a surface may be overlapping with zero or more outputs.
Enter(output Object)
// This is emitted whenever a surface's creation, movement, or resizing
// results in it no longer having any part of it within the scanout region
// of an output.
Leave(output Object)
}
// These errors can be emitted in response to Surface requests.
type SurfaceErr uint
const (
InvalidScale SurfaceErr = iota
InvalidTransform
)
func (e DisplayErr) Error() string {
switch e {
case InvalidScale:
return "buffer scale value is invalid"
case InvalidTransform:
return "buffer transform value is invalid"
default:
return "unrecognized error value"
}
}
// A seat is a group of keyboards, pointer and touch devices. This
// object is published as a global during start up, or when such a
// device is hot plugged. A seat typically has a pointer and
// maintains a keyboard focus and a pointer focus.
type Seat interface {
// The ID provided will be initialized to the Pointer interface
// for this seat.
//
// This request only takes effect if the seat has the pointer
// capability.
GetPointer(id NewId)
// The ID provided will be initialized to the Keyboard interface
// for this seat.
//
// This request only takes effect if the seat has the keyboard
// capability.
GetKeyboard(id NewId)
// The ID provided will be initialized to the Touch interface
// for this seat.
//
// This request only takes effect if the seat has the touch
// capability.
GetTouch(id NewId)
// This is emitted whenever a seat gains or loses the pointer,
// keyboard or touch capabilities. The argument is a capability
// enum containing the complete set of capabilities this seat has.
Capabilities(capabilities uint32)
// In a multiseat configuration this can be used by the client to help
// identify which physical devices the seat represents. Based on
// the seat configuration used by the compositor.
Name(name string)
}
// This is a bitmask of capabilities this seat has; if a member is
// set, then it is present on the seat.
type CapabilityMask uint
const (
PointerCap CapabilityMask = 1 << iota
KeyboardCap
TouchCap
)
// The Pointer interface represents one or more input devices,
// such as mice, which control the pointer location and pointerFocus
// of a seat.
//
// The Pointer interface generates motion, enter and leave
// events for the surfaces that the pointer is located over,
// and button and axis events for button presses, button releases
// and scrolling.