Commit graph

736 commits

Author SHA1 Message Date
Daniel Eklöf
8691ad8b2e
input: update serial on each key press/release and mouse button
The serial is used when copying/pasting data from the clipboard. Up
until now, we’ve used the serial from the keyboard/mouse enter
events.

This works in most cases, but breaks in the following example:

  $ wl-copy  WLCOPY
  /* Ctrl+Shift+v works fine (pastes "WLCOPY") */

  $ printf "\033]52;c;eHl6\a"
  /* Ctrl+Shift+v pastes "WLCOPY" instead of "xyz" */

Shifting focus away and then back to the foot window, and re-executing
the printf works, suggesting the “enter” serial is no longer valid
after another process(?) has copied something to the clipboard.

Updating the serial on key press/release (and the corresponding mouse
serial on mouse button events) seems to fix this.

I’ve also tested that “normal” copy/paste operations, within the same
foot instance, and between foot and other applications, are still
working. In at least river (wlroots based), and GNOME/mutter.

Closes #753
2021-10-20 19:59:57 +02:00
Daniel Eklöf
5ab49de7f2
selection: convert \r -> \n when reading clipboard data
This fixes an issue where pasting (using e.g. OSC-52) in client
applications that doesn’t do this conversion themselves, like tmux,
doesn’t work.

Closes #752
2021-10-19 21:34:04 +02:00
Daniel Eklöf
d4b365b55c
pgo: full-inner: add --override tweak.grapheme-shaping=no
Grapheme shaping is now enabled by default in foot. However, when
generating the profiling data in PGO builds, this results in skewed
optimizations.

The end result is worse benchmark results regardless of whether
grapheme-shaping is enabled or not (when running the benchmarks).
2021-10-16 16:58:59 +02:00
Daniel Eklöf
37f9f54840
config: enable grapheme shaping by default
This changes the default value of tweak.grapheme-shaping to “yes”,
thus enabling grapheme shaping by default.

It also changes the default value of tweak.grapheme-width-method to
“wcswidth”, for maximum compatibility with terminal applications.
2021-10-13 17:42:40 +02:00
feeptr@codeberg.org
85cc05ba22 changelog: list scrollback.indicator-color addition 2021-10-09 16:59:52 -04:00
Daniel Eklöf
0be711497d
Merge branch 'fix-0px-csd-crash' 2021-10-08 10:05:52 +02:00
feeptr@codeberg.org
ed42276ee1 changelog: mention csd.size=0 fix 2021-10-08 02:28:01 +00:00
Mitja Horvat
729f7466ae notify: add the notify-focus-inhibit config option
foot doesn't show desktop notifications (via OSC777) if the current
terminal has keyboard focus.

This is probably a sane default, but there are use cases where showing
a notification regardless of the focus status may be desired. For
example, a completion notification of a long running task inside a
non-focused tmux window.

This PR adds the notify-focus-inhibit option which can be used to
disable inhibition of notifications when the window has focus.

The default value is `yes`, which retains the old behavior.
2021-10-06 23:33:17 +02:00
Daniel Eklöf
8e4d020a41
input: check for ‘effective’ modifiers, not ‘depressed’
When reading XKB modifier state, use XKB_STATE_MODS_EFFECTIVE, not
XKB_STATE_MODS_DEPRESSED.

This fixes handling of ‘sticky’ modifier keys.
2021-10-02 17:33:01 +02:00
Daniel Eklöf
e49f741383
changelog: add a new ‘unreleased’ section 2021-10-02 14:48:13 +02:00
Daniel Eklöf
f6b96b6900
changelog: prepare for 1.9.2 2021-10-02 14:46:42 +02:00
Daniel Eklöf
9389f337d0
pgo: full-inner: do not set LC_CTYPE=en_US.UTF-8
That locale may not exist. Instead, require the user/build script to
explicitly set an UTF-8 locale.

Document this in INSTALL.md, and in the bundled PKGBUILD.
2021-10-02 14:46:02 +02:00
Daniel Eklöf
9b0fb39951
changelog: add a new ‘unreleased’ section 2021-10-01 21:57:57 +02:00
Daniel Eklöf
041c83549b
changelog: prepare for 1.9.1 2021-10-01 20:52:19 +02:00
Daniel Eklöf
548d7be4c6
selection: line-wise selection now handles soft line-wrapping
Previously, soft-wrapped lines were not selected correctly, as the
selection logic was hardcoded to simply select everything between the
first and last column on the current terminal row.

Now, we scan backward and forward, looking for hard-wrapped
lines. This is similar to how word-based selection works.

