<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/shm.c, branch 1.23.0</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.23.0</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.23.0'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2025-05-03T07:04:15Z</updated>
<entry>
<title>config: tweak.surface-bit-depth: add support for 16-bit surfaces</title>
<updated>2025-05-03T07:04:15Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-05-01T07:37:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=970e13db8deebf6c7542c7aede4f34703fa86769'/>
<id>urn:sha1:970e13db8deebf6c7542c7aede4f34703fa86769</id>
<content type='text'>
This adds supports for 16-bit surfaces, using the new
PIXMAN_a16b16g16r16 buffer format. This maps to
WL_SHM_FORMAT_ABGR16161616 (little-endian).

Use the new 16-bit surfaces by default, when
gamma-correct-blending=yes.
</content>
</entry>
<entry>
<title>config: tweak.surface-bit-depth now defaults to 'auto'</title>
<updated>2025-05-01T06:54:30Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-05-01T06:34:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e5a0755451b736c635be58764799ef8d7b536e8d'/>
<id>urn:sha1:e5a0755451b736c635be58764799ef8d7b536e8d</id>
<content type='text'>
When set to 'auto', use 10-bit surfaces if gamma-correct blending is
enabled, and 8-bit surfaces otherwise.

Note that we may still fallback to 8-bit surfaces (without disabling
gamma-correct blending) if the compositor does not support 10-bit
surfaces.

Closes #2082
</content>
</entry>
<entry>
<title>render: gamma-correct blending</title>
<updated>2025-03-05T17:45:01Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-02-21T10:01:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=ccf625b9914917e131beb83379c526bab1927edc'/>
<id>urn:sha1:ccf625b9914917e131beb83379c526bab1927edc</id>
<content type='text'>
This implements gamma-correct blending, which mainly affects font
rendering.

The implementation requires compile-time availability of the new
color-management protocol (available in wayland-protocols &gt;= 1.41),
and run-time support for the same in the compositor (specifically, the
EXT_LINEAR TF function and sRGB primaries).

How it works: all colors are decoded from sRGB to linear (using a
lookup table, generated in the exact same way pixman generates it's
internal conversion tables) before being used by pixman. The resulting
image buffer is thus in decoded/linear format. We use the
color-management protocol to inform the compositor of this, by tagging
the wayland surfaces with the 'ext_linear' image attribute.

Sixes: all colors are sRGB internally, and decoded to linear before
being used in any sixels. Thus, the image buffers will contain linear
colors. This is important, since otherwise there would be a
decode/encode penalty every time a sixel is blended to the grid.

Emojis: we require fcft &gt;= 3.2, which adds support for sRGB decoding
color glyphs. Meaning, the emoji pixman surfaces can be blended
directly to the grid, just like sixels.

Gamma-correct blending is enabled by default *when the compositor
supports it*. There's a new option to explicitly enable/disable it:
gamma-correct-blending=no|yes. If set to 'yes', and the compositor
does not implement the required color-management features, warning
logs are emitted.

There's a loss of precision when storing linear pixels in 8-bit
channels. For this reason, this patch also adds supports for 10-bit
surfaces. For now, this is disabled by default since such surfaces
only have 2 bits for alpha. It can be enabled with
tweak.surface-bit-depth=10-bit.

Perhaps, in the future, we can enable it by default if:

* gamma-correct blending is enabled
* the user has not enabled a transparent background
</content>
</entry>
<entry>
<title>shm: codespell: re-using -&gt; reusing</title>
<updated>2025-01-22T07:04:17Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2025-01-22T06:50:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5e65f3f07e41065a6fbd1af74e43acd553e1d5b5'/>
<id>urn:sha1:5e65f3f07e41065a6fbd1af74e43acd553e1d5b5</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: fix compilation when FORCED_DOUBLE_BUFFERING is enabled</title>
<updated>2024-09-21T07:11:07Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-09-20T15:06:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=046d9596575c2dfac5db0d151179711f89b52661'/>
<id>urn:sha1:046d9596575c2dfac5db0d151179711f89b52661</id>
<content type='text'>
</content>
</entry>
<entry>
<title>notify: don't close FD 0</title>
<updated>2024-07-30T14:33:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-07-30T14:33:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=0a5ba708e4a8448a0d29d4e263f939c9d1d2b953'/>
<id>urn:sha1:0a5ba708e4a8448a0d29d4e263f939c9d1d2b953</id>
<content type='text'>
This fixes a regression where closing a terminal instance, or hard- or
soft-resetting a terminal caused FD 0 to be closed.

This meant it became re-usable. Usually, by memfd_create() when
allocating a new surface buffer. So far nothing _really_ bad has
happened.

But what if FD 0 is now used by a memfd, and we close _another_
terminal instance?

This causes our memfd to be closed. And then, when e.g. trying to
scroll the terminal content: fallocate() fails with bad FD.
</content>
</entry>
<entry>
<title>shm: discard shm buffers with mis-matching alpha-setting</title>
<updated>2024-06-24T18:09:37Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-06-24T15:55:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=795e39de1a187f6a09aad02410f69f19781bd3c1'/>
<id>urn:sha1:795e39de1a187f6a09aad02410f69f19781bd3c1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>shm: minor optimization</title>
<updated>2024-05-22T12:06:15Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-05-22T12:06:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f64cc04fe6822d4efe27d85bebb9d46477be4815'/>
<id>urn:sha1:f64cc04fe6822d4efe27d85bebb9d46477be4815</id>
<content type='text'>
Don't retry memfd_create() without MFD_NOEXEC_SEAL is 0.

The overall logic is this:

* Try memfd_create() with MFD_NOEXEC_SEAL
* If that fails (which it does, on older kernels), try without the flag

If compiling against an older kernel, or on a system that doesn't
support the noexec seal, MFD_NOEXEC_SEAL is 0.

In this case, there's little point in retrying memfd_create a second
time, with the exact same set of flags.
</content>
</entry>
<entry>
<title>shm: use XRGB surfaces when we know we wont be using transparency</title>
<updated>2024-02-21T15:29:10Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-02-21T15:29:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=67f97cbca1d9c1396537d0f04afb5a336ac46855'/>
<id>urn:sha1:67f97cbca1d9c1396537d0f04afb5a336ac46855</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Don't use fancy Unicode quotes, stick to ASCII</title>
<updated>2024-02-06T11:36:45Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2024-02-06T11:36:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=7999975016a57cc0a2c2e20bc55f29de32df7044'/>
<id>urn:sha1:7999975016a57cc0a2c2e20bc55f29de32df7044</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Replace unchecked allocations with calls to xmalloc.h functions</title>
<updated>2024-01-25T07:03:50Z</updated>
<author>
<name>Craig Barnes</name>
<email>craigbarnes@protonmail.com</email>
</author>
<published>2024-01-25T07:03:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=91b22ae21acd0b3171814b47b0dead027f8da779'/>
<id>urn:sha1:91b22ae21acd0b3171814b47b0dead027f8da779</id>
<content type='text'>
</content>
</entry>
<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>
</feed>
