From 2ea32398c3e1b8c19d0b18ad0cde6c46d71658c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 29 Jun 2020 21:51:53 +0200 Subject: [PATCH 1/5] term: use 'left_ptr' instead of 'hand2' as cursor when client is mouse grabbing --- CHANGELOG.md | 2 ++ terminal.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8691a3f..e3ff8016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,8 @@ debug logging has been enabled. * OSC 4 (_Set Color_) now updates already rendered cells, excluding scrollback. +* Mouse cursor from `hand2` to `left_ptr` when client is capturing the + mouse. ### Deprecated diff --git a/terminal.c b/terminal.c index 504dec57..b7a49375 100644 --- a/terminal.c +++ b/terminal.c @@ -36,7 +36,7 @@ static const char *const XCURSOR_LEFT_PTR = "left_ptr"; static const char *const XCURSOR_TEXT = "text"; -static const char *const XCURSOR_HAND2 = "hand2"; +//static const char *const XCURSOR_HAND2 = "hand2"; bool term_to_slave(struct terminal *term, const void *_data, size_t len) @@ -2204,9 +2204,9 @@ void term_xcursor_update(struct terminal *term) { term->xcursor = - term->is_searching ? XCURSOR_LEFT_PTR : + term->is_searching ? XCURSOR_LEFT_PTR : /* TODO: something different? */ selection_enabled(term) ? XCURSOR_TEXT : - XCURSOR_HAND2; + XCURSOR_LEFT_PTR; render_xcursor_set(term); } From a6d35d41c441f445293f51038dbc895389e13c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 29 Jun 2020 21:52:32 +0200 Subject: [PATCH 2/5] changelog: make it easier to read --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3ff8016..f0e750e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ * Background transparency to only be used with the default background color. -* Copy to clipboard/primary selection to insert a line break if either +* Copy-to-clipboard/primary-selection to insert a line break if either the last cell on the previous line or the first cell on the next line is empty. * Number of lines to scroll is now always clamped to the number of From b56dbfa8549deb4d26c1de232ab8d47741507cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 29 Jun 2020 21:52:50 +0200 Subject: [PATCH 3/5] changelog: 'capturing mouse events' -> 'capturing the mouse' --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0e750e2..76c05240 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ ### Fixed * Do not stop an ongoing selection when `shift` is released. When the - client application is capturing mouse events, one must hold down + client application is capturing the mouse, one must hold down `shift` to start a selection. This selection is now finalized only when the mouse button is released - not as soon as `shift` is released. From 2c4ebec4dab82f74f7442c307a09e8006bf814fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 29 Jun 2020 21:53:07 +0200 Subject: [PATCH 4/5] changelog: slave -> client --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76c05240..3ad5522b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,12 +53,12 @@ * Rare crash when scrolling and the new viewport ended up **exactly** on the wrap around. * Selection handling when viewport wrapped around. -* Restore signal mask in the slave process. +* Restore signal mask in the client process. * Set `IUTF8`. * Selection of double-width characters. It is no longer possible to select half of a double-width character. * Draw hollow block cursor on top of character. -* Set an initial `TIOCSWINSZ`. This ensures clients never reads a +* Set an initial `TIOCSWINSZ`. This ensures clients never read a `0x0` terminal size (https://codeberg.org/dnkl/foot/issues/20). * Glyphs overflowing into surrounding cells (https://codeberg.org/dnkl/foot/issues/21). From 8f5e6e85e0401a0071814c6dac7f16adb3b0b6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 29 Jun 2020 21:53:29 +0200 Subject: [PATCH 5/5] sixel: destroy all sixels when font size is decreased If changing the font size causes the cell size to decrease, either horizontally or vertically (or both), then delete all sixels since the grid space they allocated no longer is enough to hold the images. --- CHANGELOG.md | 1 + sixel.c | 11 +++++++++++ sixel.h | 1 + terminal.c | 25 ++++++++++++++++++++++++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ad5522b..6ba2ef59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ scrollback. * Mouse cursor from `hand2` to `left_ptr` when client is capturing the mouse. +* Sixel images are now removed when the font size is **decreased**. ### Deprecated diff --git a/sixel.c b/sixel.c index a4b27416..80ac3843 100644 --- a/sixel.c +++ b/sixel.c @@ -66,6 +66,17 @@ sixel_destroy(struct sixel *sixel) sixel->data = NULL; } +void +sixel_destroy_all(struct terminal *term) +{ + tll_foreach(term->normal.sixel_images, it) + sixel_destroy(&it->item); + tll_foreach(term->alt.sixel_images, it) + sixel_destroy(&it->item); + tll_free(term->normal.sixel_images); + tll_free(term->alt.sixel_images); +} + static void sixel_erase(struct terminal *term, struct sixel *sixel) { diff --git a/sixel.h b/sixel.h index bb3eb730..fc59d6e9 100644 --- a/sixel.h +++ b/sixel.h @@ -11,6 +11,7 @@ void sixel_put(struct terminal *term, uint8_t c); void sixel_unhook(struct terminal *term); void sixel_destroy(struct sixel *sixel); +void sixel_destroy_all(struct terminal *term); /* * Deletes all sixels that are touched by the specified row(s). Used diff --git a/terminal.c b/terminal.c index b7a49375..c3a36b45 100644 --- a/terminal.c +++ b/terminal.c @@ -1423,7 +1423,30 @@ term_font_size_adjust(struct terminal *term, double amount) return false; } - term_set_fonts(term, (struct fcft_font *[]){data[0].font_out, data[1].font_out, data[2].font_out, data[3].font_out}); + const int old_cell_width = term->cell_width; + const int old_cell_height = term->cell_height; + + if (!term_set_fonts(term, (struct fcft_font *[]){data[0].font_out, data[1].font_out, data[2].font_out, data[3].font_out})) + return false; + + if (term->cell_width < old_cell_width || + term->cell_height < old_cell_height) + { + /* + * The cell size has decreased. + * + * This means sixels, which we cannot resize, no longer fit + * into their "allocated" grid space. + * + * To be able to fit them, we would have to change the grid + * content. Inserting empty lines _might_ seem acceptable, but + * we'd also need to insert empty columns, which would break + * existing layout completely. + * + * So we delete them. + */ + sixel_destroy_all(term); + } return true; }