From ef6e7e295c9c046368a3202e8c82efd8b9d24a92 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Sun, 3 Mar 2024 12:42:27 +0100 Subject: [PATCH] Make smooth-reload the default There are some corner cases, but let's reduce some of the complexity. --- doc/configuration/options.rst | 8 ---- doc/man/zathurarc.5.rst | 7 ---- zathura/config.c | 2 - zathura/page-widget.c | 9 +---- zathura/render.c | 7 +++- zathura/zathura.c | 76 ++++++++++++++++------------------- 6 files changed, 42 insertions(+), 67 deletions(-) diff --git a/doc/configuration/options.rst b/doc/configuration/options.rst index 46f7cb6..560e360 100644 --- a/doc/configuration/options.rst +++ b/doc/configuration/options.rst @@ -156,14 +156,6 @@ General settings :type: Boolean :default: false -.. describe:: smooth-reload - - Defines if flickering will be removed when a file is reloaded on change. - This option might increase memory usage. - - :type: Boolean - :default: true - .. describe:: show-signature-information Defines whether additional information on signatures embedded in documents should be displayed. diff --git a/doc/man/zathurarc.5.rst b/doc/man/zathurarc.5.rst index fb413f3..ab702e5 100644 --- a/doc/man/zathurarc.5.rst +++ b/doc/man/zathurarc.5.rst @@ -938,13 +938,6 @@ zathura * value type: Boolean * Default value false -*smooth-reload* - Defines if flickering will be removed when a file is reloaded on change. This - option might increase memory usage. - - * Value type: Boolean - * Default value: true - *statusbar-basename* Use basename of the file in the statusbar. diff --git a/zathura/config.c b/zathura/config.c index d6c2ef0..419032b 100644 --- a/zathura/config.c +++ b/zathura/config.c @@ -318,8 +318,6 @@ void config_load_default(zathura_t* zathura) { girara_setting_add(gsession, "search-hadjust", &bool_value, BOOLEAN, false, _("Center result horizontally"), NULL, NULL); bool_value = true; girara_setting_add(gsession, "render-loading", &bool_value, BOOLEAN, false, _("Render 'Loading ...'"), NULL, NULL); - bool_value = true; - girara_setting_add(gsession, "smooth-reload", &bool_value, BOOLEAN, false, _("Smooth over flicker when reloading file"), NULL, NULL); girara_setting_add(gsession, "adjust-open", "best-fit", STRING, false, _("Adjust to when opening file"), NULL, NULL); bool_value = false; girara_setting_add(gsession, "show-hidden", &bool_value, BOOLEAN, false, _("Show hidden files and directories"), NULL, NULL); diff --git a/zathura/page-widget.c b/zathura/page-widget.c index b8373da..492b103 100644 --- a/zathura/page-widget.c +++ b/zathura/page-widget.c @@ -525,12 +525,9 @@ static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) { const unsigned int page_height = gtk_widget_get_allocated_height(widget); const unsigned int page_width = gtk_widget_get_allocated_width(widget); - bool smooth_reload = true; - girara_setting_get(zathura->ui.session, "smooth-reload", &smooth_reload); - bool surface_exists = priv->surface != NULL || priv->thumbnail != NULL; - if (zathura->predecessor_document != NULL && zathura->predecessor_pages != NULL && smooth_reload && !surface_exists) { + if (zathura->predecessor_document != NULL && zathura->predecessor_pages != NULL && !surface_exists) { unsigned int page_index = zathura_page_get_index(priv->page); if (page_index < zathura_document_get_number_of_pages(priv->zathura->predecessor_document)) { @@ -727,9 +724,7 @@ static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) { cairo_fill(cairo); } } else { - if (smooth_reload) { - girara_debug("rendering loading screen, flicker might be happening"); - } + girara_debug("rendering loading screen, flicker might be happening"); /* set background color */ if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) { diff --git a/zathura/render.c b/zathura/render.c index cfbd4b2..811e53e 100644 --- a/zathura/render.c +++ b/zathura/render.c @@ -164,7 +164,12 @@ static void renderer_register_request(ZathuraRenderer* renderer, ZathuraRenderRe /* init, new and free for ZathuraRenderRequest */ -enum { REQUEST_COMPLETED, REQUEST_CACHE_ADDED, REQUEST_CACHE_INVALIDATED, REQUEST_LAST_SIGNAL }; +enum { + REQUEST_COMPLETED, + REQUEST_CACHE_ADDED, + REQUEST_CACHE_INVALIDATED, + REQUEST_LAST_SIGNAL, +}; static guint request_signals[REQUEST_LAST_SIGNAL] = {0}; diff --git a/zathura/zathura.c b/zathura/zathura.c index 95cf1f5..d4dede9 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -1498,35 +1498,30 @@ save_fileinfo_to_db(zathura_t* zathura) g_free(file_info.first_page_column_list); } -bool -document_predecessor_free(zathura_t* zathura) { - if (zathura == NULL - || (zathura->predecessor_document == NULL - && zathura->predecessor_pages == NULL)) { +bool document_predecessor_free(zathura_t* zathura) { + if (zathura == NULL || (zathura->predecessor_document == NULL && zathura->predecessor_pages == NULL)) { return false; } if (zathura->predecessor_pages != NULL) { - for (unsigned int i = 0; i < zathura_document_get_number_of_pages(zathura->predecessor_document); i++) { - g_object_unref(zathura->predecessor_pages[i]); - } - free(zathura->predecessor_pages); - zathura->predecessor_pages = NULL; - girara_debug("freed predecessor pages"); + for (unsigned int i = 0; i < zathura_document_get_number_of_pages(zathura->predecessor_document); i++) { + g_object_unref(zathura->predecessor_pages[i]); + } + free(zathura->predecessor_pages); + zathura->predecessor_pages = NULL; + girara_debug("freed predecessor pages"); } if (zathura->predecessor_document != NULL) { - /* remove document */ - zathura_document_free(zathura->predecessor_document); - zathura->predecessor_document = NULL; - girara_debug("freed predecessor document"); + /* remove document */ + zathura_document_free(zathura->predecessor_document); + zathura->predecessor_document = NULL; + girara_debug("freed predecessor document"); } return true; } -bool -document_close(zathura_t* zathura, bool keep_monitor) -{ +bool document_close(zathura_t* zathura, bool keep_monitor) { if (zathura == NULL || zathura->document == NULL) { return false; } @@ -1539,9 +1534,6 @@ document_close(zathura_t* zathura, bool keep_monitor) g_free(window_icon); } - bool smooth_reload = true; - girara_setting_get(zathura->ui.session, "smooth-reload", &smooth_reload); - /* stop rendering */ zathura_renderer_stop(zathura->sync.render_thread); g_clear_object(&zathura->window_icon_render_request); @@ -1578,19 +1570,19 @@ document_close(zathura_t* zathura, bool keep_monitor) g_clear_object(&zathura->sync.render_thread); /* keep the current state to prevent flicker? */ - bool override_predecessor = keep_monitor && smooth_reload; + bool override_predecessor = keep_monitor; if (override_predecessor) { - /* do not override predecessor buffer with empty pages */ - unsigned int cur_page_num = zathura_document_get_current_page_number(zathura->document); - ZathuraPage* cur_page = ZATHURA_PAGE(zathura->pages[cur_page_num]); - if (!zathura_page_widget_have_surface(cur_page)) { - override_predecessor = false; - } + /* do not override predecessor buffer with empty pages */ + unsigned int cur_page_num = zathura_document_get_current_page_number(zathura->document); + ZathuraPage* cur_page = ZATHURA_PAGE(zathura->pages[cur_page_num]); + if (!zathura_page_widget_have_surface(cur_page)) { + override_predecessor = false; + } } /* free predecessor buffer if we want to overwrite it or if we destroy the document for good */ - if (override_predecessor || !keep_monitor || !smooth_reload) { + if (override_predecessor || !keep_monitor) { document_predecessor_free(zathura); } @@ -1598,21 +1590,21 @@ document_close(zathura_t* zathura, bool keep_monitor) gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, NULL); if (!override_predecessor) { - for (unsigned int i = 0; i < zathura_document_get_number_of_pages(zathura->document); i++) { - g_object_unref(zathura->pages[i]); - } - free(zathura->pages); - zathura->pages = NULL; + for (unsigned int i = 0; i < zathura_document_get_number_of_pages(zathura->document); i++) { + g_object_unref(zathura->pages[i]); + } + free(zathura->pages); + zathura->pages = NULL; - /* remove document */ - zathura_document_free(zathura->document); - zathura->document = NULL; + /* remove document */ + zathura_document_free(zathura->document); + zathura->document = NULL; } else { - girara_debug("preserving pages and document as predecessor"); - zathura->predecessor_pages = zathura->pages; - zathura->pages = NULL; - zathura->predecessor_document = zathura->document; - zathura->document = NULL; + girara_debug("preserving pages and document as predecessor"); + zathura->predecessor_pages = zathura->pages; + zathura->pages = NULL; + zathura->predecessor_document = zathura->document; + zathura->document = NULL; } /* remove index */