improve dirty line management in client tabs
This fixes up a case where a tab was closed and the screen didn't repaint to show the now-current tab.
This commit is contained in:
1 parent
2a91921b6e
commit
2ae68209b7
4 files changed
+19
-5
No files matched your search
@@ -194,6 +194,7 @@ fn main() -> Result<(), Error> {
|
||||
info!("tab {}: {}", tab_id, title);
|
||||
let _data = client.get_coarse_tab_renderable_data(GetCoarseTabRenderableData {
|
||||
tab_id: *tab_id,
|
||||
dirty_all: true,
|
||||
})?;
|
||||
// info!("coarse: {:?}", data);
|
||||
}
|
||||
|
||||
@@ -253,6 +253,7 @@ pub struct ListTabsResponse {
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
pub struct GetCoarseTabRenderableData {
|
||||
pub tab_id: TabId,
|
||||
pub dirty_all: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
|
||||
@@ -105,13 +105,17 @@ impl ClientSession {
|
||||
.wait()?;
|
||||
Pdu::ListTabsResponse(result)
|
||||
}
|
||||
Pdu::GetCoarseTabRenderableData(GetCoarseTabRenderableData { tab_id }) => {
|
||||
Pdu::GetCoarseTabRenderableData(GetCoarseTabRenderableData { tab_id, dirty_all }) => {
|
||||
let result = Future::with_executor(self.executor.clone_executor(), move || {
|
||||
let mux = Mux::get().unwrap();
|
||||
let tab = mux
|
||||
.get_tab(tab_id)
|
||||
.ok_or_else(|| format_err!("no such tab {}", tab_id))?;
|
||||
let mut renderable = tab.renderer();
|
||||
if dirty_all {
|
||||
renderable.make_all_lines_dirty();
|
||||
}
|
||||
|
||||
let dirty_lines = renderable
|
||||
.get_dirty_lines()
|
||||
.iter()
|
||||
|
||||
+12
-4
@@ -39,6 +39,7 @@ impl ClientTab {
|
||||
remote_tab_id,
|
||||
coarse: RefCell::new(None),
|
||||
last_poll: RefCell::new(Instant::now()),
|
||||
dirty_all: RefCell::new(true),
|
||||
};
|
||||
|
||||
let reader = Pipe::new().expect("Pipe::new failed");
|
||||
@@ -155,25 +156,32 @@ struct RenderableState {
|
||||
remote_tab_id: TabId,
|
||||
coarse: RefCell<Option<GetCoarseTabRenderableDataResponse>>,
|
||||
last_poll: RefCell<Instant>,
|
||||
dirty_all: RefCell<bool>,
|
||||
}
|
||||
|
||||
const POLL_INTERVAL: Duration = Duration::from_millis(50);
|
||||
|
||||
impl RenderableState {
|
||||
fn poll(&self) -> Fallible<()> {
|
||||
let last = *self.last_poll.borrow();
|
||||
if last.elapsed() < POLL_INTERVAL {
|
||||
return Ok(());
|
||||
let dirty_all = *self.dirty_all.borrow();
|
||||
|
||||
if !dirty_all {
|
||||
let last = *self.last_poll.borrow();
|
||||
if last.elapsed() < POLL_INTERVAL {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
let mut client = self.client.client.lock().unwrap();
|
||||
let coarse = client.get_coarse_tab_renderable_data(GetCoarseTabRenderableData {
|
||||
tab_id: self.remote_tab_id,
|
||||
dirty_all,
|
||||
})?;
|
||||
self.coarse.borrow_mut().replace(coarse);
|
||||
}
|
||||
*self.last_poll.borrow_mut() = Instant::now();
|
||||
*self.dirty_all.borrow_mut() = false;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -219,7 +227,7 @@ impl Renderable for RenderableState {
|
||||
}
|
||||
|
||||
fn make_all_lines_dirty(&mut self) {
|
||||
// this is implicit as part of the poll
|
||||
*self.dirty_all.borrow_mut() = true;
|
||||
}
|
||||
|
||||
fn clean_dirty_lines(&mut self) {
|
||||
|
||||
Reference in new issue
Block a user