70 Commits

Author SHA1 Message Date
David Herrmann
f7eca00957 console: remove cairo from header
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>
2011-12-20 21:40:35 +01:00
David Herrmann
10dfb530d4 console: correctly set current position in buffer
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>
2011-12-18 13:49:03 +01:00
David Herrmann
fbd9446135 console: use new buffer implementation
Use the new kmscon_buffer in the console subsystem.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-18 12:58:47 +01:00
David Herrmann
68ac348389 console: remove buffer cache
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>
2011-12-18 12:23:14 +01:00
David Herrmann
0533c94677 console: allow resetting of kmscon_char's
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>
2011-12-18 11:46:08 +01:00
David Herrmann
6bf0e7ed7e Add config.h.in~ to gitignore
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-14 18:09:03 +01:00
Ran Benita
7ed09101f0 build: set in NDEBUG instead of DEBUG in configure
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-14 18:08:19 +01:00
Ran Benita
dfd880881e vt: add support for automatic VT switching
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>
2011-12-14 16:33:35 +01:00
David Herrmann
bb9089696e Add K_OFF to vt-TODO
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>
2011-12-14 15:38:26 +01:00
Ran Benita
c72953fa63 build: a few fixes to configure script
- 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>
2011-12-09 16:21:42 +01:00
David Herrmann
03a67f977a Console: Add buffer object
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>
2011-12-04 17:56:43 +01:00
David Herrmann
8f06542909 Console: Simplify character handling
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>
2011-12-03 18:09:41 +01:00
David Herrmann
20beb30357 test_console: Use new eloop and VT subsystem
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>
2011-12-03 16:49:44 +01:00
David Herrmann
e195d911e1 Output: Correctly acquire/release DRM master
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>
2011-12-03 16:39:06 +01:00
David Herrmann
39b3cc1237 Eloop: Fix function name typo
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 16:38:14 +01:00
David Herrmann
f59a28b984 Fix gitignore
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>
2011-12-03 15:14:38 +01:00
David Herrmann
ae54604784 Add VT test
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 15:14:18 +01:00
David Herrmann
7fa1ab55dd Eloop: Add debug statements
Add some more debug statements to allow easier eloop monitoring.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 15:09:10 +01:00
David Herrmann
bb5f11baa1 Add VT handling
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>
2011-12-03 15:08:18 +01:00
David Herrmann
1fb4c71895 Eloop: Pass mask argument to fd callbacks
fd-callbacks are pretty useless if we do not pass a mask argument with the
current flags.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 12:22:36 +01:00
David Herrmann
42a6c76e28 Eloop: Add idle-event support
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>
2011-12-03 12:04:29 +01:00
David Herrmann
fe5b180fbb Add event loop
Add event loop implementation with support for fd's and signal's through
signalfd.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 11:42:41 +01:00
David Herrmann
9d2fe62bd9 test_output: Use log API
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-02 15:33:52 +01:00
David Herrmann
3aad1107d8 Output: Choose sane default mode
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>
2011-12-02 15:27:01 +01:00
David Herrmann
9b88fe87e2 test_output: Use new log API
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-02 15:16:14 +01:00
David Herrmann
ed79aeccef Add log API
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>
2011-12-02 15:15:05 +01:00
David Herrmann
9093189f2f test_output: Catch SIGINT and SIGTERM
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>
2011-12-02 15:10:07 +01:00
David Herrmann
41c56410ee test_console: React on SIGINT
Correctly terminate the application on SIGINT so the CRTC gets reset.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-02 14:35:33 +01:00
David Herrmann
ca409fb0c5 Update documentation about autotools
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-02 13:31:12 +01:00
David Herrmann
0d1acc526f Change license to MIT license
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>
2011-12-02 13:23:22 +01:00
David Herrmann
6072bf445f Console: Fix cell-selection when drawing glyphs
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>
2011-12-01 18:33:49 +01:00
David Herrmann
0b6a81d901 Update TODO
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-01 18:20:54 +01:00
Ran Benita
aacb342092 output: save and restore crtc upon (de)activation
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>
2011-12-01 16:39:06 +01:00
Ran Benita
25b85f5f26 Output: Fix warning -Wall complains about
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-01 16:27:15 +01:00
Ran Benita
062dd2875d gitignore: add all the build stuff
Signed-off-by: Ran Benita <ran234@gmail.com>
2011-12-01 16:25:11 +01:00
Ran Benita
6d451a2015 build: use gnu autotools
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>
2011-12-01 16:21:37 +01:00
David Herrmann
77963ec305 Add kmscon_console_write() function
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>
2011-11-27 19:31:26 +01:00
David Herrmann
798276dea9 Add kmscon_char_set() helper
This helper allows to copy one char into another.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-27 16:10:11 +01:00
David Herrmann
0cf9a7a03c Add cursor movement helpers
Add functions to move the cursor of a console.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-27 15:50:59 +01:00
David Herrmann
89634f3f13 Update TODO
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>
2011-11-26 17:59:49 +01:00
David Herrmann
264fff909e Support glyph string caching
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>
2011-11-26 17:54:56 +01:00
David Herrmann
9e2c14a7ca Fix glyph caching
We need to use memcmp() not memcpy() to compare two kmscon_char's.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 17:53:45 +01:00
David Herrmann
c4d6c554fd Calculate font size properly
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>
2011-11-26 17:12:17 +01:00
David Herrmann
607a5eed54 Set console resolution to 800x600 by default
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>
2011-11-26 17:04:52 +01:00
David Herrmann
e5de20a22a Fix test_console
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>
2011-11-26 16:55:25 +01:00
David Herrmann
7149b5dd37 Draw console
Properly draw all cells of a console on redraw.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 16:54:40 +01:00
David Herrmann
c8855d47b2 Reset cairo surface when drawing console
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>
2011-11-26 16:48:59 +01:00
David Herrmann
c455d8f9f0 Set each cell to '?' for testing purposes
Each cell of a console is initialized to '?' to allow testing the glyph
operations.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-26 16:47:50 +01:00
David Herrmann
8b93b07db3 Refresh texture when redrawing console
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>
2011-11-26 16:46:44 +01:00
David Herrmann
27047fddbf Create font when resizing console
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>
2011-11-26 16:43:17 +01:00