<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/render.c, branch releases/1.14</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=releases%2F1.14</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=releases%2F1.14'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2023-03-30T14:13:18Z</updated>
<entry>
<title>render: protect against integer underflow when calculating scroll area</title>
<updated>2023-03-30T14:13:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-03-28T16:31:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7bc22862fa9536cb2f18b030209a95306e57360d'/>
<id>urn:sha1:7bc22862fa9536cb2f18b030209a95306e57360d</id>
<content type='text'>
When applying scroll damage, we calculate the affected region’s
height (in pixels), by subtracting the number of rows to scroll, from
the scrolling region, and finally multiply by the cell height.

If the number of rows to scroll is very large, the subtraction may
underflow, resulting in a very large height value instead of a
negative one.

This caused the check for "scrolling too many lines" to fail. That in
turn resulted in an integer overflow when calculating the source
offset into the rendered surface buffer, which typically triggered a
segfault.

This bug happened when there was continuous output in the terminal
without any new frames being rendered. This caused a buildup of scroll
damage, that triggered the underflow+overflow when we finally did
render a new frame.

For example, a compositor that doesn’t send any frame callbacks (for
example because the terminal window is minimized, or on a different
workspace/tag) would cause this.

Closes #1305
</content>
</entry>
<entry>
<title>render: fix glitchy selection while resizing the ‘normal’ screen</title>
<updated>2023-03-27T14:53:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-03-27T14:53:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=296e75f4f54f56be7d36fcccb032dca9e5be959b'/>
<id>urn:sha1:296e75f4f54f56be7d36fcccb032dca9e5be959b</id>
<content type='text'>
The selection coordinates are in absolute row numbers. As such,
selection breaks when interactively resizing the normal grid, since we
then instantiate a temporary grid mapping directly to the current
viewport (for performance reason, to avoid reflowing the entire grid
over and over again).

Fix by stashing the actual selection coordinates, and ajusting the
"active" ones to the temporary grid.
</content>
</entry>
<entry>
<title>render: resize: call xdg_toplevel_set_min_size()</title>
<updated>2023-03-02T16:22:27Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-03-02T16:22:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=514fcc20a73feec88f9a912a8dedf7eac40ca55b'/>
<id>urn:sha1:514fcc20a73feec88f9a912a8dedf7eac40ca55b</id>
<content type='text'>
This is a hint to the compositor, not to set a smaller size than this.
</content>
</entry>
<entry>
<title>render: fix inversed cursor fg color when alpha != 1.0, take #2</title>
<updated>2023-02-28T16:49:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-02-28T16:49:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8a849b4b08539766e8251fa9e7d56c557878617b'/>
<id>urn:sha1:8a849b4b08539766e8251fa9e7d56c557878617b</id>
<content type='text'>
No need to check if terminal colors have been reversed - this is done
by the cell rendering logic.

This hopefully fixes all remaining issues with invisible text when
background alpha &lt; 1.0
</content>
</entry>
<entry>
<title>render: fix selected cursor cell being ‘invisble’ when background alpha is used</title>
<updated>2023-02-27T16:51:29Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-02-27T16:51:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7a43737745e5e6d8c5ef1cb29ade75b6ca2d6f03'/>
<id>urn:sha1:7a43737745e5e6d8c5ef1cb29ade75b6ca2d6f03</id>
<content type='text'>
... by taking the cell ‘selected’ state into account when determining
whether to use the default fg or bg as the ‘text’ color.
</content>
</entry>
<entry>
<title>render: fix incorrect indent introduced by previous commit</title>
<updated>2023-01-17T23:49:32Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2023-01-17T23:49:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b81b98d47c9570f2ac7356b1ff68a284b03759b5'/>
<id>urn:sha1:b81b98d47c9570f2ac7356b1ff68a284b03759b5</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: fix double-width glyphs glitching when surrounding cells overflow into it</title>
<updated>2023-01-17T18:43:47Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-01-15T13:42:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=a9298959a188013530257a665d839a6343229b85'/>
<id>urn:sha1:a9298959a188013530257a665d839a6343229b85</id>
<content type='text'>
If cells overflowed (for example, by using an italic font that isn’t
truly monospaced) into a double-width glyph (that itself is *not*
overflowing), then the double-width glyph would glitch when being
rendered; typically the second half of it would occasionally
disappear.

This happened because we tried to rasterize the second cell of the
double-width glyph. This cell contains a special “spacer”
value. Rasterizing that typically results the font’s “not available”
glyph.

If _that_ glyph overflows, things broke; we’d later end up forcing a
re-render of it (thus erasing half the double-width glyph). But since
the double-width glyph _itself_ doesn’t overflow, _it_ wouldn’t be
re-rendered, leaving it half erased.

Fix by recognizing spacer cells, and not trying to rasterize them (set
glyph count to 0, and cell count to 1).

