terminal: drop unfinished code

This drops the libsystemd-terminal and systemd-consoled code for various
reasons:

 * It's been sitting there unfinished for over a year now and won't get
   finished any time soon.

 * Since its initial creation, several parts need significant rework: The
   input handling should be replaced with the now commonly used libinput,
   the drm accessors should coordinate the handling of mode-object
   hotplugging (including split connectors) with other DRM users, and the
   internal library users should be converted to sd-device and friends.

 * There is still significant kernel work required before sd-console is
   really useful. This includes, but is not limited to, simpledrm and
   drmlog.

 * The authority daemon is needed before all this code can be used for
   real. And this will definitely take a lot more time to get done as
   no-one else is currently working on this, but me.

 * kdbus maintenance has taken up way more time than I thought and it has
   much higher priority. I don't see me spending much time on the
   terminal code in the near future.

If anyone intends to hack on this, please feel free to contact me. I'll
gladly help you out with any issues. Once kdbus and authorityd are
finished (whenever that will be..) I'll definitely pick this up again. But
until then, lets reduce compile times and maintenance efforts on this code
and drop it for now.
This commit is contained in:
David Herrmann
2015-07-27 20:15:34 +02:00
parent 2d5c8a2756
commit d537694a98
44 changed files with 0 additions and 24559 deletions

7
.gitignore vendored
View File

@@ -66,7 +66,6 @@
/systemd-cgls
/systemd-cgroups-agent
/systemd-cgtop
/systemd-consoled
/systemd-coredump
/systemd-cryptsetup
/systemd-cryptsetup-generator
@@ -76,7 +75,6 @@
/systemd-detect-virt
/systemd-efi-boot-generator
/systemd-escape
/systemd-evcat
/systemd-export
/systemd-firstboot
/systemd-fsck
@@ -102,7 +100,6 @@
/systemd-machine-id-commit
/systemd-machine-id-setup
/systemd-machined
/systemd-modeset
/systemd-modules-load
/systemd-networkd
/systemd-networkd-wait-online
@@ -124,7 +121,6 @@
/systemd-sleep
/systemd-socket-proxyd
/systemd-stdio-bridge
/systemd-subterm
/systemd-sysctl
/systemd-system-update-generator
/systemd-sysusers
@@ -258,15 +254,12 @@
/test-strv
/test-strxcpyx
/test-tables
/test-term-page
/test-term-parser
/test-terminal-util
/test-time
/test-tmpfiles
/test-udev
/test-uid-range
/test-unaligned
/test-unifont
/test-unit-file
/test-unit-name
/test-utf8

View File

@@ -237,7 +237,6 @@ AM_CPPFLAGS = \
-I $(top_srcdir)/src/libsystemd/sd-hwdb \
-I $(top_srcdir)/src/libsystemd/sd-device \
-I $(top_srcdir)/src/libsystemd-network \
-I $(top_srcdir)/src/libsystemd-terminal \
$(OUR_CPPFLAGS)
AM_CFLAGS = $(OUR_CFLAGS)
@@ -3307,145 +3306,6 @@ tests += \
manual_tests += \
test-pppoe
# ------------------------------------------------------------------------------
if ENABLE_TERMINAL
noinst_LTLIBRARIES += \
libsystemd-terminal.la
rootlibexec_PROGRAMS += \
systemd-consoled
noinst_PROGRAMS += \
systemd-evcat \
systemd-modeset \
systemd-subterm
pkgdata_DATA = \
src/libsystemd-terminal/unifont-glyph-array.bin
nodist_userunit_DATA += \
units/user/systemd-consoled.service
USER_DEFAULT_TARGET_WANTS += \
systemd-consoled.service
tests += \
test-term-page \
test-term-parser \
test-unifont
endif
EXTRA_DIST += \
units/user/systemd-consoled.service.in
libsystemd_terminal_la_CFLAGS = \
$(AM_CFLAGS) \
$(TERMINAL_CFLAGS)
libsystemd_terminal_la_SOURCES = \
src/libsystemd-terminal/grdev.h \
src/libsystemd-terminal/grdev-internal.h \
src/libsystemd-terminal/grdev.c \
src/libsystemd-terminal/grdev-drm.c \
src/libsystemd-terminal/idev.h \
src/libsystemd-terminal/idev-internal.h \
src/libsystemd-terminal/idev.c \
src/libsystemd-terminal/idev-evdev.c \
src/libsystemd-terminal/idev-keyboard.c \
src/libsystemd-terminal/sysview.h \
src/libsystemd-terminal/sysview-internal.h \
src/libsystemd-terminal/sysview.c \
src/libsystemd-terminal/term.h \
src/libsystemd-terminal/term-internal.h \
src/libsystemd-terminal/term-charset.c \
src/libsystemd-terminal/term-page.c \
src/libsystemd-terminal/term-parser.c \
src/libsystemd-terminal/term-screen.c \
src/libsystemd-terminal/term-wcwidth.c \
src/libsystemd-terminal/unifont.h \
src/libsystemd-terminal/unifont-def.h \
src/libsystemd-terminal/unifont.c
libsystemd_terminal_la_LIBADD = \
libshared.la \
$(TERMINAL_LIBS)
systemd_consoled_CFLAGS = \
$(AM_CFLAGS) \
$(TERMINAL_CFLAGS)
systemd_consoled_SOURCES = \
src/console/consoled.h \
src/console/consoled.c \
src/console/consoled-display.c \
src/console/consoled-manager.c \
src/console/consoled-session.c \
src/console/consoled-terminal.c \
src/console/consoled-workspace.c
systemd_consoled_LDADD = \
libsystemd-terminal.la \
libshared.la \
$(TERMINAL_LIBS)
systemd_evcat_CFLAGS = \
$(AM_CFLAGS) \
$(TERMINAL_CFLAGS)
systemd_evcat_SOURCES = \
src/libsystemd-terminal/evcat.c
systemd_evcat_LDADD = \
libsystemd-terminal.la \
libshared.la \
$(TERMINAL_LIBS)
systemd_modeset_CFLAGS = \
$(AM_CFLAGS) \
$(TERMINAL_CFLAGS)
systemd_modeset_SOURCES = \
src/libsystemd-terminal/modeset.c
systemd_modeset_LDADD = \
libsystemd-terminal.la \
libshared.la \
$(TERMINAL_LIBS)
systemd_subterm_SOURCES = \
src/libsystemd-terminal/subterm.c
systemd_subterm_LDADD = \
libsystemd-terminal.la \
libshared.la
test_term_page_SOURCES = \
src/libsystemd-terminal/test-term-page.c
test_term_page_LDADD = \
libsystemd-terminal.la \
libshared.la
test_term_parser_SOURCES = \
src/libsystemd-terminal/test-term-parser.c
test_term_parser_LDADD = \
libsystemd-terminal.la \
libshared.la
test_unifont_SOURCES = \
src/libsystemd-terminal/test-unifont.c
test_unifont_LDADD = \
libsystemd-terminal.la \
libshared.la
src/libsystemd-terminal/unifont-glyph-array.bin: tools/compile-unifont.py $(UNIFONT)
$(AM_V_GEN)$(PYTHON) $< <$(UNIFONT) >$@
EXTRA_DIST += \
tools/compile-unifont.py
# ------------------------------------------------------------------------------
include_HEADERS += \
src/libudev/libudev.h

View File

@@ -57,9 +57,6 @@ cd $oldpwd
if [ "x$1" = "xc" ]; then
$topdir/configure CFLAGS='-g -O0 -ftrapv' --enable-compat-libs --enable-kdbus $args
make clean
elif [ "x$1" = "xt" ]; then
$topdir/configure CFLAGS='-g -O0 -ftrapv' --enable-compat-libs --enable-kdbus --enable-terminal $args
make clean
elif [ "x$1" = "xg" ]; then
$topdir/configure CFLAGS='-g -Og -ftrapv' --enable-compat-libs --enable-kdbus $args
make clean

View File

