1115 Commits

Author SHA1 Message Date
David Herrmann
0cecc8de1e text: add owner field to text-ops
When text-ops are registered via modules, we need an owner field so
they're correctly tracked. Hence, add this field to all text-ops and
correctly keep module references.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 17:24:41 +01:00
David Herrmann
70b069aacc kmscon: add freetype2 module
The freetype2 module register the freetype2 font backend with kmscon core.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 17:04:55 +01:00
David Herrmann
b81cff46e5 kmscon: add unifont module
The unifont module registers the unifont font backend with kmscon core.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 17:04:33 +01:00
David Herrmann
e6fa020937 text: remove old font definitions
All font definitions have been moved to font.h so remove the old
definitions and include font.h instead.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 17:03:31 +01:00
David Herrmann
e97c71fea1 text: move font layer into top-level font_* namespace
The font layer does not longer depend on the text layer so move it into
its own namespace.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 16:55:56 +01:00
David Herrmann
c14492796e kmscon: add pango module
The pango module registers the pango font-backend with kmscon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 16:30:40 +01:00
David Herrmann
5dcdc91b42 text: font: add owner field to font_ops
The owner fields specifies the module that provides the code for the given
backend. The font-core is responsible of ref/unref'ing the module so its
code is always available as long as the module exists.

We cannot push this into the modules as modules _must_ never call
kmscon_module_unref(KMSCON_THIS_MODULE)! Because this might drop the last
reference and hence the function might disallocate the module. However,
this means that it cannot return because the caller is _part_ of the
module and so no longer valid.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 16:23:52 +01:00
David Herrmann
a8c1d8bbf1 kmscon: add module support
Several parts of kmscon have huge external dependencies. However, we allow
them to be disabled during build-time. But this is not enough as it
requires distributions to choose which options to use. Therefore, we now
allow dynamicly loadable modules that can optionally be installed and
kmscon automatically picks them up.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 16:21:18 +01:00
David Herrmann
82ee6c8e51 text: font: add .finalize callback
Each font-backend now also gets a .finalize callback that is called when
the last font-user drops its font. This will allow modules to destroy
themself when the last reference is dropped.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 14:03:58 +01:00
David Herrmann
327c7f0690 shl: register: add destroy callback
The new destroy callback is called whenever an entries last reference is
dropped. This will allow modules to keep reference of its code users.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-03 14:00:57 +01:00
David Herrmann
0248318732 text: remove load/unload helpers for text-font backends
With modules we no longer need to conditionally load backends. Instead
each module will register the backend with the main application on load.

This will temporarily break pango, freetype2 and unifont backends as they
are not registered until we introduce full module support.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-02 18:14:48 +01:00
David Herrmann
180f25375d build: link each text-font backend separately
We want to modularize the text-font library, so we need each backend as a
different library. This step links each of them into a different static
library so we can now link them either into the binary or into modules.

This step also makes 8x16 always compiled into the text-font backend so we
always have a working implementation even though no modules might be
loaded.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-02 18:02:10 +01:00
David Herrmann
ca446c691f build: provide git-head revision via githead.h
We need the git-revision for module-version checks so provide the
infrastructure now and print it in log_init().

Note that the git-describe string is distributed with the tarballs so
end-users will not have to generate it themself. But when building from
git, the revision will be automatically updated whenever something
changes.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-02 15:51:54 +01:00
David Herrmann
d96934c4a5 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>
2012-12-30 19:41:08 +01:00
David Herrmann
0ec995601b 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>
2012-12-30 19:40:04 +01:00
David Herrmann
7304985892 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>
2012-12-30 16:21:27 +01:00
David Herrmann
6b39218ceb 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>
2012-12-30 16:20:51 +01:00
David Herrmann
3c9363035e 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>
2012-12-30 16:18:25 +01:00
David Herrmann
60c2851d64 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>
2012-12-21 15:30:19 +01:00
David Herrmann
382e238b2f 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>
2012-12-21 15:15:16 +01:00
David Herrmann
724b030894 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>
2012-12-21 14:13:00 +01:00
David Herrmann
6be24df169 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>
2012-12-12 21:29:23 +01:00
David Herrmann
5a33f412d9 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>
2012-12-12 21:24:51 +01:00
David Herrmann
24fe3f1911 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>
2012-12-12 21:24:15 +01:00
David Herrmann
dd481c2fa6 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>
2012-12-12 21:20:45 +01:00
David Herrmann
d50f80a72f 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>
2012-12-12 20:12:21 +01:00
David Herrmann
03aab2b54b 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>
2012-12-10 16:09:28 +01:00
David Herrmann
1657bb9a3a 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>
2012-12-10 16:00:08 +01:00
David Herrmann
0de1de25fd 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>
2012-12-10 15:55:12 +01:00
David Herrmann
bc40e1ae53 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>
2012-12-10 15:36:04 +01:00
David Herrmann
e3c9bcfb15 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>
2012-12-10 15:23:10 +01:00
David Herrmann
98970835d9 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>
2012-12-09 22:06:51 +01:00
David Herrmann
6e8fb5aa0d 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>
2012-12-09 18:34:26 +01:00
David Herrmann
b78244e1ab 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>
2012-12-09 18:33:03 +01:00
David Herrmann
3d28387fb2 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>
2012-12-09 15:55:26 +01:00
David Herrmann
89b6ff63fc 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>
2012-12-09 14:19:17 +01:00
David Herrmann
5e8ce520c2 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>
2012-12-09 14:14:41 +01:00
David Herrmann
29625b186d 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>
2012-12-09 13:50:38 +01:00
David Herrmann
06a50ce58c 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>
2012-12-09 13:44:52 +01:00
David Herrmann
cec87f029c 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>
2012-12-09 13:41:28 +01:00
David Herrmann
c4a1a33597 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>
2012-12-09 13:37:39 +01:00
David Herrmann
add239ee2c 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>
2012-12-09 13:26:45 +01:00
James Buren
b4fe3f7460 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>
2012-12-09 12:26:33 +01:00
David Herrmann
56894fb10a 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>
2012-12-06 15:21:23 +01:00
David Herrmann
fd098b828c 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>
2012-12-06 14:49:56 +01:00
David Herrmann
4258eb1a6b cdev: do not hardcode TTY major
Use TTY_MAJOR instead of hardcoding the literal 4.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-06 14:45:52 +01:00
David Herrmann
0b893bb2aa 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>
2012-12-06 14:44:14 +01:00
David Herrmann
4ceb557ecb 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>
2012-12-06 14:18:57 +01:00
David Herrmann
3cebf533fc 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>
2012-12-06 14:03:54 +01:00
David Herrmann
2ac9421377 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>
2012-12-06 13:55:00 +01:00