uvtd: vt: implement VT_GETMODE/SETMODE ioctl state-tracking
[platform/upstream/kmscon.git] / src / kmscon_seat.h
1 /*
2  * Seats
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  * Seats
28  * A seat is a single session that is self-hosting and provides all the
29  * interaction for a single logged-in user.
30  */
31
32 #ifndef KMSCON_SEAT_H
33 #define KMSCON_SEAT_H
34
35 #include <stdbool.h>
36 #include <stdlib.h>
37 #include "conf.h"
38 #include "eloop.h"
39 #include "uterm_input.h"
40 #include "uterm_video.h"
41 #include "uterm_vt.h"
42
43 struct kmscon_seat;
44 struct kmscon_session;
45
46 enum kmscon_seat_event {
47         KMSCON_SEAT_WAKE_UP,
48         KMSCON_SEAT_SLEEP,
49         KMSCON_SEAT_BACKGROUND,
50         KMSCON_SEAT_FOREGROUND,
51         KMSCON_SEAT_HUP,
52 };
53
54 typedef int (*kmscon_seat_cb_t) (struct kmscon_seat *seat,
55                                  unsigned int event,
56                                  void *data);
57
58 enum kmscon_session_event_type {
59         KMSCON_SESSION_DISPLAY_NEW,
60         KMSCON_SESSION_DISPLAY_GONE,
61         KMSCON_SESSION_ACTIVATE,
62         KMSCON_SESSION_DEACTIVATE,
63         KMSCON_SESSION_UNREGISTER,
64 };
65
66 struct kmscon_session_event {
67         unsigned int type;
68         struct uterm_display *disp;
69 };
70
71 typedef int (*kmscon_session_cb_t) (struct kmscon_session *session,
72                                     struct kmscon_session_event *event,
73                                     void *data);
74
75 int kmscon_seat_new(struct kmscon_seat **out,
76                     struct conf_ctx *main_conf,
77                     struct ev_eloop *eloop,
78                     struct uterm_vt_master *vtm,
79                     unsigned int vt_types,
80                     const char *seatname,
81                     kmscon_seat_cb_t cb,
82                     void *data);
83 void kmscon_seat_free(struct kmscon_seat *seat);
84 void kmscon_seat_startup(struct kmscon_seat *seat);
85
86 int kmscon_seat_add_display(struct kmscon_seat *seat,
87                             struct uterm_display *disp);
88 void kmscon_seat_remove_display(struct kmscon_seat *seat,
89                                 struct uterm_display *disp);
90 int kmscon_seat_add_input(struct kmscon_seat *seat, const char *node);
91 void kmscon_seat_remove_input(struct kmscon_seat *seat, const char *node);
92
93 const char *kmscon_seat_get_name(struct kmscon_seat *seat);
94 struct uterm_input *kmscon_seat_get_input(struct kmscon_seat *seat);
95 struct ev_eloop *kmscon_seat_get_eloop(struct kmscon_seat *seat);
96 struct conf_ctx *kmscon_seat_get_conf(struct kmscon_seat *seat);
97
98 void kmscon_seat_schedule(struct kmscon_seat *seat, unsigned int id);
99
100 int kmscon_seat_register_session(struct kmscon_seat *seat,
101                                  struct kmscon_session **out,
102                                  kmscon_session_cb_t cb,
103                                  void *data);
104
105 void kmscon_session_ref(struct kmscon_session *sess);
106 void kmscon_session_unref(struct kmscon_session *sess);
107 void kmscon_session_unregister(struct kmscon_session *sess);
108 bool kmscon_session_is_registered(struct kmscon_session *sess);
109
110 bool kmscon_session_is_active(struct kmscon_session *sess);
111 int kmscon_session_set_foreground(struct kmscon_session *sess);
112 int kmscon_session_set_background(struct kmscon_session *sess);
113 void kmscon_session_schedule(struct kmscon_session *sess);
114
115 void kmscon_session_enable(struct kmscon_session *sess);
116 void kmscon_session_disable(struct kmscon_session *sess);
117 bool kmscon_session_is_enabled(struct kmscon_session *sess);
118
119 void kmscon_session_notify_deactivated(struct kmscon_session *sess);
120
121 #endif /* KMSCON_SEAT_H */