131 Commits

Author SHA1 Message Date
Ran Benita
0a5bf7bb28 vte, terminal: add pseudo terminal support
This commit adds some needed terminal emulator infrastructure.

We allow to "open" (and close) a vte object (resp. terminal object).
We then create a pty pair, fork and exec a shell. We route input to the
shell and draw its output to the console.

We add callbacks for when
- The buffer changes (through the vte object). We can then schedule a
  screen redraw.
- The shell (child process) exits. We can then exit ourselves, start up
  a new shell, etc.

There is not yet any real VTE processing, so we display raw escape
codes and so on. However, this should provide immediate feedback for
any further vte development, as we start to act like a real terminal
emulator.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-01-09 02:06:21 +02:00
Ran Benita
969da54ee3 vt: add a few CLOEXEC's
These are the only open() calls missing the flag.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-01-09 02:06:21 +02:00
Ran Benita
64c018bfd2 input: make "us" default layout, override by env vars
The other layouts can be confusing.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-01-09 00:57:15 +02:00
Ran Benita
9a51e10e32 log: make sure not to override errno
This makes things easier in the common case of
<some error> -> <log error> -> <goto error handler> - <do something with
errno>

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-01-09 00:48:39 +02:00
Ran Benita
9e99726ca7 eloop: allow reporting error conditions
Add KMSCON_ERR, the equivalent of EPOLLERR.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-01-09 00:47:25 +02:00
David Herrmann
5dbeb1474b Update README to include new dependencies
Rework dependency list and also add new configure flags.
We also update the subsystem list.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 23:39:23 +01:00
David Herrmann
80e9b79f3e Add configure to autogen.sh
Use ./autogen.sh --<options> to run autogen with configure in one call.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 23:27:13 +01:00
David Herrmann
32db4b53ed Avoid installing doc files with "make install"
Move all documentation into EXTRA_DIST, otherwise it gets installed systemwide.
And probably no one is interested in having the README installed in the system.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 23:26:10 +01:00
David Herrmann
b6550aed8b configure: fix debug option NDEBUG definition
We currently define NDEBUG only if --<set>-debug is not specified at all. That
is, --disable-debug currently has almost no effect.
This fixes this bug and also corrects a wrong parenthesis.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 23:19:40 +01:00
David Herrmann
319aae35c9 font: add unfinished freetype backend
This is a first attempt of a freetype2 backend for the font drawing functions.
This avoids the heavy pango/cairo dependencies, although, we might lose
important font handling that pango does for us like correctly drawing combined
characters.

This is still a stub implementation. The drawing operations are not supported,
yet. Use --enable-pango during configure to enable the still working pango
backend.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 23:11:48 +01:00
David Herrmann
41c032d289 Update TODO
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 23:04:13 +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
4c236e110b Remove kmscon_char implementation
It was superceded by kmscon_symbol_t and is no longer used.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 17:45:57 +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
4eca3ef714 unicode: provide utf8 converter
Allow converting a ucs4 string into a utf8 string. Also export the default
symbol so other subsystems may use it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 17:42: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
39f90a4536 Add faster kmscon_char replacement
Instead of allocating big buffers with kmscon_char's for every character we now
reduce a single character to an integer. This integer is either the Unicode
codepoint or an ID to an internally allocated string.

The so called kmscon_symbol_t integer can now be used as if it were a classic
"char" value without bothering with combining marks etc.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-01 16:47:06 +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
David Herrmann
af9ab4197c console: add UCS4 to UTF8 conversion
Allow to create new kmscon_char objects with UCS4 input.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 17:38:17 +01:00
Ran Benita
22a16b0cd5 Update TODO regarding input subsystem
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:55:20 +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
553dfddc27 Correctly set Xlib copyright headers
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:40:06 +01:00
Ran Benita
bb499f7513 xkb: fix group wrapping
- Use the number of groups we actually have instead of the maximum
  number of groups, when wrapping according to group_wrap control.

- Be careful with negative relative group actions. The group fields of
  xkb_state are all unsigned (and have a weird FIXME..), so don't use
  them directly.

