summaryrefslogtreecommitdiffstats
path: root/widget/gtk/wayland/fractional-scale-v1-client-protocol.h
blob: 3db2eaad6b09efb948a23be62588c03237c25521 (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
/* Generated by wayland-scanner 1.19.0 */

#ifndef FRACTIONAL_SCALE_V1_CLIENT_PROTOCOL_H
#define FRACTIONAL_SCALE_V1_CLIENT_PROTOCOL_H

#include <stdint.h>
#include <stddef.h>
#include "wayland-client.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @page page_fractional_scale_v1 The fractional_scale_v1 protocol
 * Protocol for requesting fractional surface scales
 *
 * @section page_desc_fractional_scale_v1 Description
 *
 * This protocol allows a compositor to suggest for surfaces to render at
 * fractional scales.
 *
 * A client can submit scaled content by utilizing wp_viewport. This is done by
 * creating a wp_viewport object for the surface and setting the destination
 * rectangle to the surface size before the scale factor is applied.
 *
 * The buffer size is calculated by multiplying the surface size by the
 * intended scale.
 *
 * The wl_surface buffer scale should remain set to 1.
 *
 * If a surface has a surface-local size of 100 px by 50 px and wishes to
 * submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should
 * be used and the wp_viewport destination rectangle should be 100 px by 50 px.
 *
 * For toplevel surfaces, the size is rounded halfway away from zero. The
 * rounding algorithm for subsurface position and size is not defined.
 *
 * @section page_ifaces_fractional_scale_v1 Interfaces
 * - @subpage page_iface_wp_fractional_scale_manager_v1 - fractional surface
 * scale information
 * - @subpage page_iface_wp_fractional_scale_v1 - fractional scale interface to
 * a wl_surface
 * @section page_copyright_fractional_scale_v1 Copyright
 * <pre>
 *
 * Copyright © 2022 Kenny Levinsen
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 * </pre>
 */
struct wl_surface;
struct wp_fractional_scale_manager_v1;
struct wp_fractional_scale_v1;

#ifndef WP_FRACTIONAL_SCALE_MANAGER_V1_INTERFACE
#  define WP_FRACTIONAL_SCALE_MANAGER_V1_INTERFACE
/**
 * @page page_iface_wp_fractional_scale_manager_v1
 * wp_fractional_scale_manager_v1
 * @section page_iface_wp_fractional_scale_manager_v1_desc Description
 *
 * A global interface for requesting surfaces to use fractional scales.
 * @section page_iface_wp_fractional_scale_manager_v1_api API
 * See @ref iface_wp_fractional_scale_manager_v1.
 */
/**
 * @defgroup iface_wp_fractional_scale_manager_v1 The
 * wp_fractional_scale_manager_v1 interface
 *
 * A global interface for requesting surfaces to use fractional scales.
 */
extern const struct wl_interface wp_fractional_scale_manager_v1_interface;
#endif
#ifndef WP_FRACTIONAL_SCALE_V1_INTERFACE
#  define WP_FRACTIONAL_SCALE_V1_INTERFACE
/**
 * @page page_iface_wp_fractional_scale_v1 wp_fractional_scale_v1
 * @section page_iface_wp_fractional_scale_v1_desc Description
 *
 * An additional interface to a wl_surface object which allows the compositor
 * to inform the client of the preferred scale.
 * @section page_iface_wp_fractional_scale_v1_api API
 * See @ref iface_wp_fractional_scale_v1.
 */
/**
 * @defgroup iface_wp_fractional_scale_v1 The wp_fractional_scale_v1 interface
 *
 * An additional interface to a wl_surface object which allows the compositor
 * to inform the client of the preferred scale.
 */
extern const struct wl_interface wp_fractional_scale_v1_interface;
#endif

#ifndef WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM
#  define WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM
enum wp_fractional_scale_manager_v1_error {
  /**
   * the surface already has a fractional_scale object associated
   */
  WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS = 0,
};
#endif /* WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM */

#define WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY 0
#define WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE 1

/**
 * @ingroup iface_wp_fractional_scale_manager_v1
 */
#define WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_wp_fractional_scale_manager_v1
 */
#define WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE_SINCE_VERSION 1

/** @ingroup iface_wp_fractional_scale_manager_v1 */
static inline void wp_fractional_scale_manager_v1_set_user_data(
    struct wp_fractional_scale_manager_v1* wp_fractional_scale_manager_v1,
    void* user_data) {
  wl_proxy_set_user_data((struct wl_proxy*)wp_fractional_scale_manager_v1,
                         user_data);
}

/** @ingroup iface_wp_fractional_scale_manager_v1 */
static inline void* wp_fractional_scale_manager_v1_get_user_data(
    struct wp_fractional_scale_manager_v1* wp_fractional_scale_manager_v1) {
  return wl_proxy_get_user_data(
      (struct wl_proxy*)wp_fractional_scale_manager_v1);
}

static inline uint32_t wp_fractional_scale_manager_v1_get_version(
    struct wp_fractional_scale_manager_v1* wp_fractional_scale_manager_v1) {
  return wl_proxy_get_version((struct wl_proxy*)wp_fractional_scale_manager_v1);
}

/**
 * @ingroup iface_wp_fractional_scale_manager_v1
 *
 * Informs the server that the client will not be using this protocol
 * object anymore. This does not affect any other objects,
 * wp_fractional_scale_v1 objects included.
 */
static inline void wp_fractional_scale_manager_v1_destroy(
    struct wp_fractional_scale_manager_v1* wp_fractional_scale_manager_v1) {
  wl_proxy_marshal((struct wl_proxy*)wp_fractional_scale_manager_v1,
                   WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY);

  wl_proxy_destroy((struct wl_proxy*)wp_fractional_scale_manager_v1);
}

/**
 * @ingroup iface_wp_fractional_scale_manager_v1
 *
 * Create an add-on object for the the wl_surface to let the compositor
 * request fractional scales. If the given wl_surface already has a
 * wp_fractional_scale_v1 object associated, the fractional_scale_exists
 * protocol error is raised.
 */
static inline struct wp_fractional_scale_v1*
wp_fractional_scale_manager_v1_get_fractional_scale(
    struct wp_fractional_scale_manager_v1* wp_fractional_scale_manager_v1,
    struct wl_surface* surface) {
  struct wl_proxy* id;

  id = wl_proxy_marshal_constructor(
      (struct wl_proxy*)wp_fractional_scale_manager_v1,
      WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE,
      &wp_fractional_scale_v1_interface, NULL, surface);

  return (struct wp_fractional_scale_v1*)id;
}

/**
 * @ingroup iface_wp_fractional_scale_v1
 * @struct wp_fractional_scale_v1_listener
 */
struct wp_fractional_scale_v1_listener {
  /**
   * notify of new preferred scale
   *
   * Notification of a new preferred scale for this surface that
   * the compositor suggests that the client should use.
   *
   * The sent scale is the numerator of a fraction with a denominator
   * of 120.
   * @param scale the new preferred scale
   */
  void (*preferred_scale)(void* data,
                          struct wp_fractional_scale_v1* wp_fractional_scale_v1,
                          uint32_t scale);
};

/**
 * @ingroup iface_wp_fractional_scale_v1
 */
static inline int wp_fractional_scale_v1_add_listener(
    struct wp_fractional_scale_v1* wp_fractional_scale_v1,
    const struct wp_fractional_scale_v1_listener* listener, void* data) {
  return wl_proxy_add_listener((struct wl_proxy*)wp_fractional_scale_v1,
                               (void (**)(void))listener, data);
}

#define WP_FRACTIONAL_SCALE_V1_DESTROY 0

/**
 * @ingroup iface_wp_fractional_scale_v1
 */
#define WP_FRACTIONAL_SCALE_V1_PREFERRED_SCALE_SINCE_VERSION 1

/**
 * @ingroup iface_wp_fractional_scale_v1
 */
#define WP_FRACTIONAL_SCALE_V1_DESTROY_SINCE_VERSION 1

/** @ingroup iface_wp_fractional_scale_v1 */
static inline void wp_fractional_scale_v1_set_user_data(
    struct wp_fractional_scale_v1* wp_fractional_scale_v1, void* user_data) {
  wl_proxy_set_user_data((struct wl_proxy*)wp_fractional_scale_v1, user_data);
}

/** @ingroup iface_wp_fractional_scale_v1 */
static inline void* wp_fractional_scale_v1_get_user_data(
    struct wp_fractional_scale_v1* wp_fractional_scale_v1) {
  return wl_proxy_get_user_data((struct wl_proxy*)wp_fractional_scale_v1);
}

static inline uint32_t wp_fractional_scale_v1_get_version(
    struct wp_fractional_scale_v1* wp_fractional_scale_v1) {
  return wl_proxy_get_version((struct wl_proxy*)wp_fractional_scale_v1);
}

/**
 * @ingroup iface_wp_fractional_scale_v1
 *
 * Destroy the fractional scale object. When this object is destroyed,
 * preferred_scale events will no longer be sent.
 */
static inline void wp_fractional_scale_v1_destroy(
    struct wp_fractional_scale_v1* wp_fractional_scale_v1) {
  wl_proxy_marshal((struct wl_proxy*)wp_fractional_scale_v1,
                   WP_FRACTIONAL_SCALE_V1_DESTROY);

  wl_proxy_destroy((struct wl_proxy*)wp_fractional_scale_v1);
}

#ifdef __cplusplus
}
#endif

#endif