Commit graph

5425 commits

Author SHA1 Message Date
Daniel Eklöf
8046e5560a
changelog: key binding overrides having no effect with footclient 2022-04-17 16:01:30 +02:00
Daniel Eklöf
90a2ca966f
key-binding: new API, for handling sets of key bindings
Up until now, our Wayland seats have been tracking key bindings. This
makes sense, since the seat’s keymap determines how the key bindings
are resolved.

However, tying bindings to the seat/keymap alone isn’t enough, since
we also depend on the current configuration (i.e. user settings) when
resolving a key binding.

This means configurations that doesn’t match the wayland object’s
configuration, currently don’t resolve key bindings correctly. This
applies to footclients where the user has overridden key bindings on
the command line (e.g. --override key-bindings.foo=bar).

Thus, to correctly resolve key bindings, each set of key bindings must
be tied *both* to a seat/keymap, *and* a configuration.

This patch introduces a key-binding manager, with an API to
add/remove/lookup, and load/unload keymaps from sets of key bindings.

In the API, sets are tied to a seat and terminal instance, since this
makes the most sense (we need to instantiate, or incref a set whenever
a new terminal instance is created). Internally, the set is tied to a
seat and the terminal’s configuration.

Sets are *added* when a new seat is added, and when a new terminal
instance is created. Since there can only be one instance of each
seat, sets are always removed when a seat is removed.

Terminals on the other hand can re-use the same configuration (and
typically do). Thus, sets ref-count the configuration. In other words,
when instantiating a new terminal, we may not have to instantiate a
new set of key bindings, but can often be incref:ed instead.

Whenever the keymap changes on a seat, all key bindings sets
associated with that seat reloads (re-resolves) their key bindings.

Closes #931
2022-04-17 15:39:51 +02:00
Daniel Eklöf
e95bc9283e
meson: install foot.ini to /etc/xdg/foot/foot.ini
Closes #1001
2022-04-17 11:27:53 +02:00
Daniel Eklöf
501a9fbb5e
url-mode: add a key binding that enables “persistent” URL mode
This is an alternative to ‘show-urls-launch’, where we stay in URL
mode after activating an URL.

Closes #964
2022-04-17 11:24:27 +02:00
Daniel Eklöf
0062f4e133
changelog: scrollback search mode highlights all matches 2022-04-17 11:05:14 +02:00
Daniel Eklöf
9e3c71c277
render: overlay: apply weston quirk 2022-04-17 11:04:27 +02:00
Daniel Eklöf
074bbf767e
search: refactor: search_update_selection() takes a ‘struct range’ 2022-04-16 20:23:15 +02:00
Daniel Eklöf
bd089c845f
search: break out “find next match” logic to a new function 2022-04-16 20:13:22 +02:00
Daniel Eklöf
90c91d6148
search/render: initial support for highlighting all visible matches
Before this patch, only the currently “selected” match was
highlighted (by having the “selected” attribute, and by *not* dimming
it, like the rest of the grid during a scrollback search).

With this patch, we now highlight matches within the viewport. While
searching, only the “primary” match is searched-for, and tracked.

Then, when rendering a frame, we find all “secondary” matches as
well. “holes” are added to the search-mode overlay by the means of an
search-match iterator.

The iterator’s text matching logic is *very* similar to what we do
when the search criteria has been updated, and we re-search the
scrollback. It should be possible to refactor this, and share code.
2022-04-16 19:26:20 +02:00
Daniel Eklöf
78fcdc5787
render: implement ‘flash’ and search mode’s ‘dimming’ with a sub-surface
Search mode and ‘flash’ (OSC-555) both achieves similar visual
effects: flash tints the entire window yellow, and search mode dims
it (except the search match).

But, they do so in completely different ways. Search mode is detected
in render_cell(), and the colors are then dimmed there.

Flash is implemented by blending a yellow, semi-transparent color on
top of the rendered grid.

This patch replaces those two implementations with a single one. We
add a new sub-surface, called the ‘overlay’. In normal mode, it’s
unmapped.

When either search mode, or flash, is enabled, we enable it, and
fill it with a semi-transparent color. Yellow for ‘flash’, and
“black” (i.e. no color) for search mode.

The compositor then blends it with the grid. Hopefully on the GPU,
meaning it’ll be faster than if we blend in software.

There are more performance benefits however. By using a separate
surface, we can do much better damage tracking.

The normal grid rendering code no longer have to care about neither
search mode, nor flash. Thus, we get rid of a couple of ‘if’
statements in render_cell(), which is nice. But more importantly, we
can drop full grid repaints in a couple of circumstances:

* Entering/exiting search mode
* Every frame while flash is active

Now, when rendering the search mode overlay, we do want to do some
damage tracking, also of the overlay.

This, since search mode doesn’t dim the *entire* window. The search
match is *not* dimmed. This is implemented by punching a hole in the
overlay sub-surface. That is, we make part of it *fully*
transparent. The basic idea is to set a clip region that excludes the
search match, and then dim the rest of the overlay.

