29 Commits

Author SHA1 Message Date
David Herrmann
a11d71a987 uterm: input: forward xkbcommon log messages
Instead of letting xkbcommon write to stderr, we now forward these
messages via the llog handler.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:25:18 +01:00
David Herrmann
37eae950f0 uterm: input: use shl_llog instead of shl_log
We should use library-logging in uterm to avoid cluttering stderr for
applications. Hence, use llog instead of log directly.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:23:26 +01:00
David Herrmann
8050a28beb uterm: input: add built-in keymap fallback
This adds a small US-keymap to the uterm library which is loaded if we
cannot find a suitable system default keymap. This allows using the keymap
if no XKB keymaps are installed.

Thanks to Ran Benita for the minimal US keymap.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:22:08 +01:00
Ran Benita
d240c27ecb kmscon: add --xkb-keymap option for predefined keymaps
This adds an --xkb-keymap <FILE> option to kmscon. When given, kmscon
will try to compile the keymap from the file before trying the other
options (like the XkbKeymap option in xorg.conf).

This is useful for users who have a customized XKB keymap, which is
usually kept in a single file. Example, in X:
	xkbcomp $DISPLAY my_keymap.xkb
Customize my_keymap.xkb to your liking, and then in .xinitrc, or
xorg.conf:
	xkbcomp my_keymap.xkb $DISPLAY
Now you can also do this in kmscon.conf.

Additionally, lacking such an option, kmscon is quite difficult to use
without an installed xkeyboard-config package, which provides the
infrastructure for the "rules" configuration mechanism. We might even
want to distribute some plain xkb file as a last ditch, for
robustness, if even the default RMLVO fails... without a keyboard a
terminal is not very useful.

(changed Ran's patch to use *_from_string() instead of *_from_file())
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-12 17:31:47 +01:00
David Herrmann
0249b2cb0b shl: move log.[ch] to shl_log.[ch]
We want to avoid any static files that are shared between multiple
programs but are not part of SHL. These make the build-process just more
complex.
Move log.[ch] to SHL so we have a known context.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-04 14:40:36 +01:00
David Herrmann
2047b56c80 uterm: move input related API to uterm_input.h
This splits off the uterm-input API from uterm.h to avoid depending on
uterm.h everywhere.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-07 19:22:38 +01:00
David Herrmann
9ad1438d55 uterm: move uterm_input.h to uterm_input_internal.h
We will split the public uterm header soon to avoid big headers. Hence,
rename internal headers to *_internal.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2013-01-07 13:18:06 +01:00
David Herrmann
98970835d9 uxkb: print warning if LED update fails
If we cannot write LED states to an input device, we should print proper
warnings instead of ignoring it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-09 22:06:51 +01:00
Ran Benita
75f59c54ba uterm: input: uxkb: properly handle changed keyboard state on wake up
Fix the problems caused by the keyboard state getting out-of-sync with
the xkb_state while the device is asleep (instead of the current hack).
The problem is described in a comment and in the removed FIXME.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-11-05 15:00:41 +01:00
David Herrmann
8f79d860c1 uterm: input: allow passing "model" for keyboard descs
We set the model to a system-default, which means, we are hosed if the
system-default is not what the user expects. Therefore, allow setting the
model via internal APIs.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-27 18:55:21 +02:00
Ran Benita
b5c05dd5f1 uterm_input_uxkb: update leds to match keyboard state
Upon device wakeup or led state changes, we update the keyboard LEDs to
match the new xkb state.

This means that every kmscon instance retains its own LED state, in the
users eyes. In other words, if you had Num Lock set on one kmscon, switched
to an X VT where it's off, and come back, then Num Lock will be set as
when you left. This is what X server, linux VT, etc. do.

Note that since we need to write the LED events to the evdev devices, we
need to open them RDWR. But since we don't really care what happens to
that write(), that's fine.

Also note that this means NumLock is off by default, which might be
annoying. We need to think how to get some 'setleds' or 'numlockx'
equivalent functionality.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-27 18:12:59 +02:00
Ran Benita
874bbbe17a uterm_input: remove supporting code for updating LED state
Before we transitioned to xkbcommon, we had some code that, upon
returning from a VT-switch, looked at the evdev led state and updated
the keyboard modifier state accordingly. So if we returned and NumLock
was on, we adjusted ourselves to that. That was pretty cute.

xkbcommon however doesn't support updating the state by LEDs like that.
Normally, the state of the LEDs is derived from the modifiers; going the
other way is tricky, error-prone and not used much. What we should be
doing is updating the LEDs according to *our* state.

This commit does the part of removing the unused dead code.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-27 18:08:05 +02:00
Ran Benita
2843c80c5b xkb: use system defaults instead of "us" for layout
libxkbcommon has a configure option to set the default values for the
RMLVO's (if they are passed as NULL or "" - we use "" so it'd be safe to
print). If they are not specified there, it's just "us" like we currently
do have. But if they are specified, we should most likely defer to it.

