mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-13 10:43:46 +01:00
Fix the page number once while parsing the synctex output
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
2778868599
commit
bfb3acc1b1
@ -249,10 +249,10 @@ handle_method_call(GDBusConnection* UNUSED(connection),
|
|||||||
g_variant_get(parameters, "(i)", &page);
|
g_variant_get(parameters, "(i)", &page);
|
||||||
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
if (page < 1 || (unsigned int)page > number_of_pages) {
|
if (page < 0 || (unsigned int)page >= number_of_pages) {
|
||||||
ret = false;
|
ret = false;
|
||||||
} else {
|
} else {
|
||||||
page_set(priv->zathura, page - 1);
|
page_set(priv->zathura, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
GVariant* result = g_variant_new("(b)", ret);
|
GVariant* result = g_variant_new("(b)", ret);
|
||||||
@ -264,7 +264,7 @@ handle_method_call(GDBusConnection* UNUSED(connection),
|
|||||||
g_variant_get(parameters, "(ia(dddd)a(idddd))", &page, &iter,
|
g_variant_get(parameters, "(ia(dddd)a(idddd))", &page, &iter,
|
||||||
&secondary_iter);
|
&secondary_iter);
|
||||||
|
|
||||||
if (page < 1 || (unsigned int)page > number_of_pages) {
|
if (page < 0 || (unsigned int)page >= number_of_pages) {
|
||||||
GVariant* result = g_variant_new("(b)", false);
|
GVariant* result = g_variant_new("(b)", false);
|
||||||
g_variant_iter_free(iter);
|
g_variant_iter_free(iter);
|
||||||
g_variant_iter_free(secondary_iter);
|
g_variant_iter_free(secondary_iter);
|
||||||
@ -274,14 +274,14 @@ handle_method_call(GDBusConnection* UNUSED(connection),
|
|||||||
|
|
||||||
/* get rectangles */
|
/* get rectangles */
|
||||||
girara_list_t** rectangles = g_malloc0(number_of_pages * sizeof(girara_list_t*));
|
girara_list_t** rectangles = g_malloc0(number_of_pages * sizeof(girara_list_t*));
|
||||||
rectangles[page - 1] = girara_list_new2(g_free);
|
rectangles[page] = girara_list_new2(g_free);
|
||||||
|
|
||||||
zathura_rectangle_t temp_rect;
|
zathura_rectangle_t temp_rect;
|
||||||
while (g_variant_iter_loop(iter, "(dddd)", &temp_rect.x1, &temp_rect.x2,
|
while (g_variant_iter_loop(iter, "(dddd)", &temp_rect.x1, &temp_rect.x2,
|
||||||
&temp_rect.y1, &temp_rect.y2)) {
|
&temp_rect.y1, &temp_rect.y2)) {
|
||||||
zathura_rectangle_t* rect = g_malloc0(sizeof(zathura_rectangle_t));
|
zathura_rectangle_t* rect = g_malloc0(sizeof(zathura_rectangle_t));
|
||||||
*rect = temp_rect;
|
*rect = temp_rect;
|
||||||
girara_list_append(rectangles[page - 1], rect);
|
girara_list_append(rectangles[page], rect);
|
||||||
}
|
}
|
||||||
g_variant_iter_free(iter);
|
g_variant_iter_free(iter);
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ handle_method_call(GDBusConnection* UNUSED(connection),
|
|||||||
}
|
}
|
||||||
g_variant_iter_free(secondary_iter);
|
g_variant_iter_free(secondary_iter);
|
||||||
|
|
||||||
highlight_rects(priv->zathura, page - 1, rectangles);
|
highlight_rects(priv->zathura, page, rectangles);
|
||||||
g_free(rectangles);
|
g_free(rectangles);
|
||||||
|
|
||||||
GVariant* result = g_variant_new("(b)", true);
|
GVariant* result = g_variant_new("(b)", true);
|
||||||
|
@ -168,7 +168,7 @@ synctex_rectangles_from_position(const char* filename, const char* position,
|
|||||||
|
|
||||||
case SYNCTEX_PROP_PAGE:
|
case SYNCTEX_PROP_PAGE:
|
||||||
if (g_scanner_get_next_token(scanner) == G_TOKEN_INT) {
|
if (g_scanner_get_next_token(scanner) == G_TOKEN_INT) {
|
||||||
current_page = g_scanner_cur_value(scanner).v_int;
|
current_page = g_scanner_cur_value(scanner).v_int - 1;
|
||||||
if (rpage == ZATHURA_PAGE_NUMBER_UNSPECIFIED) {
|
if (rpage == ZATHURA_PAGE_NUMBER_UNSPECIFIED) {
|
||||||
rpage = current_page;
|
rpage = current_page;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user