Fix initial pages being not rendered in max res

This commit is contained in:
Julian Mutter 2023-11-23 12:40:28 +01:00
parent 1a7f7498cd
commit 9240db298d
2 changed files with 6 additions and 6 deletions

View File

@ -253,6 +253,9 @@ where
// Besides the name, it is not in another thread
glib::spawn_future_local(async move {
while command_receiver.is_channel_open() {
// Add delay to tell gtk to give rendering priority
timeout_future(Duration::from_millis(1)).await;
if let Some(command) = command_receiver.receive_most_important_command() {
if let Some(response) = cache.process_command(command).unwrap_or_else(|e| {
error!("Error processing command: {}", e);
@ -264,9 +267,6 @@ where
debug!("receiver done");
}
}
// Add delay to tell gtk to give rendering priority
timeout_future(Duration::from_millis(1)).await;
}
});

View File

@ -294,7 +294,7 @@ pub fn load_document(file: impl AsRef<Path>, ui: Rc<RefCell<Ui>>) {
cache::CacheResponse::SinglePageRetrieved { page } => {
ui.borrow_mut().image_left.set_paintable(Some(page.as_ref()));
ui.borrow_mut().image_right.set_visible(false);
let area_height = ui.borrow().image_left.height();
let area_height = ui.borrow().image_container.height();
ui.borrow().document_canvas.as_ref().unwrap().cache_surrounding_pages(area_height);
}
cache::CacheResponse::TwoPagesRetrieved {
@ -304,7 +304,7 @@ pub fn load_document(file: impl AsRef<Path>, ui: Rc<RefCell<Ui>>) {
ui.borrow_mut().image_left.set_paintable(Some(page_left.as_ref()));
ui.borrow_mut().image_right.set_paintable(Some(page_right.as_ref()));
ui.borrow_mut().image_right.set_visible(true);
let area_height = ui.borrow().image_left.height();
let area_height = ui.borrow().image_container.height();
ui.borrow().document_canvas.as_ref().unwrap().cache_surrounding_pages(area_height);
},
cache::CacheResponse::PageResolutionUpgraded { page_number, page } => {
@ -319,7 +319,7 @@ pub fn load_document(file: impl AsRef<Path>, ui: Rc<RefCell<Ui>>) {
let mut document_canvas = DocumentCanvas::new(sender);
document_canvas.num_pages = Some(num_pages);
document_canvas.cache_initial_pages(ui.borrow().image_left.height());
document_canvas.cache_initial_pages(ui.borrow().image_container.height());
ui.borrow_mut().document_canvas = Some(document_canvas);