diff --git a/document.h b/document.h index d4d8ce8..1c28586 100644 --- a/document.h +++ b/document.h @@ -77,7 +77,9 @@ zathura_image_buffer_t* zathura_image_buffer_create(unsigned int width, unsigned void zathura_image_buffer_free(zathura_image_buffer_t*); /** - * Rectangle structure + * Rectangle structure. + * The coordinate system has its origin in the left upper corner. The x axes + * goes to the right, the y access goes down. */ typedef struct zathura_rectangle_s { diff --git a/page_widget.c b/page_widget.c index cf0335c..1b110be 100644 --- a/page_widget.c +++ b/page_widget.c @@ -292,7 +292,7 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event) /* draw text */ cairo_set_source_rgba(cairo, 0, 0, 0, 1); cairo_set_font_size(cairo, 10); - cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y1 - 1); + cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1); char* link_number = g_strdup_printf("%i", priv->link_offset + ++link_counter); cairo_show_text(cairo, link_number); g_free(link_number); @@ -384,9 +384,9 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle) /* cause the rect to be drawn */ GdkRectangle grect; grect.x = rectangle->x1; - grect.y = rectangle->y2; + grect.y = rectangle->y1; grect.width = rectangle->x2 - rectangle->x1; - grect.height = rectangle->y1 - rectangle->y2; + grect.height = rectangle->y2 - rectangle->y1; gdk_window_invalidate_rect(GTK_WIDGET(widget)->window, &grect, TRUE); } diff --git a/utils.c b/utils.c index 27926b8..a89d852 100644 --- a/utils.c +++ b/utils.c @@ -200,28 +200,28 @@ recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle) switch (page->document->rotate) { case 90: - tmp.x1 = rectangle.y2 * page->document->scale; - tmp.x2 = rectangle.y1 * page->document->scale; + tmp.x1 = (page->height - rectangle.y2) * page->document->scale; + tmp.x2 = (page->height - rectangle.y1) * page->document->scale; tmp.y1 = rectangle.x1 * page->document->scale; tmp.y2 = rectangle.x2 * page->document->scale; break; case 180: tmp.x1 = (page->width - rectangle.x2) * page->document->scale; tmp.x2 = (page->width - rectangle.x1) * page->document->scale; - tmp.y1 = rectangle.y2 * page->document->scale; - tmp.y2 = rectangle.y1 * page->document->scale; + tmp.y1 = (page->height - rectangle.y2) * page->document->scale; + tmp.y2 = (page->height - rectangle.y1) * page->document->scale; break; case 270: - tmp.x1 = (page->height - rectangle.y1) * page->document->scale; - tmp.x2 = (page->height - rectangle.y2) * page->document->scale; - tmp.y1 = (page->width - rectangle.x2) * page->document->scale; - tmp.y2 = (page->width - rectangle.x1) * page->document->scale; + tmp.x1 = rectangle.y1 * page->document->scale; + tmp.x2 = rectangle.y2 * page->document->scale; + tmp.y1 = (page->width - rectangle.x2) * page->document->scale; + tmp.y2 = (page->width - rectangle.x1) * page->document->scale; break; default: tmp.x1 = rectangle.x1 * page->document->scale; tmp.x2 = rectangle.x2 * page->document->scale; - tmp.y1 = (page->height - rectangle.y1) * page->document->scale; - tmp.y2 = (page->height - rectangle.y2) * page->document->scale; + tmp.y1 = rectangle.y1 * page->document->scale; + tmp.y2 = rectangle.y2 * page->document->scale; } return tmp;