platform/upstream/kmscon.git
11 years agoshl: misc: add shl_ends_with() helper
David Herrmann [Sun, 30 Dec 2012 18:41:08 +0000 (19:41 +0100)]
shl: misc: add shl_ends_with() helper

This helper checks whether a string has the given suffix.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoshl: misc: add shl_dirent() helper
David Herrmann [Sun, 30 Dec 2012 18:40:04 +0000 (19:40 +0100)]
shl: misc: add shl_dirent() helper

"struct dirent" has always been a mess. As its size may differ between
systems, we need to dynamically allocate it. This helper does that for us.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: use new shl-registry objects
David Herrmann [Sun, 30 Dec 2012 15:21:27 +0000 (16:21 +0100)]
text: use new shl-registry objects

Instead of implementing our own thread-safe backend-storage, we now use
the generic shl-registry object.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: font: use new shl-registry objects
David Herrmann [Sun, 30 Dec 2012 15:20:51 +0000 (16:20 +0100)]
text: font: use new shl-registry objects

Instead of implementing a thread-safe backend-system we can now use the
new shl-registry storage module.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoshl: add new register helper
David Herrmann [Sun, 30 Dec 2012 15:18:25 +0000 (16:18 +0100)]
shl: add new register helper

The shl-register module is used to create registries of named-objects. The
main purpose for it will be for module-systems were we have different
backends implementing an interface. The registry can then be used to find
a specific module (or the default module).

No sophisticated filter/search mechanism is used as this cannot be done
efficiently in a generic way.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoCOPYING: add missing contributor's names
David Herrmann [Sun, 30 Dec 2012 11:50:47 +0000 (12:50 +0100)]
COPYING: add missing contributor's names

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agodocs: fix systemd-unit name typo
Hoàng Đức Hiếu [Sat, 29 Dec 2012 14:05:57 +0000 (21:05 +0700)]
docs: fix systemd-unit name typo

We forgot to rename the templates from kmscon to kmsconvt in the comments.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: gltex: fix y-inversion with new gbm-surfaces
David Herrmann [Fri, 21 Dec 2012 14:30:19 +0000 (15:30 +0100)]
text: gltex: fix y-inversion with new gbm-surfaces

The standard OpenGL surfaces are y-inverted (which we didn't implement
correctly previously when using our own gbm-surfaces). Therefore, we need
to flip the y-coordinates now as we use correct GL surfaces with the new
drm-uterm backend.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: video: drm: use gbm surfaces
David Herrmann [Fri, 21 Dec 2012 14:15:16 +0000 (15:15 +0100)]
uterm: video: drm: use gbm surfaces

Until now we always created our buffers via gbm_bo_create() and used
surfaceless EGL contexts so we can schedule buffer-flips manually.
However, recent gbm and EGL mesa releases include gbm-surfaces that allow
us to ignore all this an let EGL manage the buffers.

This introduces some problems as we are no longer under control of the
buffers so we cannot know which buffer is active. That means, applications
that use the uterm-drm devices must redraw the screen on each frame.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agodocs: fix default font-size=12 documentation
David Herrmann [Fri, 21 Dec 2012 13:13:00 +0000 (14:13 +0100)]
docs: fix default font-size=12 documentation

We used font-size=15 in the past but changed it long ago. However, the
documentation still used 15 so fix this now.

Reported-by: James Buren <ryu0@ymail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agodocs: add kmsconvt@.service systemd template
David Herrmann [Mon, 17 Dec 2012 12:25:52 +0000 (13:25 +0100)]
docs: add kmsconvt@.service systemd template

This new template can be used as replacement for getty@.service. It has
the same semantics and can be used as drop-in replacement. It even uses
getty@.service as fallback if kmscon fails.
See the comments in the files for more information.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: use COLORTERM=kmscon as default
David Herrmann [Wed, 12 Dec 2012 20:29:23 +0000 (21:29 +0100)]
terminal: use COLORTERM=kmscon as default

We now set COLORTERM to "kmscon" so applications can identify their
controlling terminal. Note that COLORTERM is not used for terminfo/termcap
detection (unlike TERM).

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: use /bin/login -p as default login program
David Herrmann [Wed, 12 Dec 2012 20:24:51 +0000 (21:24 +0100)]
kmscon: use /bin/login -p as default login program

We must pass "-p" to make "login" preserve the environment. We make sure
the environment is correctly reset before calling it so it is safe.
Furthermore, this allows us to pass additional environment variables to
the child without having /bin/login reset it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: add --reset-env option
David Herrmann [Wed, 12 Dec 2012 20:24:15 +0000 (21:24 +0100)]
kmscon: add --reset-env option

This option controls whether we reset the environment before spawning the
PTY child.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: add env_reset property
David Herrmann [Wed, 12 Dec 2012 20:20:45 +0000 (21:20 +0100)]
pty: add env_reset property

This property controls whether the environment should be reset before
spawning the child process. Defaults to "no" and affects whether "-p" is
passed as default argument to /bin/login.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: add "colorterm" property
David Herrmann [Wed, 12 Dec 2012 19:12:21 +0000 (20:12 +0100)]
pty: add "colorterm" property

The colorterm property is used (if set) as COLORTERM environment variable.
Note that this variable (despite the name) is not used with
terminfo/termcap. Instead, it's solely used to identify the running
terminal.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agobuild: check for udev >=172
David Herrmann [Mon, 10 Dec 2012 15:21:32 +0000 (16:21 +0100)]
build: check for udev >=172

We need udev_device_has_tag() which was introduced in version 172.
Document that in README file.

Reported-by: Manuel Rüger <mrueg@rueg.eu>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotsm: screen: add support for multi-cell characters
David Herrmann [Mon, 10 Dec 2012 15:09:28 +0000 (16:09 +0100)]
tsm: screen: add support for multi-cell characters

The wcwidth() POSIX helper returns the number of cells that a character
occupies. This is normally 1, however, if it is 0 we simply discard this
input (this should never happen as all characters that wcwidth() returns 0
for should already be handled by the VTE layer).
But if it is >1, we write the character in the first cell, set the width
correctly and mark all following characters as width=0.

Everything else is left unchanged, that means, the running application has
to be aware of wcwidth() and correctly send two backspaces to clear a
width=2 character and so on.

This behavior almost exactly matches the xterm behavior. There are some
corner cases like erasing only one part of a multi-cell character etc.
that might differ. However, these are non-standard cases that no
application should never rely on.
Anyway, if we spot any of these differences between xterm and kmscon, we
should fix kmscon to behave like xterm does.

Thanks to Shixin for looking this up in other emulators.

Reported-by: Shixin Zeng
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: add render-support for multi-cell glyphs
David Herrmann [Mon, 10 Dec 2012 15:00:08 +0000 (16:00 +0100)]
text: add render-support for multi-cell glyphs

Multi-cell glyphs are glyphs that span across multiple horizontal cells.
The font renderers already support this. This patch fixes the console
renderers to take advantage of this.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: font: draw multi-cell characters correctly
David Herrmann [Mon, 10 Dec 2012 14:40:48 +0000 (15:40 +0100)]
text: font: draw multi-cell characters correctly

Instead of clipping every character to a one-cell boundary, we now render
multi-cell characters correctly into multiple cells.

This does not adjust the console-renderers but only the font renderers to
provide the correct glyphs.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agodocs: fix typos in unicode-test.txt
David Herrmann [Mon, 10 Dec 2012 14:36:28 +0000 (15:36 +0100)]
docs: fix typos in unicode-test.txt

Two simple obvious typos.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotsm: unicode: add wcwidth() implementation
David Herrmann [Mon, 10 Dec 2012 14:31:47 +0000 (15:31 +0100)]
tsm: unicode: add wcwidth() implementation

wcwidth() is a POSIX function that returns the number of cells that a
wide-character occupies. The glibc function cannot be used as it depends
on the locale and we need _always_ UTF8 no matter what the locale is.

This implementation is provided by Markus Kuhn and is equivalent to
xterm's behavior.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotsm: unicode: fix header-protection namespace
David Herrmann [Mon, 10 Dec 2012 14:23:10 +0000 (15:23 +0100)]
tsm: unicode: fix header-protection namespace

TSM is no longer part of main-kmscon libraries so move macro-names to
TSM_* prefix.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouxkb: print warning if LED update fails
David Herrmann [Sun, 9 Dec 2012 21:06:51 +0000 (22:06 +0100)]
uxkb: print warning if LED update fails

If we cannot write LED states to an input device, we should print proper
warnings instead of ignoring it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoRelease kmscon-6
David Herrmann [Sun, 9 Dec 2012 20:55:32 +0000 (21:55 +0100)]
Release kmscon-6

