<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mirrors/foot.git/terminal.c, branch 1.9.0</title>
<subtitle>A fast, lightweight and minimalistic Wayland terminal emulator</subtitle>
<id>https://git.0x0f.dev/mirrors/foot.git/atom?h=1.9.0</id>
<link rel='self' href='https://git.0x0f.dev/mirrors/foot.git/atom?h=1.9.0'/>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/'/>
<updated>2021-08-17T16:31:42Z</updated>
<entry>
<title>term: check visual-focus, not kbd-focus when enabling/disabling cursor blink</title>
<updated>2021-08-17T16:31:42Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-08-17T16:31:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b4402a6aa5228d8428ab7129bdfc07f94ed5bc03'/>
<id>urn:sha1:b4402a6aa5228d8428ab7129bdfc07f94ed5bc03</id>
<content type='text'>
term_cursor_blink_update() is called when the visual focus changes
state (i.e. when our top-level surface is activated de-activated).

Checking keyboard focus worked on Sway, but on e.g. GNOME, the order
in which keyboard focus and visual focus are updated is different, and
we ended up either making the cursor invisible, or visible, but not
blinking, when changing focus back to the window.

Closes #686
</content>
</entry>
<entry>
<title>pt-or-px: heed the dpi-aware setting</title>
<updated>2021-08-13T15:38:56Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-08-13T15:38:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f6f8f2b35ec10eb09f2c7c5b8214b62fa87b59e5'/>
<id>urn:sha1:f6f8f2b35ec10eb09f2c7c5b8214b62fa87b59e5</id>
<content type='text'>
Before this patch, pt-or-px values, like letter-spacing, were *always*
scaled using the current DPI value.

This is wrong; if the fonts are scaled using the output’s scaling
factor, then so should all other point values.

This also fixes an issue where e.g. letter-spacing would use one DPI
value at startup, but then when increasing/decreasing or resetting the
font size, would be re-calculated using a different DPI value, leading
to completely different spacing.

This happened when there were multiple monitors, with different DPI
values, and foot guessed the initial DPI value wrong. Normally, foot
would correct itself as soon as the window was mapped, and the
“correct” DPI value known. But if the fonts were scaled using the
scaling factor, it was possible that the font reload never happened.

This patch also updates the thickness calculation (for LIGHT and HEAVY
box drawing characters) to use the scaling factor when appropriate.

Closes #680
</content>
</entry>
<entry>
<title>input: implement support for mouse wheel left/right</title>
<updated>2021-08-07T10:27:44Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-08-05T16:34:09Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c2cc964116f9fc6c6432c5c00b113c92bdfcdcd6'/>
<id>urn:sha1:c2cc964116f9fc6c6432c5c00b113c92bdfcdcd6</id>
<content type='text'>
We now emit button 6/7 events (when the client application grabs the
mouse). This buttons map to mouse wheel horizontal scroll events. Or, left/right
tilting, if you like.

Wayland report these as ‘axis’ events (just like regular scroll wheel events),
and thus we need to translate those scroll events to button events.

libinput does not define any mouse buttons for wheel tilts, so we add our own
defitions. These are added last in the BTN_* range, just before the BTN_JOYSTICK
events.
</content>
</entry>
<entry>
<title>term: disable debug logging</title>
<updated>2021-08-05T16:24:52Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-08-05T16:24:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=bdaa9a8991d535ff02459eb3cc71c37adc45e9d1'/>
<id>urn:sha1:bdaa9a8991d535ff02459eb3cc71c37adc45e9d1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>term: send SIGTERM/SIGKILL to the entire process group</title>
<updated>2021-07-31T20:50:19Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-31T20:50:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f1d440e139d675b199d4e4c1ef4032e8b6da1a39'/>
<id>urn:sha1:f1d440e139d675b199d4e4c1ef4032e8b6da1a39</id>
<content type='text'>
</content>
</entry>
<entry>
<title>term: fix release builds when LOG_ENABLE_DBG=0</title>
<updated>2021-07-31T17:52:23Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-31T17:52:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=b7edfc2822368f4599cd41caba9a270c501c39d7'/>
<id>urn:sha1:b7edfc2822368f4599cd41caba9a270c501c39d7</id>
<content type='text'>
</content>
</entry>
<entry>
<title>term: consolidate shutdown related state into an anonymous struct</title>
<updated>2021-07-31T17:08:51Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-31T17:08:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=03f952cf4dcf45d909ce209838a3beb4304358e5'/>
<id>urn:sha1:03f952cf4dcf45d909ce209838a3beb4304358e5</id>
<content type='text'>
</content>
</entry>
<entry>
<title>term: rename: slave_died() -&gt; fdm_client_terminated()</title>
<updated>2021-07-31T16:27:02Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-31T16:27:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=c23bff418961e120cef919fec39ac5e5b3a1ffa0'/>
<id>urn:sha1:c23bff418961e120cef919fec39ac5e5b3a1ffa0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>term: asynchronous client application termination</title>
<updated>2021-07-31T16:18:48Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-31T16:18:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=384b1c330ffbee4318ee75c97186450f0f6e9e35'/>
<id>urn:sha1:384b1c330ffbee4318ee75c97186450f0f6e9e35</id>
<content type='text'>
When the foot window is closed, and we need to terminate the client application,
do this in an asynchronous fashion:

