mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
wayland: estimate scaled (logical) width/height, if not provided
This makes us slightly more resilient against a missing XDG output interface. We use the “real” (the physical) dimensions, combined with the scaling factor, to estimate the logical dimensions. This works out correctly with non-fractional scaling, but not otherwise.
This commit is contained in:
parent
fe851a6936
commit
97174913e0
1 changed files with 11 additions and 5 deletions
16
wayland.c
16
wayland.c
|
|
@ -385,13 +385,19 @@ output_update_ppi(struct monitor *mon)
|
|||
break;
|
||||
}
|
||||
|
||||
mon->ppi.scaled.x = mon->dim.px_scaled.width / x_inches;
|
||||
mon->ppi.scaled.y = mon->dim.px_scaled.height / y_inches;
|
||||
int scaled_width = mon->dim.px_scaled.width;
|
||||
int scaled_height = mon->dim.px_scaled.height;
|
||||
|
||||
float px_diag = sqrt(
|
||||
pow(mon->dim.px_scaled.width, 2) +
|
||||
pow(mon->dim.px_scaled.height, 2));
|
||||
if (scaled_width == 0 && scaled_height == 0 && mon->scale > 0) {
|
||||
/* Estimate scaled width/height if none has been provided */
|
||||
scaled_width = mon->dim.px_real.width / mon->scale;
|
||||
scaled_height = mon->dim.px_real.height / mon->scale;
|
||||
}
|
||||
|
||||
mon->ppi.scaled.x = scaled_width / x_inches;
|
||||
mon->ppi.scaled.y = scaled_height / y_inches;
|
||||
|
||||
float px_diag = sqrt(pow(scaled_width, 2) + pow(scaled_height, 2));
|
||||
mon->dpi = px_diag / mon->inch * mon->scale;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue