}
}
+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. */