It’s slightly more complicated than that however, if we want to reuse
the last frame’s overlay buffer (i.e we don’t want to re-render
the *entire* overlay every frame).

In short, we need to:

* Clear (punch hole) in areas that are part of this frame’s search
  match, but not the last frame’s (since those parts are _already_
  cleared).
* Dim the areas that were part of the last frame’s search match, but
  aren’t anymore (the rest of the overlay should already be dimmed).

To do this, we save the last frame’s “holes” (as a pixman
region). Then, when rendering the next frame, we first calculate the
new frame’s “holes” region.

The region to clear is “this frame’s holes minus last frame’s holes”
The region to dim is “last frame’s holes minus this frames holes”.

Finally, we compute the bounding box of all modified cells by taking
the union of the two diff regions mentioned above. This allows us to
limit the buffer damage sent to the compositor.
2022-04-16 18:31:02 +02:00
Daniel Eklöf
abbdd3bae8
shm: add shm_did_not_use_buffer()
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.
2022-04-16 17:47:56 +02:00
Daniel Eklöf
129deaffa8
wayland: optionally disable pointer input on subsurfaces
We have a number of sub-surfaces for which we are *not* interrested in
pointer (or touch) input.

Up until now, we’ve manually dealt with these, by recognizing these
surfaces in all pointer events, and ignoring them.

But, lo and behold, there are better ways of doing this. By clearing
the subsurface’s input region, the compositor will do this for us -
when a pointer is outside a surface’s input region, the event is
passed to the next surface underneath it.

This is exactly what we want! Do this for all subsurfaces, *except*
the CSDs.
2022-04-16 17:41:14 +02:00
Daniel Eklöf
fc2ebf772c
changelog: [csd].hide-when-maximized 2022-04-16 11:45:52 +02:00
Daniel Eklöf
fbcebd4f1c
config: add [csd].hide-when-maximized=yes|no
When enabled, the CSD titlebar will be hidden when the window is
maximized.

Closes #1019
2022-04-16 11:45:50 +02:00
Daniel Eklöf
979f48a62f
render: take (visible) CSD border size into account when setting initial size 2022-04-16 11:42:26 +02:00
Daniel Eklöf
f9103d4381
wayland: add helper functions wayl_win_csd_{titlebar,borders}_visible() 2022-04-16 11:42:25 +02:00
Daniel Eklöf
7a0e7c6c01
wayland: take (visible) border width into account on configure events
When the compositor is asking us to resize ourselves, take
our (visible) CSD borders into account. This is similar to how we
already take the titlebar size into account.

This fixes an issue where the window size “jumps” when the user starts
an interactive resize, when csd.border-width > 0.

This as been observed in GNOME.
2022-04-16 11:17:19 +02:00
Daniel Eklöf
0e477e2c5e
render: take visible border width into account when setting window geometry
This fixes e.g. window snapping in GNOME.
2022-04-16 10:57:45 +02:00
Merlin Büge
5539eac590
fix some small typos 2022-04-13 09:41:10 +02:00
Daniel Eklöf
a1796ba5cd
pgo: sync up stub version of slave_spawn() 2022-04-12 15:23:41 +02:00
Daniel Eklöf
99db7aa7cf
config: config_free(): pass conf struct by pointer, not by-value 2022-04-12 15:21:43 +02:00
Daniel Eklöf
06d7432af3
config: simplify lookup of foot.ini
The old, complex, way of using a dynamic list to hold each path
component made _some_ sense before, when we needed to support both
~/.config/foot.ini and ~/.config/foot/foot.ini.

But now, it just over complicates things.
2022-04-12 15:21:11 +02:00
Daniel Eklöf
bdef28c6d1
Merge branch 'footclient-environ'
Closes #1004
2022-04-12 15:08:00 +02:00
Daniel Eklöf
b3d0cdd4b2
slave: roll our own ‘execvpe()’ on FreeBSD 2022-04-12 15:07:41 +02:00
Daniel Eklöf
fd414f79be
client/slave: explictly add ‘extern char **environ’
It’s not in any header files on FreeBSD.
2022-04-12 15:07:41 +02:00
Daniel Eklöf
261797ec56
client: refactor: add send_string_list() function
Use it to send ‘overrides’ and ‘envp’
2022-04-12 15:07:41 +02:00
Daniel Eklöf
3c6836e32d
doc: footclient: codespell 2022-04-12 15:07:41 +02:00
Daniel Eklöf
f48955b26e
completions: footclient: add -E,--client-environment 2022-04-12 15:07:41 +02:00
Daniel Eklöf
fd1e5feda4
doc: footclient: add -E,--client-environment 2022-04-12 15:07:41 +02:00
Daniel Eklöf
d02124902b
client: add -E,--client-environment
When this option is used, the child process in the new terminal
instance will inherit its environment from the footclient process,
instead of the foot server’s.

Implemented by sending (yet another) dynamic string list as part of
the client -> server setup packet. When the new option is *not* used,
the setup packet is now 2 bytes larger than before.

