blob: e0f78b4dce9a85cb83c56c556f3d1943507d4a42 [file] [log] [blame]
Armin Krezović4690c562016-09-30 14:11:03 +02001/*
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
30extern "C" {
31#endif
32
33#include "plugin-registry.h"
34
35struct weston_compositor;
36struct weston_output;
37
38#define WESTON_WINDOWED_OUTPUT_API_NAME "weston_windowed_output_api_v1"
39
40struct 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 output.
60 *
61 * \param compositor The compositor instance.
62 * \param name Desired name for a new output.
63 *
64 * Returns 0 on success, -1 on failure.
65 *
66 * This creates a new output in the backend using this API.
67 * After this function is ran, the created output should be
68 * ready for configuration using the output_configure() and
69 * weston_output_set_{scale,transform}().
70 *
71 * An optional name can be assigned to it, so it can be used
72 * by compositor to configure it. It can't be NULL.
73 */
74 int (*output_create)(struct weston_compositor *compositor,
75 const char *name);
76};
77
78static inline const struct weston_windowed_output_api *
79weston_windowed_output_get_api(struct weston_compositor *compositor)
80{
81 const void *api;
82 api = weston_plugin_api_get(compositor, WESTON_WINDOWED_OUTPUT_API_NAME,
83 sizeof(struct weston_windowed_output_api));
84
85 return (const struct weston_windowed_output_api *)api;
86}
87
88#ifdef __cplusplus
89}
90#endif
91
92#endif /* WESTON_WINDOWED_OUTPUT_API_H */