Commit graph

188 commits

Author SHA1 Message Date
Daniel Eklöf
2c8b31204f
render: fallback to background color if cursor text color is not set 2020-01-20 18:36:44 +01:00
Daniel Eklöf
767a0ec232
fcft: update to 1.0.0
Allow/disallow subpixel antialiasing in font_glyph_for_wc(), not using
font_enable_subpixel_antialias().
2020-01-19 12:44:21 +01:00
Daniel Eklöf
727be358df
render: resize: TIOCSWINSZ: don't include padding in ws_{x,y}pixel 2020-01-12 14:42:49 +01:00
Daniel Eklöf
1623fc0c0a
term: shorten application_synchronized_updates -> app_sync_updates 2020-01-12 12:55:19 +01:00
Daniel Eklöf
bdf127fc7e
term/render: move {enable,disable}_application_synchronized_updates()
From render -> terminal
2020-01-12 12:43:28 +01:00
Daniel Eklöf
afa1dbb7cc
render: add a timeout for application synchronized updates
This ensures we can recover from a crashing (or bad behaving)
application that sends a BSU but then never sends an ESU.
2020-01-12 12:40:42 +01:00
Daniel Eklöf
6e474e77e5
render: rename render_{enable,disable}_refresh() 2020-01-12 12:28:00 +01:00
Daniel Eklöf
cb8a0260f3
term: rename refresh_prohibited -> application_synchronized_updates 2020-01-12 12:25:58 +01:00
Daniel Eklöf
b2935e2b89
render: add render_{enable,disable}_refresh()
Calling render_disable_refresh() causes update requests to that
terminal to be ignored.

Calling render_enable_refresh() re-enables updates.
2020-01-12 12:19:38 +01:00
Daniel Eklöf
0b30316261
render: don't bother trying to lookup glyph for empty cells
Depending on the font, it may not have an entry for code point '0',
which will cause us to try to load fallback fonts.
2020-01-12 01:19:41 +01:00
Daniel Eklöf
457eb573c4
selection: update: don't dirty cells that don't change state
Previously when updating a selection, we would unmark *all* cells in
the old selection, and then mark all cells in the new selection.

This caused *all* cells to be dirtied and thus re-rendered.

Avoid this, by adding a temporary state to the cells' selected state.

Before unmarking the old selection, pre-mark the new selection using a
temporary state.

When unmarking the old selection, ignore cells in this temporary state.
When marking the new selection, ignore cells in this temporary
state (except clearing the temporary state).
2020-01-06 11:56:18 +01:00
Daniel Eklöf
7e178d6337
search: rename render.search_offset -> render.search_glyph_offset 2020-01-05 15:25:24 +01:00
Daniel Eklöf
5a89520274
render: ensure cursor is always visible in the search box
Maintain a view 'offset' (which glyph from the search string to start
rendering at).

This defines the start of the viewable area. The end is the offset +
the search box size (which is limited to the window size).

Adjust this offset whenever the cursor moves outside the viewable
area. For now, this is always done in the same way: set the offset to
the cursor position.

This means that when we're entering text at the end of the search
criteria (i.e. the normal case; we're simply typing), and the search
box reaches the window size, the cursor will jump to the start of the
search box, which will be empty. This could be confusing, but let's go
with for now.
2020-01-05 15:16:40 +01:00
Daniel Eklöf
f4e8a9c375
render: xcursor: remove render_xcursor_refresh() 2020-01-05 00:10:44 +01:00
Daniel Eklöf
30ce5ad386
renderer: destroy: actually free the renderer instance (doh!) 2020-01-04 23:41:26 +01:00
Daniel Eklöf
4cbd894803
wayland: use a low priority FDM hook to flush the wayland socket
This way, we don't have to manually insert flushes in code paths that
may execute outside of a wl_display_dispatch_pending().

(Those that execute inside a wl_display_dispatch_pending() are subject
to the flush performed at the end of the normal wayland FDM handler).
2020-01-04 23:27:59 +01:00
Daniel Eklöf
6534f64e6a
fdm: add hook priorities
There are now three hook priorities: low, normal, high.

High priority hooks are executed *first*. Normal next, and last the
low priority hooks.

The renderer's terminal refresh hook now runs as a normal priority
hook.
2020-01-04 23:26:27 +01:00
Daniel Eklöf
5ec447697c
render: throttle xcursor updates
With a bad behaving client (e.g. 'less' with mouse support enabled),
we can end up with a *lot* of xcursor updates (so much, that we
flooded the wayland socket before we implemented a blocking
wayl_flush()).

Since there's little point in updating the cursor more than once per
frame interval, use frame callbacks to throttle the updates.

This works more or lesslike normal terminal refreshes:

render_xcursor_set() stores the last terminal (window) that had (and
updated) the cursor.

The renderer's FDM hook checks if we have such a pending terminal set,
and if so, tries to refresh the cursor.

This is done by first checking if we're already waiting for a callback
from a previous cursor update, and if so we do nothing; the callback
will update the cursor for the next frame. If we're *not* already
waiting for a callback, we update the cursor immediately.
2020-01-04 22:58:32 +01:00
Daniel Eklöf
abc36d8f09
wayland: wl_display_flush() never blocks
Since it doesn't block, we need to detect EAGAIN failures and ensure
we actually flush everything.

If we don't, we sooner or later end up in a wayland client library
call that aborts due to the socket buffer being full.

Ideally, we'd simply enable POLLOUT in the FDM. However, we cannot
write *anything* to the wayland socket until we've actually managed to
send everything. This means enabling POLLOUT in the FDM wont work
since we may (*will*) end up trying to write more data to it before
we've flushed it.

So, add a wrapper function, wayl_flush(), that acts as a blocking
variant of wl_display_flush(), by detecting EAGAIN failiures and
calling poll() itself, on the wayland socket only, until all data has
been sent.
2020-01-04 21:10:08 +01:00
Daniel Eklöf
2128d5912f
render: remove debug logging 2020-01-04 21:09:50 +01:00
Daniel Eklöf
647a299315
render: attrs_to_font() is not used outside of render.c 2020-01-04 19:53:55 +01:00
Daniel Eklöf
99f471d738
render: trigger terminal refreshes in an FDM hook
In some cases, we end up calling render_refresh() multiple times in
the same FDM iteration. This means will render the first update
immediately, and then set the 'pending' flag, causing the updated
content to be rendered in the next frame.

This can cause flicker, or flashes, since we're presenting one or more
intermediate frames until the final content is shown.

Not to mention that it is inefficient to render multiple frames like
this.

Fix by:

* render_refresh() only sets a flag in the terminal

* install an FDM hook; this hook loops all terminals and executes what
  render_refresh() _used_ to do (that is, render immediately if we're
  not waiting for a frame callback, otherwise set 'pending' flag). for
  all terminals that have the 'refresh_needed' flag set.
2020-01-04 19:49:26 +01:00
Daniel Eklöf
f12b1473fd
selection: store cell 'selected' state in the cells' attributes
Instead of having the renderer calculate, for each cell, whether that
cell is currently selected or not, make selection_update() mark/unmark
the selected cells.

The renderer now only has to look at the cells' 'selected'
attribute. This makes the renderer both smaller and faster.
2020-01-04 12:03:04 +01:00
Daniel Eklöf
cb9ae4f6a1
render: coord_is_selected: handle block selections 2020-01-03 23:34:58 +01:00
Daniel Eklöf
f7362d381b
render: refresh: ensure window has been configured 2020-01-03 18:55:13 +01:00
Daniel Eklöf
d07fd7de39
render: remove 'refresh' from render_resize() 2020-01-03 13:56:10 +01:00
Daniel Eklöf
74aa604904
render: render_resize(): don't do anything if width or height is 0 2020-01-03 12:54:03 +01:00
Daniel Eklöf
af26f043fb
render: resize() now only calls refresh() if asked to 2020-01-03 12:44:29 +01:00
Daniel Eklöf
709dbfe18b
Merge branch 'master' into visual-focus 2020-01-03 12:08:51 +01:00
Daniel Eklöf
792b443918
render: use a unique buffer cookie for the 'search' surface
This fixes an issue where rendering the 'search' box caused the last
normal buffer from being purged.

This meant the terminal had a pointer to a now freed buffer, which we
de-referenced and occasionally memcpy:ied from.
2020-01-03 12:05:48 +01:00
Daniel Eklöf
29483f936f
render: draw_cursor: use terminal's visual focus to determine cursor shape 2020-01-02 19:37:21 +01:00
Daniel Eklöf
4ecb0ecf4d
wayland: rename focused/moused to kbd_focus/mouse_focus 2020-01-02 15:58:52 +01:00
Daniel Eklöf
19c0c3d2a4
render: presentation: cleanup 2020-01-01 11:37:47 +01:00
Daniel Eklöf
bd8c81547f
render: call wl_display_flush() right after wl_surface_commit()
This groups the two calls, for readability.
2020-01-01 11:19:39 +01:00
Daniel Eklöf
9ba702ce00
render: presentation: clean up frame interval count calculation 2020-01-01 11:19:13 +01:00
Daniel Eklöf
d3fc0fc21e
render: presentation: space between value and "µs" 2019-12-31 20:31:06 +01:00
Daniel Eklöf
a45786ef1b
render: presentation: also use seconds when calculating frame interval count 2019-12-31 20:04:44 +01:00
Daniel Eklöf
dd3e9346cf
render: presentation: log both input -> commit and commit -> presented times 2019-12-31 20:01:47 +01:00
Daniel Eklöf
2cd7e51002
render: reset input/commit timestamps on presentation discarded event 2019-12-31 16:03:42 +01:00
Daniel Eklöf
5a07419096
wayland: optionally use the presentation time protocol to measure input lag
This adds a flag, -p,--presentation-timings, that enables input lag
measuring using the presentation time Wayland protocol.

When enabled, we store a timestamp when we *send* a key to the
slave. Then, when we commit a frame for rendering to the compositor,
we request presentation feedback. We also store a timestamp for when
the frame was committed.

The 'presented' callback then looks at the input and commit
timestamps, and compares it with the presented timestamp.

The delay is logged at INFO when the delay was less than one frame
interval, at WARN when it was one frame interval, and at ERR when it
was two or more frame intervals.

We also update statistic counters that we log when foot is shut down.
2019-12-31 15:39:40 +01:00
Daniel Eklöf
88a1ebafbd
render: fix bug when erasing old cursor; send correct compositor damage 2019-12-19 07:29:05 +01:00
Daniel Eklöf
52af40a3cd
render: render_cell: break out cursor rendering 2019-12-19 07:28:49 +01:00
Daniel Eklöf
aabb7a7e8f
render: attrs_to_font: const:ify 2019-12-19 07:28:33 +01:00
Daniel Eklöf
0efcb66f3a
term/render: check for is_shutting_down in grid_render() 2019-12-19 07:27:14 +01:00
Daniel Eklöf
c22ae98729
render: get rid of 'all-clean' detection
Instead of trying to figure out if we had to render
something (i.e. something in the grid was dirty), and using that to
determine whether to post a callback or not, we now let
render_refresh() set a flag indication we need to render another
frame.

This simplifies render_grid(), which now _always_ renders, and pushes
it to the compositor.

The callback handler checks the pending flag and simply doesn't call
render_grid() when there's no more pending state to render.

This ends up reducing the number of wakeups when e.g. having a
blinking cursor.
2019-12-17 19:14:56 +01:00
Daniel Eklöf
418ff5bcd9
render: move blink timer handling to term.c 2019-12-17 19:14:55 +01:00
Daniel Eklöf
7a3fb9284e
render: render block cursor as a hollow rectangle when unfocused 2019-12-16 21:34:38 +01:00
Daniel Eklöf
7d29435d86
term: implement cursor blinking
Blinking can be enabled either by setting the cursor style with

 CSI Ps SP q

and selecting a blinking style.

Or, with 'CSI ? 12 h'

Note that both affect the same internal state. I.e. you can disable
blinking with CSI ? 12l after having selected a blinking cursor
style. This is consistent with XTerm behavior.
2019-12-15 15:07:56 +01:00
Daniel Eklöf
0f15f0ba43
fcft: update to 0.3.0
fcft now calculates the underline and strikeout integer positions,
making our rendering code much simpler.
2019-12-03 21:03:52 +01:00
Daniel Eklöf
b0d555255c
render: limit size of search surface to parent window
This shouldn't be necessary, but Sway acts up when the subsurface
exceeds the parent surface (window, in this case) size, and extends
the window size (if floating), leaving it with no content
2019-12-03 20:19:50 +01:00