On the server side, the slave process now uses execvpe() instead of
execvp(). There’s plumbing to propagate a new ‘envp’ argument from
term_init() all the way down to slave_exec(). If ‘envp’ is NULL, we
use ‘environ’ instead (thus matching the old behavior of execvp()).

Closes #1004
2022-04-12 15:07:40 +02:00
Craig Barnes
856086bbbe
csi: reduce duplication in code handling SGR 38 and 48 sequences 2022-04-11 14:20:11 +02:00
Daniel Eklöf
6792f5fce0
doc: ctlseq: document XTMODKEYS 2022-04-10 18:36:04 +02:00
Daniel Eklöf
0d42e039bb
changelog: improved compatibility with XTerm when modifyOtherKeys=2 2022-04-10 18:36:04 +02:00
Daniel Eklöf
5d6eaf606b
input: improve XTerm compatibility when modifyOtherKeys=2
Before this, foot always emitted a CSI if _any_ modifier was
active. XTerm doesn’t behave quite like this. Instead, it appears to
special-case shift somewhat:

If the generated symbol (e.g ‘A’) is the upper case version of the
pressed key’s base symbol (‘a’), and is in the range a-z, emit a CSI.

If not emit a plain symbol:

Examples (Swedish layout):

* shift-a (generated symbol is ‘A’) emits a CSI
* shift-, (generated symbol is ‘;’) emits ‘;’
* shift-alt-, (generated symbol is ‘;’) emits a CSI

Closes #1009
2022-04-10 18:34:51 +02:00
Daniel Eklöf
d1a072d67d
pgo: fix selection.{start,end} initializers
This fixes a regression introduced in
5b1f1602bc
2022-04-10 18:31:13 +02:00
Daniel Eklöf
07253c29d1
search: use a local ‘grid’ variable to hold term->grid 2022-04-09 17:28:16 +02:00
Daniel Eklöf
5b1f1602bc
refactor: add a ‘range’ struct, grouping a start and end coord together 2022-04-09 15:09:02 +02:00
Daniel Eklöf
c7dd30742a
config: use fallback when XDG_CONFIG_{HOME,DIRS} is set, but empty 2022-04-07 13:06:01 +02:00
Daniel Eklöf
20608c987b
config: fallback to /etc/xdg if XDG_CONFIG_DIRS is unset
Closes #1008
2022-04-07 13:06:01 +02:00
jvoisin
58a1ffe724
config: add tweak option to allow disabling sixels
Closes #950
2022-04-06 19:25:43 +02:00
Craig Barnes
0d1e6960af
osc: avoid unnecessary calls to strlen(3)
Checking for specific strings of length 0 or 1 can be done with e.g.:

    if (str[0] == '\0') {...}
    if (str[0] == '?' && str[1] == '\0') {...}

Doing it this way instead of using strlen(3) means we avoid the
function call overhead and also avoid scanning through more of the
string than is neceessary.

A compiler could perhaps optimize away calls to strlen(3) when the
result is compared to a small constant, but GCC 11.2 only seems to
actually do this[1] for lengths of 0.

[1]: https://godbolt.org/z/qxoW8qqW6
2022-04-06 18:19:47 +02:00
Daniel Eklöf
5ce1589c60
render: ensure an underline cursor is not positioned too low
The underline cursor is positioned just below regular underlines. A
bug in the positioning logic related to this, sometimes resulted in
the cursor being thinner than what it should be, or even invisible.

Fixes #1005
2022-04-06 18:17:59 +02:00
Merlin Büge
49ba16da25
Small clarification/rewording of default color values
This makes the example config `foot.ini` and its man page slightly more
coherent regarding the specification of default values.

Note that the cursor color is not hardcoded like e.g. foreground or
background, thus in the example config, `<inverse foreground/background>`
makes more sense.
2022-04-06 18:16:40 +02:00
Merlin Büge
ee6007aa07 doc: fix some small typos 2022-04-06 15:46:59 +02:00
Daniel Eklöf
f2870bf56c
doc: foot.ini: escape ‘-’ and ‘*’ 2022-04-05 20:20:55 +02:00
Daniel Eklöf
ca1e4e85d3
foot.ini: fix default value of dpi-aware (it’s ‘auto’) 2022-04-05 19:46:49 +02:00
Daniel Eklöf
ea9d38a6ac
doc: foot.ini: align documented default value of uri-characters with reality
Fixes #1000
2022-04-05 19:42:42 +02:00
L3MON4D3
d6dab2f2ba
Use circles for rendering light arc box-drawing characters.
Ellipses can look weird when the font is narrow.

Closes #988
2022-04-03 18:49:47 +02:00
Mariusz Bialonczyk
bbf9dcc2a3 themes/material-design: add missing bright colors 2022-03-29 08:44:49 +02:00
Daniel Eklöf
de5226c930
dcs: don’t automatically buffer anything
If a request handler doesn’t define its own put() handler, simply drop
all DCS parameter data. This way, we won’t end up allocating
potentially large buffers for unsupported/unimplemented DCS requests.

Closes #959
2022-03-21 20:40:51 +01:00