Commit graph

6414 commits

Author SHA1 Message Date
Daniel Eklöf
a9fefcf58b
render: (debug): assert row->dirty vs. cell->attrs.clean consistency 2024-09-21 09:11:07 +02:00
Daniel Eklöf
046d959657
shm: fix compilation when FORCED_DOUBLE_BUFFERING is enabled 2024-09-21 09:11:07 +02:00
Daniel Eklöf
e2aeb7f336
render: xcursor_is_valid(): don't crash when there's no theme loaded
When trying to set a custom cursor shape, we first validate it. This
is done by checking against known server-side names, and then trying
to load the cursor from the client side cursor theme.

But, if we're using server side names, there is no theme loaded, and
foot crashed.

Fix by checking if we have a theme loaded, and if not, fail the cursor
shape name validation.
2024-09-21 09:10:48 +02:00
Daniel Eklöf
297cb370aa
render: add missing include, limits.h 2024-09-15 09:56:41 +02:00
Daniel Eklöf
33f3818520
Merge branch 'toplevel-icon' 2024-09-13 09:20:50 +02:00
Daniel Eklöf
76b58b5663
changelog: remove escape sequences we've reverted 2024-09-13 09:04:18 +02:00
Daniel Eklöf
9151685d04
csi: revert implementation of CSI 20 t 2024-09-13 09:04:18 +02:00
Daniel Eklöf
7984f08925
osc: OSC-1 does not set the icon, it sets the icon _label_
In fact, there appears there *is* no escape sequence to set the icon.

Keep most of the logic in place, but in practice, we'll always set the
icon to the app-id. That is, at startup, we set it to the configured
app-id (either from config, or the command line).

OSC-176, which sets the app-id, also updates the icon (to the app-id).
2024-09-13 09:04:18 +02:00
Daniel Eklöf
c6208a98c8
main: include toplevel-icon support in --version output 2024-09-13 09:04:18 +02:00
Daniel Eklöf
f5caa2d265
pgo: add missing stub for render_refresh_icon() 2024-09-13 09:04:18 +02:00
Daniel Eklöf
97ec375c67
toplevel-icon: implement OSC-1, CSI 20/21/22/23 t
* The toplevel icon is now set to the app-id, unless "overridden" by
  OSC-1 or OSC-0.
* Implemented OSC-1
* OSC-0 extended to also set the icon
* Implemented CSI 20 t - report window icon
* Implemented CSI 21 t - report window title
* Implemented CSI 22 ; 1 t - push window icon
* Implemented CS 23 ; 1 t - pop window icon
* Extended CSI 22/23 ; 0 t to also push/pop the icon
* Verify app-id set by OSC-176 is valid UTF-8
* Verify icon set by OSC-0/1 is valid UTF-8
2024-09-13 09:04:17 +02:00
Daniel Eklöf
3f8a1fc85b
changelog: xdg-toplevel-icon-v1 2024-09-13 09:04:17 +02:00
Daniel Eklöf
b34137dde3
toplevel-icon: set to app-id, instead of hardcoding to "foot"
And, special case "footclient", and map it to "foot".
2024-09-13 09:04:17 +02:00
Daniel Eklöf
0cb07027f2
wayland: set toplevel icon
If the xdg-toplevel-icon-v1 protocol is available, and we have the
corresponding manager global, set the toplevel icon to "foot".

Note: we do *not* provide any pixel data. This is by design; we want
to keep things simple.

To be able to provide pixel data, we would have to either:

* embed the raw pixel data in the foot binary
* link against either libpng or/and e.g. nanosvg, locate, at run-time,
  the paths to our own icons, and load them at run-time.
* link against either libpng or/and e.g. nanosvg, and, at run-time, do
  a full icon lookup. This would also require us to add a config option
  for which icon theme to use.

Of the two, I would prefer the first option. But, let's skip this
completely for now.

By providing the icon as a name, the compositor will have to lookup
the icon itself. Compositors supporting icons is likely to already
support this.

So what do we gain by implementing this protocol? Compositors no
longer has to parse .desktop files and map our app-id to find the icon
to use.

There's one question remaining. With this patch, the icon name is
hardcoded to "foot", just like our .desktop files. But, perhaps we
should use the app-id instead? And if so, should we also change the
icon when the app-id changes?

My gut feeling is, yes, we should use the app-id instead, and yes, we
should update the icon when the app-id is changed at run-time.
2024-09-13 09:04:17 +02:00
Daniel Eklöf
28a1c67dd5
wayland: bind the xdg-toplevel-icon manager global 2024-09-13 09:04:17 +02:00
Daniel Eklöf
5ef69fc591
meson: detect wayland-protocols >= 1.37, and conditionally enable xdg-toplevel-icon-v1 2024-09-13 09:04:17 +02:00
Craig Barnes
d4a1283797
xsnprintf: various improvements related to xvsnprintf() and xsnprintf()
Summary of changes:

