]> git.draconx.ca Git - rrace.git/blobdiff - src/motif_ui.c
Right clicking on game area now shows the objective.
[rrace.git] / src / motif_ui.c
index 4734d054958cee5a495568fb8a16a2fcb66da4af..eca3e797605d5f42d910439144ac425782a31b4c 100644 (file)
@@ -238,27 +238,45 @@ static void do_input_move(struct app_state *state, int x, int y)
        }
 }
 
+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. */