Commit 633889f2 authored by Abdo Roig-Maranges's avatar Abdo Roig-Maranges Committed by Sebastian Ramacher

align highlighted rectangles correctly

Align center of the rectangle with the center of the viewport, vor both
keyword searches and synctex forward search.
Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 1a8e211a
......@@ -193,8 +193,13 @@ 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;
pos_x += (rectangle.x1 - (double)cell_width/2) / (double)doc_width;
/* 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;
pos_x += (center_x - (double)cell_width/2) / (double)doc_width;
/* move to position */
zathura_jumplist_add(zathura);
......
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment