aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-08-18 14:39:00 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-08-18 14:48:18 +0000
commit86ef638102a6e03a5f46326162376c964ad353af (patch)
tree4ec30d8544575e39c898a28d4681408440516ede
parentci: replace 'pipeline' with 'steps' (diff)
term: improve fallback logic when selecting scaling factor while unmapped
The foot window may, for various reasons, become completely unmapped (that is, being removed from all outputs) at run time. One example is wlroots based compositors; they unmap all other windows when an opaque window is fullscreened. 21d99f8dced335826964ca96b8ba7ccac059e598 introduced a regression, where instead of picking the scaling factor from one of the available outputs (at random), we started falling back to '1' as soon as we were unmapped. This patch restores the original logic, but also improves upon it. As soon as a scaling factor has been assigned to the window, we store a copy of it in the term struct ('scale_before_unmap'). When unmapped, we check if it has a valid value (the only time it doesn't is before the initial map). If so, we use it. Only if it hasn't been set do we fall back to picking an output at random, and using its scaling factor. Closes #1464
-rw-r--r--CHANGELOG.md3
-rw-r--r--terminal.c21
-rw-r--r--terminal.h1
3 files changed, 18 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f2272050..00d66919 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -74,8 +74,11 @@
* Race condition for systemd units start in GNOME and KDE
([#1436][1436]).
+* One frame being rendered at the wrong scale after being hidden by
+ another opaque, maximized window ([#1464][1464]).
[1436]: https://codeberg.org/dnkl/foot/issues/1436
+[1464]: https://codeberg.org/dnkl/foot/issues/1464
### Security
diff --git a/terminal.c b/terminal.c
index 2f81adc8..f19da873 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1161,6 +1161,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
.auto_margin = true,
.window_title_stack = tll_init(),
.scale = 1.,
+ .scale_before_unmap = -1,
.flash = {.fd = flash_fd},
.blink = {.fd = -1},
.vt = {
@@ -2094,21 +2095,27 @@ term_update_scale(struct terminal *term)
*
* - “preferred” scale, from the fractional-scale-v1 protocol
* - scaling factor of output we most recently were mapped on
- * - if we’re not mapped, use the scaling factor from the first
- * available output.
+ * - if we're not mapped, use the last known scaling factor
+ * - if we're not mapped, and we don't have a last known scaling
+ * factor, use the scaling factor from the first available
+ * output.
* - if there aren’t any outputs available, use 1.0
*/
- const float new_scale =
- (term_fractional_scaling(term)
- ? win->scale
- : (tll_length(win->on_outputs) > 0
+ const float new_scale = (term_fractional_scaling(term)
+ ? win->scale
+ : tll_length(win->on_outputs) > 0
? tll_back(win->on_outputs)->scale
- : 1.));
+ : term->scale_before_unmap > 0.
+ ? term->scale_before_unmap
+ : tll_length(term->wl->monitors) > 0
+ ? tll_front(term->wl->monitors).scale
+ : 1.);
if (new_scale == term->scale)
return false;
LOG_DBG("scaling factor changed: %.2f -> %.2f", term->scale, new_scale);
+ term->scale_before_unmap = new_scale;
term->scale = new_scale;
return true;
}
diff --git a/terminal.h b/terminal.h
index 25019ecd..0bba6945 100644
--- a/terminal.h
+++ b/terminal.h
@@ -489,6 +489,7 @@ struct terminal {
} blink;
float scale;
+ float scale_before_unmap; /* Last scaling factor used */
int width; /* pixels */
int height; /* pixels */
int stashed_width;