Commit graph

6652 commits

Author SHA1 Message Date
Daniel Eklöf
b93d2f042c
url-mode: fix double-width characters not being handled correctly
When a regex matches a string containing double-width characters, the
CELL_SPACER values were included in the URL string. This meant the
final URL (either launched, or copied) weren't handled correctly, as
invalid UTF-8 sequences were inserted in the middle of the string.

Closes #2027
2025-04-13 08:28:13 +02:00
Daniel Eklöf
bc2e0a29bb
changelog: move vmod support in config from "changed" to "added" 2025-04-10 12:18:34 +02:00
Daniel Eklöf
23431e3ecf
wayland+input: add support for toplevel edge constraints
Edge constraints are new (not yet available in a wayland-protocols
release) toplevel states, acting as a complement to the existing tiled
states.

Tiled tells us we shouldn't draw shadows etc *outside our window
geometry*.

Constrained tells us the window cannot be resized in the constrained
direction.

This patch does a couple of things:

* Recognize the new states when debug logging

* Change is_top_left() etc to look at the new constrained state
  instead of the tiled state. These functions are used when both
  choosing cursor shape, and when determining if/how to resize a
  window on a CSD edge click-and-drag.

* Update cursor shape selection to use the default (left_ptr) shape
  when on a constrained edge (or corner).

* Update CSD resize triggering, to not trigger a resize when attempted
  on a constrained edge (or corner).

See
86750c99ed:

    An edge constraint is an complementery state to the tiled state,
    meaning that it's not only tiled, but constrained in a way that it
    can't resize in that direction.

    This typically means that the constrained edge is tiled against a
    monitor edge. An example configuration is two windows tiled next
    to each other on a single monitor. Together they cover the whole
    work area.

    The left window would have the following tiled and edge constraint
    state:

        [ tiled_top, tiled_right, tiled_bottom, tiled_left,
          constrained_top, constrained_bottom, constrained_left ]

    while the right window would have the following:

        [ tiled_top, tiled_right, tiled_bottom, tiled_left,
          constrained_top, constrained_bottom, constrained_right ]

    This aims to replace and deprecate the
    `gtk_surface1.configure_edges` event and the
    `gtk_surface1.edge_constraint` enum.
2025-04-07 13:41:37 +02:00
Dominique Martinet
091aa90f1a
wayland: handle xdg-shell edge constraints
wayland-protocols commit 86750c99ed06 ("xdg-shell: Add edge
constraints") added a few more enums to handle, making the build fail
with -Werror:
../wayland.c: In function ‘xdg_toplevel_configure’:
../wayland.c:878:9: error: enumeration value ‘XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT’ not handled in switch [-Werror=switch]
  878 |         switch (*state) {
      |         ^~~~~~
../wayland.c:878:9: error: enumeration value ‘XDG_TOPLEVEL_STATE_CONSTRAINED_RIGHT’ not handled in switch [-Werror=switch]
../wayland.c:878:9: error: enumeration value ‘XDG_TOPLEVEL_STATE_CONSTRAINED_TOP’ not handled in switch [-Werror=switch]
../wayland.c:878:9: error: enumeration value ‘XDG_TOPLEVEL_STATE_CONSTRAINED_BOTTOM’ not handled in switch [-Werror=switch]

(This is not part of any release yet, but can be used when building with
the submodule)

From a quick look it sounds like the meaning is the same as tiling as
far as we are concerned so handle these as we do of tiling.
2025-04-07 13:03:30 +02:00
Dominique Martinet
34d3f4664b
xkbcommon: require libxkbcommon >= 1.8.0
Trying to build with an older libxkbcommon fails as follow:
```
../input.c: In function ‘keyboard_keymap’:
../input.c:648:82: error: ‘XKB_VMOD_NAME_ALT’ undeclared (first use in this function); did you mean ‘XKB_MOD_NAME_ALT’?
  648 |             xkb_mod_index_t alt = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, XKB_VMOD_NAME_ALT);
      |                                                                                  ^~~~~~~~~~~~~~~~~
      |                                                                                  XKB_MOD_NAME_ALT
../input.c:648:82: note: each undeclared identifier is reported only once for each function it appears in
../input.c:649:83: error: ‘XKB_VMOD_NAME_META’ undeclared (first use in this function); did you mean XKB_MOD_NAME_ALT’?
  649 |             xkb_mod_index_t meta = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, XKB_VMOD_NAME_META);
      |                                                                                   ^~~~~~~~~~~~~~~~~~
      |                                                                                   XKB_MOD_NAME_ALT
../input.c:650:84: error: ‘XKB_VMOD_NAME_SUPER’ undeclared (first use in this function); did you mean ‘XKB_MOD_NAME_NUM’?
  650 |             xkb_mod_index_t super = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, XKB_VMOD_NAME_SUPER);
      |                                                                                    ^~~~~~~~~~~~~~~~~~~
      |                                                                                    XKB_MOD_NAME_NUM
../input.c:651:84: error: ‘XKB_VMOD_NAME_HYPER’ undeclared (first use in this function); did you mean ‘XKB_MOD_NAME_CAPS’?
  651 |             xkb_mod_index_t hyper = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, XKB_VMOD_NAME_HYPER);
      |                                                                                    ^~~~~~~~~~~~~~~~~~~
      |                                                                                    XKB_MOD_NAME_CAPS
../input.c:652:87: error: ‘XKB_VMOD_NAME_NUM’ undeclared (first use in this function); did you mean ‘XKB_MOD_NAME_NUM’?
  652 |             xkb_mod_index_t num_lock = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, XKB_VMOD_NAME_NUM);
      |                                                                                       ^~~~~~~~~~~~~~~~~
      |                                                                                       XKB_MOD_NAME_NUM
../input.c:653:90: error: ‘XKB_VMOD_NAME_SCROLL’ undeclared (first use in this function); did you mean ‘XKB_LED_NAME_SCROLL’?
  653 |             xkb_mod_index_t scroll_lock = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, XKB_VMOD_NAME_SCROLL);
      |                                                                                          ^~~~~~~~~~~~~~~~~~~~
      |                                                                                          XKB_LED_NAME_SCROLL
../input.c:654:90: error: ‘XKB_VMOD_NAME_LEVEL3’ undeclared (first use in this function); did you mean ‘XKB_MOD_NAME_CTRL’?
  654 |             xkb_mod_index_t level_three = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, XKB_VMOD_NAME_LEVEL3);
      |                                                                                          ^~~~~~~~~~~~~~~~~~~~
      |                                                                                          XKB_MOD_NAME_CTRL
../input.c:655:89: error: ‘XKB_VMOD_NAME_LEVEL5’ undeclared (first use in this function); did you mean ‘XKB_MOD_NAME_CTRL’?
  655 |             xkb_mod_index_t level_five = xkb_keymap_mod_get_index(seat->kbd.xkb_keymap, XKB_VMOD_NAME_LEVEL5);
      |                                                                                         ^~~~~~~~~~~~~~~~~~~~
      |                                                                                         XKB_MOD_NAME_CTRL
```
2025-04-07 09:25:11 +02:00
Łukasz Wojniłowicz
bdf65672c0
Themes: Add 'Molokai' theme 2025-04-07 09:19:34 +02:00
Daniel Eklöf
1760cb6ab8
config: update default URL regex
The old one is in some cases too liberal. The new one is stricter in
two ways:

1. The protocol list is now explicit, rather than matching anything://
2. Allowed characters are now limited to the "safe character set", the
   "reserved character set", and some from the "unsafe character set"

Furthermore, some of the characters are restricted in how/when they
are allowed:

1. Periods, commas, question marks etc are allowed inside an URL, but
   not at the end.
2. [ ], ( ), " " and ' ' are allowed but only when balanced. This
   allows us to match e.g. [http://foo.bar/foo[bar]] correctly.

Closes #2016
2025-04-07 09:11:16 +02:00
Daniel Eklöf
a50f78c599
Merge branch 'kbd-no-virtual-modifiers'
Closes #2009
2025-03-31 13:04:02 +02:00
Daniel Eklöf
0d8c7db962
changelog: reword, and remove section that no longer applies 2025-03-31 11:08:22 +02:00
Daniel Eklöf
a43614f098
doc: foot.ini: mention virtual modifiers are allowed 2025-03-31 10:25:14 +02:00
Daniel Eklöf
dc99cf7358
key-binding: recognize virtual modifiers, and translate to the corresponding real modifier. 2025-03-31 10:25:06 +02:00
Daniel Eklöf
58910856c8
input: xkb: ignore virtual modifiers
Some compositors (mutter/GNOME is one) adds _virtual_ modifiers to the
set of active modifiers when e.g. Alt, Meta, Super or Hyper is
pressed. For example, pressing Alt+b would result in *both* the Alt
*and* the Mod1 modifier being set.

Since foot makes close to zero assumptions on how the modifiers should
be interpreted, this causes various breakages.

For example, a foot shortcut defined as Mod1+b will not match, since
the Alt modifiers is also set. This has forced users to
redefine/override some of the default key bindings to include the
additional modifiers.

It also causes issues with the kitty keyboard protocol, for some key
combinations. Mainly whether or not to use unshifted key or not,
resulting in incorrect escape sequences.

Since all the "real" modifiers are always set as well, we can safely
ignore the virtual modifiers.

Closes #2009
2025-03-31 08:08:43 +02:00
Daniel Eklöf
c8470f40c1
grid: reflow: fix empty line coalescing
If a range of empty lines ended with a non-empty line at the very
bottom of the to-be-resized grid, all those empty lines were removed.

Closes #2011
2025-03-29 10:16:31 +01:00
Alex Xu (Hello71)
9b776f2d6d
meson: add foot (render.c) -> srgb.h dep
otherwise, depending on ninja dependency resolution order and parallel
build, srgb.h may not be built in time

Fixes: ccf625b991 ("render: gamma-correct blending")
2025-03-26 18:17:59 +01:00
Daniel Eklöf
6922ab2b8e
doc: foot.ini: gamma-correct: move section 2025-03-23 17:00:19 +01:00
Sam McCall
663c9082db
render: dim and brighten using linear rgb interpolation
Adds setting tweak.dim-amount, similar to bold-text-in-bright-amount.

Closes #2006
2025-03-23 15:24:23 +01:00
Daniel Eklöf
5f72f51ae8
changelog: url-mode: show-urls-persistent regression fix 2025-03-20 08:52:19 +01:00
llyyr
cc99db5bc4
url-mode: fix crash when opening multiple urls with persist mode
Fixes: 051cd6ecfc
Closes #2000
2025-03-20 08:52:10 +01:00
Daniel Eklöf
a02c0c8d4d
vt: utf8: insert a REPLACEMENT CHARACTER when an invalid UTF-8 sequence is detected 2025-03-18 18:28:09 +01:00
Daniel Eklöf
878e07da59
vt: utf8: don't discard current byte when an invalid UTF-8 sequence is detected
Example:

  printf "pok\xe9mon\n"

would result in 'pokon' - the 'm' has been discarded along with E9.

While correct, in some sense, it's perhaps not intuitive.

This patch changes the VT parser to instead discard everything up to
the invalid byte, but then try the invalid byte from the ground
state. This way, invalid UTF-8 sequences followed by both plain ASCII,
or longer (and valid) UTF-8 sequences are printed as expected instead
of being discarded.
2025-03-18 14:37:28 +01:00
Daniel Eklöf
6813b321f5
changelog: add new 'unreleased' section 2025-03-17 12:15:36 +01:00
Daniel Eklöf
c2a9fd5dfa
Merge branch 'releases/1.21' 2025-03-17 12:15:16 +01:00
Daniel Eklöf
68f5eab0b0
doc: foot.ini: codespell: shouuld -> should 2025-03-17 12:10:34 +01:00
Daniel Eklöf
49d2c08912
doc: foot.ini: codespell: shouuld -> should 2025-03-17 12:08:27 +01:00
Daniel Eklöf
df32cd0504
meson: bump version to 1.21.0 2025-03-17 12:04:59 +01:00
Daniel Eklöf
3eef3ec877
changelog: prepare for 1.21.0 2025-03-17 12:04:46 +01:00
Daniel Eklöf
d2ede697f9
config: remove deprecated options 'notify' and 'notify-focus-inhibit'
They've been deprecated since 1.18.0
2025-03-17 12:02:57 +01:00
Daniel Eklöf
7dbfdc73b6
doc: foot.init: surface-bit-depth: mention 10-bit surfaces are slow 2025-03-17 08:51:27 +01:00
Daniel Eklöf
cd4ee8ae49
ime: fix initial cursor rectangle being reported as 0,0,0,0
Closes #1994
2025-03-17 08:43:12 +01:00
Craig Barnes
eb9357709b main/client: simplify code for printing --version string 2025-03-14 20:15:11 +00:00
Daniel Eklöf
d48a1c53f5
meson: require wayland-protocols >= 1.41 2025-03-13 13:28:34 +01:00
Daniel Eklöf
a79fd6a7cf
meson: require fcft-3.3.1
fcft-3.3.0 is not binary compatible with 3.2.x, and earlier.
2025-03-13 13:23:25 +01:00
Daniel Eklöf
16c384b707
changelog: mention some of the side-effects the new fcft requirement brings 2025-03-12 10:06:13 +01:00
Daniel Eklöf
7f11ba59ef
fcft: require fcft >= 3.3.0, add support for new scaling-filters
Update tweak.scaling-filter to recognize the new scaling filters added
in fcft-3.3.0.

Since fcft_set_scaling_filter() is deprecated in 3.3.0, don't use it
anymore, and set the scaling filter via fcft_font_options instead.
2025-03-12 10:03:06 +01:00
Daniel Eklöf
cfa178ab25
input: kitty: unittest: don't fail if system has no compose tables 2025-03-11 08:42:03 +01:00
Daniel Eklöf
edbfdd5150
changelog: kitty: release events for composed keys 2025-03-11 08:37:42 +01:00
Daniel Eklöf
7976975a8a
input: kitty: send release events for composed keys 2025-03-11 08:36:37 +01:00
Daniel Eklöf
04fcc5f5b5
input: kitty: regression test for #1987 2025-03-11 08:23:23 +01:00
Daniel Eklöf
8d2627b1ef
input: kitty: always use shifted key when it's the result of a compose
Closes #1987
2025-03-10 15:47:20 +01:00
Daniel Eklöf
605694bc93
grid: set linebreak=false when printing to a line, not when allocating it
This ensures empty lines are treated correctly, and is also more in
line with how lines are handled at runtime, when filling the
scrollback.

For now, set linebreak=false as soon as something is printed on a
line. It will remain like that *until* we reach the end of an old row
with linebreak=true, at which point we set linebreak=true on the
current new line.
2025-03-05 18:55:01 +01:00
Daniel Eklöf
7b6efcf19a
grid: change default value of linebreak to true
This way, all lines are treated as having a hard linebreak, until it's
cleared when we do an auto-wrap.

This change alone causes issues when reflowing text, as now all
trailing lines in an otherwise empty window are treated as hard
linebreaks, causing the new grid to insert lots of unwanted, empty
lines.

Fix by doing two things:

* *clear* the linebreak flag when we pull in new lines for the new
  grid. We only want to set it explicitly, when an old row has its
  linebreak flag set.
* Coalesce empty lines with linebreak=true, and only "emit" them as
  new liens in the new grid if they are followed by non-empty lines.
2025-03-05 18:55:01 +01:00
Daniel Eklöf
a80b32d006
term: tweak linebreaking
Don't set linebreak on linefeed. Instead, rely on the default value of
true, and that it is only cleared when a character is printed while
LCF=1.

Note that printing to a row that has linebreak cleared, will set the
linebreak flag again.
2025-03-05 18:55:00 +01:00
Daniel Eklöf
ccf625b991
render: gamma-correct blending
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 >= 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 >= 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
2025-03-05 18:45:01 +01:00
Adrian fxj9a
6d39f66eb7
config: add search-bindings.delete-to-{start,end} key bindings
Defaults to ctrl+u and ctrl+k respectively.

Closes #1972
2025-03-05 08:48:23 +01:00
Daniel Eklöf
9e6d334bd8
term: reset the grapheme clustering state on cursor movements 2025-03-04 07:50:03 +01:00
Daniel Eklöf
882f4b2468
shm-format: add new shm formats 2025-03-02 10:18:00 +01:00
Daniel Eklöf
4f11d6086f
DECSCUSR+DECRQSS: treat hollow cursor as a block cursor
If the user has configured cursor.style=hollow, make DECSCUSR 1/2 set
the cursor to hollow rather than block, and make DECRQSS DECSCUSR
respond as if cursor.style=block.

The idea is to not expose the hollow variant in DECSCUSR in any way,
to avoid having to extend it with custom encodings.

Another way to think about it is this is just a slightly more
discoverable way of doing:

    cursor.style=block
    cursor.block-cursor-is-hollow=yes
2025-02-21 08:03:41 +01:00
Daniel Eklöf
c41008da31
config+render: allow cursor.style=hollow
Closes #1965
2025-02-19 11:50:25 +01:00
Craig Barnes
101bc28698 terminal: add comment/link to cursor::lcf, to clarify its purpose 2025-02-18 17:32:54 +00:00
Daniel Eklöf
9f9ffa9434
term: set_app_id(): app_id may be NULL, in which case we can't do strlen()
Closes #1963
2025-02-18 15:09:23 +01:00