From 3bc6db1e8cc886642660b20547ff5d6af739a3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 8 Mar 2020 13:52:59 +0100 Subject: [PATCH 1/7] scripts/generate-alt-random-writes: use TIOCGWINSZ instead of shutil --- scripts/generate-alt-random-writes.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/generate-alt-random-writes.py b/scripts/generate-alt-random-writes.py index f7afbad4..9af73cfd 100755 --- a/scripts/generate-alt-random-writes.py +++ b/scripts/generate-alt-random-writes.py @@ -1,8 +1,10 @@ #!/usr/bin/env python3 import argparse import enum -import shutil +import fcntl +import struct import sys +import termios class ColorVariant(enum.IntEnum): @@ -25,9 +27,11 @@ def main(): opts = parser.parse_args() out = opts.out if opts.out is not None else sys.stdout - term_size = shutil.get_terminal_size() - lines = term_size.lines - cols = term_size.columns + lines, cols, _, _ = struct.unpack( + 'HHHH', + fcntl.ioctl(sys.stdout.fileno(), + termios.TIOCGWINSZ, + struct.pack('HHHH', 0, 0, 0, 0))) # Number of characters to write to screen count = 256 * 1024**1 From 18313dcbec4602f748fc925c285ec97ae6ddda04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 8 Mar 2020 14:08:48 +0100 Subject: [PATCH 2/7] config: csd: error out on invalid key --- config.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config.c b/config.c index 46056567..5ea035df 100644 --- a/config.c +++ b/config.c @@ -413,6 +413,12 @@ parse_section_csd(const char *key, const char *value, struct config *conf, conf->csd.color.close_set = true; conf->csd.color.close = color; } + + else { + LOG_WARN("%s:%u: invalid key: %s", path, lineno, key); + return false; + } + return true; } From 217f16e43466848253d757c4aa0141a0b92d066b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 9 Mar 2020 18:44:43 +0100 Subject: [PATCH 3/7] .desktop: 'terminal' is not a common icon name Not all icon themes have a 'terminal' icon. 'utilities-terminal' on the other hand is a standardized icon name. --- foot-server.desktop | 2 +- foot.desktop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/foot-server.desktop b/foot-server.desktop index 89d104ae..caddeb78 100644 --- a/foot-server.desktop +++ b/foot-server.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Exec=foot --server -Icon=terminal +Icon=utilities-terminal Terminal=false Categories=System;TerminalEmulator; diff --git a/foot.desktop b/foot.desktop index 87f99194..7314b83a 100644 --- a/foot.desktop +++ b/foot.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=Application Exec=foot -Icon=terminal +Icon=utilities-terminal Terminal=false Categories=System;TerminalEmulator; From 404365ec56dd3e238be46946dd15a229a64bf154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 9 Mar 2020 18:45:43 +0100 Subject: [PATCH 4/7] wayland: register FDM hook early, to avoid unregister errors when failing --- wayland.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wayland.c b/wayland.c index 4bf77562..f06668ac 100644 --- a/wayland.c +++ b/wayland.c @@ -727,6 +727,11 @@ wayl_init(const struct config *conf, struct fdm *fdm) wayl->fdm = fdm; wayl->kbd.repeat.fd = -1; + if (!fdm_hook_add(fdm, &fdm_hook, wayl, FDM_HOOK_PRIORITY_LOW)) { + LOG_ERR("failed to add FDM hook"); + goto out; + } + wayl->display = wl_display_connect(NULL); if (wayl->display == NULL) { LOG_ERR("failed to connect to wayland; no compositor running?"); @@ -851,11 +856,6 @@ wayl_init(const struct config *conf, struct fdm *fdm) goto out; } - if (!fdm_hook_add(fdm, &fdm_hook, wayl, FDM_HOOK_PRIORITY_LOW)) { - LOG_ERR("failed to add FDM hook"); - goto out; - } - return wayl; out: From 3e5f011f7571fdbe45d143049d0e49620eadbef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 9 Mar 2020 18:46:09 +0100 Subject: [PATCH 5/7] wayland: make a missing presentation time interface an error If the user wanted to do presentation timing, and the interface isn't there, then this is an error. --- wayland.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wayland.c b/wayland.c index f06668ac..0baafa28 100644 --- a/wayland.c +++ b/wayland.c @@ -780,9 +780,10 @@ wayl_init(const struct config *conf, struct fdm *fdm) if (wayl->primary_selection_device_manager == NULL) LOG_WARN("no primary selection available"); - if (conf->presentation_timings && wayl->presentation == NULL) - LOG_WARN("presentation time interface not implemented by compositor; " - "timings will not be available"); + if (conf->presentation_timings && wayl->presentation == NULL) { + LOG_ERR("presentation time interface not implemented by compositor"); + goto out; + } tll_foreach(wayl->monitors, it) { LOG_INFO( From 6c6e3da7e243dde5d4df2e2dfa33aa1abf8a3ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 9 Mar 2020 18:46:50 +0100 Subject: [PATCH 6/7] term: init: no need to roundtrip --- terminal.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/terminal.c b/terminal.c index 7fc177f0..0a7e5b5e 100644 --- a/terminal.c +++ b/terminal.c @@ -770,15 +770,15 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl, if ((term->window = wayl_win_init(term)) == NULL) goto err; - /* Let the Wayland backend know we exist */ - tll_push_back(wayl->terms, term); - wayl_roundtrip(term->wl); - term_set_window_title(term, "foot"); - /* Load fonts */ if (!term_font_dpi_changed(term)) goto err; + term_set_window_title(term, "foot"); + + /* Let the Wayland backend know we exist */ + tll_push_back(wayl->terms, term); + /* Start the slave/client */ if ((term->slave = slave_spawn(term->ptmx, argc, term->cwd, argv, term_env, conf->shell, login_shell)) == -1) goto err; From 25792a7e8cd6bd1aa1486f08e8af6770d170da09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 9 Mar 2020 18:47:10 +0100 Subject: [PATCH 7/7] server/client: add XDG_SESSION_ID to the default socket path This allows multiple foot servers to run in multiple sessions. --- client.c | 5 ++++- config.c | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client.c b/client.c index 29b4e3b2..30271c86 100644 --- a/client.c +++ b/client.c @@ -135,10 +135,13 @@ main(int argc, char *const *argv) } else { bool connected = false; + const char *xdg_session_id = getenv("XDG_SESSION_ID"); const char *xdg_runtime = getenv("XDG_RUNTIME_DIR"); if (xdg_runtime != NULL) { - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/foot.sock", xdg_runtime); + if (xdg_session_id == NULL) + xdg_session_id = ""; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/foot-%s.sock", xdg_runtime, xdg_session_id); if (connect(fd, (const struct sockaddr *)&addr, sizeof(addr)) == 0) connected = true; else diff --git a/config.c b/config.c index 5ea035df..dc4917b1 100644 --- a/config.c +++ b/config.c @@ -567,12 +567,16 @@ err: static char * get_server_socket_path(void) { + const char *xdg_session_id = getenv("XDG_SESSION_ID"); const char *xdg_runtime = getenv("XDG_RUNTIME_DIR"); if (xdg_runtime == NULL) return strdup("/tmp/foot.sock"); - char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot.sock") + 1); - sprintf(path, "%s/foot.sock", xdg_runtime); + if (xdg_session_id == NULL) + xdg_session_id = ""; + + char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot-.sock") + strlen(xdg_session_id) + 1); + sprintf(path, "%s/foot-%s.sock", xdg_runtime, xdg_session_id); return path; }