+void
+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 long ewmhseq[9];
+ Dimension w, h;
+ int i;
+
+ uint_least32_t gp[3] = {
+ state->board.goal[0],
+ state->board.goal[1],
+ 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;
+
+ if (icon_shell) {
+ unsigned tile;
+
+ tile = redraw_tile(state, display, state->icon_pixmap,
+ gp, x, y, ICON_SIZE/3, ICON_SIZE/3);
+ ewmhseq[i] = COLOUR_MAX*0x10101 * (tile-1) + 0x20100;
+ }
+
+ if (mask & 1)
+ redraw_tile(state, display, goal, gp, x, y, w, h);
+
+ /*
+ * Goal bitmaps have a gap of 2 tiles between each row.
+ * This funny shift will accomodate that.
+ */
+ mask >>= 1|x;
+ }
+
+ if (icon_shell)
+ set_icon(state, display, icon_shell, ewmhseq);
+}
+