This release contains a lot of fixes all over the place and introduces
many new features. See ./NEWS for a list of new features.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoREADME: update readme-file
David Herrmann [Sun, 9 Dec 2012 19:49:28 +0000 (20:49 +0100)]
README: update readme-file

We updated configure.ac several times and need to update the README with
the newest command-line options.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoNEWS: add further kmscon-6 news entries
David Herrmann [Sun, 9 Dec 2012 19:11:14 +0000 (20:11 +0100)]
NEWS: add further kmscon-6 news entries

We added some more features in the recent weeks so add them. Most of it
were bugfixes, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoCOPYING: add all contributors
David Herrmann [Sun, 9 Dec 2012 18:53:27 +0000 (19:53 +0100)]
COPYING: add all contributors

Add name of all contributors to COPYING.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agobuild: add systemd service files to EXTRA_DIST
David Herrmann [Sun, 9 Dec 2012 18:52:35 +0000 (19:52 +0100)]
build: add systemd service files to EXTRA_DIST

These service files aren't installed, yet but they work so distribute
them.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agobuild: add manpage-XML files to EXTRA_DIST
David Herrmann [Sun, 9 Dec 2012 18:51:51 +0000 (19:51 +0100)]
build: add manpage-XML files to EXTRA_DIST

We need these XML files to build the man-pages so add them to EXTRA_DIST.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agobuild: add kmscon_cdev.h to source files
David Herrmann [Sun, 9 Dec 2012 18:51:22 +0000 (19:51 +0100)]
build: add kmscon_cdev.h to source files

This is needed to get "make distcheck" working again.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoAdd getty@.service replacement
David Herrmann [Sun, 9 Dec 2012 17:40:26 +0000 (18:40 +0100)]
Add getty@.service replacement

This unit file is a new replacement for standard systemd-getty files.
Installed into /etc/systemd/system it replaces the standard systemd unit
and spawns kmscon instead of agetty on virtual terminals.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: add --seats=current option
David Herrmann [Sun, 9 Dec 2012 17:34:26 +0000 (18:34 +0100)]
kmscon: add --seats=current option

This option uses XDG_SEAT to determine the current seat. If this is NULL,
we fall back to "seat0".

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: use /bin/login by default
David Herrmann [Sun, 9 Dec 2012 17:33:03 +0000 (18:33 +0100)]
pty: use /bin/login by default

kmscon does always pass a proper argv array so the default is never used.
However, for security reasons we shouldn't hardcode /bin/login. If some
other program uses the pty layer and forgets to pass in a suitable argv
all the time, they mind end up with opening a root shell.

Hence, use /bin/login as default.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agobuild: add more verbose recursive error-messages to configure.ac
David Herrmann [Sun, 9 Dec 2012 16:45:50 +0000 (17:45 +0100)]
build: add more verbose recursive error-messages to configure.ac

Our dependency checker should recursively report missing dependencies.
Otherwise, the user doesn't really know what is missing.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agobuild: add AC_PROG_SED to configure.ac
David Herrmann [Sun, 9 Dec 2012 16:45:20 +0000 (17:45 +0100)]
build: add AC_PROG_SED to configure.ac

We need SED for man-page generation so explicitly look for it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: remove compositor support
David Herrmann [Sun, 9 Dec 2012 14:55:26 +0000 (15:55 +0100)]
kmscon: remove compositor support

The wayland compositor support was some research project that turned out
to not work that well. The main problem is that the DRM planes support
cannot be easily forwarded to a child. Sub-surface support might change
that but until then we remove compositor support.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: always activate fake-VTs during startup
David Herrmann [Sun, 9 Dec 2012 13:19:17 +0000 (14:19 +0100)]
seat: always activate fake-VTs during startup

Instead of relying on --switchvt, we should always activate fake-VTs
during startup. Otherwise, we might end up with dead seats as there is no
way to wake up kmscon later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: remove broken vt_eloop concept
David Herrmann [Sun, 9 Dec 2012 13:14:41 +0000 (14:14 +0100)]
kmscon: remove broken vt_eloop concept

We tried to avoid running unused code during shutdown by moving VT
handling into a separate eloop and run it exclusively. However, with
delayed VT switching, we need to run other event-handlers to make the VT
switch work. Therefore, run all of this during shutdown and remove the
vt_eloop event-loop.

