chiark / gitweb /
terminal/subterm: skip setting parent's cursor
[elogind.git] / src / libsystemd-terminal / sysview-internal.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #pragma once
23
24 #include <inttypes.h>
25 #include <libudev.h>
26 #include <stdbool.h>
27 #include <stdlib.h>
28 #include <systemd/sd-bus.h>
29 #include <systemd/sd-event.h>
30 #include "hashmap.h"
31 #include "list.h"
32 #include "macro.h"
33 #include "sysview.h"
34 #include "util.h"
35
36 /*
37  * Devices
38  */
39
40 struct sysview_device {
41         sysview_seat *seat;
42         char *name;
43         unsigned int type;
44
45         union {
46                 struct {
47                         struct udev_device *ud;
48                 } evdev, drm;
49         };
50 };
51
52 sysview_device *sysview_find_device(sysview_context *c, const char *name);
53
54 int sysview_device_new(sysview_device **out, sysview_seat *seat, const char *name);
55 sysview_device *sysview_device_free(sysview_device *device);
56
57 DEFINE_TRIVIAL_CLEANUP_FUNC(sysview_device*, sysview_device_free);
58
59 /*
60  * Sessions
61  */
62
63 struct sysview_session {
64         sysview_seat *seat;
65         char *name;
66         char *path;
67         void *userdata;
68
69         sd_bus_slot *slot_take_control;
70
71         bool custom : 1;
72         bool public : 1;
73         bool wants_control : 1;
74         bool has_control : 1;
75 };
76
77 sysview_session *sysview_find_session(sysview_context *c, const char *name);
78
79 int sysview_session_new(sysview_session **out, sysview_seat *seat, const char *name);
80 sysview_session *sysview_session_free(sysview_session *session);
81
82 DEFINE_TRIVIAL_CLEANUP_FUNC(sysview_session*, sysview_session_free);
83
84 /*
85  * Seats
86  */
87
88 struct sysview_seat {
89         sysview_context *context;
90         char *name;
91         char *path;
92
93         Hashmap *session_map;
94         Hashmap *device_map;
95
96         bool scanned : 1;
97         bool public : 1;
98 };
99
100 sysview_seat *sysview_find_seat(sysview_context *c, const char *name);
101
102 int sysview_seat_new(sysview_seat **out, sysview_context *c, const char *name);
103 sysview_seat *sysview_seat_free(sysview_seat *seat);
104
105 DEFINE_TRIVIAL_CLEANUP_FUNC(sysview_seat*, sysview_seat_free);
106
107 /*
108  * Contexts
109  */
110
111 struct sysview_context {
112         sd_event *event;
113         sd_bus *sysbus;
114         struct udev *ud;
115         uint64_t custom_sid;
116
117         Hashmap *seat_map;
118         Hashmap *session_map;
119         Hashmap *device_map;
120
121         sd_event_source *scan_src;
122         sysview_event_fn event_fn;
123         void *userdata;
124
125         /* udev scanner */
126         struct udev_monitor *ud_monitor;
127         sd_event_source *ud_monitor_src;
128
129         /* logind scanner */
130         sd_bus_slot *ld_slot_manager_signal;
131         sd_bus_slot *ld_slot_list_seats;
132         sd_bus_slot *ld_slot_list_sessions;
133
134         bool scan_logind : 1;
135         bool scan_evdev : 1;
136         bool scan_drm : 1;
137         bool running : 1;
138         bool scanned : 1;
139         bool rescan : 1;
140 };
141
142 int sysview_context_rescan(sysview_context *c);