1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00
Commit Graph

120 Commits

Author SHA1 Message Date
David Herrmann
a38f05b7f7 Revert commit f131770b "tree-wide: spelling fixes"
This partially reverts:

    commit f131770b14
    Author: Veres Lajos <vlajos@gmail.com>
    Date:   Mon Dec 29 09:45:58 2014 +0000

        tree-wide: spelling fixes

The commit in question changed a binary file. I didn't look at the diff in
particular, so I have no idea what exactly was changed. However, the file
is generated and it looked highly suspiciuous. Therefore, I reverted that
part.

Note that this is generated by "make update-unifont" so really no reason
to touch at all.
2014-12-31 13:34:21 +01:00
Veres Lajos
f131770b14 tree-wide: spelling fixes
https://github.com/vlajos/misspell_fixer

b6fdeb618c
Thanks to Torstein Husebo <torstein@huseboe.net>.
2014-12-30 20:07:04 -05:00
Tom Gundersen
2bb4c7e384 shared: utf8 - support ucs4 -> utf8
Originally we only supported ucs2, so move the ucs4 version from libsystemd-terminal to shared
and use that everywhere.
2014-12-22 20:26:53 +01:00
Lennart Poettering
eccaf89933 tree-wide: use our memset() macros instead of memset() itself 2014-12-11 16:58:45 +01:00
Torstein Husebø
f7340ab269 treewide: correct spacing near eol in code comments 2014-12-11 15:10:03 +01:00
Zbigniew Jędrzejewski-Szmek
553acb7b6b treewide: sanitize loop_write
loop_write() didn't follow the usual systemd rules and returned status
partially in errno and required extensive checks from callers. Some of
the callers dealt with this properly, but many did not, treating
partial writes as successful. Simplify things by conforming to usual rules.
2014-12-09 21:36:08 -05:00
David Herrmann
5eb9e762ea terminal/screen: fix GL/GR double-mapping
We must not call screen_map() multiple times for the same input char. Fix
the double-mapping for GL/GR maps are correctly applied.
2014-11-30 14:37:57 +01:00
Michal Schmidt
4a62c710b6 treewide: another round of simplifications
Using the same scripts as in f647962d64 "treewide: yet more log_*_errno
+ return simplifications".
2014-11-28 19:57:32 +01:00
Michal Schmidt
56f64d9576 treewide: use log_*_errno whenever %m is in the format string
If the format string contains %m, clearly errno must have a meaningful
value, so we might as well use log_*_errno to have ERRNO= logged.

Using:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/'

Plus some whitespace, linewrap, and indent adjustments.
2014-11-28 19:49:27 +01:00
Michal Schmidt
23bbb0de4e treewide: more log_*_errno + return simplifications 2014-11-28 18:24:30 +01:00
Michal Schmidt
eb56eb9b40 treewide: simplify log_*_errno(r,...) immediately followed by "return r" 2014-11-28 17:34:26 +01:00
Michal Schmidt
c33b329709 treewide: more log_*_errno() conversions, multiline calls
Basically:

find . -name '*.[ch]' | while read f; do perl -i.mmm -e \
'local $/;
 local $_=<>;
 s/log_(debug|info|notice|warning|error|emergency)\("([^"]*)%s"([^;]*),\s*strerror\(-?([->a-zA-Z_]+)\)\);/log_\1_errno(\4, "\2%m"\3);/gms;print;' \
 $f; done

Plus manual indentation fixups.
2014-11-28 17:17:51 +01:00
Michal Schmidt
da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt
0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Thomas Hindoe Paaboel Andersen
b5a1e50495 fix build with --enable-terminal
Broke with 086891e5c1
2014-11-27 23:18:34 +01:00
Lennart Poettering
79008bddf6 log: rearrange log function naming
- Rename log_meta() → log_internal(), to follow naming scheme of most
  other log functions that are usually invoked through macros, but never
  directly.

- Rename log_info_object() to log_object_info(), simply because the
  object should be before any other parameters, to follow OO-style
  programming style.
2014-11-27 22:05:24 +01:00
David Herrmann
2f0dd5164d terminal/idev: forward xkb-messages
Properly forward all XKB messages. You can use XKB_LOG_VERBOSITY= to
control the amount of messages sent by XKB. We explicitly set
XKB_LOG_LEVEL to 7 you can use SYSTEMD_LOG_LEVEL to control the log-level
generically.
2014-11-25 10:24:39 +01:00
David Herrmann
123a8dc84d terminal/idev: avoid magic numbers
Use XKB_CONTEXT_NO_FLAGS instead of magic 0.
2014-11-25 10:24:08 +01:00
David Herrmann
a2ce1730e1 terminal/idev: use compose tables
Before forwarding keyboard events, feed them into possible compose tables.
This enables Compose-key and Dead-key features.