Closes #726
2021-09-30 13:39:23 +02:00
Daniel Eklöf
fb77637eb9
term: only scale using DPI if *all* monitors have a scaling factor or one
With dpi-aware=auto (the default), scale fonts using DPI *only*
if *all* available monitors have a scaling factor of one.

The idea is this: if a user, with multiple monitors, have enabled
scaling on *at least* one monitor, he/she has most likely done so to
match the size of his/hers other monitors.

For example, if the user has one monitor with a scaling factor of one,
and another one with a scaling factor of two, he/she expects things to
be twice as large on the second monitor.

If we (foot) scale using DPI on the first monitor, and using the
scaling factor on the second monitor, foot will *not* look twice as
big on the second monitor (this was the old behavior of
dpi-aware=auto).

Part of #714
2021-09-24 22:07:47 +02:00
Craig Barnes
ef7919e64d main/client: add no-op "-e" command-line option 2021-09-18 23:40:40 +01:00
Daniel Eklöf
b4c759e2de
box-drawing: add braille characters
Render braille ourselves, instead of using font glyphs. Decoding a
braille character is easy enough; there are 256 codepoints,
represented by an 8-bit integer (i.e. subtract the Unicode codepoint
offset, 0x2800, and you’re left with an integer in the range 0-255).

Each bit corresponds to a dot. The first 6 bits represent the upper 6
dots, while the two last bits represent the fourth (and last) row of
dots.

The hard part is sizing the dots and the spacing between them.

The aim is to have the spacing between the dots be the same size as
the dots themselves, and to have the margins on each side be half the
size of the dots.

In a perfectly sized cell, this means two braille characters next to
each other will be evenly spaced.

This is however almost never the case. The layout logic currently:

* Set dot size to either the width / 4, or height / 8, depending on
  which one is smallest.

* Horizontal spacing is initialized to the width / 4

* Vertical spacing is initialized to the height / 8

* Horizontal margins are initialized to the horizontal spacing / 2

* Vertical margins are initialized to the vertical spacing / 2.

Next, we calculate the number of “remaining” pixels. That is, if we
add the left margin, two dots and the spacing between, how many pixels
are left on the horizontal axis?

These pixels are distributed in the following order (we “stop” as soon
as we run out of pixels):

* If the dot size is 0 (happens for very small font sizes), increase
  it to 1.
* If the margins are 0, increase them to 1.
* If we have enough pixels (need at 2 horizontal and 4 vertical),
  increase the dot size.
* Increase spacing.
* Increase margins.

Closes #702
2021-09-12 19:22:12 +02:00
Daniel Eklöf
32900207f9
changelog: pgo build scripts 2021-09-12 16:59:23 +02:00
Daniel Eklöf
e553e1076c
input: workaround GNOME issue with pointer button events
Under certain circumstances, GNOME will send multiple pointer button
press events, without any release or leave events in between.

This trips up our button tracking.

Workaround, by replacing the existing state for the pressed button
with the new state.

Previously, debug builds would assert (and thus crash), while release
builds would have multiple states for the same button,
causing (probably) issues like the title bar not being usable (as in,
cannot be dragged, buttons not working etc).

Hopefully closes #709
2021-09-12 10:32:22 +02:00
Daniel Eklöf
e51e085d7a
changelog: check if primary font is monospaced 2021-08-31 19:58:35 +02:00
Daniel Eklöf
83c8eeb575
changelog: terminfo changes 2021-08-30 20:31:28 +02:00
Daniel Eklöf
ac30da7a01
spawn: don’t error out if we fail to chdir() 2021-08-30 17:55:36 +02:00
Daniel Eklöf
341193a627
changelog: add new ‘unreleased’ section 2021-08-27 13:44:18 +02:00
Daniel Eklöf
fd0236f323
changelog: prepare for 1.9.0 2021-08-27 13:32:21 +02:00
Daniel Eklöf
ee68a3fe95
changelog: cursor.blink now works in GNOME 2021-08-18 20:18:00 +02:00
Daniel Eklöf
7639186865
terminfo: install to $datadir/foot/terminfo by default, append to TERMINFO_DIRS
As of 2021-07-31, ncurses ships its own version of foot’s terminfo.

Since:

* It doesn’t have the non-standard Sync,Tc,setrgbf,setrgbb
  capabilities.
* It doesn’t set hs,fsl,dsl (statusbar).
* We want to be able to update our termminfo without waiting for an
  ncurses release.
* Foot should be installable and usable on Linux systems that doesn’t
  have the latest ncurses.

we still want to ship our own version. We can however not install it
to the default terminfo location (e.g. /usr/share/terminfo), since it
will collide with the ncurses provided files.

Our options are to either rename our terminfo to something else, or to
keep the name, but install our terminfo files somewhere else.

