Commit graph

5781 commits

Author SHA1 Message Date
Daniel Eklöf
774570ec41
sixel: stop cropping images to the last non-transparent row 2023-06-24 07:31:08 +02:00
Daniel Eklöf
d6d143e2a6
sixel: respect sixel aspect ratio
That is, parse P1 when initializing a new sixel, and don’t ignore
pad/pad in the raster attributes command.

The default aspect ratio is 2:1, but most sixels will override it in
the raster attributes command (to 1:1).
2023-06-24 07:31:08 +02:00
Daniel Eklöf
66d9b8da60
sixel: fix cursor positioning logic
This adjusts the logic that positions the text cursor after emitting a
sixel, when sixel scrolling mode is *enabled*.

We’ve always mimicked XTerm’s behavior. However, XTerm recently
changed its behavior, to better match that of an VT382.

Now, the cursor is placed *on* the last row of the sixel, instead of
on a new row after the sixel.

This allows applications to print sixels to the bottom row of the
terminal, without causing the content to scroll.

Finally, there was a bug in the horizontal positioning of the cursor;
it was placed on the *first* column of the row, instead of on the
first column of the sixel.
2023-06-24 07:31:02 +02:00
Daniel Eklöf
8a3620bafa
term: scroll: only record scroll damage when viewport is at the bottom
We don’t need to record scroll damage if the viewport isn’t at the
bottom, since in this case, the renderer ignores the scroll damage
anyway.

This fixes a performance corner case, when the viewport is at the top
of the scrollback history.

When application scrolls the terminal contents, and the scrollback
history is full, and the viewport is at top of the history, then the
viewport needs to be moved (the scrollback history is a circular
buffer, and thus the top of the history “moves” when we’re scrolling
in new contents).

Moving the viewport typically results in another type of scroll
damage (DAMAGE_SCROLL_IN_VIEW, instead of the “normal” DAMAGE_SCROLL).

Thus, each application triggered scroll, will result in two scroll
damage records: one DAMAGE_SCROLL, and one
DAMAGE_SCROLL_IN_VIEW. These two are incompatible, meaning they can’t
be merged. What’s worse, it also means the DAMAGE_SCROLL records from
two application triggered scrolls cannot be merged (since there’s a
DAMAGE_SCROLL_IN_VIEW in between).

As a result, the renderer will not see one, or “a few” scroll damage
events, but a *ton*. _Each_ one typically a single line, or so. And
each one resulting in lots of traffic on the wayland socket, as we
create and destroy new buffer pools, when doing “shm scrolling”.

This eventually leads to the socket not being able to keep up, and the
socket is closed on us, forcing us to exit.

The fix is really simple: don’t record “normal” scroll damage when
scrolling, _unless_ the viewport is at the bottom (and thus “follows”
the application output).

As soon as the user scrolls up in the history, we’ll stop emitting
normal scroll damage records. This is just fine, since, as mentioned
above, the renderer ignores them when the viewport isn’t at the
bottom.

What if the viewport is moved back down again, before the next frame
has been rendered? Wont there be “missing” scroll damage records? No,
because moving the viewport results in scroll damage records by
itself.

Closes #1380
2023-06-23 20:38:03 +02:00
wout
70ffc2632f Fixed a type for the pixel fontsize change
xp -> px
2023-06-23 18:10:19 +00:00
Daniel Eklöf
3a59cbbaa3
render: resize: fix crash when reflowing the alt screen
When doing an interactive resize, and `resize-delay-ms` > 0 (the
default), we would crash if the original screen size (i.e. the size
before the interactive resize started) was larger than the last window
size.

For example, if we interactively go from 85 rows to 75, and then
non-interactively went from 75 to 80, we’d crash.

The resizes had to be made in a single go. One way to trigger this was
to start an interactive resize on a floating window, and then *while
resizing* toggle the window’s floating mode.

Closes #1377
2023-06-20 15:59:16 +02:00
Antoine Beaupré
67b3663f39
add srcery theme
Based on https://srcery.sh/
2023-06-20 14:57:23 +02:00
Daniel Eklöf
2c0c4ce821
csi: CHA+HPA (cursor horizontal absolute): use term_cursor_col() 2023-06-20 14:55:32 +02:00
Daniel Eklöf
24f12c7b5e
term: add term_cursor_col()
Set cursor column, absolute.

term_cursor_to() needs to reload the current row pointer, and is thus
not very effective when we only need to modify the column.
2023-06-20 14:55:32 +02:00
Daniel Eklöf
d88bea5e22
vt: split up action_param() to three separate functions
We’re already switching on the next VT input byte in the state
machine; no need to if...else if in action_param() too.

That is, split up action_param() into three:

* action_param_new()
* action_param_new_subparam()
* action_param()

This makes the code cleaner, and hopefully slightly faster.

Next, to improve performance further, only check for (sub)parameter
overflow in action_param_new() and action_param_subparam().

Add pointers to the VT struct that points to the currently active
parameter and sub-parameter.

When the number of parameters (or sub-parameters) overflow, warn, and
then point the parameter pointer to a "dummy" value in the VT struct.

This way, we don’t have to check anything in action_param().
2023-06-16 16:26:13 +02:00
Dan Bungert
690d78edfa
test: config: add test for url.protocols option 2023-06-15 14:40:47 +02:00
Daniel Eklöf
b91bde8a65
terminfo: add TS capability
This is a new ‘extended’ capability. ‘TS’ has been around for a while,
but was originally not part of foot’s terminfo. Not sure when it was
added to ncurses’ foot terminfo.

In any case, ncurses has this to say about TS:

  These building-blocks allow access to the X titlebar and icon name as a
  status line.  There are a few problems in using them in entries:

   a) tsl should have a parameter to denote the column on which to transfer to
      the status line.

   ...

  But that issue regarding the parameter for tsl means that applications may
  not rely on it.  The SVr4 documentation says tsl will "move to status line,
  column #1".  At the point in time when ESR added DJM's "pseudo-color" entry
  with the split-up escape sequence for tsl/fsl, there were 65 entries using
  tsl:
     32 used a parameter, matching the documentation (including x10term).
     21 used a parameterless control, exiting from the status line on ^M.
      6 used parameterless controls for tsl and fsl
      6 used a split-up escape sequence, e.g., the same approach.

  The extension "TS" is preferable, because it does not accept a parameter.
  However, if you are using a non-extended terminfo, "TS" is not visible.
2023-06-15 14:31:23 +02:00
Daniel Eklöf
93b6883896
terminfo: XM: add private mode 1004
This was added to ncurses (to the xterm+sm+1006 fragment) in
2023-05-08.
2023-06-15 14:31:15 +02:00
sewn
16872ecc41
meson: use meson feed feature for scdoc input
Removes the need for a shell dependency.
2023-06-14 17:15:20 +00:00
Phillip Susi
8859e134ef
Fix non UTF-8 locale complaint
If the locale isn't UTF-8, foot tries to fall back to C.UTF-8 and
prints a warning.  The warning was garbled because the name of the
original locale is no longer valid after calling setlocale() a
second time.  Use strdup to stash the original string.

Closes #1362
2023-06-01 12:12:49 +02:00
Daniel Eklöf
1433a81c08
sixel: apply background alpha when P2=0 or P2=2, and current bg color is the default bg color
Closes #1360
2023-05-31 16:27:48 +02:00
Daniel Eklöf
b4e418f251
ci: try alpine edge instead of latest 2023-05-26 10:20:05 +02:00
Daniel Eklöf
c51050a9bc
osc: update font subpixel mode, and window opaque compositor hint, on alpha changes
When background alpha is changed at runtime (using OSC-11), we (may)
have to update the opaque hint we send to the compositor.

We must also update the subpixel mode used when rendering font
glyphs.

Why?