This means that we might create new seats, displays, etc. during shutdown.
This is valid and doesn't harm kmscon, but we want to avoid doing stuff
that is undone few miliseconds later. Therefore, we set a "exiting" flag
and check that before initiating most of the big handlers.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: start hotplugged seats if --switchvt is given
David Herrmann [Sun, 9 Dec 2012 12:50:38 +0000 (13:50 +0100)]
seat: start hotplugged seats if --switchvt is given

We currently only start seats (switch to their VT) during startup but we
should also do that for hotplugged seats. Therefore, move that logic into
kmscon_seat and perform the startup after the seat is fully set up.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: remove unused 'out' arguments
David Herrmann [Sun, 9 Dec 2012 12:44:52 +0000 (13:44 +0100)]
kmscon: remove unused 'out' arguments

We don't use the newly created objects so no need to return them.
Furthermore, we want the functions to already perform actions on the
objects so there is no guarantee the objects are still alive after
function return. Thus, simply return nothing.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: move video-device uterm-monitor handling
David Herrmann [Sun, 9 Dec 2012 12:41:28 +0000 (13:41 +0100)]
kmscon: move video-device uterm-monitor handling

Same as previous commit: Move uterm-monitor device-data handling into the
real device create/destroy functions to allow dynamic device removal.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: set uterm-seat data in seat-creation
David Herrmann [Sun, 9 Dec 2012 12:37:39 +0000 (13:37 +0100)]
kmscon: set uterm-seat data in seat-creation

If we want to be able to destroy seats from anywhere, not just
uterm-monitor callbacks, we need to be able to reset the monitor-event
seat-data so we no longer access the seat memory.
Hence, move the seat-data set/reset logic into the actual seat
creation/destroy functions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: pass allowed VTs from caller
David Herrmann [Sun, 9 Dec 2012 12:26:45 +0000 (13:26 +0100)]
seat: pass allowed VTs from caller

We should handle everything --listen related in kmscon_main so pass in the
allowed-VTs mask from the caller.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoAdd manpage infrastructure and kmscon.1 manpage
David Herrmann [Sun, 9 Dec 2012 12:18:56 +0000 (13:18 +0100)]
Add manpage infrastructure and kmscon.1 manpage

Add a very basic man-page infrastructure so we can easily add new
docbook-style manpages.

Also add kmscon.1 man-page with a basic overview.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: fix compilation of builds where fbdev is the only output
James Buren [Thu, 6 Dec 2012 20:31:17 +0000 (14:31 -0600)]
uterm: fix compilation of builds where fbdev is the only output

Declare helpers as "static inline" as they might get included but not
used.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: change TODO item to check for CAP_KILL
David Herrmann [Thu, 6 Dec 2012 14:21:23 +0000 (15:21 +0100)]
cdev: change TODO item to check for CAP_KILL

CAP_KILL will be documented in kmscon manuals, but we should actually
check for the capability during startup.

However, this requires linking with libcap or libcap-ng and we currently
want to avoid that for such a simple task.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: ignore SIGPIPE
David Herrmann [Thu, 6 Dec 2012 13:49:56 +0000 (14:49 +0100)]
kmscon: ignore SIGPIPE

Ignore SIGPIPE globally. We handle HUP correctly everywhere and this
signal is just annoying.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: do not hardcode TTY major
David Herrmann [Thu, 6 Dec 2012 13:45:52 +0000 (14:45 +0100)]
cdev: do not hardcode TTY major

Use TTY_MAJOR instead of hardcoding the literal 4.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: use current VT if it is unused
David Herrmann [Thu, 6 Dec 2012 13:44:14 +0000 (14:44 +0100)]
uterm: vt: use current VT if it is unused

If we autoselect a VT and the current VT is unused, use it. This is
similar to the behavior of Weston and X-Server.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: run only on VT-less seats in listen-mode
David Herrmann [Thu, 6 Dec 2012 13:18:57 +0000 (14:18 +0100)]
kmscon: run only on VT-less seats in listen-mode

If we run in listen mode, we are supposed to take over a seat. If a seat
supports VTs (like kernel VTs or kmscon cdev fake VTs) we assume that
there is some manager for these VTs (the one who created them). Therefore,
there is no need to run kmscon in listen mode on these seats. Instead, you
should run kmscon in default mode on these seats.

We enforce this limitation because if the VT-master on those seats dies
and causes a HUP, they have no way to notify us when they startup again.
Therefore, this kind of setup is broken. Furthermore, no-one would every
want such setups.

