diff --git a/render.c b/render.c index 913f463..6f22d61 100644 --- a/render.c +++ b/render.c @@ -600,8 +600,14 @@ render(ZathuraRenderRequest* request, ZathuraRenderer* renderer) /* create cairo surface */ unsigned int page_width = 0; unsigned int page_height = 0; - const double real_scale = page_calc_height_width(page, &page_height, - &page_width, false); + + zathura_document_t* document = zathura_page_get_document(page); + double height = zathura_page_get_height(page); + double width = zathura_page_get_width(page); + + const double real_scale = page_calc_height_width(document, height, width, + &page_height, &page_width, false); + cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, page_width, page_height); @@ -705,7 +711,9 @@ render_all(zathura_t* zathura) zathura_page_t* page = zathura_document_get_page(zathura->document, page_id); unsigned int page_height = 0, page_width = 0; - page_calc_height_width(page, &page_height, &page_width, true); + double height = zathura_page_get_height(page); + double width = zathura_page_get_width(page); + page_calc_height_width(zathura->document, height, width, &page_height, &page_width, true); GtkWidget* widget = zathura_page_get_widget(zathura, page); gtk_widget_set_size_request(widget, page_width, page_height); diff --git a/utils.c b/utils.c index e92c8f3..363245e 100644 --- a/utils.c +++ b/utils.c @@ -241,17 +241,11 @@ error_ret: } double -page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned int* page_width, bool rotate) +page_calc_height_width(zathura_document_t* document, double height, double width, + unsigned int* page_height, unsigned int* page_width, bool rotate) { - g_return_val_if_fail(page != NULL && page_height != NULL && page_width != NULL, 0.0); + g_return_val_if_fail(document != NULL && page_height != NULL && page_width != NULL, 0.0); - zathura_document_t* document = zathura_page_get_document(page); - if (document == NULL) { - return 0.0; - } - - double height = zathura_page_get_height(page); - double width = zathura_page_get_width(page); double scale = zathura_document_get_scale(document); double real_scale; diff --git a/utils.h b/utils.h index d42baf5..8276ede 100644 --- a/utils.h +++ b/utils.h @@ -96,7 +96,8 @@ zathura_rectangle_t recalc_rectangle(zathura_page_t* page, zathura_rectangle_t r * @return real scale after rounding */ double -page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned int* page_width, bool rotate); +page_calc_height_width(zathura_document_t* document, double height, double width, + unsigned int* page_height, unsigned int* page_width, bool rotate); /** * Compute the size of the entire document to be displayed (in pixels), taking @@ -138,7 +139,7 @@ void document_draw_search_results(zathura_t* zathura, bool value); * * @param zathura The zathura instance * @param markup Enable markup - * @return Version string + * @return Version string */ char* zathura_get_version_string(zathura_t* zathura, bool markup); diff --git a/zathura.c b/zathura.c index 8ba2e80..56cbe02 100644 --- a/zathura.c +++ b/zathura.c @@ -745,7 +745,10 @@ document_open(zathura_t* zathura, const char* path, const char* password, /* set widget size */ unsigned int page_height = 0; unsigned int page_width = 0; - page_calc_height_width(page, &page_height, &page_width, true); + + double height = zathura_page_get_height(page); + double width = zathura_page_get_width(page); + page_calc_height_width(zathura->document, height, width, &page_height, &page_width, true); gtk_widget_set_size_request(page_widget, page_width, page_height);