From 341193a627287e3b0006fde84e706306db919b7f Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 27 Aug 2021 13:44:18 +0200 Subject: changelog: add new ‘unreleased’ section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ed83e6e..51f06141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* [Unreleased](#unreleased) * [1.9.0](#1-9-0) * [1.8.2](#1-8-2) * [1.8.1](#1-8-1) @@ -29,6 +30,16 @@ * [1.2.0](#1-2-0) +## Unreleased +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security +### Contributors + + ## 1.9.0 ### Added -- cgit v1.3 From ac30da7a01b55ec4778f96c70dc3b8b6ab791272 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 30 Aug 2021 17:55:36 +0200 Subject: spawn: don’t error out if we fail to chdir() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ spawn.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 51f06141..e168cdc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,8 @@ now translated to pixel values using the monitor’s scaling factor when `dpi-aware=no`, or `dpi-aware=auto` and the scaling factor is larger than 1 (https://codeberg.org/dnkl/foot/issues/680). +* Spawning a new terminal with a working directory that does not exist + is no longer a fatal error. ### Removed diff --git a/spawn.c b/spawn.c index 8adef19d..d02ab131 100644 --- a/spawn.c +++ b/spawn.c @@ -48,6 +48,11 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[], if (sigaction(SIGHUP, &(struct sigaction){.sa_handler = SIG_DFL}, NULL) < 0) goto child_err; + if (cwd != NULL && chdir(cwd) < 0) { + LOG_WARN("failed to change working directory to %s: %s", + cwd, strerror(errno)); + } + bool close_stderr = stderr_fd >= 0; bool close_stdout = stdout_fd >= 0 && stdout_fd != stderr_fd; bool close_stdin = stdin_fd >= 0 && stdin_fd != stdout_fd && stdin_fd != stderr_fd; @@ -58,7 +63,6 @@ spawn(struct reaper *reaper, const char *cwd, char *const argv[], || (close_stdout && close(stdout_fd) < 0))) || (stderr_fd >= 0 && (dup2(stderr_fd, STDERR_FILENO) < 0 || (close_stderr && close(stderr_fd) < 0))) || - (cwd != NULL && chdir(cwd) < 0) || execvp(argv[0], argv) < 0) { goto child_err; -- cgit v1.3 From 83c8eeb575df1ea8b178cbfdab49627f8b05aea1 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 30 Aug 2021 20:31:28 +0200 Subject: changelog: terminfo changes --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index e168cdc4..f983202c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,17 @@ ## Unreleased ### Added ### Changed + +* `-Ddefault-terminfo` is now also applied to the generated terminfo + definitions when `-Dterminfo=enabled`. +* `-Dcustom-terminfo-install-location` no longer accepts `no` as a + special value, to disable exporting `TERMINFO`. To achieve the same + result, simply don’t set it at all. If it _is_ set, `TERMINFO` is + still exported, like before. +* The default install location for the terminfo definitions have been + changed back to `${datadir}/terminfo`. + + ### Deprecated ### Removed ### Fixed -- cgit v1.3 From e51e085d7a9713a21bfaebaab233b3df40f64e27 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Tue, 31 Aug 2021 19:54:31 +0200 Subject: changelog: check if primary font is monospaced --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index f983202c..cf13d300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,12 @@ ## Unreleased ### Added + +* Warn when it appears the primary font is not monospaced. Can be + disabled by setting `[tweak].font-monospace-warn=no` + (https://codeberg.org/dnkl/foot/issues/704). + + ### Changed * `-Ddefault-terminfo` is now also applied to the generated terminfo -- cgit v1.3 From e553e1076c78fe99a7ea1faa5f2fd28a4f529d10 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 6 Sep 2021 18:12:45 +0200 Subject: input: workaround GNOME issue with pointer button events Under certain circumstances, GNOME will send multiple pointer button press events, without any release or leave events in between. This trips up our button tracking. Workaround, by replacing the existing state for the pressed button with the new state. Previously, debug builds would assert (and thus crash), while release builds would have multiple states for the same button, causing (probably) issues like the title bar not being usable (as in, cannot be dragged, buttons not working etc). Hopefully closes #709 --- CHANGELOG.md | 6 ++++ input.c | 102 +++++++++++++++++++++++++++++++++-------------------------- 2 files changed, 63 insertions(+), 45 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index cf13d300..57984c49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,12 @@ ### Deprecated ### Removed ### Fixed + +* Added workaround for GNOME bug where multiple button press events + (for the same button) is sent to the CSDs without any release or + leave events in between (https://codeberg.org/dnkl/foot/issues/709). + + ### Security ### Contributors diff --git a/input.c b/input.c index ec76c42a..853bc495 100644 --- a/input.c +++ b/input.c @@ -1694,50 +1694,6 @@ fdm_csd_move(struct fdm *fdm, int fd, int events, void *data) struct wl_window *win = seat->mouse_focus->window; - /* - * Workaround GNOME bug - * - * Dragging the window, then stopping the drag (releasing the - * mouse button), *without* moving the mouse, and then clicking - * twice, waiting for the CSD timer, and finally clicking once - * more, results in the following sequence (keyboard and other - * irrelevant events filtered out, unless they’re needed to prove - * a point): - * - * dbg: input.c:1551: cancelling drag timer, moving window - * dbg: input.c:759: keyboard_leave: keyboard=0x607000003580, serial=873, surface=0x6070000036d0 - * dbg: input.c:1432: seat0: pointer-leave: pointer=0x607000003660, serial=874, surface = 0x6070000396e0, old-moused = 0x622000006100 - * - * --> drag stopped here - * - * --> LMB clicked first time after the drag (generates the enter event on *release*, but no button events) - * dbg: input.c:1360: pointer-enter: pointer=0x607000003660, serial=876, surface = 0x6070000396e0, new-moused = 0x622000006100 - * - * --> LMB clicked, and held until the timer times out, second time after the drag - * dbg: input.c:1712: BUTTON: pointer=0x607000003660, serial=877, button=110, state=1 - * dbg: input.c:1806: starting move timer - * dbg: input.c:1692: move timer timed out - * dbg: input.c:759: keyboard_leave: keyboard=0x607000003580, serial=878, surface=0x6070000036d0 - * - * --> NOTE: ^^ no pointer leave event this time, only the keyboard leave - * - * --> LMB clicked one last time - * dbg: input.c:697: seat0: keyboard_enter: keyboard=0x607000003580, serial=879, surface=0x6070000036d0 - * dbg: input.c:1712: BUTTON: pointer=0x607000003660, serial=880, button=110, state=1 - * err: input.c:1741: BUG in wl_pointer_button(): assertion failed: 'it->item.button != button' - * - * What are we seeing? - * - * - GNOME does *not* send a pointer *enter* event after the drag - * has stopped - * - The second drag does *not* generate a pointer *leave* event - * - The missing leave event means we’re still tracking LMB as - * being held down in our seat struct. - * - This leads to an assert (debug builds) when LMB is clicked - * again (seat’s button list already contains LMB). - */ - tll_free(seat->mouse.buttons); - win->csd.move_timeout_fd = -1; xdg_toplevel_move(win->xdg_toplevel, seat->wl_seat, win->csd.serial); return true; @@ -1774,6 +1730,62 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, } else seat->mouse.count = 1; + /* + * Workaround GNOME bug + * + * Dragging the window, then stopping the drag (releasing the + * mouse button), *without* moving the mouse, and then + * clicking twice, waiting for the CSD timer, and finally + * clicking once more, results in the following sequence + * (keyboard and other irrelevant events filtered out, unless + * they’re needed to prove a point): + * + * dbg: input.c:1551: cancelling drag timer, moving window + * dbg: input.c:759: keyboard_leave: keyboard=0x607000003580, serial=873, surface=0x6070000036d0 + * dbg: input.c:1432: seat0: pointer-leave: pointer=0x607000003660, serial=874, surface = 0x6070000396e0, old-moused = 0x622000006100 + * + * --> drag stopped here + * + * --> LMB clicked first time after the drag (generates the + * enter event on *release*, but no button events) + * dbg: input.c:1360: pointer-enter: pointer=0x607000003660, serial=876, surface = 0x6070000396e0, new-moused = 0x622000006100 + * + * --> LMB clicked, and held until the timer times out, second + * time after the drag + * dbg: input.c:1712: BUTTON: pointer=0x607000003660, serial=877, button=110, state=1 + * dbg: input.c:1806: starting move timer + * dbg: input.c:1692: move timer timed out + * dbg: input.c:759: keyboard_leave: keyboard=0x607000003580, serial=878, surface=0x6070000036d0 + * + * --> NOTE: ^^ no pointer leave event this time, only the + * keyboard leave + * + * --> LMB clicked one last time + * dbg: input.c:697: seat0: keyboard_enter: keyboard=0x607000003580, serial=879, surface=0x6070000036d0 + * dbg: input.c:1712: BUTTON: pointer=0x607000003660, serial=880, button=110, state=1 + * err: input.c:1741: BUG in wl_pointer_button(): assertion failed: 'it->item.button != button' + * + * What are we seeing? + * + * - GNOME does *not* send a pointer *enter* event after the drag + * has stopped + * - The second drag does *not* generate a pointer *leave* event + * - The missing leave event means we’re still tracking LMB as + * being held down in our seat struct. + * - This leads to an assert (debug builds) when LMB is clicked + * again (seat’s button list already contains LMB). + * + * Note: I’ve also observed variants of the above + */ + tll_foreach(seat->mouse.buttons, it) { + if (it->item.button == button) { + LOG_WARN("multiple button press events for button %d " + "(compositor bug?)", button); + tll_remove(seat->mouse.buttons, it); + break; + } + } + #if defined(_DEBUG) tll_foreach(seat->mouse.buttons, it) xassert(it->item.button != button); @@ -1817,7 +1829,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer, * 4. Release mouse button * 5. BAM! */ - LOG_WARN("stray button release event"); + LOG_WARN("stray button release event (compositor bug?)"); return; } -- cgit v1.3 From 32900207f989d2a1e5e54d75e8c0729cd423e176 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 12 Sep 2021 16:59:23 +0200 Subject: changelog: pgo build scripts --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 57984c49..fef6c13f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,9 @@ * Warn when it appears the primary font is not monospaced. Can be disabled by setting `[tweak].font-monospace-warn=no` (https://codeberg.org/dnkl/foot/issues/704). +* PGO build scripts, in the `pgo` directory. See INSTALL.md - + _Performance optimized, PGO_, for details + (https://codeberg.org/dnkl/foot/issues/701). ### Changed -- cgit v1.3 From b4c759e2de429c20bf07c9e16162d154152014d9 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 2 Sep 2021 14:55:26 +0200 Subject: box-drawing: add braille characters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Render braille ourselves, instead of using font glyphs. Decoding a braille character is easy enough; there are 256 codepoints, represented by an 8-bit integer (i.e. subtract the Unicode codepoint offset, 0x2800, and you’re left with an integer in the range 0-255). Each bit corresponds to a dot. The first 6 bits represent the upper 6 dots, while the two last bits represent the fourth (and last) row of dots. The hard part is sizing the dots and the spacing between them. The aim is to have the spacing between the dots be the same size as the dots themselves, and to have the margins on each side be half the size of the dots. In a perfectly sized cell, this means two braille characters next to each other will be evenly spaced. This is however almost never the case. The layout logic currently: * Set dot size to either the width / 4, or height / 8, depending on which one is smallest. * Horizontal spacing is initialized to the width / 4 * Vertical spacing is initialized to the height / 8 * Horizontal margins are initialized to the horizontal spacing / 2 * Vertical margins are initialized to the vertical spacing / 2. Next, we calculate the number of “remaining” pixels. That is, if we add the left margin, two dots and the spacing between, how many pixels are left on the horizontal axis? These pixels are distributed in the following order (we “stop” as soon as we run out of pixels): * If the dot size is 0 (happens for very small font sizes), increase it to 1. * If the margins are 0, increase them to 1. * If we have enough pixels (need at 2 horizontal and 4 vertical), increase the dot size. * Increase spacing. * Increase margins. Closes #702 --- CHANGELOG.md | 2 ++ box-drawing.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ render.c | 15 +++++++--- terminal.h | 7 +++-- 4 files changed, 105 insertions(+), 7 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index fef6c13f..0b0c2011 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ * PGO build scripts, in the `pgo` directory. See INSTALL.md - _Performance optimized, PGO_, for details (https://codeberg.org/dnkl/foot/issues/701). +* Braille characters (U+2800 - U+28FF) are now rendered by foot + itself (https://codeberg.org/dnkl/foot/issues/702). ### Changed diff --git a/box-drawing.c b/box-drawing.c index f246fd01..a1940392 100644 --- a/box-drawing.c +++ b/box-drawing.c @@ -1953,6 +1953,92 @@ draw_quadrant(struct buf *buf, wchar_t wc) quad_lower_right(buf); } +static void +draw_braille(struct buf *buf, wchar_t wc) +{ + int w = min(buf->width / 4, buf->height / 8); + int x_spacing = buf->width / 4; + int y_spacing = buf->height / 8; + int x_margin = x_spacing / 2; + int y_margin = y_spacing / 2; + + int x_pix_left = buf->width - 2 * x_margin - x_spacing - 2 * w; + int y_pix_left = buf->height - 2 * y_margin - 3 * y_spacing - 4 * w; + + LOG_DBG( + "braille: before adjusting: " + "cell: %dx%d, margin=%dx%d, spacing=%dx%d, width=%d, left=%dx%d", + buf->width, buf->height, x_margin, y_margin, x_spacing, y_spacing, + w, x_pix_left, y_pix_left); + + /* First, try hard to ensure the DOT width is non-zero */ + if (x_pix_left >= 2 && y_pix_left >= 4 && w == 0) { + w++; + x_pix_left -= 2; + y_pix_left -= 4; + } + + /* Second, prefer a non-zero margin */ + if (x_pix_left >= 2 && x_margin == 0) { x_margin = 1; x_pix_left -= 2; } + if (y_pix_left >= 2 && y_margin == 0) { y_margin = 1; y_pix_left -= 2; } + + if (x_pix_left >= 2 && y_pix_left >= 4) { + w++; + x_pix_left -= 2; + y_pix_left -= 4; + } + + if (x_pix_left >= 1) { x_spacing++; x_pix_left--; } + if (y_pix_left >= 3) { y_spacing++; y_pix_left -= 3; } + + if (x_pix_left >= 2) { x_margin++; x_pix_left -= 2; } + if (y_pix_left >= 2) { y_margin++; y_pix_left -= 2; } + + LOG_DBG( + "braille: after adjusting: " + "cell: %dx%d, margin=%dx%d, spacing=%dx%d, width=%d, left=%dx%d", + buf->width, buf->height, x_margin, y_margin, x_spacing, y_spacing, + w, x_pix_left, y_pix_left); + + xassert(x_pix_left <= 1 || y_pix_left <= 1); + xassert(2 * x_margin + 2 * w + x_spacing <= buf->width); + xassert(2 * y_margin + 4 * w + 3 * y_spacing <= buf->height); + + int x[2], y[4]; + x[0] = x_margin; + x[1] = x_margin + w + x_spacing; + y[0] = y_margin; + y[1] = y[0] + w + y_spacing; + y[2] = y[1] + w + y_spacing; + y[3] = y[2] + w + y_spacing; + + assert(wc >= 0x2800); + assert(wc <= 0x28ff); + uint8_t sym = wc - 0x2800; + + /* Left side */ + if (sym & 1) + rect(x[0], y[0], x[0] + w, y[0] + w); + if (sym & 2) + rect(x[0], y[1], x[0] + w, y[1] + w); + if (sym & 4) + rect(x[0], y[2], x[0] + w, y[2] + w); + + /* Right side */ + if (sym & 8) + rect(x[1], y[0], x[1] + w, y[0] + w); + if (sym & 16) + rect(x[1], y[1], x[1] + w, y[1] + w); + if (sym & 32) + rect(x[1], y[2], x[1] + w, y[2] + w); + + /* 8-dot patterns */ + if (sym & 64) + rect(x[0], y[3], x[0] + w, y[3] + w); + if (sym & 128) + rect(x[1], y[3], x[1] + w, y[3] + w); +} + static void sextant_upper_left(struct buf *buf) { @@ -2653,6 +2739,8 @@ draw_glyph(struct buf *buf, wchar_t wc) case 0x2595: draw_right_one_eighth_block(buf); break; case 0x2596 ... 0x259f: draw_quadrant(buf, wc); break; + case 0x2800 ... 0x28ff: draw_braille(buf, wc); break; + case 0x1fb00 ... 0x1fb3b: draw_sextant(buf, wc); break; case 0x1fb3c ... 0x1fb40: diff --git a/render.c b/render.c index cfb6f0bb..1cbff10d 100644 --- a/render.c +++ b/render.c @@ -515,6 +515,9 @@ render_cell(struct terminal *term, pixman_image_t *pix, /* Classic box drawings */ (base >= 0x2500 && base <= 0x259f) || + /* Braille */ + (base >= 0x2800 && base <= 0x28ff) || + /* * Unicode 13 "Symbols for Legacy Computing" * sub-ranges below. @@ -531,9 +534,12 @@ render_cell(struct terminal *term, pixman_image_t *pix, /* Box drawing characters */ size_t idx = base >= 0x1fb00 ? (base >= 0x1fb9a - ? base - 0x1fb9a + 300 - : base - 0x1fb00 + 160) - : base - 0x2500; + ? base - 0x1fb9a + 556 + : base - 0x1fb00 + 416) + : (base >= 0x2800 + ? base - 0x2800 + 160 + : base - 0x2500); + xassert(idx < ALEN(term->box_drawing)); if (likely(term->box_drawing[idx] != NULL)) @@ -541,7 +547,8 @@ render_cell(struct terminal *term, pixman_image_t *pix, else { mtx_lock(&term->render.workers.lock); - /* Parallel thread may have instantiated it while we took the lock */ + /* Other thread may have instantiated it while we + * aquired the lock */ if (term->box_drawing[idx] == NULL) term->box_drawing[idx] = box_drawing(term, base); mtx_unlock(&term->render.workers.lock); diff --git a/terminal.h b/terminal.h index 620678b1..bfb327e3 100644 --- a/terminal.h +++ b/terminal.h @@ -335,10 +335,11 @@ struct terminal { /* * 0-159: U+02500+0259F - * 160-299: U+1FB00-1FB8B - * 300-301: U+1FB9A-1FB9B + * 160-415: U+02800-028FF + * 416-555: U+1FB00-1FB8B + * 556-557: U+1FB9A-1FB9B */ - struct fcft_glyph *box_drawing[302]; + struct fcft_glyph *box_drawing[558]; bool is_sending_paste_data; ptmx_buffer_list_t ptmx_buffers; -- cgit v1.3 From ef7919e64d09d4b29a1557641883e78f5896841d Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Sat, 18 Sep 2021 23:40:40 +0100 Subject: main/client: add no-op "-e" command-line option --- CHANGELOG.md | 5 +++++ client.c | 8 ++++++-- doc/foot.1.scd | 10 ++++++++++ doc/footclient.1.scd | 4 ++++ main.c | 8 ++++++-- 5 files changed, 31 insertions(+), 4 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b0c2011..d229c4ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,9 @@ (https://codeberg.org/dnkl/foot/issues/701). * Braille characters (U+2800 - U+28FF) are now rendered by foot itself (https://codeberg.org/dnkl/foot/issues/702). +* `-e` command-line option. This option is simply ignored, to appease + program launchers that blindly pass `-e` to any terminal emulator + (https://codeberg.org/dnkl/foot/issues/184). ### Changed @@ -67,6 +70,8 @@ ### Security ### Contributors +* [craigbarnes](https://codeberg.org/craigbarnes) + ## 1.9.0 diff --git a/client.c b/client.c index 7cfcb0ef..5c767e11 100644 --- a/client.c +++ b/client.c @@ -71,7 +71,8 @@ print_usage(const char *prog_name) " -o,--override=[section.]key=value override configuration option\n" " -d,--log-level={info|warning|error|none} log level (info)\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"; + " -v,--version show the version number and quit\n" + " -e ignored (for compatibility with xterm -e)\n"; printf("Usage: %s [OPTIONS...]\n", prog_name); printf("Usage: %s [OPTIONS...] command [ARGS...]\n", prog_name); @@ -145,7 +146,7 @@ main(int argc, char *const *argv) struct client_string *cargv = NULL; while (true) { - int c = getopt_long(argc, argv, "+t:T:a:w:W:mFLD:s:HNo:d:l::vh", longopts, NULL); + int c = getopt_long(argc, argv, "+t:T:a:w:W:mFLD:s:HNo:d:l::veh", longopts, NULL); if (c == -1) break; @@ -273,6 +274,9 @@ main(int argc, char *const *argv) ret = EXIT_SUCCESS; goto err; + case 'e': + break; + case '?': goto err; } diff --git a/doc/foot.1.scd b/doc/foot.1.scd index bbe784bc..91a7808a 100644 --- a/doc/foot.1.scd +++ b/doc/foot.1.scd @@ -141,6 +141,16 @@ the foot command line *-v*,*--version* Show the version number and quit. +*-e* + Ignored; for compatibility with *xterm -e*. + + This option was added in response to several program launchers + passing *-e* to arbitrary terminals, under the assumption that + they all implement the same semantics for it as *xterm*(1). + Ignoring it allows foot to be invoked as e.g. *foot -e man foot* + with the same results as with xterm, instead of producing an + "invalid option" error. + # EXIT STATUS Foot will exit with code 230 if there is a failure in foot itself. diff --git a/doc/footclient.1.scd b/doc/footclient.1.scd index b252d5e1..9cb4ef69 100644 --- a/doc/footclient.1.scd +++ b/doc/footclient.1.scd @@ -79,6 +79,10 @@ terminal has terminated. *-v*,*--version* Show the version number and quit +*-e* + Ignored; for compatibility with *xterm -e*. See *foot*(1) for more + details. + # EXIT STATUS Footlient will exit with code 220 if there is a failure in footclient diff --git a/main.c b/main.c index 7d4cbbcf..fd27aebd 100644 --- a/main.c +++ b/main.c @@ -78,7 +78,8 @@ print_usage(const char *prog_name) " -d,--log-level={info|warning|error|none} log level (info)\n" " -l,--log-colorize=[{never|always|auto}] enable/disable colorization of log output on stderr\n" " -s,--log-no-syslog disable syslog logging (only applicable in server mode)\n" - " -v,--version show the version number and quit\n"; + " -v,--version show the version number and quit\n" + " -e ignored (for compatibility with xterm -e)\n"; printf("Usage: %s [OPTIONS...]\n", prog_name); printf("Usage: %s [OPTIONS...] command [ARGS...]\n", prog_name); @@ -216,7 +217,7 @@ main(int argc, char *const *argv) config_override_t overrides = tll_init(); while (true) { - int c = getopt_long(argc, argv, "+c:Co:t:T:a:LD:f:w:W:s::HmFPp:d:l::Svh", longopts, NULL); + int c = getopt_long(argc, argv, "+c:Co:t:T:a:LD:f:w:W:s::HmFPp:d:l::Sveh", longopts, NULL); if (c == -1) break; @@ -375,6 +376,9 @@ main(int argc, char *const *argv) print_usage(prog_name); return EXIT_SUCCESS; + case 'e': + break; + case '?': return ret; } -- cgit v1.3 From fb77637eb96a71de48b49e40fbe7dd71ec85bcbf Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 19 Sep 2021 11:58:34 +0200 Subject: term: only scale using DPI if *all* monitors have a scaling factor or one With dpi-aware=auto (the default), scale fonts using DPI *only* if *all* available monitors have a scaling factor of one. The idea is this: if a user, with multiple monitors, have enabled scaling on *at least* one monitor, he/she has most likely done so to match the size of his/hers other monitors. For example, if the user has one monitor with a scaling factor of one, and another one with a scaling factor of two, he/she expects things to be twice as large on the second monitor. If we (foot) scale using DPI on the first monitor, and using the scaling factor on the second monitor, foot will *not* look twice as big on the second monitor (this was the old behavior of dpi-aware=auto). Part of #714 --- CHANGELOG.md | 3 +++ README.md | 6 +++--- box-drawing.c | 4 ++-- doc/foot.ini.5.scd | 6 ++++-- terminal.c | 59 +++++++++++++++++++++++++++++++++++++----------------- terminal.h | 3 +-- wayland.c | 5 +++++ 7 files changed, 59 insertions(+), 27 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index d229c4ec..c08b29c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,9 @@ still exported, like before. * The default install location for the terminfo definitions have been changed back to `${datadir}/terminfo`. +* `dpi-aware=auto`: fonts are now scaled using the monitor’s DPI only + when **all** monitors have a scaling factor of one + (https://codeberg.org/dnkl/foot/issues/714). ### Deprecated diff --git a/README.md b/README.md index 93d783c4..d90302f8 100644 --- a/README.md +++ b/README.md @@ -347,9 +347,9 @@ This is not how it is meant to be. Fonts are measured in _point sizes_ all mediums, be it printers or monitors, regardless of their DPI. Foot’s default behavior is to use the monitor’s DPI to size fonts when -output scaling has been disabled. On monitors where output scaling has -been enabled, fonts will instead be sized using the scaling -factor. +output scaling has been disabled on **all** monitors. If at least one +monitor has output scaling enabled, fonts will instead by sized using +the scaling factor. This can be changed to either **always** use the monitor’s DPI (regardless of scaling factor), or to **never** use it, with the diff --git a/box-drawing.c b/box-drawing.c index 887aa0c9..3f8a38ef 100644 --- a/box-drawing.c +++ b/box-drawing.c @@ -2837,8 +2837,8 @@ box_drawing(const struct terminal *term, wchar_t wc) abort(); } - double dpi = term_font_sized_by_dpi(term, term->scale) ? term->font_dpi : 96.; - double scale = term_font_sized_by_scale(term, term->scale) ? term->scale : 1.; + double dpi = term->font_is_sized_by_dpi ? term->font_dpi : 96.; + double scale = term->font_is_sized_by_dpi ? 1. : term->scale; double cell_size = sqrt(pow(term->cell_width, 2) + pow(term->cell_height, 2)); int base_thickness = diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index ea4779c5..6bc93cc4 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -161,8 +161,10 @@ in this order: scaling factor *does* double the font size. Finally, if set to *auto*, fonts will be sized using the monitor's - DPI on monitors with a scaling factor of 1, but otherwise using - the scaling factor. + DPI if _all_ monitors have a scaling factor of 1. If at least one + monitor as a scaling factor larger than 1 (regardless of whether + the foot window is mapped on that monitor or not), fonts will be + scaled using the scaling factor. Note that this option typically does not work with bitmap fonts, which only contains a pre-defined set of sizes, and cannot be diff --git a/terminal.c b/terminal.c index e6837977..2738291d 100644 --- a/terminal.c +++ b/terminal.c @@ -813,25 +813,48 @@ get_font_subpixel(const struct terminal *term) return FCFT_SUBPIXEL_DEFAULT; } -bool -term_font_sized_by_dpi(const struct terminal *term, int scale) +static bool +term_font_size_by_dpi(const struct terminal *term) { - return term->conf->dpi_aware == DPI_AWARE_YES || - (term->conf->dpi_aware == DPI_AWARE_AUTO && scale <= 1); -} + switch (term->conf->dpi_aware) { + case DPI_AWARE_YES: return true; + case DPI_AWARE_NO: return false; -bool -term_font_sized_by_scale(const struct terminal *term, int scale) -{ - return !term_font_sized_by_dpi(term, scale); + case DPI_AWARE_AUTO: + /* + * Scale using DPI if all monitors have a scaling factor or 1. + * + * The idea is this: if a user, with multiple monitors, have + * enabled scaling on at least one monitor, then he/she has + * most likely done so to match the size of his/hers other + * monitors. + * + * I.e. if the user has one monitor with a scaling factor of + * one, and another with a scaling factor of two, he/she + * expects things to be twice as large on the second + * monitor. + * + * If we (foot) scale using DPI on the first monitor, and + * using the scaling factor on the second monitor, foot will + * *not* look twice as big on the second monitor. + */ + tll_foreach(term->wl->monitors, it) { + const struct monitor *mon = &it->item; + if (mon->scale > 1) + return false; + } + return true; + } + + BUG("unhandled DPI awareness value"); } int term_pt_or_px_as_pixels(const struct terminal *term, const struct pt_or_px *pt_or_px) { - double scale = term_font_sized_by_scale(term, term->scale) ? term->scale : 1.; - double dpi = term_font_sized_by_dpi(term, term->scale) ? term->font_dpi : 96.; + double scale = !term->font_is_sized_by_dpi ? term->scale : 1.; + double dpi = term->font_is_sized_by_dpi ? term->font_dpi : 96.; return pt_or_px->px == 0 ? round(pt_or_px->pt * scale * dpi / 72) @@ -878,8 +901,7 @@ reload_fonts(struct terminal *term) bool use_px_size = term->font_sizes[i][j].px_size > 0; char size[64]; - const int scale = - term_font_sized_by_scale(term, term->scale) ? term->scale : 1; + const int scale = term->font_is_sized_by_dpi ? 1 : term->scale; if (use_px_size) snprintf(size, sizeof(size), ":pixelsize=%d", @@ -914,7 +936,7 @@ reload_fonts(struct terminal *term) const size_t count_bold_italic = custom_bold_italic ? counts[3] : counts[0]; const char **names_bold_italic = (const char **)(custom_bold_italic ? names[3] : names[0]); - const bool use_dpi = term_font_sized_by_dpi(term, term->scale); + const bool use_dpi = term->font_is_sized_by_dpi; char *attrs[4] = {NULL}; int attr_len[4] = {-1, -1, -1, -1}; /* -1, so that +1 (below) results in 0 */ @@ -2008,8 +2030,8 @@ term_font_dpi_changed(struct terminal *term, int old_scale) float dpi = get_font_dpi(term); xassert(term->scale > 0); - bool was_scaled_using_dpi = term_font_sized_by_dpi(term, old_scale); - bool will_scale_using_dpi = term_font_sized_by_dpi(term, term->scale); + bool was_scaled_using_dpi = term->font_is_sized_by_dpi; + bool will_scale_using_dpi = term_font_size_by_dpi(term); bool need_font_reload = was_scaled_using_dpi != will_scale_using_dpi || @@ -2019,15 +2041,16 @@ term_font_dpi_changed(struct terminal *term, int old_scale) if (need_font_reload) { LOG_DBG("DPI/scale change: DPI-awareness=%s, " - "DPI: %.2f -> %.2f, scale: %d, " + "DPI: %.2f -> %.2f, scale: %d -> %d, " "sizing font based on monitor's %s", term->conf->dpi_aware == DPI_AWARE_AUTO ? "auto" : term->conf->dpi_aware == DPI_AWARE_YES ? "yes" : "no", - term->font_dpi, dpi, term->scale, + term->font_dpi, dpi, old_scale, term->scale, will_scale_using_dpi ? "DPI" : "scaling factor"); } term->font_dpi = dpi; + term->font_is_sized_by_dpi = will_scale_using_dpi; if (!need_font_reload) return true; diff --git a/terminal.h b/terminal.h index 028b4844..b3b4a90e 100644 --- a/terminal.h +++ b/terminal.h @@ -329,6 +329,7 @@ struct terminal { struct config_font *font_sizes[4]; struct pt_or_px font_line_height; float font_dpi; + bool font_is_sized_by_dpi; int16_t font_x_ofs; int16_t font_y_ofs; enum fcft_subpixel font_subpixel; @@ -660,8 +661,6 @@ bool term_font_size_reset(struct terminal *term); bool term_font_dpi_changed(struct terminal *term, int old_scale); void term_font_subpixel_changed(struct terminal *term); -bool term_font_sized_by_dpi(const struct terminal *term, int scale); -bool term_font_sized_by_scale(const struct terminal *term, int scale); int term_pt_or_px_as_pixels( const struct terminal *term, const struct pt_or_px *pt_or_px); diff --git a/wayland.c b/wayland.c index 911694ff..49c8ed92 100644 --- a/wayland.c +++ b/wayland.c @@ -340,6 +340,11 @@ update_terms_on_monitor(struct monitor *mon) tll_foreach(wayl->terms, it) { struct terminal *term = it->item; + if (term->conf->dpi_aware == DPI_AWARE_AUTO) { + update_term_for_output_change(term); + continue; + } + tll_foreach(term->window->on_outputs, it2) { if (it2->item == mon) { update_term_for_output_change(term); -- cgit v1.3 From 548d7be4c60601fe9321d31aa3d8c47c2fa039fe Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Thu, 30 Sep 2021 13:39:23 +0200 Subject: selection: line-wise selection now handles soft line-wrapping Previously, soft-wrapped lines were not selected correctly, as the selection logic was hardcoded to simply select everything between the first and last column on the current terminal row. Now, we scan backward and forward, looking for hard-wrapped lines. This is similar to how word-based selection works. Closes #726 --- CHANGELOG.md | 2 ++ selection.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 85 insertions(+), 16 deletions(-) (limited to 'CHANGELOG.md') diff --git a/CHANGELOG.md b/CHANGELOG.md index c08b29c5..f15256b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ * Added workaround for GNOME bug where multiple button press events (for the same button) is sent to the CSDs without any release or leave events in between (https://codeberg.org/dnkl/foot/issues/709). +* Line-wise selection not taking soft line-wrapping into account + (https://codeberg.org/dnkl/foot/issues/726). ### Security diff --git a/selection.c b/selection.c index b40215e6..b6bae978 100644 --- a/selection.c +++ b/selection.c @@ -378,6 +378,50 @@ selection_find_word_boundary_right(struct terminal *term, struct coord *pos, } } +void +selection_find_line_boundary_left(struct terminal *term, struct coord *pos, + bool spaces_only) +{ + int next_row = pos->row; + pos->col = 0; + + while (true) { + if (--next_row < 0) + return; + + const struct row *row = grid_row_in_view(term->grid, next_row); + assert(row != NULL); + + if (row->linebreak) + return; + + pos->col = 0; + pos->row = next_row; + } +} + +void +selection_find_line_boundary_right(struct terminal *term, struct coord *pos, + bool spaces_only) +{ + int next_row = pos->row; + pos->col = term->cols - 1; + + while (true) { + const struct row *row = grid_row_in_view(term->grid, next_row); + assert(row != NULL); + + if (row->linebreak) + return; + + if (++next_row >= term->rows) + return; + + pos->col = term->cols - 1; + pos->row = next_row; + } +} + void selection_start(struct terminal *term, int col, int row, enum selection_kind kind, @@ -421,13 +465,19 @@ selection_start(struct terminal *term, int col, int row, break; } - case SELECTION_LINE_WISE: - term->selection.start = (struct coord){0, term->grid->view + row}; + case SELECTION_LINE_WISE: { + struct coord start = {0, row}, end = {term->cols - 1, row}; + selection_find_line_boundary_left(term, &start, spaces_only); + selection_find_line_boundary_right(term, &end, spaces_only); + + term->selection.start = (struct coord){ + start.col, term->grid->view + start.row}; term->selection.pivot.start = term->selection.start; - term->selection.pivot.end = (struct coord){term->cols - 1, term->grid->view + row}; + term->selection.pivot.end = (struct coord){end.col, term->grid->view + end.row}; - selection_update(term, term->cols - 1, row); + selection_update(term, end.col, end.row); break; + } case SELECTION_NONE: BUG("Invalid selection kind"); @@ -756,13 +806,21 @@ selection_update(struct terminal *term, int col, int row) case SELECTION_LINE_WISE: switch (term->selection.direction) { - case SELECTION_LEFT: - new_end.col = 0; + case SELECTION_LEFT: { + struct coord end = {0, row}; + selection_find_line_boundary_left( + term, &end, term->selection.spaces_only); + new_end = (struct coord){end.col, term->grid->view + end.row}; break; + } - case SELECTION_RIGHT: - new_end.col = term->cols - 1; + case SELECTION_RIGHT: { + struct coord end = {col, row}; + selection_find_line_boundary_right( + term, &end, term->selection.spaces_only); + new_end = (struct coord){end.col, term->grid->view + end.row}; break; + } case SELECTION_UNDIR: break; @@ -870,6 +928,8 @@ selection_extend_normal(struct terminal *term, int col, int row, } } + const bool spaces_only = term->selection.spaces_only; + switch (term->selection.kind) { case SELECTION_CHAR_WISE: xassert(new_kind == SELECTION_CHAR_WISE); @@ -883,10 +943,8 @@ selection_extend_normal(struct terminal *term, int col, int row, struct coord pivot_start = {new_start.col, new_start.row - term->grid->view}; struct coord pivot_end = pivot_start; - selection_find_word_boundary_left( - term, &pivot_start, term->selection.spaces_only); - selection_find_word_boundary_right( - term, &pivot_end, term->selection.spaces_only); + selection_find_word_boundary_left(term, &pivot_start, spaces_only); + selection_find_word_boundary_right(term, &pivot_end, spaces_only); term->selection.pivot.start = (struct coord){pivot_start.col, term->grid->view + pivot_start.row}; @@ -895,13 +953,22 @@ selection_extend_normal(struct terminal *term, int col, int row, break; } - case SELECTION_LINE_WISE: + case SELECTION_LINE_WISE: { xassert(new_kind == SELECTION_CHAR_WISE || - new_kind == SELECTION_LINE_WISE); + new_kind == SELECTION_LINE_WISE); + + struct coord pivot_start = {new_start.col, new_start.row - term->grid->view}; + struct coord pivot_end = pivot_start; + + selection_find_line_boundary_left(term, &pivot_start, spaces_only); + selection_find_line_boundary_right(term, &pivot_end, spaces_only); - term->selection.pivot.start = (struct coord){0, new_start.row}; - term->selection.pivot.end = (struct coord){term->cols - 1, new_start.row}; + term->selection.pivot.start = + (struct coord){pivot_start.col, term->grid->view + pivot_start.row}; + term->selection.pivot.end = + (struct coord){pivot_end.col, term->grid->view + pivot_end.row}; break; + } case SELECTION_BLOCK: case SELECTION_NONE: -- cgit v1.3