Commit graph

304 commits

Author SHA1 Message Date
Daniel Eklöf
8c72e9434e
term: cache kbd-focused state, just like we cache visual focus state
There's one difference however, when we receive a kbd unfocus call,
*all* seats must have us unfocused before we actually change the
state.
2020-07-11 09:04:46 +02:00
Daniel Eklöf
4e48d550ef
multi-seat: improve handling of multiple (mouse) pointers
* xcursor always set for all pointers
* xcursor sometimes not updated when it should be
* mouse grabbed state wasn't per seat, but global (i.e. "does at least
  one seat enable mouse grabbing")
* selection enabled state wasn't per seat
2020-07-09 09:52:11 +02:00
Daniel Eklöf
6bbd4a5110
focus in/out: terminal checks whether it is a state change or not 2020-07-09 09:16:54 +02:00
Daniel Eklöf
fc9fde88c3
input: only call term_kbd_focus_{in,out}() on actual state change
That is, only call term_kbd_focus_in() if we're the *first* seat
focusing that terminal, and only call term_kbd_focus_out() if we're
the *last* seat that focused it.
2020-07-09 08:46:25 +02:00
Daniel Eklöf
58415428cf
multi-seat: re-enable mouse button+motion reporting support 2020-07-08 18:16:43 +02:00
Daniel Eklöf
be2490022d
multi-seat: enable xcursor theme support again 2020-07-08 18:08:39 +02:00
Daniel Eklöf
c470825067
wip: multi-seat support
Compiles and runs, but mouse, clipboard and other things have been
disabled.
2020-07-08 16:45:26 +02:00
Daniel Eklöf
69e4213e4a
term: don't use deprecated fcft_size_adjust()
When resizing the font on-the-fly, we now do a complete
font-reload (this is basically what fcft_size_adjust() did anyway).

To get the correct size, we maintain the current size ourselves.

We get the initial size from the user-provided font pattern, by
converting the string to an FcPattern, and using FcPatternGet() to
retrieve both the FC_SIZE and FC_PIXEL_SIZE attributes. These
attributes are then removed from the pattern, and the pattern is
converted back to a string.

The terminal struct maintains a copy of the font sizes. These are
initially set to the sizes from the config.

When the user resizes the font, the terminal-local sizes are
adjusted. To ensure the primary and user-configured fallback fonts are
resizes equally much, convert any pixel sizes to point sizes at this
point.

When the font size is reset, we reload the font sizes from the
config (thus once again returning actual pixel-sizes, if that's what
the user has configured).
2020-07-07 10:44:55 +02:00
Daniel Eklöf
a259eda535
config: add 'blink' option to cursor section in footrc
This option controls whether the default cursor should blink or
not. The default is to *not* blink.
2020-06-30 17:45:34 +02:00
Daniel Eklöf
fad5838dba
Merge branch 'master' into sixel-performance 2020-06-29 22:03:26 +02:00
Daniel Eklöf
62be729c45
scroll: destroy scrolled out sixels before scroll is applied
The logic that breaks out of sixel loops does not work for rows that
has already wrapped around.

Thus, we need to destroy sixels that are about to be scrolled
out *before* we actually scroll.

Since this is the *only* time we destroy sixels (instead of
overwriting it), rename the sixel functions. And, since they now do a
very specific thing, they can be greatly simplified (and thus faster).
2020-06-29 22:01:02 +02:00
Daniel Eklöf
8f5e6e85e0
sixel: destroy all sixels when font size is decreased
If changing the font size causes the cell size to decrease, either
horizontally or vertically (or both), then delete all sixels since the
grid space they allocated no longer is enough to hold the images.
2020-06-29 21:53:29 +02:00
Daniel Eklöf
2ea32398c3
term: use 'left_ptr' instead of 'hand2' as cursor when client is mouse grabbing 2020-06-29 21:51:53 +02:00
Daniel Eklöf
4006fc86e4
sixel: overwrite: pass 'width' to sixel_overwrite_at_cursor()
This is necessary to handle multi-column characters correctly.
2020-06-28 11:01:19 +02:00
Daniel Eklöf
186a07c364
sixel: split -> overwrite 2020-06-27 15:29:47 +02:00
Daniel Eklöf
ae727e372a
term: erasing characters now splits sixels instead of deleting them 2020-06-27 15:22:31 +02:00
Daniel Eklöf
0953ffd2d3
sixel: delete/split: early(ier) exit when there aren't in sixel images
Avoid unnecessary wrap checks if the sixel image list is empty.
2020-06-27 14:43:29 +02:00
Daniel Eklöf
bc82d4ee28
sixel: wip: split up image being overwritten, rather than erasing it
Instead of completely erasing a sixel image when it is being
"overwritten" (text is printed somewhere within the image, or another
sixel image is emitted within the first image), split it up into up to
four pieces: 'above', 'below', 'to-the-left' and 'to-the-right'.

