Commit graph

144 commits

Author SHA1 Message Date
Daniel Eklöf
c22ae98729
render: get rid of 'all-clean' detection
Instead of trying to figure out if we had to render
something (i.e. something in the grid was dirty), and using that to
determine whether to post a callback or not, we now let
render_refresh() set a flag indication we need to render another
frame.

This simplifies render_grid(), which now _always_ renders, and pushes
it to the compositor.

The callback handler checks the pending flag and simply doesn't call
render_grid() when there's no more pending state to render.

This ends up reducing the number of wakeups when e.g. having a
blinking cursor.
2019-12-17 19:14:56 +01:00
Daniel Eklöf
418ff5bcd9
render: move blink timer handling to term.c 2019-12-17 19:14:55 +01:00
Daniel Eklöf
7a3fb9284e
render: render block cursor as a hollow rectangle when unfocused 2019-12-16 21:34:38 +01:00
Daniel Eklöf
7d29435d86
term: implement cursor blinking
Blinking can be enabled either by setting the cursor style with

 CSI Ps SP q

and selecting a blinking style.

Or, with 'CSI ? 12 h'

Note that both affect the same internal state. I.e. you can disable
blinking with CSI ? 12l after having selected a blinking cursor
style. This is consistent with XTerm behavior.
2019-12-15 15:07:56 +01:00
Daniel Eklöf
0f15f0ba43
fcft: update to 0.3.0
fcft now calculates the underline and strikeout integer positions,
making our rendering code much simpler.
2019-12-03 21:03:52 +01:00
Daniel Eklöf
b0d555255c
render: limit size of search surface to parent window
This shouldn't be necessary, but Sway acts up when the subsurface
exceeds the parent surface (window, in this case) size, and extends
the window size (if floating), leaving it with no content
2019-12-03 20:19:50 +01:00
Daniel Eklöf
3c71389993
render: don't allow negative coordinates of the search surface
While the protocol allows this, it appears Sway offsets (moves) the
parent surface when this happens, resulting in a window half without
content.
2019-12-03 19:58:33 +01:00
Daniel Eklöf
30335ef32a
fcft: include <fcft/fcft.h>, and use fcft/stride.h instead of local copy 2019-12-01 14:03:24 +01:00
Daniel Eklöf
fd9c28464d
fcft: use fcft instead of local copy of font.c/font.h 2019-12-01 13:43:51 +01:00
Daniel Eklöf
90bfcc1fbd
render: fix underline/strikeout positioning
There were two errors:

* We subtracted half the line width instead of adding it to the
  baseline

* We rounded the line positioning and thickness before the positioning
  calculation. In particular, rounding the thickness before using it
  to adjust the position was wrong. Now we round just before the
  pixman call.
2019-11-30 14:53:22 +01:00
Daniel Eklöf
7be98291e1
render: font_baseline(): simply use the primary font's ascent
This is what we used as baseline for regular glyphs anyway. Thus, we
can update that code to call font_baseline() now. This makes it easier
to change how we define the baseline in the future.
2019-11-30 14:51:44 +01:00
Daniel Eklöf
b96fb2ddab
render: fix rendering of cursor when cell is reversed
When the user had configured the cursor color, we failed to
invert (reverse) the foreground and background color when the cursor
was on a cell with the 'reverse' attribute set.
2019-11-28 19:22:21 +01:00
Daniel Eklöf
bc86cd61c7
font: move metrics from terminal struct to font struct 2019-11-26 19:02:35 +01:00
Daniel Eklöf
d637b8c9ba
term: add struct cursor 2019-11-17 09:44:31 +01:00
Daniel Eklöf
37139fc4fa
render: configure default tab stops when resizing the terminal 2019-11-16 10:54:56 +01:00
Daniel Eklöf
bf9aff056a
Revert "render: last_buf may point to a free:d buffer"
This reverts commit 4d3251a93b.
2019-11-02 01:28:29 +01:00
Daniel Eklöf
4d3251a93b
render: last_buf may point to a free:d buffer
So, store last buf's width/height separately
2019-11-02 00:48:07 +01:00
Daniel Eklöf
00b46455a0
shm: associate a 'cookie' with each buffer
When re-using a buffer from cache, only re-use ones with a matching
cookie.

