summaryrefslogtreecommitdiff
path: root/src/wayland-server.ads
blob: c9ab05c64018110d3bb45f33b6c36d57f0760239 (plain)
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


package Wayland.Server is


    --  All types declared first to make primitive op grouping easier


    type Signal is new Wayland_Object with private;
    type Signal_Number is new Integer;




    type Event_Source is new Wayland_Object with private;




    type Event_Loop is new Wayland_Object with private;
    type Event_Loop_Access is access Event_Loop;

    type Event_Loop_Reference (Data : not null access Event_Loop) is limited private
        with Implicit_Dereference => Data;

    type Event_Loop_FD_Function is access function
           (This : in out Event_Loop;
            FD   : in     File_Descriptor;
            Mask : in     Client_State)
        return Boolean;

    type Event_Loop_Timer_Function is access function
           (This : in out Event_Loop)
        return Boolean;

    type Event_Loop_Signal_Function is access function
           (This : in out Event_Loop;
            Num  : in     Signal_Number)
        return Boolean;

    type Event_Loop_Idle_Function is access procedure
           (This : in out Event_Loop);




    type Client is new Wayland_Object with private
        with Variable_Indexing => Get_Object;
    type Client_Access is access Client;

    type Client_Reference (Data : not null access Client) is limited private
        with Implicit_Dereference => Data;

    type Client_State is record
        Readable : Boolean := False;
        Writable : Boolean := False;
        Hangup   : Boolean := False;
        Error    : Boolean := False;
    end record;




    type Display is new Wayland_Object with private;
    type Display_Access is access Display;

    type Display_Reference (Data : not null access Display) is limited private
        with Implicit_Dereference => Data;




    type Global is new Wayland_Object with private;
    type Global_Access is access Global;

    type Global_Bind_Function is access procedure
           (My_Client : in Client_Access;
            Version   : in Version_Number;
            ID        : in ID_Number);




    type Global_Filter_Function is access function
           (Caller    : in Display;
            My_Client : in Client;
            My_Global : in Global)
        return Boolean;




    type Resource is new Wayland_Object with private;
    type Resource_Access is access Resource;

    type Resource_Reference (Data : not null access Resource) is limited private
        with Implicit_Dereference => Data;




    type Pixel_Value is new Unsigned_Integer;
    type Stride_Size is new Positive;
    type Pixel_Format is new Unsigned_Integer;

    type Shared_Memory is new Wayland_Object with private;
    type SHM_Access is access Shared_Memory;




    type Shared_Pool is new Wayland_Object with private;
    type SHM_Pool_Access is access Shared_Pool;




    type Protocol_Logger is new Wayland_Object with private;
    type Protocol_Logger_Direction is (Request, Event);

    type Protocol_Logger_Message is record
    end record;

    type Protocol_Logger_Function is access procedure
           (From : in Display;
            Dir  : in Protocol_Logger_Direction;
            Msg  : in Protocol_Logger_Message);




    --  Signal

    function Create
        return Signal;

    procedure Add
           (This : in out Signal;
            Func : in     Listener_Function);

    function Has
           (This : in Signal;
            Func : in Listener_Function)
        return Boolean;

    procedure Remove
           (This : in out Signal;
            Func : in     Listener_Function);

    procedure Emit
           (This : in Signal);




    --  Event_Source

    function FD_Update
           (Source : in Event_Source;
            Mask   : in Client_State)
        return Result;

    function Timer_Update
           (Source : in Event_Source;
            Time   : in Duration)
        return Result;

    procedure Remove
           (Source : in Event_Source);

    procedure Check
           (Source : in Event_Source);




    --  Event_Loop

    function Create
        return Event_Loop;

    function Add_FD
           (This : in out Event_Loop;
            FD   : in     File_Descriptor;
            Mask : in     Client_State;
            Func : in     Event_Loop_FD_Function)
        return Event_Source;

    function Get_FD
           (This : in Event_Loop)
        return File_Descriptor;

    function Add_Timer
           (This : in out Event_Loop;
            Func : in     Event_Loop_Timer_Function)
        return Event_Source;

    function Add_Signal
           (This : in out Event_Loop;
            Sig  : in     Signal_Number;
            Func : in     Event_Loop_Signal_Function)
        return Event_Source;

    function Add_Idle
           (This : in out Event_Loop;
            Func : in     Event_Loop_Idle_Function)
        return Event_Source;

    function Dispatch
           (This    : in out Event_Loop;
            Timeout : in     Natural)
        return Result;

    procedure Dispatch_Idle
           (This : in out Event_Loop);

    procedure Add_Destroy_Listener
           (This : in out Event_Loop;
            Func : in     Listener_Function);

    function Has_Destroy_Listener
           (This : in Event_Loop;
            Func : in Listener_Function)
        return Boolean;

    procedure Remove_Destroy_Listener
           (This : in out Event_Loop;
            Func : in     Listener_Function);




    --  Display

    function Create
        return Display;

    function Get_Event_Loop
           (This : in Display)
        return Event_Loop_Reference;

    function Add_Socket
           (This : in out Display;
            Name : in     String)
        return Result;

    function Add_Socket_Auto
           (This : in out Display)
        return String;

    function Add_Socket_FD
           (This : in out Display;
            FD   : in     File_Descriptor)
        return Result;

    procedure Stop
           (This : in out Display);

    procedure Run
           (This : in out Display);

    procedure Flush_Clients
           (This : in out Display);

    function Get_Serial
           (This : in Display)
        return Serial_Number;

    function Next_Serial
           (This : in Display)
        return Serial_Number;

    procedure Add_Destroy_Listener
           (This : in out Display;
            Func : in     Listener_Function);

    function Has_Destroy_Listener
           (This : in Display;
            Func : in Listener_Function)
        return Boolean;

    procedure Remove_Destroy_Listener
           (This : in out Display;
            Func : in     Listener_Function);

    procedure Add_Client_Created_Listener
           (This : in out Display;
            Func : in     Listener_Function);

    function Has_Client_Created_Listener
           (This : in Display)
            Func : in Listener_Function)
        return Boolean;

    procedure Remove_Client_Created_Listener
           (This : in out Display;
            Func : in     Listener_Function);

    procedure Set_Global_Filter
           (This : in out Display;
            Func : in     Global_Filter_Function);

    function Add_Protocol_Logger
           (This : in out Display;
            Func : in     Protocol_Logger_Function)
        return Protocol_Logger;




    --  Client

    function Create
           (My_Display : in Display_Access;
            FD         : in File_Descriptor)
        return Client;

    procedure Flush
           (This : in out Client);

    procedure Get_Credentials
           (This : in     Client;
            PID  :    out Process_ID;
            UID  :    out User_ID;
            GID  :    out Group_ID);

    function Get_Display
           (This : in Client)
        return Display_Reference;

    function Get_FD
           (This : in Client)
        return File_Descriptor;

    function Get_Object
           (This : in Client;
            ID   : in ID_Number)
        return Resource_Reference;

    procedure Post_No_Memory
           (This : in out Client);

    procedure Add_Destroy_Listener
           (This : in out Client;
            Func : in     Listener_Function);

    function Has_Destroy_Listener
           (This : in Client;
            Func : in Listener_Function)
        return Boolean;

    procedure Remove_Destroy_Listener
           (This : in out Client;
            Func : in     Listener_Function);

    procedure Add_Resource_Created_Listener
           (This : in out Client;
            Func : in     Listener_Function);

    function Has_Resource_Created_Listener
           (This : in Client;
            Func : in Listener_Function)
        return Boolean;

    procedure Remove_Resource_Created_Listener
           (This : in out Client;
            Func : in     Listener_Function);




    --  Global

    function Create
           (My_Display   : in Display_Access;
            My_Interface : in Protocol_Interface_Access;
            Version      : in Version_Number;
            Bind_Func    : in Global_Bind_Function)
        return Global;

    function Get_Interface
           (This : in Global_Access)
        return Protocol_Interface_Reference;




    --  Resource

    function Create
           (My_Client    : in Client_Access;
            My_Interface : in Protocol_Interface_Access;
            Version      : in Version_Number;
            ID           : in ID_Number)
        return Resource;

    procedure Post_Event
           (This : in out Resource;
            Op   : in     Opcode;
            Args : in     Argument_Array);

    procedure Queue_Event
           (This : in out Resource;
            Op   : in     Opcode;
            Args : in     Argument_Array);

    procedure Post_Error
           (This : in out Resource;
            Code : in     Error_Code;
            Msg  : in     String);

    procedure Post_No_Memory
           (This : in out Resource);

    function Get_ID
           (This : in Resource)
        return ID_Number;

    function Get_Client
           (This : in Resource)
        return Client_Reference;

    function Get_Version
           (This : in Resource)
        return Version_Number;

    procedure Add_Destroy_Listener
           (This : in out Resource;
            Func : in     Listener_Function);

    function Has_Destroy_Listener
           (This : in Resource;
            Func : in Listener_Function)
        return Boolean;

    procedure Remove_Destroy_Listener
           (This : in out Resource;
            Func : in     Listener_Function);




    --  Shared_Memory

    function Create
           (My_Client : in Client_Access;
            ID        : in ID_Number;
            W, H      : in Natural;
            Stride    : in Stride_Size;
            Format    : in Pixel_Format)
        return Shared_Memory;

    function Get_Buffer
           (From : in Resource)
        return Shared_Memory;

    function Get_Pixel
           (This : in Shared_Memory;
            X, Y : in Natural)
        return Pixel_Value;

    procedure Set_Pixel
           (This  : in out Shared_Memory;
            X, Y  : in     Natural;
            Value : in     Pixel_Value);

    function Get_Stride
           (This : in Shared_Memory)
        return Stride_Size;

    function Get_Format
           (This : in Shared_Memory)
        return Pixel_Format;

    function Get_Width
           (This : in Shared_Memory)
        return Natural;

    function Get_Height
           (This : in Shared_Memory)
        return Natural;




    --  Shared_Pool

    function Reference_Pool
           (From : in Shared_Memory)
        return Shared_Pool;

    procedure Unreference
           (This : in out Shared_Pool);




    --  Log

    procedure Set_Log_Handler
           (Handler : in Log_Function);


