1 /*
2 * Copyright © 2016 Armin Krezović
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26 #ifndef WESTON_WINDOWED_OUTPUT_API_H
27 #define WESTON_WINDOWED_OUTPUT_API_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #include <libweston/plugin-registry.h>
34
35 struct weston_compositor;
36 struct weston_output;
37
38 #define WESTON_WINDOWED_OUTPUT_API_NAME "weston_windowed_output_api_v1"
39
40 struct weston_windowed_output_api {
41 /** Assign a given width and height to an output.
42 *
43 * \param output An output to be configured.
44 * \param width Desired width of the output.
45 * \param height Desired height of the output.
46 *
47 * Returns 0 on success, -1 on failure.
48 *
49 * This assigns a desired width and height to a windowed
50 * output. The backend decides what should be done and applies
51 * the desired configuration. After using this function and
52 * generic weston_output_set_*, a windowed
53 * output should be in a state where weston_output_enable()
54 * can be run.
55 */
56 int (*output_set_size)(struct weston_output *output,
57 int width, int height);
58
59 /** Create a new windowed head.
60 *
61 * \param compositor The compositor instance.
62 * \param name Desired name for a new head, not NULL.
63 *
64 * Returns 0 on success, -1 on failure.
65 *
66 * This creates a new head in the backend. The new head will
67 * be advertised in the compositor's head list and triggers a
68 * head_changed callback.
69 *
70 * A new output can be created for the head. The output must be
71 * configured with output_set_size() and
72 * weston_output_set_{scale,transform}() before enabling it.
73 *
74 * \sa weston_compositor_set_heads_changed_cb(),
75 * weston_compositor_create_output_with_head()
76 */
77 int (*create_head)(struct weston_compositor *compositor,
78 const char *name);
79 };
80
81 static inline const struct weston_windowed_output_api *
weston_windowed_output_get_api(struct weston_compositor * compositor)82 weston_windowed_output_get_api(struct weston_compositor *compositor)
83 {
84 const void *api;
85 api = weston_plugin_api_get(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
86 sizeof(struct weston_windowed_output_api));
87
88 return (const struct weston_windowed_output_api *)api;
89 }
90
91 #ifdef __cplusplus
92 }
93 #endif
94
95 #endif /* WESTON_WINDOWED_OUTPUT_API_H */
96