We do the same for the model field, instead of hardcoding "evdev". The
rules field remains hardcoded to "evdev", because we rely on it when
doing the evdev scancode-to-keycode +8 mapping.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-27 18:06:43 +02:00
Ran Benita
ae78864cc9 xkb: don't use deprecated libxkbcommon symbols
Now that libxkbcommon had a release, that has some API breakage (in
particular to xkb_keysym_from_name), we should update our code against
it and advise users to just use the xkbcommon release.

This should not happen anymore, for the foreseeable future at least.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-27 18:05:59 +02:00
David Herrmann
94f11b18b9 uterm: input: fix resetting key-repeat timer during key-press
We currently do not reset the key-repeat-delay when key-presses are
changed fast enough to fall into the repeat-rate range. Therefore, we
might get spurios key-repeats, even though the key itself wasn't held for
repeat-delay milliseconds.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-15 22:59:31 +02:00
David Herrmann
d904eb929a uterm: input: fix key-repeat handling
We currently do not handle modifier-changes during key-repeats. This is
odd as pressing shift should change a repeating key.

To avoid duplicating a lot of code, this patch puts most of the
key-handling into helper functions and cleans it up. We now handle all
kinds of key-repeat specialties and everything should work fine.

Reported-by: Ran Benity <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-12 01:22:47 +02:00
David Herrmann
b9b05283bf uterm: input: fix stopping key-repeats on key-up
A key-repeat is about keycodes, not keysyms. We repeat the keycode and the
events that are generated by it, so we must also stop repeating if the
given keycode is released.

This fixes a bug where a key would still be repeated if we press:
<a-down> - <Shift-down> - <a-up> - <Shift-up>

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-12 00:30:58 +02:00
David Herrmann
990881fa87 uterm: input: fix passing the correct keycode to get_ascii()
We need to pass the +8 shifted codes instead of the real hardware codes as
XKB needs these for X11 legacy reasons.

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-09 16:17:12 +02:00
David Herrmann
a17aa99ff9 kmscon: add --xkb-repeat-rate/delay command-line arguments
These new arguments allow changing the xkb-repeat settings for kmscon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-09 13:23:09 +02:00
David Herrmann
cbff71f6e2 uterm: input: implement software key-repeat
To allow users to specify key-repeat rates/delays, we now implement
software key-repeat. This is mostly copied from wlt_toolkit.c which
already does this.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-09 13:12:02 +02:00
David Herrmann
33ebc01441 tsm: vte: use ASCII keysyms for ctrl+<XY> shortcuts
If a user has multiple active XKB layouts but only one of them has ASCII
keysyms on the base level, then ctrl+<XY> might actually never work,
because these keys aren't available in the current layout. This patch
tries to find a layout of the user that actually _has_ ascii keysyms on
the base level and passes this information along with the normal keysym
information.

The TSM layer can now use this ascii keysym instead of the normal unicode
keysym to handle ctrl+<XY> shortcuts. This is the same way xterm et. al.
handle this, so it seems to be a good idea to do this in TSM, too.

Reported (and mainly written) by Ran Benita.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-09 12:30:40 +02:00
David Herrmann
0a03785ffc uterm: input: add support for multiple keysyms
xkbcommon supports reporting multiple keysyms per key-event. There is no
keymap which uses this, yet. However, this feature is not meant to enhance
performance by reducing the number of calls into xkb, but instead multiple
keysyms are to be handled as one big keysym.
But there are no examples, yet, so we cannot actually perform any
conversions on them. But we can add the infrastructure for it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-09 11:19:30 +02:00
David Herrmann
fba4b9104b uterm: input: use uxkb directly
This changes the uterm-input infrastructure to use XKB directly instead of
using a modularized infrastructure. There is no need to use something else
anymore.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-09 10:56:00 +02:00
David Herrmann
79ef4f9505 Move grab-parsing into conf.c
We really need to clean this up and allow parsing of grabs in conf.c
again. xkbcommon is now mandatory so we can fix all the input layers to
use it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-10-01 11:23:21 +02:00
David Herrmann
7f2d9dc4ff uterm: move uterm_internal.h to uterm_input.h
uterm_internal.h contains only input related content so we can rename it
and remove all the inclusions where it is not needed.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-09-11 19:16:54 +02:00
David Herrmann
3baeb6f04a uterm: input: uxkb: fix compile error in string_to_keysym()
Damnit, already pushed and not noticed this bug. Anyway, this fixes the
obvious typo in uxkb module.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-09-05 19:50:00 +02:00
David Herrmann
7ff4426bc3 uterm: input: add string_to_keysym() helper
This new helper can be used to convert a string description of a keysym
into a real keysym. This is required to allow users to configure keyboard
shortcuts and more.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-09-05 14:04:05 +02:00
David Herrmann
5aade75f3d uterm: uxkb: fix correctly resetting input state
We currently have a very subtle bug when modifiers are pressed while
leaving a terminal but released while entering. The internal state will
not be updated and as xkbcommon does not fix this up, we need to recreate
the state when re-entering the terminal.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-08-14 22:47:34 +02:00
David Herrmann
741b8d33df Refactor input backend-system
This is a rewrite of the input system. The backends itself are not
modified. However, it is now possible to have multiple backends and change
them on runtime.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-07-21 19:06:50 +02:00