53 Commits

Author SHA1 Message Date
David Herrmann
cfca84f250 vt: fix callback enum type
We should use the enum type instead of plain "int" to be more verbose
here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 16:42:04 +01:00
David Herrmann
096f0cadc7 Move to new uterm infrastructure
This fixes all compositor/output/context/etc. uses and replaces them by
the new uterm API.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 14:18:50 +01:00
David Herrmann
1dd7198216 test_output: use new uterm/log/etc. subsystems
Convert the test_output test to use the new subsystems.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-23 13:35:02 +01:00
David Herrmann
4790d9f7ab eloop: move prefix to "ev_" instead of "kmscon_"
The long "kmscon_" prefix is horrible so move everything to "ev_" now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:08:29 +01:00
Ran Benita
d8cf293c94 build: implicitly include config.h
config.h is meant to be around in all files, as it contains stuff like
_GNU_SOURCE, NDEBUG and HAVE_*.

Make these definitions available without needing to #include config.h
every single time.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-20 19:00:16 +01:00
David Herrmann
2b8caca91c console: remove *_buffer_newline()
This function is no longer needed as we now have proper scrolling
functions. This also adjusts the buffer tests to be more appropriate.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-04 14:34:33 +01:00
David Herrmann
ff408d6fb9 test_buffer: add margin tests
Modify the buffer test to add margin tests.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-03 18:43:56 +01:00
David Herrmann
af3a1f3e50 console: move kmscon_console_rotate to *_newline
We do no rotation so rename the function to the more appropriate name
kmscon_console_newline.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-02 17:01:54 +01:00
David Herrmann
2ddd47e858 test_buffer: add utf8 state machine test
Add trivial test to show how to use the utf8 state machine.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-29 14:21:19 +01:00
David Herrmann
79e1ada7e5 vte: handle keyboard input (stub)
Make the vte subsystem handle the keyboard input instead of doing this
inside of test_terminal.

The handling is just a stub function. No actual keys are parsed yet.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 22:14:20 +01:00
David Herrmann
da0623c260 terminal, pty: pass eloop reference on obj creation
There is no reason to pass the eloop reference late at terminal/pty
open. If we pass it early on object creation we will always have a valid
reference and can remove several code paths.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 13:56:13 +01:00
David Herrmann
bd09f38a4d log: move log_warning to log_warn
log_warn is much shorter and we already use log_err instead of log_error
so this is more consistent now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-24 15:29:55 +01:00
Ran Benita
5cc190d947 test_terminal: wait on children to avoid zombies
Unfortunately, there is no clean way I see to hook this up from the pty
object. We can (and will) have more than one pty object opened at a
time, but the semantics of signalfd make it impossible to deliver each
SIGCHLD to its rightful owner without complicating things.

[ From what I tested:
 - If you have two signalfd's listening to the same signal, they will be
   dispatched in some round-robin manner.
 - Also, if more than one child exits before we read signalfd (possibly
   beloging to different terminals), they will be compressed to one
    event. ]

We therefore need to do the reaping from a central location, and need to
remember to copy this snippet over to main.c in the future.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-24 15:06:51 +01:00
Ran Benita
6ebc7c1892 terminal: use new pty object
Add a new terminal_open/terminal_close methods to correspond to the pty
ones, and notify when the terminal is closed.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-24 15:04:06 +01:00
Ran Benita
582ee16d31 test_input: simplify and drop xkbcommon dependency
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-23 13:51:50 +01:00
David Herrmann
5a3801386a font: rewrite font backend
We now properly draw fonts with OpenGL. We now use FreeType2 instead of
pango to avoid big dependencies.

