X-Git-Url: http://git.draconx.ca/gitweb/rrace.git/blobdiff_plain/bbe659b000e2c281340953c5fc96bd7ac3b94eaa..ceb2df0fe41852ba3f5637dcd04217113b4259ba:/src/x11.c?ds=sidebyside diff --git a/src/x11.c b/src/x11.c index b15e7d6..6d09a7d 100644 --- a/src/x11.c +++ b/src/x11.c @@ -140,14 +140,19 @@ static void draw_tile(struct app_state *state, Display *display, Drawable d, XFillRectangle(display, d, state->tile_gc, tx+2, ty+2, tw-4, th-4); } -static void clear_rect(struct app_state *state, Display *display, Drawable d, - int x, int y, int w, int h) +static void +clear_rect(Display *display, Drawable d, int x, int y, int w, int h) { #if X11_RENDER_DEBUG XRectangle r = { x, y, w, h }; + XGCValues gcv; + GC gc; + + gcv.foreground = 0xff0000; + gc = XCreateGC(display, d, GCForeground, &gcv); + XFillRectangles(display, d, gc, &r, 1); + XFreeGC(display, gc); - XSetForeground(display, state->tile_gc, 0xff0000); - XFillRectangles(display, d, state->tile_gc, &r, 1); XFlush(display); usleep(70000); #endif @@ -160,23 +165,20 @@ static void clear_rect(struct app_state *state, Display *display, Drawable d, * which tiles need clearing, but for the border clear it is safe to wipe an * entire row or column of the border using a single XClearArea. */ -static void clear_border(struct app_state *state, Display *display, Drawable d, - Dimension w, Dimension h, uint_fast32_t mask) +static void clear_border(Display *display, Drawable d, unsigned sz) { - if (!(mask &= ~GOAL_MASK & 0x1ffffff)) - return; - - clear_rect(state, display, d, 0, 0, 5*w, h); - clear_rect(state, display, d, 0, 4*h, 5*w, h); - clear_rect(state, display, d, 0, 0, w, 5*h); - clear_rect(state, display, d, 4*w, 0, w, 5*h); + clear_rect(display, d, 0, 0, -1, sz); + clear_rect(display, d, 0, 4*sz, -1, sz); + clear_rect(display, d, 0, 0, sz, -1); + clear_rect(display, d, 4*sz, 0, sz, -1); } static int redraw_tile(struct app_state *state, Display *display, Drawable d, - uint_least32_t *gp, int x, int y, Dimension w, Dimension h) + uint_least32_t *gp, int x, int y, unsigned sz) { unsigned tile = board_tile(gp, 5*y+x); + unsigned w = sz, h = sz; #if X11_RENDER_DEBUG if (d == XtWindow(state->game) || d == XtWindow(state->goal)) { @@ -235,8 +237,8 @@ x11_redraw_goal(struct app_state *state, uint_fast32_t mask, Widget icon_shell) { Display *display = XtDisplay(state->goal); Window goal = XtWindow(state->goal); + unsigned sz = state->goal_tile_sz; unsigned long ewmhseq[9]; - Dimension w, h; int i; uint_least32_t gp[3] = { @@ -245,9 +247,6 @@ x11_redraw_goal(struct app_state *state, uint_fast32_t mask, Widget icon_shell) state->board.goal[2] }; - XtVaGetValues(state->goal, XtNwidth, &w, XtNheight, &h, (char *)NULL); - w /= 3; h /= 3; - for (i = 0; i < 9; i++) { int x = i%3, y = i/3; @@ -255,12 +254,12 @@ x11_redraw_goal(struct app_state *state, uint_fast32_t mask, Widget icon_shell) unsigned tile; tile = redraw_tile(state, display, state->icon_pixmap, - gp, x, y, ICON_SIZE/3, ICON_SIZE/3); + gp, x, y, ICON_SIZE/3); ewmhseq[i] = COLOUR_MAX*0x10101 * (tile-1) + 0x20100; } if (mask & 1) - redraw_tile(state, display, goal, gp, x, y, w, h); + redraw_tile(state, display, goal, gp, x, y, sz); /* * Goal bitmaps have a gap of 2 tiles between each row. @@ -278,12 +277,9 @@ void x11_redraw_game(struct app_state *state, uint_fast32_t mask) Display *display = XtDisplay(state->goal); Window game = XtWindow(state->game); uint_least32_t buf[3], *gp = state->board.game; - Dimension w, h; + unsigned sz = state->game_tile_sz; int i; - XtVaGetValues(state->game, XtNwidth, &w, XtNheight, &h, (char *)NULL); - w /= 5; h /= 5; - if (state->view_goal_on_game) { for (i = 0; i < 3; i++) { buf[i] = state->board.goal[i]; @@ -294,13 +290,13 @@ void x11_redraw_game(struct app_state *state, uint_fast32_t mask) /* Optimize the game end case where the outer frame is cleared */ if (((gp[0] | gp[1] | gp[2]) & ~GOAL_MASK) == 0) { - clear_border(state, display, game, w, h, mask); + clear_border(display, game, sz); mask &= GOAL_MASK; } for (i = 0; i < 25; i++) { if (mask & 1) - redraw_tile(state, display, game, gp, i%5, i/5, w, h); + redraw_tile(state, display, game, gp, i%5, i/5, sz); mask >>= 1; } }