Few notes:
 * REPEAT events are never fed into compose tables. It just doesn't make
   sense and is usually not wanted. Compose-sequences are usually hard to
   remember and take time to type. Thus, the REPEAT event of the
   Compose-key itself would often cancel the compose sequence already.

 * Stop resolving symbols for UP events. Anything but keycodes is never
   associated to a physical key, but is a one-time action. There is
   nothing like UP events for key-symbols!

 * Cancel compose-sequences on Multi-Key UP. See the inline comment. We
   should make this configurable!
2014-11-24 18:30:03 +01:00
David Herrmann
cdcd0ccdbe terminal/idev: add compose-file support
Add support for compose files to idev-keyboard. This requires
libxkbcommon-0.5.0, which is pretty new, but should be fine.

We don't use the compose-files, yet. Further commits will put life into
them.
2014-11-24 18:30:03 +01:00
David Herrmann
44dd2c6e86 util: introduce negative_errno()
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-11-04 08:27:31 +01:00
Lennart Poettering
ef309a681f util: unify how we see srand() 2014-10-30 15:35:37 +01:00
Tom Gundersen
9536cf93b9 terminal: log unsupported ANSI or DEC mode changes 2014-10-16 14:43:57 +02:00
Tom Gundersen
7ee738ec33 terminal: split ANSI from DEC mode changes 2014-10-16 14:43:57 +02:00
David Herrmann
f08f302732 terminal/grdrm: force deep modeset on enter
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-11 18:49:20 +02:00
Thomas Hindoe Paaboel Andersen
0077776275 terminal: remove an unused initialization 2014-10-05 22:43:07 +02:00
David Herrmann
62d5068d63 terminal/idev: don't remove consumed-mods from kbd-matches
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-05 18:02:28 +02:00
David Herrmann
34dbefceb1 terminal/screen: perform bold->light conversion only on foreground
Bold glyphs always use light colors. However, this color conversion is
limited to the foreground color, so skip it for backgrounds.
2014-10-05 15:49:26 +02:00
David Herrmann
378c4eed02 terminal/subterm: leave bold-light conversion to parent
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-05 15:48:32 +02:00
Tom Gundersen
c7afe4f3d7 terminal/screen: add support for alternate screen buffers
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-05 15:26:54 +02:00
David Herrmann
3ae49a8fdb terminal/screen: save state in separate object
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-05 14:57:19 +02:00
David Herrmann
9ed6e68e52 terminal/subterm: skip setting parent's cursor
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-05 14:47:57 +02:00
David Herrmann
621dbb0569 terminal: fix TERM_FLAG_* comment
7BIT mode is enabled by default. Fix the comment to state this correctly.
2014-10-05 14:45:33 +02:00
Tom Gundersen
b7af2c8740 terminal: fix restoring of screen flags 2014-10-05 14:17:14 +02:00
David Herrmann
ce04e2335a terminal/screen: adjust screen age only on update
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-03 15:57:00 +02:00
David Herrmann
56dec05d29 terminal/screen: add color converter
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-03 15:57:00 +02:00
David Herrmann
cad8fe9a2b terminal/screen: add cursor rendering
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-03 15:57:00 +02:00
David Herrmann
2ea8d19b21 terminal/screen: mark cursor dirty on enabled/disable
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-03 15:57:00 +02:00
David Herrmann
884964a963 terminal/idev: add helper to match keyboard shortcuts
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-03 15:57:00 +02:00
David Herrmann
f8958c3495 terminal/screen: add keyboard mapping
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-03 15:57:00 +02:00
David Herrmann
fe741a85c1 terminal/idev: don't map XKB_KEY_NoSymbol as ASCII 0
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-03 15:57:00 +02:00
David Herrmann
61d0326a5b terminal/unifont: add built-in fallback glyph
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-03 15:57:00 +02:00
David Herrmann
cb51a41fa6 terminal/subterm: use screen renderer
Don't hard-code the screen renderer but use the newly introduced
term_screen_draw() helper.
2014-10-03 15:57:00 +02:00
David Herrmann
be50221384 terminal: add screen renderer
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-03 15:57:00 +02:00
David Herrmann
1bfa594cf2 terminal/drm: clear 'applied' flag when changing state
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-03 15:57:00 +02:00
David Herrmann
66695cc343 terminal/grdev: allow arbitrary fb-age contexts
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-03 15:57:00 +02:00
David Herrmann
51cff8bded terminal/grdev: provide front and back buffer to renderers
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-03 15:57:00 +02:00
David Herrmann
aec3f44651 terminal/drm: provide pipe->target() callback
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-03 15:57:00 +02:00
David Herrmann
6a15ce2b3e terminal/grdev: simplify DRM event parsing
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-03 15:57:00 +02:00
David Herrmann
f1f5b2a3bd terminal: make utf8 decoder return length
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-03 15:57:00 +02:00