* Don’t do a blocking call to waitpid(), instead, rely on the reaper callback
* Use a timer FD to implement the timeout before sending SIGKILL (instead of
  using SIGALRM).
* Send SIGTERM immediately (we used to *just* close the PTY, and then wait 2
  seconds before sending SIGTERM).
* Raise the timeout from 2 seconds to 60

Full shutdown now depends on *two* asynchronous tasks - unmapping the window,
and waiting for the client application to terminate.

Only when *both* of these have completed do we proceed and call term_destroy(),
and the user provided shutdown callback.
</content>
</entry>
<entry>
<title>render: use a single backing SHM pool for CSD surface buffers</title>
<updated>2021-07-18T14:46:43Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-18T14:46:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=20fc80e57e365f2e002eead7de110cb23ffa7adc'/>
<id>urn:sha1:20fc80e57e365f2e002eead7de110cb23ffa7adc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>term: erase_scrollback(): destroy sixels that touch the scrollback</title>
<updated>2021-07-18T14:31:33Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-18T14:31:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=e8e9cd559529b91968af9f776df8b87751df7b97'/>
<id>urn:sha1:e8e9cd559529b91968af9f776df8b87751df7b97</id>
<content type='text'>
</content>
</entry>
<entry>
<title>term: add unit test for term_erase_scrollback()</title>
<updated>2021-07-18T14:14:25Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-18T13:34:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=d0a7f999c662759d1704d97d5217736e84f508c1'/>
<id>urn:sha1:d0a7f999c662759d1704d97d5217736e84f508c1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>csi: erase scrollback: cancel selection if it touches the scrollback</title>
<updated>2021-07-18T14:14:21Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-16T14:45:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=5f0ceb72f176caf7673ea1d4bc5195f26f4b4df7'/>
<id>urn:sha1:5f0ceb72f176caf7673ea1d4bc5195f26f4b4df7</id>
<content type='text'>
This breaks out the scrollback erasing logic for \E[3J from csi.c, and
moves it to the new function term_erase_scrollback(), and changes the
logic to calculate the start and end row (absolute) numbers of the
scrollback, and only iterate those, instead of iterating *all* rows,
filtering out those that are on-screen.

It also adds an intersection range check of the selection range, and
cancels the selection if it touches any of the deleted scrollback
rows.

This fixes a crash when trying to render the next frame, since the
selection now references rows that have been freed.

Closes #633
</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: 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>config: add locked-title=no|yes</title>
<updated>2021-07-04T15:59:40Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-04T15:59:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fcb60abc132b12ccf8fb8ff215acc924a44773d6'/>
<id>urn:sha1:fcb60abc132b12ccf8fb8ff215acc924a44773d6</id>
<content type='text'>
Closes #386
</content>
</entry>
<entry>
<title>term: rows printed to now defaults to having a hard linebreak</title>
<updated>2021-07-03T16:05:45Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-07-02T14:31:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=07652d3b9e58dd99f5fedd6776092ed815ccb7fa'/>
<id>urn:sha1:07652d3b9e58dd99f5fedd6776092ed815ccb7fa</id>
<content type='text'>
That is, instead of requiring a ‘\n’ to be printed, non-empty lines
are now treated as having a hard linebreak by default.

The linebreak is cleared on an explicit wrap.
</content>
</entry>
<entry>
<title>term: destroy: free URLs before free:ing the grids</title>
<updated>2021-06-28T20:33:57Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-28T20:33:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=117e24dbf4e5a54c8209f7415a97dbd2da906cd5'/>
<id>urn:sha1:117e24dbf4e5a54c8209f7415a97dbd2da906cd5</id>
<content type='text'>
Fixes use-after-free when destroying a terminal with “live”
URLs (i.e. when URL mode is active).
</content>
</entry>
<entry>
<title>composed: store compose chains in a binary search tree</title>
<updated>2021-06-24T15:30:49Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-24T11:17:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=fe8ca23cfee77a6cac433892755dd7455e354a9d'/>
<id>urn:sha1:fe8ca23cfee77a6cac433892755dd7455e354a9d</id>
<content type='text'>
The previous implementation stored compose chains in a dynamically
allocated array. Adding a chain was easy: resize the array and append
the new chain at the end. Looking up a compose chain given a compose
chain key/index was also easy: just index into the array.

However, searching for a pre-existing chain given a codepoint sequence
was very slow. Since the array wasn’t sorted, we typically had to scan
through the entire array, just to realize that there is no
pre-existing chain, and that we need to add a new one.

Since this happens for *each* codepoint in a grapheme cluster, things
quickly became really slow.

Things were ok:ish as long as the compose chain struct was small, as
that made it possible to hold all the chains in the cache. Once the
number of chains reached a certain point, or when we were forced to
bump maximum number of allowed codepoints in a chain, we started
thrashing the cache and things got much much worse.

So what can we do?

We can’t sort the array, because

a) that would invalidate all existing chain keys in the grid (and
iterating the entire scrollback and updating compose keys is *not* an
option).

