1256 Commits

Author SHA1 Message Date
Peifeng Yu
5abd14191c pty: remove deprecated signal constant SIGUNUSED
With glibc 2.6, the obsolete signal constant SIGUNUSED is no longer defined by signal.h.
2018-01-03 15:46:38 -05:00
Aetf
dac3c31b9e drm3d: fix coordinate in uterm_display_fill, finally fixed margin color issue 2018-01-03 15:40:11 -05:00
Aetf
e3fe7277b6 Use background color rather than hardcoded black color to fill margin 2018-01-03 15:40:11 -05:00
Aetf
7b049cee0c text: font: implement underlines 2014-10-13 17:05:01 +08:00
David Herrmann
074792020c Partly revert "shl: handle pathconf() errors"
This partly reverts commit 41e76d11dff6dd9bc08bf829751f9634f32cdd38. I
removed the "superfluous" errno-handling, which in fact is needed. Turns
out pathconf() might leave errno unchanged.

Reported-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-25 11:56:50 +02:00
Lubomir Rintel
41e76d11df shl: handle pathconf() errors
It can return -1 (feature not supported, denied by a security module, etc.),
resulting in wrong allocation later on.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
(remove superfluous errno-checks)
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2014-05-25 11:42:27 +02:00
David Herrmann
3b6fb0f75f uterm: drm: activate context before swapping
Lets be safe here and activate the context before performing the
buffer-swap. Drivers might be inconsistent and require this in case the
background process changed the DRM state.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-04 19:37:05 +01:00
David Herrmann
48bf4bd58f uterm: drm: force immediate modeset during wakeup
We need to call drmModeSetCrtc during wakeup to prepare for page-flips. An
immediate modeset is needed, otherwise we cannot be sure the FB/Crtc
configuration is still the same.

Force an immediate DRM modeset on wakeup to reset the screen.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-04 08:07:43 +01:00
David Herrmann
9b944add91 uterm: drm: set VIDEO_HOTPLUG on wakeup
Be more verbose during wake-up and set VIDEO_HOTPLUG so we force the
hotplug-check. I don't know why it worked until now, but we definitely
need to force it as we have no idea what display-status changed.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-04 08:05:28 +01:00
David Herrmann
a11d71a987 uterm: input: forward xkbcommon log messages
Instead of letting xkbcommon write to stderr, we now forward these
messages via the llog handler.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:25:18 +01:00
David Herrmann
4bcf507302 shl: log: check for trailing newlines
If the format string contains a trailing newline, we now skip writing our
own. We also skip the fn+file information as it would be written on the
next line.

Trailing newlines occur only when forwarding messages from other
libraries. In this case we don't need the fn+file information, anyway.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:24:55 +01:00
David Herrmann
7e095d9db3 shl: log: don't use strerror()
strerror() is not re-entrant safe so we should use %m instead.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:24:14 +01:00
David Herrmann
37eae950f0 uterm: input: use shl_llog instead of shl_log
We should use library-logging in uterm to avoid cluttering stderr for
applications. Hence, use llog instead of log directly.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:23:26 +01:00
David Herrmann
8050a28beb uterm: input: add built-in keymap fallback
This adds a small US-keymap to the uterm library which is loaded if we
cannot find a suitable system default keymap. This allows using the keymap
if no XKB keymaps are installed.

Thanks to Ran Benita for the minimal US keymap.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:22:08 +01:00
David Herrmann
118935c906 genunifont: remove useless status message
No reason to clutter build output with this debug message. Drop it.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:19:56 +01:00
David Herrmann
6f14e5905d build: replace genshader by binary linker
Instead of generating C source files, we now use our binary-linker make
target which can link in any arbitrary binary file.

