Commit graph

1316 commits

Author SHA1 Message Date
Daniel Eklöf
e658fe3da7
input: add a switch-based function that translates XKB keysym to escape data 2020-01-11 18:18:31 +01:00
Daniel Eklöf
8efedc9655
input: break out keymap lookup to a separate function 2020-01-11 17:55:45 +01:00
Daniel Eklöf
b5bb571adf
README: installation: s/debug/release/ 2020-01-11 15:02:19 +01:00
Daniel Eklöf
9f3d860e61
README: install::other: do a release build, and mention profile guided 2020-01-11 14:59:57 +01:00
Daniel Eklöf
d86b0ddc21
fcft/tllist: remove git submodules 2020-01-11 14:59:39 +01:00
Daniel Eklöf
8837309c2e
keymap: add KP enter
This makes the keypad enter key emit "\eOM" in keypad application
mode.
2020-01-11 12:37:07 +01:00
Daniel Eklöf
5956faac01
term/wayland: use MONOTONIC timers 2020-01-10 21:33:40 +01:00
Daniel Eklöf
bdc4bf2372
README: some terminal emulators call "server mode" "daemon mode" 2020-01-10 20:48:48 +01:00
Daniel Eklöf
30f6480644
keymap: add escapes for keypad 'begin'
This is usually the '5' key, in non-num lock mode.
2020-01-10 20:23:56 +01:00
Daniel Eklöf
5bfc560451
Revert "terminal: use edge-triggered FDM handler for the PTY"
This reverts commit f5e27b49eb.
2020-01-10 19:51:16 +01:00
Daniel Eklöf
3957d50a8a
Revert "selection: use edge-triggered FDM handlers"
This reverts commit 5bac3cfa2c.
2020-01-10 19:49:48 +01:00
Daniel Eklöf
ed8d7f4bae
Revert "server: use edge-triggered FDM handler for the client connections"
This reverts commit 9141b8a657.
2020-01-10 19:49:26 +01:00
Daniel Eklöf
9141b8a657
server: use edge-triggered FDM handler for the client connections 2020-01-10 19:30:03 +01:00
Daniel Eklöf
629a625422
server: be more resilient against bad behaving clients
Make both the server listening socket and the connecting client
sockets non-blocking.

Then, when reading the initial length of the setup packet, handle read
errors from partial reads separately.

Assume the client writes all four bytes of the 'length' field at once,
and bail out if we are unable to read those 4 bytes.

Limit the maximum setup packet size to 128K. This is to prevent
clients from pretending the setup packet is insanely large, causing us
to fail to malloc.
2020-01-10 19:27:17 +01:00
Daniel Eklöf
3762f1f205
terminal: make the event FD used to delay shutdown non-blocking 2020-01-10 19:25:56 +01:00
Daniel Eklöf
f5e27b49eb
terminal: use edge-triggered FDM handler for the PTY
This means that the read handler now has to keep reading until we get
EAGAIN.

But it also means we don't have to flip the EPOLLOUT flag in the FDM
handler back and forth when writing to the PTY.
2020-01-10 19:24:45 +01:00
Daniel Eklöf
5bac3cfa2c
selection: use edge-triggered FDM handlers 2020-01-10 19:24:04 +01:00
Daniel Eklöf
4e335422b8
wayland; fixup 2020-01-10 19:23:32 +01:00
Daniel Eklöf
7ce2cca49a
wayland: just to be sure, check return value of wl_display_read_events() 2020-01-10 19:23:08 +01:00
Daniel Eklöf
832e6f1370
wayland: make wayland socket non-blocking 2020-01-10 19:22:59 +01:00
Daniel Eklöf
a07de9ef3c
fdm: fix log message 2020-01-10 19:22:41 +01:00
Daniel Eklöf
698d5fdf06
fdm: verify FDs are non-blocking (debug builds only) 2020-01-10 19:22:10 +01:00
Daniel Eklöf
70f0f02016
fcft: bump 2020-01-09 21:09:25 +01:00
Daniel Eklöf
21a666e7eb
completions: zsh: add empty completions for options with required argument 2020-01-09 21:06:20 +01:00
Daniel Eklöf
40bb63e206
selection: finalize: ignore whether selections are 'enabled' or not
This fixes an issue where a "forced" selection (shift being pressed
while slave is tracking mouse events) would not finalize if the user
released shift *before* releasing the mouse button.
2020-01-06 11:59:26 +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
6833abf33c
selection: foreach_selection_*: must wrap row number
Fixes occasional crashes when we're at the end of the grid and
selection wraps around.
2020-01-05 15:38:45 +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
f209541688
Merge branch 'search-render-improvements' 2020-01-05 15:20:34 +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
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