On X11, reload DPI on _XSETTINGS_SETTINGS

This also fixes the deadlock when such reload may happen.

Fixes: #3383
Signed-off-by: John Nunley <dev@notgull.net>
Signed-off-by: Kirill Chibisov <contact@kchibisov.com>
This commit is contained in:
John Nunley 2024-01-30 04:52:29 -08:00 committed by GitHub
parent db1ca45a17
commit df8805c0d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 439 additions and 19 deletions

View file

@ -38,6 +38,15 @@ pub fn calc_dpi_factor(
impl XConnection {
// Retrieve DPI from Xft.dpi property
pub fn get_xft_dpi(&self) -> Option<f64> {
// Try to get it from XSETTINGS first.
match self.xsettings_dpi() {
Ok(Some(dpi)) => return Some(dpi),
Ok(None) => {}
Err(err) => {
log::warn!("failed to fetch XSettings: {err}");
}
}
self.database()
.get_string("Xft.dpi", "")
.and_then(|s| f64::from_str(s).ok())