113ea1a2d927e8cd8cee690711024b62250c6f2a
[platform/upstream/kmscon.git] / src / kmscon_conf.h
1 /*
2  * Main App
3  *
4  * Copyright (c) 2012 David Herrmann <dh.herrmann@googlemail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files
8  * (the "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25
26 /*
27  * This includes global data for the whole kmscon application. For instance,
28  * global parameters can be accessed via this header.
29  */
30
31 #ifndef KMSCON_MAIN_H
32 #define KMSCON_MAIN_H
33
34 #include <stdbool.h>
35 #include <stddef.h>
36 #include <stdlib.h>
37 #include "conf.h"
38 #include "shl_dlist.h"
39
40 enum kmscon_conf_gpu_selection {
41         KMSCON_GPU_ALL,
42         KMSCON_GPU_AUX,
43         KMSCON_GPU_PRIMARY,
44 };
45
46 struct kmscon_conf_t {
47         /* header information */
48         bool seat_config;
49
50         /* General Options */
51         /* show help/usage information */
52         bool help;
53         /* exit application after parsing options */
54         bool exit;
55         /* enable verbose info messages */
56         bool verbose;
57         /* enable debug messages */
58         bool debug;
59         /* disable notices and warnings */
60         bool silent;
61         /* config directory name */
62         char *configdir;
63         /* listen mode */
64         bool listen;
65
66         /* Seat Options */
67         /* VT number to run on */
68         char *vt;
69         /* enter new VT directly */
70         bool switchvt;
71         /* seats */
72         char **seats;
73
74         /* Session Options */
75         /* sessions */
76         unsigned int session_max;
77         /* allow keyboard session control */
78         bool session_control;
79         /* run terminal session */
80         bool terminal_session;
81         /* cdev session */
82         bool cdev_session;
83
84         /* Terminal Options */
85         /* custom login process */
86         bool login;
87         /* argv for login process */
88         char **argv;
89         /* TERM value */
90         char *term;
91         /* reset environment */
92         bool reset_env;
93         /* color palette */
94         char *palette;
95         /* terminal scroll-back buffer size */
96         unsigned int sb_size;
97
98         /* Input Options */
99         /* input KBD model */
100         char *xkb_model;
101         /* input KBD layout */
102         char *xkb_layout;
103         /* input KBD variant */
104         char *xkb_variant;
105         /* input KBD options */
106         char *xkb_options;
107         /* input predefined KBD keymap */
108         char *xkb_keymap;
109         /* keyboard key-repeat delay */
110         unsigned int xkb_repeat_delay;
111         /* keyboard key-repeat rate */
112         unsigned int xkb_repeat_rate;
113
114         /* Grabs / Keyboard-Shortcuts */
115         /* scroll-up grab */
116         struct conf_grab *grab_scroll_up;
117         /* scroll-down grab */
118         struct conf_grab *grab_scroll_down;
119         /* page-up grab */
120         struct conf_grab *grab_page_up;
121         /* page-down grab */
122         struct conf_grab *grab_page_down;
123         /* zoom-in grab */
124         struct conf_grab *grab_zoom_in;
125         /* zoom-out grab */
126         struct conf_grab *grab_zoom_out;
127         /* session-next grab */
128         struct conf_grab *grab_session_next;
129         /* session-prev grab */
130         struct conf_grab *grab_session_prev;
131         /* session-dummy grab */
132         struct conf_grab *grab_session_dummy;
133         /* session-close grab */
134         struct conf_grab *grab_session_close;
135         /* terminal-new grab */
136         struct conf_grab *grab_terminal_new;
137
138         /* Video Options */
139         /* use DRM if available */
140         bool drm;
141         /* use 3D hardware-acceleration if available */
142         bool hwaccel;
143         /* gpu selection mode */
144         unsigned int gpus;
145         /* render engine */
146         char *render_engine;
147         /* print render-engine timing information */
148         bool render_timing;
149
150         /* Font Options */
151         /* font engine */
152         char *font_engine;
153         /* font size */
154         unsigned int font_size;
155         /* font name */
156         char *font_name;
157         /* font ppi (overrides per monitor PPI) */
158         unsigned int font_ppi;
159 };
160
161 int kmscon_conf_new(struct conf_ctx **out);
162 void kmscon_conf_free(struct conf_ctx *ctx);
163 int kmscon_conf_load_main(struct conf_ctx *ctx, int argc, char **argv);
164 int kmscon_conf_load_seat(struct conf_ctx *ctx, const struct conf_ctx *main,
165                           const char *seat);
166
167 static inline bool kmscon_conf_is_current_seat(struct kmscon_conf_t *conf)
168 {
169         return conf && shl_string_list_is(conf->seats, "current");
170 }
171
172 static inline bool kmscon_conf_is_all_seats(struct kmscon_conf_t *conf)
173 {
174         return conf && shl_string_list_is(conf->seats, "all");
175 }
176
177 static inline bool kmscon_conf_is_single_seat(struct kmscon_conf_t *conf)
178 {
179         return conf && !kmscon_conf_is_all_seats(conf) &&
180                shl_string_list_count(conf->seats, true) == 1;
181 }
182
183 #endif /* KMSCON_MAIN_H */