Commit graph

170 commits

Author SHA1 Message Date
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
Daniel Eklöf
3c71389993
render: don't allow negative coordinates of the search surface
While the protocol allows this, it appears Sway offsets (moves) the
parent surface when this happens, resulting in a window half without
content.
2019-12-03 19:58:33 +01:00
Daniel Eklöf
30335ef32a
fcft: include <fcft/fcft.h>, and use fcft/stride.h instead of local copy 2019-12-01 14:03:24 +01:00
Daniel Eklöf
fd9c28464d
fcft: use fcft instead of local copy of font.c/font.h 2019-12-01 13:43:51 +01:00
Daniel Eklöf
90bfcc1fbd
render: fix underline/strikeout positioning
There were two errors:

* We subtracted half the line width instead of adding it to the
  baseline

* We rounded the line positioning and thickness before the positioning
  calculation. In particular, rounding the thickness before using it
  to adjust the position was wrong. Now we round just before the
  pixman call.
2019-11-30 14:53:22 +01:00
Daniel Eklöf
7be98291e1
render: font_baseline(): simply use the primary font's ascent
This is what we used as baseline for regular glyphs anyway. Thus, we
can update that code to call font_baseline() now. This makes it easier
to change how we define the baseline in the future.
2019-11-30 14:51:44 +01:00
Daniel Eklöf
b96fb2ddab
render: fix rendering of cursor when cell is reversed
When the user had configured the cursor color, we failed to
invert (reverse) the foreground and background color when the cursor
was on a cell with the 'reverse' attribute set.
2019-11-28 19:22:21 +01:00
Daniel Eklöf
bc86cd61c7
font: move metrics from terminal struct to font struct 2019-11-26 19:02:35 +01:00
Daniel Eklöf
d637b8c9ba
term: add struct cursor 2019-11-17 09:44:31 +01:00
Daniel Eklöf
37139fc4fa
render: configure default tab stops when resizing the terminal 2019-11-16 10:54:56 +01:00
Daniel Eklöf
bf9aff056a
Revert "render: last_buf may point to a free:d buffer"
This reverts commit 4d3251a93b.
2019-11-02 01:28:29 +01:00
Daniel Eklöf
4d3251a93b
render: last_buf may point to a free:d buffer
So, store last buf's width/height separately
2019-11-02 00:48:07 +01:00
Daniel Eklöf
00b46455a0
shm: associate a 'cookie' with each buffer
When re-using a buffer from cache, only re-use ones with a matching
cookie.

This prevents contention between multiple terminal windows.
2019-11-02 00:33:37 +01:00
Daniel Eklöf
8df82938b0
shm: get_buffer(): remove 'copies' argument; it's not used 2019-11-02 00:23:51 +01:00
Daniel Eklöf
dac1ba18c8
render: limit length of title in call to xdg_toplevel_set_title()
Trying to pass a too long title (not sure what "too long" is
though...) will trigger a call to abort() inside the wayland-client
library.
2019-11-01 20:25:44 +01:00
Daniel Eklöf
291a928a49
render: call wl_display_flush() after rendering
This allows us to remove that call from the main event loop.
2019-11-01 20:01:36 +01:00
Daniel Eklöf
ad0f8a02d5
Merge branch 'fdm' 2019-10-30 17:31:44 +01:00
Daniel Eklöf
a42df2434b
scrollback: regression: fix rendering of scrollback diffs less than a screen
When doing "small" scrolls (typically done via mouse wheel or
similar), we render the scrolling by emitting a "scroll damage".

A recent commit changed how scroll damage is rendered; only when the
view is at the bottom ("following" the screen output) do we render the
damage.

To fix this, add a new type of scroll damage,
SCROLL_DAMAGE_IN_VIEW and SCROLL_DAMAGE_REVERSE_IN_VIEW.

These signal to the renderer that it should always render the damage.
2019-10-29 21:09:37 +01:00
Daniel Eklöf
8e6f87eb17
render worker context: allocate, and let worker threads free
Since we now initialize the worker threads from term_init(), which
returns before the threads terminate, we can no longer use
stack-allocated worker contexts.

We _could_ put them in the terminal struct. But a simpler solution is
to allocate them in term_init(), and let the threads free them when
they don't need them anymore.
2019-10-28 18:51:04 +01:00