Commit graph

64 commits

Author SHA1 Message Date
Ronan Pigott
99d5bf64bc foot/client: implement xdga client activation
This is an application of the xdg activation protocol that will allow
compositors to associate new foot toplevels with the command that
launched them.

footclient receives an activation token from the launcher which the
compositor can use to track application startup. It passes the token
to the foot server, which then activates the new window with the token
to complete the startup sequence.
2021-10-31 18:52:29 -07:00
Daniel Eklöf
f39a62fa5e
server: no need to clone the config to handle -N,--no-wait 2021-09-05 09:28:19 +02:00
Daniel Eklöf
1233e000f0
server: verify primary font is monospaced
... unless we’re re-using the main conf as-is, in which case we will
already have done this (and the conf’s user-notification list will
already contain a warning).
2021-08-31 19:58:35 +02:00
Daniel Eklöf
03f952cf4d
term: consolidate shutdown related state into an anonymous struct 2021-07-31 19:08:51 +02:00
Daniel Eklöf
8290cebc09
server: the terminal now purges SHM pixmaps on its own 2021-07-11 11:54:08 +02:00
Daniel Eklöf
ef349bfea2
server: make sure ‘overrides’ have been initialized in all error paths 2021-06-23 15:38:29 +02:00
Daniel Eklöf
04d42662c7
server: avoid “member access within misaligned address” ASAN warning 2021-06-23 15:12:08 +02:00
Daniel Eklöf
136d60606a
client: send overrides for everything that is publicly visible in the conf
Send a generic “overrides” list to the server, containing options in
text, on the format “section.key=value”.

This reduces the size of the base client/server protocol packet, as
well as opens up for a generic -o,--override command line option (not
yet implemented).
2021-06-23 15:12:08 +02:00
Daniel Eklöf
fa5cde6ce1
server: use config_clone() + config_override_apply()
When the connecting client overrides config options, clone the
server’s configuration, and then convert the overridden options to
config overrides, and apply them using config_override_apply().

When destroying the client, free the cloned config using the regular
config_free().
2021-06-23 15:12:07 +02:00
Daniel Eklöf
7d2770f154
server: don’t clone the config unless we’re going to modify it 2021-06-17 18:11:16 +02:00
Daniel Eklöf
da923100ca
main/client: change exit code
* foot exits with -26/230
* footclient exits with -36/220

This is to give each application a range of exit codes. Currently
unused, but we may want to change this in the future.
2021-05-04 10:41:22 +02:00
Daniel Eklöf
a1b41bd186
foot/footclient: use a custom exit code when foot/footclient fail to run
Normally, foot and footclient uses the exit code from the client
application (i.e. the shell).

However, foot (or footclient) itself may fail to run; if run outside
of a Wayland session, or no fonts are installed, or the client
application/shell cannot be found (“foot lsdjfldsjf”) etc.

Up until now, there has been no way to differentiate these kind of
failures from the client application exiting with code 1.

This patch changes foot’s failure exit code to -27/229, and
footclient’s to -28/228. Note that footclient will exit with foot’s
-27/229 if footclient ran successfully, but the foot server failed to
instantiate a new window.

Closes #466.
2021-05-04 10:40:38 +02:00
Felipe Trzaskowski
2dc13cc13b fix code style issues and memory leak 2021-03-13 08:01:38 -03:00
Felipe Trzaskowski
3ed9314266 add option to detach the client process from the terminal instance 2021-03-13 05:48:55 -03:00
Daniel Eklöf
64a60d12f0
server: send exit-code -1 when we fail to instantiate a new terminal 2021-02-12 21:42:53 +01:00
Jan Beich
567a8de3b0
client/server: switch to POSIX header for sockaddr_un
client.c:13:10: fatal error: 'linux/un.h' file not found
 #include <linux/un.h>
          ^~~~~~~~~~~~
client.c:195:24: error: variable has incomplete type 'struct sockaddr_un'
    struct sockaddr_un addr = {.sun_family = AF_UNIX};
                       ^
client.c:195:12: note: forward declaration of 'struct sockaddr_un'
    struct sockaddr_un addr = {.sun_family = AF_UNIX};
           ^
server.c:11:10: fatal error: 'linux/un.h' file not found
 #include <linux/un.h>
          ^~~~~~~~~~~~
server.c:307:24: error: variable has incomplete type 'struct sockaddr_un'
    struct sockaddr_un addr;
                       ^
server.c:307:12: note: forward declaration of 'struct sockaddr_un'
    struct sockaddr_un addr;
           ^
server.c:347:24: error: variable has incomplete type 'struct sockaddr_un'
    struct sockaddr_un addr = {.sun_family = AF_UNIX};
                       ^
server.c:347:12: note: forward declaration of 'struct sockaddr_un'
    struct sockaddr_un addr = {.sun_family = AF_UNIX};
           ^