private


    type Signal is new Wayland_Object with null record;

    procedure Finalize
           (This : in out Signal);




    type Event_Source is new Wayland_Object with null record;

    procedure Finalize
           (This : in out Event_Source);




    type Event_Loop is new Wayland_Object with null record;

    procedure Finalize
           (This : in out Event_Loop);

    type Event_Loop_Reference (Data : not null access Event_Loop) is limited null record
        with Implicit_Dereference => Data;




    type Client is new Wayland_Object with null record
        with Variable_Indexing => Get_Object;

    procedure Finalize
           (This : in out Client);

    type Client_Reference (Data : not null access Client) is limited null record
        with Implicit_Dereference => Data;




    type Display is new Wayland_Object with null record;

    procedure Finalize
           (This : in out Display);

    type Display_Reference (Data : not null access Display) is limited null record
        with Implicit_Dereference => Data;




    type Global is new Wayland_Object with null record;

    procedure Finalize
           (This : in out Global);




    type Resource is new Wayland_Object with null record;

    procedure Finalize
           (This : in out Resource);

    type Resource_Reference (Data : not null access Resource) is limited null record
        with Implicit_Dereference => Data;




    type Shared_Memory is new Wayland_Object with record
        Needs_Dealloc : Boolean;
    end record;

    procedure Finalize
           (This : in out Shared_Memory);




    type Shared_Pool is new Wayland_Object with null record;

    procedure Finalize
           (This : in out Shared_Pool);




    type Protocol_Logger is new Wayland_Object with null record;

    procedure Finalize
           (This : in out Protocol_Logger);


end Wayland.Server;