aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-26 17:55:03 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-26 18:02:35 +0000
commit204bfa02f453dc931b0491f0f6f8313ad9183944 (patch)
tree94a9d3b723f2f34e4263b6152b983a44b5fe77fa
parentfont: move metrics from terminal struct to font struct (diff)
wayland: calculate output PPI (pixels-per-inch)
-rw-r--r--wayland.c12
-rw-r--r--wayland.h3
2 files changed, 12 insertions, 3 deletions
diff --git a/wayland.c b/wayland.c
index dd813250..c7720404 100644
--- a/wayland.c
+++ b/wayland.c
@@ -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 */
diff --git a/wayland.h b/wayland.h
index 951a0ece..cbcedc1a 100644
--- a/wayland.h
+++ b/wayland.h
@@ -27,6 +27,9 @@ struct monitor {
int width_px;
int height_px;
+ int x_ppi;
+ int y_ppi;
+
int scale;
float refresh;
};