This way, we can delete genshader and instead link the files directly.
This speeds up compilation and makes the code more consistent.
We also strip the shaders from useless comments and whitespaces to reduce
memory consumption.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:15:35 +01:00
David Herrmann
0a098393c2 shl: shader: add "len" parameter to shader sources
Shader sources may not be 0 terminated if we mmap() them. Hence, we need
to pass the length to the shader compiler. As glShaderSource() allows this
<0 as zero-terminated strings, we can simply add a parameter for the
shader length.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:12:29 +01:00
David Herrmann
924a732e7c shl: move static_gl_* to shl_gl_*
No need to keep these static helpers outside of SHL. Instead, include them
in SHL to avoid any external linking.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-11-03 12:12:07 +01:00
David Herrmann
1e94fc361e Remove cairo text-renderer
The cairo text-renderer is _way_ too slow. There's no reason to keep it
around, anymore.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-29 10:07:46 +01:00
David Herrmann
9f2f11d2a5 Remove libuvt
uvt is not used inside of kmscon. Moved into a separate library if
some-one is interested.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-29 10:01:13 +01:00
David Herrmann
761434ecac Remove freetype2 font backend
The freetype2 font backend lacks support for proper combining marks and I
do not intend to ever implement that. Use pango!

If you don't want heavy dependencies, you can use the unifont or 8x16
backends.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-29 09:31:03 +01:00
David Herrmann
96b28e953d tsm: remove and depend on libtsm
TSM was extracted from kmscon sources so it can more easily be used by
other emulators. It is available at:
  http://cgit.freedesktop.org/~dvdhrm/libtsm

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23 16:55:59 +02:00
David Herrmann
972ec107cf kmscon: remove cdev sessions
cdev sessions are outdated. Use libuvt instead. Remove all references to
cdev-sessions and clean up the build chain.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23 15:22:28 +02:00
David Herrmann
bcfb1d2ab5 uvtd: remove
Remove uvtd. The idea is outdated and not really needed. With recent
systemd-logind changes, all we need is a shim between legacy-programs
(like XServer) and logind. We can easily do that via libuvt without
requiring a huge daemon like uvtd.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23 15:15:50 +02:00
David Herrmann
695c855da3 wlterm: remove
Remove all wlterm sources. I never intended to maintain it longer than any
major terminal-emulator needs to get ported over to wayland. Hence, remove
it. It was buggy, anyway.

If anyone is interested, a GTK+ based wlterm is available on:
  http://cgit.freedesktop.org/~dvdhrm/wlterm

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23 15:11:21 +02:00
David Herrmann
cdd87983a0 dummy: redraw on display-refresh
If we get a display-refresh event, redraw the screen. Otherwise, we might
stay blank during VT switches if we get a delayed set-master.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23 13:45:18 +02:00
David Herrmann
709cece883 terminal: redraw on display-refresh
If we get a display-refresh event from the session layer, we must redraw
the screen to avoid staying blank.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-23 13:44:48 +02:00
David Herrmann
53f163537c seat: forward UTERM_REFRESH events to sessions
On UTERM_REFRESH events we now forward the event to all sessions on the
bound seat. Sessions can then react to it and repaint the screen.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-18 18:33:03 +02:00
David Herrmann
b17b3c9378 uterm: drm: retry DRM wakeup after short timeout
If drm-wakeup fails, we now retry after 20ms continously to gain
DRM-Master again. If we succeed we send UTERM_REFRESH events for all
available displays so existing code can pick it up.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-18 18:32:50 +02:00
David Herrmann
0b37478d3f genunifont: fix MAX_DATA_SIZE to be in 8bit range
We only use uint8_t as length-counter so MAX_DATA_SIZE must be <256 to
make our length-checks work. This fixes a bug where we read invalid data
if someone uses modified genunifont data files. As this just produces
garbled glyphs if garbled data is given, this is actually not critical at
all.

Reported-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-18 17:59:34 +02:00
David Herrmann
2157b039ac genunifont: fix ftell() error checking
We need to use signed types to actually see errors from ftell(). Fix it by
using "long" for status bits now.

Reported-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-18 17:56:46 +02:00
David Herrmann
b00dde0bc9 uterm: drm: move display_ops into vdrm object
Instead of passing display-ops to every helper store it in vdrm-objects.
During vdrm-setup we set the pointer and reuse it in all helpers. This
simplifies the function headers and allows calling them from
helper-callbacks without requiring a pointer from the respective user.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-10-18 17:17:26 +02:00
Ran Benita
ca22b38421 wlt: toolkit: flush display after wl_display_dispatch_pending()
wlterm doesn't work with current Wayland/Weston; the events are never
sent and the window doesn't come up. We need to flush the display, as
per wl_display_dispatch_pending(3):

    To proper integrate the wayland display fd into a main loop, the
    client should always call wl_display_dispatch_pending() and then
    wl_display_flush() prior to going back to sleep.