@@ -1170,27 +1170,6 @@ AS_IF([test "x$enable_gnuefi" != "xno"], [
])
AM_CONDITIONAL(HAVE_GNUEFI, [test "x$have_gnuefi" = xyes])
# ------------------------------------------------------------------------------
AC_ARG_WITH(unifont,
AS_HELP_STRING([--with-unifont=PATH],
[Path to unifont.hex]),
[UNIFONT="$withval"],
[UNIFONT="/usr/share/unifont/unifont.hex"])
AC_SUBST(UNIFONT)
have_terminal=no
have_unifont=no
AC_ARG_ENABLE(terminal, AS_HELP_STRING([--enable-terminal], [enable terminal support]))
if test "x$enable_terminal" = "xyes"; then
PKG_CHECK_MODULES([TERMINAL], [ libevdev >= 1.2 xkbcommon >= 0.5 libdrm >= 2.4], [have_terminal=yes])
AC_CHECK_FILE($UNIFONT, [have_unifont=yes])
AS_IF([test "x$have_terminal" != xyes -o "x$have_unifont" != "xyes" -a "x$enable_terminal" = xyes],
[AC_MSG_ERROR([*** terminal support requested but required dependencies not available])],
[test "x$have_terminal" = xyes -a "x$have_unifont" = "xyes"],
[AC_DEFINE(ENABLE_TERMINAL, 1, [Define if terminal support is to be enabled])])
fi
AM_CONDITIONAL(ENABLE_TERMINAL, [test "x$have_terminal" = "xyes" -a "x$have_unifont" = "xyes"])
# ------------------------------------------------------------------------------
have_kdbus=no
AC_ARG_ENABLE(kdbus, AS_HELP_STRING([--disable-kdbus], [do not connect to kdbus by default]))
@@ -1547,7 +1526,6 @@ AC_MSG_RESULT([
dbus: ${have_dbus}
nss-myhostname: ${have_myhostname}
hwdb: ${enable_hwdb}
terminal: ${have_terminal}
kdbus: ${have_kdbus}
Python: ${have_python}
man pages: ${have_manpages}

View File

@@ -1 +0,0 @@
../Makefile

View File

@@ -1,81 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include "consoled.h"
#include "grdev.h"
#include "list.h"
#include "macro.h"
#include "util.h"
int display_new(Display **out, Session *s, grdev_display *display) {
_cleanup_(display_freep) Display *d = NULL;
assert(out);
assert(s);
assert(display);
d = new0(Display, 1);
if (!d)
return -ENOMEM;
d->session = s;
d->grdev = display;
d->width = grdev_display_get_width(display);
d->height = grdev_display_get_height(display);
LIST_PREPEND(displays_by_session, d->session->display_list, d);
grdev_display_enable(display);
*out = d;
d = NULL;
return 0;
}
Display *display_free(Display *d) {
if (!d)
return NULL;
LIST_REMOVE(displays_by_session, d->session->display_list, d);
free(d);
return NULL;
}
void display_refresh(Display *d) {
assert(d);
d->width = grdev_display_get_width(d->grdev);
d->height = grdev_display_get_height(d->grdev);
}
void display_render(Display *d, Workspace *w) {
const grdev_display_target *target;
assert(d);
assert(w);
GRDEV_DISPLAY_FOREACH_TARGET(d->grdev, target) {
if (workspace_draw(w, target))
grdev_display_flip_target(d->grdev, target);
}
}

View File

@@ -1,284 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-login.h"
#include "log.h"
#include "signal-util.h"
#include "util.h"
#include "consoled.h"
#include "idev.h"
#include "grdev.h"
#include "sysview.h"
#include "unifont.h"
int manager_new(Manager **out) {
_cleanup_(manager_freep) Manager *m = NULL;
int r;
assert(out);
m = new0(Manager, 1);
if (!m)
return -ENOMEM;
r = sd_event_default(&m->event);
if (r < 0)
return r;
r = sd_event_set_watchdog(m->event, true);
if (r < 0)
return r;
r = sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGQUIT, SIGINT, SIGWINCH, SIGCHLD, -1);
if (r < 0)
return r;
r = sd_event_add_signal(m->event, NULL, SIGTERM, NULL, NULL);
if (r < 0)
return r;
r = sd_event_add_signal(m->event, NULL, SIGQUIT, NULL, NULL);
if (r < 0)
return r;
r = sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
if (r < 0)
return r;
r = sd_bus_open_system(&m->sysbus);
if (r < 0)
return r;
r = sd_bus_attach_event(m->sysbus, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return r;
r = unifont_new(&m->uf);
if (r < 0)
return r;
r = sysview_context_new(&m->sysview,
SYSVIEW_CONTEXT_SCAN_LOGIND |
SYSVIEW_CONTEXT_SCAN_EVDEV |
SYSVIEW_CONTEXT_SCAN_DRM,
m->event,
m->sysbus,
NULL);
if (r < 0)
return r;
r = grdev_context_new(&m->grdev, m->event, m->sysbus);
if (r < 0)
return r;
r = idev_context_new(&m->idev, m->event, m->sysbus);
if (r < 0)
return r;
*out = m;
m = NULL;
return 0;
}
Manager *manager_free(Manager *m) {
if (!m)
return NULL;
assert(!m->workspace_list);
m->idev = idev_context_unref(m->idev);
m->grdev = grdev_context_unref(m->grdev);
m->sysview = sysview_context_free(m->sysview);
m->uf = unifont_unref(m->uf);
m->sysbus = sd_bus_unref(m->sysbus);
m->event = sd_event_unref(m->event);
free(m);
return NULL;
}
static int manager_sysview_session_filter(Manager *m, sysview_event *event) {
const char *sid = event->session_filter.id;
_cleanup_free_ char *desktop = NULL;
int r;
assert(sid);
r = sd_session_get_desktop(sid, &desktop);
if (r < 0)
return 0;
return streq(desktop, "systemd-console");
}
static int manager_sysview_session_add(Manager *m, sysview_event *event) {
sysview_session *session = event->session_add.session;
Session *s;
int r;
r = sysview_session_take_control(session);
if (r < 0)
return log_error_errno(r, "Cannot request session control on '%s': %m",
sysview_session_get_name(session));
r = session_new(&s, m, session);
if (r < 0) {
log_error_errno(r, "Cannot create session on '%s': %m",
sysview_session_get_name(session));
sysview_session_release_control(session);
return r;
}
sysview_session_set_userdata(session, s);
return 0;
}
static int manager_sysview_session_remove(Manager *m, sysview_event *event) {
sysview_session *session = event->session_remove.session;
Session *s;
s = sysview_session_get_userdata(session);
if (!s)
return 0;
session_free(s);
return 0;
}
static int manager_sysview_session_attach(Manager *m, sysview_event *event) {
sysview_session *session = event->session_attach.session;
sysview_device *device = event->session_attach.device;
Session *s;
s = sysview_session_get_userdata(session);
if (!s)
return 0;
session_add_device(s, device);
return 0;
}
static int manager_sysview_session_detach(Manager *m, sysview_event *event) {
sysview_session *session = event->session_detach.session;
sysview_device *device = event->session_detach.device;
Session *s;
s = sysview_session_get_userdata(session);
if (!s)
return 0;
session_remove_device(s, device);
return 0;
}
static int manager_sysview_session_refresh(Manager *m, sysview_event *event) {
sysview_session *session = event->session_refresh.session;
sysview_device *device = event->session_refresh.device;
struct udev_device *ud = event->session_refresh.ud;
Session *s;
s = sysview_session_get_userdata(session);
if (!s)
return 0;
session_refresh_device(s, device, ud);
return 0;
}
static int manager_sysview_session_control(Manager *m, sysview_event *event) {
sysview_session *session = event->session_control.session;
int error = event->session_control.error;
Session *s;
s = sysview_session_get_userdata(session);
if (!s)
return 0;
if (error < 0) {
log_error_errno(error, "Cannot take session control on '%s': %m",
sysview_session_get_name(session));
session_free(s);
sysview_session_set_userdata(session, NULL);
return error;
}
return 0;
}
static int manager_sysview_fn(sysview_context *sysview, void *userdata, sysview_event *event) {
Manager *m = userdata;
int r;
assert(m);
switch (event->type) {
case SYSVIEW_EVENT_SESSION_FILTER:
r = manager_sysview_session_filter(m, event);
break;
case SYSVIEW_EVENT_SESSION_ADD:
r = manager_sysview_session_add(m, event);
break;
case SYSVIEW_EVENT_SESSION_REMOVE:
r = manager_sysview_session_remove(m, event);
break;
case SYSVIEW_EVENT_SESSION_ATTACH:
r = manager_sysview_session_attach(m, event);
break;
case SYSVIEW_EVENT_SESSION_DETACH:
r = manager_sysview_session_detach(m, event);
break;
case SYSVIEW_EVENT_SESSION_REFRESH:
r = manager_sysview_session_refresh(m, event);
break;
case SYSVIEW_EVENT_SESSION_CONTROL:
r = manager_sysview_session_control(m, event);
break;
default:
r = 0;
break;
}
return r;
}
int manager_run(Manager *m) {
int r;
assert(m);
r = sysview_context_start(m->sysview, manager_sysview_fn, m);
if (r < 0)
return r;
r = sd_event_loop(m->event);
sysview_context_stop(m->sysview);
return r;
}

View File

@@ -1,279 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include "consoled.h"
#include "grdev.h"
#include "idev.h"
#include "list.h"
#include "macro.h"
#include "sd-event.h"
#include "sysview.h"
#include "util.h"
static bool session_feed_keyboard(Session *s, idev_data *data) {
idev_data_keyboard *kdata = &data->keyboard;
if (!data->resync && kdata->value == 1 && kdata->n_syms == 1) {
uint32_t nr;
sysview_seat *seat;
/* handle VT-switch requests */
nr = 0;
switch (kdata->keysyms[0]) {
case XKB_KEY_F1 ... XKB_KEY_F12:
if (IDEV_KBDMATCH(kdata,
IDEV_KBDMOD_CTRL | IDEV_KBDMOD_ALT,
kdata->keysyms[0]))
nr = kdata->keysyms[0] - XKB_KEY_F1 + 1;
break;
case XKB_KEY_XF86Switch_VT_1 ... XKB_KEY_XF86Switch_VT_12:
nr = kdata->keysyms[0] - XKB_KEY_XF86Switch_VT_1 + 1;
break;
}
if (nr != 0) {
seat = sysview_session_get_seat(s->sysview);
sysview_seat_switch_to(seat, nr);
return true;
}
}
return false;
}
static bool session_feed(Session *s, idev_data *data) {
switch (data->type) {
case IDEV_DATA_KEYBOARD:
return session_feed_keyboard(s, data);
default:
return false;
}
}
static int session_idev_fn(idev_session *idev, void *userdata, idev_event *event) {
Session *s = userdata;
switch (event->type) {
case IDEV_EVENT_DEVICE_ADD:
idev_device_enable(event->device_add.device);
break;
case IDEV_EVENT_DEVICE_REMOVE:
idev_device_disable(event->device_remove.device);
break;
case IDEV_EVENT_DEVICE_DATA:
if (!session_feed(s, &event->device_data.data))
workspace_feed(s->active_ws, &event->device_data.data);
break;
}
return 0;
}
static void session_grdev_fn(grdev_session *grdev, void *userdata, grdev_event *event) {
grdev_display *display;
Session *s = userdata;
Display *d;
int r;
switch (event->type) {
case GRDEV_EVENT_DISPLAY_ADD:
display = event->display_add.display;
r = display_new(&d, s, display);
if (r < 0) {
log_error_errno(r, "Cannot create display '%s' on '%s': %m",
grdev_display_get_name(display), sysview_session_get_name(s->sysview));
break;
}
grdev_display_set_userdata(display, d);
workspace_refresh(s->active_ws);
break;
case GRDEV_EVENT_DISPLAY_REMOVE:
display = event->display_remove.display;
d = grdev_display_get_userdata(display);
if (!d)
break;
display_free(d);
workspace_refresh(s->active_ws);
break;
case GRDEV_EVENT_DISPLAY_CHANGE:
display = event->display_remove.display;
d = grdev_display_get_userdata(display);
if (!d)
break;
display_refresh(d);
workspace_refresh(s->active_ws);
break;
case GRDEV_EVENT_DISPLAY_FRAME:
display = event->display_remove.display;
d = grdev_display_get_userdata(display);
if (!d)
break;
session_dirty(s);
break;
}
}
static int session_redraw_fn(sd_event_source *src, void *userdata) {
Session *s = userdata;
Display *d;
LIST_FOREACH(displays_by_session, d, s->display_list)
display_render(d, s->active_ws);
grdev_session_commit(s->grdev);
return 0;
}
int session_new(Session **out, Manager *m, sysview_session *session) {
_cleanup_(session_freep) Session *s = NULL;
int r;
assert(out);
assert(m);
assert(session);
s = new0(Session, 1);
if (!s)
return -ENOMEM;
s->manager = m;
s->sysview = session;
r = grdev_session_new(&s->grdev,
m->grdev,
GRDEV_SESSION_MANAGED,
sysview_session_get_name(session),
session_grdev_fn,
s);
if (r < 0)
return r;
r = idev_session_new(&s->idev,
m->idev,
IDEV_SESSION_MANAGED,
sysview_session_get_name(session),
session_idev_fn,
s);
if (r < 0)
return r;
r = workspace_new(&s->my_ws, m);
if (r < 0)
return r;
s->active_ws = workspace_attach(s->my_ws, s);
r = sd_event_add_defer(m->event, &s->redraw_src, session_redraw_fn, s);
if (r < 0)
return r;
grdev_session_enable(s->grdev);
idev_session_enable(s->idev);
*out = s;
s = NULL;
return 0;
}
Session *session_free(Session *s) {
if (!s)
return NULL;
assert(!s->display_list);
sd_event_source_unref(s->redraw_src);
workspace_detach(s->active_ws, s);
workspace_unref(s->my_ws);
idev_session_free(s->idev);
grdev_session_free(s->grdev);
free(s);
return NULL;
}
void session_dirty(Session *s) {
int r;
assert(s);
r = sd_event_source_set_enabled(s->redraw_src, SD_EVENT_ONESHOT);
if (r < 0)
log_error_errno(r, "Cannot enable redraw-source: %m");
}
void session_add_device(Session *s, sysview_device *device) {
unsigned int type;
assert(s);
assert(device);
type = sysview_device_get_type(device);
switch (type) {
case SYSVIEW_DEVICE_DRM:
grdev_session_add_drm(s->grdev, sysview_device_get_ud(device));
break;
case SYSVIEW_DEVICE_EVDEV:
idev_session_add_evdev(s->idev, sysview_device_get_ud(device));
break;
}
}
void session_remove_device(Session *s, sysview_device *device) {
unsigned int type;
assert(s);
assert(device);
type = sysview_device_get_type(device);
switch (type) {
case SYSVIEW_DEVICE_DRM:
grdev_session_remove_drm(s->grdev, sysview_device_get_ud(device));
break;
case SYSVIEW_DEVICE_EVDEV:
idev_session_remove_evdev(s->idev, sysview_device_get_ud(device));
break;
}
}
void session_refresh_device(Session *s, sysview_device *device, struct udev_device *ud) {
unsigned int type;
assert(s);
assert(device);
type = sysview_device_get_type(device);
switch (type) {
case SYSVIEW_DEVICE_DRM:
grdev_session_hotplug_drm(s->grdev, sysview_device_get_ud(device));
break;
}
}

View File

@@ -1,358 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include "consoled.h"
#include "list.h"
#include "macro.h"
#include "util.h"
static int terminal_write_fn(term_screen *screen, void *userdata, const void *buf, size_t size) {
Terminal *t = userdata;
int r;
if (t->pty) {
r = pty_write(t->pty, buf, size);
if (r < 0)
return log_oom();
}
return 0;
}
static int terminal_pty_fn(Pty *pty, void *userdata, unsigned int event, const void *ptr, size_t size) {
Terminal *t = userdata;
int r;
switch (event) {
case PTY_CHILD:
log_debug("PTY child exited");
t->pty = pty_unref(t->pty);
break;
case PTY_DATA:
r = term_screen_feed_text(t->screen, ptr, size);
if (r < 0)
log_error_errno(r, "Cannot update screen state: %m");
workspace_dirty(t->workspace);
break;
}
return 0;
}
int terminal_new(Terminal **out, Workspace *w) {
_cleanup_(terminal_freep) Terminal *t = NULL;
int r;
assert(w);
t = new0(Terminal, 1);
if (!t)
return -ENOMEM;
t->workspace = w;
LIST_PREPEND(terminals_by_workspace, w->terminal_list, t);
r = term_parser_new(&t->parser, true);
if (r < 0)
return r;
r = term_screen_new(&t->screen, terminal_write_fn, t, NULL, NULL);
if (r < 0)
return r;
r = term_screen_set_answerback(t->screen, "systemd-console");
if (r < 0)
return r;
if (out)
*out = t;
t = NULL;
return 0;
}
Terminal *terminal_free(Terminal *t) {
if (!t)
return NULL;
assert(t->workspace);
if (t->pty) {
(void) pty_signal(t->pty, SIGHUP);
pty_close(t->pty);
pty_unref(t->pty);
}
term_screen_unref(t->screen);
term_parser_free(t->parser);
LIST_REMOVE(terminals_by_workspace, t->workspace->terminal_list, t);
free(t);
return NULL;
}
void terminal_resize(Terminal *t) {
uint32_t width, height, fw, fh;
int r;
assert(t);
width = t->workspace->width;
height = t->workspace->height;
fw = unifont_get_width(t->workspace->manager->uf);
fh = unifont_get_height(t->workspace->manager->uf);
width = (fw > 0) ? width / fw : 0;
height = (fh > 0) ? height / fh : 0;
if (t->pty) {
r = pty_resize(t->pty, width, height);
if (r < 0)
log_error_errno(r, "Cannot resize pty: %m");
}
r = term_screen_resize(t->screen, width, height);
if (r < 0)
log_error_errno(r, "Cannot resize screen: %m");
}
void terminal_run(Terminal *t) {
pid_t pid;
assert(t);
if (t->pty)
return;
pid = pty_fork(&t->pty,
t->workspace->manager->event,
terminal_pty_fn,
t,
term_screen_get_width(t->screen),
term_screen_get_height(t->screen));
if (pid < 0) {
log_error_errno(pid, "Cannot fork PTY: %m");
return;
} else if (pid == 0) {
/* child */
char **argv = (char*[]){
(char*)getenv("SHELL") ? : (char*)_PATH_BSHELL,
NULL
};
setenv("TERM", "xterm-256color", 1);
setenv("COLORTERM", "systemd-console", 1);
execve(argv[0], argv, environ);
log_error_errno(errno, "Cannot exec %s (%d): %m", argv[0], -errno);
_exit(1);
}
}
static void terminal_feed_keyboard(Terminal *t, idev_data *data) {
idev_data_keyboard *kdata = &data->keyboard;
int r;
if (!data->resync && (kdata->value == 1 || kdata->value == 2)) {
assert_cc(TERM_KBDMOD_CNT == (int)IDEV_KBDMOD_CNT);
assert_cc(TERM_KBDMOD_IDX_SHIFT == (int)IDEV_KBDMOD_IDX_SHIFT &&
TERM_KBDMOD_IDX_CTRL == (int)IDEV_KBDMOD_IDX_CTRL &&
TERM_KBDMOD_IDX_ALT == (int)IDEV_KBDMOD_IDX_ALT &&
TERM_KBDMOD_IDX_LINUX == (int)IDEV_KBDMOD_IDX_LINUX &&
TERM_KBDMOD_IDX_CAPS == (int)IDEV_KBDMOD_IDX_CAPS);
r = term_screen_feed_keyboard(t->screen,
kdata->keysyms,
kdata->n_syms,
kdata->ascii,
kdata->codepoints,
kdata->mods);
if (r < 0)
log_error_errno(r, "Cannot feed keyboard data to screen: %m");
}
}
void terminal_feed(Terminal *t, idev_data *data) {
switch (data->type) {
case IDEV_DATA_KEYBOARD:
terminal_feed_keyboard(t, data);
break;
}
}
static void terminal_fill(uint8_t *dst,
uint32_t width,
uint32_t height,
uint32_t stride,
uint32_t value) {
uint32_t i, j, *px;
for (j = 0; j < height; ++j) {
px = (uint32_t*)dst;
for (i = 0; i < width; ++i)
*px++ = value;
dst += stride;
}
}
static void terminal_blend(uint8_t *dst,
uint32_t width,
uint32_t height,
uint32_t dst_stride,
const uint8_t *src,
uint32_t src_stride,
uint32_t fg,
uint32_t bg) {
uint32_t i, j, *px;
for (j = 0; j < height; ++j) {
px = (uint32_t*)dst;
for (i = 0; i < width; ++i) {
if (!src || src[i / 8] & (1 << (7 - i % 8)))
*px = fg;
else
*px = bg;
++px;
}
src += src_stride;
dst += dst_stride;
}
}
typedef struct {
const grdev_display_target *target;
unifont *uf;
uint32_t cell_width;
uint32_t cell_height;
bool dirty;
} TerminalDrawContext;
static int terminal_draw_cell(term_screen *screen,
void *userdata,
unsigned int x,
unsigned int y,
const term_attr *attr,
const uint32_t *ch,
size_t n_ch,
unsigned int ch_width) {
TerminalDrawContext *ctx = userdata;
const grdev_display_target *target = ctx->target;
grdev_fb *fb = target->back;
uint32_t xpos, ypos, width, height;
uint32_t fg, bg;
unifont_glyph g;
uint8_t *dst;
int r;
if (n_ch > 0) {
r = unifont_lookup(ctx->uf, &g, *ch);
if (r < 0)
r = unifont_lookup(ctx->uf, &g, 0xfffd);
if (r < 0)
unifont_fallback(&g);
}
xpos = x * ctx->cell_width;
ypos = y * ctx->cell_height;
if (xpos >= fb->width || ypos >= fb->height)
return 0;
width = MIN(fb->width - xpos, ctx->cell_width * ch_width);
height = MIN(fb->height - ypos, ctx->cell_height);
term_attr_to_argb32(attr, &fg, &bg, NULL);
ctx->dirty = true;
dst = fb->maps[0];
dst += fb->strides[0] * ypos + sizeof(uint32_t) * xpos;
if (n_ch < 1) {
terminal_fill(dst,
width,
height,
fb->strides[0],
bg);
} else {
if (width > g.width)
terminal_fill(dst + sizeof(uint32_t) * g.width,
width - g.width,
height,
fb->strides[0],
bg);
if (height > g.height)
terminal_fill(dst + fb->strides[0] * g.height,
width,
height - g.height,
fb->strides[0],
bg);
terminal_blend(dst,
width,
height,
fb->strides[0],
g.data,
g.stride,
fg,
bg);
}
return 0;
}
bool terminal_draw(Terminal *t, const grdev_display_target *target) {
TerminalDrawContext ctx = { };
uint64_t age;
assert(t);
assert(target);
/* start up terminal on first frame */
terminal_run(t);
ctx.target = target;
ctx.uf = t->workspace->manager->uf;
ctx.cell_width = unifont_get_width(ctx.uf);
ctx.cell_height = unifont_get_height(ctx.uf);
ctx.dirty = false;
if (target->front) {
/* if the frontbuffer is new enough, no reason to redraw */
age = term_screen_get_age(t->screen);
if (age != 0 && age <= target->front->data.u64)
return false;
} else {
/* force flip if no frontbuffer is set, yet */
ctx.dirty = true;
}
term_screen_draw(t->screen, terminal_draw_cell, &ctx, &target->back->data.u64);
return ctx.dirty;
}

View File

@@ -1,167 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include "consoled.h"
#include "grdev.h"
#include "idev.h"
#include "list.h"
#include "macro.h"
#include "util.h"
int workspace_new(Workspace **out, Manager *m) {
_cleanup_(workspace_unrefp) Workspace *w = NULL;
int r;
assert(out);
w = new0(Workspace, 1);
if (!w)
return -ENOMEM;
w->ref = 1;
w->manager = m;
LIST_PREPEND(workspaces_by_manager, m->workspace_list, w);
r = terminal_new(&w->current, w);
if (r < 0)
return r;
*out = w;
w = NULL;
return 0;
}
static void workspace_cleanup(Workspace *w) {
Terminal *t;
assert(w);
assert(w->ref == 0);
assert(w->manager);
assert(!w->session_list);
w->current = NULL;
while ((t = w->terminal_list))
terminal_free(t);
LIST_REMOVE(workspaces_by_manager, w->manager->workspace_list, w);
free(w);
}
Workspace *workspace_ref(Workspace *w) {
assert(w);
++w->ref;
return w;
}
Workspace *workspace_unref(Workspace *w) {
if (!w)
return NULL;
assert(w->ref > 0);
if (--w->ref == 0)
workspace_cleanup(w);
return NULL;
}
Workspace *workspace_attach(Workspace *w, Session *s) {
assert(w);
assert(s);
LIST_PREPEND(sessions_by_workspace, w->session_list, s);
workspace_refresh(w);
return workspace_ref(w);
}
Workspace *workspace_detach(Workspace *w, Session *s) {
assert(w);
assert(s);
assert(s->active_ws == w);
LIST_REMOVE(sessions_by_workspace, w->session_list, s);
workspace_refresh(w);
return workspace_unref(w);
}
void workspace_refresh(Workspace *w) {
uint32_t width, height;
Terminal *t;
Session *s;
Display *d;
assert(w);
width = 0;
height = 0;
/* find out minimum dimension of all attached displays */
LIST_FOREACH(sessions_by_workspace, s, w->session_list) {
LIST_FOREACH(displays_by_session, d, s->display_list) {
assert(d->width > 0 && d->height > 0);
if (width == 0 || d->width < width)
width = d->width;
if (height == 0 || d->height < height)
height = d->height;
}
}
/* either both are zero, or none is zero */
assert(!(!width ^ !height));
/* update terminal-sizes if dimensions changed */
if (w->width != width || w->height != height) {
w->width = width;
w->height = height;
LIST_FOREACH(terminals_by_workspace, t, w->terminal_list)
terminal_resize(t);
workspace_dirty(w);
}
}
void workspace_dirty(Workspace *w) {
Session *s;
assert(w);
LIST_FOREACH(sessions_by_workspace, s, w->session_list)
session_dirty(s);
}
void workspace_feed(Workspace *w, idev_data *data) {
assert(w);
assert(data);
terminal_feed(w->current, data);
}
bool workspace_draw(Workspace *w, const grdev_display_target *target) {
assert(w);
assert(target);
return terminal_draw(w->current, target);
}

View File

@@ -1,66 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <stdlib.h>
#include "sd-daemon.h"
#include "log.h"
#include "signal-util.h"
#include "consoled.h"
int main(int argc, char *argv[]) {
_cleanup_(manager_freep) Manager *m = NULL;
int r;
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
umask(0022);
if (argc != 1) {
log_error("This program takes no arguments.");
r = -EINVAL;
goto out;
}
r = manager_new(&m);
if (r < 0) {
log_error_errno(r, "Could not create manager: %m");
goto out;
}
sd_notify(false,
"READY=1\n"
"STATUS=Processing requests...");
r = manager_run(m);
if (r < 0) {
log_error_errno(r, "Cannot run manager: %m");
goto out;
}
out:
sd_notify(false,
"STATUS=Shutting down...");
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}

View File

@@ -1,164 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#pragma once
/***
This file is part of systemd.
Copyright 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include "grdev.h"
#include "idev.h"
#include "list.h"
#include "macro.h"
#include "pty.h"
#include "sd-bus.h"
#include "sd-event.h"
#include "sysview.h"
#include "term.h"
#include "unifont.h"
typedef struct Manager Manager;
typedef struct Session Session;
typedef struct Display Display;
typedef struct Workspace Workspace;
typedef struct Terminal Terminal;
/*
* Terminals
*/
struct Terminal {
Workspace *workspace;
LIST_FIELDS(Terminal, terminals_by_workspace);
term_utf8 utf8;
term_parser *parser;
term_screen *screen;
Pty *pty;
};
int terminal_new(Terminal **out, Workspace *w);
Terminal *terminal_free(Terminal *t);
DEFINE_TRIVIAL_CLEANUP_FUNC(Terminal*, terminal_free);
void terminal_resize(Terminal *t);
void terminal_run(Terminal *t);
void terminal_feed(Terminal *t, idev_data *data);
bool terminal_draw(Terminal *t, const grdev_display_target *target);
/*
* Workspaces
*/
struct Workspace {
unsigned long ref;
Manager *manager;
LIST_FIELDS(Workspace, workspaces_by_manager);
LIST_HEAD(Terminal, terminal_list);
Terminal *current;
LIST_HEAD(Session, session_list);
uint32_t width;
uint32_t height;
};
int workspace_new(Workspace **out, Manager *m);
Workspace *workspace_ref(Workspace *w);
Workspace *workspace_unref(Workspace *w);
DEFINE_TRIVIAL_CLEANUP_FUNC(Workspace*, workspace_unref);
Workspace *workspace_attach(Workspace *w, Session *s);
Workspace *workspace_detach(Workspace *w, Session *s);
void workspace_refresh(Workspace *w);
void workspace_dirty(Workspace *w);
void workspace_feed(Workspace *w, idev_data *data);
bool workspace_draw(Workspace *w, const grdev_display_target *target);
/*
* Displays
*/
struct Display {
Session *session;
LIST_FIELDS(Display, displays_by_session);
grdev_display *grdev;
uint32_t width;
uint32_t height;
};
int display_new(Display **out, Session *s, grdev_display *grdev);
Display *display_free(Display *d);
DEFINE_TRIVIAL_CLEANUP_FUNC(Display*, display_free);
void display_refresh(Display *d);
void display_render(Display *d, Workspace *w);
/*
* Sessions
*/
struct Session {
Manager *manager;
sysview_session *sysview;
grdev_session *grdev;
idev_session *idev;
LIST_FIELDS(Session, sessions_by_workspace);
Workspace *my_ws;
Workspace *active_ws;
LIST_HEAD(Display, display_list);
sd_event_source *redraw_src;
};
int session_new(Session **out, Manager *m, sysview_session *session);
Session *session_free(Session *s);
DEFINE_TRIVIAL_CLEANUP_FUNC(Session*, session_free);
void session_dirty(Session *s);
void session_add_device(Session *s, sysview_device *device);
void session_remove_device(Session *s, sysview_device *device);
void session_refresh_device(Session *s, sysview_device *device, struct udev_device *ud);
/*
* Managers
*/
struct Manager {
sd_event *event;
sd_bus *sysbus;
unifont *uf;
sysview_context *sysview;
grdev_context *grdev;
idev_context *idev;
LIST_HEAD(Workspace, workspace_list);
};
int manager_new(Manager **out);
Manager *manager_free(Manager *m);
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
int manager_run(Manager *m);

View File

@@ -1 +0,0 @@
/unifont-glyph-array.bin

View File

@@ -1,488 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
/*
* Event Catenation
* The evcat tool catenates input events of all requested devices and prints
* them to standard-output. It's only meant for debugging of input-related
* problems.
*/
#include <errno.h>
#include <getopt.h>
#include <libevdev/libevdev.h>
#include <linux/kd.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <termios.h>
#include <unistd.h>
#include <xkbcommon/xkbcommon.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "sd-login.h"
#include "build.h"
#include "event-util.h"
#include "macro.h"
#include "signal-util.h"
#include "util.h"
#include "idev.h"
#include "sysview.h"
#include "term-internal.h"
typedef struct Evcat Evcat;
struct Evcat {
char *session;
char *seat;
sd_event *event;
sd_bus *bus;
sysview_context *sysview;
idev_context *idev;
idev_session *idev_session;
bool managed : 1;
};
static Evcat *evcat_free(Evcat *e) {
if (!e)
return NULL;
e->idev_session = idev_session_free(e->idev_session);
e->idev = idev_context_unref(e->idev);
e->sysview = sysview_context_free(e->sysview);
e->bus = sd_bus_unref(e->bus);
e->event = sd_event_unref(e->event);
free(e->seat);
free(e->session);
free(e);
tcflush(0, TCIOFLUSH);
return NULL;
}
DEFINE_TRIVIAL_CLEANUP_FUNC(Evcat*, evcat_free);
static bool is_managed(const char *session) {
unsigned int vtnr;
struct stat st;
long mode;
int r;
/* Using logind's Controller API is highly fragile if there is already
* a session controller running. If it is registered as controller
* itself, TakeControl will simply fail. But if its a legacy controller
* that does not use logind's controller API, we must never register
* our own controller. Otherwise, we really mess up the VT. Therefore,
* only run in managed mode if there's no-one else. */
if (geteuid() == 0)
return false;
if (!isatty(1))
return false;
if (!session)
return false;
r = sd_session_get_vt(session, &vtnr);
if (r < 0 || vtnr < 1 || vtnr > 63)
return false;
mode = 0;
r = ioctl(1, KDGETMODE, &mode);
if (r < 0 || mode != KD_TEXT)
return false;
r = fstat(1, &st);
if (r < 0 || minor(st.st_rdev) != vtnr)
return false;
return true;
}
static int evcat_new(Evcat **out) {
_cleanup_(evcat_freep) Evcat *e = NULL;
int r;
assert(out);
e = new0(Evcat, 1);
if (!e)
return log_oom();
r = sd_pid_get_session(getpid(), &e->session);
if (r < 0)
return log_error_errno(r, "Cannot retrieve logind session: %m");
r = sd_session_get_seat(e->session, &e->seat);
if (r < 0)
return log_error_errno(r, "Cannot retrieve seat of logind session: %m");
e->managed = is_managed(e->session);
r = sd_event_default(&e->event);
if (r < 0)
return r;
r = sd_bus_open_system(&e->bus);
if (r < 0)
return r;
r = sd_bus_attach_event(e->bus, e->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return r;
r = sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1);
if (r < 0)
return r;
r = sd_event_add_signal(e->event, NULL, SIGTERM, NULL, NULL);
if (r < 0)
return r;
r = sd_event_add_signal(e->event, NULL, SIGINT, NULL, NULL);
if (r < 0)
return r;
r = sysview_context_new(&e->sysview,
SYSVIEW_CONTEXT_SCAN_LOGIND |
SYSVIEW_CONTEXT_SCAN_EVDEV,
e->event,
e->bus,
NULL);
if (r < 0)
return r;
r = idev_context_new(&e->idev, e->event, e->bus);
if (r < 0)
return r;
*out = e;
e = NULL;
return 0;
}
static void kdata_print(idev_data *data) {
idev_data_keyboard *k = &data->keyboard;
char buf[128];
uint32_t i, c;
int cwidth;
/* Key-press state: UP/DOWN/REPEAT */
printf(" %-6s", k->value == 0 ? "UP" :
k->value == 1 ? "DOWN" :
"REPEAT");
/* Resync state */
printf(" | %-6s", data->resync ? "RESYNC" : "");
/* Keycode that triggered the event */
printf(" | %5u", (unsigned)k->keycode);
/* Well-known name of the keycode */
printf(" | %-20s", libevdev_event_code_get_name(EV_KEY, k->keycode) ? : "<unknown>");
/* Well-known modifiers */
printf(" | %-5s", (k->mods & IDEV_KBDMOD_SHIFT) ? "SHIFT" : "");
printf(" %-4s", (k->mods & IDEV_KBDMOD_CTRL) ? "CTRL" : "");
printf(" %-3s", (k->mods & IDEV_KBDMOD_ALT) ? "ALT" : "");
printf(" %-5s", (k->mods & IDEV_KBDMOD_LINUX) ? "LINUX" : "");
printf(" %-4s", (k->mods & IDEV_KBDMOD_CAPS) ? "CAPS" : "");
/* Consumed modifiers */
printf(" | %-5s", (k->consumed_mods & IDEV_KBDMOD_SHIFT) ? "SHIFT" : "");
printf(" %-4s", (k->consumed_mods & IDEV_KBDMOD_CTRL) ? "CTRL" : "");
printf(" %-3s", (k->consumed_mods & IDEV_KBDMOD_ALT) ? "ALT" : "");
printf(" %-5s", (k->consumed_mods & IDEV_KBDMOD_LINUX) ? "LINUX" : "");
printf(" %-4s", (k->consumed_mods & IDEV_KBDMOD_CAPS) ? "CAPS" : "");
/* Resolved symbols */
printf(" |");
for (i = 0; i < k->n_syms; ++i) {
buf[0] = 0;
xkb_keysym_get_name(k->keysyms[i], buf, sizeof(buf));
if (is_locale_utf8()) {
c = k->codepoints[i];
if (c < 0x110000 && c > 0x20 && (c < 0x7f || c > 0x9f)) {
/* "%4lc" doesn't work well, so hard-code it */
cwidth = mk_wcwidth(c);
while (cwidth++ < 2)
printf(" ");
printf(" '%lc':", (wchar_t)c);
} else {
printf(" ");
}
}
printf(" XKB_KEY_%-30s", buf);
}
printf("\n");
}
static bool kdata_is_exit(idev_data *data) {
idev_data_keyboard *k = &data->keyboard;
if (k->value != 1)
return false;
if (k->n_syms != 1)
return false;
return k->codepoints[0] == 'q';
}
static int evcat_idev_fn(idev_session *session, void *userdata, idev_event *ev) {
Evcat *e = userdata;
switch (ev->type) {
case IDEV_EVENT_DEVICE_ADD:
idev_device_enable(ev->device_add.device);
break;
case IDEV_EVENT_DEVICE_REMOVE:
idev_device_disable(ev->device_remove.device);
break;
case IDEV_EVENT_DEVICE_DATA:
switch (ev->device_data.data.type) {
case IDEV_DATA_KEYBOARD:
if (kdata_is_exit(&ev->device_data.data))
sd_event_exit(e->event, 0);
else
kdata_print(&ev->device_data.data);
break;
}
break;
}
return 0;
}
static int evcat_sysview_fn(sysview_context *c, void *userdata, sysview_event *ev) {
unsigned int flags, type;
Evcat *e = userdata;
sysview_device *d;
const char *name;
int r;
switch (ev->type) {
case SYSVIEW_EVENT_SESSION_FILTER:
if (streq_ptr(e->session, ev->session_filter.id))
return 1;
break;
case SYSVIEW_EVENT_SESSION_ADD:
assert(!e->idev_session);
name = sysview_session_get_name(ev->session_add.session);
flags = 0;
if (e->managed)
flags |= IDEV_SESSION_MANAGED;
r = idev_session_new(&e->idev_session,
e->idev,
flags,
name,
evcat_idev_fn,
e);
if (r < 0)
return log_error_errno(r, "Cannot create idev session: %m");
if (e->managed) {
r = sysview_session_take_control(ev->session_add.session);
if (r < 0)
return log_error_errno(r, "Cannot request session control: %m");
}
idev_session_enable(e->idev_session);
break;
case SYSVIEW_EVENT_SESSION_REMOVE:
idev_session_disable(e->idev_session);
e->idev_session = idev_session_free(e->idev_session);
if (sd_event_get_exit_code(e->event, &r) == -ENODATA)
sd_event_exit(e->event, 0);
break;
case SYSVIEW_EVENT_SESSION_ATTACH:
d = ev->session_attach.device;
type = sysview_device_get_type(d);
if (type == SYSVIEW_DEVICE_EVDEV) {
r = idev_session_add_evdev(e->idev_session, sysview_device_get_ud(d));
if (r < 0)
return log_error_errno(r, "Cannot add evdev device to idev: %m");
}
break;
case SYSVIEW_EVENT_SESSION_DETACH:
d = ev->session_detach.device;
type = sysview_device_get_type(d);
if (type == SYSVIEW_DEVICE_EVDEV) {
r = idev_session_remove_evdev(e->idev_session, sysview_device_get_ud(d));
if (r < 0)
return log_error_errno(r, "Cannot remove evdev device from idev: %m");
}
break;
case SYSVIEW_EVENT_SESSION_CONTROL:
r = ev->session_control.error;
if (r < 0)
return log_error_errno(r, "Cannot acquire session control: %m");
r = ioctl(1, KDSKBMODE, K_UNICODE);
if (r < 0)
return log_error_errno(errno, "Cannot set K_UNICODE on stdout: %m");
r = ioctl(1, KDSETMODE, KD_TEXT);
if (r < 0)
return log_error_errno(errno, "Cannot set KD_TEXT on stdout: %m");
printf("\n");
break;
}
return 0;
}
static int evcat_run(Evcat *e) {
struct termios in_attr, saved_attr;
int r;
assert(e);
if (!e->managed && geteuid() > 0)
log_warning("You run in unmanaged mode without being root. This is likely to produce no output..");
printf("evcat - Read and catenate events from selected input devices\n"
" Running on seat '%s' in user-session '%s'\n"
" Exit by pressing ^C or 'q'\n\n",
e->seat ? : "seat0", e->session ? : "<none>");
r = sysview_context_start(e->sysview, evcat_sysview_fn, e);
if (r < 0)
goto out;
r = tcgetattr(0, &in_attr);
if (r < 0) {
r = -errno;
goto out;
}
saved_attr = in_attr;
in_attr.c_lflag &= ~ECHO;
r = tcsetattr(0, TCSANOW, &in_attr);
if (r < 0) {
r = -errno;
goto out;
}
r = sd_event_loop(e->event);
tcsetattr(0, TCSANOW, &saved_attr);
printf("exiting..\n");
out:
sysview_context_stop(e->sysview);
return r;
}
static int help(void) {
printf("%s [OPTIONS...]\n\n"
"Read and catenate events from selected input devices.\n\n"
" -h --help Show this help\n"
" --version Show package version\n"
, program_invocation_short_name);
return 0;
}
static int parse_argv(int argc, char *argv[]) {
enum {
ARG_VERSION = 0x100,
};
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, ARG_VERSION },
{},
};
int c;
assert(argc >= 0);
assert(argv);
while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
switch (c) {
case 'h':
help();
return 0;
case ARG_VERSION:
puts(PACKAGE_STRING);
puts(SYSTEMD_FEATURES);
return 0;
case '?':
return -EINVAL;
default:
assert_not_reached("Unhandled option");
}
if (argc > optind) {
log_error("Too many arguments");
return -EINVAL;
}
return 1;
}
int main(int argc, char *argv[]) {
_cleanup_(evcat_freep) Evcat *e = NULL;
int r;
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
setlocale(LC_ALL, "");
if (!is_locale_utf8())
log_warning("Locale is not set to UTF-8. Codepoints will not be printed!");
r = parse_argv(argc, argv);
if (r <= 0)
goto finish;
r = evcat_new(&e);
if (r < 0)
goto finish;
r = evcat_run(e);
finish:
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,251 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#pragma once
#include <inttypes.h>
#include <libudev.h>
#include <stdbool.h>
#include <stdlib.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "hashmap.h"
#include "list.h"
#include "util.h"
#include "grdev.h"
typedef struct grdev_tile grdev_tile;
typedef struct grdev_display_cache grdev_display_cache;
typedef struct grdev_pipe_vtable grdev_pipe_vtable;
typedef struct grdev_pipe grdev_pipe;
typedef struct grdev_card_vtable grdev_card_vtable;
typedef struct grdev_card grdev_card;
/*
* DRM cards
*/
bool grdev_is_drm_card(grdev_card *card);
grdev_card *grdev_find_drm_card(grdev_session *session, dev_t devnum);
int grdev_drm_card_new(grdev_card **out, grdev_session *session, struct udev_device *ud);
void grdev_drm_card_hotplug(grdev_card *card, struct udev_device *ud);
/*
* Displays
*/
enum {
GRDEV_TILE_LEAF,
GRDEV_TILE_NODE,
GRDEV_TILE_CNT
};
struct grdev_tile {
LIST_FIELDS(grdev_tile, children_by_node);
grdev_tile *parent;
grdev_display *display;
uint32_t x;
uint32_t y;
unsigned int rotate;
unsigned int flip;
uint32_t cache_w;
uint32_t cache_h;
unsigned int type;
union {
struct {
grdev_pipe *pipe;
} leaf;
struct {
size_t n_children;
LIST_HEAD(grdev_tile, child_list);
} node;
};
};
int grdev_tile_new_leaf(grdev_tile **out, grdev_pipe *pipe);
int grdev_tile_new_node(grdev_tile **out);
grdev_tile *grdev_tile_free(grdev_tile *tile);
DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_tile*, grdev_tile_free);
struct grdev_display {
grdev_session *session;
char *name;
void *userdata;
size_t n_leafs;
grdev_tile *tile;
size_t n_pipes;
size_t max_pipes;
uint32_t width;
uint32_t height;
struct grdev_display_cache {
grdev_pipe *pipe;
grdev_display_target target;
bool incomplete : 1;
} *pipes;
bool enabled : 1;
bool public : 1;
bool modified : 1;
bool framed : 1;
};
grdev_display *grdev_find_display(grdev_session *session, const char *name);
int grdev_display_new(grdev_display **out, grdev_session *session, const char *name);
grdev_display *grdev_display_free(grdev_display *display);
DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_display*, grdev_display_free);
/*
* Pipes
*/
struct grdev_pipe_vtable {
void (*free) (grdev_pipe *pipe);
void (*enable) (grdev_pipe *pipe);
void (*disable) (grdev_pipe *pipe);
grdev_fb *(*target) (grdev_pipe *pipe);
};
struct grdev_pipe {
const grdev_pipe_vtable *vtable;
grdev_card *card;
char *name;
grdev_tile *tile;
grdev_display_cache *cache;
sd_event_source *vsync_src;
uint32_t width;
uint32_t height;
uint32_t vrefresh;
size_t max_fbs;
grdev_fb *front;
grdev_fb *back;
grdev_fb **fbs;
bool enabled : 1;
bool running : 1;
bool flip : 1;
bool flipping : 1;
};
#define GRDEV_PIPE_INIT(_vtable, _card) ((grdev_pipe){ \
.vtable = (_vtable), \
.card = (_card), \
})
grdev_pipe *grdev_find_pipe(grdev_card *card, const char *name);
int grdev_pipe_add(grdev_pipe *pipe, const char *name, size_t n_fbs);
grdev_pipe *grdev_pipe_free(grdev_pipe *pipe);
DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_pipe*, grdev_pipe_free);
void grdev_pipe_ready(grdev_pipe *pipe, bool running);
void grdev_pipe_frame(grdev_pipe *pipe);
void grdev_pipe_schedule(grdev_pipe *pipe, uint64_t frames);
/*
* Cards
*/
struct grdev_card_vtable {
void (*free) (grdev_card *card);
void (*enable) (grdev_card *card);
void (*disable) (grdev_card *card);
void (*commit) (grdev_card *card);
void (*restore) (grdev_card *card);
};
struct grdev_card {
const grdev_card_vtable *vtable;
grdev_session *session;
char *name;
Hashmap *pipe_map;
bool enabled : 1;
bool modified : 1;
};
#define GRDEV_CARD_INIT(_vtable, _session) ((grdev_card){ \
.vtable = (_vtable), \
.session = (_session), \
})
grdev_card *grdev_find_card(grdev_session *session, const char *name);
int grdev_card_add(grdev_card *card, const char *name);
grdev_card *grdev_card_free(grdev_card *card);
DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_card*, grdev_card_free);
/*
* Sessions
*/
struct grdev_session {
grdev_context *context;
char *name;
char *path;
grdev_event_fn event_fn;
void *userdata;
unsigned long n_pins;
Hashmap *card_map;
Hashmap *display_map;
bool custom : 1;
bool managed : 1;
bool enabled : 1;
bool modified : 1;
};
grdev_session *grdev_session_pin(grdev_session *session);
grdev_session *grdev_session_unpin(grdev_session *session);
DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_session*, grdev_session_unpin);
/*
* Contexts
*/
struct grdev_context {
unsigned long ref;
sd_event *event;
sd_bus *sysbus;
Hashmap *session_map;
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,199 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
/*
* Graphics Devices
* The grdev layer provides generic access to graphics devices. The device
* types are hidden in the implementation and exported in a generic way. The
* grdev_session object forms the base layer. It loads, configures and prepares
* any graphics devices associated with that session. Each session is totally
* independent of other sessions and can be controlled separately.
* The target devices on a session are called display. A display always
* corresponds to a real display regardless how many pipes are needed to drive
* that display. That is, an exported display might internally be created out
* of arbitrary combinations of target pipes. However, this is meant as
* implementation detail and API users must never assume details below the
* display-level. That is, a display is the most low-level object exported.
* Therefore, pipe-configuration and any low-level modesetting is hidden from
* the public API. It is provided by the implementation, and it is the
* implementation that decides how pipes are driven.
*
* The API users are free to ignore specific displays or combine them to create
* larger screens. This often requires user-configuration so is dictated by
* policy. The underlying pipe-configuration might be affected by these
* high-level policies, but is never directly controlled by those. That means,
* depending on the displays you use, it might affect how underlying resources
* are assigned. However, users can never directly apply policies to the pipes,
* but only to displays. In case specific hardware needs quirks on the pipe
* level, we support that via hwdb, not via public user configuration.
*
* Right now, displays are limited to rgb32 memory-mapped framebuffers on the
* primary plane. However, the grdev implementation can be easily extended to
* allow more powerful access (including hardware-acceleration for 2D and 3D
* compositing). So far, this wasn't needed so it is not exposed.
*/
#pragma once
#include <libudev.h>
#include <stdbool.h>
#include <stdlib.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "util.h"
typedef struct grdev_fb grdev_fb;
typedef struct grdev_display_target grdev_display_target;
typedef struct grdev_display grdev_display;
typedef struct grdev_event grdev_event;
typedef struct grdev_session grdev_session;
typedef struct grdev_context grdev_context;
enum {
/* clockwise rotation; we treat this is abelian group Z4 with ADD */
GRDEV_ROTATE_0 = 0,
GRDEV_ROTATE_90 = 1,
GRDEV_ROTATE_180 = 2,
GRDEV_ROTATE_270 = 3,
};
enum {
/* flip states; we treat this as abelian group V4 with XOR */
GRDEV_FLIP_NONE = 0x0,
GRDEV_FLIP_HORIZONTAL = 0x1,
GRDEV_FLIP_VERTICAL = 0x2,
};
/*
* Displays
*/
struct grdev_fb {
uint32_t width;
uint32_t height;
uint32_t format;
int32_t strides[4];
void *maps[4];
union {
void *ptr;
uint64_t u64;
} data;
void (*free_fn) (void *ptr);
};
struct grdev_display_target {
uint32_t x;
uint32_t y;
uint32_t width;
uint32_t height;
unsigned int rotate;
unsigned int flip;
grdev_fb *front;
grdev_fb *back;
};
void grdev_display_set_userdata(grdev_display *display, void *userdata);
void *grdev_display_get_userdata(grdev_display *display);
const char *grdev_display_get_name(grdev_display *display);
uint32_t grdev_display_get_width(grdev_display *display);
uint32_t grdev_display_get_height(grdev_display *display);
bool grdev_display_is_enabled(grdev_display *display);
void grdev_display_enable(grdev_display *display);
void grdev_display_disable(grdev_display *display);
const grdev_display_target *grdev_display_next_target(grdev_display *display, const grdev_display_target *prev);
void grdev_display_flip_target(grdev_display *display, const grdev_display_target *target);
#define GRDEV_DISPLAY_FOREACH_TARGET(_display, _t) \
for ((_t) = grdev_display_next_target((_display), NULL); \
(_t); \
(_t) = grdev_display_next_target((_display), (_t)))
/*
* Events
*/
enum {
GRDEV_EVENT_DISPLAY_ADD,
GRDEV_EVENT_DISPLAY_REMOVE,
GRDEV_EVENT_DISPLAY_CHANGE,
GRDEV_EVENT_DISPLAY_FRAME,
};
typedef void (*grdev_event_fn) (grdev_session *session, void *userdata, grdev_event *ev);
struct grdev_event {
unsigned int type;
union {
struct {
grdev_display *display;
} display_add, display_remove, display_change;
struct {
grdev_display *display;
} display_frame;
};
};
/*
* Sessions
*/
enum {
GRDEV_SESSION_CUSTOM = (1 << 0),
GRDEV_SESSION_MANAGED = (1 << 1),
};
int grdev_session_new(grdev_session **out,
grdev_context *context,
unsigned int flags,
const char *name,
grdev_event_fn event_fn,
void *userdata);
grdev_session *grdev_session_free(grdev_session *session);
DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_session*, grdev_session_free);
bool grdev_session_is_enabled(grdev_session *session);
void grdev_session_enable(grdev_session *session);
void grdev_session_disable(grdev_session *session);
void grdev_session_commit(grdev_session *session);
void grdev_session_restore(grdev_session *session);
void grdev_session_add_drm(grdev_session *session, struct udev_device *ud);
void grdev_session_remove_drm(grdev_session *session, struct udev_device *ud);
void grdev_session_hotplug_drm(grdev_session *session, struct udev_device *ud);
/*
* Contexts
*/
int grdev_context_new(grdev_context **out, sd_event *event, sd_bus *sysbus);
grdev_context *grdev_context_ref(grdev_context *context);
grdev_context *grdev_context_unref(grdev_context *context);
DEFINE_TRIVIAL_CLEANUP_FUNC(grdev_context*, grdev_context_unref);

