From: H.G. Muller Date: Thu, 11 Oct 2012 17:08:49 +0000 (+0200) Subject: Fix 1-pixel offset of grid lines on some cairo implementations X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=794815198d57537b59e1b08b129568632da249d2 Fix 1-pixel offset of grid lines on some cairo implementations --- diff --git a/draw.c b/draw.c index f811dbe..8a39aeb 100644 --- a/draw.c +++ b/draw.c @@ -502,6 +502,7 @@ DrawGrid() { /* draws a grid starting around Nx, Ny squares starting at x,y */ int i; + float odd = (lineGap & 1)/2.; cairo_t *cr; /* get a cairo_t */ @@ -513,8 +514,8 @@ DrawGrid() /* lines in X */ for (i = 0; i < BOARD_WIDTH + BOARD_HEIGHT + 2; i++) { - cairo_move_to (cr, gridSegments[i].x1, gridSegments[i].y1); - cairo_line_to (cr, gridSegments[i].x2, gridSegments[i].y2); + cairo_move_to (cr, gridSegments[i].x1 + odd, gridSegments[i].y1 + odd); + cairo_line_to (cr, gridSegments[i].x2 + odd, gridSegments[i].y2 + odd); cairo_stroke (cr); } @@ -541,7 +542,7 @@ DrawBorder (int x, int y, int type, int odd) SetPen(cr, lineGap, col, 0); cairo_stroke(cr); cairo_destroy(cr); - GraphExpose(currBoard, x - lineGap/2, y - lineGap/2, squareSize+lineGap+odd, squareSize+lineGap+odd); + GraphExpose(currBoard, x - lineGap/2, y - lineGap/2, squareSize+2*lineGap+odd, squareSize+2*lineGap+odd); } static int diff --git a/xoptions.c b/xoptions.c index 2446fb0..979399a 100644 --- a/xoptions.c +++ b/xoptions.c @@ -569,6 +569,7 @@ GraphEventProc(Widget widget, caddr_t client_data, XEvent *event) } cr = cairo_create((cairo_surface_t *) graph->textValue); cairo_set_source_surface(cr, (cairo_surface_t *) graph->choice, 0, 0); + cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE); cairo_rectangle(cr, ((XExposeEvent*)event)->x, ((XExposeEvent*)event)->y, ((XExposeEvent*)event)->width, ((XExposeEvent*)event)->height); cairo_fill(cr); cairo_destroy(cr);