Hi

On 2014-01-17 13:48:05, Abdó Roig-Maranges wrote:
> I attach some small fixes for the new synctex forward search functionality.

Thanks for the patches. Unfortunately, they do not apply (starting with
patch 2).

> From 922361bab36aef469766806cca12974e442ce99a Mon Sep 17 00:00:00 2001
> From: Abdo Roig-Maranges <abdo.r...@gmail.com>
> Date: Fri, 17 Jan 2014 12:52:05 +0100
> Subject: [PATCH 1/4] fix page range check
> 
> In those cases, page is in the range [1...N], both ends included.
> ---
>  dbus-interface.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/dbus-interface.c b/dbus-interface.c
> index 569d83a..d145106 100644
> --- a/dbus-interface.c
> +++ b/dbus-interface.c
> @@ -255,7 +255,7 @@ handle_method_call(GDBusConnection* UNUSED(connection),
>      g_variant_get(parameters, "(i)", &page);
>  
>      bool ret = true;
> -    if (page < 1 || (unsigned int)page >= number_of_pages) {
> +    if (page < 1 || (unsigned int)page > number_of_pages) {
>        ret = false;
>      } else {
>        page_set(priv->zathura, page - 1);
> @@ -270,7 +270,7 @@ handle_method_call(GDBusConnection* UNUSED(connection),
>      g_variant_get(parameters, "(ia(dddd)a(idddd))", &page, &iter,
>          &secondary_iter);
>  
> -    if (page < 1 || (unsigned int)page >= number_of_pages) {
> +    if (page < 1 || (unsigned int)page > number_of_pages) {
>        GVariant* result = g_variant_new("(b)", false);
>        g_variant_iter_free(iter);
>        g_variant_iter_free(secondary_iter);
> -- 
> 1.8.5.3
> 
> 
> From b77b32259b6b0ecfed298102e0a1878625773263 Mon Sep 17 00:00:00 2001
> From: Abdo Roig-Maranges <abdo.r...@gmail.com>
> Date: Fri, 17 Jan 2014 13:09:10 +0100
> Subject: [PATCH 2/4] fix rectangles subindex. Need page not 0
> 
> ---
>  dbus-interface.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/dbus-interface.c b/dbus-interface.c
> index d145106..e8e55e5 100644
> --- a/dbus-interface.c
> +++ b/dbus-interface.c
> @@ -169,7 +169,7 @@ highlight_rects(zathura_t* zathura, unsigned int page,
>  
>    document_draw_search_results(zathura, true);
>  
> -  if (rectangles[0] == NULL || girara_list_size(rectangles[0]) == 0) {
> +  if (rectangles[page] == NULL || girara_list_size(rectangles[page]) == 0) {
>      page_set(zathura, page);
>      return;
>    }
> @@ -192,7 +192,8 @@ highlight_rects(zathura_t* zathura, unsigned int page,
>    unsigned int doc_width = 0;
>    zathura_document_get_document_size(zathura->document, &doc_height, 
> &doc_width);
>  
> -  zathura_rectangle_t* rectangle = girara_list_nth(rectangles[0], 0);
> +  zathura_rectangle_t* rectangle = girara_list_nth(rectangles[page], 0);
> +
>    pos_y += (rectangle->y1 - (double)cell_height/2) / (double)doc_height;
>    if (search_hadjust == true) {
>      pos_x += (rectangle->x1 - (double)cell_width/2) / (double)doc_width;

There is now search_hadjust in highlight_rects.

> 1.8.5.3
> 
> 
> From 7874948b7b7dd00a1dc2b04c800381bc64dac397 Mon Sep 17 00:00:00 2001
> From: Abdo Roig-Maranges <abdo.r...@gmail.com>
> Date: Fri, 17 Jan 2014 13:35:11 +0100
> Subject: [PATCH 3/4] properly scale and rotate rectangle
> 
> ---
>  dbus-interface.c | 9 ++++++---
>  shortcuts.c      | 1 +
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/dbus-interface.c b/dbus-interface.c
> index e8e55e5..1f780dd 100644
> --- a/dbus-interface.c
> +++ b/dbus-interface.c
> @@ -192,11 +192,14 @@ highlight_rects(zathura_t* zathura, unsigned int page,
>    unsigned int doc_width = 0;
>    zathura_document_get_document_size(zathura->document, &doc_height, 
> &doc_width);
>  
> -  zathura_rectangle_t* rectangle = girara_list_nth(rectangles[page], 0);
> +  /* Need to adjust rectangle to page scale and orientation */
> +  zathura_page_t* doc_page = zathura_document_get_page(zathura->document, 
> page);
> +  zathura_rectangle_t* rect = girara_list_nth(rectangles[page], 0);
> +  zathura_rectangle_t rectangle = recalc_rectangle(doc_page, *rect);
>  
> -  pos_y += (rectangle->y1 - (double)cell_height/2) / (double)doc_height;
> +  pos_y += (rectangle.y1 - (double)cell_height/2) / (double)doc_height;
>    if (search_hadjust == true) {
> -    pos_x += (rectangle->x1 - (double)cell_width/2) / (double)doc_width;
> +    pos_x += (rectangle.x1 - (double)cell_width/2) / (double)doc_width;

See above.

>    }
>  
>    /* move to position */
> diff --git a/shortcuts.c b/shortcuts.c
> index 7e76235..a067dac 100644
> --- a/shortcuts.c
> +++ b/shortcuts.c
> @@ -917,6 +917,7 @@ sc_search(girara_session_t* session, girara_argument_t* 
> argument,
>      g_object_set(page_widget, "search-current", target_idx, NULL);
>      g_object_get(page_widget, "search-results", &results, NULL);
>  
> +    /* Need to adjust rectangle to page scale and orientation */
>      zathura_rectangle_t* rect = girara_list_nth(results, target_idx);
>      zathura_rectangle_t rectangle = recalc_rectangle(target_page, *rect);
>  
> -- 
> 1.8.5.3
> 
> 
> From d3926da7fd7d3eb6b9742e7b23c238d99151dcf6 Mon Sep 17 00:00:00 2001
> From: Abdo Roig-Maranges <abdo.r...@gmail.com>
> Date: Fri, 17 Jan 2014 13:40:51 +0100
> Subject: [PATCH 4/4] align highlighted rectangles correctly
> 
> Align center of the rectangle with the center of the viewport, vor both
> keyword searches and synctex forward search.
> ---
>  dbus-interface.c | 9 +++++++--
>  shortcuts.c      | 8 ++++++--
>  2 files changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/dbus-interface.c b/dbus-interface.c
> index 1f780dd..c22b2f2 100644
> --- a/dbus-interface.c
> +++ b/dbus-interface.c
> @@ -197,9 +197,14 @@ highlight_rects(zathura_t* zathura, unsigned int page,
>    zathura_rectangle_t* rect = girara_list_nth(rectangles[page], 0);
>    zathura_rectangle_t rectangle = recalc_rectangle(doc_page, *rect);
>  
> -  pos_y += (rectangle.y1 - (double)cell_height/2) / (double)doc_height;
> +  /* compute the center of the rectangle, which will be aligned to the center
> +     of the viewport */
> +  double center_x = (rectangle.x1 + rectangle.x2) / 2;
> +  double center_y = (rectangle.y1 + rectangle.y2) / 2;
> +
> +  pos_y += (center_y - (double)cell_height/2) / (double)doc_height;
>    if (search_hadjust == true) {
> -    pos_x += (rectangle.x1 - (double)cell_width/2) / (double)doc_width;
> +    pos_x += (center_x - (double)cell_width/2) / (double)doc_width;
>    }

See above

>  
>    /* move to position */
> diff --git a/shortcuts.c b/shortcuts.c
> index a067dac..0f5c807 100644
> --- a/shortcuts.c
> +++ b/shortcuts.c
> @@ -940,10 +940,14 @@ sc_search(girara_session_t* session, girara_argument_t* 
> argument,
>      unsigned int doc_width = 0;
>      zathura_document_get_document_size(zathura->document, &doc_height, 
> &doc_width);
>  
> -    pos_y += (rectangle.y1 - (double)cell_height/2) / (double)doc_height;
> +    /* compute the center of the rectangle, which will be aligned to the 
> center
> +       of the viewport */
> +    double center_x = (rectangle.x1 + rectangle.x2) / 2;
> +    double center_y = (rectangle.y1 + rectangle.y2) / 2;
>  
> +    pos_y += (center_y - (double)cell_height/2) / (double)doc_height;
>      if (search_hadjust == true) {
> -      pos_x += (rectangle.x1 - (double)cell_width/2) / (double)doc_width;
> +      pos_x += (center_x - (double)cell_width/2) / (double)doc_width;
>      }
>  
>      /* move to position */
> -- 
> 1.8.5.3
> 

Regards
-- 
Sebastian Ramacher
_______________________________________________
zathura mailing list
zathura@lists.pwmt.org
http://lists.pwmt.org/mailman/listinfo/zathura

Reply via email to