* Make xvsnprintf() static
* restrict-qualify pointer arguments (as done by the libc equivalents)
* Make comments and spec references more thorough
* Remove pointless `n <= INT_MAX` assertion (see comment)
* Use FATAL_ERROR() instead of xassert() (since the assertion is inside
  a shared util function but the caller is responsible for ensuring the
  condition holds true)
* Change some callers to use size_t instead of int for the return value
  (negative returns are impossible and all subsequent uses are size_t)

The updated comments and code were taken (and adapted) from:

49260bb154/src/util/xsnprintf.c (L6-50)

This work was entirely authored by me and I hereby license this
contribution under the MIT license (stated explicitly, so that
there's no ambiguity w.r.t. the original license).
2024-09-13 09:01:15 +02:00
Craig Barnes
31f88e636c readme: typo: foot-ctlseq -> foot-ctlseqs 2024-09-11 22:08:45 +01:00
Daniel Eklöf
1925593a37
render: resize(): don't overflow the number of scrollback lines
The config system allows setting the scrollback lines to
2**32-1.

However, the total number of grid lines is the scrollback lines plus
the window size, and then rounded *up* to the nearest power of two.

Furthermore, the number of rows is represented with a plain 'int'
throughout the code base.

The largest positive integer that fits in an int is 2**31-1. That
however, is not a power of two.

The largest positive integer, that also is a power of two, that fits
in an int is 2**30, or 1073741824.

Ideally, we'd just cast the line count to a 64-bit integer, and call
__builtin_clzl{,l}() on it, and then take the smallest value of that,
or 2**30. But, for some reason, __builtin_clzl(), and
__builtin_clzll() appears to ignore bits above 32, despite they being
typed to long and long long. Bug?

Instead, ensure we never call __builtin_clz() on anything larger than
2**30.

Closes #1828
2024-09-09 06:58:52 +02:00
Daniel Eklöf
8a4bbbf5cb
readme: update mastodon link 2024-09-08 13:45:20 +02:00
Daniel Eklöf
c8185aec1d
desktop: rename to foot{,client,-server}.desktop
That is, skip the reverse DNS naming scheme suggested by the .desktop
specification, and directly match our app-ids ("foot", and
"footclient").

This simplifies .desktop -> window instance mapping, allowing DEs to
match the filenames directly, without having to look at the
StartupWMClass key in the .desktop files.

These are the original names of the .desktop files. There were
renamed (to use the reverse DNS syntax) to please the flathub people,
who *required* this scheme to accept the foot package.

But, since:

* We don't package foot ourselves
* We don't go out of our way to support non-distro packaging schemes
* Flathub still hasn't merged the foot PR (it's now 2 years old)
* There are no know issues in any known DE that prevents a non-reverse
  DNS .desktop filename from working
* There are plenty of other applications that doesn't use reverse DNS
  names (a very clear majority, in my case)

Let's just revert back to the simpler naming scheme.

Closes #1607
2024-09-08 13:06:27 +02:00
Daniel Eklöf
11ff9ba7ec
.desktop: remove StartupWMClass cludge 2024-09-08 10:22:29 +02:00
Daniel Eklöf
a916a6a8ca
metainfo: add recent releases, update feature list 2024-09-08 10:21:28 +02:00
Daniel Eklöf
c41f55c3a0
sixel: default bg color is now taken from the sixel palette, not the ANSI bg color
The wording in the original VT340 documentation is vague:

    Pixel positions specified as 0 are set to the current background
    color.

What does that mean? We _thought_ it meant the current ANSI background
color, as set with e.g. CSI 4x m.

It's still all a bit vague, but seeing that we have separate palettes
for text and graphic (should we?), it doesn't make sense to use the
ANSI background color as the default sixel background color.

So, use entry 0 from the sixel palette instead.
2024-09-05 07:33:05 +02:00
Daniel Eklöf
c5bb1fb2ed
notifications: BEL and OSC-777 now focuses the window on notification activation
Or put more propertly; if the notification daemon, and the
notification helper used by foot has been configured
properly (i.e. they both support XDG activation tokens), notifications
generated by BEL and OSC-777 will now raise/focus the window when the
default action of the notification is activated - typically by
clicking the notification.