The first option would be the easy one. However, I think it makes
sense to use the same name. For example, a user that SSH’s into a
remote system that does *not* have our own version installed,
but *does* have the ncurses one, will gracefully fall back to that
one, which is better than manually having to set
e.g. TERM=xterm-256color.

Now, if we want to use the same name, we need to install it somewhere
else. But where? And how do we ensure our version is preferred over
the ncurses one?

I opted to $datadir/foot/terminfo (e.g. /usr/share/foot/terminfo) by
default. It makes it namespaced to foot (i.e. we’re not introducing a
new “standard” terminfo location), thus guaranteeing it wont collide
with ncurses.

To enable applications to find it, we export TERMINFO_DIRS. This is a
list of *additional* directories to search for terminfo files. If it’s
already defined, we *append* to it.

The nice thing with this is, if there’s no terminfo in that
location (e.g. when you SSH into a remote), the default terminfo
location is *also* searched. But only *after* having searched through
TERMINFO_DIRS.

In short: our version is preferred, but the ncurses one (or an older
version of our terminfo package!) will be used if ours cannot be
found.

To enable packagers full control over the new behavior, the existing
meson command line options have been modified, and a new option added:

-Dterminfo=disabled|enabled|auto: *build* and *install* the terminfo
files.

-Dcustom-terminfo-install-location=<path>: *where* the terminfo files
are expected to be found.

This *needs* to be set *even* if -Dterminfo=disabled. For example, if
the packaging script builds and packages the terminfo files separate
from the regular foot build. The path is *relative to $prefix*, and
defaults to $datadir/foot/terminfo.

This is the value that will be appended to TERMINFO_DIRS. Note that
you can set it to ‘no’, in which case foot will *not* set/modify
TERMINFO_DIRS. Only do this if you don’t intend to package foot’s
terminfo files at all (i.e. you plan on using the ncurses ones only).

-Ddefault-terminfo=foot. Allows overriding the default TERM
value. This should only be changed if the target platform doesn’t
support terminfo files.

Closes #671
2021-08-17 21:04:30 +02:00
Daniel Eklöf
b4402a6aa5
term: check visual-focus, not kbd-focus when enabling/disabling cursor blink
term_cursor_blink_update() is called when the visual focus changes
state (i.e. when our top-level surface is activated de-activated).

Checking keyboard focus worked on Sway, but on e.g. GNOME, the order
in which keyboard focus and visual focus are updated is different, and
we ended up either making the cursor invisible, or visible, but not
blinking, when changing focus back to the window.

Closes #686
2021-08-17 18:31:42 +02:00
Daniel Eklöf
f204f09253
changelog: mention keypad application mode keys being removed 2021-08-14 21:10:47 +02:00
Daniel Eklöf
b40aefa50a
changelog: mention km/smm/rmm being removed 2021-08-14 21:08:32 +02:00
Daniel Eklöf
f6f8f2b35e
pt-or-px: heed the dpi-aware setting
Before this patch, pt-or-px values, like letter-spacing, were *always*
scaled using the current DPI value.

This is wrong; if the fonts are scaled using the output’s scaling
factor, then so should all other point values.

This also fixes an issue where e.g. letter-spacing would use one DPI
value at startup, but then when increasing/decreasing or resetting the
font size, would be re-calculated using a different DPI value, leading
to completely different spacing.

This happened when there were multiple monitors, with different DPI
values, and foot guessed the initial DPI value wrong. Normally, foot
would correct itself as soon as the window was mapped, and the
“correct” DPI value known. But if the fonts were scaled using the
scaling factor, it was possible that the font reload never happened.

This patch also updates the thickness calculation (for LIGHT and HEAVY
box drawing characters) to use the scaling factor when appropriate.

Closes #680
2021-08-13 17:38:56 +02:00
Daniel Eklöf
41a8f2fc65
render: run the “overflowing glyphs” prepass *before* rendering sixels
This fixes an issue where the left-most column of a sixel was
“overwritten” by the cell content.

This patch also rewrites the prepass logic, to try to reduce the
number of loads performed.

The new logic loops each row from left to right, looking for dirty
cells. When a dirty cell is found, we first scan backwards, until we
find a non-overflowing cell. That cell is unaffected by the
overflowing cell we’re currently dealing with.

We can also stop as soon as we see a dirty cell, since that cell will
already have been dealt with.

Then, we scan forward, dirtying cells until we see a non-overflowing
cell. That first non-overflowing cell is also dirtied, but after that
we break.

