Modify it to adjust Tizen IVI enviroment
[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_DISPLAY_REFRESH,
62         KMSCON_SESSION_ACTIVATE,
63         KMSCON_SESSION_DEACTIVATE,
64         KMSCON_SESSION_UNREGISTER,
65 };
66
67 struct kmscon_session_event {
68         unsigned int type;
69         struct uterm_display *disp;
70 };
71
72 typedef int (*kmscon_session_cb_t) (struct kmscon_session *session,
73                                     struct kmscon_session_event *event,
74                                     void *data);
75
76 int kmscon_seat_new(struct kmscon_seat **out,
77                     struct conf_ctx *main_conf,
78                     struct ev_eloop *eloop,
79                     struct uterm_vt_master *vtm,
80                     unsigned int vt_types,
81                     const char *seatname,
82                     kmscon_seat_cb_t cb,
83                     void *data);
84 void kmscon_seat_free(struct kmscon_seat *seat);
85 void kmscon_seat_startup(struct kmscon_seat *seat);
86
87 int kmscon_seat_add_display(struct kmscon_seat *seat,
88                             struct uterm_display *disp);
89 void kmscon_seat_remove_display(struct kmscon_seat *seat,
90                                 struct uterm_display *disp);
91 void kmscon_seat_refresh_display(struct kmscon_seat *seat,
92                                  struct uterm_display *disp);
93 int kmscon_seat_add_input(struct kmscon_seat *seat, const char *node);
94 void kmscon_seat_remove_input(struct kmscon_seat *seat, const char *node);
95
96 const char *kmscon_seat_get_name(struct kmscon_seat *seat);
97 struct uterm_input *kmscon_seat_get_input(struct kmscon_seat *seat);
98 struct ev_eloop *kmscon_seat_get_eloop(struct kmscon_seat *seat);
99 struct conf_ctx *kmscon_seat_get_conf(struct kmscon_seat *seat);
100
101 void kmscon_seat_schedule(struct kmscon_seat *seat, unsigned int id);
102
103 int kmscon_seat_register_session(struct kmscon_seat *seat,
104                                  struct kmscon_session **out,
105                                  kmscon_session_cb_t cb,
106                                  void *data);
107
108 void kmscon_session_ref(struct kmscon_session *sess);
109 void kmscon_session_unref(struct kmscon_session *sess);
110 void kmscon_session_unregister(struct kmscon_session *sess);
111 bool kmscon_session_is_registered(struct kmscon_session *sess);
112
113 bool kmscon_session_is_active(struct kmscon_session *sess);
114 int kmscon_session_set_foreground(struct kmscon_session *sess);
115 int kmscon_session_set_background(struct kmscon_session *sess);
116 void kmscon_session_schedule(struct kmscon_session *sess);
117
118 void kmscon_session_enable(struct kmscon_session *sess);
119 void kmscon_session_disable(struct kmscon_session *sess);
120 bool kmscon_session_is_enabled(struct kmscon_session *sess);
121
122 void kmscon_session_notify_deactivated(struct kmscon_session *sess);
123
124 #endif /* KMSCON_SEAT_H */