We also add a DejaVu font so we currently don't have to deal with font
selection.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-22 22:44:12 +01:00
David Herrmann
e5f5c2729a font: require compositor reference
To avoid cairo dependencies we now take a compositor reference in the
font backend so fonts can be drawn with GL textures instead of cairo.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-22 13:51:23 +01:00
David Herrmann
7085084b1d context: use GL_TRIANGLES instead of GL_QUADS
GL_QUADS may actually be not supported on some embedded platforms so we
use GL_TRIANGLES.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-20 16:11:30 +01:00
David Herrmann
83cec439c6 console: use new drawing pipeline
Instead of drawing with fixed-function GL pipeline we now use our own
shader for texture drawing. This also fixes test_console to no longer
depend on GL.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-20 15:45:58 +01:00
David Herrmann
05a1747f00 console: take reference of compositor
To switch to the new drawing subsystem we need a reference to a valid
compositor object so we can retrieve the GL context.
This also applies to the terminal object.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-18 18:09:08 +01:00
David Herrmann
cabde245df test_output: use new drawing pipeline
This converts the output test function to use the new kmscon_context for
drawing operations so we no longer depend directly on GL.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-18 16:26:57 +01:00
Ran Benita
01e469b9ec test_console: fix use-after-free
Here's how it goes:
1. stdin reaches EOF, kmscon_eloop_rm_fd is called on stdin_fd.
2. The fd object is freed, the memory is reused in the meantime.
3. rm_fd is called again in destroy_eloop.
4. con->stdin_fd points to garbage and we get a segmentation fault.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-09 20:20:58 +01:00
David Herrmann
c203b3a83d font: move font handling into new subsystem
We use a new font factory which is used to create a new font. It will later also
be used to cache fonts and select proper system fonts.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 18:27:09 +01:00
David Herrmann
a7128cc683 Adjust all code to use new kmscon_symbol_t
This is a big performance boost and reduces the code size quite a bit.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 17:43:57 +01:00
David Herrmann
b3ce42bc63 test_buffer: add kmscon_symbol_t test
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 16:52:30 +01:00
David Herrmann
117d7ddbcd test_terminal: add experimental input support
Add input subsystem to terminal test app. This currently allows to actually
"write" to the console. There is still much to do to convert the input to proper
data but basic alphanumeric characters work for now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 17:38:46 +01:00
Ran Benita
8d28790ba4 input: define our own modifiers
Just a direct mapping to X modifiers for now (= Shift, Control,
Lock, Mod1-5).
This gives us more flexibility to adapt it to our needs in the future.
Also we don't have to include libxkbcommon headers just for the modifier
definitions.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:53:54 +01:00
Ran Benita
7c9fb7bf29 input: don't use 0 to signal lack of unicode value
0 is actually a valid unicode value, so instead we use
KMSCON_INPUT_INVALID which is not legal unicode.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:52:22 +01:00
Ran Benita
c3912b23a2 input: shuffle headers and includes
Just some renames/moving/prefixing to conform to the style of the
other files.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:50:52 +01:00
Ran Benita
6e301a9af3 input: use libxkbcommon to convert input events
This commit introduces a new kmscon_input_event structure which is
delivered to the input consumer. The information provided is
- The evdev scancode (=physical keyboard key).
- The X keysym (a symbol representing what the typist really intended).
- The active modifiers (e.g. Shift, Control..)
- The unicode (UCS-4) value, when it makes sense.

To achieve this we add two dependencies:
- libxkbcommon (this entails xproto and kbproto, but shouldn't bring any of
  big X dependencies)
- A function to translate keysyms to unicode values (taken from xlib,
  copied in-tree).

libxkbcommon is not an all-around solution, and requires various degrees
of supporting code, depending on how much we wish to support. This
commit implements the common, basic uses:
- Choosing layouts, variants and options
- Switching groups
- Switching shift-levels
- Setting modifiers
Though some stuff is missing. Further information in the comments.

test_input.c is updated to use the new input event interface. You can
change the layouts in input.c:init_input() and see what works and what
doesn't.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:18:29 +01:00
Ran Benita
7a5f5091f6 tests: add test for the input subsystem
It should:
- Capture your keypresses
- Announce when a device is added or removed (with --enable-debug)
- stop/start capturing on SIGQUIT (Ctrl-\)

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 12:33:36 +01:00
David Herrmann
f60356d429 terminal: add dummy terminal implementation
vte: This adds a dummy VTE subsystem. It will be used to emulate a vt100
terminal based on our console subsystem.

terminal: This ties together several subsystems including the output-, the
console- and the vte-subsystem.

The test_terminal test application can be used to test the terminal. It is
supposed to provide a full vt100 implementation which is displayed on all
available screens.

Most of the functionality here is not implemented yet and only a dummy function.
These will be added in later commits.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 18:01:00 +01:00
David Herrmann
b8124efaf9 test_console: fix call to kmscon_comp*_use
We should activate the GL context on initialization to allow other subsystems to
create GL objects.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 16:48:20 +01:00
David Herrmann
240d6671ba test_output: handle kmscon_comp*_use failure
Move the call before the wakeup and also check its return code.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 16:44:28 +01:00
David Herrmann
84248b0ac7 vt: fix race-condition in signal handling
Currently, we set up our VT with SIGUSR1/2 signals and after that the user may
connect the signal handlers to the eloop. However, if we receive a signal in
between, the signal gets lost.

Therefore, this simply merges the kmscon_vt_connect_eloop function into
kmscon_vt_open as there is no obvious reason to split them.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 13:47:36 +01:00
David Herrmann
0f44dfdde8 test_console: fix console deinitialization bug
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>
2011-12-26 14:46:22 +01:00
David Herrmann
74d8ba5eea test_console: copy stdin to console output
Add new fd to eloop that copies stdin to console output.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-26 14:27:03 +01:00
David Herrmann
4ca6eeae82 console: calculate width by font
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>
2011-12-26 12:45:54 +01:00
David Herrmann
d75404742b console: support writing to console
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>
2011-12-21 16:30:06 +01:00
David Herrmann
7402e5e753 console: correctly resize lines
When resizing lines we shouldn't drop all information. Instead we only
initialize new cells.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-21 16:07:40 +01:00
David Herrmann
c762375c92 test_buffer: add buffer playground
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>
2011-12-21 15:44:24 +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
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
ae54604784 Add VT test
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-03 15:14:18 +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
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
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
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
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