Commit graph

4591 commits

Author SHA1 Message Date
Craig Barnes
0a22183fdf osc: fix typo in LOG_DBG() message 2021-07-24 01:58:34 +01:00
Knut Anders Hatlen
9a8c9b649a readme: fix a typo 2021-07-23 21:09:49 +02:00
Daniel Eklöf
f281937335
pgo: add stub for search_selection_cancelled()
Fixes PGO build failures caused by
251545203b

Closes #648
2021-07-23 10:15:35 +02:00
Daniel Eklöf
14737d1d82
Merge branch 'search-crash-when-selection-is-cancelled'
Closes #644
2021-07-22 21:34:25 +02:00
Daniel Eklöf
7092a72ce4
search: redraw search box after selection has been cancelled 2021-07-22 17:57:52 +02:00
Daniel Eklöf
251545203b
search: reset match state when selection is cancelled
While we’re in scrollback search mode, the selection may be
cancelled (for example, if the application is scrolling out the
selected text). Trying to e.g. extend the search selection after this
has happened triggered a crash.

This fixes it by simply resetting the search match state when the
selection is cancelled.

Closes #644
2021-07-22 17:57:43 +02:00
Daniel Eklöf
a987b1bd99
doc: ctlseq: improve description of OSC 52 response 2021-07-22 12:02:28 +02:00
Daniel Eklöf
e327251d49
Merge branch 'pgo-shm-fixes'
Closes #642
2021-07-22 11:15:23 +02:00
Daniel Eklöf
2acd4b34c5
pgo: fix PGO builds with clang
Add stubs for shm_chain_new(), shm_chain_free() and shm_unref(). This
fixes ‘pgo’ linking failures in the ‘generate’ phase when doing a PGO
build with clang.

