Commit graph

125 commits

Author SHA1 Message Date
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
Daniel Eklöf
dcf6d18872
render: log frame rendering time with microseconds instead of milliseconds 2019-08-24 11:32:28 +02:00
Daniel Eklöf
74a0c5f3fc
render: change resize debug log message to an info log message 2019-08-23 17:23:09 +02:00
Daniel Eklöf
7c7720a3ab
scrolling: optimize row access by assuming number of rows is a power of 2
With this assumption, we can replace 'a % b' with 'a & (b - 1)'. In
terms of instructions, this means a fast 'and' instead of a slow
'div'.

Further optimize scrolling by:

* not double-initializing empty rows. Previously, grid_row_alloc()
  called calloc(), which was then followed by a memset() when
  scrolling. This is of course unnecessary.

* Don't loop the entire set of visible rows (this was done to ensure
  all visible rows had been allocated, and to prefetch the cell
  contents).

  This isn't necessary; only newly pulled in rows can be NULL. For
  now, don't prefetch at all.
2019-08-22 17:33:23 +02:00
Daniel Eklöf
c1903f5522
render: multiply width/height with *new* scale factor, not old 2019-08-21 17:56:41 +02:00
Daniel Eklöf
d5bc46f333
render: reload cursor theme when scale (may) have changed 2019-08-21 17:53:52 +02:00
Daniel Eklöf
d84b485202
render: don't 're-calculate fg unnecessarily 2019-08-18 18:11:38 +02:00
Daniel Eklöf
9b6d0cfcd1
render: minor optimization
Don't instantiate a pixman color unnecessarily when drawing a block
cursor.
2019-08-17 17:43:47 +02:00
Daniel Eklöf
80aef9b6af
render: use 32-bit pixman calls, where applicable 2019-08-17 17:36:27 +02:00
Daniel Eklöf
72d3cbca26
shm/render: there's no need to have one pixman image per thread 2019-08-16 22:54:05 +02:00
Daniel Eklöf
81107753bf
render: replace all usage of cairo with pixman 2019-08-16 22:06:06 +02:00
Daniel Eklöf
bed7b34c28
wip: render background and glyphs using pixman 2019-08-16 20:40:32 +02:00
Daniel Eklöf
9fe6e8cc48
Add background alpha support 2019-08-15 18:15:43 +02:00
Daniel Eklöf
c2451e2a80
output: track output we're mapped on, and use maximum scale
Our surface may be on multiple outputs at the same time. In this case,
we use the largest scale factor, and let the compositor down scale on
the "other" output(s).
2019-08-12 21:49:17 +02:00
Daniel Eklöf
05e91fa9df
output: resize on scale changes 2019-08-12 21:33:24 +02:00
Daniel Eklöf
74f723e0cf
output: initial support for output scaling
* Not updated run-time; only scale at start up used
* Multiple monitors (outputs) not supported, as we can't track which
  output we're on (yet).
2019-08-12 21:33:24 +02:00
Daniel Eklöf
c6640adde3
render: fix foreground color for non-block cursor
When rendering either the 'bar' or 'underline' cursor styles, only use
the configured "cursor color" if it has actually been configured.

If it hasn't, use the current foreground color.
2019-08-12 20:00:28 +02:00
Daniel Eklöf
2a8962fd1a
render: selection may not be "ordered", since it may not have been finalized 2019-08-08 17:58:06 +02:00
Daniel Eklöf
1e08d93528
selection: ensure start < end in finalize
When the selection is finalized, swap start/end if necessary, to make
sure start <= end.
2019-08-05 20:15:18 +02:00
Daniel Eklöf
c411dedc3b
render: make sure the current view is allocated and visible 2019-08-04 18:34:14 +02:00