<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/shm.c, branch 1.16.1</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.16.1</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.16.1'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2023-10-12T14:16:11Z</updated>
<entry>
<title>shm: memfd_create: fallback to not using MFD_NOEXEC_SEAL</title>
<updated>2023-10-12T14:16:11Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-10-12T14:16:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c006ac3a079d00e30f9d1cd7986d8112724629b4'/>
<id>urn:sha1:c006ac3a079d00e30f9d1cd7986d8112724629b4</id>
<content type='text'>
MFD_NOEXEC_SEAL was introduced in linux 6.3. Kernels before that
will *reject* memfd_create() calls that set it.

This caused foot to exit (i.e. not start at all), when compiled on
linux &gt;= 6.3, but run on linux &lt; 6.3.

We _do_ want to use MFD_NOEXEC_SEAL, since a) our memory mapped really
shouldn't be executable, and b) to silence a warning on linux &gt;= 6.3.

To handle all cases, first try *with* MFD_NOEXEC_SEAL. If that fails
with EINVAL, retry *without* it.

Closes #1514
</content>
</entry>
<entry>
<title>render: more fine-grained wayland surface damage tracking</title>
<updated>2023-10-10T05:56:27Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-10-07T14:23:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c50b1f990093a2a453288b976ef7f6d9a303f793'/>
<id>urn:sha1:c50b1f990093a2a453288b976ef7f6d9a303f793</id>
<content type='text'>
Before this patch. Wayland surface damage tracking was done on a
per-row basis. That is, even if just one cell was updated, the entire
row was "damaged".

Now, damage is per cell. This hopefully results in lower latencies in
many use cases, and especially on high DPI monitors.
</content>
</entry>
<entry>
<title>shm: move definition of FOOT_MFD_FLAGS to the top</title>
<updated>2023-10-08T09:03:13Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-10-08T09:03:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e41555fe0ff0882b79b49c1f00c6b23caa1eaf70'/>
<id>urn:sha1:e41555fe0ff0882b79b49c1f00c6b23caa1eaf70</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: if defined, set MFD_NOEXEC_SEAL flag for memfd_create</title>
<updated>2023-10-05T10:33:05Z</updated>
<author>
<name>6t8k</name>
<email>6t8k@noreply.codeberg.org</email>
</author>
<published>2023-10-05T10:22:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=61eb56dfda605427156b52d019be4bf5ce84c3aa'/>
<id>urn:sha1:61eb56dfda605427156b52d019be4bf5ce84c3aa</id>
<content type='text'>
Effective from Linux 6.3.0 onward, this creates the memfd without
execute permissions and prevents that setting from ever being changed.

This is a defense-in-depth security measure and prevents a respective
kernel warning from being emitted.

See https://lwn.net/Articles/918106/ for more information.
</content>
</entry>
<entry>
<title>Codespell fixes</title>
<updated>2023-10-03T12:12:58Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-10-03T12:12:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5e1d73f3cddcd7f21c80abfbc6914e8f8b0c6f3f'/>
<id>urn:sha1:5e1d73f3cddcd7f21c80abfbc6914e8f8b0c6f3f</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Codespell fixes</title>
<updated>2023-10-03T12:11:55Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2023-10-03T12:11:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=58d967b2f31ebe1f16bd0915f28ec93919d3fddc'/>
<id>urn:sha1:58d967b2f31ebe1f16bd0915f28ec93919d3fddc</id>
<content type='text'>
</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>
<entry>
<title>shm: add shm_did_not_use_buffer()</title>
<updated>2022-04-16T15:47:56Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2022-04-16T15:47:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=abbdd3bae884a4bcea20d5059f25684f9a5a7571'/>
<id>urn:sha1:abbdd3bae884a4bcea20d5059f25684f9a5a7571</id>
<content type='text'>
This allows a caller to return a buffer (obtained with
shm_get_buffer()) to the pool,