The last loop, that scans forward, advances the same cell pointer used
in the outer loop.
2021-08-11 18:26:00 +02:00
Daniel Eklöf
5ce48a6574
changelog: url.uri-characters 2021-08-09 19:58:40 +02:00
Daniel Eklöf
c2cc964116
input: implement support for mouse wheel left/right
We now emit button 6/7 events (when the client application grabs the
mouse). This buttons map to mouse wheel horizontal scroll events. Or, left/right
tilting, if you like.

Wayland report these as ‘axis’ events (just like regular scroll wheel events),
and thus we need to translate those scroll events to button events.

libinput does not define any mouse buttons for wheel tilts, so we add our own
defitions. These are added last in the BTN_* range, just before the BTN_JOYSTICK
events.
2021-08-07 12:27:44 +02:00
Daniel Eklöf
7a372a8c23
Revert "terminfo: add ich1=\E[@"
This reverts commit 76fab8cf69.

See https://codeberg.org/dnkl/foot/issues/668#issuecomment-246149
2021-08-07 12:25:42 +02:00
Daniel Eklöf
159ae6cb95
terminfo: change kmous to \E[<, add XM+xm capabilities
ncurses has had a bug where mouse support is completely disabled if the terminfo
didn’t have kmous=\E[M, *or*, the terminfo *name* contained ‘xterm’.

This appears to have been fixed.

Thus, change kmous to \E[<, and set xm/XM accordingly. With this, ncurses
application will use the SGR mouse reporting mode, instead of the legacy
reporting mode.
2021-08-06 22:34:47 +02:00
Daniel Eklöf
76fab8cf69
terminfo: add ich1=\E[@ 2021-08-06 22:33:56 +02:00
Daniel Eklöf
1c43fdbea4
box-drawing: add U+1FB3C-U+1FB6F, U+1FB9A and U+1FB9B
These are the “wedges” from the Unicode 13 “Legacy Computing” symbols.

Closes #474
2021-08-05 18:25:01 +02:00
Daniel Eklöf
f1d440e139
term: send SIGTERM/SIGKILL to the entire process group 2021-07-31 22:50:19 +02:00
Daniel Eklöf
98e8778e41
changelog: asynchronous client application termination 2021-07-31 20:13:52 +02:00
Daniel Eklöf
02f0e0d912
config: include: add support for ~-expansion
Closes #659
2021-07-30 14:57:28 +02:00
David Rosca
2c5a23867f
Only brighten palette colors with bold-text-in-bright=palette-based 2021-07-26 19:13:46 +02:00
Daniel Eklöf
be24bd2d32
changelog: initialize output scaling factor to 1 2021-07-26 19:00:56 +02:00
Daniel Eklöf
bcd28311f4
wayland: prevent hang when terminating due to broken Wayland connection
If the call to fdm_wayl() with EPOLLHUP was followed by calls to
wayl_roundtrip(), foot would hang.

The reason for this is that the EPOLLHUP handler in fdm_wayl() would
call wl_display_cancel_read().

wayl_roundtrip() also calls wl_display_cancel_read() (since we
normally have called wl_display_prepare_read()), before calling
wl_display_roundtrip().

When calling wl_display_cancel_read() two times in a row, without a
wl_display_prepare_read() in between, wl_display_roundtrip() hangs.

Fix by not calling wl_display_cancel_read() in fdm_wayl(). This
ensures our invariant holds: wl_display_prepare_read() is *always* in
effect outside of fdm_wayl().

Closes #651
2021-07-24 20:38:56 +02:00
Daniel Eklöf
7c686208a1
meson: add -Ddocs=disabled|enabled|auto command line option
When enabled (the default, if scdoc is found), we build and install
the man pages, example foot.ini, readme, changelog and license files.
2021-07-24 13:12:10 +02:00
Daniel Eklöf
9985b8c713
changelog: window title in CSDs 2021-07-24 11:02:43 +02:00
Daniel Eklöf
251545203b
search: reset match state when selection is cancelled
While we’re in scrollback search mode, the selection may be
cancelled (for example, if the application is scrolling out the
selected text). Trying to e.g. extend the search selection after this
has happened triggered a crash.

This fixes it by simply resetting the search match state when the
selection is cancelled.

Closes #644
2021-07-22 17:57:43 +02:00
Daniel Eklöf
2acd4b34c5
pgo: fix PGO builds with clang
Add stubs for shm_chain_new(), shm_chain_free() and shm_unref(). This
fixes ‘pgo’ linking failures in the ‘generate’ phase when doing a PGO
build with clang.

Closes #642
2021-07-22 10:02:52 +02:00
Timur Celik
a410734f96 render: prevent cells from overflowing into margin 2021-07-20 11:44:27 +02:00
Daniel Eklöf
4a50abece3
changelog: add new ‘unreleased’ section 2021-07-18 18:07:26 +02:00