terminal compositor: move area calculation into impl IndexView
This commit is contained in:
parent
0a1b4c2c23
commit
b62bfa54a0
2 changed files with 21 additions and 40 deletions
|
@ -26,9 +26,6 @@ impl Observer<dyn TerminalView> for CompositeLayer {
|
||||||
*v = view.clone();
|
*v = view.clone();
|
||||||
drop(v);
|
drop(v);
|
||||||
|
|
||||||
//todo: fixme: why does this cause a deadlock?
|
|
||||||
//c.update_range();
|
|
||||||
|
|
||||||
if let Some(old_view) = old_view {
|
if let Some(old_view) = old_view {
|
||||||
if let Some(area) = old_view.area() {
|
if let Some(area) = old_view.area() {
|
||||||
c.cast.notify_each(area);
|
c.cast.notify_each(area);
|
||||||
|
@ -53,32 +50,9 @@ impl Observer<dyn TerminalView> for CompositeLayer {
|
||||||
pub struct TerminalCompositeView {
|
pub struct TerminalCompositeView {
|
||||||
idx_count: usize,
|
idx_count: usize,
|
||||||
layers: HashMap<usize, (Arc<RwLock<CompositeLayer>>, Option<Arc<dyn TerminalView>>)>,
|
layers: HashMap<usize, (Arc<RwLock<CompositeLayer>>, Option<Arc<dyn TerminalView>>)>,
|
||||||
area: Option<Vec<Point2<i16>>>,
|
|
||||||
cast: Arc<RwLock<ObserverBroadcast<dyn TerminalView>>>
|
cast: Arc<RwLock<ObserverBroadcast<dyn TerminalView>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TerminalCompositeView {
|
|
||||||
fn update_range(&mut self) {
|
|
||||||
self.area = Some(Vec::new());
|
|
||||||
|
|
||||||
for (_, layer) in self.layers.iter() {
|
|
||||||
if let Some(view) = layer.1.as_ref() {
|
|
||||||
if let (
|
|
||||||
Some(mut new_area),
|
|
||||||
Some(area)
|
|
||||||
) = (
|
|
||||||
view.area(),
|
|
||||||
self.area.as_mut()
|
|
||||||
) {
|
|
||||||
area.append(&mut new_area);
|
|
||||||
} else {
|
|
||||||
self.area = None;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ImplIndexView for TerminalCompositeView {
|
impl ImplIndexView for TerminalCompositeView {
|
||||||
type Key = Point2<i16>;
|
type Key = Point2<i16>;
|
||||||
type Value = Option<TerminalAtom>;
|
type Value = Option<TerminalAtom>;
|
||||||
|
@ -89,16 +63,6 @@ impl ImplIndexView for TerminalCompositeView {
|
||||||
for idx in 0 .. self.idx_count {
|
for idx in 0 .. self.idx_count {
|
||||||
if let Some(l) = self.layers.get(&idx) {
|
if let Some(l) = self.layers.get(&idx) {
|
||||||
if let Some(view) = l.1.as_ref() {
|
if let Some(view) = l.1.as_ref() {
|
||||||
/*
|
|
||||||
if let Some(range) = view.range() {
|
|
||||||
if pos.x < range.start.x ||
|
|
||||||
pos.x >= range.end.x ||
|
|
||||||
pos.y < range.start.y ||
|
|
||||||
pos.y >= range.end.y {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
match (atom, view.get(pos)) {
|
match (atom, view.get(pos)) {
|
||||||
(None, next) => atom = next,
|
(None, next) => atom = next,
|
||||||
(Some(last), Some(next)) => atom = Some(next.add_style_back(last.style)),
|
(Some(last), Some(next)) => atom = Some(next.add_style_back(last.style)),
|
||||||
|
@ -112,7 +76,25 @@ impl ImplIndexView for TerminalCompositeView {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn area(&self) -> Option<Vec<Point2<i16>>> {
|
fn area(&self) -> Option<Vec<Point2<i16>>> {
|
||||||
self.area.clone()
|
let mut area = Some(Vec::new());
|
||||||
|
|
||||||
|
for (_, layer) in self.layers.iter() {
|
||||||
|
if let Some(view) = layer.1.as_ref() {
|
||||||
|
if let (
|
||||||
|
Some(mut new_area),
|
||||||
|
Some(area)
|
||||||
|
) = (
|
||||||
|
view.area(),
|
||||||
|
area.as_mut()
|
||||||
|
) {
|
||||||
|
area.append(&mut new_area);
|
||||||
|
} else {
|
||||||
|
area = None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
area
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +110,6 @@ impl TerminalCompositor {
|
||||||
TerminalCompositeView {
|
TerminalCompositeView {
|
||||||
idx_count: 0,
|
idx_count: 0,
|
||||||
layers: HashMap::new(),
|
layers: HashMap::new(),
|
||||||
area: None,//Some(Vec::new()),
|
|
||||||
cast: port.get_broadcast()
|
cast: port.get_broadcast()
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub enum TerminalEvent {
|
||||||
|
|
||||||
pub struct Terminal {
|
pub struct Terminal {
|
||||||
writer: Arc<TermOutWriter>,
|
writer: Arc<TermOutWriter>,
|
||||||
observer: Arc<RwLock<TermOutObserver>>,
|
_observer: Arc<RwLock<TermOutObserver>>,
|
||||||
|
|
||||||
events: ChannelReceiver<Vec<TerminalEvent>>,
|
events: ChannelReceiver<Vec<TerminalEvent>>,
|
||||||
_signal_handle: signal_hook_async_std::Handle
|
_signal_handle: signal_hook_async_std::Handle
|
||||||
|
@ -98,7 +98,7 @@ impl Terminal {
|
||||||
|
|
||||||
Terminal {
|
Terminal {
|
||||||
writer,
|
writer,
|
||||||
observer,
|
_observer: observer,
|
||||||
events: event_rx,
|
events: event_rx,
|
||||||
_signal_handle: handle
|
_signal_handle: handle
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue