}
}
+static void set_view_goal(struct app_state *state, int view_goal)
+{
+ state->view_goal_on_game = view_goal;
+ x11_redraw_game(state, GOAL_MASK);
+}
+
static void game_input(Widget w, void *data, void *cb_data)
{
XmDrawingAreaCallbackStruct *cbs = cb_data;
- XButtonEvent *click = &cbs->event->xbutton;
+ XButtonEvent *b = &cbs->event->xbutton;
struct app_state *state = data;
Dimension width, height;
- unsigned x = -1, y = -1;
switch (cbs->event->type) {
case ButtonPress:
- XtVaGetValues(w, XmNwidth, &width,
- XmNheight, &height,
- (char *)NULL);
- x = click->x / (width/5);
- y = click->y / (height/5);
+ switch (b->button) {
+ case Button1:
+ if (b->state & Button3Mask)
+ break;
+
+ XtVaGetValues(w, XmNwidth, &width,
+ XmNheight, &height,
+ (char *)NULL);
+
+ do_input_move(state, b->x / (width / 5),
+ b->y / (height / 5));
+ break;
+ case Button3:
+ set_view_goal(state, 1);
+ break;
+ }
+ break;
+ case ButtonRelease:
+ switch (b->button) {
+ case Button3:
+ set_view_goal(state, 0);
+ break;
+ }
}
-
- if (x > 4 || y > 4)
- return;
-
- do_input_move(state, x, y);
}
/* Figure out which tiles intersect a rectangle. */
{
Display *display = XtDisplay(state->goal);
Window game = XtWindow(state->game);
- uint_least32_t *gp = state->board.game;
+ uint_least32_t buf[3], *gp = state->board.game;
Dimension w, h;
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];
+ buf[i] = (gp[i] & ~GOAL_MASK) | (buf[i] << GOAL_SHIFT);
+ }
+ gp = buf;
+ }
+
for (i = 0; i < 25; i++) {
if (mask & 1) {
redraw_tile(state, display, game,