212 Commits

Author SHA1 Message Date
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
09e15d84e8 console: add function to clear scrollback buffer
The new function can be used by the UI to clear the current scrollback
buffer to free resources or whatever. It will also be used by the CSI
handler to reset the console.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-02 16:47:43 +01:00
David Herrmann
3560ae8eb1 console: add function to set max scrollback buffer size
The maximum scrollback-buffer size can now be changed on the fly. We
also reduce the current buffer size to the new size so we do not need to
clear the console to flush the scrollback buffer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-02 16:43:15 +01:00
David Herrmann
bb918d9361 console: set sb_max to 0 by default
The scrollback-buffer maximum is 0 by default to avoid strange
hard-coded default values.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-02 16:33:00 +01:00
David Herrmann
54a552b852 console: allow scrollback-buffer maximum = 0
The scrollback buffer has a variable maximum of lines which can be set
by the application. We currently require it to be greater than 0. This
allows sb_max to be 0 so we can have a console buffer without a
scroll-back buffer.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-02 16:30:18 +01:00
Ran Benita
fb14273bf7 eloop: add timer support
Add support for dispatching events every given interval. timerfd is used
for hooking up to the event loop, similar to how signalfd is used.

Only relative, monotonic and possibly repeating timer events are
supported. It can be enhanced if there's ever a need.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-01 22:35:54 +01:00
David Herrmann
8fa3336a6b vte: add stub CSI parser
The new parser reads CSI parameters correctly and saves them in an array
for later evaluation. We currently do not handle the CSI commands. This
needs to be added now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-01 19:33:38 +01:00
David Herrmann
0e31653eb1 vte: parse basic control codes
This adds a parser for basic control codes but does not implement their
functionality, yet. Only the newline handler is kept.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-01 17:13:22 +01:00
David Herrmann
c4683b34ef vte: first check for special keys then for ucs4 char
We should first check whether we recognize the XK_* identifier before we
rely on the converted UCS4 character.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-01 16:03:54 +01:00
David Herrmann
23b7270790 vte: implement basic key mappings
The system keys are mapped to their ASCII equivalents. We do not support
CR/NL mode nor scroll-lock yet (is this supported by any term?).

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-02-01 15:59:53 +01:00
David Herrmann
d5c4d80562 doc: add VTE links and resources
The vte.txt file will contain information about the terminal emulator
used by KMSCON. Our main goal is xterm-compatibility but for now it
might be easier to try to be linux-console compatible.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-31 19:59:02 +01:00
David Herrmann
7a31fa98d6 pty: avoid 4KB buffers on the stack
Allocate the IO-buffer dynamically on the heap for every pty object to
avoid 4KB objects on the stack. This may not be a problem now but we
might get stack overflows later if we continue to use such huge arrays
on the stack.

This doesn't affect the runtime performance as the buffer is still
allocated only once on pty-creation.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-30 22:01:32 +01:00
Ran Benita
9d4cd66631 pty: increase input buffer size
Increase the buffer size to match the kernel's. This should guarantee
(practically) that we read() everything queued up for us.

This speeds us up considerably when running something like
$ find /
Such a process spends most of its time blocking on write() waiting for
us. By increasing the buffer size we avoid repeated
read pty -> draw screen -> read pty
cycles, which take most of our time.

To time it, before:
real  0m22.588s
user  0m00.000s
sys   0m00.020s

After:
real  0m00.680s
user  0m00.023s
sys   0m00.000s

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-30 20:51:27 +01:00
Ran Benita
9c97408910 kbd: correctly initialize refcount
The ->ref field was always zero and so the object was never released.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-30 20:48:31 +01:00
Ran Benita
6eb0f706d7 xkb: fix invalid read from uninitialized memory
The memset was missing a sizeof(..) multiplication.

Really the entire function is more complex than need be, so simplify it.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-30 20:48:13 +01:00
David Herrmann
f8b17b1ffc Remove TODO
The TODO is now located in the wiki at github.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-29 17:10:51 +01:00
David Herrmann
e138e4ada0 vte: handle keyboard "return"/linefeed
This makes the VTE subsystem emulate a linefeed if XK_Return is read
from the keyboard.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-29 14:51:35 +01:00
David Herrmann
ff0e91ec45 terminal: use UTF8 state machine
This adds a converter from UTF8 stream to UCS4 data so the VTE subsystem
can handle the input correctly without complicated UTF8 input.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-29 14:23:27 +01:00
David Herrmann
885bdef87b pty: change callback parameters to "const xy"
There is no reason to allow the callbacks to modify our internal data so
make it constant.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-29 14:22:48 +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
046d397987 unicode: add utf8 state machine
The state machine is used to convert a stream of UTF8 data into UCS4
characters. It is slightly based on the machine found in the
wayland-compositor demos.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-29 14:19:49 +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
55d4132931 console: add header protection
The header was missing a #ifndef to protect against multiple inclusions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 18:08:10 +01:00
David Herrmann
f63eaffc95 pty: remove unneeded variable in setup_child
We can use "ret" instead of "saved_errno" here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 17:43:26 +01:00
David Herrmann
d8d0e24a22 pty: move fork_pty_child to setup_child
The name fork_pty_child was misleading. It doesn't fork at all but
instead sets up the child's environment.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 17:39:20 +01:00
David Herrmann
31fc374065 pty: avoid FIONREAD ioctl
This ioctl is really not needed and performs needles kernel context
switches. We can simply read into our buffer without checking how many
data is available.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 17:23:49 +01:00
David Herrmann
229b4bfde2 pty: buffer data between pty and child
If the child returns EWOULDBLOCK on write we need to save the input in a
buffer to avoid loosing data. We need to work in non-blocking mode to
avoid UI hangs so we simply use the new ring-buffer object to store
data.

