parent
25d6a1d46d
commit
a87cfb62c3
2 changed files with 16 additions and 5 deletions
|
|
@ -1413,6 +1413,9 @@ impl<T: 'static> EventProcessor<T> {
|
||||||
F: FnMut(Event<T>),
|
F: FnMut(Event<T>),
|
||||||
{
|
{
|
||||||
let wt = get_xtarget(&self.target);
|
let wt = get_xtarget(&self.target);
|
||||||
|
wt.xconn
|
||||||
|
.reload_database()
|
||||||
|
.expect("failed to reload Xft database");
|
||||||
|
|
||||||
// In the future, it would be quite easy to emit monitor hotplug events.
|
// In the future, it would be quite easy to emit monitor hotplug events.
|
||||||
let prev_list = {
|
let prev_list = {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::{
|
||||||
fmt, ptr,
|
fmt, ptr,
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicU32, Ordering},
|
atomic::{AtomicU32, Ordering},
|
||||||
Arc, Mutex,
|
Arc, Mutex, RwLock, RwLockReadGuard,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ pub(crate) struct XConnection {
|
||||||
pub monitor_handles: Mutex<Option<Vec<MonitorHandle>>>,
|
pub monitor_handles: Mutex<Option<Vec<MonitorHandle>>>,
|
||||||
|
|
||||||
/// The resource database.
|
/// The resource database.
|
||||||
database: resource_manager::Database,
|
database: RwLock<resource_manager::Database>,
|
||||||
|
|
||||||
pub latest_error: Mutex<Option<XError>>,
|
pub latest_error: Mutex<Option<XError>>,
|
||||||
pub cursor_cache: Mutex<HashMap<Option<CursorIcon>, ffi::Cursor>>,
|
pub cursor_cache: Mutex<HashMap<Option<CursorIcon>, ffi::Cursor>>,
|
||||||
|
|
@ -115,7 +115,7 @@ impl XConnection {
|
||||||
timestamp: AtomicU32::new(0),
|
timestamp: AtomicU32::new(0),
|
||||||
latest_error: Mutex::new(None),
|
latest_error: Mutex::new(None),
|
||||||
monitor_handles: Mutex::new(None),
|
monitor_handles: Mutex::new(None),
|
||||||
database,
|
database: RwLock::new(database),
|
||||||
cursor_cache: Default::default(),
|
cursor_cache: Default::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -159,8 +159,16 @@ impl XConnection {
|
||||||
|
|
||||||
/// Get the resource database.
|
/// Get the resource database.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn database(&self) -> &resource_manager::Database {
|
pub fn database(&self) -> RwLockReadGuard<'_, resource_manager::Database> {
|
||||||
&self.database
|
self.database.read().unwrap_or_else(|e| e.into_inner())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reload the resource database.
|
||||||
|
#[inline]
|
||||||
|
pub fn reload_database(&self) -> Result<(), super::X11Error> {
|
||||||
|
let database = resource_manager::new_from_default(self.xcb_connection())?;
|
||||||
|
*self.database.write().unwrap_or_else(|e| e.into_inner()) = database;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the latest timestamp.
|
/// Get the latest timestamp.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue