summaryrefslogtreecommitdiff
path: root/src/libsystemd-terminal
AgeCommit message (Collapse)Author
2014-11-04util: introduce negative_errno()David Herrmann
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.
2014-10-30util: unify how we see srand()Lennart Poettering
2014-10-16terminal: log unsupported ANSI or DEC mode changesTom Gundersen
2014-10-16terminal: split ANSI from DEC mode changesTom Gundersen
2014-10-11terminal/grdrm: force deep modeset on enterDavid Herrmann
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.
2014-10-05terminal: remove an unused initializationThomas Hindoe Paaboel Andersen
2014-10-05terminal/idev: don't remove consumed-mods from kbd-matchesDavid Herrmann
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.
2014-10-05terminal/screen: perform bold->light conversion only on foregroundDavid Herrmann
Bold glyphs always use light colors. However, this color conversion is limited to the foreground color, so skip it for backgrounds.
2014-10-05terminal/subterm: leave bold-light conversion to parentDavid Herrmann
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.
2014-10-05terminal/screen: add support for alternate screen buffersTom Gundersen
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)
2014-10-05terminal/screen: save state in separate objectDavid Herrmann
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.
2014-10-05terminal/subterm: skip setting parent's cursorDavid Herrmann
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.
2014-10-05terminal: fix TERM_FLAG_* commentDavid Herrmann
7BIT mode is enabled by default. Fix the comment to state this correctly.
2014-10-05terminal: fix restoring of screen flagsTom Gundersen
2014-10-03terminal/screen: adjust screen age only on updateDavid Herrmann
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.
2014-10-03terminal/screen: add color converterDavid Herrmann
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.
2014-10-03terminal/screen: add cursor renderingDavid Herrmann
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.
2014-10-03terminal/screen: mark cursor dirty on enabled/disableDavid Herrmann
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.
2014-10-03terminal/idev: add helper to match keyboard shortcutsDavid Herrmann
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.
2014-10-03terminal/screen: add keyboard mappingDavid Herrmann
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!
2014-10-03terminal/idev: don't map XKB_KEY_NoSymbol as ASCII 0David Herrmann
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.
2014-10-03terminal/unifont: add built-in fallback glyphDavid Herrmann
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.
2014-10-03terminal/subterm: use screen rendererDavid Herrmann
Don't hard-code the screen renderer but use the newly introduced term_screen_draw() helper.
2014-10-03terminal: add screen rendererDavid Herrmann
We don't want to expose the term_screen internals for rendering. Therefore, provide an iterator that allows external renderers to draw terminals.
2014-10-03terminal/drm: clear 'applied' flag when changing stateDavid Herrmann
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.
2014-10-03terminal/grdev: allow arbitrary fb-age contextsDavid Herrmann
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.
2014-10-03terminal/grdev: provide front and back buffer to renderersDavid Herrmann
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.
2014-10-03terminal/drm: provide pipe->target() callbackDavid Herrmann
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.
2014-10-03terminal/grdev: simplify DRM event parsingDavid Herrmann
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.
2014-10-03terminal: make utf8 decoder return lengthDavid Herrmann
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.
2014-10-03terminal: fix back-buffer selection on DRM page-flipDavid Herrmann
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.
2014-10-02terminal: add helpers to retrieve page dimensionsDavid Herrmann
Allow term users to retrieve the page dimensions of a terminal screen. This is needed to properly calculate the grid dimensions when rendering.
2014-10-02terminal: add term.h header for library usersDavid Herrmann
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.
2014-10-02terminal: move unifont-map to datadirDavid Herrmann
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.
2014-10-02terminal: add unifont_get_width/height()David Herrmann
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.
2014-10-02terminal: move unifont-internal.h to unifont.hDavid Herrmann
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.
2014-09-29terminal: add helper to retrieve the seat of a sessionDavid Herrmann
Allow sysview users to retrieve the seat that a session is assigned to.
2014-09-29terminal: add sysview_seat_switch_to()David Herrmann
Add helper to perform session switches on a specific seat whenever we retrieve a VT-switch keyboard event.
2014-09-23terminal: provide display dimensions to API usersDavid Herrmann
Allow users to query the display dimensions of a grdev_display. This is required to properly resize the objects to be rendered.
2014-09-23terminal: verify kernel-returned DRM events are not truncatedDavid Herrmann
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.
2014-09-23terminal: verify grdev tiles are correctly linkedDavid Herrmann
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.
2014-09-23terminal: fix tile-offset calculationDavid Herrmann
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.
2014-09-23Silence some "unchecked return-value" warningsDavid Herrmann
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.
2014-09-23terminal: fix spelling mistakeZbigniew Jędrzejewski-Szmek
2014-09-22terminal: signal object removal during sysview_context_stop()David Herrmann
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.
2014-09-22terminal: handle callback errors in sysview instead of propagating themDavid Herrmann
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.
2014-09-22terminal: allow user-context to be retrieved/storedDavid Herrmann
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.
2014-09-22terminal: make evdev logind-matches per sessionDavid Herrmann
Instead of adding matches per device, we now add logind matches per session. This reduces the number of matches considerably and saves resources.
2014-09-22terminal: raise sysview DEVICE_CHANGE events per attachmentDavid Herrmann
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.
2014-09-22terminal: forward evdev RESYNC events to linked devicesDavid Herrmann
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.