Mir
common.h
Go to the documentation of this file.
1/*
2 * Simple definitions common to client and server.
3 *
4 * Copyright © 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
19#ifndef MIR_COMMON_H_
20#define MIR_COMMON_H_
21
22//for clang
23#ifndef __has_feature
24 #define __has_feature(x) 0 // Compatibility with non-clang
25#endif
26
27//for clang
28#ifndef __has_extension
29 #define __has_extension __has_feature // Compatibility with pre-3.0
30#endif
31
32/* This is C code. Not C++. */
33
34/**
35 * Attributes of a window that the client and server/shell may wish to
36 * get or set over the wire.
37 */
38typedef enum MirWindowAttrib
39{
40 /* Do not specify values...code relies on 0...N ordering. */
43 mir_window_attrib_swapinterval, /**< \deprecated Do not listen for events
44 reporting this attribute. Use the
45 "mir_*_get_swapinterval()" functions
46 instead if you wish query its value */
51 /* Must be last */
53} MirWindowAttrib;
54
55typedef enum MirWindowType
56{
57 mir_window_type_normal, /**< AKA "regular" */
58 mir_window_type_utility, /**< AKA "floating" */
63 mir_window_type_inputmethod, /**< AKA "OSK" or handwriting etc. */
64 mir_window_type_satellite, /**< AKA "toolbox"/"toolbar" */
65 mir_window_type_tip, /**< AKA "tooltip" */
68} MirWindowType;
69
70typedef enum MirWindowState
71{
77 /* mir_window_state_semimaximized,
78 Omitted for now, since it's functionally a subset of vertmaximized and
79 differs only in the X coordinate. */
83 mir_window_state_attached, /**< Used for panels, notifications and other windows attached to output edges */
85} MirWindowState;
86
88{
89 mir_window_focus_state_unfocused = 0, /**< Inactive and does not have focus */
90 mir_window_focus_state_focused, /**< Active and has keybaord focus */
91 mir_window_focus_state_active /**< Active but does not have keyboard focus */
92} MirWindowFocusState;
93
95{
98} MirWindowVisibility;
99
101{
105} MirLifecycleState;
106
107typedef enum MirPowerMode
108{
109 mir_power_mode_on, /* Display in use. */
110 mir_power_mode_standby, /* Blanked, low power. */
111 mir_power_mode_suspend, /* Blanked, lowest power. */
112 mir_power_mode_off /* Powered down. */
113} MirPowerMode;
114
115typedef enum MirOutputType
116{
117 mir_output_type_unknown = 0, /* DRM_MODE_CONNECTOR_Unknown */
118 mir_output_type_vga = 1, /* DRM_MODE_CONNECTOR_VGA */
119 mir_output_type_dvii = 2, /* DRM_MODE_CONNECTOR_DVII */
120 mir_output_type_dvid = 3, /* DRM_MODE_CONNECTOR_DVID */
121 mir_output_type_dvia = 4, /* DRM_MODE_CONNECTOR_DVIA */
122 mir_output_type_composite = 5, /* DRM_MODE_CONNECTOR_Composite */
123 mir_output_type_svideo = 6, /* DRM_MODE_CONNECTOR_SVIDEO */
124 mir_output_type_lvds = 7, /* DRM_MODE_CONNECTOR_LVDS */
125 mir_output_type_component = 8, /* DRM_MODE_CONNECTOR_Component */
126 mir_output_type_ninepindin = 9, /* DRM_MODE_CONNECTOR_9PinDIN */
127 mir_output_type_displayport = 10, /* DRM_MODE_CONNECTOR_DisplayPort */
128 mir_output_type_hdmia = 11, /* DRM_MODE_CONNECTOR_HDMIA */
129 mir_output_type_hdmib = 12, /* DRM_MODE_CONNECTOR_HDMIB */
130 mir_output_type_tv = 13, /* DRM_MODE_CONNECTOR_TV */
131 mir_output_type_edp = 14, /* DRM_MODE_CONNECTOR_eDP */
132 mir_output_type_virtual = 15, /* DRM_MODE_CONNECTOR_VIRTUAL */
133 mir_output_type_dsi = 16, /* DRM_MODE_CONNECTOR_DSI */
134 mir_output_type_dpi = 17, /* DRM_MODE_CONNECTOR_DPI */
135} MirOutputType;
136
138{
142} MirPromptSessionState;
143
144/**
145 * 32-bit pixel formats (8888):
146 * The order of components in the enum matches the order of the components
147 * as they would be written in an integer representing a pixel value of that
148 * format. For example; abgr_8888 should be coded as 0xAABBGGRR, which will
149 * end up as R,G,B,A in memory on a little endian system, and as A,B,G,R on a
150 * big endian system.
151 *
152 * 24-bit pixel formats (888):
153 * These are in literal byte order, regardless of CPU architecture it's always
154 * the same. Writing these 3-byte pixels is typically slower than other formats
155 * but uses less memory than 32-bit and is endian-independent.
156 *
157 * 16-bit pixel formats (565/5551/4444):
158 * Always interpreted as one 16-bit integer per pixel with components in
159 * high-to-low bit order following the format name. These are the fastest
160 * formats, however colour quality is visibly lower.
161 */
162typedef enum MirPixelFormat
163{
174 /*
175 * TODO: Big endian support would require additional formats in order to
176 * composite software surfaces using OpenGL (GL_RGBA/GL_BGRA_EXT):
177 * mir_pixel_format_rgb[ax]_8888
178 * mir_pixel_format_bgr[ax]_8888
179 */
180 mir_pixel_formats /* Note: This is always max format + 1 */
181} MirPixelFormat;
182
183/* This could be improved... https://bugs.launchpad.net/mir/+bug/1236254 */
184#define MIR_BYTES_PER_PIXEL(f) ((f) == mir_pixel_format_bgr_888 ? 3 :
185 (f) == mir_pixel_format_rgb_888 ? 3 :
186 (f) == mir_pixel_format_rgb_565 ? 2 :
187 (f) == mir_pixel_format_rgba_5551 ? 2 :
188 (f) == mir_pixel_format_rgba_4444 ? 2 :
189 4)
190
191/** Direction relative to the "natural" orientation of the display */
192typedef enum MirOrientation
193{
198} MirOrientation;
199
200/** Mirroring axis relative to the "natural" orientation of the display */
201typedef enum MirMirrorMode
202{
206} MirMirrorMode;
207
209{
220} MirOrientationMode;
221
223{
228} MirEdgeAttachment;
229
230// Inspired by GdkGravity
231/**
232 * Reference point for aligning a surface relative to a rectangle.
233 * Each element (surface and rectangle) has a MirPlacementGravity assigned.
234 */
236{
237 /// the reference point is at the center.
239
240 /// the reference point is at the middle of the left edge.
242
243 /// the reference point is at the middle of the right edge.
245
246 /// the reference point is in the middle of the top edge.
248
249 /// the reference point is at the middle of the lower edge.
251
252 /// the reference point is at the top left corner.
254
255 /// the reference point is at the top right corner.
257
258 /// the reference point is at the lower left corner.
260
261 /// the reference point is at the lower right corner.
263} MirPlacementGravity;
264
265// Inspired by GdkAnchorHints
266/**
267 * Positioning hints for aligning a window relative to a rectangle.
268 *
269 * These hints determine how the window should be positioned in the case that
270 * the surface would fall off-screen if placed in its ideal position.
271 *
272 * For example, \p mir_placement_hints_flip_x will invert the x component of
273 * \p aux_rect_placement_offset and replace \p mir_placement_gravity_northwest
274 * with \p mir_placement_gravity_northeast and vice versa if the window extends
275 * beyond the left or right edges of the monitor.
276 *
277 * If \p mir_placement_hints_slide_x is set, the window can be shifted
278 * horizontally to fit on-screen.
279 *
280 * If \p mir_placement_hints_resize_x is set, the window can be shrunken
281 * horizontally to fit.
282 *
283 * If \p mir_placement_hints_antipodes is set then the rect gravity may be
284 * substituted with the opposite corner (e.g. \p mir_placement_gravity_northeast
285 * to \p mir_placement_gravity_southwest) in combination with other options.
286 *
287 * When multiple flags are set, flipping should take precedence over sliding,
288 * which should take precedence over resizing.
289 */
291{
292 /// allow flipping anchors horizontally
294
295 /// allow flipping anchors vertically
297
298 /// allow sliding window horizontally
300
301 /// allow sliding window vertically
303
304 /// allow resizing window horizontally
306
307 /// allow resizing window vertically
309
310 /// allow flipping aux_anchor to opposite corner
312
313 /// allow flipping anchors on both axes
315
316 /// allow sliding window on both axes
318
319 /// allow resizing window on both axes
321} MirPlacementHints;
322
323
324/**
325 * Hints for resizing a window.
326 *
327 * These values are used to indicate which edge(s) of a surface
328 * is being dragged in a resize operation.
329 */
330typedef enum MirResizeEdge
331{
341} MirResizeEdge;
342
343/**
344 * Form factor associated with a physical output
345 */
346typedef enum MirFormFactor
347{
354} MirFormFactor;
355
356
357/**
358 * Physical arrangement of subpixels on the physical output
359 *
360 * This is always relative to the “natural†orientation of the display - mir_orientation_normal.
361 */
363{
364 mir_subpixel_arrangement_unknown, /**< Arrangement of subpixels cannot be determined */
365 mir_subpixel_arrangement_horizontal_rgb, /**< Subpixels are arranged horizontally, R, G, B from left to right */
366 mir_subpixel_arrangement_horizontal_bgr, /**< Subpixels are arranged horizontally, B, G, R from left to right */
367 mir_subpixel_arrangement_vertical_rgb, /**< Subpixels are arranged vertically, R, G, B from top to bottom */
368 mir_subpixel_arrangement_vertical_bgr, /**< Subpixels are arranged vertically, B, G, R from top to bottom */
369 mir_subpixel_arrangement_none /**< Device does not have regular subpixels */
370} MirSubpixelArrangement;
371
372/**
373 * Shell chrome
374 */
375typedef enum MirShellChrome
376{
379} MirShellChrome;
380
381/**
382 * Pointer Confinement
383 */
385{
391} MirPointerConfinementState;
392
393/**
394 * Supports gamma correction
395 */
397{
400} MirOutputGammaSupported;
401
402/**
403 * Depth layer controls Z ordering of surfaces.
404 *
405 * A surface will always appear on top of surfaces with a lower depth layer, and below those with a higher one.
406 * A depth layer can be converted to a number with mir::mir_depth_layer_get_index().
407 * This is useful for creating a list indexed by depth layer, or comparing the height of two layers.
408 */
409typedef enum MirDepthLayer
410{
411 mir_depth_layer_background, /**< For desktop backgrounds and alike (lowest layer) */
412 mir_depth_layer_below, /**< For panels or other controls/decorations below normal windows */
413 mir_depth_layer_application, /**< For normal application windows */
414 mir_depth_layer_always_on_top, /**< For always-on-top application windows */
415 mir_depth_layer_above, /**< For panels or notifications that want to be above normal windows */
416 mir_depth_layer_overlay, /**< For overlays such as lock screens (heighest layer) */
417} MirDepthLayer;
418
419/**
420 * Focus mode controls how a surface gains and loses focus.
421 */
422typedef enum MirFocusMode
423{
424 mir_focus_mode_focusable, /**< The surface can gain and lose focus normally */
425 mir_focus_mode_disabled, /**< The surface will never be given focus */
426 mir_focus_mode_grabbing, /**< This mode causes the surface to take focus if possible, and prevents focus from
427 leaving it as long as it has this mode */
428} MirFocusMode;
429
430#endif
MirFocusMode
Focus mode controls how a surface gains and loses focus.
Definition: common.h:423
@ mir_focus_mode_grabbing
This mode causes the surface to take focus if possible, and prevents focus from leaving it as long as...
Definition: common.h:426
@ mir_focus_mode_disabled
The surface will never be given focus.
Definition: common.h:425
@ mir_focus_mode_focusable
The surface can gain and lose focus normally.
Definition: common.h:424
MirFormFactor
Form factor associated with a physical output.
Definition: common.h:347
@ mir_form_factor_unknown
Definition: common.h:348
@ mir_form_factor_projector
Definition: common.h:353
@ mir_form_factor_tablet
Definition: common.h:350
@ mir_form_factor_phone
Definition: common.h:349
@ mir_form_factor_tv
Definition: common.h:352
@ mir_form_factor_monitor
Definition: common.h:351
MirOrientation
Direction relative to the "natural" orientation of the display.
Definition: common.h:193
@ mir_orientation_right
Definition: common.h:197
@ mir_orientation_normal
Definition: common.h:194
@ mir_orientation_left
Definition: common.h:195
@ mir_orientation_inverted
Definition: common.h:196
MirResizeEdge
Hints for resizing a window.
Definition: common.h:331
@ mir_resize_edge_northeast
Definition: common.h:338
@ mir_resize_edge_southwest
Definition: common.h:339
@ mir_resize_edge_south
Definition: common.h:336
@ mir_resize_edge_southeast
Definition: common.h:340
@ mir_resize_edge_north
Definition: common.h:335
@ mir_resize_edge_east
Definition: common.h:334
@ mir_resize_edge_west
Definition: common.h:333
@ mir_resize_edge_none
Definition: common.h:332
@ mir_resize_edge_northwest
Definition: common.h:337
MirPowerMode
Definition: common.h:108
@ mir_power_mode_standby
Definition: common.h:110
@ mir_power_mode_suspend
Definition: common.h:111
@ mir_power_mode_off
Definition: common.h:112
@ mir_power_mode_on
Definition: common.h:109
MirPointerConfinementState
Pointer Confinement.
Definition: common.h:385
@ mir_pointer_locked_oneshot
Definition: common.h:389
@ mir_pointer_unconfined
Definition: common.h:386
@ mir_pointer_locked_persistent
Definition: common.h:390
@ mir_pointer_confined_oneshot
Definition: common.h:387
@ mir_pointer_confined_persistent
Definition: common.h:388
MirLifecycleState
Definition: common.h:101
@ mir_lifecycle_connection_lost
Definition: common.h:104
@ mir_lifecycle_state_will_suspend
Definition: common.h:102
@ mir_lifecycle_state_resumed
Definition: common.h:103
MirWindowType
Definition: common.h:56
@ mir_window_type_menu
Definition: common.h:62
, /* Blanked, lowest p/b> common.h:56
, /* Blanked, lowest p/b>9713c22fb0c2d7fe545aaa69d8610bf49­„ˆ½n> enum enum eent">/* Blanked, lowest p/b>9713c22fb0c2d7fe545aaa69d8610bf49­„ˆ½n>stest formats, however colour quality is visibly lower.

enum
enum
Definition: common.href="common_8h.html#a09460db0a7a636dc39d36fd5aa1f4865a007dece37d69a3541d1fd835ff1d5276"> 427 span> span>  span>  span> span> 492ad301797"> 61 s41a24bee0d5dcfd3d4d42c5793896ac25834997e3602675f2espan> mir_subpixel_ar class="el" href="span> 389
= 1 << 0 ,
= 1 << 0 ,
= 1 << 0 ,
371 371 371662a7497cdab31557a073a4f5d195b2e636dc364c8c16b23bd6c0c5bdafba26337e63b26ca61e01d8fddf24b1f6et">
m>} MirOutputGammaSupported;
Enumeratormir_depth_laye hl_enumvalue" href=088344n_8h.html#a767377fc0ee9f2097bcee966c72b957c36429f7f00600826f">3993d5 14ortrait_inverted = 1 <<8257405eb33d747">mir_depth_laye 40d">◆ MirMirrorMode
7 * it under the terms of the GNU Lesser General Public Licens= 1 <<8257405eb33d747">mir_depth_laye 40d">◆ 
221
span> 0 492ad301797"> 61 span class="lineno"> 1399 mir_dow_state_restored,
Pointer Confinementns="http://www.w3.org/1999ye 40d">◆&nbs="line"> .wr>
MirWindowType
mi class="ttdoc">The surface can gain and lose focus noclass="line" href="common_8h.htmla61e01d8fddf24b1f6et">
47
Definition: common4627ee_east
398
398<"l0043be0bf225281112ea5e3a"> 398 398Defd class="memname">tyfc143ca3199c31b20aaeb09eaf945">mir_pixel_format_rgd_5h.html#ae3151d665951e96c1e4874b6d45ba0fda7b39e2049:195
< mir_focus_mode_disame">e486c02e6824e4438ff1b3be0bf225281112ea5e3a"> 398 41
< mir_focus_mode_disame">e486c02e6824e4438ff1b
@ mac_form_factor_phone
Definition: common.h:349@ mir_form_factor_tablet
Definition: common.h:350
@ mac_form_factor_phone
Definitioiv>
Definitidiv class="ttc" id="acommon_8h_html_a0b15a32ffb64c8c16b23bd6c0c5bda3baa8f5552aa" id="acommo7e63b26ca61e01d9f82c4">MirShellChrome
@ mac_form_factor_phone
@ mac_form_facppear on top of surfaces with a lefinitidiv class="ttc" id="acommon_8h_html_a0b15a32fss="ttc" id="acommon_8h_html_a0b15a32fss="ttc" id="acommon_8h_htm */
mir_resize_ed>
mir_pixel_format_invalidrm_facppear on top of surtor
/**< For alwa**&l ; For alwa**&l ; For alwa**&l ; For alwa**&l ; For alwa**&l ; For a**&l_phone
@ mir_form_factor_phone
253 714abd85accf8ab460c9fbfd1f773f6 name="l00205">50b9c6709714abd85accf8ab460c9fbfd1f773f6 <43" name="l00243"> 243