wayland: include more output (monitor) details in the log output

This commit is contained in:
Daniel Eklöf 2019-12-05 19:35:34 +01:00
parent 8dc9560431
commit db1d913ba8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 26 additions and 10 deletions

View file

@ -92,6 +92,15 @@ static const struct wl_seat_listener seat_listener = {
.name = seat_handle_name,
};
static void
output_update_ppi(struct monitor *mon)
{
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
output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
int32_t physical_width, int32_t physical_height,
@ -101,6 +110,10 @@ output_geometry(void *data, struct wl_output *wl_output, int32_t x, int32_t y,
struct monitor *mon = data;
mon->width_mm = physical_width;
mon->height_mm = physical_height;
mon->inch = sqrt(pow(mon->width_mm, 2) + pow(mon->height_mm, 2)) * 0.03937008;
mon->make = make != NULL ? strdup(make) : NULL;
mon->model = model != NULL ? strdup(model) : NULL;
output_update_ppi(mon);
}
static void
@ -117,12 +130,6 @@ 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
@ -162,6 +169,7 @@ xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output,
struct monitor *mon = data;
mon->width_px = width;
mon->height_px = height;
output_update_ppi(mon);
}
static void
@ -543,10 +551,12 @@ wayl_init(struct fdm *fdm)
LOG_WARN("no primary selection available");
tll_foreach(wayl->monitors, it) {
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.x_ppi, it->item.y_ppi,
it->item.refresh, it->item.scale);
LOG_INFO(
"%s: %dx%d+%dx%d@%dHz %s (%.2f\", PPI=%dx%d, scale=%d)",
it->item.name, it->item.width_px, it->item.height_px,
it->item.x, it->item.y, (int)round(it->item.refresh), it->item.model, it->item.inch,
it->item.x_ppi, it->item.y_ppi,
it->item.scale);
}
/* Clipboard */
@ -635,6 +645,8 @@ wayl_destroy(struct wayland *wayl)
zxdg_output_v1_destroy(it->item.xdg);
if (it->item.output != NULL)
wl_output_destroy(it->item.output);
free(it->item.make);
free(it->item.model);
tll_remove(wayl->monitors, it);
}

View file

@ -33,6 +33,10 @@ struct monitor {
int scale;
float refresh;
char *make;
char *model;
float inch; /* e.g. 24" */
};
struct kbd {