When the window is fully opaque, we use wl_surface_set_opaque_region()
on the entire surface, to hint to the compositor that it doesn’t have
to blend the window content with whatever is behind the
window. Obviously, if alpha is changed from opaque, to transparent (or
semi-transparent), that hint must be removed.

Sub-pixel mode is harder to explain, but in short, we can’t do
subpixel hinting with a (semi-)transparent background. Thus, similar
to the opaque hint, subpixel antialiasing must be enabled/disabled
when background alpha is changed.
2023-05-26 10:01:32 +02:00
jdevdevdev
134b54dfe0
.desktop: remove StartupWMClass from server, use distinct StartupWMClass for foot and footclient
For this to work, the default app-id of footclient has been changed
from ‘foot’ to ‘footclient’.

By using distinct StartupWMClasses, the compositor can connect a
running foot/footclient instance to the correct .desktop-file. This
ensures the correct icon is being used in e.g. docks, and that actions
like “open another window” works correctly.

Note that the user can override the app-id, either by setting app-id
in foot.ini, or with the -a,--app-id command line option.

Closes #1355
2023-05-22 18:57:54 +02:00
Daniel Eklöf
f4b8e4f4d6
test: config: add test for main.utmp-helper option 2023-05-22 18:47:38 +02:00
Daniel Eklöf
e78319fccd
utmp: rewrite utmp logging
This patch generalizes the utmp support, to not only support
libutempter, but also ulog (and in the future, even more interfaces).

* Rename config option main.utempter to main.utmp-helper
* Add meson option -Dutmp-backend=none|libutempter|ulog|auto
* Rename meson option -Ddefault-utempter-path to -Dutmp-default-helper-path
* utmp is no longer detected at compile time, but at runtime instead.

Meson will configure the following pre-processor macros, based on the
selected utmp backend:

* UTMP_ADD - argument to pass to utmp helper when adding a record (starting foot)
* UTMP_DEL - argument to pass to utmp helper when removing a record (exiting foot)
* UTMP_DEL_HAVE_ARGUMENT - if defined, UTMP_DEL expects an extra argument ($WAYLAND_DISPLAY)
* UTMP_DEFAULT_HELPER_PATH - path to the default utmp helper binary

The documentation has been updated to mention which arguments are
passed to the helper binary.

Closes #1314
2023-05-22 18:47:25 +02:00
Daniel Eklöf
a2f765b72a
slave: unset TERM_PROGRAM{,_VERSION}
Foot’s policy is to not set environment variables that identifies
it (except the well-known and established `TERM` variable).

We encourage applications to use terminfo to determine capabilities,
or terminal queries, when available. Or, at least use terminal queries
to detect the terminal and its version.

Setting environment variables is a bad idea since they are inherited
by all applications started by the terminal (which is the whole
point). But, this includes other terminal emulators, making it very
possible a terminal emulator gets mis-detected just because it was
started from another terminal.

Since there are a couple of terminal emulators that _do_ set
TERM_PROGRAM and TERM_PROGRAM_VERSION, unset these environment
variables to avoid being misdetected.

Closes #1349
2023-05-18 17:50:48 +02:00
locture
d2f81443f1
customized gnome-like csd buttons 2023-05-18 17:49:44 +02:00
Daniel Eklöf
738deb2368
search: regression: refresh current view when canceling a scrollback search
3b41379be4 introduced a regression,
where canceling a scrollback search didn’t refresh the viewport
correctly; the viewport was changed, but the screen content was not
refreshed.

This worked before, because the workaround for
https://github.com/swaywm/sway/issues/6960 always called
term_damage_view() when exiting scrollback search mode.

3b41379be4 removed that call since it’s
no longer required. *Except* when executing the
BIND_ACTION_SEARCH_CANCEL binding, since then the viewport may be
moved.

Note that this regression affected *all* compositors, not just Sway.

Closes #1354
2023-05-15 20:34:58 +02:00
Daniel Eklöf
3b41379be4
quirks: sway does not damage surface beneath sub-surface, when unmapped
When unmapping a sub-surface, Sway <= 1.8 does not damage the surface
beneath the sub-surface.