Closes #1256
</content>
</entry>
<entry>
<title>render: maybe_resize(): remove debug assert</title>
<updated>2022-11-01T16:12:16Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-11-01T16:12:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=30d088376cf8f5c44f393ce876f9a3a10f1dcd82'/>
<id>urn:sha1:30d088376cf8f5c44f393ce876f9a3a10f1dcd82</id>
<content type='text'>
This, depending on which compiler being used, caused issues not only
in debug builds, but release builds as well (with NDEBUG defined).
</content>
</entry>
<entry>
<title>render: never apply alpha to text color</title>
<updated>2022-10-30T18:43:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-30T18:39:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=2c2a39317be3df4ff9899896067684408526fb29'/>
<id>urn:sha1:2c2a39317be3df4ff9899896067684408526fb29</id>
<content type='text'>
When drawing a block cursor using inversed fg/bg colors, we didn’t
strip the alpha from the background color. This meant that the text
"behind" the cursor was rendered with transparency. If alpha was set
to 0, the text was completely invisible.

We should never apply alpha to the text color. So, detect this, and
force alpha to 1.0.

Normally, when selecting the cursor’s color, we don’t really know
_where_ the background color is coming from (or more accurately,
_what_ it is).

However, the *only* background color that can have a non-1.0 alpha is
the *default* background color.

This is why we can ignore the bg parameter, and use term-&gt;colors.fg/bg
instead.

Closes #1205
</content>
</entry>
<entry>
<title>render: resize: do full text reflow immediately if resize-delay-ms == 0</title>
<updated>2022-10-23T08:34:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-23T08:34:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=59c9dfe109f9045b583299d934ac54b8a07749d2'/>
<id>urn:sha1:59c9dfe109f9045b583299d934ac54b8a07749d2</id>
<content type='text'>
That is, skip all custom grid handling when doing an interactive
resize, if resize-delay-ms == 0.
</content>
</entry>
<entry>
<title>interactive resize: improve user experience</title>
<updated>2022-10-17T16:49:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-17T16:49:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0ac0d0647ae996bcef119d885cbd2d22a9940d8d'/>
<id>urn:sha1:0ac0d0647ae996bcef119d885cbd2d22a9940d8d</id>
<content type='text'>
Re-initialize the temporary ‘normal’ grid instance each time we
receive a configure event while doing an interactive resize.

This way, window content will not be "erased" when the window is first
made smaller, then larger again.

And, if the viewport is up in the scrollback history, increasing the
window size will reveal more of the scrollback, instead of just being
black.

The last issue is the cursor; it’s currently not "stuck" where it
should be. Instead, it follows the window around. This is due to two
things:

1) the temporary grid we create is large enough to contain the current
   viewport, but not more than that. That means we can’t "scroll up", to
   hide the cursor.

2) grid_resize_without_reflow() doesn’t know anything about
   "interactive resizing". As such, it will ensure the cursor is bound
   to the new grid dimensions.

I don’t yet have a solution for this. This patch implements a
workaround to at least reduce the impact, by simply hiding the cursor
while we’re doing an interactive resize.
</content>
</entry>
<entry>
<title>render: rename term-&gt;render.resizing -&gt; term-&gt;interactive_resizing</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-09T14:17:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=298f210ed93a83a531a44f772172da7f64510217'/>
<id>urn:sha1:298f210ed93a83a531a44f772172da7f64510217</id>
<content type='text'>
But also, more importantly, logical fixes:

* Stash the number of new scrollback lines the stashed ‘normal’ grid
  should be resized *to*.

There’s also a couple of performance changes here:

* When doing a delayed reflow (tiocswinsz timer), call
  sixel_reflow_grid(term, &amp;term-&gt;normal) - there’s no need to reflow
  sixels in the ‘alt’ screen.

* When doing a delayed reflow, free all scroll damage. It’s not
  needed, since we’re damaging the entire window anyway.

* Use minimum size for the temporary ‘normal’ grid (that contains the
  current viewport). We just need it to be large enough to fit the
  current viewport, and be a valid grid row count (power of 2). This
  just so happens to be the current ‘alt’ grid’s row count...
</content>
</entry>
<entry>
<title>render: resize: do delayed reflow immediately when failing to arm tiocswinsz timer</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-09T14:16:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c550d67cd856ba806c616ac2f15bdbca283e0a67'/>
<id>urn:sha1:c550d67cd856ba806c616ac2f15bdbca283e0a67</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: delayed reflow: not enough to damage current view; need to refresh too</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-09T14:11:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d4b0b0887e73c80cf5ff22fdbac82947897b2b91'/>
<id>urn:sha1:d4b0b0887e73c80cf5ff22fdbac82947897b2b91</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: resize: ignore ptmx read events during interactive resize</title>
<updated>2022-10-10T15:19:18Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-06T15:23:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f4f1989b6ef341557cc90a6805d745fef2a7a815'/>
<id>urn:sha1:f4f1989b6ef341557cc90a6805d745fef2a7a815</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: performance improvements during interactive resize</title>
<updated>2022-10-10T15:19:17Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-06T15:09:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3565cbd636dacf15049504d686219b787783733c'/>
<id>urn:sha1:3565cbd636dacf15049504d686219b787783733c</id>
<content type='text'>
Instead of copying the entire grid when an interactive resize is
started, stash the complete grid (to be used in the final reflow).