Instead use the startup mechanism of the VT/seat-manager to start kmscon
in default mode on those seats.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: prevent --no-listen in combination with --cdev-session
David Herrmann [Thu, 6 Dec 2012 13:03:54 +0000 (14:03 +0100)]
kmscon: prevent --no-listen in combination with --cdev-session

cdev sessions should only be used in listen-mode to avoid stacking cdev
sessions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: introduce new --listen mode
David Herrmann [Thu, 6 Dec 2012 12:55:00 +0000 (13:55 +0100)]
kmscon: introduce new --listen mode

Instead of configuring everything for every kind of situation, we now
split kmscon into two modes: default-mode and listen-mode

In default-mode we run on the given seats once until we encounter a HUP or
until we are closed. It's a perfect replacement for agetty.

In listen-mode, we run only on non-VT seats and provide the full kmscon
functionality. We run as system daemon and wait for new seats and close
seats if they are destroyed. We simply provide a full system-console on
all seats.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: replace gpu selection modes with new --gpu option
David Herrmann [Thu, 6 Dec 2012 10:36:46 +0000 (11:36 +0100)]
kmscon: replace gpu selection modes with new --gpu option

Instead of using one option for each selection mode, we now provide a new
option --gpus. It takes as argument the selection mode to use.

We also remove the --video-devices option as it doesn't fit into the big
picture. Instead, we should provide a blacklist and users would then use
--gpu=all --blacklist-video=<blacklist> instead.

However, blacklisting is also required for input devices and until we
figure it out, we will provide no blacklisting at all.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoMove .pc files to ./docs/pc/
David Herrmann [Wed, 5 Dec 2012 17:25:05 +0000 (18:25 +0100)]
Move .pc files to ./docs/pc/

We want only C-source files in ./src and the documents ./docs directory is
meant to contain any other sources.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: fix opening new VTs
David Herrmann [Sun, 2 Dec 2012 22:27:00 +0000 (23:27 +0100)]
uterm: vt: fix opening new VTs

If no VT name is explicitly given, we need to use VT_OPENQRY to find one.
This used to work until we switched to supporting fake-VTs. Fix this again
to work like it used to.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: fix rescheduling sessions if none is active
David Herrmann [Sun, 2 Dec 2012 14:24:13 +0000 (15:24 +0100)]
seat: fix rescheduling sessions if none is active

If no session is active, we must not choose the scheduled session as
start-place. Otherwise, we will not schedule any session because the
start-session isn't used in the iteration.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: use the new child-reaper sources
David Herrmann [Sun, 2 Dec 2012 14:08:07 +0000 (15:08 +0100)]
pty: use the new child-reaper sources

Instead of registering for SIGCHLD we should use the child-reaper sources
to avoid nasty race-conditions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoeloop: add child-reaper event sources
David Herrmann [Sun, 2 Dec 2012 14:06:00 +0000 (15:06 +0100)]
eloop: add child-reaper event sources

If multiple childs die simultaneously, only a single SIGCHLD is queued.
Only after our process got scheduled and we unqueued the SIGCHLD, a next
signal can be queued. Therefore, using SIGCHLD as indicator that a
specific child died does not work reliably.

Instead, we must use waitpid() to wait for childs. Hence, we introduce a
new event-source which does that. It reports the PID/status combination
for each child to the registered callbacks.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: use "opened" logic
David Herrmann [Sun, 2 Dec 2012 13:59:12 +0000 (14:59 +0100)]
terminal: use "opened" logic

We already keep the open state as "opened" so we should use it instead of
always pushing the work down to the pty layer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoeloop: fix memory loop when signal registration fails
David Herrmann [Sun, 2 Dec 2012 13:57:43 +0000 (14:57 +0100)]
eloop: fix memory loop when signal registration fails

If the signal-registration fails, we need to destroy it again. Otherwise,
it will keep a reference to the current eloop-object and hence it will
never get freed.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoshl: hook: allow callbacks to destroy the hook
David Herrmann [Sun, 2 Dec 2012 12:56:31 +0000 (13:56 +0100)]
shl: hook: allow callbacks to destroy the hook

If we currently dispatch a callback and they unregister themself and then
destroy the hook, we currently do not free the hook as we would free
memory that is used in the callstack.
However, it is a valid use-case for hook-callbacks to destroy the hook.
Therefore, we set a "dead" flag and destroy the hook after all callbacks
are done.

This fixes some memory-leaks inside the shared-signal callbacks of eloop.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: simplify pty_close()
David Herrmann [Sun, 2 Dec 2012 12:42:15 +0000 (13:42 +0100)]
pty: simplify pty_close()

The old logic is no longer needed as we use edge-triggered fd notification
now. Therefore, simplify the helpers to make them more readable.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: gltex: free atlas during destruction
David Herrmann [Sun, 2 Dec 2012 12:40:53 +0000 (13:40 +0100)]
text: gltex: free atlas during destruction

If we remove an atlas, we have to correctly free its memory. Otherwise, we
will loose the memory.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: free seat argument on destruction
David Herrmann [Sun, 2 Dec 2012 12:40:16 +0000 (13:40 +0100)]
pty: free seat argument on destruction

We didn't correctly free this parameter even though we dup'ed it earlier.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: unref session after unregistration
David Herrmann [Sun, 2 Dec 2012 12:39:00 +0000 (13:39 +0100)]
seat: unref session after unregistration

Session registration does not provide a reference to the caller. Instead,
the seat itself owns the reference. Hence, we must clear this reference
during unregistration, otherwise we will never free the session structure.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: forward HUP to caller
David Herrmann [Sun, 2 Dec 2012 11:42:35 +0000 (12:42 +0100)]
seat: forward HUP to caller

We now forward VT_HUP to the caller so they can react on it. Default
behavior is to shutdown this seat. In single-seat mode we also close the
application.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: protect kmscon_seat_remove_display() correctly
David Herrmann [Sun, 2 Dec 2012 11:42:07 +0000 (12:42 +0100)]
seat: protect kmscon_seat_remove_display() correctly

We have to check for NULL pointers like all the other public entries do.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconf: improve --vt warning by allowing --seats=,all
David Herrmann [Sun, 2 Dec 2012 11:29:18 +0000 (12:29 +0100)]
conf: improve --vt warning by allowing --seats=,all

If a seat is called "all" and we want to use it as single seat, we
currently have to pass "--seats=all," or "--seats=,all" etc. so it is not
detected as --seats=all.
However, our warning when --vt is used with it does not respect this.
Improve this warning to detect this case and correctly ignore it then.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoshl: misc: add shl_string_list_count() helper
David Herrmann [Sun, 2 Dec 2012 11:28:48 +0000 (12:28 +0100)]
shl: misc: add shl_string_list_count() helper

This helper counts the entries in a string-list with an option to ignore
empty elements.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: schedule dummy session if no other session is available
David Herrmann [Sun, 2 Dec 2012 11:07:06 +0000 (12:07 +0100)]
seat: schedule dummy session if no other session is available

In special situations (like forcing deactivation of a background session)
we might end up with no real registered session and no current session. In
these situations, we should allow the session-scheduler to schedule dummy
sessions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: allow asynchronous command scheduling
David Herrmann [Sun, 2 Dec 2012 11:05:18 +0000 (12:05 +0100)]
seat: allow asynchronous command scheduling

When an asynchronous session-deactivation is finished, we need to know
which task to do now. As we cannot let the caller decide, because we are
asynchronous, we have to remember the task.

Three tasks are defined now but this can be extended. We reset the task
after the current session got deactivated. This guarantees that we never
have pending schedules but always return to a sane default even if we
missed a notification.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: handle HUP on controlling TTY
David Herrmann [Sun, 2 Dec 2012 11:02:06 +0000 (12:02 +0100)]
uterm: vt: handle HUP on controlling TTY

If the controlling TTY (in our case the VT) signals us a HUP, we should
consider it closed and forward that to the caller. This does normally not
happen on real VTs, however, on fake-VTs this happens if the parent goes
away.

We forward the HUP to the controlling subsystem which then has to deal
with it. But more importantly, we disable the fd so we don't hog the CPU
by unconditionally flushing the queue.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: introduce client 'dead' state
David Herrmann [Sun, 2 Dec 2012 10:03:40 +0000 (11:03 +0100)]
cdev: introduce client 'dead' state

Files have the disadvantage that the kernel (or in this case 'we') cannot
force a client to close it. Instead, we have to mark it as 'dead' and wait
until the client closes the file theirself.
While marked as 'dead' we always return EPIPE or signal EPOLLHUP so the
client will notice that the file is dead.

