mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-13 07:15:59 +01:00
Make smooth-reload the default
There are some corner cases, but let's reduce some of the complexity.
This commit is contained in:
parent
ab78c1ddb0
commit
ef6e7e295c
6 changed files with 42 additions and 67 deletions
|
@ -156,14 +156,6 @@ General settings
|
||||||
:type: Boolean
|
:type: Boolean
|
||||||
:default: false
|
: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
|
.. describe:: show-signature-information
|
||||||
|
|
||||||
Defines whether additional information on signatures embedded in documents should be displayed.
|
Defines whether additional information on signatures embedded in documents should be displayed.
|
||||||
|
|
|
@ -938,13 +938,6 @@ zathura
|
||||||
* value type: Boolean
|
* value type: Boolean
|
||||||
* Default value false
|
* 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*
|
*statusbar-basename*
|
||||||
Use basename of the file in the statusbar.
|
Use basename of the file in the statusbar.
|
||||||
|
|
||||||
|
|
|
@ -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);
|
girara_setting_add(gsession, "search-hadjust", &bool_value, BOOLEAN, false, _("Center result horizontally"), NULL, NULL);
|
||||||
bool_value = true;
|
bool_value = true;
|
||||||
girara_setting_add(gsession, "render-loading", &bool_value, BOOLEAN, false, _("Render 'Loading ...'"), NULL, NULL);
|
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);
|
girara_setting_add(gsession, "adjust-open", "best-fit", STRING, false, _("Adjust to when opening file"), NULL, NULL);
|
||||||
bool_value = false;
|
bool_value = false;
|
||||||
girara_setting_add(gsession, "show-hidden", &bool_value, BOOLEAN, false, _("Show hidden files and directories"), NULL, NULL);
|
girara_setting_add(gsession, "show-hidden", &bool_value, BOOLEAN, false, _("Show hidden files and directories"), NULL, NULL);
|
||||||
|
|
|
@ -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_height = gtk_widget_get_allocated_height(widget);
|
||||||
const unsigned int page_width = gtk_widget_get_allocated_width(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;
|
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);
|
unsigned int page_index = zathura_page_get_index(priv->page);
|
||||||
|
|
||||||
if (page_index < zathura_document_get_number_of_pages(priv->zathura->predecessor_document)) {
|
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);
|
cairo_fill(cairo);
|
||||||
}
|
}
|
||||||
} else {
|
} 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 */
|
/* set background color */
|
||||||
if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) {
|
if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) {
|
||||||
|
|
|
@ -164,7 +164,12 @@ static void renderer_register_request(ZathuraRenderer* renderer, ZathuraRenderRe
|
||||||
|
|
||||||
/* init, new and free for ZathuraRenderRequest */
|
/* 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};
|
static guint request_signals[REQUEST_LAST_SIGNAL] = {0};
|
||||||
|
|
||||||
|
|
|
@ -1498,35 +1498,30 @@ save_fileinfo_to_db(zathura_t* zathura)
|
||||||
g_free(file_info.first_page_column_list);
|
g_free(file_info.first_page_column_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool document_predecessor_free(zathura_t* zathura) {
|
||||||
document_predecessor_free(zathura_t* zathura) {
|
if (zathura == NULL || (zathura->predecessor_document == NULL && zathura->predecessor_pages == NULL)) {
|
||||||
if (zathura == NULL
|
|
||||||
|| (zathura->predecessor_document == NULL
|
|
||||||
&& zathura->predecessor_pages == NULL)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zathura->predecessor_pages != NULL) {
|
if (zathura->predecessor_pages != NULL) {
|
||||||
for (unsigned int i = 0; i < zathura_document_get_number_of_pages(zathura->predecessor_document); i++) {
|
for (unsigned int i = 0; i < zathura_document_get_number_of_pages(zathura->predecessor_document); i++) {
|
||||||
g_object_unref(zathura->predecessor_pages[i]);
|
g_object_unref(zathura->predecessor_pages[i]);
|
||||||
}
|
}
|
||||||
free(zathura->predecessor_pages);
|
free(zathura->predecessor_pages);
|
||||||
zathura->predecessor_pages = NULL;
|
zathura->predecessor_pages = NULL;
|
||||||
girara_debug("freed predecessor pages");
|
girara_debug("freed predecessor pages");
|
||||||
}
|
}
|
||||||
if (zathura->predecessor_document != NULL) {
|
if (zathura->predecessor_document != NULL) {
|
||||||
/* remove document */
|
/* remove document */
|
||||||
zathura_document_free(zathura->predecessor_document);
|
zathura_document_free(zathura->predecessor_document);
|
||||||
zathura->predecessor_document = NULL;
|
zathura->predecessor_document = NULL;
|
||||||
girara_debug("freed predecessor document");
|
girara_debug("freed predecessor document");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool document_close(zathura_t* zathura, bool keep_monitor) {
|
||||||
document_close(zathura_t* zathura, bool keep_monitor)
|
|
||||||
{
|
|
||||||
if (zathura == NULL || zathura->document == NULL) {
|
if (zathura == NULL || zathura->document == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1539,9 +1534,6 @@ document_close(zathura_t* zathura, bool keep_monitor)
|
||||||
g_free(window_icon);
|
g_free(window_icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool smooth_reload = true;
|
|
||||||
girara_setting_get(zathura->ui.session, "smooth-reload", &smooth_reload);
|
|
||||||
|
|
||||||
/* stop rendering */
|
/* stop rendering */
|
||||||
zathura_renderer_stop(zathura->sync.render_thread);
|
zathura_renderer_stop(zathura->sync.render_thread);
|
||||||
g_clear_object(&zathura->window_icon_render_request);
|
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);
|
g_clear_object(&zathura->sync.render_thread);
|
||||||
|
|
||||||
/* keep the current state to prevent flicker? */
|
/* keep the current state to prevent flicker? */
|
||||||
bool override_predecessor = keep_monitor && smooth_reload;
|
bool override_predecessor = keep_monitor;
|
||||||
|
|
||||||
if (override_predecessor) {
|
if (override_predecessor) {
|
||||||
/* do not override predecessor buffer with empty pages */
|
/* do not override predecessor buffer with empty pages */
|
||||||
unsigned int cur_page_num = zathura_document_get_current_page_number(zathura->document);
|
unsigned int cur_page_num = zathura_document_get_current_page_number(zathura->document);
|
||||||
ZathuraPage* cur_page = ZATHURA_PAGE(zathura->pages[cur_page_num]);
|
ZathuraPage* cur_page = ZATHURA_PAGE(zathura->pages[cur_page_num]);
|
||||||
if (!zathura_page_widget_have_surface(cur_page)) {
|
if (!zathura_page_widget_have_surface(cur_page)) {
|
||||||
override_predecessor = false;
|
override_predecessor = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free predecessor buffer if we want to overwrite it or if we destroy the document for good */
|
/* 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);
|
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);
|
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, NULL);
|
||||||
|
|
||||||
if (!override_predecessor) {
|
if (!override_predecessor) {
|
||||||
for (unsigned int i = 0; i < zathura_document_get_number_of_pages(zathura->document); i++) {
|
for (unsigned int i = 0; i < zathura_document_get_number_of_pages(zathura->document); i++) {
|
||||||
g_object_unref(zathura->pages[i]);
|
g_object_unref(zathura->pages[i]);
|
||||||
}
|
}
|
||||||
free(zathura->pages);
|
free(zathura->pages);
|
||||||
zathura->pages = NULL;
|
zathura->pages = NULL;
|
||||||
|
|
||||||
/* remove document */
|
/* remove document */
|
||||||
zathura_document_free(zathura->document);
|
zathura_document_free(zathura->document);
|
||||||
zathura->document = NULL;
|
zathura->document = NULL;
|
||||||
} else {
|
} else {
|
||||||
girara_debug("preserving pages and document as predecessor");
|
girara_debug("preserving pages and document as predecessor");
|
||||||
zathura->predecessor_pages = zathura->pages;
|
zathura->predecessor_pages = zathura->pages;
|
||||||
zathura->pages = NULL;
|
zathura->pages = NULL;
|
||||||
zathura->predecessor_document = zathura->document;
|
zathura->predecessor_document = zathura->document;
|
||||||
zathura->document = NULL;
|
zathura->document = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove index */
|
/* remove index */
|
||||||
|
|
Loading…
Reference in a new issue