mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-27 01:40:16 -05:00
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.
21d99f8dce 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
This commit is contained in:
parent
50a28fe1e8
commit
86ef638102
3 changed files with 18 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
21
terminal.c
21
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue