If we have only an output but not the related compositor we currently cannot
figure out whether this output is awake. This adds such a helper function.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We must not destroy the compositor object if there is still a console using the
GL context. Otherwise we get a SEGFAULT when calling any gl* function.
In future we may need propoper dependencies here. We use reference counts so
this should be easy to implement.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
kmscon_console_newline() can be used to produce a newline. Writing \n doesn't
work as this would write \n as character into the cell and not produce a
newline.
The console does not perform any parsing so we provide a separate function.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Remove the *_set_res() function entirely. Instead, the *_resize() function now
accepts a height argument which is used as quality hint. Internally, we compute
the texture width by the selected font plus the given height. This simplifies
the API and the internal handling and improves output on non-standard
resolutions or with non-standard fonts.
Until now it was only optimized for my 16x9 output but 5x4 output was quite
garbled.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We shouldn't do anything if buffer_resize is called with the same size. This
also suppresses useless "buffer resized to XxY" debug messages.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When creating a new font we automatically measure the average width of a
character. This allows us to draw fonts even on weird resolutions.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
A kmscon_char has always a valid buffer so we can always return a valid pointer.
The user shouldn't use it if length is 0 but it's not our job to prohibit that.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Forward resizing requests to the buffer but correctly update our size cache and
the cursor position.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Add kmscon_console_write() to write a character to the current position of the
cursor. The cursor is automatically moved to the next cell.
Also extend the test_console example to use this new function.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When resizing lines we shouldn't drop all information. Instead we only
initialize new cells.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This test app is used to stress test the buffer implementation and finding bugs
of the scrollback-buffer rotations etc.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We now use a proper cache for the current screen and a linked list for the
scrollback buffer. This allows fast rotations and fast access.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
There is no reason to make all tests/* apps need cairo dependencies. We pass
this parameter internally so we can safely use void*.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Our scrollback buffer needs to adjust the current position when being resized or
when a new line is pushed.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Unless we benchmark the buffer implementation we shouldn't implement
speedup-hacks. Therefore, remove the buffer-cache and look how it works out.
This simplifies buffer handling alot.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Resetting a char should never fail so we provide a separate function that sets a
char to its default value.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
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>