http://ftp.x.org/contrib/applications/xscreensaver-2.23.tar.gz
[xscreensaver] / driver / demo.c
index b13622e175828704f30fa7fbf60edce7b5de3aa5..23a42974c6ae88d7015d173d4b6940835efa04ae 100644 (file)
@@ -1,5 +1,5 @@
 /* demo.c --- implements the interactive demo-mode and options dialogs.
- * xscreensaver, Copyright (c) 1993-1997 Jamie Zawinski <jwz@netscape.com>
+ * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@netscape.com>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
 
 #include <X11/Intrinsic.h>
 
-#ifdef DEBUG
-# include <X11/IntrinsicP.h>   /* just to get debug info for gdb... */
-# include <X11/ShellP.h>
-#endif
+/* We don't actually use any widget internals, but these are included
+   so that gdb will have debug info for the widgets... */
+#include <X11/IntrinsicP.h>
+#include <X11/ShellP.h>
 
 #ifdef HAVE_MOTIF
 # include <Xm/Xm.h>
@@ -226,6 +226,9 @@ select_cb (Widget button, XtPointer client_data, XtPointer call_data)
 #ifdef HAVE_ATHENA
   XawListReturnStruct *item = (XawListReturnStruct*)call_data;
   demo_mode_hack (si, item->string);
+  if (item->list_index >= 0)
+    si->default_screen->current_hack = item->list_index;
+
 #else  /* HAVE_MOTIF */
   XmListCallbackStruct *lcb = (XmListCallbackStruct *) call_data;
   char *string = 0;
@@ -233,7 +236,11 @@ select_cb (Widget button, XtPointer client_data, XtPointer call_data)
     XmStringGetLtoR (lcb->item, XmSTRING_DEFAULT_CHARSET, &string);
   set_text_string (text_line, (string ? string : ""));
   if (lcb->reason == XmCR_DEFAULT_ACTION && string)
-    demo_mode_hack (si, string);
+    {
+      demo_mode_hack (si, string);
+      if (lcb->item_position > 0)
+       si->default_screen->current_hack = lcb->item_position - 1;
+    }
   if (string)
     XtFree (string);
 #endif /* HAVE_MOTIF */
@@ -492,13 +499,12 @@ pop_up_dialog_box (Widget dialog, Widget form, int where)
   XtSetArg (av [ac], XtNheight, &h); ac++;
   XtGetValues (form, av, ac);
 
-#ifdef DEBUG
+  /* for debugging -- don't ask */
   if (where >= 69)
     {
       where -= 69;
       sw = (sw * 7) / 12;
     }
-#endif
 
   switch (where)
     {
@@ -619,18 +625,21 @@ make_screenhack_dialog (saver_info *si)
                 XtNnumberStrings, si->prefs.screenhacks_count,
                 0);
   XtAddCallback (demo_list, XtNcallback, select_cb, si);
-
-  /* ####   still need to do the "select most-recently-run hack"
-     ####   thing for Athena.
-  */
+  if (ssi->current_hack > 0)
+  XawListHighlight(demo_list, ssi->current_hack);
 
 #endif /* HAVE_ATHENA */
 
+  monitor_power_on (si);
   pop_up_dialog_box(demo_dialog, demo_form,
-#ifdef DEBUG
+                   /* for debugging -- don't ask */
                    (si->prefs.debug_p ? 69 : 0) +
-#endif
                    0);
+
+#ifdef HAVE_ATHENA
+  /* For Athena, have to do this after the dialog is managed. */
+  ensure_selected_item_visible (demo_list);
+#endif /* HAVE_ATHENA */
 }
 
 \f
@@ -744,21 +753,20 @@ res_done_cb (Widget button, XtPointer client_data, XtPointer call_data)
   p->unfade_p = res.unfade;
   p->lock_p = res.lock_p;
 
-#ifdef DEBUG
   if (p->debug_p && p->verbose_p)
     fprintf (stderr, "%s: parameters changed:\n\
        timeout: %d\n\tcycle:   %d\n\tlock:    %d\n\tpasswd:  %d\n\
        fade:    %d\n\tfade:    %d\n\tverbose: %d\n\tinstall: %d\n\
        fade:    %d\n\tunfade:  %d\n\tlock:    %d\n",
             progname, p->timeout, p->cycle, p->lock_timeout,
-# ifdef NO_LOCKING
+#ifdef NO_LOCKING
             0,
-# else
+#else
             p->passwd_timeout,
-# endif
+#endif
             p->fade_seconds, p->fade_ticks, p->verbose_p, p->install_cmap_p,
             p->fade_p, p->unfade_p, p->lock_p);
-#endif /* DEBUG */
+
 
 #if defined(HAVE_MIT_SAVER_EXTENSION) || defined(HAVE_SGI_SAVER_EXTENSION)
   if (p->use_mit_saver_extension || p->use_sgi_saver_extension)
@@ -911,10 +919,10 @@ pop_resources_dialog (saver_info *si)
   set_toggle_button_state (unfade_toggle, res.unfade);
   set_toggle_button_state (lock_toggle, res.lock_p);
 
+  monitor_power_on (si);
   pop_up_dialog_box (resources_dialog, resources_form,
-#ifdef DEBUG
+                    /* for debugging -- don't ask */
                     (si->prefs.debug_p ? 69 : 0) +
-#endif
                     1);
 }
 
@@ -927,7 +935,7 @@ demo_mode (saver_info *si)
 {
   saver_preferences *p = &si->prefs;
   si->dbox_up_p = True;
-  initialize_screensaver_window (si);
+  monitor_power_on (si);
   raise_window (si, True, False, False);
   make_screenhack_dialog (si);
   while (si->demo_mode_p)