Add two functions to enter/leave our VT object. This allows to
implement to expected behavior of automatically switching to the kmscon
when it is running on a new tty, and switching back to the tty we came
from when the program finishes. Presumably this behavior will be
controlled by a config variable or command line argument later on (like
Xorg's -novtswitch).
There's a bit of a subtlety in this because of VT_PROCESS. We need
permission from ourselves to switch in/out of out VT; this is done when
processing SIGUSR[12] in the eloop. We therefore must dispatch the loop
at least once after switching out. The usual case is demonstrated in
test_vt.c.
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
See https://github.com/dvdhrm/kmscon/pull/3 for a discussion of K_OFF in the VT
subsystem. We cannot apply it now but we have to reconsider it when the input
subsystem has been written.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
- Use C99 and gnu extensions.
- Explicitly link against libdrm (more strict linkers like gold would
complain).
- Consistently use *_CPPFLAGS where due.
- Clear the default CFLAGS.
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The buffer object manages the cells and scrollback buffer. It is optimized for
speed: fast rotations, fast resize, etc.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We add a new helper to initialize a new character directly to avoid two
allocations. This also refactors the character code and simplifies it alot.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The test_console application now supports VT-switching and monitor-hotplug. New
monitors are detected when switching VTs. Full hotplug-support will be added
later.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
If we switch VT, we must release DRM master to allow other applications to
access the DRM. When waking up the compositor we try to acquire the master again
to access the DRM.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We currently ignore all test sources. Restrict the filter to the root directory
so only the binaries are affected.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
As long as we are run in a VT we need to correctly handle VT-switches to avoid
blocking the crtc/input.
This is copied from wayland-compositor demos and modified to fit to our needs.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Idle events are dispatched everytime kmscon_eloop_dispatch() is called. To allow
the callbacks to add/remove/modify all current idle events (including themself),
we need to keep a pointer to the currently dispatched event.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We currently use the first mode in the list if no mode is explicitely specified
by the caller. However, this is most often the lowest available resolution
reported by the kernel.
This patch adds a new pointer to every output which remembers a sane default.
This is currently the first mode reported by the kernel but may later be
optimized to choose a better default mode.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We simply forward all log messages to stderr. We use syslog/prink-like severity
prefixes. Use systemd or alike to forward stderr to syslog, kernel-log or
similar.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Correctly handle SIGINT and SIGTERM. This will also reset the crtc so it won't
stay black if the application is killed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Further commits will need a Signed-off-by line, otherwise I cannot accept them.
MIT license is compatible with GPL so we still can switch to GPL in the future
if we want.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We didn't calculate the correct cell number when drawing a cell. Fix that.
Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The crtc is saved from kmscon_output_activate, and restored from
kmscon_output_deactivate.
This means that when the program exits, the screen is back to what it
was - we don't need to switch back VTs if we started the program from an
fbcon, etc.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit adds basic autoconf + automake files to build the project.
It also adds a main.c stub in order to simulate the main binary.
The configure script uses pkg-config to find the libraries. The usual
stuff should work. The only additional option right now is:
./configure --enable-debug [To enable debugging symbols]
The Makefile should also support the standard stuff:
make [To build the kmscon binary]
make check [To build the test_* binaries]
make dist [To create a tarball]
make clean
make install
etc.
To start from a clean tree (e.g. git clean -dfx), do something like the
following:
./autogen.sh
./configure --enable-debug CFLAGS=-O0
make
It all should work well enough for now.
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This function can be used to change the content of the current cell. It
automatically moves the cursor to the next cell.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Similar to libvte we could speed up font-drawing by using cairo_scaled_font_t to
bypass pango entirely if a glyph is already in the hash-table.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
To avoid redrawing the whole layout every time, we now support caching a single
glyph-string if it consists of only one run.
This should speed up drawing considerably. We still support drawing the whole
layout as fall-back method.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We set the font size to the absolute size we have per cell instead of using a
fixed font-size.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This sets the console resolution to 800x600 on startup. We no longer have a
console with an invalid resolution after startup so we now can start calculating
font sizes properly.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Correctly set locale on startup and sleep for one second after each redraw to
reduce CPU consumption.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We must use SOURCE operator to reset the surface. Otherwise, we end up doing
nothing here because our alpha value is 0.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We need to refresh the GL texture data when redrawing the console. Otherwise, we
always end up with the first frame mapped onto the GL quad object.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When resizing a kmscon_console object we automatically create a new font because
all cached objects get invalid now.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
A kmscon_font object is used to store the current font information. It allows to
draw any kind of UTF-8 string to the screen. Internally, it uses kmscon_glyph to
store glyph information for every character that has been drawn so redrawing it
is much faster.
Currently, we only support GLYPH_LAYOUT as caching method which is quite slow.
However, it supports any kind of input and always works. Better and faster
caching algorithms like cairo_scaled_font_t will be added later.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
A console has a fixed line and column count. Each entry is represented by a
kmscon_cell object. The console can be resized on the fly.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>