package wayland

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file wlr_screencopy_unstable_v1_server.ml

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
(* This file was generated automatically by wayland-scanner-ocaml *)

[@@@ocaml.warning "-27"]
open struct
  module Imports = struct
    include Wlr_screencopy_unstable_v1_proto
    include Wayland.Wayland_proto
  end
  
  module Proxy = Wayland.Proxy
  module Msg = Wayland.Msg
  module Fixed = Wayland.Fixed
  module Iface_reg = Wayland.Iface_reg
  module S = Wayland.S
end


(** Manager to inform clients and begin capturing.
    
    This object is a manager which offers requests to start capturing from a
    source. *)
module Zwlr_screencopy_manager_v1 = struct
  type 'v t = ([`Zwlr_screencopy_manager_v1], 'v, [`Server]) Proxy.t
  
  (** {2 Version 1, 2, 3} *)
  
  (**/**)
  class virtual ['v] _handlers_unsafe = object (_self : (_, 'v, _) #Proxy.Handler.t)
    method user_data = S.No_data
    method metadata = (module Wlr_screencopy_unstable_v1_proto.Zwlr_screencopy_manager_v1)
    method max_version = 3l
    
    method private virtual on_capture_output : [> ] t -> ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t ->
                                               overlay_cursor:int32 ->
                                               output:([`Wl_output], [> Imports.Wl_output.versions], [`Server]) Proxy.t ->
                                               unit
    
    method private virtual on_capture_output_region : [> ] t -> ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t ->
                                                      overlay_cursor:int32 ->
                                                      output:([`Wl_output], [> Imports.Wl_output.versions], [`Server]) Proxy.t ->
                                                      x:int32 -> y:int32 -> width:int32 -> height:int32 -> unit
    
    method private virtual on_destroy : [> ] t -> unit
    
    
    method dispatch (_proxy : 'v t) _msg =
      let _proxy = Proxy.cast_version _proxy in
      match Msg.op _msg with
      | 0 ->
        let frame : ([`Zwlr_screencopy_frame_v1], _, _) Proxy.t =
          Msg.get_int _msg |> Proxy.Handler.accept_new _proxy (module Imports.Zwlr_screencopy_frame_v1) in
        let overlay_cursor = Msg.get_int _msg in
        let output : ([`Wl_output], _, _) Proxy.t =
          let Proxy.Proxy p = Msg.get_int _msg |> Proxy.lookup_other _proxy in
          match Proxy.ty p with
          | Imports.Wl_output.T -> p
          | _ -> Proxy.wrong_type ~parent:_proxy ~expected:"wl_output" p
          in
        _self#on_capture_output _proxy frame ~overlay_cursor ~output
      | 1 ->
        let frame : ([`Zwlr_screencopy_frame_v1], _, _) Proxy.t =
          Msg.get_int _msg |> Proxy.Handler.accept_new _proxy (module Imports.Zwlr_screencopy_frame_v1) in
        let overlay_cursor = Msg.get_int _msg in
        let output : ([`Wl_output], _, _) Proxy.t =
          let Proxy.Proxy p = Msg.get_int _msg |> Proxy.lookup_other _proxy in
          match Proxy.ty p with
          | Imports.Wl_output.T -> p
          | _ -> Proxy.wrong_type ~parent:_proxy ~expected:"wl_output" p
          in
        let x = Msg.get_int _msg in
        let y = Msg.get_int _msg in
        let width = Msg.get_int _msg in
        let height = Msg.get_int _msg in
        _self#on_capture_output_region _proxy frame ~overlay_cursor ~output ~x ~y ~width ~height
      | 2 ->
        Proxy.shutdown_recv _proxy;
        _self#on_destroy _proxy 
      | _ -> assert false
  end
  (**/**)
  
  (** {2 Handlers}
      Note: Servers will always want to use [v1].
   *)
  
  
  (** Handler for a proxy with version >= 1. *)
  class virtual ['v] v1 = object (_ : (_, 'v, _) #Proxy.Service_handler.t)
    (**/**)
    inherit [[< `V1 | `V2 | `V3] as 'v] _handlers_unsafe
    (**/**)
    method private virtual on_capture_output : [> `V1 | `V2 | `V3] t -> ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t ->
                                               overlay_cursor:int32 ->
                                               output:([`Wl_output], [> Imports.Wl_output.versions], [`Server]) Proxy.t ->
                                               unit
    
    (** Capture an output.
        
        Capture the next frame of an entire output. *)
    
    method private virtual on_capture_output_region : [> `V1 | `V2 | `V3] t -> ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t ->
                                                      overlay_cursor:int32 ->
                                                      output:([`Wl_output], [> Imports.Wl_output.versions], [`Server]) Proxy.t ->
                                                      x:int32 -> y:int32 -> width:int32 -> height:int32 -> unit
    
    (** Capture an output's region.
        
        Capture the next frame of an output's region.
        
        The region is given in output logical coordinates, see
        xdg_output.logical_size. The region will be clipped to the output's
        extents. *)
    
    method private virtual on_destroy : [> `V1 | `V2 | `V3] t -> unit
    
    (** Destroy the manager.
        
        All objects created by the manager will still remain valid, until their
        appropriate destroy request has been called. *)
    
    method min_version = 1l
    method bind_version : [`V1] = `V1
  end
  
  (** Handler for a proxy with version >= 2. *)
  class virtual ['v] v2 = object (_ : (_, 'v, _) #Proxy.Service_handler.t)
    (**/**)
    inherit [[< `V2 | `V3] as 'v] _handlers_unsafe
    (**/**)
    method private virtual on_capture_output : [> `V2 | `V3] t -> ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t ->
                                               overlay_cursor:int32 ->
                                               output:([`Wl_output], [> Imports.Wl_output.versions], [`Server]) Proxy.t ->
                                               unit
    
    (** Capture an output.
        
        Capture the next frame of an entire output. *)
    
    method private virtual on_capture_output_region : [> `V2 | `V3] t -> ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t ->
                                                      overlay_cursor:int32 ->
                                                      output:([`Wl_output], [> Imports.Wl_output.versions], [`Server]) Proxy.t ->
                                                      x:int32 -> y:int32 -> width:int32 -> height:int32 -> unit
    
    (** Capture an output's region.
        
        Capture the next frame of an output's region.
        
        The region is given in output logical coordinates, see
        xdg_output.logical_size. The region will be clipped to the output's
        extents. *)
    
    method private virtual on_destroy : [> `V2 | `V3] t -> unit
    
    (** Destroy the manager.
        
        All objects created by the manager will still remain valid, until their
        appropriate destroy request has been called. *)
    
    method min_version = 2l
    method bind_version : [`V2] = `V2
  end
  
  (** Handler for a proxy with version >= 3. *)
  class virtual ['v] v3 = object (_ : (_, 'v, _) #Proxy.Service_handler.t)
    (**/**)
    inherit [[< `V3] as 'v] _handlers_unsafe
    (**/**)
    method private virtual on_capture_output : [> `V3] t -> ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t ->
                                               overlay_cursor:int32 ->
                                               output:([`Wl_output], [> Imports.Wl_output.versions], [`Server]) Proxy.t ->
                                               unit
    
    (** Capture an output.
        
        Capture the next frame of an entire output. *)
    
    method private virtual on_capture_output_region : [> `V3] t -> ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t ->
                                                      overlay_cursor:int32 ->
                                                      output:([`Wl_output], [> Imports.Wl_output.versions], [`Server]) Proxy.t ->
                                                      x:int32 -> y:int32 -> width:int32 -> height:int32 -> unit
    
    (** Capture an output's region.
        
        Capture the next frame of an output's region.
        
        The region is given in output logical coordinates, see
        xdg_output.logical_size. The region will be clipped to the output's
        extents. *)
    
    method private virtual on_destroy : [> `V3] t -> unit
    
    (** Destroy the manager.
        
        All objects created by the manager will still remain valid, until their
        appropriate destroy request has been called. *)
    
    method min_version = 3l
    method bind_version : [`V3] = `V3
  end
end

(** A frame ready for copy.
    
    This object represents a single frame.
    
    When created, a series of buffer events will be sent, each representing a
    supported buffer type. The "buffer_done" event is sent afterwards to
    indicate that all supported buffer types have been enumerated. The client
    will then be able to send a "copy" request. If the capture is successful,
    the compositor will send a "flags" followed by a "ready" event.
    
    For objects version 2 or lower, wl_shm buffers are always supported, ie.
    the "buffer" event is guaranteed to be sent.
    
    If the capture failed, the "failed" event is sent. This can happen anytime
    before the "ready" event.
    
    Once either a "ready" or a "failed" event is received, the client should
    destroy the frame. *)
module Zwlr_screencopy_frame_v1 = struct
  type 'v t = ([`Zwlr_screencopy_frame_v1], 'v, [`Server]) Proxy.t
  module Error = Wlr_screencopy_unstable_v1_proto.Zwlr_screencopy_frame_v1.Error
  
  module Flags = Wlr_screencopy_unstable_v1_proto.Zwlr_screencopy_frame_v1.Flags
  
  (** {2 Version 1} *)
  
  (** Frame copy failed.
      
      This event indicates that the attempted frame copy has failed.
      
      After receiving this event, the client should destroy the object. *)
  let failed (_t:([< `V1 | `V2 | `V3] as 'v) t)  =
    let _msg = Proxy.alloc _t ~op:3 ~ints:0 ~strings:[] ~arrays:[] in
    Proxy.send _t _msg
  
  (** Indicates frame is available for reading.
      
      Called as soon as the frame is copied, indicating it is available
      for reading. This event includes the time at which presentation happened
      at.
      
      The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples,
      each component being an unsigned 32-bit value. Whole seconds are in
      tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo,
      and the additional fractional part in tv_nsec as nanoseconds. Hence,
      for valid timestamps tv_nsec must be in [0, 999999999]. The seconds part
      may have an arbitrary offset at start.
      
      After receiving this event, the client should destroy the object. *)
  let ready (_t:([< `V1 | `V2 | `V3] as 'v) t) ~tv_sec_hi ~tv_sec_lo ~tv_nsec =
    let _msg = Proxy.alloc _t ~op:2 ~ints:3 ~strings:[] ~arrays:[] in
    Msg.add_int _msg tv_sec_hi;
    Msg.add_int _msg tv_sec_lo;
    Msg.add_int _msg tv_nsec;
    Proxy.send _t _msg
  
  (** Frame flags.
      
      Provides flags about the frame. This event is sent once before the
      "ready" event. *)
  let flags (_t:([< `V1 | `V2 | `V3] as 'v) t) ~flags =
    let _msg = Proxy.alloc _t ~op:1 ~ints:1 ~strings:[] ~arrays:[] in
    Msg.add_int _msg (Imports.Zwlr_screencopy_frame_v1.Flags.to_int32 flags);
    Proxy.send _t _msg
  
  (** Wl_shm buffer information.
      
      Provides information about wl_shm buffer parameters that need to be
      used for this frame. This event is sent once after the frame is created
      if wl_shm buffers are supported. *)
  let buffer (_t:([< `V1 | `V2 | `V3] as 'v) t) ~format ~width ~height ~stride =
    let _msg = Proxy.alloc _t ~op:0 ~ints:4 ~strings:[] ~arrays:[] in
    Msg.add_int _msg (Imports.Wl_shm.Format.to_int32 format);
    Msg.add_int _msg width;
    Msg.add_int _msg height;
    Msg.add_int _msg stride;
    Proxy.send _t _msg
  
  
  (** {2 Version 2} *)
  
  (** Carries the coordinates of the damaged region.
      
      This event is sent right before the ready event when copy_with_damage is
      requested. It may be generated multiple times for each copy_with_damage
      request.
      
      The arguments describe a box around an area that has changed since the
      last copy request that was derived from the current screencopy manager
      instance.
      
      The union of all regions received between the call to copy_with_damage
      and a ready event is the total damage since the prior ready event. *)
  let damage (_t:([< `V2 | `V3] as 'v) t) ~x ~y ~width ~height =
    let _msg = Proxy.alloc _t ~op:4 ~ints:4 ~strings:[] ~arrays:[] in
    Msg.add_int _msg x;
    Msg.add_int _msg y;
    Msg.add_int _msg width;
    Msg.add_int _msg height;
    Proxy.send _t _msg
  
  
  (** {2 Version 3} *)
  
  (** All buffer types reported.
      
      This event is sent once after all buffer events have been sent.
      
      The client should proceed to create a buffer of one of the supported
      types, and send a "copy" request. *)
  let buffer_done (_t:([< `V3] as 'v) t)  =
    let _msg = Proxy.alloc _t ~op:6 ~ints:0 ~strings:[] ~arrays:[] in
    Proxy.send _t _msg
  
  (** Linux-dmabuf buffer information.
      
      Provides information about linux-dmabuf buffer parameters that need to
      be used for this frame. This event is sent once after the frame is
      created if linux-dmabuf buffers are supported. *)
  let linux_dmabuf (_t:([< `V3] as 'v) t) ~format ~width ~height =
    let _msg = Proxy.alloc _t ~op:5 ~ints:3 ~strings:[] ~arrays:[] in
    Msg.add_int _msg format;
    Msg.add_int _msg width;
    Msg.add_int _msg height;
    Proxy.send _t _msg
  
  (**/**)
  class virtual ['v] _handlers_unsafe = object (_self : (_, 'v, _) #Proxy.Handler.t)
    method user_data = S.No_data
    method metadata = (module Wlr_screencopy_unstable_v1_proto.Zwlr_screencopy_frame_v1)
    method max_version = 3l
    
    method private virtual on_copy : [> ] t -> buffer:([`Wl_buffer], [> Imports.Wl_buffer.versions], [`Server]) Proxy.t ->
                                     unit
    
    method private virtual on_destroy : [> ] t -> unit
    
    method private virtual on_copy_with_damage : [> ] t -> buffer:([`Wl_buffer], [> Imports.Wl_buffer.versions], [`Server]) Proxy.t ->
                                                 unit
    
    
    method dispatch (_proxy : 'v t) _msg =
      let _proxy = Proxy.cast_version _proxy in
      match Msg.op _msg with
      | 0 ->
        let buffer : ([`Wl_buffer], _, _) Proxy.t =
          let Proxy.Proxy p = Msg.get_int _msg |> Proxy.lookup_other _proxy in
          match Proxy.ty p with
          | Imports.Wl_buffer.T -> p
          | _ -> Proxy.wrong_type ~parent:_proxy ~expected:"wl_buffer" p
          in
        _self#on_copy _proxy ~buffer
      | 1 ->
        Proxy.shutdown_recv _proxy;
        _self#on_destroy _proxy 
      | 2 ->
        let buffer : ([`Wl_buffer], _, _) Proxy.t =
          let Proxy.Proxy p = Msg.get_int _msg |> Proxy.lookup_other _proxy in
          match Proxy.ty p with
          | Imports.Wl_buffer.T -> p
          | _ -> Proxy.wrong_type ~parent:_proxy ~expected:"wl_buffer" p
          in
        _self#on_copy_with_damage _proxy ~buffer
      | _ -> assert false
  end
  (**/**)
  
  (** {2 Handlers}
      Note: Servers will always want to use [v1].
   *)
  
  
  (** Handler for a proxy with version >= 1. *)
  class virtual ['v] v1 = object (_ : (_, 'v, _) #Proxy.Service_handler.t)
    (**/**)
    inherit [[< `V1 | `V2 | `V3] as 'v] _handlers_unsafe
    (**/**)
    method private virtual on_copy : [> `V1 | `V2 | `V3] t -> buffer:([`Wl_buffer], [> Imports.Wl_buffer.versions], [`Server]) Proxy.t ->
                                     unit
    
    (** Copy the frame.
        
        Copy the frame to the supplied buffer. The buffer must have a the
        correct size, see zwlr_screencopy_frame_v1.buffer and
        zwlr_screencopy_frame_v1.linux_dmabuf. The buffer needs to have a
        supported format.
        
        If the frame is successfully copied, a "flags" and a "ready" events are
        sent. Otherwise, a "failed" event is sent. *)
    
    method private virtual on_destroy : [> `V1 | `V2 | `V3] t -> unit
    
    (** Delete this object, used or not.
        
        Destroys the frame. This request can be sent at any time by the client. *)
    
    method private virtual on_copy_with_damage : [> `V2 | `V3] t -> buffer:([`Wl_buffer], [> Imports.Wl_buffer.versions], [`Server]) Proxy.t ->
                                                 unit
    
    (** Copy the frame when it's damaged.
        
        Same as copy, except it waits until there is damage to copy. *)
    
    method min_version = 1l
  end
  
  (** Handler for a proxy with version >= 2. *)
  class virtual ['v] v2 = object (_ : (_, 'v, _) #Proxy.Service_handler.t)
    (**/**)
    inherit [[< `V2 | `V3] as 'v] _handlers_unsafe
    (**/**)
    method private virtual on_copy : [> `V2 | `V3] t -> buffer:([`Wl_buffer], [> Imports.Wl_buffer.versions], [`Server]) Proxy.t ->
                                     unit
    
    (** Copy the frame.
        
        Copy the frame to the supplied buffer. The buffer must have a the
        correct size, see zwlr_screencopy_frame_v1.buffer and
        zwlr_screencopy_frame_v1.linux_dmabuf. The buffer needs to have a
        supported format.
        
        If the frame is successfully copied, a "flags" and a "ready" events are
        sent. Otherwise, a "failed" event is sent. *)
    
    method private virtual on_destroy : [> `V2 | `V3] t -> unit
    
    (** Delete this object, used or not.
        
        Destroys the frame. This request can be sent at any time by the client. *)
    
    method private virtual on_copy_with_damage : [> `V2 | `V3] t -> buffer:([`Wl_buffer], [> Imports.Wl_buffer.versions], [`Server]) Proxy.t ->
                                                 unit
    
    (** Copy the frame when it's damaged.
        
        Same as copy, except it waits until there is damage to copy. *)
    
    method min_version = 2l
  end
  
  (** Handler for a proxy with version >= 3. *)
  class virtual ['v] v3 = object (_ : (_, 'v, _) #Proxy.Service_handler.t)
    (**/**)
    inherit [[< `V3] as 'v] _handlers_unsafe
    (**/**)
    method private virtual on_copy : [> `V3] t -> buffer:([`Wl_buffer], [> Imports.Wl_buffer.versions], [`Server]) Proxy.t ->
                                     unit
    
    (** Copy the frame.
        
        Copy the frame to the supplied buffer. The buffer must have a the
        correct size, see zwlr_screencopy_frame_v1.buffer and
        zwlr_screencopy_frame_v1.linux_dmabuf. The buffer needs to have a
        supported format.
        
        If the frame is successfully copied, a "flags" and a "ready" events are
        sent. Otherwise, a "failed" event is sent. *)
    
    method private virtual on_destroy : [> `V3] t -> unit
    
    (** Delete this object, used or not.
        
        Destroys the frame. This request can be sent at any time by the client. *)
    
    method private virtual on_copy_with_damage : [> `V3] t -> buffer:([`Wl_buffer], [> Imports.Wl_buffer.versions], [`Server]) Proxy.t ->
                                                 unit
    
    (** Copy the frame when it's damaged.
        
        Same as copy, except it waits until there is damage to copy. *)
    
    method min_version = 3l
  end
end
OCaml

Innovation. Community. Security.