+static void
+testx11_graph_rotator (struct testx11 *st)
+{
+ double x, y, z;
+
+ int boxw = st->xgwa.width / 3;
+ int boxh = (st->xgwa.height - (22 * 5)) / 4;
+ int boxx = st->xgwa.width - boxw - 20;
+ int boxy = st->xgwa.height - boxh - 20;
+
+ /* position */
+
+ get_position (st->rot, &x, &y, &z, True);
+ if (x < 0 || x >= 1 || y < 0 || y >= 1 || z < 0 || z >= 1) abort();
+
+
+ XSetForeground (st->dpy, st->graph_gc, st->dark_slate_gray1);
+ XDrawRectangle (st->dpy, st->win, st->graph_gc,
+ boxx-1, boxy-1, boxw+2, boxh+2);
+
+ XCopyArea (st->dpy, st->win, st->win, st->graph_gc,
+ boxx+1, boxy, boxw-1, boxh, boxx, boxy);
+
+ XSetForeground (st->dpy, st->graph_gc, BlackPixelOfScreen (st->xgwa.screen));
+ XDrawLine (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1, boxy,
+ boxx + boxw - 1, boxy + boxh);
+
+ XSetForeground (st->dpy, st->graph_gc, st->salmon);
+ XDrawPoint (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1,
+ boxy + boxh - 1 - (int) (x * (boxh - 1)));
+
+ XSetForeground (st->dpy, st->graph_gc, st->magenta);
+ XDrawPoint (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1,
+ boxy + boxh - 1 - (int) (y * (boxh - 1)));
+
+ XSetForeground (st->dpy, st->graph_gc, st->gray50);
+ XDrawPoint (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1,
+ boxy + boxh - 1 - (int) (z * (boxh - 1)));
+
+ /* spin */
+
+ get_rotation (st->rot, &x, &y, &z, True);
+ if (x < 0 || x >= 1 || y < 0 || y >= 1 || z < 0 || z >= 1) abort();
+
+ /* put 0 in the middle */
+ x += 0.5; if (x > 1) x--;
+ y += 0.5; if (y > 1) y--;
+ z += 0.5; if (z > 1) z--;
+
+
+ boxy -= boxh + 20;
+
+ XSetForeground (st->dpy, st->graph_gc, st->dark_slate_gray1);
+ XDrawRectangle (st->dpy, st->win, st->graph_gc,
+ boxx-1, boxy-1, boxw+2, boxh+2);
+
+ XCopyArea (st->dpy, st->win, st->win, st->graph_gc,
+ boxx+1, boxy, boxw-1, boxh, boxx, boxy);
+
+ XSetForeground (st->dpy, st->graph_gc, BlackPixelOfScreen (st->xgwa.screen));
+ XDrawLine (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1, boxy,
+ boxx + boxw - 1, boxy + boxh);
+
+ XSetForeground (st->dpy, st->graph_gc, st->magenta);
+ XDrawPoint (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1,
+ boxy + boxh - 1 - (int) (x * (boxh - 1)));
+
+
+ boxy -= boxh + 20;
+
+ XSetForeground (st->dpy, st->graph_gc, st->dark_slate_gray1);
+ XDrawRectangle (st->dpy, st->win, st->graph_gc,
+ boxx-1, boxy-1, boxw+2, boxh+2);
+
+ XCopyArea (st->dpy, st->win, st->win, st->graph_gc,
+ boxx+1, boxy, boxw-1, boxh, boxx, boxy);
+
+ XSetForeground (st->dpy, st->graph_gc, BlackPixelOfScreen (st->xgwa.screen));
+ XDrawLine (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1, boxy,
+ boxx + boxw - 1, boxy + boxh);
+
+ XSetForeground (st->dpy, st->graph_gc, st->magenta);
+ XDrawPoint (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1,
+ boxy + boxh - 1 - (int) (y * (boxh - 1)));
+
+
+ boxy -= boxh + 20;
+
+ XSetForeground (st->dpy, st->graph_gc, st->dark_slate_gray1);
+ XDrawRectangle (st->dpy, st->win, st->graph_gc,
+ boxx-1, boxy-1, boxw+2, boxh+2);
+
+ XCopyArea (st->dpy, st->win, st->win, st->graph_gc,
+ boxx+1, boxy, boxw-1, boxh, boxx, boxy);
+
+ XSetForeground (st->dpy, st->graph_gc, BlackPixelOfScreen (st->xgwa.screen));
+ XDrawLine (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1, boxy,
+ boxx + boxw - 1, boxy + boxh);
+
+ XSetForeground (st->dpy, st->graph_gc, st->magenta);
+ XDrawPoint (st->dpy, st->win, st->graph_gc,
+ boxx + boxw - 1,
+ boxy + boxh - 1 - (int) (z * (boxh - 1)));
+}
+
+
+/* Draws a blinking box in what should be the upper left corner of the
+ device, as physically oriented. The box is taller than it is wide.
+ */
+static void
+testx11_show_orientation (struct testx11 *st)
+{
+#ifdef HAVE_MOBILE
+ int x, y;
+ int w = st->xgwa.width;
+ int h = st->xgwa.height;
+ int ww = 15;
+ int hh = ww*2;
+ static int tick = 0;
+ static int oo = -1;
+ int o = (int) current_device_rotation ();
+
+ if (o != oo) {
+// fprintf (stderr,"ROT %d -> %d\n", oo, o);
+ oo = o;
+ }
+
+ switch (o) {
+ case 0: case 360: x = 0; y = 0; w = ww; h = hh; break;
+ case 90: case -270: x = 0; y = h-ww; w = hh; h = ww; break;
+ case -90: case 270: x = w-hh; y = 0; w = hh; h = ww; break;
+ case 180: case -180: x = w-ww; y = h-hh; w = ww; h = hh; break;
+ default: return;
+ }
+
+ if (++tick > 20) tick = 0;
+
+ XSetForeground (st->dpy, st->graph_gc,
+ (tick > 10
+ ? WhitePixelOfScreen (st->xgwa.screen)
+ : BlackPixelOfScreen (st->xgwa.screen)));
+ XFillRectangle (st->dpy, st->win, st->graph_gc,
+ x, y, w, h);
+#endif
+}
+
+