platform/upstream/kmscon.git
11 years agouterm: vt: set K_RAW before trying K_OFF
David Herrmann [Sun, 2 Dec 2012 09:18:15 +0000 (10:18 +0100)]
uterm: vt: set K_RAW before trying K_OFF

K_OFF is not available on older kernels and it is currently discussed
whether it should be replaced on newer kernels. Therefore, set K_RAW
before trying K_OFF and then ignore errors if K_OFF cannot be set.

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: fix delayed deactivation to update internal state
David Herrmann [Sun, 2 Dec 2012 09:16:24 +0000 (10:16 +0100)]
cdev: fix delayed deactivation to update internal state

We need to set "active" to false during delayed deactivation, as
otherwise we have inconsistent state in respect to the seat subsystem.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotsm: vte: ignore DEC SET/RESET 12 mode
David Herrmann [Sun, 2 Dec 2012 09:15:40 +0000 (10:15 +0100)]
tsm: vte: ignore DEC SET/RESET 12 mode

This mode is used to start/stop blinking cursors. As vim uses this
heavily, we should simply ignore it to avoid printing useless debug
messages.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: ignore keyboard shortcuts in single-session mode
David Herrmann [Sat, 1 Dec 2012 22:45:55 +0000 (23:45 +0100)]
seat: ignore keyboard shortcuts in single-session mode

Instead of not handling the keyboard shortcuts we should ignore them but
mark them as handled. Otherwise, we might get them from the parent session
and they will end up cluttering the terminal log.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: implement VT_WAITACTIVE
David Herrmann [Sat, 1 Dec 2012 18:06:38 +0000 (19:06 +0100)]
cdev: implement VT_WAITACTIVE

The VT API provides a VT_WAITACTIVE ioctl which waits until the VT got
activated. We use the same technique as with blocking reads() to implement
this without threads.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: fix unregistering display callbacks when removing screens
David Herrmann [Sat, 1 Dec 2012 17:22:38 +0000 (18:22 +0100)]
terminal: fix unregistering display callbacks when removing screens

We must unregister the display callback when removing a screen. Otherwise,
we keep writing to the screen memory which becomes invalid then.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: change default keyboard shortcuts to ctrl+logo
David Herrmann [Sat, 1 Dec 2012 16:39:38 +0000 (17:39 +0100)]
seat: change default keyboard shortcuts to ctrl+logo

ctrl+alt is already used by many other applications so lets use some other
unused shortcut modifiers.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconf: introduce --configdir parameter
David Herrmann [Sat, 1 Dec 2012 15:21:33 +0000 (16:21 +0100)]
conf: introduce --configdir parameter

The --configdir parameter allows specifying another configuration
directory than the default /etc/kmscon.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: limit multi-session mode to --multi-session
David Herrmann [Sat, 1 Dec 2012 15:09:14 +0000 (16:09 +0100)]
seat: limit multi-session mode to --multi-session

If kmscon is started without the --multi-session option, we no longer
provide multi-session support (now the default). This is for better
backwards compatibility to agetty and friends.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconf: print warning if --vt is used wrong
David Herrmann [Sat, 1 Dec 2012 14:46:42 +0000 (15:46 +0100)]
conf: print warning if --vt is used wrong

--vt should only be used when kmscon runs on a single seat. Otherwise,
this VT will be forced on all seats and each kmscon instance _might_
collide.
If this is done with care, the --vt/--seats combination can work. However,
the use-cases are negligible and we should rather warn the ordinary user
not to do it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: use real VTs on all seats if available
David Herrmann [Sat, 1 Dec 2012 14:25:37 +0000 (15:25 +0100)]
uterm: vt: use real VTs on all seats if available

If there is already a kmscon instance running that provides fake-VTs, then
lets use it. This allows stacking kmscon processes and is very useful for
debugging.

Also other applications that use uterm can now run inside of kmscon
without any other special configuration.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: register cdev session only when --cdev is given
David Herrmann [Sat, 1 Dec 2012 14:05:07 +0000 (15:05 +0100)]
seat: register cdev session only when --cdev is given

