Commit graph

6373 commits

Author SHA1 Message Date
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
Shogo Yamazaki
9d5d84a835
meson: fix false positive detection of memfd_create
Add the arguments to `has_function` to properly detect availability of the
function on SDK environments.
2024-08-09 08:14:12 +02:00
Daniel Eklöf
01eca82d33
readme: remove CI badges for gitlab and sr.ht 2024-08-07 17:15:00 +02:00
Daniel Eklöf
8607fb6312
readme: repology: use four columns instead of three 2024-08-07 17:14:26 +02:00
Daniel Eklöf
a0b5f79f32
readme: repology: use three columns instead of one 2024-08-07 17:13:38 +02:00
Daniel Eklöf
fb74a2df27
changelog: osc-99: sound support 2024-08-04 15:23:33 +02:00
Daniel Eklöf
84d36606cb
osc: kitty notifications: add support for XDG sound names 2024-08-04 15:23:31 +02:00
Daniel Eklöf
6349262491
osc: kitty notifications: implement s=silent
This implements part of the new 's' (sound) parameter; the 'silent'
value. When s=silent, we set the ${muted} template argument to
"true". It is intended to set the 'suppress-sound' hint:

    notify-send --hint BOOLEAN:suppress-sound:${muted}
2024-08-04 14:20:35 +02:00
Daniel Eklöf
a3a35f2c8c
term: reload_fonts(): don't ignore return value of thrd_join()
This should fix the

    ‘ret’ may be used uninitialized

warning

Closes #1789
2024-08-04 11:55:25 +02:00
Craig Barnes
b27841e1b5 Merge branch 'xstrjoin3' 2024-08-03 10:42:37 +01:00
Daniel Eklöf
6b72108ee2
osc: kitty notifications: ignore invalid IDs
Notification IDs must only use characters from [a-zA-Z0-9_-+.]

    Terminals **must** sanitize ids received from client programs
    before sending them back in responses, to mitigate input injection
    based attacks. That is, they must either reject ids containing
    characters not from the above set, or remove bad characters when
    reading ids sent to them.

Foot implements the first: reject IDs containing characters not from
the above set.
2024-08-03 11:05:58 +02:00
Craig Barnes
f87c9bb9f7 xmalloc: remove delim param from xstrjoin() and add separate xstrjoin3()
This avoids the need for an unused third argument for most xstrjoin()
calls and replaces the cases where it's needed with a more flexible
function. Code generation is the same in both cases, when there are 2
string params and a compile-time known delimiter.

This commit also converts 4 uses of xasprintf() to use xstrjoin*().

See also: https://godbolt.org/z/xsjrhv9b6
2024-08-03 08:51:06 +01:00
Daniel Eklöf
62b0b65d47
changelog: add new 'unreleased' section 2024-08-02 14:33:26 +02:00
Daniel Eklöf
bf51d8c19b
Merge branch 'releases/1.18' 2024-08-02 14:33:08 +02:00
Daniel Eklöf
b5e692ef8b
meson: bump version to 1.18.0 2024-08-02 14:28:16 +02:00
Daniel Eklöf
1272632f3b
changelog: prepare for 1.18.0 2024-08-02 14:27:57 +02:00
Daniel Eklöf
a176d8fbdb
readme: typo: foot -> foot's 2024-08-02 12:06:08 +02:00
Daniel Eklöf
aabb239c0f
readme: xtgettcap: mention tigetstr() compability 2024-08-02 10:33:18 +02:00
Daniel Eklöf
901daefd96
changelog: more template parameters we've added to desktop-notifications 2024-08-02 10:18:59 +02:00
Daniel Eklöf
a9e462d952
Remove a number of unused includes 2024-08-02 08:28:13 +02:00
Daniel Eklöf
09ab8c6c7c
notify: codespell: programatically -> programmatically 2024-08-02 08:25:29 +02:00
Daniel Eklöf
1a89538700
notify: codespell: notificaton -> notification 2024-08-02 08:24:03 +02:00
Daniel Eklöf
ebd8ad8937
doc: foot.ini: codespell: furhermore -> furthermore 2024-08-02 08:24:03 +02:00
Daniel Eklöf
ea2f0e7c3f
osc: kitty notifications: cleanup and update to latest version of spec
* Don't store a list of unfinished notifications. Use a single one. If
  the notification ID of the 'current' notification doesn't match the
  previous, unfinished one, the 'current' notification replaces the
  previous one, instead of updating it.

* Update xstrjoin() to take an optional delimiter (for example ','),
  and use that when joining categories and 'alive IDs'.

* Rename ${action-arg} to ${action-argument}

* Update handling of the 'n' parameter (symbolic icon name); the spec
  allows it to be used multiple times, and the terminal is supposed to
  pick the first one it can resolve. Foot can't resolve icons at all,
  neither can 'notify-send' or 'fyi' (which is what foot typically
  executes to display a notification); it's the notification daemon that
  resolves icons.

  The spec _could_ be interpreted to mean the terminal should lookup
  .desktop files, and use the value of the 'Icon' key from the first
  matching .desktop files. But foot doesn't read .desktop files, and I
  don't intend to implement XDG directory scanning and parsing of
  .desktop files just to figure out which icon to use.

  Instead, use a simple heuristics; use the *shortest* symbolic
  names. The idea is pretty simple: plain icon names are typically
  shorter than .desktop file IDs.
