diff --git a/callbacks.c b/callbacks.c index 2ce408b..31364ec 100644 --- a/callbacks.c +++ b/callbacks.c @@ -90,13 +90,14 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi .height = zathura_page_get_height(page) * scale }; GtkWidget* page_widget = zathura_page_get_widget(zathura, page); + ZathuraPage* zathura_page_widget = ZATHURA_PAGE(page_widget); gtk_widget_translate_coordinates(page_widget, zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y); if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) { if (zathura_page_get_visibility(page) == false) { zathura_page_set_visibility(page, true); - zathura_page_widget_update_view_time(ZATHURA_PAGE(page_widget)); + zathura_page_widget_update_view_time(zathura_page_widget); zathura_page_cache_add(zathura, zathura_page_get_index(page)); } if (zathura->global.update_page_number == true && updated == false @@ -106,11 +107,13 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi } } else { zathura_page_set_visibility(page, false); + /* If a page becomes invisible, abort all render requests. */ + zathura_page_widget_abort_render_request(zathura_page_widget); /* if the page is not visible and not cached, but still has a surface, we * need to get rid of the surface */ - if (zathura_page_widget_have_surface(ZATHURA_PAGE(page_widget)) == true && + if (zathura_page_widget_have_surface(zathura_page_widget) == true && zathura_page_cache_is_cached(zathura, zathura_page_get_index(page)) == false) { - zathura_page_widget_update_surface(ZATHURA_PAGE(page_widget), NULL); + zathura_page_widget_update_surface(zathura_page_widget, NULL); } girara_list_t* results = NULL; @@ -529,7 +532,8 @@ cb_unknown_command(girara_session_t* session, const char* input) } /* check for number */ - for (unsigned int i = 0; i < strlen(input); i++) { + const size_t size = strlen(input); + for (size_t i = 0; i < size; i++) { if (g_ascii_isdigit(input[i]) == FALSE) { return false; } diff --git a/page-widget.c b/page-widget.c index fea6810..5f5cd32 100644 --- a/page-widget.c +++ b/page-widget.c @@ -24,7 +24,6 @@ typedef struct zathura_page_widget_private_s { zathura_t* zathura; /**< Zathura object */ cairo_surface_t* surface; /**< Cairo surface */ ZathuraRenderRequest* render_request; /* Request object */ - bool render_requested; /**< No surface and rendering has been requested */ gint64 last_view; /**< Last time the page has been viewed */ mutex lock; /**< Lock */ @@ -146,7 +145,6 @@ zathura_page_widget_init(ZathuraPage* widget) zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); priv->page = NULL; priv->surface = NULL; - priv->render_requested = false; priv->render_request = NULL; priv->last_view = g_get_real_time(); @@ -504,10 +502,7 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) } /* render real page */ - if (priv->render_requested == false) { - priv->render_requested = true; - zathura_render_request(priv->render_request, priv->last_view); - } + zathura_render_request(priv->render_request, priv->last_view); } mutex_unlock(&(priv->lock)); return FALSE; @@ -529,11 +524,10 @@ zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface cairo_surface_destroy(priv->surface); priv->surface = NULL; } - priv->render_requested = false; if (surface != NULL) { /* if we're not visible or not cached, we don't care about the surface */ - if (zathura_page_get_visibility(priv->page) == true || - zathura_page_cache_is_cached(priv->zathura, zathura_page_get_index(priv->page)) == true) { + /*if (zathura_page_get_visibility(priv->page) == true || + zathura_page_cache_is_cached(priv->zathura, zathura_page_get_index(priv->page)) == true) */ { priv->surface = surface; cairo_surface_reference(surface); } @@ -919,3 +913,11 @@ zathura_page_widget_have_surface(ZathuraPage* widget) return priv->surface != NULL; } +void +zathura_page_widget_abort_render_request(ZathuraPage* widget) +{ + g_return_if_fail(ZATHURA_IS_PAGE(widget)); + zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); + zathura_render_request_abort(priv->render_request); +} + diff --git a/page-widget.h b/page-widget.h index b9a1c38..08944d1 100644 --- a/page-widget.h +++ b/page-widget.h @@ -96,4 +96,11 @@ void zathura_page_widget_update_view_time(ZathuraPage* widget); */ bool zathura_page_widget_have_surface(ZathuraPage* widget); +/** + * Abort outstanding render requests + * + * @param widget the widget + */ +void zathura_page_widget_abort_render_request(ZathuraPage* widget); + #endif diff --git a/render.c b/render.c index 9c7a4ac..050cc4f 100644 --- a/render.c +++ b/render.c @@ -537,6 +537,7 @@ render(ZathuraRenderRequest* request, ZathuraRenderer* renderer) /* before recoloring, check if we've been aborted */ if (priv->about_to_close == true || request_priv->aborted == true) { + request_priv->requested = false; cairo_surface_destroy(surface); return true; } @@ -581,6 +582,7 @@ render_job(void* data, void* user_data) girara_debug("Rendering page %d ...", zathura_page_get_index(request_priv->page) + 1); if (render(request, renderer) != true) { girara_error("Rendering failed (page %d)\n", zathura_page_get_index(request_priv->page) + 1); + request_priv->requested = false; } } diff --git a/render.h b/render.h index 00d1e07..0963a9e 100644 --- a/render.h +++ b/render.h @@ -177,7 +177,6 @@ void zathura_render_request(ZathuraRenderRequest* request, */ void zathura_render_request_abort(ZathuraRenderRequest* request); - /** * This function is used to unmark all pages as not rendered. This should * be used if all pages should be rendered again (e.g.: the zoom level or the