This fixes a bug where when we forced an unregistration of a cdev session,
the cdev_client went away too early and the user still had the file open.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: fix copying pollhandles correctly
David Herrmann [Sun, 2 Dec 2012 10:02:17 +0000 (11:02 +0100)]
cdev: fix copying pollhandles correctly

The pollhandle is solely implemented in libfuse and does not correspond to
some kernel-intern object. Instead, the kernel notifies us when it has
poll-waiters via a flag. If that flag is set we should notify the kernel
whenever the poll-flags change.

Therefore, we can safely copy the pollhandle all the time and delete our
temporary handles.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: add uterm_vt_get_type() helper
David Herrmann [Sun, 2 Dec 2012 09:19:43 +0000 (10:19 +0100)]
uterm: vt: add uterm_vt_get_type() helper

This helper returns the VT type. This will allow external users to see
whether we have real VTs or whether we don't.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: set K_RAW before trying K_OFF
David Herrmann [Sun, 2 Dec 2012 09:18:15 +0000 (10:18 +0100)]
uterm: vt: set K_RAW before trying K_OFF

K_OFF is not available on older kernels and it is currently discussed
whether it should be replaced on newer kernels. Therefore, set K_RAW
before trying K_OFF and then ignore errors if K_OFF cannot be set.

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: fix delayed deactivation to update internal state
David Herrmann [Sun, 2 Dec 2012 09:16:24 +0000 (10:16 +0100)]
cdev: fix delayed deactivation to update internal state

We need to set "active" to false during delayed deactivation, as
otherwise we have inconsistent state in respect to the seat subsystem.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotsm: vte: ignore DEC SET/RESET 12 mode
David Herrmann [Sun, 2 Dec 2012 09:15:40 +0000 (10:15 +0100)]
tsm: vte: ignore DEC SET/RESET 12 mode

This mode is used to start/stop blinking cursors. As vim uses this
heavily, we should simply ignore it to avoid printing useless debug
messages.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: ignore keyboard shortcuts in single-session mode
David Herrmann [Sat, 1 Dec 2012 22:45:55 +0000 (23:45 +0100)]
seat: ignore keyboard shortcuts in single-session mode

Instead of not handling the keyboard shortcuts we should ignore them but
mark them as handled. Otherwise, we might get them from the parent session
and they will end up cluttering the terminal log.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: implement VT_WAITACTIVE
David Herrmann [Sat, 1 Dec 2012 18:06:38 +0000 (19:06 +0100)]
cdev: implement VT_WAITACTIVE

The VT API provides a VT_WAITACTIVE ioctl which waits until the VT got
activated. We use the same technique as with blocking reads() to implement
this without threads.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: fix unregistering display callbacks when removing screens
David Herrmann [Sat, 1 Dec 2012 17:22:38 +0000 (18:22 +0100)]
terminal: fix unregistering display callbacks when removing screens

We must unregister the display callback when removing a screen. Otherwise,
we keep writing to the screen memory which becomes invalid then.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: change default keyboard shortcuts to ctrl+logo
David Herrmann [Sat, 1 Dec 2012 16:39:38 +0000 (17:39 +0100)]
seat: change default keyboard shortcuts to ctrl+logo

ctrl+alt is already used by many other applications so lets use some other
unused shortcut modifiers.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconf: introduce --configdir parameter
David Herrmann [Sat, 1 Dec 2012 15:21:33 +0000 (16:21 +0100)]
conf: introduce --configdir parameter

The --configdir parameter allows specifying another configuration
directory than the default /etc/kmscon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: limit multi-session mode to --multi-session
David Herrmann [Sat, 1 Dec 2012 15:09:14 +0000 (16:09 +0100)]
seat: limit multi-session mode to --multi-session

If kmscon is started without the --multi-session option, we no longer
provide multi-session support (now the default). This is for better
backwards compatibility to agetty and friends.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconf: print warning if --vt is used wrong
David Herrmann [Sat, 1 Dec 2012 14:46:42 +0000 (15:46 +0100)]
conf: print warning if --vt is used wrong

--vt should only be used when kmscon runs on a single seat. Otherwise,
this VT will be forced on all seats and each kmscon instance _might_
collide.
If this is done with care, the --vt/--seats combination can work. However,
the use-cases are negligible and we should rather warn the ordinary user
not to do it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: use real VTs on all seats if available
David Herrmann [Sat, 1 Dec 2012 14:25:37 +0000 (15:25 +0100)]
uterm: vt: use real VTs on all seats if available