This is currently very un-optimized, but seems to produce correct
results.
2020-06-23 21:07:12 +02:00
Daniel Eklöf
bae11000cc
term: reset: set title to the user configured title, not "foot" 2020-06-22 14:33:16 +02:00
Daniel Eklöf
e466063020
term: ptmx: don't abort on EAGAIN when trying to read from ptxm 2020-06-19 11:33:03 +02:00
Daniel Eklöf
cc5dedc259
sixel: do not reset palette after each image
A client can re-use the palette between images. Resetting the palette
breaks this.

Now we initialize the palette on demand, and resets it when the
palette size is changed (by the client).
2020-06-10 18:38:46 +02:00
Daniel Eklöf
9df7e8fa07
term: print_insert: early return 2020-06-09 17:31:28 +02:00
Daniel Eklöf
29630ac92e
term: set an initial TIOCSWINSZ right after opening the pty
Since foot is pretty aggressive about spawning the client early, it
was possible for a fast client to read a 0x0 terminal size. Not all
clients coped well.

Closes #20.
2020-06-02 19:59:28 +02:00
Daniel Eklöf
789617d5ad
term: don't double fork new terminal windows
Instead, register their PIDs with the new reaper module and let it
handle them.
2020-05-21 20:17:29 +02:00
Daniel Eklöf
08588cd0fc
selection: handle viewport wrap around correctly
When the viewport wraps around, the selection points may be
"incorrect".
2020-05-19 18:49:42 +02:00
Daniel Eklöf
550667a9ea
term: scrolling: calling function must clamp scroll amount 2020-05-19 18:47:38 +02:00
Daniel Eklöf
33346ba02d
term: erase_cell_range: set row->dirty before calling memset() 2020-05-17 16:29:09 +02:00
Daniel Eklöf
52e6a751b3
term: scrolling: mark selection top if-statement as 'unlikely' 2020-05-17 15:48:58 +02:00
Daniel Eklöf
96a4f1b993
term: scrolling: hopefully fix all selection/scrolling related crashes
When scrolling, there are a couple of cases where an existing
selection must be canceled because we cannot meaningfully represent it
after scrolling.

These are when the selection is (partly) inside:

* The top scrolling region
* The bottom scrolling region
* The new lines scrolled in. I.e. re-used lines

For the scrolling regions, the real problem is when the selection
crosses the scrolling region boundary; a selection that is completely
inside a scrolling regions _might_ be possible to keep, but we would
need to translate the selection coordinates to the new scrolling
region lines.

For simplicity, we cancel the selection if it touches the scrolling
region. Period.

The last item, newly scrolled in lines is when the selection covers
very old lines and we're now wrapping around the scrollback history.

Then there's a fourth problem case: when the user has started a
selection, but hasn't yet moved the cursor. In this case, we have no
end point.

What's more problematic is that when the user (after scrolling) moves
the cursor, we try to create a huge selection that covers mostly
empty (NULL) rows, causing us to crash.

This can happen e.g. when reverse scrolling in such a way that we wrap
around the scrollback history.

The actual viewport in this case is something like `-n - m`. But the
selection we'll end up trying to create will be `m - (rows - n)`. This
range may very well contain NULL rows.

To deal with this, we simply cancel the selection.
2020-05-17 15:34:49 +02:00
Daniel Eklöf
8f9e6127da
term: scrolling: sixel: simplify now that row count is clamped 2020-05-17 11:46:44 +02:00
Daniel Eklöf
cfd0b5d2d8
term: scrolling: in debug builds, verify all rows are allocated 2020-05-16 23:53:23 +02:00
Daniel Eklöf
ebd867372a
term: scrolling: simplify, now that scroll row count is clamped 2020-05-16 23:53:03 +02:00
Daniel Eklöf
a4f5938123
term: scrolling: clamp number of rows to number of rows in scrolling region 2020-05-16 23:44:54 +02:00
Daniel Eklöf
57e04a1320
grid: swap_row: remove unused parameter 'initialize' 2020-05-16 23:43:05 +02:00
Daniel Eklöf
a1c95562fb
term: scrolling: clear selection *before* scrolling
We normally don't clear the selection when scrolling. The exception is
when the selection covers re-used rows. I.e. rows that we scroll in
and clear.

In this case we cancel the selection (we _could_ modify it and keep as
much as possible and only remove the re-used rows...). We must do
this *before* scrolling, since scrolling will swap rows (when there's
a scrolling region). When this happens, the selection is "corrupted",
and canceling it afterwards will not work.
2020-05-16 21:27:56 +02:00
Daniel Eklöf
38c050746d
selection: on_row_in_view() -> on_rows_in_view(), and now takes a range
This allows us to check the selection once when scrolling, instead of
once for each scrolled in line.
2020-05-16 21:16:11 +02:00
Daniel Eklöf
c090a0664f
Revert "term: print: line-wrap multi-column characters instead of cutting them in half"
This reverts commit 8448296bb3.

Applications need to be multi-column character aware anyway, and they
should deal with this.
2020-05-09 12:04:55 +02:00
Daniel Eklöf
8448296bb3
term: print: line-wrap multi-column characters instead of cutting them in half 2020-05-09 11:57:19 +02:00
Daniel Eklöf
56d53ec2a1
term: don't register ptmx with FDM if we're shutting down
This can happen when there's an error instantiating the
terminal *after* we've spawned the slave process.
2020-05-04 20:49:28 +02:00
Daniel Eklöf
9864d91975
term: set 'is_shutting_down' before calling term_destroy() on error 2020-05-04 20:46:27 +02:00
Daniel Eklöf
921331854a
term: check return value when instantiating thread synchronization primitives 2020-05-04 20:11:45 +02:00
Daniel Eklöf
6bac1bd257
term: thrd_success isn't necessarily 0 2020-05-03 14:17:54 +02:00
Daniel Eklöf
7525fa20c2
thrd_create(): handle errors correctly
* Detect thrd_create() failures in all places where we instantiate
  threads
* Log error correctl; thrd_create() does not return an errno value
2020-05-03 12:25:04 +02:00
Daniel Eklöf
62e0774319
unicode-combining: store seen combining chains "globally" in the term struct
Instead of storing combining data per cell, realize that most
combinations are re-occurring and that there's lots of available space
left in the unicode range, and store seen base+combining combinations
chains in a per-terminal array.

When we encounter a combining character, we first try to pre-compose,
like before. If that fails, we then search for the current
base+combining combo in the list of previously seen combinations. If
not found there either, we allocate a new combo and add it to the
list. Regardless, the result is an index into this array. We store
this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell.

When rendering, we need to check if the cell character is a plain
character, or if it's a composed character (identified by checking if
the cell character is >= COMB_CHARS_LO).

Then we render the grapheme pretty much like before.
2020-05-03 11:03:22 +02:00
Daniel Eklöf
d945b68b73
unicode-combine: remove utf8proc dependency
We only used utf8proc to try to pre-compose a glyph from a base and
combining character.

We can do this ourselves by using a pre-compiled table of valid
pre-compositions. This table isn't _that_ big, and binary searching it
is fast.

That is, for a very small amount of code, and not too much extra RO
data, we can get rid of the utf8proc dependency.
2020-05-02 17:29:00 +02:00
Daniel Eklöf
3474624c2c
unicode-combining: completely remove unicode combining characters when feature is disabled 2020-05-01 12:05:38 +02:00
Daniel Eklöf
76567e9ef0
render: render combining characters
This is basically just a loop that renders additional glyphs on top
off the base glyph.

Since we now need access to the row struct, for the combining
characters, the function prototype for 'render_cell()' has changed.

When rendering the combining characters we also need to deal with
broken fonts; some fonts use positive offsets (as if the combining
character was a regular character), while others use a negative
offset (to be used as if you had already advanced the pen position).

We handle both - a positive offset is rendered just like a regular
glyph. When we see a negative offset we simply add the width of a cell
first.
2020-05-01 11:56:13 +02:00
Daniel Eklöf
67614df9f9
term: print: reset combining characters for this cell
This is the *only* place combining characters are reset. In
particular, we do *not* reset them in a normal cell erase.

This is a performance design decision - clearing the combining
characters in erase is way too slow.

This way, we clear it only when we *have* to. Anything looking at the
combining characters must first ensure the base character is not 0.
2020-05-01 11:50:38 +02:00
Daniel Eklöf
69c3e74498
util.h: new header file defining commonly used macros 2020-05-01 11:46:24 +02:00
Daniel Eklöf
fc2e385d87
term: don't enable ptmx FDM callback until Wayland window has been configured
The way things works right now, we cannot enable the ptmx FDM callback
right away. We need to wait for the Wayland window to have been
configured.

Before the window is configured, we don't have a size, and no
grid. Thus, if we try to process ptmx data we'll crash since we have
no where to write it to.

So, registering the ptmx fd with the FDM is now delayed until we've
received the first 'configure' event from Wayland.
2020-04-30 17:22:57 +02:00