Remove parking_lot dependency (#2423)
This commit is contained in:
parent
ec7e935248
commit
8729119536
16 changed files with 197 additions and 175 deletions
|
|
@ -3,10 +3,10 @@ use std::{
|
|||
ffi::{CStr, CString},
|
||||
fmt::Debug,
|
||||
os::raw::*,
|
||||
sync::Mutex,
|
||||
};
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ static ATOM_CACHE: Lazy<Mutex<AtomCache>> = Lazy::new(|| Mutex::new(HashMap::wit
|
|||
impl XConnection {
|
||||
pub fn get_atom<T: AsRef<CStr> + Debug>(&self, name: T) -> ffi::Atom {
|
||||
let name = name.as_ref();
|
||||
let mut atom_cache_lock = ATOM_CACHE.lock();
|
||||
let mut atom_cache_lock = ATOM_CACHE.lock().unwrap();
|
||||
let cached_atom = (*atom_cache_lock).get(name).cloned();
|
||||
if let Some(atom) = cached_atom {
|
||||
atom
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ impl XConnection {
|
|||
let cursor = *self
|
||||
.cursor_cache
|
||||
.lock()
|
||||
.unwrap()
|
||||
.entry(cursor)
|
||||
.or_insert_with(|| self.get_cursor(cursor));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use std::sync::Mutex;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
@ -9,11 +10,11 @@ static SUPPORTED_HINTS: Lazy<Mutex<Vec<ffi::Atom>>> =
|
|||
static WM_NAME: Lazy<Mutex<Option<String>>> = Lazy::new(|| Mutex::new(None));
|
||||
|
||||
pub fn hint_is_supported(hint: ffi::Atom) -> bool {
|
||||
(*SUPPORTED_HINTS.lock()).contains(&hint)
|
||||
(*SUPPORTED_HINTS.lock().unwrap()).contains(&hint)
|
||||
}
|
||||
|
||||
pub fn wm_name_is_one_of(names: &[&str]) -> bool {
|
||||
if let Some(ref name) = *WM_NAME.lock() {
|
||||
if let Some(ref name) = *WM_NAME.lock().unwrap() {
|
||||
names.contains(&name.as_str())
|
||||
} else {
|
||||
false
|
||||
|
|
@ -22,8 +23,8 @@ pub fn wm_name_is_one_of(names: &[&str]) -> bool {
|
|||
|
||||
impl XConnection {
|
||||
pub fn update_cached_wm_info(&self, root: ffi::Window) {
|
||||
*SUPPORTED_HINTS.lock() = self.get_supported_hints(root);
|
||||
*WM_NAME.lock() = self.get_wm_name(root);
|
||||
*SUPPORTED_HINTS.lock().unwrap() = self.get_supported_hints(root);
|
||||
*WM_NAME.lock().unwrap() = self.get_wm_name(root);
|
||||
}
|
||||
|
||||
fn get_supported_hints(&self, root: ffi::Window) -> Vec<ffi::Atom> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue