aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-02-07 12:23:56 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-02-07 12:23:56 +0000
commit3baf7de3b8e313a008d248a39175c0cad58d08fd (patch)
tree354f8a3e4e2030e23aeaf7a5fc16523ed9d3aeee
parentchangelog: “(null)” being logged as font-name (diff)
parentchangelog: mouse selections are finalized on window resize (diff)
Merge branch 'finalize-selection-on-window-resize'
Closes #922
-rw-r--r--CHANGELOG.md7
-rw-r--r--render.c16
-rw-r--r--terminal.c4
3 files changed, 27 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c2377b4c..abc72229 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -40,6 +40,11 @@
## Unreleased
### Added
### Changed
+
+* Mouse selections are now finalized when the window is resized
+ (https://codeberg.org/dnkl/foot/issues/922).
+
+
### Deprecated
### Removed
### Fixed
@@ -48,6 +53,8 @@
(https://codeberg.org/dnkl/foot/issues/918).
* “(null)” being logged as font-name (for some fonts) when warning
about a non-monospaced primary font.
+* Rare crash when the window is resized while a mouse selection is
+ ongoing (https://codeberg.org/dnkl/foot/issues/922).
### Security
diff --git a/render.c b/render.c
index 024d0954..953ec4da 100644
--- a/render.c
+++ b/render.c
@@ -3681,7 +3681,23 @@ maybe_resize(struct terminal *term, int width, int height, bool force)
if (term->grid == &term->alt)
selection_cancel(term);
+ else {
+ /*
+ * Don’t cancel, but make sure there aren’t any ongoing
+ * selections after the resize.
+ */
+ tll_foreach(term->wl->seats, it) {
+ if (it->item.kbd_focus == term)
+ selection_finalize(&it->item, term, it->item.pointer.serial);
+ }
+ }
+ /*
+ * TODO: if we remove the selection_finalize() call above (i.e. if
+ * we start allowing selections to be ongoing across resizes), the
+ * selection’s pivot point coordinates *must* be added to the
+ * tracking points list.
+ */
struct coord *const tracking_points[] = {
&term->selection.start,
&term->selection.end,
diff --git a/terminal.c b/terminal.c
index 3b935909..81df743b 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1158,6 +1158,10 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.selection = {
.start = {-1, -1},
.end = {-1, -1},
+ .pivot = {
+ .start = {-1, -1},
+ .end = {-1, -1},
+ },
.auto_scroll = {
.fd = -1,
},