Commit graph

1286 commits

Author SHA1 Message Date
Daniel Eklöf
ee7ff9501e
README: add 'git submodule update --init' step to how-to-install 2020-01-05 12:58:02 +01:00
Daniel Eklöf
f4e8a9c375
render: xcursor: remove render_xcursor_refresh() 2020-01-05 00:10:44 +01:00
Daniel Eklöf
00479fe204
doc: slight change of wording for mouse-drag-to-select 2020-01-04 23:56:17 +01:00
Daniel Eklöf
fdcab07663
README: abuse of definition list to get multiple paragraphs 2020-01-04 23:52:08 +01:00
Daniel Eklöf
41305db9fb
README: let's see if codeberg understands these paragraphs belong together 2020-01-04 23:49:02 +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
ae82939158
wayland: wayl_flush: re-initialize fd array before each poll 2020-01-04 23:36:32 +01:00
Daniel Eklöf
11d381f0c3
wayland: add comment 2020-01-04 23:33:50 +01:00
Daniel Eklöf
d243a836ce
wayland: only call wl_display_prepare_read() if we read any events
That is, only call it if we have POLLIN. If not, then we never read
any events and we still hold the read lock and thus we shouldn't try
to acquire it again.
2020-01-04 23:32:00 +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
040a1cd00d
input: scroll: call term_mouse_up() once, after all term_mouse_down()
Note that scroll button release events are not actually sent to the
client, but this makes the code more correct, logically.
2020-01-04 21:35:38 +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
f29d506f3b
Merge branch 'render-refresh-optimize' 2020-01-04 19:57:16 +01:00
Daniel Eklöf
1060a4250b
term: more comments in the 'render' sub-struct 2020-01-04 19:56:59 +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
a3c18e72f5
fdm: add support for hooks
Hooks are functions executed just before going into a poll(). Or just
after executing all FD handlers, if you like.
2020-01-04 19:48:15 +01:00
Daniel Eklöf
14d897ac75
doc: document how to do block selections 2020-01-04 14:58:43 +01:00
Daniel Eklöf
1bc6917921
doc: add descriptions for ctrl+w and ctrl+shift+w in scrollback search 2020-01-04 14:58:29 +01:00
Daniel Eklöf
d32dfed235
doc: add headers to keyboard shortcuts for normal+scrollback search 2020-01-04 14:57:59 +01:00
Daniel Eklöf
6f338984ad
README: mention that ctrl+mouse creates a block selection 2020-01-04 14:47:20 +01:00
Daniel Eklöf
12d05b79d1
PKGBUILD: remove old *.gcda files 2020-01-04 14:40:06 +01:00
Daniel Eklöf
0b99ed7a55
Merge branch 'block-selection' 2020-01-04 14:36:11 +01:00
Daniel Eklöf
a83c9e2813
selection: min_bufsize_for_extraction: add one extra column for *all* rows 2020-01-04 14:06:39 +01:00
Daniel Eklöf
4c78b0203e
selection: rename selection_cell_count -> min_bufsize_for_extraction 2020-01-04 13:56:52 +01:00
Daniel Eklöf
e6f0483294
selection: cell count now adds one extra column per row, for \n
When we extract text, we may insert '\n' at the end of each line (or
last column of selection, for block selections).

These newlines doesn't occupy any physical cells, and thus we
must **make** room for them in the extraction buffer.
2020-01-04 13:53:30 +01:00
Daniel Eklöf
6ee86be1bf
selection: fix bug where first column on all rows but the first was lost
When extracting text from the selection, we lost the first column on
all rows but the first.

This is because the algorithm changed slightly when we moved to
foreach_selection(); the end-of-line detection is now done on the
first column of the new line, instead of the last column on the
previous line.
2020-01-04 13:19:30 +01:00
Daniel Eklöf
e28cb989d8
selection: simplify extraction by converting to UTF-8 at the end
Instead of converting a cell at a time to UTF-8, copy the wide
characters as is, and then convert everything at once at the end.
2020-01-04 13:09:06 +01:00
Daniel Eklöf
975a35ae16
selection: extract_selection now uses foreach_selected()
This "automagically" adds support for block selections, since
foreach_selected already handles block selections.
2020-01-04 13:01:00 +01:00
Daniel Eklöf
b7c970010d
term: mouse_grabbed: ctrl may be pressed too (for block selection) 2020-01-04 12:09:26 +01:00
Daniel Eklöf
2a531327dd
selection: selection_cancel() now sets 'kind' to SELECTION_NONE 2020-01-04 12:09:09 +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
d706e68280
selection: track selection type; normal or block selection 2020-01-03 23:29:45 +01:00
Daniel Eklöf
1178a7763b
wayland: window: optimize: set opaque region
When background alpha is 1.0 (0xffff), i.e. completely opaque, tell
the compositor this, via wl_surface_set_opaque_region().

This allows it to optimize drawing of surfaces _behind_ our window.
2020-01-03 21:53:38 +01:00
Daniel Eklöf
ce4e99ebe2
term: background alpha is not a floating point number 2020-01-03 21:53:16 +01:00
Daniel Eklöf
0ea0323d0f
wayland: don't use wl_display_dispatch()
wl_display_dispatch() calls poll(), which is unnecessary since we
already know the FD is readable.

Use the more lower level wl_display_read_events() +
wl_display_dispatch_pending().

These require wl_display_prepare_read() to have been called.

The idea is to call wl_display_prepare_read() **before** calling
poll().

Thus, we do this more or less last in wayl_init(), and at the **end**
of the FDM handler.

However, having taking this lock also means we no longer can call
wl_display_roundtrip() directly (it will hang).

So, add a wrapper, wayl_roundtrip(), that cancels the read intent,
does the roundtrip, and then re-acquires the read intent.
2020-01-03 21:02:12 +01:00
Daniel Eklöf
c6e46bbfac
selection: remove unneeded wayland display roundtrips 2020-01-03 21:01:07 +01:00
Daniel Eklöf
ef3c7d7e0a
term: init: don't resize if compositor has already resized us 2020-01-03 19:31:09 +01:00
Daniel Eklöf
782da0f8e9
term: no need to call render_refresh() when starting/stopping blink timer 2020-01-03 19:27:57 +01:00
Daniel Eklöf
a291999f2c
wayland: flush after commit new pointer surface 2020-01-03 19:04:42 +01:00
Daniel Eklöf
c118ed9252
wayland: configure: resize before changing visual focus
This hopefully fixes and issue where the visual focus in/out caused a
render refresh with the *old* size.

This caused the occasional flicker at startup, or when resizing the
window.

By placing the resize call before the visual focus in/out, we ensure
the refresh uses the new size.

This is a temporary workaround. The correct solution is to ensure we
only call refresh() once.
2020-01-03 18:58:26 +01:00
Daniel Eklöf
f7362d381b
render: refresh: ensure window has been configured 2020-01-03 18:55:13 +01:00
Daniel Eklöf
f2a745cfdb
Merge branch 'cleanup-wayland-window-callbacks' 2020-01-03 13:56:24 +01:00
Daniel Eklöf
d07fd7de39
render: remove 'refresh' from render_resize() 2020-01-03 13:56:10 +01:00
Daniel Eklöf
46c434d3f1
wayland: window: apply all configure changes after acking the event 2020-01-03 13:54:44 +01:00
Daniel Eklöf
765fe13aff
wayland: remove wayl_terminal_from_xdg_{surface,toplevel} 2020-01-03 13:46:37 +01:00