server.c:394:24: error: variable has incomplete type 'struct sockaddr_un'
    struct sockaddr_un addr = {.sun_family = AF_UNIX};
                       ^
server.c:394:12: note: forward declaration of 'struct sockaddr_un'
    struct sockaddr_un addr = {.sun_family = AF_UNIX};
           ^
2021-01-21 12:00:02 +01:00
Craig Barnes
e56136ce11 debug: rename assert() to xassert(), to avoid clashing with <assert.h> 2021-01-16 20:16:00 +00:00
Craig Barnes
adde947fc5 config: replace union in config struct with simple width/height members 2020-11-30 02:24:38 +00:00
Craig Barnes
748f98e0c0 client: add "--window-size-pixels" and "--window-size-chars" options 2020-11-22 18:52:28 +00:00
Daniel Eklöf
f4de500a18
server: avoid doing unaligned struct accesses 2020-11-21 20:47:17 +01:00
Daniel Eklöf
f2a88d6071
server: verify strings are NULL terminated 2020-11-21 20:27:13 +01:00
Daniel Eklöf
fc81f413c0
client/server: simplify setup packet handling
Instead of writing (and logging errors for) every parameter, one at a
time, send all fixed size data in a single struct, followed by all the
variable length data.
2020-11-21 20:21:18 +01:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Daniel Eklöf
3943cad7ed
client/server: implement '--hold' in footclient 2020-05-26 20:11:38 +02:00
Daniel Eklöf
789617d5ad
term: don't double fork new terminal windows
Instead, register their PIDs with the new reaper module and let it
handle them.
2020-05-21 20:17:29 +02:00
Daniel Eklöf
02edee78b2
server: don't do misaligned loads 2020-04-18 12:20:28 +02:00
Daniel Eklöf
1776f8bf1e
Fix clang warnings
All are printf() formatter related. Even if a variable is e.g. a
'short', when used in an expression like '<variable> - 1' it is
promoted to an 'int'.

Closes #16
2020-04-12 18:20:52 +02:00
Daniel Eklöf
ec7a768487
conf: add 'title' conf option and --title command line option 2020-04-01 19:59:47 +02:00
Daniel Eklöf
4d52a870b4
conf: add app-id config option and --app-id command line option 2020-04-01 18:40:51 +02:00
Daniel Eklöf
758fd9fd58
client: add --maximized and --fullscreen
We now create a copy of the config for each client, and updates it
with the values passed from the client.

Since we're not actually cloning it (and e.g. strdup() all strings
etc) we can't call conf_destroy() to free it, but need to free just
the strings we've replaced.
2020-03-27 21:14:49 +01:00
Daniel Eklöf
f7572d4ab1
server: purge *all* buffers when a terminal shuts down
Previously we only purged the main grid buffers. Now we also purge the
search buffers and the CSD buffers.
2020-03-18 16:53:12 +01:00
Daniel Eklöf
b5efe984bb
slave: prefix argv[0] with a '-' when spawning a login-shell 2020-02-20 18:36:09 +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
c91ef4c512
server: verify CWD string length matches the indicated length 2019-12-21 20:05:14 +01:00
Daniel Eklöf
cd382a467c
server: move forward the indicated number of TERM bytes 2019-12-21 20:05:00 +01:00
Daniel Eklöf
2a58fc27b7
server: bug: move forward 2 bytes, not whatever the client sent 2019-12-21 20:04:40 +01:00
Daniel Eklöf
39146fac5c
term: term_init: add 'cwd' argument
This is used when spawning the slave, to set its current working
directory just before we exec() the client.

In a regular foot instance, we set the cwd from getcwd().

In a foot server instance, each connecting client sends its cwd to the
server, and we use that.
2019-12-21 19:57:28 +01:00
Daniel Eklöf
277735db65
client/server: client sends its CWD to server 2019-12-21 19:56:37 +01:00
Daniel Eklöf
a484a65fef
term: term_spawn_new: always spawn foot/footclient from PATH 2019-12-21 15:29:42 +01:00
Daniel Eklöf
57de9feaa5
term: term_spawn_new(): new function, spawns a new foot/footclient process
Bind ctrl+shift+return to it
2019-12-21 15:27:17 +01:00
Daniel Eklöf
89ea61cf0c
server: use socket-path from config 2019-12-14 12:59:38 +01:00
Daniel Eklöf
6ef65058cf
server: log socket packet 2019-12-13 22:28:48 +01:00
Daniel Eklöf
b5780e735e
Add missing includes 2019-12-01 19:22:45 +01:00
Daniel Eklöf
29cccadd1d
tllist: is now an external "library", so use <> includes 2019-11-17 19:19:55 +01:00
Daniel Eklöf
54f750c494
server: disable debug output 2019-11-05 14:36:58 +01:00
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