2024-08-02 08:07:13 +02:00
Daniel Eklöf
18b87b2e20
notify: don't forget terminating NULL when patching notify helper's argv 2024-07-31 18:33:24 +02:00
Daniel Eklöf
76ac910b11
osc: kitty notifications: buttons, icons, app-name, categories etc
First, icons have been finalized in the specification. There were only
three things we needed to adjust:

* symbolic names are base64 encoded
* there are a couple of OSC-99 defined symbolic names that need to be
  translated to the corresponding XDG icon name.
* allow in-band icons without a cache ID (that is, allow applications
  to use p=icon without having to cache the icon first).

Second, add support for the following new additions to the protocol:

* 'f': custom app-name, overrides the terminal's app-id
* 't': categories
* 'p=alive': lets applications poll for currently active notifications
* 'id' is now 'unset' by default, rather than "0"
* 'w': expire time (i.e. notification timeout)
* "buttons": aka actions. This lets applications add additional (to
  the terminal defined "default" action) actions. The 'activated' event
  has been updated to report which button/action was used to activate
  the notification.

To support button/actions, desktop-notifications.command had to be
reworked a bit.

There's now a new config option:
desktop-notifications.command-action-arg. It has two template
arguments ${action-name} and ${action-label}.

command-action-arg gets expanded for *each* action.

${action-name} and ${action-label} has been replaced by ${action-arg}
in command. This is a somewhat special template, in that it gets
replaced by *all* instances of the expanded actions.
2024-07-31 16:22:17 +02:00
Daniel Eklöf
d87b81dd52
notify: disable debug logging 2024-07-30 17:31:15 +02:00
Daniel Eklöf
259a75e957
notify: remove debug assertion
(FD 0 _is_ valid, after all)
2024-07-30 17:24:48 +02:00
Daniel Eklöf
ba79bf1602
notify: ${icon}: don't fallback to app-id
* Revert --icon to ${app-id}
* Use --hint STRING:image-path:${icon} instead
* ${icon} no longer expands to ${app-id} if notification has no icon
2024-07-30 17:16:02 +02:00
Daniel Eklöf
0a5ba708e4
notify: don't close FD 0
This fixes a regression where closing a terminal instance, or hard- or
soft-resetting a terminal caused FD 0 to be closed.

This meant it became re-usable. Usually, by memfd_create() when
allocating a new surface buffer. So far nothing _really_ bad has
happened.

But what if FD 0 is now used by a memfd, and we close _another_
terminal instance?

This causes our memfd to be closed. And then, when e.g. trying to
scroll the terminal content: fallocate() fails with bad FD.
2024-07-30 16:33:19 +02:00
Daniel Eklöf
a3ad740251
readme: IRC: update link to point to the web interface 2024-07-27 08:48:32 +02:00
Daniel Eklöf
00ec2a8f09
readme: update mastodon link 2024-07-27 08:37:41 +02:00
Daniel Eklöf
9cf99ea4bf
notify: close notification by sending SIGINT to helper
If the user hasn't configured a custom 'desktop-notifications.close'
command, try to close the notification by sending SIGINT to the
notification helper.

This is best-effort:

* If there's no helper running, we do nothing (except warn)
* We don't verify, in any way, the notification is actually closed
* We don't send any other signals, under any circumstances. That is,
  no SIGTERM, no SIGKILL. Ever.
2024-07-26 16:28:47 +02:00
Daniel Eklöf
8f16fe54d3
pgo: add notify_close() stub 2024-07-25 19:31:27 +02:00
Daniel Eklöf
c4d9f8a8ff
osc: kitty notifications: implement the 'close' request
Add a new config option, desktop-notifications.close, defining what to
execute to close a notification. It has a single template parameter,
${id}, that is expanded to the external notification ID foot may have
picked up from the notification helper.

notify-send does not support closing notifications, and it appears
impossible to pass an *unsigned* integer as argument to gdbus. Hence
no default value for the new 'close' option.

Example:

    printf '\e]99;i=123;this is a notification\e\\'
    printf '\e]99;i=123:p=close;\e\\'
2024-07-25 19:24:28 +02:00
Daniel Eklöf
c797222930
osc: kitty notification: implement 'close' events
Application can now request to receive a 'close' event when the
notification is closed (but not necessarily activated), by adding
'c=1' to the notification request.
2024-07-25 18:47:23 +02:00
Daniel Eklöf
d53f0aea75
notify: rename 'report' -> 'report_activated' 2024-07-25 18:45:58 +02:00
Daniel Eklöf
0ce4ef6000
notify: kitty notifications: fix ID string in activation event
We forgot to prefix the notification ID with 'i='
2024-07-25 18:45:04 +02:00
Daniel Eklöf
a213e14ca3
Merge branch 'kitty-notifications' 2024-07-25 18:32:57 +02:00
Daniel Eklöf
a6bc9cafaf
osc+notify: strcmp() -> streq() 2024-07-24 16:04:14 +02:00
Daniel Eklöf
f56da385fe
notify: try to read the daemon assigned notification ID from stdout
And document the things we recognize in the notification helper's
stdout.
2024-07-24 16:02:19 +02:00
Daniel Eklöf
e271027c0c
config: notify-send: it's "action=label", not "action,label" 2024-07-24 16:01:42 +02:00