We cannot have multiple instances of kmscon running with cdev emulation,
so disable it by default. A kmscon-system-daemon now needs --cdev if you
want fake VTs to work.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoconf: fix whitespace offset for -s
David Herrmann [Sat, 1 Dec 2012 13:50:53 +0000 (14:50 +0100)]
conf: fix whitespace offset for -s

Align everything to the same offset.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: downgrade error to debug message on I/O errors
David Herrmann [Sat, 1 Dec 2012 12:15:01 +0000 (13:15 +0100)]
pty: downgrade error to debug message on I/O errors

I/O errors aren't fatal or important on PTYs so ignore them and mark it as
debug message.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: fix typo in warning
David Herrmann [Sat, 1 Dec 2012 12:11:39 +0000 (13:11 +0100)]
cdev: fix typo in warning

Obvious typo. Got those words swapped...

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: clear displays during sleep and wakeup
David Herrmann [Wed, 28 Nov 2012 21:54:46 +0000 (22:54 +0100)]
uterm: clear displays during sleep and wakeup

We shouldn't leave the content on the framebuffers when leaving kmscon.
This might confuse the user. Furthermore, we shouldn't reload the old
framebuffer during wakeup as this frame can be quite old and we see a
short flickering during wakeup which isn't wanted, either.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: set DPMS to ON before broadcasting the device
David Herrmann [Wed, 28 Nov 2012 21:21:33 +0000 (22:21 +0100)]
seat: set DPMS to ON before broadcasting the device

We cannot modeset a device while DPMS is set to OFF so we should do this
before broadcasting the device. Otherwise, the callback might not be able
to use the display.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agomain: correctly remove all displays on uterm-video shutdown
David Herrmann [Wed, 28 Nov 2012 21:16:07 +0000 (22:16 +0100)]
main: correctly remove all displays on uterm-video shutdown

If we close an uterm-video object, we must correctly remove all displays
first.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: check swapping state during activation
David Herrmann [Wed, 28 Nov 2012 21:14:05 +0000 (22:14 +0100)]
terminal: check swapping state during activation

If a terminal gets activated while a swap-buffer operation is still in
progress from the previous session, we must not directly reschedule it.
Instead, we wait for the page-flip event and continue then.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: activate displays only when being in foreground
David Herrmann [Wed, 28 Nov 2012 20:55:50 +0000 (21:55 +0100)]
seat: activate displays only when being in foreground

We shouldn't activate displays when we are active but in background. In
these moments, the uterm-video device might not be initialized, yet.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: remove now unused --fps option
David Herrmann [Wed, 28 Nov 2012 19:57:36 +0000 (20:57 +0100)]
terminal: remove now unused --fps option

We no longer have a framerate-control option so remove it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: sync redraw events with vertical blanks
David Herrmann [Wed, 28 Nov 2012 19:51:30 +0000 (20:51 +0100)]
terminal: sync redraw events with vertical blanks

We used an FPS timer to control redraw events but this caused some
unwanted artifacts. Instead, we should always wait for the page-flip event
before redrawing the screen.

This can still be optimized (for instance via triple-buffering) but it
works very nice now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: keep terminal reference in each screen
David Herrmann [Wed, 28 Nov 2012 18:31:09 +0000 (19:31 +0100)]
terminal: keep terminal reference in each screen

We need to have a terminal reference in future screen callbacks so keep
one from the beginning.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: fix ignoring HUP on pty-master files
David Herrmann [Wed, 28 Nov 2012 16:47:31 +0000 (17:47 +0100)]
pty: fix ignoring HUP on pty-master files

A HUP is reported whenever there is no client listening on the other side
of the PTY. As /bin/login and friends call vhangup() during setup, there
is a short time-span when we might get a HUP.
Hence, we need to ignore HUPs and solely track clients by PID. To avoid
hogging the CPU while the TTY is hungup, we change the event-mode to
edge-triggered.

This fixes a bug where we tried starting /bin/login several times because
we always ran into this race-condition and directly closed the TTY again.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoeloop: allow edge-triggered operation
David Herrmann [Wed, 28 Nov 2012 16:46:18 +0000 (17:46 +0100)]
eloop: allow edge-triggered operation

A new EV_ET flag allows ev_fd sources to operate in edge-triggered instead
of level-triggered mode. See epoll(7) for more information.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agopty: remove unused "master" argument
David Herrmann [Tue, 27 Nov 2012 18:02:48 +0000 (19:02 +0100)]
pty: remove unused "master" argument