This also changes the callback behavior. The pty is no longer closed
implicitely so the owner must call pty_close now even if the close
callback is called. This avoids circular callbacks.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 17:17:20 +01:00
David Herrmann
2c8622d468 Add ring buffer object
The new ring buffer object will be used to buffer a byte-stream between
two sockets.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 17:16:37 +01:00
David Herrmann
ecb7ddbc29 pty: merge input and close callbacks
There is no reason to keep two callbacks as the caller always registers
both. Hence, we can use a shared callback. Reading length 0 means closed
like reading from an fd.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 14:03:52 +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
9b4c6c5542 pty: move output_cb to input_cb
The output_cb handles output from the pty but it actually makes more
sense to call it input_cb as we are handling input to our console here.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 13:45:06 +01:00
David Herrmann
cda62d3e60 pty: move pty_input to pty_write
pty_write actually makes more sense as we are writing to the other end
and not reading input.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 13:44:25 +01:00
David Herrmann
c3d2ea3eb2 pty: fix style issue
Fix small indentation style issue.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 13:43:09 +01:00
David Herrmann
57bb28b1b4 pty: merge fork_pty and pty_spawn
pty_spawn was just a short wrapper so we can merge both into one
function.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 13:22:44 +01:00
Ran Benita
d480ec1030 pty: unblock all signals before exec'ing the child
When we register signals in the eloop we also block them in our signal
mask. The signal mask is inherited by the child. Therefore, if the child
does not reset its mask (e.g. bash and most normal processes), it will
not receive any of the signals that we handle. So for example C-c
(SIGINT) does nothing in the child process.

We now unblock all signals before we exec the child.

It's also worth noting that if we _ignore_ a signal -
sigaction(SIG_IGN) - this is also inherited and we must reset it to
default. However, we do not ignore signals so this is unneeded.

Here is some more discussion on signalfd and this problem:
https://lwn.net/Articles/415684/

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 12:54:22 +01:00
David Herrmann
beb4301830 kbd-dumb: fix log_warning -> log_warn
We recently moved log_warning to log_warn and I forgot to fix it when
merging the kbd-dumb backend. Fix this now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 12:38:11 +01:00
Ran Benita
647d666da3 build: fix out-of-tree build and distcheck
The paths can be off when building out of tree, so have make put them in
for us instead. This requires turning the straight genshader.c file to a
template.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 12:29:49 +01:00
Ran Benita
510e53376a kbd: add a new "dumb" keyboard backend
This commit adds a very simple keyboard backend which does basic keycode
interpretation. It is used as a fallback when xkbcommon is unavailable
or is not required.

See the file header for what is supported.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 12:28:19 +01:00
Ran Benita
83dd9a6cfa build: depend on xproto explicitly
Currently it's required by xkbcommon. However, we will need it for other
backends as well, even with xkbcommon support disabled.

xproto consisted only of static header files. We use the XK_ keysym
definitions. It is therefore only required during compilation and we
shouldn't needlessly duplicate it ourselves.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 12:20:04 +01:00
David Herrmann
5cc56b8e3c xkb: fix merge failure
Merging the big xkb cleanup reversed the previous modifier state change.
Fix this now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-28 12:14:48 +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
David Herrmann
8e6803ed0a context: use GL_RGBA when full OpenGL is used
GL_BGRA_EXT as internal format is not supported with full OpenGL so we
must use GL_RGBA as internal format.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-24 15:14:15 +01:00
David Herrmann
4d34890cde eloop: remove verbose debug messages
These dispatch debug messages are currently no longer needed and just
fill the log needlessly.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-24 15:10:16 +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
c63a5f2b95 Add pseudo terminal support
This commit adds a new pty object.

The pty object takes care of all pseudo terminal handling, reading and
writing. It can be opened and closed, and notify through callbacks when
input arrives or the child process exits/dies. It can also receive input
and pass it along to the child process.

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>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-23 14:02:43 +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
Ran Benita
9b75aa0b9d input, xkb: port to new kbd object
This commit ports the XKB handling to the new kbd interface, and makes
the input subsystem use it without any direct knowledge of XKB.

Some code is moved around but there are no functional changes.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-23 13:49:41 +01:00
Ran Benita
7cf93b8930 Add skeleton for multiple keyboard handling backends
This defines the API the keyboard backends will need to implement. It is
based on what's in input_xkb.h but cleaned up and simplified.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-23 13:44:07 +01:00
David Herrmann
629221b060 font: add debug messages
Add debug messages to freetype font backend.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-01-22 22:49:33 +01:00