Commit graph

871 commits

Author SHA1 Message Date
Daniel Eklöf
9abc5ca971
server/client: harden reading of initialization data, and make async
* Client terminal initialization data is now received
  asynchronously. To facilitate this, a couple of minor changes to the
  protocol was made:
    - The client now starts with sending a 4-byte unsigned integer
      with the *total* size of the initialization data (*not*
      including the size field itself.
    - Strings (TERM variable + argv) are now sent NULL-terminated

* The server allocates a single buffer, and fills it
  asynchronously. When full (as indicated by the initial 'total size'
  integer), we parse it (taking care not to read outside boundaries
  etc, and verifies the lengths (of the TERM variable and argv array)
  indicated by the client matches the actual lengths of the strings
  received.

* The server now ignores 'unexpected' data received from the client,
  after the terminal has been instantiated.
2019-11-05 10:08:30 +01:00
Daniel Eklöf
5b3fe4492c
server: workaround evil clients
If the clients attempt to send more data after we've instantiated the
terminal, just consume the data but ignore it.
2019-11-05 09:31:47 +01:00
Daniel Eklöf
5f77f0e999
server: don't cache argc/argv in client context 2019-11-05 09:31:14 +01:00
Daniel Eklöf
1c7fb2869d
main: destroy cached SHM buffers *after* terminals have been destroyed 2019-11-05 09:30:24 +01:00
Daniel Eklöf
fef07138b3
terminal: ptmx: ignore *both* EPOLLIN and EPOLLOUT on EPOLLHUP 2019-11-05 09:23:13 +01:00
Daniel Eklöf
fd82caad42
selection: document the asynchronous behavior of text_from_{primary,clipboard} 2019-11-05 09:13:47 +01:00
Daniel Eklöf
b17358bd0a
selection: make text_from_{clipboard,primary} async 2019-11-05 09:09:51 +01:00
Daniel Eklöf
dd57418494
selection: initialize 'ctx' before jumping into its scope 2019-11-05 08:51:10 +01:00
Daniel Eklöf
b15032d223
selection: text_from_{clipboard,primary}: add 'done' callback
This callback is *always* called, including when there has been an
error.

This is in preparation for making text_from_{clipboard,primary}
asynchronous.
2019-11-05 08:49:32 +01:00
Daniel Eklöf
9cd22dc398
selection: async send: handle POLLHUP 2019-11-05 08:40:39 +01:00
Daniel Eklöf
1207ad1502
selection: free strdup:ed clipboard data on fdm failure 2019-11-05 08:40:24 +01:00
Daniel Eklöf
8824e3823e
selection: remove debug assert 2019-11-05 08:40:01 +01:00
Daniel Eklöf
bb9dad18f4
selection: typedef not needed here (copy-paste from fdm.h) 2019-11-05 08:39:39 +01:00
Daniel Eklöf
dbb51ed4c9
selection: we don't set user data on primary/clipboard data sources 2019-11-04 14:11:18 +01:00
Daniel Eklöf
739c5cf7f0
input: remove unneeded(?) term_reset_view() calls
Not sure why these were added here; they don't appear to be
needed (we're writing to the client - it's up to the client to echo
stuff, in which case we redraw as usual).
2019-11-04 14:10:37 +01:00
Daniel Eklöf
cebeb390e4
selection: try to write selection data synchronously first
Only if we fail to write everything do we switch to asynchronous mode.
2019-11-04 14:00:51 +01:00
Daniel Eklöf
3081898caf
terminal: use async_write() when writing to ptmx 2019-11-04 13:46:30 +01:00
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