1216 Commits

Author SHA1 Message Date
David Herrmann
715287427d pty: simplify pty_close()
The old logic is no longer needed as we use edge-triggered fd notification
now. Therefore, simplify the helpers to make them more readable.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 13:42:15 +01:00
David Herrmann
636c383c68 text: gltex: free atlas during destruction
If we remove an atlas, we have to correctly free its memory. Otherwise, we
will loose the memory.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 13:40:53 +01:00
David Herrmann
4199d3331e pty: free seat argument on destruction
We didn't correctly free this parameter even though we dup'ed it earlier.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 13:40:16 +01:00
David Herrmann
24d320b86a seat: unref session after unregistration
Session registration does not provide a reference to the caller. Instead,
the seat itself owns the reference. Hence, we must clear this reference
during unregistration, otherwise we will never free the session structure.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 13:39:00 +01:00
David Herrmann
5d94e9eb48 seat: forward HUP to caller
We now forward VT_HUP to the caller so they can react on it. Default
behavior is to shutdown this seat. In single-seat mode we also close the
application.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 12:42:35 +01:00
David Herrmann
dc1ac3d891 seat: protect kmscon_seat_remove_display() correctly
We have to check for NULL pointers like all the other public entries do.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 12:42:07 +01:00
David Herrmann
63298eb881 conf: improve --vt warning by allowing --seats=,all
If a seat is called "all" and we want to use it as single seat, we
currently have to pass "--seats=all," or "--seats=,all" etc. so it is not
detected as --seats=all.
However, our warning when --vt is used with it does not respect this.
Improve this warning to detect this case and correctly ignore it then.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 12:29:18 +01:00
David Herrmann
89081916d7 shl: misc: add shl_string_list_count() helper
This helper counts the entries in a string-list with an option to ignore
empty elements.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 12:28:48 +01:00
David Herrmann
0d006aa263 seat: schedule dummy session if no other session is available
In special situations (like forcing deactivation of a background session)
we might end up with no real registered session and no current session. In
these situations, we should allow the session-scheduler to schedule dummy
sessions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 12:07:06 +01:00
David Herrmann
4ceedc188d seat: allow asynchronous command scheduling
When an asynchronous session-deactivation is finished, we need to know
which task to do now. As we cannot let the caller decide, because we are
asynchronous, we have to remember the task.

Three tasks are defined now but this can be extended. We reset the task
after the current session got deactivated. This guarantees that we never
have pending schedules but always return to a sane default even if we
missed a notification.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 12:05:18 +01:00
David Herrmann
84a006777b uterm: vt: handle HUP on controlling TTY
If the controlling TTY (in our case the VT) signals us a HUP, we should
consider it closed and forward that to the caller. This does normally not
happen on real VTs, however, on fake-VTs this happens if the parent goes
away.

We forward the HUP to the controlling subsystem which then has to deal
with it. But more importantly, we disable the fd so we don't hog the CPU
by unconditionally flushing the queue.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 12:02:06 +01:00
David Herrmann
653ceff5b0 cdev: introduce client 'dead' state
Files have the disadvantage that the kernel (or in this case 'we') cannot
force a client to close it. Instead, we have to mark it as 'dead' and wait
until the client closes the file theirself.
While marked as 'dead' we always return EPIPE or signal EPOLLHUP so the
client will notice that the file is dead.

This fixes a bug where when we forced an unregistration of a cdev session,
the cdev_client went away too early and the user still had the file open.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 11:03:40 +01:00
David Herrmann
d0e625f074 cdev: fix copying pollhandles correctly
The pollhandle is solely implemented in libfuse and does not correspond to
some kernel-intern object. Instead, the kernel notifies us when it has
poll-waiters via a flag. If that flag is set we should notify the kernel
whenever the poll-flags change.

Therefore, we can safely copy the pollhandle all the time and delete our
temporary handles.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 11:02:17 +01:00
David Herrmann
8e23d947f1 uterm: vt: add uterm_vt_get_type() helper
This helper returns the VT type. This will allow external users to see
whether we have real VTs or whether we don't.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-02 10:19:43 +01:00
David Herrmann
9bfd8c4f86 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>
2012-12-02 10:18:15 +01:00
David Herrmann
fddd1f6fb4 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>
2012-12-02 10:16:24 +01:00
David Herrmann
9ddbe5405a 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>
2012-12-02 10:15:40 +01:00
David Herrmann
d22e59f2b0 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>
2012-12-01 23:45:55 +01:00
David Herrmann
294312185f 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>
2012-12-01 19:06:38 +01:00
David Herrmann
00297c43cc 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>
2012-12-01 18:22:38 +01:00
David Herrmann
4cd7b696d3 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>
2012-12-01 17:39:38 +01:00
David Herrmann
529ad081ab 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>
2012-12-01 17:27:45 +01:00
David Herrmann
22a1e1b91b 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>
2012-12-01 16:09:14 +01:00
David Herrmann
79312a60ae 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>
2012-12-01 15:46:42 +01:00
David Herrmann
53ad90da0f 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>
2012-12-01 15:25:37 +01:00
David Herrmann
1796e33441 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>
2012-12-01 15:05:07 +01:00
David Herrmann
0da912fbbd conf: fix whitespace offset for -s
Align everything to the same offset.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-01 14:50:53 +01:00
David Herrmann
0d8102a286 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>
2012-12-01 13:15:01 +01:00
David Herrmann
2f546b7f19 cdev: fix typo in warning
Obvious typo. Got those words swapped...

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2012-12-01 13:11:39 +01:00
David Herrmann
5442e5f903 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>
2012-11-28 22:58:39 +01:00
David Herrmann
9a70af0ecc 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>
2012-11-28 22:21:33 +01:00
David Herrmann
145e6fc402 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>
2012-11-28 22:16:07 +01:00
David Herrmann
9f63ed94d4 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>
2012-11-28 22:14:05 +01:00
David Herrmann
df98046189 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>
2012-11-28 21:55:50 +01:00
David Herrmann
f24ab890ad 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>
2012-11-28 20:57:36 +01:00
David Herrmann
19c2991fbb 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>
2012-11-28 20:51:30 +01:00
David Herrmann
5c527e7fec 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>
2012-11-28 19:31:09 +01:00
David Herrmann
0b9fa6aa29 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>
2012-11-28 17:47:31 +01:00
David Herrmann
ae97bbf7e3 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>
2012-11-28 17:46:18 +01:00
David Herrmann
e8c439c805 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>
2012-11-27 19:02:48 +01:00
David Herrmann
f25c41f8f9 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>
2012-11-27 19:00:57 +01:00
David Herrmann
48ab1317ad 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>
2012-11-26 17:19:45 +01:00
David Herrmann
d0991ec639 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>
2012-11-26 17:11:07 +01:00
David Herrmann
da7219e6de 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>
2012-11-26 17:10:44 +01:00
David Herrmann
5f234e6592 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>
2012-11-26 16:50:39 +01:00
David Herrmann
2cac43f64e 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>
2012-11-20 14:30:54 +01:00
David Herrmann
9fe0e9119f 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>
2012-11-19 16:26:38 +01:00
David Herrmann
054955c530 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>
2012-11-19 16:14:38 +01:00
David Herrmann
65f97ef564 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>
2012-11-19 16:11:34 +01:00
David Herrmann
3c223d9bec 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>
2012-11-19 16:10:01 +01:00