Closes #642
2021-07-22 10:02:52 +02:00
Daniel Eklöf
029920ddcc
Merge branch 'prevent-overflow-into-margin' 2021-07-20 20:08:20 +02:00
Timur Celik
a410734f96 render: prevent cells from overflowing into margin 2021-07-20 11:44:27 +02:00
Daniel Eklöf
4a50abece3
changelog: add new ‘unreleased’ section 2021-07-18 18:07:26 +02:00
Daniel Eklöf
3309dce68a
Merge branch 'releases/1.8' 2021-07-18 18:07:05 +02:00
Daniel Eklöf
cd8c96d746
meson/pkgbuild: bump version to 1.8.2 2021-07-18 17:58:05 +02:00
Daniel Eklöf
721174ffea
changelog: prepare for 1.8.2 2021-07-18 17:57:42 +02:00
Daniel Eklöf
4d82e04860
Merge branch 'master' into releases/1.8 2021-07-18 17:57:11 +02:00
Daniel Eklöf
318385040c
changelog: remove entries that are no longer relevant
The tweak.allow-overflowing-double-width-glyphs option have been
superseded by tweak.overflowing-glyphs.
2021-07-18 17:16:17 +02:00
Daniel Eklöf
e6b13af59d
Merge branch 'csd-shared-shm-pool' 2021-07-18 17:13:03 +02:00
Daniel Eklöf
20fc80e57e
render: use a single backing SHM pool for CSD surface buffers 2021-07-18 16:46:43 +02:00
Daniel Eklöf
5b6a2b0eaf
shm: get_many(): allow “NULL” buffers - buffers where width or height is 0
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.
2021-07-18 16:44:49 +02:00
Daniel Eklöf
e8e9cd5595
term: erase_scrollback(): destroy sixels that touch the scrollback 2021-07-18 16:31:33 +02:00
Daniel Eklöf
f65e062ce4
sixel: destroy(): don’t unref a NULL pixman image 2021-07-18 16:30:42 +02:00
Daniel Eklöf
a577496f8f
Merge branch 'crash-when-selection-is-in-scrollback-and-scrollback-is-erased'
Closes #633
2021-07-18 16:15:18 +02:00
Daniel Eklöf
7d8884fec4
changelog: crash when \E[3J was executed with a selection in the scrollback 2021-07-18 16:14:25 +02:00
Daniel Eklöf
d0a7f999c6
term: add unit test for term_erase_scrollback() 2021-07-18 16:14:25 +02:00
Daniel Eklöf
5f0ceb72f1
csi: erase scrollback: cancel selection if it touches the scrollback
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
2021-07-18 16:14:21 +02:00
Daniel Eklöf
34de799f90
Merge branch 'refactor-shm-buffer-management' 2021-07-18 11:41:14 +02:00
Daniel Eklöf
6657146a20
shm: chain_free: BUG() if there are buffers remaining after purge
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().
2021-07-17 19:14:42 +02:00
Daniel Eklöf
0751172b92
shm: get_buffer: purge mismatching buffers in first buffer iteration
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.
2021-07-17 19:14:42 +02:00
Daniel Eklöf
53851e13ec
shm: refactor: move away from a single, global, buffer list
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.
2021-07-17 19:14:42 +02:00
Daniel Eklöf
4efb34927e
shm: remove deferred buffers from main list immediately
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.
2021-07-17 19:14:42 +02:00
Daniel Eklöf
232fb20269
shm: replace 'locked' attribute with a ref-counter
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.
2021-07-17 19:14:42 +02:00
Daniel Eklöf
69260dd960
shm: we may exit with busy buffers remaining (seen on KDE) 2021-07-17 19:14:41 +02:00
Daniel Eklöf
99ea47c97a
shm: move ‘size’ to the private buffer struct 2021-07-17 19:14:41 +02:00
Daniel Eklöf
f5da62c462
shm: replace inclusion of terminal.h with a forward declaration of damage
It’s the only thing we “need” from terminal.h
2021-07-17 19:14:41 +02:00
Daniel Eklöf
9b6cee825b
shm: rename buffer.mmapped to buffer.data 2021-07-17 19:14:41 +02:00
Daniel Eklöf
75f7f21a48
shm: split up buffer struct into internal/private and public parts 2021-07-17 19:14:41 +02:00
Daniel Eklöf
a18959f2df
Merge branch 'allow-bleeding-glyphs' 2021-07-17 19:14:00 +02:00
Timur Celik
91801ae55d render: Allow cells to bleed into their neighbor
This patch adds a `confined` flag to each cell to track if the last
rendered glyph bled into it's right neighbor.  To keep things simple,
bleeding into any other neighbor cell than the immediate right one is
not allowed.  This should cover most use cases.

Before rendering a row we now do a prepass and mark all cells unclean
that are affected by a bleeding neighbor.  If there are consecutive
bleeding cells, the whole group must be re-rendered even if only a
single cell has changed.

The patch also deprecates both old overflowing glyph options
*allow-overflowing-double-width-glyphs* and *pua-double-width* in favor
of a single new one named *overflowing-glyphs*.
2021-07-17 13:22:44 +02:00
Daniel Eklöf
9211ee694c
Merge branch 'decsdm'
Closes #631
2021-07-16 17:33:30 +02:00
Daniel Eklöf
931595bda5
shm: codespell 2021-07-15 19:40:15 +02:00
Daniel Eklöf
a486851bdd
shm: auto-purge when we have multiple buffers eligible for re-use
It may happen that we end up with multiple non-busy, same-sized
buffers for the same cookie (context), and thus eligible for re-use.

Before this patch, we would keep all those buffers around. This is
completely unnecessary. Under normal circumstances, we’ll either be
re-using a single buffer, or swap between two. In the second case, the
“other” buffer is always busy, and thus not eligible for re-use.

So, if we _do_ detect multiple, re-usable buffers, pick the one with
the lowest “age” (increasing the chance of applying damage tracking,
instead of re-drawing everything), and mark the other one for purging.
2021-07-15 19:19:31 +02:00
Daniel Eklöf
5d7b729ac5
wayland: win_destroy: unmap URL labels 2021-07-15 18:45:25 +02:00
Daniel Eklöf
31fad58465
url-mode: use shm_get_many()
If we have lots of URLs, we use up a *lot* of SHM buffers (and thus
pools). Each and every one is a single mmap(), of at least 4K.

Since all URL labels are created and destroyed at the same time, it
makes sense to use a single pool for all buffers.

To do this, we must now do two passes; first one to generate the
actual string (label content), and to calculate the label sizes.

Then we use this information to allocate all SHM buffers at once, from
the same pool.

Finally, we iterate the URLs again, this time to actually render them.
2021-07-15 18:39:41 +02:00
Daniel Eklöf
7533684d8f
shm: add shm_get_many() - allows buffers to share a single pool
shm_get_many() always returns new buffers (i.e. never old, cached
ones). The newly allocated buffers are also marked for immediate
purging, meaning they’ll be destroyed on the next call to either
shm_get_buffer(), or shm_get_many().

Furthermore, we add a new attribute, ‘locked’, to the buffer
struct. When auto purging buffers, look at this instead of comparing
cookies.

Buffer consumers are expected to set ‘locked’ while they hold a
reference to it, and don’t want it destroyed behind their back.
2021-07-15 18:39:23 +02:00
Daniel Eklöf
5e64c67c25
render: search: set clip region
Fixes crash when the search box has been reduced in height, due to
limited window space.
2021-07-15 18:27:10 +02:00
Daniel Eklöf
628fd39098
render: scrollback indicator: improve handling of very small window sizes 2021-07-15 18:26:26 +02:00
Daniel Eklöf
e259f460f3
render: margins: use correct background color
* Sync actual color used, with how render_cell() selects the
  background color
* Use color_dim_for_search(), not color_dim()
2021-07-15 18:24:27 +02:00
Daniel Eklöf
fcc2e62a7d
render: track alpha directly, rather whether to use it or not 2021-07-15 18:23:49 +02:00
Daniel Eklöf
22651ed221
shm: reset buffer pool FD when we close it
This fixes an issue where we ended up "double closing" buffer FDs.

In many cases (especially on compositors with SSDs) this was pretty
rare. And even when it did happen, the FD was normally unused, and
thus nothing bad happened.

However, by quickly resizing the window while using CSDs, it was
fairly easy to trigger this. We sometimes ended up closing the
TIOCSWINCH timer FD while thinking it was a buffer FD, but most of the
times we just ended up closing _another_ buffer’s pool FD, leading to
an immediate disconnect by the compositor.
2021-07-14 20:51:42 +02:00