If there is already a kmscon instance running that provides fake-VTs, then
lets use it. This allows stacking kmscon processes and is very useful for
debugging.

Also other applications that use uterm can now run inside of kmscon
without any other special configuration.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: register cdev session only when --cdev is given
David Herrmann [Sat, 1 Dec 2012 14:05:07 +0000 (15:05 +0100)]
seat: register cdev session only when --cdev is given

We cannot have multiple instances of kmscon running with cdev emulation,
so disable it by default. A kmscon-system-daemon now needs --cdev if you
want fake VTs to work.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconf: fix whitespace offset for -s
David Herrmann [Sat, 1 Dec 2012 13:50:53 +0000 (14:50 +0100)]
conf: fix whitespace offset for -s

Align everything to the same offset.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: downgrade error to debug message on I/O errors
David Herrmann [Sat, 1 Dec 2012 12:15:01 +0000 (13:15 +0100)]
pty: downgrade error to debug message on I/O errors

I/O errors aren't fatal or important on PTYs so ignore them and mark it as
debug message.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: fix typo in warning
David Herrmann [Sat, 1 Dec 2012 12:11:39 +0000 (13:11 +0100)]
cdev: fix typo in warning

Obvious typo. Got those words swapped...

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: clear displays during sleep and wakeup
David Herrmann [Wed, 28 Nov 2012 21:54:46 +0000 (22:54 +0100)]
uterm: clear displays during sleep and wakeup

We shouldn't leave the content on the framebuffers when leaving kmscon.
This might confuse the user. Furthermore, we shouldn't reload the old
framebuffer during wakeup as this frame can be quite old and we see a
short flickering during wakeup which isn't wanted, either.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: set DPMS to ON before broadcasting the device
David Herrmann [Wed, 28 Nov 2012 21:21:33 +0000 (22:21 +0100)]
seat: set DPMS to ON before broadcasting the device

We cannot modeset a device while DPMS is set to OFF so we should do this
before broadcasting the device. Otherwise, the callback might not be able
to use the display.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agomain: correctly remove all displays on uterm-video shutdown
David Herrmann [Wed, 28 Nov 2012 21:16:07 +0000 (22:16 +0100)]
main: correctly remove all displays on uterm-video shutdown

If we close an uterm-video object, we must correctly remove all displays
first.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: check swapping state during activation
David Herrmann [Wed, 28 Nov 2012 21:14:05 +0000 (22:14 +0100)]
terminal: check swapping state during activation

If a terminal gets activated while a swap-buffer operation is still in
progress from the previous session, we must not directly reschedule it.
Instead, we wait for the page-flip event and continue then.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: activate displays only when being in foreground
David Herrmann [Wed, 28 Nov 2012 20:55:50 +0000 (21:55 +0100)]
seat: activate displays only when being in foreground

We shouldn't activate displays when we are active but in background. In
these moments, the uterm-video device might not be initialized, yet.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: remove now unused --fps option
David Herrmann [Wed, 28 Nov 2012 19:57:36 +0000 (20:57 +0100)]
terminal: remove now unused --fps option

We no longer have a framerate-control option so remove it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: sync redraw events with vertical blanks
David Herrmann [Wed, 28 Nov 2012 19:51:30 +0000 (20:51 +0100)]
terminal: sync redraw events with vertical blanks

We used an FPS timer to control redraw events but this caused some
unwanted artifacts. Instead, we should always wait for the page-flip event
before redrawing the screen.

This can still be optimized (for instance via triple-buffering) but it
works very nice now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: keep terminal reference in each screen
David Herrmann [Wed, 28 Nov 2012 18:31:09 +0000 (19:31 +0100)]
terminal: keep terminal reference in each screen

We need to have a terminal reference in future screen callbacks so keep
one from the beginning.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: fix ignoring HUP on pty-master files
David Herrmann [Wed, 28 Nov 2012 16:47:31 +0000 (17:47 +0100)]
pty: fix ignoring HUP on pty-master files

A HUP is reported whenever there is no client listening on the other side
of the PTY. As /bin/login and friends call vhangup() during setup, there
is a short time-span when we might get a HUP.
Hence, we need to ignore HUPs and solely track clients by PID. To avoid
hogging the CPU while the TTY is hungup, we change the event-mode to
edge-triggered.

This fixes a bug where we tried starting /bin/login several times because
we always ran into this race-condition and directly closed the TTY again.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>