Signed-off-by: Ran Benita <ran234@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-09-12 13:04:51 +02:00
David Herrmann
a4ed3959d8 kmscon: set default precision for fragment shaders
With mesa-9.2 fragment shaders are required to define default precisions
as defined in the standard. We didn't do this.. whoops. Add the mediump
declarations and everything should be working again.

fixes fdo bug: #68934

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-09-04 15:02:03 +02:00
David Herrmann
c4193b81d7 gltex: fix GL_UNPACK_ROW_LENGTH(_EXT) update
Khronos updated their GLES2 headers and broke backwards compatibility,
hurray. Fix it for real now.

Reported-by: Yichao Yu <yyc1992@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-08-19 23:30:54 +02:00
David Herrmann
31d7b4d596 uterm: drm3d: fix GL_UNPACK_ROW_LENGTH(_EXT) macro
Khronos "fixed" their new OpenGLES2 headers and added a bunch of _EXT
suffixes. Now we need to test for both, the old and new macros, yay!

Thanks to Yichao Yu for spotting that.

Reported-by: Yichao Yu <yyc1992@gmail.com>
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-08-19 23:15:43 +02:00
David Herrmann
4962213bac kmscon: pass vtnr to pty so XDG_VTNR is set
We need to correctly set the VTNR for each new pty, otherwise the pty
cannot set the XDG_VTNR correctly. Note that we do this only for real VTs,
that is, vtnr > 0.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-06-12 15:53:03 +02:00
David Herrmann
35eb595863 pty: set XDG_VTNR if requested by caller
A caller can now pass a VT-num to the PTY which will get set as XDG_VTNR
in the environment of new childs.

This can be used to tell systemd-logind to associate the session with
the correct VT. But note that this still cannot overwrite VT-associations
if the pty is created from within an existing session.

Reported-by: Thomas Hebb
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-06-12 15:50:03 +02:00
David Herrmann
066cf51445 uterm: vt: add uterm_vt_get_num() helper
This helper returns the VT-number for the given VT if, and only if, it
is a real VT. In all other cases 0 is returned.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-06-12 15:43:17 +02:00
David Herrmann
3d2d8f5984 wlt: toolkit: dont depend on implicit buffer releases
Wayland compositors are not required to send buffer release notifications
on an implicit buffer-attach. That is, an attach->commit->commit series
does not cause a buffer-release notification after the second commit.

Hence, send a buffer-attach on every commit that requires a new
buffer-release notification.

For the related wayland-protocol changes, see:
  http://cgit.freedesktop.org/wayland/wayland/commit/?id=7165bf21917ed1c4f5ec823a1e1642a9e83aa984

This fixes a bug where wlterm only redraws the window-content when
resizing (due to explicit buffer-attach calls during redraw).

Reported by: MoD
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-06-11 18:57:38 +02:00
Ran Benita
d240c27ecb kmscon: add --xkb-keymap option for predefined keymaps
This adds an --xkb-keymap <FILE> option to kmscon. When given, kmscon
will try to compile the keymap from the file before trying the other
options (like the XkbKeymap option in xorg.conf).

This is useful for users who have a customized XKB keymap, which is
usually kept in a single file. Example, in X:
	xkbcomp $DISPLAY my_keymap.xkb
Customize my_keymap.xkb to your liking, and then in .xinitrc, or
xorg.conf:
	xkbcomp my_keymap.xkb $DISPLAY
Now you can also do this in kmscon.conf.

Additionally, lacking such an option, kmscon is quite difficult to use
without an installed xkeyboard-config package, which provides the
infrastructure for the "rules" configuration mechanism. We might even
want to distribute some plain xkb file as a last ditch, for
robustness, if even the default RMLVO fails... without a keyboard a
terminal is not very useful.