The buffer must not have been used. I.e. it must not have been
attached and committed to a wayland surface.
</content>
</entry>
<entry>
<title>replace gettimeofday with clock_gettime</title>
<updated>2022-01-15T16:05:45Z</updated>
<author>
<name>Pranjal Kole</name>
<email>pranjal.kole7@gmail.com</email>
</author>
<published>2022-01-15T09:26:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0da19a81bc9a94f83bfcf8c5af0e3571f751cf38'/>
<id>urn:sha1:0da19a81bc9a94f83bfcf8c5af0e3571f751cf38</id>
<content type='text'>
POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the
use of clock_gettime(2) instead.

CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is
unaffected by manual changes in the system clock. This makes it better
for our purposes, namely, measuring the difference between two points in
time.

tv_sec has been casted to long in most places since POSIX does not
define the actual type of time_t.
</content>
</entry>
<entry>
<title>shm: get_buffer(): make sure buffer-&gt;busy is set</title>
<updated>2021-12-18T13:26:26Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-12-15T11:37:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fc6533c92048029032eaa734ff538b4fccb94c03'/>
<id>urn:sha1:fc6533c92048029032eaa734ff538b4fccb94c03</id>
<content type='text'>
When going through the cached buffers, we only set buffer-&gt;busy on
the *first* re-usable buffer we found.

In some cases, we will find more than one re-usable buffer. In this
case, we select the “youngest” one (i.e the one most recently used, in
the hopes that we can use damage tracking instead of re-rendering the
entire buffer).

If the “current” buffer is younger than the previously detected,
re-usable, buffer, then we unref:ed the previously selected buffer,
and replaced it with the current one.

But, we did not sanitize it. That is, we did not:

* set buffer-&gt;busy
* clear its dirty region
* clear its scroll damage

That buffer would eventually get rendered to, and committed to the
compositor. Later, the compositor would free it. And there, in our
buffer_release() callback, we’d assert that buffer-&gt;busy was
set. And fail.

Closes #844
</content>
</entry>
<entry>
<title>fix crashes when resizing after CSD enabled at runtime with csd.size = 0</title>
<updated>2021-10-04T22:14:58Z</updated>
<author>
<name>feeptr</name>
<email>feeptr@codeberg.org</email>
</author>
<published>2021-09-23T22:17:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=304aacdb7a1dfbe92e4b0e1a419a872bd3ba6113'/>
<id>urn:sha1:304aacdb7a1dfbe92e4b0e1a419a872bd3ba6113</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: get_many(): allow “NULL” buffers - buffers where width or height is 0</title>
<updated>2021-07-18T14:44:49Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-18T14:44:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5b6a2b0eaff1ffef84d728a6c76c044c7f01a1d8'/>
<id>urn:sha1:5b6a2b0eaff1ffef84d728a6c76c044c7f01a1d8</id>
<content type='text'>
When a zero-sized buffer is requested, simply return a NULL buffer,
instead of crashing with a Wayland protocol error.

This makes it easier to request many buffers, where some may be
zero-sized, without having to pack the width/height and bufs arrays.
</content>
</entry>
<entry>
<title>shm: chain_free: BUG() if there are buffers remaining after purge</title>
<updated>2021-07-17T17:14:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:49:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=6657146a207834ac44425c01703935dee6d61d41'/>
<id>urn:sha1:6657146a207834ac44425c01703935dee6d61d41</id>
<content type='text'>
There may be buffers left, if their destruction has been
deferred. However, they should be on the 'deferred' list, not the
chain's buffer list.

