Merge pull request #1477 from Oblomov/dpifallback
Fall back to reported DPI if Xft.dpi is not present
This commit is contained in:
commit
27c3b96a08
4
event.c
4
event.c
|
@ -842,10 +842,14 @@ event_handle_randr_screen_change_notify(xcb_randr_screen_change_notify_event_t *
|
|||
/* Do (part of) what XRRUpdateConfiguration() would do (update our state) */
|
||||
if (ev->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270)) {
|
||||
globalconf.screen->width_in_pixels = ev->height;
|
||||
globalconf.screen->width_in_millimeters = ev->mheight;
|
||||
globalconf.screen->height_in_pixels = ev->width;
|
||||
globalconf.screen->height_in_millimeters = ev->mwidth;
|
||||
} else {
|
||||
globalconf.screen->width_in_pixels = ev->width;
|
||||
globalconf.screen->width_in_millimeters = ev->mwidth;
|
||||
globalconf.screen->height_in_pixels = ev->height;
|
||||
globalconf.screen->height_in_millimeters = ev->mheight;;
|
||||
}
|
||||
|
||||
globalconf.screen_need_refresh = true;
|
||||
|
|
|
@ -83,6 +83,22 @@ function xresources.get_dpi(s)
|
|||
if awesome and awesome.xrdb_get_value then
|
||||
xresources.dpi = tonumber(awesome.xrdb_get_value("", "Xft.dpi"))
|
||||
end
|
||||
-- Following Keith Packard's whitepaper on Xft,
|
||||
-- https://keithp.com/~keithp/talks/xtc2001/paper/xft.html#sec-editing
|
||||
-- the proper fallback for Xft.dpi is the vertical DPI reported by
|
||||
-- the X server. This will generally be 96 on Xorg, unless the user
|
||||
-- has configured it differently
|
||||
if not xresources.dpi then
|
||||
if root then
|
||||
local mm_to_inch = 25.4
|
||||
_, h = root.size()
|
||||
_, hmm = root.size_mm()
|
||||
if hmm ~= 0 then
|
||||
xresources.dpi = round(h*mm_to_inch/hmm)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- ultimate fallback
|
||||
if not xresources.dpi then
|
||||
xresources.dpi = 96
|
||||
end
|
||||
|
|
15
root.c
15
root.c
|
@ -448,6 +448,20 @@ luaA_root_size(lua_State *L)
|
|||
return 2;
|
||||
}
|
||||
|
||||
/** Get the physical size of the root window, in millimeter.
|
||||
*
|
||||
* @return Width of the root window, in millimeters.
|
||||
* @return height of the root window, in millimeters.
|
||||
* @function size_mm
|
||||
*/
|
||||
static int
|
||||
luaA_root_size_mm(lua_State *L)
|
||||
{
|
||||
lua_pushinteger(L, globalconf.screen->width_in_millimeters);
|
||||
lua_pushinteger(L, globalconf.screen->height_in_millimeters);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/** Get the attached tags.
|
||||
* @return A table with all tags.
|
||||
* @function tags
|
||||
|
@ -474,6 +488,7 @@ const struct luaL_Reg awesome_root_lib[] =
|
|||
{ "drawins", luaA_root_drawins },
|
||||
{ "wallpaper", luaA_root_wallpaper },
|
||||
{ "size", luaA_root_size },
|
||||
{ "size_mm", luaA_root_size_mm },
|
||||
{ "tags", luaA_root_tags },
|
||||
{ "__index", luaA_default_index },
|
||||
{ "__newindex", luaA_default_newindex },
|
||||
|
|
Loading…
Reference in New Issue