Commit graph

904 commits

Author SHA1 Message Date
Daniel Eklöf
9ae5c311d1
async: add async_write(), a write primitive to write to a NONBLOCK:ing FD 2019-11-04 13:46:30 +01:00
Daniel Eklöf
60c3ff8737
selection: send primary/clipboard data asynchronously
TODO: try writing synchronously first
2019-11-04 13:11:15 +01:00
Daniel Eklöf
a706c1e804
terminal: add comments describing the sync/async writing modes 2019-11-04 12:36:43 +01:00
Daniel Eklöf
a3f79ead94
Merge branch 'window-urgency' 2019-11-04 12:24:03 +01:00
Daniel Eklöf
5f6d230c10
csi: comment out handling of CSI ? 1042/1043 h/l
In Wayland, we neither _have_ an urgency hint to set, nor can we raise
the window(?)
2019-11-04 12:23:02 +01:00
Daniel Eklöf
42eef90268
csi: recognize CSI ? 1042/1043 h/l
1042: set 'urgency' window manager hint when receiving ctrl-g
1043: raise window when receiving ctrl-g
2019-11-04 12:00:50 +01:00
Daniel Eklöf
e46b963139
doc: foot.5: don't upper case 'one' in the middle of a sentence 2019-11-03 16:28:00 +01:00
Daniel Eklöf
db9fd03283
doc: foot.1: add description of the (mouse) wheel 2019-11-03 16:23:18 +01:00
Daniel Eklöf
ef101f0c96
doc: foot.1: spelling 2019-11-03 16:23:09 +01:00
Daniel Eklöf
988134717f
wayland: verify xdg-output-manager interface version 2019-11-03 16:14:35 +01:00
Daniel Eklöf
4e93b3a2d8
wayland: verify server implements the required interface versions 2019-11-03 15:39:26 +01:00
Daniel Eklöf
f84a59bea7
README: remove extra period 2019-11-03 13:54:12 +01:00
Daniel Eklöf
d51bee6bb3
man: foot.1: add reference to footclient(1) 2019-11-03 13:47:28 +01:00
Daniel Eklöf
0c4d43e285
man: footclient.1: initial documentation 2019-11-03 13:47:19 +01:00
Daniel Eklöf
f63c5a66ac
man: foot.1: add a DESCRIPTION 2019-11-03 13:47:03 +01:00
Daniel Eklöf
0712a6dbff
man: foot.1: document -s,--server 2019-11-03 13:46:47 +01:00
Daniel Eklöf
567989e9f3
main: usage for --server now hints about 'footclient' 2019-11-03 13:46:09 +01:00
Daniel Eklöf
61dfa1365e
slave: restore signals before calling exec() 2019-11-03 13:24:15 +01:00
Daniel Eklöf
d26c67e589
main: ignore SIGHUP in master process 2019-11-03 13:23:49 +01:00
Daniel Eklöf
a8cb6c531e
Remove unneeded include 2019-11-03 13:07:19 +01:00
Daniel Eklöf
d3e4ba6c94
slave: remove unneeded define 2019-11-03 13:02:16 +01:00
Daniel Eklöf
78cd93f030
terminal: malloc_trim() is a GNU extension 2019-11-03 12:57:47 +01:00
Daniel Eklöf
2195e2cf71
terminal: trim memory after free:ing a terminal
A terminal with lots of scrollback history will have allocated a lot
of memory.

Normally, free() wont return this memory to the OS, and we don't seem
to trigger the automatic trim calls.

This means the server would accumulate quite a lot of memory over
time, as terminals come and go.

Now we explicitly trim the memory every time a terminal is destroyed.
2019-11-03 12:48:18 +01:00
Daniel Eklöf
ffadb5f020
README: updates
* Multiple windows _are_ supported, sort of, via --server
* Add note about GNOME not having SSDs
* Add mouse wheel to list of keyboard/mouse shortcuts
2019-11-03 12:24:14 +01:00
Daniel Eklöf
e76357eabb
terminal: ptmx fdm handler: tag unlikely branches 2019-11-03 12:14:09 +01:00
Daniel Eklöf
79945419eb
terminal: comments and cleanup 2019-11-03 12:13:51 +01:00
Daniel Eklöf
a326427caf
server: set CLOEXEC | NONBLOCK directly in socket() call 2019-11-03 01:48:40 +01:00
Daniel Eklöf
e1b6aa87fb
Merge branch 'async-ptmx' 2019-11-03 01:26:42 +01:00
Daniel Eklöf
cba1551b03
terminal: cleanup asynchronous ptmx output handling
Break out actual writing to a separate function, and call this
function both from the synchronous and the asynchronous code paths.
2019-11-03 01:25:41 +01:00
Daniel Eklöf
b4c810cf50
Merge branch 'master' into async-ptmx 2019-11-03 01:14:48 +01:00
Daniel Eklöf
8cf981ca12
slave: turn on FD_CLOEXEC after slave has been spawned
This ensures that our ptmx FD isn't carried over to other terminals
spawned later.
2019-11-03 01:14:02 +01:00
Daniel Eklöf
8d9ad96b52
server: FD_CLOEXEC is a file descriptor flag, not a file status flag 2019-11-03 01:11:02 +01:00
Daniel Eklöf
f00c5fdac6
term: asynchronous writes to slave
Make ptmx non-blocking. Then, when writing data to the slave would
have blocked, use the FDM to asynchronously write the remaining data.

This is done by enabling EPOLLOUT on ptmx, and enqueueing all outgoing
data. The FDM handler will go through the enqueued data, and once all
of it has been written, we turn off EPOLLOUT again (thus switching
back to synchronous writes)
2019-11-03 01:03:52 +01:00
Daniel Eklöf
777d851282
fdm: invert check to get rid of one level of indentation 2019-11-03 00:52:24 +01:00
Daniel Eklöf
9f1525aef7
Rename: vt_to_slave() -> term_to_slave() 2019-11-03 00:52:24 +01:00
Daniel Eklöf
79c3121aa3
misc: fdm already logs failures 2019-11-03 00:52:24 +01:00
Daniel Eklöf
89997b97a0
fdm: add fdm_event_add() and fdm_event_del()
These functions allow users to modify already registered FDs, to add
or remove events they are interested in.
2019-11-03 00:52:24 +01:00
Daniel Eklöf
e09bda322a
fdm: bug: 'ret' was renamed to 'r', and replaced with another 'ret' 2019-11-03 00:51:47 +01:00
Daniel Eklöf
8ffa021de8
fdm: rename struct fd -> struct handler 2019-11-02 23:37:19 +01:00
Daniel Eklöf
9b67a6627a
fdm: fdm_destroy(): assert deferred delete list is empty 2019-11-02 23:36:02 +01:00
Daniel Eklöf
ba7f79af18
fdm: purge deferred delete list also when handler fails 2019-11-02 23:35:42 +01:00
Daniel Eklöf
1543c71f78
server: server_destroy(): unlink UNIX socket 2019-11-02 23:32:13 +01:00
Daniel Eklöf
ad26914631
server: use a non-blocking socket when trying to connect
When checking of a 'foot --server' instance is already running, we try
to connect to the UNIX socket we're planning on listening on.

In most cases, this will fail hard and fast. But under certain
circumstances, we can get stuck in connect() waiting for a connection
timeout.

Since it should be possible to establish a connection immediately *if*
there's someone actually listening on the socket, rely on the fact
that connect() will fail with a EINPROGRESS if a connection can *not*
be established immediately (and thus no one is listening on it).
2019-11-02 23:25:14 +01:00
Daniel Eklöf
32129083bd
main: pre-allocate fonts
Since fonts are cached, this adds no additional memory. However, it
makes the first terminal window in --server mode start much faster,
since the (primary) fonts have already been loaded.

Fallback fonts are still loaded on-demand.
2019-11-02 13:50:40 +01:00
Daniel Eklöf
c99c0285dc
fdm: fdm_poll(): disallow nested calls 2019-11-02 13:46:54 +01:00
Daniel Eklöf
338747dc5a
server: don't get stuck in read() if TERM length is 0 2019-11-02 12:17:30 +01:00
Daniel Eklöf
a1ba4cb010
server: don't get stuck in read() if length of argv argument is 0 2019-11-02 12:16:50 +01:00
Daniel Eklöf
965d8a3a8e
terminal: don't get stuck waiting for misbehaving slaves to terminate
While unusual, it *is* possible for a client *not* to terminate when
we close ptmx.

We need to handle this *somehow*. Since it is so unusual, we'll go
with a fairly easy, but synchronous method:

* Register a signal handler for SIGALRM, and setup a 2 second alarm
* Wait for slave to die
* If it didn't die, sent SIGTERM, then re-set the alarm for another 2
  seconds.
* If it still hasn't died, send SIGKILL (this time without an alarm).
2019-11-02 12:09:32 +01:00
Daniel Eklöf
563c910127
terminal: 'child_ret' variables isn't needed 2019-11-02 11:30:32 +01:00
Daniel Eklöf
f28fb6c039
timerfd: read() returns -1 with errno == EAGAIN, not 0
When there hasn't been a timeout (or in our case, there was a timeout,
but we reset the timer before we got to the read()), read() returns,
not 0, but -1 with errno == EAGAIN.
2019-11-02 01:44:01 +01:00