Age | Commit message (Collapse) | Author |
|
Imagine a constructor like this:
int object_new(void **out) {
void *my_object;
int r;
...
r = ioctl(...);
if (r < 0)
return -errno;
...
*out = my_object;
return 0;
}
We have a lot of those in systemd. If you now call those, gcc might inline
the call and optimize it. However, gcc cannot know that "errno" is
negative if "r" is. Therefore, a caller like this will produce warnings:
r = object_new(&obj);
if (r < 0)
return r;
obj->xyz = "foobar";
In case the ioctl in the constructor fails, gcc might assume "errno" is 0
and thus the error-handling is not triggered. Therefore, "obj" is
uninitialized, but accessed. Gcc will warn about that.
The new negative_errno() helper can be used to mitigate those warnings.
The helper is guaranteed to return a negative integer. Furthermore, it
spills out runtime warnings if "errno" is non-negative.
Instead of returning "-errno", you can use:
return negative_errno();
gcc will no longer assume that this can return >=0, thus, it will not warn
about it.
Use this new helper in libsystemd-terminal to fix some grdev-drm warnings.
|
|
|
|
|
|
|
|
Usually, when our session is activated (or re-configurated) we should be
able to try a page-flip to our buffer. The kernel driver should reject it
if it is incompatible. As it turns out, drivers don't do this. Therefore,
we now force a deep modeset if we're not sure what mode is set.
This has the side-effect that we might get glitches on session-switches
(depending on driver behavior). However, there's no way around this and it
is what everyone does so far. Most drivers still detect if we keep the
mode and so don't touch the clocks. Therefore, we just get a regular async
flip.
|
|
|
|
XKB consumed mods include modifiers that *didn't* affect the translation,
but might affect it if used. This is very misleading, given that we are
usually not interested in that information. Therefore, keep them in real
mods to behave like X11 does. Maybe at some point, XKB introduces proper
shortcut matching...
Also make evcat display consumed modifiers so we can better debug those
situations.
|
|
Bold glyphs always use light colors. However, this color conversion is
limited to the foreground color, so skip it for backgrounds.
|
|
We rely on the parent terminal to do color conversion, so also leave
bold->light conversion to the parent. Otherwise, it will be performed
twice and we might apply it on the wrong color.
|
|
Hook up SM/RM 47/1047-1049 and enable alternate screen buffers for term
applications.
(David: rebased on top of -git, renamed helpers and added docs)
|
|
Terminal state can be saved/restored by applications. To simplify our
internal handling, put all affected state into a separate object.
Especially with alternate screen buffers, this will simplify our code
significantly.
|
|
We draw our own cursor in subterm now, so there's no reason to update the
cursor-position of the parent terminal on each frame. The parent's cursor
is hidden, anyway.
|
|
7BIT mode is enabled by default. Fix the comment to state this correctly.
|
|
|
|
Instead of increasing the screen-age on redraw, we now increase it only on
real updates. This is effectively the same, but avoids increased age
counters on backbuffer rendering. Therefore, we can now check age counters
against fronbuffers safely, while rendering frames in background.
|
|
Terminals use pseudo color-codes mixed with 8bit and 24bit colors. Provide
a color-converter so external renderers only have to deal with ARGB32
colors.
This requires a color-palette as input as there's no fixed mapping. We
provide a default, but maybe we wanna support external palettes in the
future.
|
|
This is the most simple way to render cursors: flip attr->inverse of the
cursor cell. This causes the background and foreground colors of the
cursor-cell to be inversed.
Now that we render cursors ourselves, make subterm not call into the
parent terminal to render cursors.
|
|
If we hide or show the cursor, we change visual attributes and have to
mark the underlying cell as dirty. Otherwise, the terminal will not be
redrawn.
|
|
Matching keyboard shortcuts on internationalized keyboards is actually
non-trivial. Matching the actual key is easy, but the modifiers can be
used by both, the matching and the translation step. Therefore, XKB
exports "consumed-modifiers" that we use to figure out whether a modifier
was already used by the translation step.
The new IDEV_KBDMATCH() helper can be used to match on any keyboard
shortcut and it will do the right thing.
|
|
Implement the feed_keyboard() handling by mapping XKB keys according to
DEC-VT behavior.
Public information on terminal key-mappings is pretty scarce. We only
implement the most basic mapping for now. Further improvements welcome!
|
|
XKB_KEY_NoSymbol is defined as 0 but does not correspond to a VT key with
ASCII value 0. No such key exists, so don't try to find such a key.
|
|
In case we cannot render a glyph, we want a fallback we can display
instead. If we rely on the font itself to provide the fallback character,
we have nothing to display if that character is not available. Therefore,
add a static fallback that we can use at any time.
|
|
Don't hard-code the screen renderer but use the newly introduced
term_screen_draw() helper.
|
|
We don't want to expose the term_screen internals for rendering.
Therefore, provide an iterator that allows external renderers to draw
terminals.
|
|
If a pipe is enabled/disabled, we have to clear crtc->applied of the
linked CRTC. Otherwise, we will not run a deep modeset, but leave the crtc
in the pre-configured state.
|
|
Instead of limiting fb-aging to 64bit integers, allow any arbitrary
context together with a release function to free it once the FB is
destroyed.
|
|
We really want more sophisticated aging than just 64bit integers. So
always provide front *and* back buffers to renderers so they can compare
arbitrary aging information and decide whether to re-render.
|
|
Instead of looking for available back-buffers on each operation, set it to
NULL and wait for the next frame request. It will call back into the pipe
to request the back-buffer via ->target(), where we can do the same and
look for an available backbuffer.
This simplifies the code and avoids double lookups if we run short of
buffers.
|
|
Coverity complained about this code and is partially right. We are not
really protected against integer overflows. Sure, unlikely, but lets just
avoid any overflows and properly protect our parser loop.
|
|
Lets return the parsed length in term_utf8_decode() instead of a buffer
pointer. Store the pointer in the passed argument.
This makes it adhere to the systemd coding-style, were we always avoid
returning pointers, but store them in output arguments. In this case, the
storage is not allocated, so it doesn't fit 100% to this idiom, but still
looks much nicer.
|
|
We currently select front-buffers as new back-buffer if they happen to be
the last buffer in our framebuffer-array. Fix this by never selecting a
new front buffer as back buffer.
|
|
Allow term users to retrieve the page dimensions of a terminal screen.
This is needed to properly calculate the grid dimensions when rendering.
|
|
Like all the other parts of libsystemd-terminal, split API of
term-internal.h into term.h so we can use it from systemd-consoled.
|
|
Lets avoid putting stuff into /usr/shared/unifont/, but keep it in
/usr/share/systemd/. Upstream lacks interest in this, so don't bother for
now.
|
|
Allow unifont users to retrieve the width and height of unifont glyphs. In
version 1 this is hard-coded as 8/16, but may be changed in the future.
|
|
All the definitions are for outside users, so drop the -internal suffix.
Internal definitions are in unifont-def.h and unifont.c, no need to share
those.
|
|
Allow sysview users to retrieve the seat that a session is assigned to.
|
|
Add helper to perform session switches on a specific seat whenever we
retrieve a VT-switch keyboard event.
|
|
Allow users to query the display dimensions of a grdev_display. This is
required to properly resize the objects to be rendered.
|
|
Make sure the kernel always returns events properly. This is guaranteed
right now, otherwise, we do something really wrong. But lets be sure and
verify the received values properly. This also silences some coverity
warnings.
|
|
We used to set "pipe->tile = tile" inside of the leaf allocation. We no
longer do that. Verify that "out" is non-NULL, otherwise we'd leak memory.
This is currently always given, but make sure to add an assert(), so
coverity does not complain.
|
|
Binary operators with two pointers as arguments always operate on
object-size, not bytes. That is, "int *a, *b", (a - b) calculates the
number of integers between b and a, not the number of bytes.
Fix our cache-offset calculation to not use sizeof() with full-ptr
arithmetic.
|
|
This adds some log-messages to ioctl() calls where we don't really care
for the return value. It isn't strictly necessary to look for those, but
lets be sure and print warnings. This silences gcc and coverity, and also
makes sure we get reports in case something goes wrong and we didn't
expect it to fail that way.
|
|
|
|
Now that we no longer propagate callback return values, we can safely call
into user-callbacks during sysview_context_stop(). This way, users can
rely on all objects to be removed via callbacks (except if they failed
during object creation). This avoids duplicating any object hashtables on
the users' side and reduces memory consumption.
|
|
We cannot sanely propagate error codes if we call into user-callbacks
multiple times for multiple objects. There is no way to merge those errors
or somehow propagate them.
However, we can just act similar to sd-event and print a log-message while
discarding the values. This way, we allow error-returns, but can properly
continue working on our objects.
|
|
Add "userdata" storage to a bunch of external objects, namely displays and
sessions. Furthermore, add some property retrieval helpers.
This is required if we want external API users to not duplicate our own
object hashtables, but retrieve context from the objects themselves.
|
|
Instead of adding matches per device, we now add logind matches per
session. This reduces the number of matches considerably and saves
resources.
|
|
Instead of raising DEVICE_CHANGE only per device, we now raise it per
device-session attachment. This is what we want for all sysview users,
anyway, as sessions are meant to be independent of each other. Lets avoid
any external session iterators and just do that in sysview itself.
|
|
Whenever we resync an evdev device (or disable it), we should send RESYNC
events to the linked upper layers. This allows to disable key-repeat and
assume some events got dropped.
|