This prevents contention between multiple terminal windows.
2019-11-02 00:33:37 +01:00
Daniel Eklöf
8df82938b0
shm: get_buffer(): remove 'copies' argument; it's not used 2019-11-02 00:23:51 +01:00
Daniel Eklöf
dac1ba18c8
render: limit length of title in call to xdg_toplevel_set_title()
Trying to pass a too long title (not sure what "too long" is
though...) will trigger a call to abort() inside the wayland-client
library.
2019-11-01 20:25:44 +01:00
Daniel Eklöf
291a928a49
render: call wl_display_flush() after rendering
This allows us to remove that call from the main event loop.
2019-11-01 20:01:36 +01:00
Daniel Eklöf
ad0f8a02d5
Merge branch 'fdm' 2019-10-30 17:31:44 +01:00
Daniel Eklöf
a42df2434b
scrollback: regression: fix rendering of scrollback diffs less than a screen
When doing "small" scrolls (typically done via mouse wheel or
similar), we render the scrolling by emitting a "scroll damage".

A recent commit changed how scroll damage is rendered; only when the
view is at the bottom ("following" the screen output) do we render the
damage.

To fix this, add a new type of scroll damage,
SCROLL_DAMAGE_IN_VIEW and SCROLL_DAMAGE_REVERSE_IN_VIEW.

These signal to the renderer that it should always render the damage.
2019-10-29 21:09:37 +01:00
Daniel Eklöf
8e6f87eb17
render worker context: allocate, and let worker threads free
Since we now initialize the worker threads from term_init(), which
returns before the threads terminate, we can no longer use
stack-allocated worker contexts.

We _could_ put them in the terminal struct. But a simpler solution is
to allocate them in term_init(), and let the threads free them when
they don't need them anymore.
2019-10-28 18:51:04 +01:00
Daniel Eklöf
89cec15920
render: regression: don't apply scroll damage when view is in scrollback
When user has scrolled back in the output history, new output should
not trigger scrolling.

This was true for normal cell rendering, which renders the cells *in
view*, not caring where the "front" of the output is.

However, we still applied scroll damage. I.e. we memmoved part of the
screen.

The fix is simple; only apply scroll damage when the view is at the
front of the output.
2019-10-28 17:58:44 +01:00
Daniel Eklöf
957fb25559
wayland: move reload_cursor_theme() and update_cursor_surface() to wayland 2019-10-27 19:36:45 +01:00
Daniel Eklöf
61cc8c3c55
wayland: implement wayl_init()
Wayland instantiation is now done by the wayland backend, not in main.
2019-10-27 19:08:48 +01:00
Daniel Eklöf
1adab32906
term: wayland struct is now not a part of the terminal struct
We do however need access to it, so provide a pointer. The difference
is that now we can have a *single* wayland instance, but multiple
terminal instances.
2019-10-27 18:51:14 +01:00
Daniel Eklöf
9e6c28f5b6
wayland: implement wayl_win_destroy() 2019-10-27 16:01:44 +01:00
Daniel Eklöf
f63458ef33
term: move per-window wayland objects from wayland struct to terminal struct
Short term, we want to break out the wayland backend from the terminal
struct. Long term, we might want to support multiple windows.

One step towards both the above is separating global wayland objects
from per-window objects.
2019-10-27 12:57:37 +01:00
Daniel Eklöf
a789230cf9
font: font_from_name() returns an allocated font struct 2019-10-16 21:52:12 +02:00
Daniel Eklöf
67905c6000
render: handle compositors that does buffer swapping
Not all compositors support buffer re-use. I.e. they will call the
frame callback *before* the previous buffer has been
released. Effectively causing us to swap between two buffers.

Previously, this made us enter an infinite re-render loop, since we
considered the window 'dirty' (and in need of re-draw) when the buffer
is different from last redraw.

Now, we detect the buffer swapping case; size must match, and we must
not have any other condition that require a full repaint.

In this case, we can memcpy() the old buffer to the new one, without
dirtying the entire grid. We then update only the dirty cells (and
scroll damage).

Note that there was a bug here, where we erased the old
cursor *before* checking for a new buffer. This worked when the buffer
had *not* changed.

Now that we need to handle the case where it *has* changed, we must do
the memcpy() *before* we erase the cursor, or the re-painted cell is
lost.

