Mir
common.h
Go to the documentation of this file.
1 /*
2  * Simple definitions common to client and server.
3  *
4  * Copyright © 2013-2016 Canonical Ltd.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License version 2 or 3 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
19  */
20 
21 #ifndef MIR_COMMON_H_
22 #define MIR_COMMON_H_
23 
25 
26 //for clang
27 #ifndef __has_feature
28  #define __has_feature(x) 0 // Compatibility with non-clang
29 #endif
30 
31 //for clang
32 #ifndef __has_extension
33  #define __has_extension __has_feature // Compatibility with pre-3.0
34 #endif
35 
36 #if __GNUC__ >= 6 || \
37  (__has_extension(attribute_deprecated_with_message) && \
38  __has_extension(enumerator_attributes))
39  #define MIR_DEPRECATED_ENUM(ENUM, INSTEAD) \
40  ENUM MIR_FOR_REMOVAL_IN_VERSION_1("Use " #INSTEAD " instead")
41 #else
42  #define MIR_DEPRECATED_ENUM(ENUM, INSTEAD) \
43  ENUM
44 #endif
49 /* This is C code. Not C++. */
50 
55 typedef enum MirSurfaceAttrib
56 {
57  /* Do not specify values...code relies on 0...N ordering. */
68  /* Must be last */
70 } MirSurfaceAttrib MIR_FOR_REMOVAL_IN_VERSION_1("use MirWindowAttrib");
71 
76 typedef enum MirWindowAttrib
77 {
78  /* Do not specify values...code relies on 0...N ordering. */
89  /* Must be last */
92 
93 typedef enum MirSurfaceType
94 {
107 } MirSurfaceType MIR_FOR_REMOVAL_IN_VERSION_1("use MirWindowType");
108 
109 typedef enum MirWindowType
110 {
123 
124 typedef enum MirSurfaceState
125 {
131  /* mir_surface_state_semimaximized,
132  Omitted for now, since it's functionally a subset of vertmaximized and
133  differs only in the X coordinate. */
139 } MirSurfaceState MIR_FOR_REMOVAL_IN_VERSION_1("use MirWindowState");
140 
141 typedef enum MirWindowState
142 {
148  /* mir_window_state_semimaximized,
149  Omitted for now, since it's functionally a subset of vertmaximized and
150  differs only in the X coordinate. */
157 
159 {
162 } MirSurfaceFocusState MIR_FOR_REMOVAL_IN_VERSION_1("use MirWindowFocusState");
163 
165 {
169 
171 {
174 } MirSurfaceVisibility MIR_FOR_REMOVAL_IN_VERSION_1("use MirWindowFocusState");
175 
177 {
181 
182 typedef enum MirLifecycleState
183 {
188 
189 typedef enum MirPowerMode
190 {
191  mir_power_mode_on, /* Display in use. */
192  mir_power_mode_standby, /* Blanked, low power. */
193  mir_power_mode_suspend, /* Blanked, lowest power. */
194  mir_power_mode_off /* Powered down. */
196 
197 typedef enum MirOutputType
198 {
199  mir_output_type_unknown = 0, /* DRM_MODE_CONNECTOR_Unknown */
200  mir_output_type_vga = 1, /* DRM_MODE_CONNECTOR_VGA */
201  mir_output_type_dvii = 2, /* DRM_MODE_CONNECTOR_DVII */
202  mir_output_type_dvid = 3, /* DRM_MODE_CONNECTOR_DVID */
203  mir_output_type_dvia = 4, /* DRM_MODE_CONNECTOR_DVIA */
204  mir_output_type_composite = 5, /* DRM_MODE_CONNECTOR_Composite */
205  mir_output_type_svideo = 6, /* DRM_MODE_CONNECTOR_SVIDEO */
206  mir_output_type_lvds = 7, /* DRM_MODE_CONNECTOR_LVDS */
207  mir_output_type_component = 8, /* DRM_MODE_CONNECTOR_Component */
208  mir_output_type_ninepindin = 9, /* DRM_MODE_CONNECTOR_9PinDIN */
209  mir_output_type_displayport = 10, /* DRM_MODE_CONNECTOR_DisplayPort */
210  mir_output_type_hdmia = 11, /* DRM_MODE_CONNECTOR_HDMIA */
211  mir_output_type_hdmib = 12, /* DRM_MODE_CONNECTOR_HDMIB */
212  mir_output_type_tv = 13, /* DRM_MODE_CONNECTOR_TV */
213  mir_output_type_edp = 14, /* DRM_MODE_CONNECTOR_eDP */
214  mir_output_type_virtual = 15, /* DRM_MODE_CONNECTOR_VIRTUAL */
215  mir_output_type_dsi = 16, /* DRM_MODE_CONNECTOR_DSI */
216  mir_output_type_dpi = 17, /* DRM_MODE_CONNECTOR_DPI */
218 
220 {
225 
244 typedef enum MirPixelFormat
245 {
256  /*
257  * TODO: Big endian support would require additional formats in order to
258  * composite software surfaces using OpenGL (GL_RGBA/GL_BGRA_EXT):
259  * mir_pixel_format_rgb[ax]_8888
260  * mir_pixel_format_bgr[ax]_8888
261  */
262  mir_pixel_formats /* Note: This is always max format + 1 */
264 
265 /* This could be improved... https://bugs.launchpad.net/mir/+bug/1236254 */
266 #define MIR_BYTES_PER_PIXEL(f) ((f) == mir_pixel_format_bgr_888 ? 3 : \
267  (f) == mir_pixel_format_rgb_888 ? 3 : \
268  (f) == mir_pixel_format_rgb_565 ? 2 : \
269  (f) == mir_pixel_format_rgba_5551 ? 2 : \
270  (f) == mir_pixel_format_rgba_4444 ? 2 : \
271  4)
272 
274 typedef enum MirOrientation
275 {
281 
283 typedef enum MirMirrorMode
284 {
289 
290 typedef enum MirOrientationMode
291 {
303 
304 typedef enum MirEdgeAttachment
305 {
311 
312 // Inspired by GdkGravity
318 {
321 
324 
327 
330 
333 
336