+static trackball_state *trackball;
+static Bool button_down_p = False;
+
+
+Bool
+screenflip_handle_event (ModeInfo *mi, XEvent *event)
+{
+ if (event->xany.type == ButtonPress &&
+ event->xbutton.button & Button1)
+ {
+ button_down_p = True;
+ gltrackball_start (trackball,
+ event->xbutton.x, event->xbutton.y,
+ MI_WIDTH (mi), MI_HEIGHT (mi));
+ return True;
+ }
+ else if (event->xany.type == ButtonRelease &&
+ event->xbutton.button & Button1)
+ {
+ button_down_p = False;
+ return True;
+ }
+ else if (event->xany.type == MotionNotify &&
+ button_down_p)
+ {
+ gltrackball_track (trackball,
+ event->xmotion.x, event->xmotion.y,
+ MI_WIDTH (mi), MI_HEIGHT (mi));
+ return True;
+ }
+
+ return False;
+}
+