Initial, guessed, scaling factor not corrected when wrong #509

Closed
opened 5 months ago by dnkl · 2 comments
dnkl commented 5 months ago
Owner

I'm experiencing huge fonts when waking from suspend on a multi-monitor and mixed-scaling setup on Sway 1.6 with wlroots 0.13. That wlroots version should include the fix mentioned above, but I'm experiencing practically the same buggy behavior, so I'm posting here.

Here are my WAYLAND_DEBUG=1 foot logs, before and after suspend. I tend to use kanshi to configure outputs via hotplugging, but I killed it before suspending, to make sure it wasn't a bug there.

Originally posted by @mvdan in #182

I'm experiencing huge fonts when waking from suspend on a multi-monitor and mixed-scaling setup on Sway 1.6 with wlroots 0.13. That wlroots version should include the fix mentioned above, but I'm experiencing practically the same buggy behavior, so I'm posting here. Here are my `WAYLAND_DEBUG=1 foot` logs, before and after suspend. I tend to use kanshi to configure outputs via hotplugging, but I killed it before suspending, to make sure it wasn't a bug there. _Originally posted by @mvdan in https://codeberg.org/dnkl/foot/issues/182#issuecomment-197852_
Poster
Owner

See #182

See https://codeberg.org/dnkl/foot/issues/182#issuecomment-198024
Poster
Owner

@mvdan here's a POC patch that I think should fix your issue. Unless I can get rid of one of term->scale and term->font_scale, a cleaned up version of this will be the final fix:

diff --git a/terminal.c b/terminal.c
index f3513a0..0002823 100644
--- a/terminal.c
+++ b/terminal.c
@@ -730,10 +730,11 @@ get_font_scale(const struct terminal *term)
     /* Same as get_font_dpi(), but returns output scale factor instead */
     int scale = 0;
 
-    xassert(term->window != NULL);
-    tll_foreach(term->window->on_outputs, it) {
-        if (it->item->scale > scale)
-            scale = it->item->scale;
+    if (term->window != NULL) {
+        tll_foreach(term->window->on_outputs, it) {
+            if (it->item->scale > scale)
+                scale = it->item->scale;
+        }
     }
 
     if (scale == 0) {
@@ -1179,12 +1180,15 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
 
     reaper_add(term->reaper, term->slave, &slave_died, term);
 
+#if 0
     /* Guess scale; we're not mapped yet, so we don't know on which
      * output we'll be. Pick highest scale we find for now */
     tll_foreach(term->wl->monitors, it) {
         if (it->item.scale > term->scale)
             term->scale = it->item.scale;
     }
+#endif
+    term->scale = get_font_scale(term);
 
     memcpy(term->colors.table, term->conf->colors.table,
            sizeof(term->colors.table));
@mvdan here's a POC patch that I _think_ should fix your issue. Unless I can get rid of one of `term->scale` and `term->font_scale`, a cleaned up version of this will be the final fix: ```diff diff --git a/terminal.c b/terminal.c index f3513a0..0002823 100644 --- a/terminal.c +++ b/terminal.c @@ -730,10 +730,11 @@ get_font_scale(const struct terminal *term) /* Same as get_font_dpi(), but returns output scale factor instead */ int scale = 0; - xassert(term->window != NULL); - tll_foreach(term->window->on_outputs, it) { - if (it->item->scale > scale) - scale = it->item->scale; + if (term->window != NULL) { + tll_foreach(term->window->on_outputs, it) { + if (it->item->scale > scale) + scale = it->item->scale; + } } if (scale == 0) { @@ -1179,12 +1180,15 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper, reaper_add(term->reaper, term->slave, &slave_died, term); +#if 0 /* Guess scale; we're not mapped yet, so we don't know on which * output we'll be. Pick highest scale we find for now */ tll_foreach(term->wl->monitors, it) { if (it->item.scale > term->scale) term->scale = it->item.scale; } +#endif + term->scale = get_font_scale(term); memcpy(term->colors.table, term->conf->colors.table, sizeof(term->colors.table)); ```
dnkl added the
bug
label 5 months ago
dnkl referenced this issue from a commit 5 months ago
dnkl closed this issue 5 months ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.