+static void
+undo_vp_motion (saver_info *si)
+{
+#ifdef HAVE_XF86VMODE
+ saver_preferences *p = &si->prefs;
+ int screen = 0; /* always screen 0 */
+ saver_screen_info *ssi = &si->screens[screen];
+ int event, error, x, y;
+ Bool status;
+
+ if (ssi->blank_vp_x == -1 && ssi->blank_vp_y == -1)
+ return;
+ if (!XF86VidModeQueryExtension (si->dpy, &event, &error))
+ return;
+ if (!XF86VidModeGetViewPort (si->dpy, 0, &x, &y))
+ return;
+ if (ssi->blank_vp_x == x && ssi->blank_vp_y == y)
+ return;
+
+ /* We're going to move the viewport. The mouse has just been grabbed on
+ (and constrained to, thus warped to) the password window, so it is no
+ longer near the edge of the screen. However, wait a bit anyway, just
+ to make sure the server drains its last motion event, so that the
+ screen doesn't continue to scroll after we've reset the viewport.
+ */
+ XSync (si->dpy, False);
+ usleep (250); /* 1/4 second */
+ XSync (si->dpy, False);
+
+ status = XF86VidModeSetViewPort (si->dpy, screen,
+ ssi->blank_vp_x, ssi->blank_vp_y);
+
+ if (!status)
+ fprintf (stderr, "%s: unable to move vp from (%d,%d) back to (%d,%d)!\n",
+ blurb(), x, y, ssi->blank_vp_x, ssi->blank_vp_y);
+ else if (p->verbose_p)
+ fprintf (stderr, "%s: vp moved to (%d,%d); moved it back to (%d,%d).\n",
+ blurb(), x, y, ssi->blank_vp_x, ssi->blank_vp_y);
+
+#endif /* HAVE_XF86VMODE */
+}
+
+
+static void
+set_vp_mode_switch_locked (saver_info *si, Bool locked_p)
+{
+#ifdef HAVE_XF86VMODE
+ saver_preferences *p = &si->prefs;
+ int screen = 0; /* always screen 0 */
+ int event, error;
+ Bool status;
+
+ if (!XF86VidModeQueryExtension (si->dpy, &event, &error))
+ return;
+ status = XF86VidModeLockModeSwitch (si->dpy, screen, locked_p);
+
+ if (!status)
+ fprintf (stderr, "%s: unable to %s vp switching!\n",
+ blurb(), (locked_p ? "lock" : "unlock"));
+ else if (p->verbose_p)
+ fprintf (stderr, "%s: %s vp switching.\n",
+ blurb(), (locked_p ? "locked" : "unlocked"));
+#endif /* HAVE_XF86VMODE */
+}
+
+