File diff suppressed because it is too large Load Diff

View File

@@ -1,188 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 David Herrmann <dh.herrmann@gmail.com>
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#pragma once
#include <inttypes.h>
#include <libudev.h>
#include <linux/input.h>
#include <stdbool.h>
#include <stdlib.h>
#include <xkbcommon/xkbcommon.h>
#include "sd-bus.h"
#include "sd-event.h"
#include "hashmap.h"
#include "list.h"
#include "util.h"
#include "idev.h"
typedef struct idev_link idev_link;
typedef struct idev_device_vtable idev_device_vtable;
typedef struct idev_element idev_element;
typedef struct idev_element_vtable idev_element_vtable;
/*
* Evdev Elements
*/
bool idev_is_evdev(idev_element *e);
idev_element *idev_find_evdev(idev_session *s, dev_t devnum);
int idev_evdev_new(idev_element **out, idev_session *s, struct udev_device *ud);
/*
* Keyboard Devices
*/
bool idev_is_keyboard(idev_device *d);
idev_device *idev_find_keyboard(idev_session *s, const char *name);
int idev_keyboard_new(idev_device **out, idev_session *s, const char *name);
/*
* Element Links
*/
struct idev_link {
/* element-to-device connection */
LIST_FIELDS(idev_link, links_by_element);
idev_element *element;
/* device-to-element connection */
LIST_FIELDS(idev_link, links_by_device);
idev_device *device;
};
/*
* Devices
*/
struct idev_device_vtable {
void (*free) (idev_device *d);
void (*attach) (idev_device *d, idev_link *l);
void (*detach) (idev_device *d, idev_link *l);
int (*feed) (idev_device *d, idev_data *data);
};
struct idev_device {
const idev_device_vtable *vtable;
idev_session *session;
char *name;
LIST_HEAD(idev_link, links);
bool public : 1;
bool enabled : 1;
};
#define IDEV_DEVICE_INIT(_vtable, _session) ((idev_device){ \
.vtable = (_vtable), \
.session = (_session), \
})
idev_device *idev_find_device(idev_session *s, const char *name);
int idev_device_add(idev_device *d, const char *name);
idev_device *idev_device_free(idev_device *d);
DEFINE_TRIVIAL_CLEANUP_FUNC(idev_device*, idev_device_free);
int idev_device_feed(idev_device *d, idev_data *data);
void idev_device_feedback(idev_device *d, idev_data *data);
/*
* Elements
*/
struct idev_element_vtable {
void (*free) (idev_element *e);
void (*enable) (idev_element *e);
void (*disable) (idev_element *e);
void (*open) (idev_element *e);
void (*close) (idev_element *e);
void (*resume) (idev_element *e, int fd);
void (*pause) (idev_element *e, const char *mode);
void (*feedback) (idev_element *e, idev_data *data);
};
struct idev_element {
const idev_element_vtable *vtable;
idev_session *session;
unsigned long n_open;
char *name;
LIST_HEAD(idev_link, links);
bool enabled : 1;
bool readable : 1;
bool writable : 1;
};
#define IDEV_ELEMENT_INIT(_vtable, _session) ((idev_element){ \
.vtable = (_vtable), \
.session = (_session), \
})
idev_element *idev_find_element(idev_session *s, const char *name);
int idev_element_add(idev_element *e, const char *name);
idev_element *idev_element_free(idev_element *e);
DEFINE_TRIVIAL_CLEANUP_FUNC(idev_element*, idev_element_free);
int idev_element_feed(idev_element *e, idev_data *data);
void idev_element_feedback(idev_element *e, idev_data *data);
/*
* Sessions
*/
struct idev_session {
idev_context *context;
char *name;
char *path;
sd_bus_slot *slot_resume_device;
sd_bus_slot *slot_pause_device;
Hashmap *element_map;
Hashmap *device_map;
idev_event_fn event_fn;
void *userdata;
bool custom : 1;
bool managed : 1;
bool enabled : 1;
};
idev_session *idev_find_session(idev_context *c, const char *name);
int idev_session_raise_device_data(idev_session *s, idev_device *d, idev_data *data);
/*
* Contexts
*/
struct idev_context {
unsigned long ref;
sd_event *event;
sd_bus *sysbus;
Hashmap *session_map;
Hashmap *data_map;
};

Some files were not shown because too many files have changed in this diff Show More