If there are buffers left on the chain's list, that means someone
forgot to call shm_unref().
</content>
</entry>
<entry>
<title>shm: get_buffer: purge mismatching buffers in first buffer iteration</title>
<updated>2021-07-17T17:14:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:49:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0751172b922e32a9c6d54b52e721c934cb88fe9f'/>
<id>urn:sha1:0751172b922e32a9c6d54b52e721c934cb88fe9f</id>
<content type='text'>
There's no longer any need to defer purging of mismatching buffer
(i.e. buffers whose width/height doesn't match the requested ones) to
after the cache lookup loop.
</content>
</entry>
<entry>
<title>shm: refactor: move away from a single, global, buffer list</title>
<updated>2021-07-17T17:14:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:48:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=53851e13ec976001cdec2077d7963c292bcd6d20'/>
<id>urn:sha1:53851e13ec976001cdec2077d7963c292bcd6d20</id>
<content type='text'>
Up until now, *all* buffers have been tracked in a single, global
buffer list. We've used 'cookies' to separate buffers from different
contexts (so that shm_get_buffer() doesn't try to re-use e.g. a
search-box buffer for the main grid).

This patch refactors this, and completely removes the global
list.

Instead of cookies, we now use 'chains'. A chain tracks both the
properties to apply to newly created buffers (scrollable, number of
pixman instances to instantiate etc), as well as the instantiated
buffers themselves.

This means there's strictly speaking not much use for shm_fini()
anymore, since its up to the chain owner to call shm_chain_free(),
which will also purge all buffers.

However, since purging a buffer may be deferred, if the buffer is
owned by the compositor at the time of the call to shm_purge() or
shm_chain_free(), we still keep a global 'deferred' list, on to which
deferred buffers are pushed. shm_fini() iterates this list and
destroys the buffers _even_ if they are still owned by the
compositor. This only happens at program termination, and not when
destroying a terminal instance. I.e. closing a window in a “foot
--server” does *not* trigger this.

Each terminal instatiates a number of chains, and these chains are
destroyed when the terminal instance is destroyed. Note that some
buffers may be put on the deferred list, as mentioned above.
</content>
</entry>
<entry>
<title>shm: remove deferred buffers from main list immediately</title>
<updated>2021-07-17T17:14:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:48:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=4efb34927eb46d8b12fc0d5638653cf23839d7dc'/>
<id>urn:sha1:4efb34927eb46d8b12fc0d5638653cf23839d7dc</id>
<content type='text'>
When unref:ing a "busy" buffer, destruction is (still) deferred to the
buffer release event.

However, we now move the buffer off the buffer list immediately, and
instead push it to a 'deferred' list. This prevents buffer re-use of
buffers scheduled for destruction.

It also means less buffers to iterate through when trying to find a
re-usable buffer in shm_get_buffer(), since we no longer have to wade
through a potentially long list of to-be-deleted buffers.
</content>
</entry>
<entry>
<title>shm: replace 'locked' attribute with a ref-counter</title>
<updated>2021-07-17T17:14:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:47:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=232fb20269b68157874f57d676c1b0b95c2386aa'/>
<id>urn:sha1:232fb20269b68157874f57d676c1b0b95c2386aa</id>
<content type='text'>
The initial ref-count is either 1 or 0, depending on whether the
buffer is supposed to be released "immeidately" (meaning, as soon as
the compositor releases it).

Two new user facing functions have been added: shm_addref() and
shm_unref().

Our renderer now uses these two functions instead of manually setting
and clearing the 'locked' attribute.

shm_unref() will decrement the ref-counter, and destroy the buffer
when the counter reaches zero. Except if the buffer is currently
"busy" (compositor owned), in which case destruction is deferred to
the release event. The buffer is still removed from the list though.
</content>
</entry>
<entry>
<title>shm: we may exit with busy buffers remaining (seen on KDE)</title>
<updated>2021-07-17T17:14:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:47:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=69260dd9604f39f5e7270ac44502c7e60618500b'/>
<id>urn:sha1:69260dd9604f39f5e7270ac44502c7e60618500b</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: move ‘size’ to the private buffer struct</title>
<updated>2021-07-17T17:14:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-15T20:30:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=99ea47c97ac6884e469d1d2cdb76220f3398a737'/>
<id>urn:sha1:99ea47c97ac6884e469d1d2cdb76220f3398a737</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: rename buffer.mmapped to buffer.data</title>
<updated>2021-07-17T17:14:41Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-15T20:18:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=9b6cee825beb927ec24ef28f0f162623db218fe2'/>
<id>urn:sha1:9b6cee825beb927ec24ef28f0f162623db218fe2</id>
<content type='text'>
</content>
</entry>
</feed>
