wayland: calculate output PPI (pixels-per-inch)

This commit is contained in:
Daniel Eklöf 2019-11-26 18:55:03 +01:00
parent bc86cd61c7
commit 204bfa02f4
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 12 additions and 3 deletions

View file

@ -113,6 +113,12 @@ output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
static void
output_done(void *data, struct wl_output *wl_output)
{
struct monitor *mon = data;
int x_inches = mon->width_mm * 0.03937008;
int y_inches = mon->height_mm * 0.03937008;
mon->x_ppi = mon->width_px / x_inches;
mon->y_ppi = mon->height_px / y_inches;
}
static void
@ -531,11 +537,11 @@ wayl_init(struct fdm *fdm)
if (wayl->primary_selection_device_manager == NULL)
LOG_WARN("no primary selection available");
tll_foreach(wayl->monitors, it) {
LOG_INFO("%s: %dx%d+%dx%d (scale=%d, refresh=%.2fHz)",
LOG_INFO("%s: %dx%d+%dx%d (PPI=%dx%d, refresh=%.2fHz, scale=%d)",
it->item.name, it->item.width_px, it->item.height_px,
it->item.x, it->item.y, it->item.scale, it->item.refresh);
it->item.x, it->item.y, it->item.x_ppi, it->item.y_ppi,
it->item.refresh, it->item.scale);
}
/* Clipboard */

View file

@ -27,6 +27,9 @@ struct monitor {
int width_px;
int height_px;
int x_ppi;
int y_ppi;
int scale;
float refresh;
};