2 * vim:ts=4:sw=4:expandtab
4 * i3 - an improved dynamic tiling window manager
5 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
12 * Convert a logical amount of pixels (e.g. 2 pixels on a “standard” 96 DPI
13 * screen) to a corresponding amount of physical pixels on a standard or retina
14 * screen, e.g. 5 pixels on a 227 DPI MacBook Pro 13" Retina screen.
17 int logical_px(const int logical) {
18 if (root_screen == NULL) {
19 /* Dpi info may not be available when parsing a config without an X
20 * server, such as for config file validation. */
24 const int dpi = (double)root_screen->height_in_pixels * 25.4 /
25 (double)root_screen->height_in_millimeters;
26 /* There are many misconfigurations out there, i.e. systems with screens
27 * whose dpi is in fact higher than 96 dpi, but not significantly higher,
28 * so software was never adapted. We could tell people to reconfigure their
29 * systems to 96 dpi in order to get the behavior they expect/are used to,
30 * but since we can easily detect this case in code, let’s do it for them.
32 if ((dpi / 96.0) < 1.25)
34 return ceil((dpi / 96.0) * logical);