https://github.com/swaywm/sway/issues/6960

The workaround is to manually damage the main surface. Previously,
this was done when exiting scrollback search, and after the ‘flash’
OSC. But other sub-surfaces, that may also be unmapped, did not.

This patch adds a quirk handler that does this, and calls it when:

* Exiting scrollback search
* Ending the ‘flash’ OSC
* Exiting unicode input mode
* Clearing URL labels
* Removing the scrollback position indicator

Closes #1335
2023-05-12 14:51:05 +02:00
Daniel Eklöf
7eea69df89
term: reset: switch modifyOtherKeys back to level 1 2023-05-12 09:42:35 +02:00
Daniel Eklöf
c13495e26e
kitty: F3 is no longer allowed to emit CSI R
The original kitty keyboard specification allowed F3 to emit either
CSI R, or CSI 13~.

Support for CSI R was removed in later revisions of the protocol,
since it collides with "Cursor Position Report" sequences.
2023-04-26 18:34:03 +02:00
Daniel Eklöf
dc7642f2a5
csi: implement "CSI ? m" 2023-04-26 18:30:09 +02:00
Daniel Eklöf
a2db3cdd5b
render: regression: keep empty bottom scroll margin empty after resize 2023-04-12 18:09:41 +02:00
Daniel Eklöf
e2baa65238
render: ensure scroll region’s endpoint is valid after a window resize
If we had a non-empty bottom scroll region, and the window was resized
to a smaller size, the scroll region was not reset correctly.

This led to a crash when scrolling the screen content.

Fix by making sure the scroll region’s endpoint is within range.
2023-04-12 17:57:53 +02:00
Vivian Szczepanski
98528da5e5
meson: bump tllist dependency version to 1.1.0
The tll_sort() macro was added to tllist in version 1.1.0, and so
building with a previous version causes a linking error.
2023-04-09 09:05:50 +02:00
Daniel Eklöf
479b3c8ee1
*.desktop: add StartupWMClass=foot
At least Gnome needs this in order to link running instances of foot
to their corresponding .desktop file, used e.g. when determining which
icon to display for running applications.

Closes #1317
2023-04-05 14:42:34 +02:00
Daniel Eklöf
a858934c04
changelog: add a new ‘unreleased’ section 2023-04-03 18:57:50 +02:00
Daniel Eklöf
446288d9a1
Merge branch 'releases/1.14' 2023-04-03 18:57:32 +02:00
Daniel Eklöf
ae6bbce6c2
meson: bump version to 1.14.0 2023-04-03 18:52:42 +02:00
Daniel Eklöf
862a003b5b
changelog: prepare for 1.14.0 2023-04-03 18:52:22 +02:00
Daniel Eklöf
ae81f5af4c
terminfo: remove DECRST of DECCOLM+DECSCLM
We’ve never supported neither 132-column mode, nor smooth
scrolling. But we _did_ recognize the escape sequences.

We don’t, anymore. Thus it makes very little sense to include these
escapes in any of our terminfo capabilities. So, remove them.
2023-04-02 18:00:38 +02:00
Daniel Eklöf
f114068a46
csi: DECCOLM+DECSCLM: remove all support
We don’t support neither 132 column mode, nor smooth scrolling. Thus
it makes little sense to recognize these control condes.

Note that while XTerm does support 132 columns, it is disabled by
default. In this mode, XTerm also doesn’t trigger the
side-effects (i.e. clearing the screen).

Closes #1265
2023-03-31 13:16:43 +02:00
Daniel Eklöf
0bc934070c
ci (woodpecker): do a second release build, using clang instead of gcc 2023-03-31 13:16:11 +02:00
Daniel Eklöf
e71e7f5cf6
input: kitty: don’t treat zero-length utf8/utf32 strings as text
This is a regression introduced in 3215d54f31