Closes #1822
2024-09-05 07:16:15 +02:00
Daniel Eklöf
c15ebbfa2e
changelog: strikeout-thickness 2024-08-26 19:36:26 +02:00
Oleh Hushchenkov
b47a4dd255
add setting for strikeout thickness 2024-08-26 19:34:47 +02:00
Daniel Eklöf
01fa59b6b7
changelog: mbsntoc32() failure checks 2024-08-20 07:17:58 +02:00
Daniel Eklöf
8f9f3dbd9d
term_set_window_title(): fix bad check for invalid UTF-8
mbsntoc32() returns (size_t)-1 on failure, not (char32_t)-1.
2024-08-20 07:15:22 +02:00
Daniel Eklöf
7dd204fd31
osc: notify: fix bad check for invalid UTF-8
mbsntoc32() returns (size_t)-1 on failure, not (char32_t)-1.
2024-08-20 07:14:53 +02:00
Daniel Eklöf
be13788a4f
changelog: resize-keep-grid 2024-08-20 07:12:19 +02:00
Daniel Eklöf
b3fd994fd3
changelog: add missing reference to #1787 2024-08-20 07:12:09 +02:00
Andrew J. Hesford
1969717527
feature: add resize-keep-grid to allow text reflow on font changes 2024-08-20 07:07:29 +02:00
tokyo4j
a2fc2a986e
render: follow cursor.unfocused-style regardless of cursor.style
Before this commit, cursor.unfocused-style was effective only with
cursor.style=block
2024-08-20 06:59:33 +02:00
Daniel Eklöf
96c30cd410
term: thrd_join() returns thrd_success on success, not 0
Closes #1812
2024-08-15 17:20:12 +02:00
Daniel Eklöf
dc5ff7db28
changelog: add new 'unreleased' section 2024-08-14 12:02:56 +02:00
Daniel Eklöf
4cd65f0e70
Merge branch 'releases/1.18' 2024-08-14 12:02:36 +02:00
Daniel Eklöf
ce9c9f6be6
meson: bump version to 1.18.1 2024-08-14 12:00:20 +02:00
Daniel Eklöf
447b02b530
changelog: prepare for 1.18.1 2024-08-14 12:00:08 +02:00
Daniel Eklöf
54c1660a1e
Merge branch 'master' into releases/1.18 2024-08-14 11:59:23 +02:00
Daniel Eklöf
2896c18981
osc: regression: fix OSC-111 handling of alpha changes
When the background alpha changes from fully opaque, to transparent,
or vice versa, we need to do more than just repaint the affected
cells.

For example, we need to create new surfaces with the correct pixel
format.

OSC-11 (set background color) already does this, but the same alpha
checking logic was missing in OSC-111 (reset background color).

Fixes #1801
2024-08-14 08:53:45 +02:00
Daniel Eklöf
eb185bfa47
utils/xtgettcap: fix possible NULL deref, found by -fanalyzer 2024-08-14 08:53:21 +02:00
Daniel Eklöf
cee0c5423a
main: spell out the most common reason for setlocale() to fail 2024-08-13 17:33:31 +02:00
Daniel Eklöf
6d351ffc43
main: invalid locale != non-UTF-8 locale
When doing locale fallback, and printing user notifications and log
warnings, better separate the case "locale is invalid" from "locale is
valid but not UTF-8".

Closes #1798
2024-08-13 17:33:23 +02:00
Daniel Eklöf
7e1894978f
slave: prefix user notifications with 'foot'
To make it clearer _who_ is emitting the warning/errors
2024-08-09 13:55:21 +02:00
Daniel Eklöf
ee9c76ded0
osc: kitty: update 's' to the latest spec
* The spec now defines a couple of "standard" names. Translate these
  to the freedesktop compliant names.
* The query response no longer contains 'xdg-names', but instead list
  the supported standard names.
2024-08-09 08:25:36 +02:00
Daniel Eklöf
481ce82d66
doc: foot.ini: document the Unicode ranges covered by the builtin glyphs 2024-08-09 08:24:53 +02:00
Daniel Eklöf
bef613e656
csd: track pointer when rendering and handling CSD button clicks
* Render button as highlighted only when pointer is above them
* Releasing the mouse button while *not* on the button does *not*
  activate the button

When pressing, and holding, a mouse button, the compositor keeps
sending motion events for the surface where the button was pressed,
even if the mouse has moved outside it.

We also don't get any surface leave/enter events.

This meant that the button was rendered as highlighted, and a click
registered, if the user pressed the mouse button while on the button,
and then moved the cursor away from the button before releasing the
button.

This patch fixes it, by checking if the current cursor coordinates
fall within the button surface.
2024-08-09 08:20:59 +02:00
Daniel Eklöf
7ec9ca2b95
input: CSD buttons are now triggered when releasing the mouse button
This is how most UIs work.

Note that we (at least on River) don't get any surface enter/leave
events while a button is held. This means we can't detect if the user
pressed the mouse button while on a CSD button, but then moves the
mouse outside. Releasing the mouse button will still activate the CSD
button.

Closes #1787
2024-08-09 08:20:36 +02:00
Daniel Eklöf
803f712332
meson: add "prefix: '#include <unistd.h>" to cc.has_function()
When checking for execvpe, include <unistd.h>
2024-08-09 08:15:13 +02:00