uvtd: vt: implement VT_GETMODE/SETMODE ioctl state-tracking
[platform/upstream/kmscon.git] / src / uterm_vt.h
1 /*
2  * uterm - Linux User-Space Terminal VT API
3  *
4  * Copyright (c) 2011-2013 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  * Virtual Terminals
28  * Virtual terminals allow controlling multiple virtual terminals on one real
29  * terminal. It is multi-seat capable and fully asynchronous.
30  */
31
32 #ifndef UTERM_UTERM_VT_H
33 #define UTERM_UTERM_VT_H
34
35 #include <eloop.h>
36 #include <inttypes.h>
37 #include <stdbool.h>
38 #include <stdlib.h>
39 #include <uterm_input.h>
40
41 struct uterm_vt;
42 struct uterm_vt_master;
43
44 enum uterm_vt_action {
45         UTERM_VT_ACTIVATE,
46         UTERM_VT_DEACTIVATE,
47         UTERM_VT_HUP,
48 };
49
50 enum uterm_vt_flags {
51         UTERM_VT_FORCE = 0x01,
52 };
53
54 struct uterm_vt_event {
55         unsigned int action;
56         unsigned int flags;
57         int target;
58 };
59
60 enum uterm_vt_type {
61         UTERM_VT_REAL = 0x01,
62         UTERM_VT_FAKE = 0x02,
63 };
64
65 typedef int (*uterm_vt_cb) (struct uterm_vt *vt, struct uterm_vt_event *ev,
66                             void *data);
67
68 int uterm_vt_master_new(struct uterm_vt_master **out,
69                         struct ev_eloop *eloop);
70 void uterm_vt_master_ref(struct uterm_vt_master *vtm);
71 void uterm_vt_master_unref(struct uterm_vt_master *vtm);
72
73 int uterm_vt_master_activate_all(struct uterm_vt_master *vtm);
74 int uterm_vt_master_deactivate_all(struct uterm_vt_master *vtm);
75
76 int uterm_vt_allocate(struct uterm_vt_master *vt, struct uterm_vt **out,
77                       unsigned int allowed_types,
78                       const char *seat, struct uterm_input *input,
79                       const char *vt_name, uterm_vt_cb cb, void *data);
80 void uterm_vt_deallocate(struct uterm_vt *vt);
81 void uterm_vt_ref(struct uterm_vt *vt);
82 void uterm_vt_unref(struct uterm_vt *vt);
83
84 int uterm_vt_activate(struct uterm_vt *vt);
85 int uterm_vt_deactivate(struct uterm_vt *vt);
86 void uterm_vt_retry(struct uterm_vt *vt);
87 unsigned int uterm_vt_get_type(struct uterm_vt *vt);
88
89 #endif /* UTERM_UTERM_VT_H */