This makes foot work on Plasma, without burning CPU. The memcpy() does
incur a performance penalty, but we're still (much) faster than
e.g. konsole. In fact, we're still mostly on par with Alacritty.
2019-09-27 19:33:45 +02:00
Daniel Eklöf
b87bf0dd9d
render: attach buffer *before* generating damage
Fixes 'invisible window' on Plasma
2019-09-27 19:33:10 +02:00
Daniel Eklöf
2d6369482e
main: initialize scale to '1'
This ensures we always have a valid (but possibly incorrect) scaling
value. This allows us to simplify code that uses the scale - it
doesn't have to verify the scale if valid.

Furthermore, since render_resize() is the function that actually
updates term->scale, make sure to call it *before* updating the
cursor (otherwise, the cursor will use the old scaling value).
2019-09-26 18:39:49 +02:00
Daniel Eklöf
55968413b6
render: remove assertion that isn't always true
It's not true for e.g. Cascadia code.
2019-09-21 00:45:22 +02:00
Daniel Eklöf
7c4c41fbae
render: search box: use colors from the color table
Use the 'yellow' color from the 'regular' range of colors (SGR 33) for
background when we have a match, or 'red' from the 'regular' range of
colors (SGR 31) when we don't have a match.

Foreground uses the 'black' color from the regular range of
colors (SGR 30).
2019-08-30 21:01:13 +02:00
Daniel Eklöf
e8d187e4f3
render: draw (cursor) bar using the same thickness as underlines 2019-08-30 19:42:33 +02:00
Daniel Eklöf
fcb0e05009
render: search box: fix glyph spacing
We're using the same font as in the terminal, so use the same glyph
spacing.
2019-08-30 19:35:47 +02:00
Daniel Eklöf
2ca7400cc6
render: render_search_box: draw cursor as a bar 2019-08-29 21:03:00 +02:00
Daniel Eklöf
bffa1f05ac
render: draw_strikeout: use font_baseline() for baseline calculation 2019-08-29 20:42:57 +02:00
Daniel Eklöf
1f98c8f787
render: draw_underline: use font_baseline() for baseline calculation 2019-08-29 20:42:45 +02:00
Daniel Eklöf
6e5688d7da
render: draw_bar: don't assume height == ascent+descent
Instead, draw a bar that is ascent+descent tall, positioned around the
baseline such that it starts at the ascent and ends at the descent.
2019-08-29 20:41:40 +02:00
Daniel Eklöf
013cf61ffb
render: add font_baseline() - calculates the y-coordinate for the baseline
The old baseline calculation was copy-pasted to a couple of places,
and also assumed that the font's height was equal to ascent+descent.

While this is typically true, it isn't necessarily so.

Now, we assume that height >= ascent+descent, and then position the
baseline in "center" (but adjusted for the descent).
2019-08-29 20:39:22 +02:00
Daniel Eklöf
3ec7fbf0a3
render: remove INFO log (that really was a debug log) 2019-08-29 20:23:44 +02:00
Daniel Eklöf
2c3ab701e7
search: move render() function to the 'render' module 2019-08-29 20:18:06 +02:00
Daniel Eklöf
2a31c2fbbc
render: reduce amount of dim while searching scrollback history 2019-08-29 19:33:25 +02:00
Daniel Eklöf
242ab66c97
render: double-dim fg+bg when searching the scrollback buffer
By toning down the screen content more, the selection (i.e. the search
match) pops out much more.
2019-08-28 21:53:01 +02:00
Daniel Eklöf
bb4fd58223
render: don't dim selection while searching 2019-08-27 19:40:07 +02:00
Daniel Eklöf
61cabdac13
search: wip: re-direct input while searching, and build a search buffer
This adds a new state, 'is_searching'. While active, input is
re-directed, and stored in a search buffer. In the future, we'll use
this buffer and search for its content in the scrollback buffer, and
move the view and create a selection on matches.

When rendering in 'is_searching', everything is dimmed. In the future,
we'll render the current search buffer on-top of the dimmed "regular"
terminal output.
2019-08-27 17:23:28 +02:00
Daniel Eklöf
2d7ca416f0
render: center grid in window
Instead of placing the upper left corner of the grid at 0,0 in the
window, center it.
2019-08-27 15:25:35 +02:00