not really sure
This commit is contained in:
parent
2304968de7
commit
1ee395e708
73
src/wm.rs
73
src/wm.rs
|
@ -3,6 +3,7 @@ use std::{
|
||||||
cell::{Cell, RefCell, RefMut},
|
cell::{Cell, RefCell, RefMut},
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
ffi::CString,
|
ffi::CString,
|
||||||
|
hash::{Hash, Hasher},
|
||||||
io::{Error, ErrorKind, Result},
|
io::{Error, ErrorKind, Result},
|
||||||
ptr::{null, null_mut},
|
ptr::{null, null_mut},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
@ -76,6 +77,14 @@ pub struct Client {
|
||||||
window: Window,
|
window: Window,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for Client {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.window == other.window
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for Client {}
|
||||||
|
|
||||||
pub struct XLibState {
|
pub struct XLibState {
|
||||||
display: Display,
|
display: Display,
|
||||||
root: Window,
|
root: Window,
|
||||||
|
@ -350,46 +359,48 @@ impl WMState {
|
||||||
|
|
||||||
match event.get_type() {
|
match event.get_type() {
|
||||||
xlib::MapRequest => {
|
xlib::MapRequest => {
|
||||||
let event = unsafe { &event.map_request };
|
let event = unsafe { &event.map_request };
|
||||||
|
|
||||||
self.mut_state
|
let _ = self.mut_state.try_borrow_mut().and_then(|mut_state| {
|
||||||
.borrow_mut()
|
RefMut::map(mut_state, |t| &mut t.clients)
|
||||||
.clients
|
.entry(event.window)
|
||||||
.entry(event.window)
|
.or_insert_with(|| {
|
||||||
.or_insert_with(|| {
|
unsafe { xlib::XMapWindow(self.dpy(), event.window) };
|
||||||
unsafe { xlib::XMapWindow(self.dpy(), event.window) };
|
Arc::new(Client {
|
||||||
Arc::new(Client {
|
window: event.window,
|
||||||
window: event.window,
|
})
|
||||||
})
|
});
|
||||||
});
|
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
xlib::UnmapNotify => {
|
xlib::UnmapNotify => {
|
||||||
let event = unsafe { &event.unmap };
|
let event = unsafe { &event.unmap };
|
||||||
|
|
||||||
println!("UnmapNotify: {:?}", event.window);
|
println!("UnmapNotify: {:?}", event.window);
|
||||||
|
|
||||||
if event.send_event == 0 {
|
if event.send_event == 0 {
|
||||||
let _ = self.mut_state.try_borrow_mut().and_then(|mut_state| {
|
let _ = self.mut_state.try_borrow_mut().and_then(|mut_state| {
|
||||||
if mut_state.clients.contains_key(&event.window) {
|
if mut_state.clients.contains_key(&event.window) {
|
||||||
RefMut::map(mut_state, |t| &mut t.clients).remove(&event.window);
|
RefMut::map(mut_state, |t| &mut t.clients).remove(&event.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xlib::DestroyNotify => {
|
xlib::DestroyNotify => {
|
||||||
let event = unsafe { &event.destroy_window };
|
let event = unsafe { &event.destroy_window };
|
||||||
|
|
||||||
println!("DestroyNotify: {:?}", event.window);
|
println!("DestroyNotify: {:?}", event.window);
|
||||||
|
|
||||||
let _ = self.mut_state.try_borrow_mut().and_then(|mut_state| {
|
let _ = self.mut_state.try_borrow_mut().and_then(|mut_state| {
|
||||||
if mut_state.clients.contains_key(&event.window) {
|
if mut_state.clients.contains_key(&event.window) {
|
||||||
RefMut::map(mut_state, |t| &mut t.clients).remove(&event.window);
|
RefMut::map(mut_state, |t| &mut t.clients).remove(&event.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
xlib::ConfigureRequest => {
|
xlib::ConfigureRequest => {
|
||||||
let event = unsafe { &event.configure_request };
|
let event = unsafe { &event.configure_request };
|
||||||
|
|
Loading…
Reference in a new issue