We do not use the master pty fd when spawning the child so skip it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoeloop: fix not disabling sources on EV_HUP
David Herrmann [Tue, 27 Nov 2012 18:00:57 +0000 (19:00 +0100)]
eloop: fix not disabling sources on EV_HUP

We used to disable event sources on EV_HUP to avoid draining the
event-queue for non-edge-triggered sources. However, this turns out to be
not working with special files so we disable it again.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: video: add uterm_display_is_swapping() helper
David Herrmann [Mon, 26 Nov 2012 16:19:45 +0000 (17:19 +0100)]
uterm: video: add uterm_display_is_swapping() helper

This new helper can be used to check whether a display has a pending
vsync'ed buffer-flip scheduled.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: video: remove uterm_screen API
David Herrmann [Mon, 26 Nov 2012 16:11:07 +0000 (17:11 +0100)]
uterm: video: remove uterm_screen API

The uterm_screen API is no longer used internally and we do not plan to
extend it. So we can use uterm_display as a replacement to make the API
thinner and easier to use.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotest_output: use uterm_display directly
David Herrmann [Mon, 26 Nov 2012 16:10:44 +0000 (17:10 +0100)]
test_output: use uterm_display directly

uterm_screen is scheduled for removal so use the display API directly.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: use uterm_display directly
David Herrmann [Mon, 26 Nov 2012 15:50:39 +0000 (16:50 +0100)]
text: use uterm_display directly

Instead of using the uterm-screen indirection, we now directly access
uterm-display objects. We do not really intend to use virtual screens with
kmscon so there is no need to make this more complex.

I don't think consoles should every provide this feature. Instead, you
should use real compositors for such tasks like Wayland+wlterm. kmscon,
however, is rather an emergency tool or a safe backup than a fancy
daily-use-console.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoui: remove old unused UI subsystem
David Herrmann [Tue, 20 Nov 2012 13:30:54 +0000 (14:30 +0100)]
ui: remove old unused UI subsystem

The UI subsystem was replaced by the seat subsystem and is no longer used.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotsm: handle ISO_Left_Tab
David Herrmann [Mon, 19 Nov 2012 15:26:38 +0000 (16:26 +0100)]
tsm: handle ISO_Left_Tab

If Shift+Tab is pressed, most keyboard layouts map this to ISO_Left_Tab
which itself should be converted to \e[Z.

Reported-by: Vladimir Kravets
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: implement fake-VT-switching
David Herrmann [Mon, 19 Nov 2012 15:14:38 +0000 (16:14 +0100)]
cdev: implement fake-VT-switching

This implements VT switching for cdev sessions. This allows to run
external applications as sessions inside of kmscon.

This should only be used for backwards compatibility. There is really no
reason to develop new applications to do this. Instead, use
system-compositors which make all the work for you!

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: add --grab-session-dummy option
David Herrmann [Mon, 19 Nov 2012 15:11:34 +0000 (16:11 +0100)]
seat: add --grab-session-dummy option

This option specifies a shortcut that can be used to schedule the dummy
session on the given seat.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: add helpers to schedule sessions from the outside
David Herrmann [Mon, 19 Nov 2012 15:10:01 +0000 (16:10 +0100)]
seat: add helpers to schedule sessions from the outside

Two new helpers to schedule a specific session or a session given by a
hint-number. These can be used by other subsystems to schedule
their/others sessions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: remove "manual input" logic
David Herrmann [Mon, 19 Nov 2012 15:07:34 +0000 (16:07 +0100)]
seat: remove "manual input" logic

This really doesn't make sense. We no longer want the applications to be
in charge of VT switches so always force the VT-master to be in control of
the VT-switching logic.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: allow scheduling dummy session
David Herrmann [Mon, 19 Nov 2012 15:03:57 +0000 (16:03 +0100)]
seat: allow scheduling dummy session

We always considered the dummy session to be no real session. However,
under special circumstances it might be desirable to schedule the dummy
session (very important for debugging). Therefore, change the logic to
allow scheduling the dummy session.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: fix input-device sleep-control
David Herrmann [Mon, 19 Nov 2012 14:57:35 +0000 (15:57 +0100)]
uterm: vt: fix input-device sleep-control

We need to correctly put input devices asleep only if we really disable
the VT. If our callbacks fail and prevent the VT-switch, we must keep the
input devices awake. Otherwise, we will lose control over the
sleep-states.

Also correctly put the device asleep during shutdown.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoshl: array: use "const" for source arguments
David Herrmann [Mon, 19 Nov 2012 12:54:17 +0000 (13:54 +0100)]
shl: array: use "const" for source arguments

Use "const" even for void pointers as gcc will complain otherwise. Source
arguments are read-only, anyway, so this doesn't break anything.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: be more verbose on asynchronous session switching
David Herrmann [Mon, 19 Nov 2012 12:18:53 +0000 (13:18 +0100)]
seat: be more verbose on asynchronous session switching

Print debug messages when doing asynchronous session switches and handle
EINPROGRESS as special error code.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: fix delayed VT switches
David Herrmann [Mon, 19 Nov 2012 12:13:01 +0000 (13:13 +0100)]
seat: fix delayed VT switches

If we switch VT and the current session cannot be put asleep, and later it
notifies us that it went asleep, we should then switch VT and not
reschedule the sessions.

We do this by remembering whether a VT switch is pending. The new
uterm-retry infrastructure allows us to easily repeat VT switches then.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: fix calling parent-callbacks on forced sleeping
David Herrmann [Mon, 19 Nov 2012 12:12:10 +0000 (13:12 +0100)]
seat: fix calling parent-callbacks on forced sleeping

If we force a seat to go asleep, we should _always_ notify the parent
about this. Otherwise, we might get unexpected results.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: allow sessions to switch between background/foreground
David Herrmann [Mon, 19 Nov 2012 12:10:51 +0000 (13:10 +0100)]
seat: allow sessions to switch between background/foreground

Two new helpers allow sessions to mark them as background and foreground
sessions. This will immediately switch them into the new state.

The internal infrastructure was already available, but we currently always
used foreground sessions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: allow sessions to control VT-switches
David Herrmann [Mon, 19 Nov 2012 12:06:43 +0000 (13:06 +0100)]
seat: allow sessions to control VT-switches

A new helper allows sessions to manually handly input events so the core
does no longer perform session/VT switches on their behalf.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: implement delayed VT-switches
David Herrmann [Mon, 19 Nov 2012 12:04:15 +0000 (13:04 +0100)]
uterm: vt: implement delayed VT-switches

If we cannot immediately perform a VT switch away from our application, we
might want to retry this shortly after. Therefore, we can now call
uterm_vt_retry() which then performs any outstanding VT-switches.

To avoid unexpected behavior, we limit this to a 2-3 second delay.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: do nothing if VT-switch targets our VT
David Herrmann [Mon, 19 Nov 2012 12:01:57 +0000 (13:01 +0100)]
uterm: vt: do nothing if VT-switch targets our VT

If the user presses some keys to switch VTs and the target VT is our VT
(which is already active in this case), we shouldn't do anything. Calling
VT_ACTIVATE doesn't particularly hurt, but it doesn't get us anything
here so skip it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: do nothing if target-VT is already active during deactivation
David Herrmann [Mon, 19 Nov 2012 12:00:38 +0000 (13:00 +0100)]
uterm: vt: do nothing if target-VT is already active during deactivation

If we deactivate our VT and the target-VT is already active (probably
because we opened the _current_ VT during uterm-vt creation), we shouldn't
do anything but simply close the VT.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: fix forwarding errors in seat_pause()
David Herrmann [Sat, 17 Nov 2012 19:25:29 +0000 (20:25 +0100)]
seat: fix forwarding errors in seat_pause()

If we force a pause we need to forward the error code. Otherwise, we
cannot properly react on it and print warnings.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: allow calling go_foreground if already in foreground
David Herrmann [Sat, 17 Nov 2012 19:13:27 +0000 (20:13 +0100)]
seat: allow calling go_foreground if already in foreground

If we are asleep and in foreground, go_foreground() should return success
so we can safely unload asynchronous sessions. Otherwise, we wouldn't be
able to handle them properly while being inactive or we would need a whole
bunch of other checks.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: do not check SIGUSR1/2 for SI_KERNEL
David Herrmann [Sat, 17 Nov 2012 18:45:44 +0000 (19:45 +0100)]
uterm: vt: do not check SIGUSR1/2 for SI_KERNEL

If we want to run as client under user-space fake-VT implementations like
kmscon-cdev, we need to be able to catch those signals from
userspace-daemons. Therefore, do not check whether the signals were
generated by the kernel.

This doesn't affect security in any way as non-priviledged processes
aren't allowed to send signals, anyway. Moreover, this increases
debugability of VT layers a lot as we can fake these signals now.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agobuild: fix wlterm wayland-dependency check
David Herrmann [Sat, 17 Nov 2012 18:42:57 +0000 (19:42 +0100)]
build: fix wlterm wayland-dependency check

The logic behind this two-layer check is bogus and doesn't work. Merge
both layers so we have a proper dependency-check again. This will make the
error messages less verbose but at least it works again.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: remove bogus debug statements
David Herrmann [Sun, 11 Nov 2012 11:17:11 +0000 (12:17 +0100)]
seat: remove bogus debug statements

These shouldn't be pushed into the public repository. Sorry.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotest_vt: add --switchvt option
David Herrmann [Sun, 11 Nov 2012 10:39:38 +0000 (11:39 +0100)]
test_vt: add --switchvt option

This has the same effect as for kmscon but is disabled by default.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotest_vt: add --vt=<path> option
David Herrmann [Sun, 11 Nov 2012 10:37:17 +0000 (11:37 +0100)]
test_vt: add --vt=<path> option

This new option allows specifying a path to the VT that should be used.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotest_vt: remove trailing newline in log-message
David Herrmann [Sun, 11 Nov 2012 10:36:38 +0000 (11:36 +0100)]
test_vt: remove trailing newline in log-message

The log-subsystem adds these automatically so we shouldn't use them.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotest_vt: use a dummy input-object
David Herrmann [Sun, 11 Nov 2012 10:35:15 +0000 (11:35 +0100)]
test_vt: use a dummy input-object

We cannot allocate VT objects without an associated input object.
Therefore, allocate a dummy device with no input devices assigned to it
and use it for the test-vt object.

Note that this makes switching from/to this VT via command-line
impossible.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: fix not overwriting 'ret' in error paths
David Herrmann [Sun, 11 Nov 2012 10:33:19 +0000 (11:33 +0100)]
uterm: vt: fix not overwriting 'ret' in error paths

We cannot use 'ret' in error paths, otherwise, we might return 0. This
might then cause instabilities as the objects weren't initialized
correctly.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: do not modify TTY settings
David Herrmann [Sat, 10 Nov 2012 17:11:16 +0000 (18:11 +0100)]
uterm: vt: do not modify TTY settings

We do not use the TTY for anything except VT functions. Hence, there is no
need to modify the TTY settings before using it.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: allow sessions to notify seat when deactivating
David Herrmann [Sat, 10 Nov 2012 15:57:04 +0000 (16:57 +0100)]
seat: allow sessions to notify seat when deactivating

If a session is deactivated asynchronously, it can now notify the seat
when it is done. This will then cause a re-schedule of the session list.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: implement delayed session switching
David Herrmann [Sat, 10 Nov 2012 15:46:58 +0000 (16:46 +0100)]
seat: implement delayed session switching

If we want to allow external programs to control sessions inside of
kmscon, we need to give them some time for session
activation/deactivation. Therefore, the whole session-management is
asynchronous now and allows the session code to return EINPROGRESS or
similar if they need more time.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoshl: dlist: fix *_but_one() loops to allow "start == head"
David Herrmann [Sat, 10 Nov 2012 15:42:42 +0000 (16:42 +0100)]
shl: dlist: fix *_but_one() loops to allow "start == head"

If we iterate over a non-empty list and pass the same pointer for start
and head, then we will never leave that loop.

It might be unclear why this is supported at all as we can simply use the
shl_dlist_for_each() for that. However, it makes code a lot easier to read
if the user can simply use shl_dlist_for_each_but_one() without checking
whether they passed the same for start and head.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: gltex: use bold fonts
David Herrmann [Thu, 8 Nov 2012 13:16:28 +0000 (14:16 +0100)]
text: gltex: use bold fonts

Make the gltex renderer use bold fonts for bold characters. Internally, we
use a separate hashtable to cache all glyph information. As the hash-key
is the unicode ID, we have to use a separate table for bold glyphs. This
doesn't affect performance, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: bblit: use bold fonts
David Herrmann [Thu, 8 Nov 2012 12:59:10 +0000 (13:59 +0100)]
text: bblit: use bold fonts

This makes the bblit renderer use bold fonts for bold characters.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: bbulk: implement bold-char renderer
David Herrmann [Thu, 8 Nov 2012 12:56:09 +0000 (13:56 +0100)]
text: bbulk: implement bold-char renderer

Instead of always using the regular font, we now use the bold font for
bold characters.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoterminal: allocate bold fonts
David Herrmann [Thu, 8 Nov 2012 12:55:04 +0000 (13:55 +0100)]
terminal: allocate bold fonts

This makes the terminal layer allocate bold fonts (and use normal fonts as
fallback) and pass it to the text layer. This allows the text layer to
actually draw bold characters.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agotext: add bold font as separate font object
David Herrmann [Thu, 8 Nov 2012 12:40:37 +0000 (13:40 +0100)]
text: add bold font as separate font object

We now allow the user to specify the font that is used for bold
characters. If NULL is given, the normal font is used.

The bold font is not used by any renderer backend, yet, but will be hooked
up later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoAdd kmscon@.service
Matthew Monaco [Mon, 5 Nov 2012 04:30:42 +0000 (21:30 -0700)]
Add kmscon@.service

This almost certainly can be optimized, but we should be able to mask
getty@.service with kmscon@.service.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: input: uxkb: properly handle changed keyboard state on wake up
Ran Benita [Mon, 29 Oct 2012 19:52:54 +0000 (21:52 +0200)]
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>
11 years agouterm: input: don't test device capability in wakeup_dev
Ran Benita [Mon, 29 Oct 2012 20:00:16 +0000 (22:00 +0200)]
uterm: input: don't test device capability in wakeup_dev

The current code ignores non-keyboard devices, and various places
implicitly assume that it does. If we ever need finer granularity, we
should review (and probably restructure) the code for that; but for now
this test seems out of place.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: avoid blocking SIGUSR1/2 twice
David Herrmann [Mon, 5 Nov 2012 13:52:25 +0000 (14:52 +0100)]
uterm: vt: avoid blocking SIGUSR1/2 twice

eloop does already block signals that we register callbacks for so we do
not have to block it manually here.
Note that the signal-handlers are registered _before_ doing the backend
initialization so we also avoid the previously fixed race-condition.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: keep graphics mode during VT switch
David Herrmann [Mon, 5 Nov 2012 13:47:38 +0000 (14:47 +0100)]
uterm: vt: keep graphics mode during VT switch

If we open a VT, we assume that we are the only user on it. Therefore, we
put it into graphics mode _once_ and keep it this way. Resetting it to
text mode is useless, as there is no other user and every VT has its own
modes.

This also fixes page-flip issues during VT-switches which caused the
text-mode fbdev layer to claim one vertical-sync for their own page-flip
only for us to override it immediately after it is done.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: add fake_open/close() helpers
David Herrmann [Mon, 5 Nov 2012 13:45:22 +0000 (14:45 +0100)]
uterm: vt: add fake_open/close() helpers

Instead of doing the backend initialization directly in uterm_vt code, we
now use fake_* helpers similar to real_* helpers.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: allow VT-deactivation to fail
David Herrmann [Mon, 5 Nov 2012 13:18:41 +0000 (14:18 +0100)]
uterm: vt: allow VT-deactivation to fail

If we dispatch VT-deactivation to child-processes, we might allow them to
abort the VT-switch, so the upper layer (uterm_vt) must also allow us to
abort the VT-switch.
During shutdown, we need to force the deactivation to guarantee that a VT
is inactive during shutdown.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoseat: clean up session-callback function type
David Herrmann [Fri, 2 Nov 2012 17:25:49 +0000 (18:25 +0100)]
seat: clean up session-callback function type

We use structures to pass information in all callbacks so we always get 3
arguments: parent, parameters, data
Also change the return type to int so we can catch errors when changing
session stati.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: implement KDSKBMODE/KDGKBMODE ioctls
David Herrmann [Mon, 29 Oct 2012 20:08:15 +0000 (21:08 +0100)]
cdev: implement KDSKBMODE/KDGKBMODE ioctls

These ioctls change/retrieve the keyboard mode. We only support K_UNICODE,
K_RAW and K_OFF. Even K_RAW isn't supported fully as it is unclear what it
is supposed to do.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: implement KDSETMODE/KDGETMODE ioctl stubs
David Herrmann [Mon, 29 Oct 2012 19:49:41 +0000 (20:49 +0100)]
cdev: implement KDSETMODE/KDGETMODE ioctl stubs

These ioctls are used to change from TEXT to GRAPHICS mode. We currently
do not support GRAPHICS mode correctly, but this will be added later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agocdev: implement basic ioctl() stubs
David Herrmann [Mon, 29 Oct 2012 19:35:36 +0000 (20:35 +0100)]
cdev: implement basic ioctl() stubs

This commit adds stubs for every ioctl() that we need to support so an
xserver can run on this fake VT.
There are a lot more ioctl()s that can be invoked on TTYs and VTs, but we
currently do not intend to support these. If there is an application that
uses these and it makes sense to run it under kmscon, we will add the
needed ioctls.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoshl: ring: add shl_ring_flush() helper
David Herrmann [Mon, 29 Oct 2012 19:34:52 +0000 (20:34 +0100)]
shl: ring: add shl_ring_flush() helper

This helper flushes all messages from the ring buffer and releases the
memory.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agobuild: fix typo in configure.ac regarding cdev-sessions
David Herrmann [Mon, 29 Oct 2012 19:34:03 +0000 (20:34 +0100)]
build: fix typo in configure.ac regarding cdev-sessions

A missing "test" keyword causes bash to fail executing this statement. Fix
this.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: enable --all-gpus by default
David Herrmann [Mon, 29 Oct 2012 17:29:52 +0000 (18:29 +0100)]
kmscon: enable --all-gpus by default

Users with multiple GPUs that cannot be used simultaneously should pass
--no-all-gpus if they encounter problems or use --video-devices
explicitly. However, we cannot rely on PRIMARY flags being set for all
kinds of setups. Instead, default behavior should be using all available
GPUs unconditionally (except the safe DRM_BACKED and fbdev PRIMARY logic).

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: monitor: put systemd-layer into separate file
David Herrmann [Mon, 29 Oct 2012 17:09:35 +0000 (18:09 +0100)]
uterm: monitor: put systemd-layer into separate file

This moves all systemd code into uterm_systemd.[ch]. This removes all the
ugly #ifdef's.

Furthermore, this fixes some hidden bugs in the previous implementation
and makes use of sd_booted() to see whether runtime systemd is really
available.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: fix real VTs when opening the currently active VT
David Herrmann [Sun, 28 Oct 2012 16:38:28 +0000 (17:38 +0100)]
uterm: vt: fix real VTs when opening the currently active VT

We always assumed that the currently active VT is never the VT we open.
However, this is not true so schedule a VT-activation if this happens.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: drm: fix device-detection if no master is active
David Herrmann [Sun, 28 Oct 2012 16:37:18 +0000 (17:37 +0100)]
uterm: drm: fix device-detection if no master is active

If we try to detect a device name if no master is active, the
drmGetBusid() call will always return an empty string. Therefore, try to
become drm-master and set the correct interface version before doing this.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: put input devices asleep when inactive
David Herrmann [Sun, 28 Oct 2012 15:56:50 +0000 (16:56 +0100)]
uterm: vt: put input devices asleep when inactive

There is no need to keep the input-devices around while another VT is
active.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: input: fix stopping key-repeat when going asleep
David Herrmann [Sun, 28 Oct 2012 15:54:07 +0000 (16:54 +0100)]
uterm: input: fix stopping key-repeat when going asleep

We need to stop each key-repeat when putting input-devices to sleep.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: vt: fix race by blocking signals before setting them
David Herrmann [Sun, 28 Oct 2012 15:17:18 +0000 (16:17 +0100)]
uterm: vt: fix race by blocking signals before setting them

We must block the signals before setting the signal handlers to avoid
retrieving them asynchronously.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: drm: clear new buffers after allocation
David Herrmann [Sun, 28 Oct 2012 15:11:06 +0000 (16:11 +0100)]
uterm: drm: clear new buffers after allocation

Framebuffers are not guaranteed to be cleared after we allocate them.
Therefore, clear them as all the other uterm-video backends do.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: change default grab for "sesison-close" to "BackSpace"
David Herrmann [Sun, 28 Oct 2012 15:06:26 +0000 (16:06 +0100)]
kmscon: change default grab for "sesison-close" to "BackSpace"

Session management should be done with global keys. This allows us to use
the known "w", "t", "n" keys for "close", "new tab", "new window" etc.
functionality later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: add --video-devices option
David Herrmann [Sun, 28 Oct 2012 15:02:28 +0000 (16:02 +0100)]
kmscon: add --video-devices option

If all the auto-detection logic of kmscon still does something you don't
want, you can now use this list to override all this logic with a
statically configured white-list.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoshl: add shl_string_list_is() helper
David Herrmann [Sun, 28 Oct 2012 15:01:47 +0000 (16:01 +0100)]
shl: add shl_string_list_is() helper

This helper tests whether a string-list has only a single entry and
compares this with the given entry.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: monitor: mark vesafb devices as primary
David Herrmann [Sun, 28 Oct 2012 14:40:56 +0000 (15:40 +0100)]
uterm: monitor: mark vesafb devices as primary

VESA VGA devices are platform devices so they are always primary.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: remove deprecated /etc/kmscon.conf support
David Herrmann [Sun, 28 Oct 2012 14:23:09 +0000 (15:23 +0100)]
kmscon: remove deprecated /etc/kmscon.conf support

This was supported for backwards-compatibility, but is no longer
supported. Use the new /etc/kmscon/kmscon.conf files.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: replace --fbdev/--dumb with --drm/--hwaccel
David Herrmann [Sun, 28 Oct 2012 14:20:20 +0000 (15:20 +0100)]
kmscon: replace --fbdev/--dumb with --drm/--hwaccel

The old options were quite stupid and low-level. It doesn't make sense to
require users to understand "--dumb" (besides, it sounds wrong).

Therefore, two new options replace the old options:
 --drm: Enabled by default. If true, kmscon uses primary DRM devices and
        avoids primary fbdev devices. If false, kmscon uses no DRM devices
        at all but uses primary fbdev devices now.
 --hwaccel: Disabled by default. If true, kmscon tries to
            hardware-accelerate any rendering if available. This can also
            affect fbdev or other devices in the future.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: add uterm_video_available() helper
David Herrmann [Sun, 28 Oct 2012 13:29:59 +0000 (14:29 +0100)]
uterm: add uterm_video_available() helper

This helper provides information whether a given backend is available and
even whether kernel-runtime support is available for this backend.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: enable DRM helpers with UTERM_VIDEO_DUMB
David Herrmann [Sun, 28 Oct 2012 13:22:19 +0000 (14:22 +0100)]
uterm: enable DRM helpers with UTERM_VIDEO_DUMB

The DRM helpers can actually also be used with dumb-displays so provide it
in both cases.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agoNEWS: add kmscon-6 entries
David Herrmann [Sat, 27 Oct 2012 17:22:56 +0000 (19:22 +0200)]
NEWS: add kmscon-6 entries

Add entries for all main features since kmscon-5.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: fix --fbdev implying --all-gpus
David Herrmann [Sat, 27 Oct 2012 17:21:56 +0000 (19:21 +0200)]
kmscon: fix --fbdev implying --all-gpus

We currently have no code that sets PRIMARY flags for fbdev devices so
this logic does not make sense with --fbdev. Hence, imply --all-gpus when
--fbdev is set.

Reported-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agokmscon: add --xkb-model option
David Herrmann [Sat, 27 Oct 2012 17:00:43 +0000 (19:00 +0200)]
kmscon: add --xkb-model option

This option now allows the user to change the XkbModel from the command
line or configuration file.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
11 years agouterm: input: allow passing "model" for keyboard descs
David Herrmann [Sat, 27 Oct 2012 16:55:21 +0000 (18:55 +0200)]
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>