Instead of scheduling for redraw, we have to schedule for resize as the
new widget might want to change the size constraints.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
If we resize the buffers, we skip redrawing as resizing implies this.
However, if the resize-handler skips resizing because the size didn't
change, it also skips redrawing.
Hence, we add a new flag to force redrawing even if the resize-operation
is skipped. This fixes a bug where we didn't redraw during stalling resize
operations by the user.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
If we scroll the screen during resize to keep the screen-content constant,
we should also move the cursor position. Otherwise, the application has an
inconsistent state.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This changes the prepare-resize logic to allow widgets full control of the
new size. The initial size starts at 0 and each widget can increase it.
The last widget should be a catch-all that uses all size that is available
and computes a good new size based on the requirements that the previous
widgets provided.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We call screen_scroll_up() under special conditions when resizing. We
require it to allocate the lines with the new width even though we didn't
set it yet. Therefore, we need to set the width before calling it and then
adjust the height.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The getty variants out there (including agetty) require an relative path
to the /dev directory as argument. This is really odd but we want to be
backwards-compatible to them so we allow this, too.
--vt now accepts:
* A positive number which is internally converted into /dev/ttyXY
* A string that does not start with '/' or '.' which is interpreted
relative to /dev as /dev/%s
* Everything else is interpreted as path
This option still selects only the TTY on seat0. On all other seats we do
not use controlling TTYs.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The standard C/POSIX helpers are really ugly to use. This small helper
returns 0 on success, otherwise an error.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When enabling the printf() logic for the logging subsystem, several
warnings were produced about missing or wrong specifiers. This fixes all
those occurrences.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We must under all conditions avoid encoding invalid UTF8. Otherwise, we
would rely on other applications to do error-recovery.
Unfortunately, this is no syntactical change but a semnatical fix as the
Unicode standard defines several codepoints which are invalid or which
must never be used in UTF8.
See the Unicode standard if you're interested in these codepoint ranges.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Add gcc attributes so the printf formats are correctly checked. This
causes a lot of warnings which will be fixed in the following commits.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This is a stable release for kmscon. It includes mainly bugfixes and
cleanups. The TSM library was created out of the internal VTE layers and
mostly code-cleanups took place.
Happy testing!
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
VTs are only available on seat0 so this option does not affect other
seats. On seat0 it selects the VT that we run on. We do _not_ fall back to
another seat if it fails but disable this seat instead.
Reported-by: Matthew Monaco
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This is very similar to the UINT datatype but allows signed values. This
will be required for the coming --vt option as default value.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Use wl_shell_surface_set_maximized() to notify the compositor that we
support being maximized now. The server actually decides whether it
resizes our window.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
I just noticed that older compiles do not support _Static_assert() so we
now check in configure.ac for it. We do not use it heavily, anyway.
Dynamic asserts are avoided entirely.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
People might want to close file-descriptors before destroying the ev_fd
object if they actually have no direct control of it. For instance if used
through a library.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This forwards the PTY-HUP event to the caller so we can close the terminal
window when the client application exits.
Reported-by: Alexander Preisinger
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This converts a warning into a debug message to avoid spending too much
time in the logger when parsing unknown content. This speeds up "cat
/dev/urandom" by like 1000x.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We actually allow draining a timer so we cannot be sure that a timer has
valid data that we can read. We already handle the non-blocking case
everywhere, we just missed setting this flag.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This adds a timer that automatically repeats key-events while pressed. In
the XKB-1 protocol embedded in wayland, key-repeates are not sent for
performance reason so we have to emulate them.
It is currently unclear where to take key-repeat rates from. This will be
solved in the future, though.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
If NULL is passed for timer udpates, we simply assume that the timer
should be disarmed and use a zeroed itimerspec.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
There is some nasty bug where we do not correctly clean buffers when
resizing. So we now clear the whole offscreen region on resize to go sure
everything is clean.
Note that cells can pretty much move everywhere during their
offscreen-life so this is a quite sophisticated task to keep track which
cells are clean and which not. Therefore, simply clean all of them when
taking them on-screen.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The array type used to be from glib which did that check automatically. We
now have to check explicitely that we do not access it out-of-bounds.
This fixes a nasty resizing-bug of TSM.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We actually created a new table all the time which led to huge memory
leaks. We now actually use the default table if it is available.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We need to keep dp_fd alive for all calls to wl_display_*(). Otherwise,
the callback will use it and access invalid memory.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
The need_frame and idle_frame logic was slightly wrong. We ended up not
correctly requesting the frame-cb after a _real_ frame-cb. Hence, the
idle-cb did simply send the next attach() request.
This fixes this small race and adds a comment how all this is supposed to
work.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Current default size is pretty small and there are still some resizing
bugs so increase it to have a working terminal.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This implements the wl_keyboard client-side of the wayland protocol and
takes care of pushing keyboard events to the correct window.
A new callback is added to all widgets which is called when keyboard input
is sent to the specific window.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Use the font subsystem to blit the console glyphs to the wlterm window
during redraw-callbacks.
This is mostly copied from src/terminal.c and the blitting functions from
uterm-fbdev.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We need the text-font modules to render fonts in wlterm. Therefore, load
all the font modules during startup before initializing the application.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
wlterm needs xkbcommon as the wayland protocol depends on XKB states.
Hence, we add a hard-dependency for wlterm.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Instead of doing all this in main() we now use the two helpers. This makes
the code much more readable and avoids too many stuff in main().
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We want to use the font-rendering layer in wlterm so we need to split this
out. Gladly, the layer has only a build-time dependency on uterm and not
other hard-coded stuff. That is, we have no cleanup to do.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Create TSM screens and VTE objects plus a PTY and connect everything so we
have a working terminal. Keyboard input still needs to be hooked up and
the drawing functions aren't implemented, yet.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This helper allows widgets to retrieve the eloop that is used by the
window. Otherwise, we couldn't dispatch events there.
No refcounting is needed as all widgets are destroyed before the window is
destroyed. Other users need to perform ref-counting by themself.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This makes the pty layer independent of kmscon global state. This allows
us to use it in other applications bundled with kmscon. There is still
some work to do to make it fully independent so we can integrate it into
TSM. But that's not really needed, yet.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Instead of accessing global state, we now set the TERM value via a helper
function. This is needed to make the pty layer independent of kmscon.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Sorry for the big commit, but I was working on the wlterm application and
then thought I can rework the whole configure-logic again. This mainly
renames all build-defines to BUILD_DEFINE_* and BUILD_HAVE_* and allows
specifying which applications to build via --enable-kmscon/--enable-wlterm
and similar.
wlterm is a new application which is a native wayland client with no
external dependencies. It serves several purposes:
* It uses TSM (not yet implemented, but will come soon) to create a
console independent from kmscon. This shows how TSM can easily be used
to create independent terminal emulators.
* It is a native wayland application (probably the first independent
wayland app so far?) and is used to test how well the wayland API
works. As wayland is still under heavy development, we need more
application-writers who report back whether the wayland-API makes
sense to them and whether it works correctly.
* A proper terminal-emulator for wayland! There is currently no proper
emulator so we really need something that we can work with.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
We move the GRAB type into kmscon-main.c to avoid any uterm dependency in
the conf subsystem. It is still open how we can better handle the
key-parser without a valid uterm_input object, but when there will be a
xkbcommon release, we can hopefully add a hard depedency to it.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Now that we can differentiate between fbdev-DRM and normal fbdev devices,
we can just pick up the normal fbdev devices by default.
--fbdev now makes kmscon use the FBDEV_DRM devices instead of pure DRM.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Most DRM drivers also provide a legacy fbdev device so fbcon can pick it
up (and more importantly, we get kernel panics on it). However, as an
application developer, I don't want to use two devices which drive the
same physical hardware.
This marks all such DRM fbdev devices as FBDEV_DRM so kmscon doesn't pick
them up automatically.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
When multiple requests are pushed into the video backends at once, we
should ignore NULL buffers. Otherwise, users might have to re-order
buffers just so we don't segfault. Instead, we now ignore them and the
application can set requests to NULL to signal us that it is unused.
This fixes some bugs with multi-monitor setups and kmscon.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>