From d28494c01d7df37fd8f8d5b9d205aed5240be869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 14 Mar 2020 22:28:16 +0100 Subject: [PATCH 01/11] changelog: remove 'unreleased' section --- CHANGELOG.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e52a01f..9507eb74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,5 @@ # Changelog -## Unreleased -### Added -### Changed -### Deprecated -### Removed -### Fixed -### Security - ## 1.2.1 ### Fixed From 9e3a68d6e703ec223c63a997bd4b7adbe6f456c0 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 02/11] .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 8ab402b25249cc9659bcd07823b0a4f101f5fec2 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 03/11] 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 46056567..4f9cde4d 100644 --- a/config.c +++ b/config.c @@ -561,12 +561,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; } From 35de42959249b040d4193db8128711cf3b0c2700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 9 Mar 2020 21:11:41 +0100 Subject: [PATCH 04/11] changelog: update --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9507eb74..bd6a671e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.2.2 + +### Changed +* Changed icon name in `foot.desktop` and `foot-server.desktop` from + _terminal_ to _utilities-terminal_. +* `XDG_SESSION_ID` is now included in the server/daemon default socket + path. + + ## 1.2.1 ### Fixed From fdb684eceb68d75edd14d7af17f52cc24ec67e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 10 Mar 2020 18:02:37 +0100 Subject: [PATCH 05/11] client: update --server-socket usage to mention XDG_SESSION_ID --- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.c b/client.c index 30271c86..daa0e252 100644 --- a/client.c +++ b/client.c @@ -34,7 +34,7 @@ print_usage(const char *prog_name) printf("Options:\n"); printf(" -t,--term=TERM value to set the environment variable TERM to (foot)\n" " --login-shell start shell as a login shell\n" - " -s,--server-socket=PATH path to the server UNIX domain socket (default=XDG_RUNTIME_DIR/foot.sock)\n" + " -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$XDG_SESSION_ID.sock)\n" " -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\n" " -v,--version show the version number and quit\n"); } From 3bee0318674ec5e7ed79e31e62a68f1719df1ddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 10 Mar 2020 18:02:57 +0100 Subject: [PATCH 06/11] client: log path we actually tried to connect to (and failed) --- client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.c b/client.c index daa0e252..faa7c919 100644 --- a/client.c +++ b/client.c @@ -145,7 +145,7 @@ main(int argc, char *const *argv) if (connect(fd, (const struct sockaddr *)&addr, sizeof(addr)) == 0) connected = true; else - LOG_WARN("%s/foot.sock: failed to connect, will now try /tmp/foot.sock", xdg_runtime); + LOG_WARN("%s: failed to connect, will now try /tmp/foot.sock", addr.sun_path); } if (!connected) { From c8ea1d137ef280b1a25ec8685e38bcd9c47a17d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 10 Mar 2020 18:07:12 +0100 Subject: [PATCH 07/11] terminal: appky scale factor when force-resizing on font reload If we don't, we'll end up e.g. increasing the window size when moving the window between outputs with different scaling. Closes #3 --- terminal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/terminal.c b/terminal.c index 7fc177f0..3803e847 100644 --- a/terminal.c +++ b/terminal.c @@ -525,7 +525,7 @@ term_set_fonts(struct terminal *term, struct font *fonts[static 4]) term->fonts[0]->ascent + term->fonts[0]->descent); LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height); - render_resize_force(term, term->width, term->height); + render_resize_force(term, term->width / term->scale, term->height / term->scale); return true; } From af2e33b78e20fa91d7b6802360a5e1b91bf6e8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 10 Mar 2020 18:17:14 +0100 Subject: [PATCH 08/11] changelog: updated to mention fix for #3 I really need to learn to update the changelog **with** the fix... --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd6a671e..f4f27667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ * `XDG_SESSION_ID` is now included in the server/daemon default socket path. +### Fixed +* Window size doubling when moving window between outputs with + different scaling factors (https://codeberg.org/dnkl/foot/issues/3). + ## 1.2.1 From be0d620669519d8bbc7bcd232b9028b7641684ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 12 Mar 2020 09:31:25 +0100 Subject: [PATCH 09/11] quirks: weston_csd_{on,off}: don't do anything in fullscreen mode --- quirks.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quirks.c b/quirks.c index 6db96e46..05d2dd5f 100644 --- a/quirks.c +++ b/quirks.c @@ -61,6 +61,8 @@ quirk_weston_csd_on(struct terminal *term) { if (term->window->use_csd != CSD_YES) return; + if (term->window->is_fullscreen) + return; for (int i = 0; i < ALEN(term->window->csd.surface); i++) quirk_weston_subsurface_desync_on(term->window->csd.sub_surface[i]); @@ -71,6 +73,8 @@ quirk_weston_csd_off(struct terminal *term) { if (term->window->use_csd != CSD_YES) return; + if (term->window->is_fullscreen) + return; for (int i = 0; i < ALEN(term->window->csd.surface); i++) quirk_weston_subsurface_desync_off(term->window->csd.sub_surface[i]); From 36ef0463b7157199aac1876ad4cc9725403fff4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 11 Mar 2020 16:10:55 +0100 Subject: [PATCH 10/11] term: use logical DPI+scale factor when scaling fonts This fixes an issue where the fonts were rendered too small when the output had fractional scaling. For integral scaling, using the logical (scaled) DPI multiplied with the scaling factor results in the same final DPI value as if we had used the physical DPI. But for fractional scaling, this works around the fact that the compositor downscales the surface after we've rendered it. Closes #5 --- terminal.c | 27 ++++++++++++++++++++++++--- wayland.c | 39 +++++++++++++++++++++++++-------------- wayland.h | 37 +++++++++++++++++++++++++++++++------ 3 files changed, 80 insertions(+), 23 deletions(-) diff --git a/terminal.c b/terminal.c index 3803e847..68dc9b58 100644 --- a/terminal.c +++ b/terminal.c @@ -532,18 +532,39 @@ term_set_fonts(struct terminal *term, struct font *fonts[static 4]) static unsigned get_font_dpi(const struct terminal *term) { + /* + * Use output's DPI to scale font. This is to ensure the font has + * the same physical height (if measured by a ruler) regardless of + * monitor. + * + * Conceptually, we use the physical monitor specs to calculate + * the DPI, and we ignore the output's scaling factor. + * + * However, to deal with fractional scaling, where we're told to + * render at e.g. 2x, but are then downscaled by the compositor to + * e.g. 1.25, we use the scaled DPI value multiplied by the scale + * factor instead. + * + * For integral scaling factors the resulting DPI is the same as + * if we had used the physical DPI. + * + * For fractional scaling factors we'll get a DPI *larger* than + * the physical DPI, that ends up being right when later + * downscaled by the compositor. + */ + /* Use highest DPI from outputs we're mapped on */ unsigned dpi = 0; assert(term->window != NULL); tll_foreach(term->window->on_outputs, it) { - if (it->item->y_ppi > dpi) - dpi = it->item->y_ppi; + if (it->item->ppi.scaled.y > dpi) + dpi = it->item->ppi.scaled.y * term->scale; } /* If we're not mapped, use DPI from first monitor. Hopefully this is where we'll get mapped later... */ if (dpi == 0) { tll_foreach(term->wl->monitors, it) { - dpi = it->item.y_ppi; + dpi = it->item.ppi.scaled.y * term->scale; break; } } diff --git a/wayland.c b/wayland.c index 4bf77562..6b92c235 100644 --- a/wayland.c +++ b/wayland.c @@ -169,10 +169,16 @@ update_terms_on_monitor(struct monitor *mon) static void output_update_ppi(struct monitor *mon) { - int x_inches = mon->width_mm * 0.03937008; - int y_inches = mon->height_mm * 0.03937008; - mon->x_ppi = mon->width_px / x_inches; - mon->y_ppi = mon->height_px / y_inches; + if (mon->dim.mm.width == 0 || mon->dim.mm.height == 0) + return; + + int x_inches = mon->dim.mm.width * 0.03937008; + int y_inches = mon->dim.mm.height * 0.03937008; + mon->ppi.real.x = mon->dim.px_real.width / x_inches; + mon->ppi.real.y = mon->dim.px_real.height / y_inches; + + mon->ppi.scaled.x = mon->dim.px_scaled.width / x_inches; + mon->ppi.scaled.y = mon->dim.px_scaled.height / y_inches; } static void @@ -182,9 +188,9 @@ output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y, int32_t transform) { struct monitor *mon = data; - mon->width_mm = physical_width; - mon->height_mm = physical_height; - mon->inch = sqrt(pow(mon->width_mm, 2) + pow(mon->height_mm, 2)) * 0.03937008; + mon->dim.mm.width = physical_width; + mon->dim.mm.height = physical_height; + mon->inch = sqrt(pow(mon->dim.mm.width, 2) + pow(mon->dim.mm.height, 2)) * 0.03937008; mon->make = make != NULL ? strdup(make) : NULL; mon->model = model != NULL ? strdup(model) : NULL; output_update_ppi(mon); @@ -199,8 +205,8 @@ output_mode(void *data, struct wl_output *wl_output, uint32_t flags, struct monitor *mon = data; mon->refresh = (float)refresh / 1000; - mon->width_px = width; - mon->height_px = height; + mon->dim.px_real.width = width; + mon->dim.px_real.height = height; output_update_ppi(mon); } @@ -238,6 +244,10 @@ static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, int32_t width, int32_t height) { + struct monitor *mon = data; + mon->dim.px_scaled.width = width; + mon->dim.px_scaled.height = height; + output_update_ppi(mon); } static void @@ -781,11 +791,12 @@ wayl_init(const struct config *conf, struct fdm *fdm) tll_foreach(wayl->monitors, it) { LOG_INFO( - "%s: %dx%d+%dx%d@%dHz %s (%.2f\", PPI=%dx%d, scale=%d)", - it->item.name, it->item.width_px, it->item.height_px, - it->item.x, it->item.y, (int)round(it->item.refresh), it->item.model, it->item.inch, - it->item.x_ppi, it->item.y_ppi, - it->item.scale); + "%s: %dx%d+%dx%d@%dHz %s %.2f\" scale=%d PPI=%dx%d (physical) PPI=%dx%d (logical)", + it->item.name, it->item.dim.px_real.width, it->item.dim.px_real.height, + it->item.x, it->item.y, (int)round(it->item.refresh), + it->item.model, it->item.inch, it->item.scale, + it->item.ppi.real.x, it->item.ppi.real.y, + it->item.ppi.scaled.x, it->item.ppi.scaled.y); } /* Clipboard */ diff --git a/wayland.h b/wayland.h index ed53591d..7d7b36ca 100644 --- a/wayland.h +++ b/wayland.h @@ -24,14 +24,39 @@ struct monitor { int x; int y; - int width_mm; - int height_mm; + struct { + /* Physical size, in mm */ + struct { + int width; + int height; + } mm; - int width_px; - int height_px; + /* Physical size, in pixels */ + struct { + int width; + int height; + } px_real; - int x_ppi; - int y_ppi; + /* Scaled size, in pixels */ + struct { + int width; + int height; + } px_scaled; + } dim; + + struct { + /* PPI, based on physical size */ + struct { + int x; + int y; + } real; + + /* PPI, logical, based on scaled size */ + struct { + int x; + int y; + } scaled; + } ppi; int scale; float refresh; From c28c0c3db46410c2d7011878d67d82873e52048a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 11 Mar 2020 20:18:47 +0100 Subject: [PATCH 11/11] changelog: mention fix for #5 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f27667..8a1855e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ ### Fixed * Window size doubling when moving window between outputs with different scaling factors (https://codeberg.org/dnkl/foot/issues/3). +* Font being too small on monitors with fractional scaling + (https://codeberg.org/dnkl/foot/issues/5). ## 1.2.1