diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-12-13 18:15:17 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-12-13 18:15:17 +0000 |
| commit | 97174913e09db464d3020c50cbf223d2fe823d3d (patch) | |
| tree | cb33fde7043746f2b408f4b7d39cab0663eda6de | |
| parent | input: kitty: return the result of term_to_slave() (diff) | |
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.
| -rw-r--r-- | wayland.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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; } |
