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>
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>
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>
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>
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>
The --configdir parameter allows specifying another configuration
directory than the default /etc/kmscon.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
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>
--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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Print debug messages when doing asynchronous session switches and handle
EINPROGRESS as special error code.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>