package wayland

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

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

[@@@ocaml.warning "-27-34"]
open struct
  module Imports = struct
    include Viewporter_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


(** Surface cropping and scaling.
    
    The global interface exposing surface cropping and scaling
    capabilities is used to instantiate an interface extension for a
    wl_surface object. This extended interface will then allow
    cropping and scaling the surface contents, effectively
    disconnecting the direct relationship between the buffer and the
    surface size. *)
module Wp_viewporter = struct
  type 'v t = ([`Wp_viewporter], 'v, [`Server]) Proxy.t
  module Error = Viewporter_proto.Wp_viewporter.Error
  
  (** {2 Version 1} *)
  
  (**/**)
  class virtual ['v] _handlers_unsafe = object (_self : (_, 'v, _) #Proxy.Handler.t)
    method user_data = S.No_data
    method metadata = (module Viewporter_proto.Wp_viewporter)
    method max_version = 1l
    
    method private virtual on_destroy : [> ] t -> unit
    
    method private virtual on_get_viewport : [> ] t -> ([`Wp_viewport], 'v, [`Server]) Proxy.t ->
                                             surface:([`Wl_surface], [> Imports.Wl_surface.versions], [`Server]) Proxy.t ->
                                             unit
    
    
    method dispatch (_proxy : 'v t) _msg =
      let _proxy = Proxy.cast_version _proxy in
      match Msg.op _msg with
      | 0 ->
        Proxy.shutdown_recv _proxy;
        _self#on_destroy _proxy 
      | 1 ->
        let id : ([`Wp_viewport], _, _) Proxy.t =
          Msg.get_int _msg |> Proxy.Handler.accept_new _proxy (module Imports.Wp_viewport) in
        let surface : ([`Wl_surface], _, _) Proxy.t =
          let Proxy.Proxy p = Msg.get_int _msg |> Proxy.lookup_other _proxy in
          match Proxy.ty p with
          | Imports.Wl_surface.T -> p
          | _ -> Proxy.wrong_type ~parent:_proxy ~expected:"wl_surface" p
          in
        _self#on_get_viewport _proxy id ~surface
      | _ -> 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] as 'v] _handlers_unsafe
    (**/**)
    method private virtual on_destroy : [> `V1] t -> unit
    
    (** Unbind from the cropping and scaling interface.
        
        Informs the server that the client will not be using this
        protocol object anymore. This does not affect any other objects,
        wp_viewport objects included. *)
    
    method private virtual on_get_viewport : [> `V1] t -> ([`Wp_viewport], 'v, [`Server]) Proxy.t ->
                                             surface:([`Wl_surface], [> Imports.Wl_surface.versions], [`Server]) Proxy.t ->
                                             unit
    
    (** Extend surface interface for crop and scale.
        
        Instantiate an interface extension for the given wl_surface to
        crop and scale its content. If the given wl_surface already has
        a wp_viewport object associated, the viewport_exists
        protocol error is raised. *)
    
    method min_version = 1l
    method bind_version : [`V1] = `V1
  end
end

(** Crop and scale interface to a wl_surface.
    
    An additional interface to a wl_surface object, which allows the
    client to specify the cropping and scaling of the surface
    contents.
    
    This interface works with two concepts: the source rectangle (src_x,
    src_y, src_width, src_height), and the destination size (dst_width,
    dst_height). The contents of the source rectangle are scaled to the
    destination size, and content outside the source rectangle is ignored.
    This state is double-buffered, see wl_surface.commit.
    
    The two parts of crop and scale state are independent: the source
    rectangle, and the destination size. Initially both are unset, that
    is, no scaling is applied. The whole of the current wl_buffer is
    used as the source, and the surface size is as defined in
    wl_surface.attach.
    
    If the destination size is set, it causes the surface size to become
    dst_width, dst_height. The source (rectangle) is scaled to exactly
    this size. This overrides whatever the attached wl_buffer size is,
    unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
    has no content and therefore no size. Otherwise, the size is always
    at least 1x1 in surface local coordinates.
    
    If the source rectangle is set, it defines what area of the wl_buffer is
    taken as the source. If the source rectangle is set and the destination
    size is not set, then src_width and src_height must be integers, and the
    surface size becomes the source rectangle size. This results in cropping
    without scaling. If src_width or src_height are not integers and
    destination size is not set, the bad_size protocol error is raised when
    the surface state is applied.
    
    The coordinate transformations from buffer pixel coordinates up to
    the surface-local coordinates happen in the following order:
    1. buffer_transform (wl_surface.set_buffer_transform)
    2. buffer_scale (wl_surface.set_buffer_scale)
    3. crop and scale (wp_viewport.set*[])
    This means, that the source rectangle coordinates of crop and scale
    are given in the coordinates after the buffer transform and scale,
    i.e. in the coordinates that would be the surface-local coordinates
    if the crop and scale was not applied.
    
    If src_x or src_y are negative, the bad_value protocol error is raised.
    Otherwise, if the source rectangle is partially or completely outside of
    the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
    when the surface state is applied. A NULL wl_buffer does not raise the
    out_of_buffer error.
    
    If the wl_surface associated with the wp_viewport is destroyed,
    all wp_viewport requests except 'destroy' raise the protocol error
    no_surface.
    
    If the wp_viewport object is destroyed, the crop and scale
    state is removed from the wl_surface. The change will be applied
    on the next wl_surface.commit. *)
module Wp_viewport = struct
  type 'v t = ([`Wp_viewport], 'v, [`Server]) Proxy.t
  module Error = Viewporter_proto.Wp_viewport.Error
  
  (** {2 Version 1} *)
  
  (**/**)
  class virtual ['v] _handlers_unsafe = object (_self : (_, 'v, _) #Proxy.Handler.t)
    method user_data = S.No_data
    method metadata = (module Viewporter_proto.Wp_viewport)
    method max_version = 1l
    
    method private virtual on_destroy : [> ] t -> unit
    
    method private virtual on_set_source : [> ] t -> x:Fixed.t -> y:Fixed.t -> width:Fixed.t -> height:Fixed.t -> unit
    
    method private virtual on_set_destination : [> ] t -> width:int32 -> height:int32 -> unit
    
    
    method dispatch (_proxy : 'v t) _msg =
      let _proxy = Proxy.cast_version _proxy in
      match Msg.op _msg with
      | 0 ->
        Proxy.shutdown_recv _proxy;
        _self#on_destroy _proxy 
      | 1 ->
        let x = Msg.get_fixed _msg in
        let y = Msg.get_fixed _msg in
        let width = Msg.get_fixed _msg in
        let height = Msg.get_fixed _msg in
        _self#on_set_source _proxy ~x ~y ~width ~height
      | 2 ->
        let width = Msg.get_int _msg in
        let height = Msg.get_int _msg in
        _self#on_set_destination _proxy ~width ~height
      | _ -> 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] as 'v] _handlers_unsafe
    (**/**)
    method private virtual on_destroy : [> `V1] t -> unit
    
    (** Remove scaling and cropping from the surface.
        
        The associated wl_surface's crop and scale state is removed.
        The change is applied on the next wl_surface.commit. *)
    
    method private virtual on_set_source : [> `V1] t -> x:Fixed.t -> y:Fixed.t -> width:Fixed.t -> height:Fixed.t ->
                                           unit
    
    (** Set the source rectangle for cropping.
        
        Set the source rectangle of the associated wl_surface. See
        wp_viewport for the description, and relation to the wl_buffer
        size.
        
        If all of x, y, width and height are -1.0, the source rectangle is
        unset instead. Any other set of values where width or height are zero
        or negative, or x or y are negative, raise the bad_value protocol
        error.
        
        The crop and scale state is double-buffered, see wl_surface.commit. *)
    
    method private virtual on_set_destination : [> `V1] t -> width:int32 -> height:int32 -> unit
    
    (** Set the surface size for scaling.
        
        Set the destination size of the associated wl_surface. See
        wp_viewport for the description, and relation to the wl_buffer
        size.
        
        If width is -1 and height is -1, the destination size is unset
        instead. Any other pair of values for width and height that
        contains zero or negative values raises the bad_value protocol
        error.
        
        The crop and scale state is double-buffered, see wl_surface.commit. *)
    
    method min_version = 1l
  end
end
OCaml

Innovation. Community. Security.