Symptoms: e.g. arrow keys not working in vim/neovim
2023-03-31 11:34:04 +02:00
Daniel Eklöf
deb43c8dc3
changelog: typo: now -> not 2023-03-31 10:43:39 +02:00
Daniel Eklöf
03b23ed6e5
changeloge: remove bad escape char 2023-03-31 10:42:50 +02:00
Daniel Eklöf
a5dd003627
changelog: remove trailing back-tick 2023-03-31 10:41:17 +02:00
Daniel Eklöf
27c52fb4e3
test: config: call FcIni() + FcFini()
Some of the config options we’re testing result in calls to FontConfig
APIs. Without calling FcIni()+FcFini(), we leak memory:

  Direct leak of 768 byte(s) in 3 object(s) allocated from:
      #0 0x7f7e95cbfa89 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
      #1 0x7f7e95bd1fe5  (/usr/lib/libfontconfig.so.1+0x20fe5)

  Indirect leak of 96 byte(s) in 3 object(s) allocated from:
      #0 0x7f7e95cbf411 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:77
      #1 0x7f7e95bd63fd  (/usr/lib/libfontconfig.so.1+0x253fd)

  Indirect leak of 19 byte(s) in 2 object(s) allocated from:
      #0 0x7f7e95c72faa in __interceptor_strdup /build/gcc/src/gcc/libsanitizer/asan/asan_interceptors.cpp:439
      #1 0x7f7e95bd1898 in FcValueSave (/usr/lib/libfontconfig.so.1+0x20898)
2023-03-31 10:30:58 +02:00
Daniel Eklöf
981e4b77cb
term: protect against integer overflow when accumulating scroll damage
When accumulating scroll damage, we check if the last scroll damage’s
scrolling region, and type, matches the new/current scroll damage. If
so, the number of lines in the last scroll damage is increased,
instead of adding a new scroll damage instance to the list.

If the scroll damage list isn’t consumed, this build up of scroll
damage would eventually overflow.

And, even if it didn’t overflow, it could become large enough, that
when later used to calculate e.g. the affected surface area, while
rendering a frame, would cause an overflow there instead.

This patch fixes both issues by:

a) do an overflow check before increasing the line count
b) limit the line count to UINT16_MAX
2023-03-30 16:13:19 +02:00
Daniel Eklöf
7bc22862fa
render: protect against integer underflow when calculating scroll area
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
2023-03-30 16:13:18 +02:00
Daniel Eklöf
3215d54f31
input: (kitty kbd): the resulting UTF-8 string may translate to multiple UTF-32 codepoints
When this happened (for example, by specifying a custom compose
sequence), the kitty keyboard protocol didn’t emit any text at all.

This was caused by the utf32 codepoint being -1. This in turned was
caused by us trying to convert the utf8 sequence to a *single* utf32
codepoint.

This patch replaces the use of mbrtoc32() with a call to
ambstoc32(), and the utf32 codepoint with an utf32 string.

The kitty keyboard protocol is updated:

* When determining if we’re dealing with text, check *all* codepoints
  in the utf32 string.

* Add support for multiple codepoints when reporting "associated
  text". The first codepoint is the actual parameter in the emitted
  sequence, and the remaining codepoints are sub-parameters. I.e. the
  codepoints are colon separated.

Closes #1288
2023-03-30 16:12:17 +02:00
Harri Nieminen
ae26915916 fix typos 2023-03-29 00:45:18 +03:00
Daniel Eklöf
296e75f4f5
render: fix glitchy selection while resizing the ‘normal’ screen
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.
2023-03-27 16:53:41 +02:00
Craig Barnes
5b2f02d826 slave: set $TERM_PROGRAM and $TERM_PROGRAM_VERSION environment variables
These are already being set by iTerm2, WezTerm, tmux and likely some
others. Even though using yet more environment variables seems rather
questionable, if we don't set these we run the risk of inheriting them
from other terminals.

See also:

* 97a6078df8/sources/PTYSession.m (L2568-2570)
* 1d0f68dee9/environ.c (L263-L264)
* https://github.com/search?q=TERM_PROGRAM&type=code
2023-03-20 14:40:36 +00:00