b) inserting a chain becomes slow as we need to first find _where_ to
insert it, and then memmove() the rest of the array.

This patch uses a binary search tree to store the chains instead of a
simple array.

The tree is sorted on a “key”, which is the XOR of all codepoints,
truncated to the CELL_COMB_CHARS_HI-CELL_COMB_CHARS_LO range.

The grid now stores CELL_COMB_CHARS_LO+key, instead of
CELL_COMB_CHARS_LO+index.

Since the key is truncated, collisions may occur. This is handled by
incrementing the key by 1.

Lookup is of course slower than before, O(log n) instead of
O(1).

Insertion is slightly slower as well: technically it’s O(log n)
instead of O(1). However, we also need to take into account the
re-allocating the array will occasionally force a full copy of the
array when it cannot simply be growed.

But finding a pre-existing chain is now *much* faster: O(log n)
instead of O(n). In most cases, the first lookup will either
succeed (return a true match), or fail (return NULL). However, since
key collisions are possible, it may also return false matches. This
means we need to verify the contents of the chain before deciding to
use it instead of inserting a new chain. But remember that this
comparison was being done for each and every chain in the previous
implementation.

With lookups being much faster, and in particular, no longer requiring
us to check the chain contents for every singlec chain, we can now use
a dynamically allocated ‘chars’ array in the chain. This was
previously a hardcoded array of 10 chars.

Using a dynamic allocated array means looking in the array is slower,
since we now need two loads: one to load the pointer, and a second to
load _from_ the pointer.

As a result, the base size of a compose chain (i.e. an “empty” chain)
has now been reduced from 48 bytes to 32. A chain with two codepoints
is 40 bytes. This means we have up to 4 codepoints while still using
less, or the same amount, of memory as before.

Furthermore, the Unicode random test (i.e. write random “unicode”
chars) is now **faster** than current master (i.e. before text-shaping
support was added), **with** test-shaping enabled. With text-shaping
disabled, we’re _even_ faster.
</content>
</entry>
<entry>
<title>config: add new function config_clone()</title>
<updated>2021-06-23T08:39:14Z</updated>
<author>
<name>Daniel Eklöf</name>
<email>daniel@ekloef.se</email>
</author>
<published>2021-06-18T14:18:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0x0f.dev/mirrors/foot.git/commit/?id=f7860aec7610be897155046bd730ad0b406bd56c'/>
<id>urn:sha1:f7860aec7610be897155046bd730ad0b406bd56c</id>
<content type='text'>
</content>
</entry>
</feed>