- Add the grp:ctrl_shift_toggle option to the rmlvo set to also test
  locking the previous group (i.e. a negative relative group action).

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:29:58 +01:00
Ran Benita
83b95f643f xkb: refactor keysym compat_init into a separate function
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:28:31 +01:00
Ran Benita
2b540610e4 input: fix formatting
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:27:45 +01:00
David Herrmann
7af290efbf input: fix open() call parameters
Third argument of open() is for file creation flags and nor for file open flags.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:27:37 +01:00
Ran Benita
fdf73407b7 xkb: latches were not always released correctly
Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:27:27 +01:00
Ran Benita
a407143174 xkb: filter unwanted repeats
We can disable repeats globally or per-key. Also any modifier
keys should not repeat.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:27:14 +01:00
Ran Benita
ee92c1c554 xkb: comment out LevelOneOnly handling
Stuff like grp:ctrl_shift_toggle didn't work because of it.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 16:26:35 +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
David Herrmann
92de8f3f12 Add Ran Benita to authors list
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 12:46:15 +01:00
David Herrmann
546f51e4a3 input: do not take reference of parent input object
This is currently broken, anyway as we do not unref the object. However, if we
take a reference, then kmscon_input_unref() would never destroy the object as
there are still references. The caller would have to call kmscon_input_sleep()
first to have the desired effect.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 12:44:10 +01:00
David Herrmann
1ed4f89164 input: silently ignore devices without device-node
We either need to adjust our filters to only receive inputX/eventY events or we
simply ignore all other events silently to avoid useless warnings.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 12:39:42 +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
0799fbb4be input: rearrange code to avoid forward declarations
The diff may look a bit wild but this mostly fixes coding style issues:
 - sort includes alphabetically
 - add missing includes
 - rearrange structures/functions to avoid forward declarations
 - adding "data" user-defineable field to input structure (for callbacks)
 - correctly handle errors in device_data_arrived
 - remove device_added/device_removed
 - merge input_init into constructor
 - add some log messages for debugging
 - remove devices when wake-up fails
 - set cb/data fields on eloop connection, not on initialization
 - remove all devices when disconnecting eloop so the eloop is guaranteed to be
   not used by the input subsystem after disconnection.
 - some error handling fixes
 - remove some TODOs which are correctly implemented
 - Add O_NONBLOCK when opening the device node (I don't know how it actually
   worked without it in the data_arrived callback)

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-31 12:04:17 +01:00
Ran Benita
33afda8421 input: add infrastructure for an input subsystem
This does all the boring stuff for an input subsystem:
- Input device discovery using udev
- Input device hotplug (add/remove)
- Reading the evdev data from the devices
- Publishing input events to a callback through the eloop
- Suspending and resuming the input capture

Currently the delivered input events are basically just evdev's
"struct input_event" (type, code, value). More work is required to
have it pass out useful data.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 18:07:23 +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
e70a56b92e output: add debug and error messages
Print useful debug and error messages to the global log file.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 17:13:15 +01:00
David Herrmann
22da12c999 console: fix debug messages for buffer objects
It doesn't make sense to print the size of new buffer objects as the resize
function does the same. We also currently access uninitialized memory here so it
is useless anyway.
Also move the message of the unref function to be consistent with other objects.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 17:08:01 +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
290601396e output: allow kmscon_compositor_use to be called when asleep
There is no reason to prohibit a compositor from activating its GL context while
being asleep. It is even recommended to activate the GL context when being
asleep as there is no other way to initialize other subsystems without an GL
context.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 16:40:49 +01:00
David Herrmann
bb727640e9 output: fix dropping master priviledges on wakeup
If wakeup fails we should drop master priviledges again, otherwise we might
break other applications.

Also remove the SetMaster call on compositor initialization. It is redundant and
not needed by us.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-30 16:38:42 +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
068591e395 output: add helper to check whether output is awake
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>
2011-12-26 21:30:37 +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
676b03cb5c console: add newline function
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>
2011-12-26 14:24:31 +01:00