(changed Ran's patch to use *_from_string() instead of *_from_file())
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-12 17:31:47 +01:00
David Herrmann
e6d0d78543 shl: add shl_read_file() helper
This reads in a complete file as a string and returns it to the caller.
The string is 0 terminated (which isn't guaranteed by mmap()) so this
helper is needed if we have to work with APIs that don't accept buffer
lengths.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-12 17:16:49 +01:00
David Herrmann
ddf4126c11 kmscon: implement dynamic font-resizing via shortcuts
This implements two new keyboard shortcuts zoom-in and zoom-out that
increase/decrease font size of the current terminal.

This is similar to how wlterm does it and allows runtime modification of
fonts.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-09 13:51:05 +01:00
David Herrmann
9f0bb1262d terminal: clear unused margins on each frame
If the terminal screen is smaller than the real screen, we never paint to
the margins. This doesn't hurt as long as we never resize the terminal.
The uterm layer clears all framebuffers during allocation.

However, uterm behavior may change and our terminal may get resized (eg.,
during hotplugging) so we really should clear all the margins.

We now clear them on every frame as it is a trivial task. However, if we
speed up rendering, we should probably set a "needs_clear" flag that
simply clears the framebuffer.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-09 13:47:00 +01:00
David Herrmann
40f6811a07 terminal: share font settings across screens
We currently retrieve one font object per screen (which is in fact shared
in the font-layer), but we can also move it one layer up to the terminal
layer. This shares the same font per terminal between all screens.

This simplifies on-the-fly font modifications and speeds up monitor
hotplugging.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-09 13:19:05 +01:00
Chang Liu
e874518153 font: pango: fix vertical alignment of non-ASCII glyphs
pango_ft2_render_layout_line() requires the baseline offset as argument,
not the vertical extent of the glyphs. This is important as we currently
align glyphs to the bottom edge instead of the baseline.

Fix this by passing the cached baseline offset so all glyphs are correctly
aligned to the baseline. We then clip according to the cell-extents as
usual.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-09 12:26:48 +01:00
David Herrmann
1658bd8216 wlt: theme: change frame color to white plus black border
It is currently pretty annoying to use multiple wlterm windows stacked on
top on each other when the terminal-background is black. The border
doesn't use multiple colors so it is hard to distinguish from the
main-frame.
This patch changes the border color to white (as most terminal-backgrounds
are black by default) and additionally draws a black 1px frame around it.
This guarantees that the frame is even visible with white terminal
backgrounds.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-09 11:31:11 +01:00
David Herrmann
e1344b5691 uvtd: vt: return -ENODEV if session died
We now keep a link to our parent seat and set it to NULL when our session
is unregistered. In this case, any further request that depends on the
session being registered and probably a valid seat pointer, we will stop
with ENODEV.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-06 19:21:57 +01:00
David Herrmann
fb08eea373 uvtd: vt: implement VT_GETMODE/SETMODE ioctl state-tracking
These ioctls are used to retrieve and set the VT-mode. That is, the
signals and PID information that correspond to the VT controlling process.
It is notified whenever the VT gets active/inactive so it can react to it
or prevent/acknowledge it.

This doesn't implement the signal-sending logic, yet. It only implements
state-tracking.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-06 19:03:34 +01:00
David Herrmann
066d9fdb78 uvtd: seat: implement session IDs
Session IDs provide a unique ID for each registered session. They are used
to sort the sessions so next/prev return the correct neighbour-sessions.
Furthermore, they can be used by outside users to refer to a session
directly without knowing the session implementation.
Sessions with ID=0 are always linked at the end and considered to be
"unnamed".

The algorithm to switch to a session with a given ID is:
  Try to find the first session with the exact same ID. If there is none,
  return the session with the next higher ID. If there is none, return the
  ID'th session in the list. If there is none, return the last session.

This provides a fairly predictable way of switching between session. It is
modeled after the classic VT F1-F12 keys that switch between sessions. If
a session is not given, these keys will switch to the next higher session
instead.
All "unnamed" sessions are put at the end. So if you have only F1-F4, then
F5-F12 will map to unnamed sessions.

Please note that new sessions are always linked at the end of their group.
So new unnamed sessions are at the far end, new named sessions are linked
in the sorted list but behind all sessions with the same ID.
Hence, the caller should avoid multiple sessions with the same ID,
otherwise, some sessions might not be reachable even though they're named
(unless you use next/prev of course).

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
2013-03-06 18:21:25 +01:00