Copy the current viewport only, to be used during the interactive
resize.

This gets rid of the initial "pause" when snapshotting the grid when
an interactive resize is started.
</content>
</entry>
<entry>
<title>render: delay reflow for ‘resize-delay-ms’ milliseconds</title>
<updated>2022-10-10T15:19:17Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-10-05T15:05:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=8179d73daa95dc3b3bdd76eaecc78e456bb4686a'/>
<id>urn:sha1:8179d73daa95dc3b3bdd76eaecc78e456bb4686a</id>
<content type='text'>
Reflowing a large scrollback is *slow*. During an interactive resize,
it can easily take long enough that the compositor fills the Wayland
socket with configure events. Eventually, the socket becomes full and
the compositor terminates the connection, causing foot to exit.

This patch is work-in-progress, and the first step towards alleviating
this.

It delays the reflow by:

* Snapshotting (copying) the original grid when an interactive resize
  is started.
* While resizing, we apply a simple truncation resize of the
  grid (like we handle the alt screen).
* When the resize is done, or paused for ‘resize-delay-ms’, the grid
  is reflowed.

TODO: we *must* not allow any changes to the temporary (truncated)
grid during the resize. Any changes to the grid would be lost when the
final reflow is applied. That is, we must completely pause the ptmx
pipe while a resize is in progress.

Future improvements:

The initial copy can be slow. We should be able to avoid it by
rewriting the reflow algorithm to not free anything. This is
complicated by the fact that some resources (e.g. sixel images) are
currently *moved* to the new grid. They’d instead have to be copied.
</content>
</entry>
<entry>
<title>render: fix nanosec "overflow" when calculating timeout value</title>
<updated>2022-10-05T14:51:25Z</updated>
<author>
<name>Alexey Sakovets</name>
<email>alexeysakovets@gmail.com</email>
</author>
<published>2022-10-03T16:41:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=37218be64853dccd5574a7f5de7193c0e1a7b5e6'/>
<id>urn:sha1:37218be64853dccd5574a7f5de7193c0e1a7b5e6</id>
<content type='text'>
</content>
</entry>
<entry>
<title>render: overlay: fix visual glitches when double buffering</title>
<updated>2022-09-23T18:33:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-09-22T16:39:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=3be44fb316b166c0b5d5536fdb5bb6c7abdd3a90'/>
<id>urn:sha1:3be44fb316b166c0b5d5536fdb5bb6c7abdd3a90</id>
<content type='text'>
When rendering the overlay for scrollback search, the logic assumed
buffer re-use. On some compositors this isn’t happening (on
e.g. KDE/plasma we’re forced to double buffer).

This resulted in matches not being highlighted correctly.

The problem is in how we calculated the region for which areas to
clear ("un-dim"). It uses the "previous frame’s see-through area"
minus the current frame’s see-through area.

However, when we’ve detected that the current buffer isn’t the same as
the last one, we set the last frame’s see-through region to "the
entire buffer". Thus, when calculating the diff, we end up with an
empty region, and nothing is highlighted.

Fix by simply using the current frame’s see-through region as-is when
we’ve detected we’re not re-using the last frame’s buffer.
</content>
</entry>
<entry>
<title>render: fix application of old scroll damage when double buffering</title>
<updated>2022-09-23T18:33:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-09-22T16:34:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=4340f8a3b4c5149825d8f1786cfeb7a3af9c0e51'/>
<id>urn:sha1:4340f8a3b4c5149825d8f1786cfeb7a3af9c0e51</id>
<content type='text'>
On compositors that forces us to double buffer, we need to re-apply
the last frame’s damage to the current frame (which uses the buffer
from the next-to-last frame).

General cell updates are handled by simply copying from the last
frame’s pixman buffer to the current frame’s.

In an attempt to improve performance, scroll damage were up until now
handled by re-playing the last frame’s scroll damage (on the current
frame’s buffer). This does not work, and resulted in glitches when
scrolling in the scrollback.

This patch does the following:

* grid_render_scroll{,_reverse}() now update the buffer’s "dirty"
  region. This means the generic copy-old-frames-buffer handles the
  scroll damage (albeit in, potentially, a less efficient way).

* Tracking of, and re-applying old scroll damage is completely
  removed.

Closes #1173
</content>
</entry>
</feed>
