~ubuntu-branches/ubuntu/quantal/xscreensaver/quantal

« back to all changes in this revision

Viewing changes to driver/xscreensaver.c

  • Committer: Bazaar Package Importer
  • Author(s): Ted Gould
  • Date: 2008-08-28 16:15:25 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080828161525-mxga521aoezxjq8h
Tags: 5.07-0ubuntu1
* Upgrade upstream version
* debian/control: Remove suggest xdaliclock as it is no longer
  included
* Remove 10_jwz-screensaver-randr-patch-3.patch as it has been merged
  upstream.
* Add 24_hacks_xsublim_enable.patch as it seems that xsublim was dropped
  from the build files.  There is nothing in the Changelog about it
  so I believe it was accidental.
* Updating the .desktop files from the XML files using gnome-screensaver's
  utility to do so.  Lots of text updates.  Also:
    * Added: abstractile.desktop
    * Added: cwaves.desktop
    * Added: m6502.desktop
    * Added: skytentacles.desktop
    * Removed: xteevee.desktop
* xscreensaver-gl-extra.files: Added skytentacles
* xscreensaver-data-extra.files: Added abstractile, cwaves and m6502
* xscreensaver-data.files: Remove partial abstractile, m6502 and cwaves

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 *   via the $XSCREENSAVER_WINDOW environment variable -- this trick requires
47
47
 *   a recent (Aug 2003) revision of vroot.h.
48
48
 *
 
49
 *   (See comments in screens.c for more details about Xinerama/RANDR stuff.)
 
50
 *
49
51
 *   While we are waiting for user activity, we also set up timers so that,
50
52
 *   after a certain amount of time has passed, we can start a different
51
53
 *   screenhack.  We do this by killing the running child process with
164
166
# include "xmu.h"
165
167
#endif /* !HAVE_XMU */
166
168
 
 
169
#ifdef HAVE_MIT_SAVER_EXTENSION
 
170
#include <X11/extensions/scrnsaver.h>
 
171
#endif /* HAVE_MIT_SAVER_EXTENSION */
 
172
 
167
173
#ifdef HAVE_XIDLE_EXTENSION
168
174
# include <X11/extensions/xidle.h>
169
175
#endif /* HAVE_XIDLE_EXTENSION */
170
176
 
 
177
#ifdef HAVE_SGI_VC_EXTENSION
 
178
# include <X11/extensions/XSGIvc.h>
 
179
#endif /* HAVE_SGI_VC_EXTENSION */
 
180
 
 
181
#ifdef HAVE_READ_DISPLAY_EXTENSION
 
182
# include <X11/extensions/readdisplay.h>
 
183
#endif /* HAVE_READ_DISPLAY_EXTENSION */
 
184
 
 
185
#ifdef HAVE_XSHM_EXTENSION
 
186
# include <X11/extensions/XShm.h>
 
187
#endif /* HAVE_XSHM_EXTENSION */
 
188
 
 
189
#ifdef HAVE_DPMS_EXTENSION
 
190
# include <X11/extensions/dpms.h>
 
191
#endif /* HAVE_DPMS_EXTENSION */
 
192
 
 
193
 
 
194
#ifdef HAVE_DOUBLE_BUFFER_EXTENSION
 
195
# include <X11/extensions/Xdbe.h>
 
196
#endif /* HAVE_DOUBLE_BUFFER_EXTENSION */
 
197
 
 
198
#ifdef HAVE_XF86VMODE
 
199
# include <X11/extensions/xf86vmode.h>
 
200
#endif /* HAVE_XF86VMODE */
 
201
 
 
202
#ifdef HAVE_XF86MISCSETGRABKEYSSTATE
 
203
# include <X11/extensions/xf86misc.h>
 
204
#endif /* HAVE_XF86MISCSETGRABKEYSSTATE */
 
205
 
171
206
#ifdef HAVE_XINERAMA
172
207
# include <X11/extensions/Xinerama.h>
173
208
#endif /* HAVE_XINERAMA */
174
209
 
 
210
#ifdef HAVE_RANDR
 
211
# include <X11/extensions/Xrandr.h>
 
212
#endif /* HAVE_RANDR */
 
213
 
 
214
 
175
215
#include "xscreensaver.h"
176
216
#include "version.h"
177
217
#include "yarandom.h"
205
245
 
206
246
  /* useful for debugging */
207
247
  { "-no-capture-stderr",  ".captureStderr",    XrmoptionNoArg, "off" },
 
248
  { "-log",                ".logFile",          XrmoptionSepArg, 0 },
208
249
};
209
250
 
210
251
#ifdef __GNUC__
263
304
  return str;
264
305
}
265
306
 
266
 
static Bool blurb_timestamp_p = False;   /* kludge */
 
307
static Bool blurb_timestamp_p = True;   /* kludge */
267
308
 
268
309
const char *
269
310
blurb (void)
334
375
        }
335
376
      else
336
377
        {
337
 
          fprintf (real_stderr,
338
 
                   "#######################################"
339
 
                   "#######################################\n\n");
340
 
          fprintf (real_stderr,
 
378
#ifdef __GNUC__
 
379
  __extension__   /* don't warn about "string length is greater than the
 
380
                     length ISO C89 compilers are required to support". */
 
381
#endif
 
382
          fprintf (real_stderr,
 
383
   "#######################################################################\n"
 
384
   "\n"
341
385
   "    If at all possible, please re-run xscreensaver with the command\n"
342
 
   "    line arguments `-sync -verbose -no-capture', and reproduce this\n"
 
386
   "    line arguments `-sync -verbose -log log.txt', and reproduce this\n"
343
387
   "    bug.  That will cause xscreensaver to dump a `core' file to the\n"
344
388
   "    current directory.  Please include the stack trace from that core\n"
345
 
   "    file in your bug report.  *DO NOT* mail the core file itself!\n"
346
 
   "    That won't work.\n");
347
 
          fprintf (real_stderr,
 
389
   "    file in your bug report.  *DO NOT* mail the core file itself!  That\n"
 
390
   "    won't work.  A \"log.txt\" file will also be written.  Please *do*\n"
 
391
   "    include the complete \"log.txt\" file with your bug report.\n"
348
392
   "\n"
349
393
   "    http://www.jwz.org/xscreensaver/bugs.html explains how to create\n"
350
394
   "    the most useful bug reports, and how to examine core files.\n"
351
395
   "\n"
352
396
   "    The more information you can provide, the better.  But please\n"
353
397
   "    report this bug, regardless!\n"
 
398
   "\n"
 
399
   "#######################################################################\n"
 
400
   "\n"
354
401
   "\n");
355
 
          fprintf (real_stderr,
356
 
                   "#######################################"
357
 
                   "#######################################\n\n");
358
402
 
359
403
          saver_exit (si, -1, 0);
360
404
        }
658
702
    with `xscreensaver-demo' or `xscreensaver-command'.\n\
659
703
.   See the man pages for details, or check the web page:\n\
660
704
    http://www.jwz.org/xscreensaver/\n\n");
661
 
 
662
 
              /* Since version 1.21 renamed the "-lock" option to "-lock-mode",
663
 
                 suggest that explicitly. */
664
 
              if (!strcmp (s, "-lock"))
665
 
                fprintf (stderr, "\
666
 
    Or perhaps you meant either the \"-lock-mode\" or the\n\
667
 
    \"-lock-timeout <minutes>\" options to xscreensaver?\n\n");
668
705
            }
669
706
 
670
707
          exit (1);
755
792
}
756
793
 
757
794
 
758
 
#ifdef HAVE_XINERAMA
759
 
 
760
 
static Bool
761
 
screens_overlap_p (XineramaScreenInfo *a, XineramaScreenInfo *b)
762
 
{
763
 
  /* Two rectangles overlap if the max of the tops is less than the
764
 
     min of the bottoms and the max of the lefts is less than the min
765
 
     of the rights.
766
 
   */
767
 
# undef MAX
768
 
# undef MIN
769
 
# define MAX(A,B) ((A)>(B)?(A):(B))
770
 
# define MIN(A,B) ((A)<(B)?(A):(B))
771
 
 
772
 
  int maxleft  = MAX(a->x_org, b->x_org);
773
 
  int maxtop   = MAX(a->y_org, b->y_org);
774
 
  int minright = MIN(a->x_org + a->width  - 1, b->x_org + b->width);
775
 
  int minbot   = MIN(a->y_org + a->height - 1, b->y_org + b->height);
776
 
  return (maxtop < minbot && maxleft < minright);
777
 
}
778
 
 
779
 
 
780
 
/* Go through the list of Xinerama screen descriptions, and mark the
781
 
   ones that appear to be insane, so that we don't use them.
782
 
 */
783
 
static void
784
 
check_xinerama_sanity (int count, Bool verbose_p, XineramaScreenInfo *xsi)
785
 
{
786
 
  static Bool printed_p = False;
787
 
  int i, j;
788
 
  char err[1024];
789
 
  *err = 0;
790
 
 
791
 
# define X1 xsi[i].x_org
792
 
# define X2 xsi[j].x_org
793
 
# define Y1 xsi[i].y_org
794
 
# define Y2 xsi[j].y_org
795
 
# define W1 xsi[i].width
796
 
# define W2 xsi[j].width
797
 
# define H1 xsi[i].height
798
 
# define H2 xsi[j].height
799
 
 
800
 
# define WHINE() do {                                                        \
801
 
    if (verbose_p) {                                                         \
802
 
      if (! printed_p) {                                                     \
803
 
        fprintf (stderr, "%s: compensating for Xinerama braindamage:\n",     \
804
 
                 blurb());                                                   \
805
 
        printed_p = True;                                                    \
806
 
      }                                                                      \
807
 
      fprintf (stderr, "%s:   %d: %s\n", blurb(), xsi[i].screen_number,err); \
808
 
    }                                                                        \
809
 
    xsi[i].screen_number = -1;                                               \
810
 
  } while(0)
811
 
 
812
 
  /* If a screen is enclosed by any other screen, that's insane.
813
 
   */
814
 
  for (i = 0; i < count; i++)
815
 
    for (j = 0; j < count; j++)
816
 
      if (i != j &&
817
 
          xsi[i].screen_number >= 0 &&
818
 
          xsi[j].screen_number >= 0 &&
819
 
          X1 >= X2 && Y1 >= Y2 && (X1+W1) <= (X2+W2) && (X1+H1) <= (X2+H2))
820
 
        {
821
 
          sprintf (err, "%dx%d+%d+%d enclosed by %dx%d+%d+%d",
822
 
                   W1, H1, X1, Y1,
823
 
                   W2, H2, X2, Y2);
824
 
          WHINE();
825
 
          continue;
826
 
        }
827
 
 
828
 
  /* After checking for enclosure, check for other lossage against earlier
829
 
     screens.  We do enclosure first so that we make sure to pick the
830
 
     larger one.
831
 
   */
832
 
  for (i = 0; i < count; i++)
833
 
    for (j = 0; j < i; j++)
834
 
      {
835
 
        if (xsi[i].screen_number < 0) continue; /* already marked */
836
 
 
837
 
        *err = 0;
838
 
        if (X1 == X2 && Y1 == Y2 && W1 == W2 && H1 == H2)
839
 
          sprintf (err, "%dx%d+%d+%d duplicated", W1, H1, X1, Y1);
840
 
 
841
 
        else if (screens_overlap_p (&xsi[i], &xsi[j]))
842
 
          sprintf (err, "%dx%d+%d+%d overlaps %dx%d+%d+%d",
843
 
                   W1, H1, X1, Y1,
844
 
                   W2, H2, X2, Y2);
845
 
 
846
 
        if (*err) WHINE();
847
 
      }
848
 
 
849
 
# undef X1
850
 
# undef X2
851
 
# undef Y1
852
 
# undef Y2
853
 
# undef W1
854
 
# undef W2
855
 
# undef H1
856
 
# undef H2
857
 
}
858
 
 
859
 
#endif /* HAVE_XINERAMA */
860
 
 
 
795
/* called from screens.c so that all the Xt crud is here. */
 
796
void
 
797
initialize_screen_root_widget (saver_screen_info *ssi)
 
798
{
 
799
  saver_info *si = ssi->global;
 
800
  if (ssi->toplevel_shell)
 
801
    XtDestroyWidget (ssi->toplevel_shell);
 
802
  ssi->toplevel_shell =
 
803
    XtVaAppCreateShell (progname, progclass, 
 
804
                        applicationShellWidgetClass,
 
805
                        si->dpy,
 
806
                        XtNscreen, ssi->screen,
 
807
                        XtNvisual, ssi->current_visual,
 
808
                        XtNdepth,  visual_depth (ssi->screen,
 
809
                                                 ssi->current_visual),
 
810
                        NULL);
 
811
}
861
812
 
862
813
 
863
814
/* Examine all of the display's screens, and populate the `saver_screen_info'
866
817
static void
867
818
initialize_per_screen_info (saver_info *si, Widget toplevel_shell)
868
819
{
869
 
  Bool found_any_writable_cells = False;
870
820
  int i;
871
821
 
872
 
# ifdef HAVE_XINERAMA
873
 
  {
874
 
    int event, error;
875
 
    si->xinerama_p = (XineramaQueryExtension (si->dpy, &event, &error) &&
876
 
                      XineramaIsActive (si->dpy));
877
 
  }
878
 
 
879
 
  if (si->xinerama_p && ScreenCount (si->dpy) != 1)
880
 
    {
881
 
      si->xinerama_p = False;
882
 
      if (si->prefs.verbose_p)
883
 
        fprintf (stderr,
884
 
                 "%s: Xinerama AND %d screens?  Disabling Xinerama support!\n",
885
 
                 blurb(), ScreenCount(si->dpy));
886
 
    }
887
 
 
888
 
  if (si->xinerama_p)
889
 
    {
890
 
      int nscreens = 0;
891
 
      XineramaScreenInfo *xsi = XineramaQueryScreens (si->dpy, &nscreens);
892
 
      if (!xsi)
893
 
        si->xinerama_p = False;
894
 
      else
895
 
        {
896
 
          int j = 0;
897
 
          si->screens = (saver_screen_info *)
898
 
            calloc(sizeof(saver_screen_info), nscreens);
899
 
          check_xinerama_sanity (nscreens, si->prefs.verbose_p, xsi);
900
 
          for (i = 0; i < nscreens; i++)
901
 
            {
902
 
              if (xsi[i].screen_number < 0)  /* deemed insane */
903
 
                continue;
904
 
              si->screens[j].x      = xsi[i].x_org;
905
 
              si->screens[j].y      = xsi[i].y_org;
906
 
              si->screens[j].width  = xsi[i].width;
907
 
              si->screens[j].height = xsi[i].height;
908
 
              j++;
909
 
            }
910
 
          si->nscreens = j;
911
 
          XFree (xsi);
912
 
        }
913
 
      si->default_screen = &si->screens[0];
914
 
      si->default_screen->real_screen_p = True;
915
 
    }
916
 
# endif /* !HAVE_XINERAMA */
917
 
 
918
 
  if (!si->xinerama_p)
919
 
    {
920
 
      si->nscreens = ScreenCount(si->dpy);
921
 
      si->screens = (saver_screen_info *)
922
 
        calloc(sizeof(saver_screen_info), si->nscreens);
923
 
      si->default_screen = &si->screens[DefaultScreen(si->dpy)];
924
 
 
925
 
      for (i = 0; i < si->nscreens; i++)
926
 
        {
927
 
          saver_screen_info *ssi = &si->screens[i];
928
 
          ssi->width  = DisplayWidth  (si->dpy, i);
929
 
          ssi->height = DisplayHeight (si->dpy, i);
930
 
          ssi->real_screen_p = True;
931
 
          ssi->real_screen_number = i;
932
 
        }
933
 
    }
934
 
 
935
 
 
936
 
# ifdef QUAD_MODE
937
 
  /* In "quad mode", we use the Xinerama code to pretend that there are 4
938
 
     screens for every physical screen, and run four times as many hacks...
939
 
   */
940
 
  if (si->prefs.quad_p)
941
 
    {
942
 
      int ns2 = si->nscreens * 4;
943
 
      saver_screen_info *ssi2 = (saver_screen_info *)
944
 
        calloc(sizeof(saver_screen_info), ns2);
945
 
 
946
 
      for (i = 0; i < si->nscreens; i++)
947
 
        {
948
 
          saver_screen_info *old = &si->screens[i];
949
 
 
950
 
          if (si->prefs.debug_p) old->width = old->width / 2;
951
 
 
952
 
          ssi2[i*4  ] = *old;
953
 
          ssi2[i*4+1] = *old;
954
 
          ssi2[i*4+2] = *old;
955
 
          ssi2[i*4+3] = *old;
956
 
 
957
 
          ssi2[i*4  ].width  /= 2;
958
 
          ssi2[i*4  ].height /= 2;
959
 
 
960
 
          ssi2[i*4+1].x      += ssi2[i*4  ].width;
961
 
          ssi2[i*4+1].width  -= ssi2[i*4  ].width;
962
 
          ssi2[i*4+1].height /= 2;
963
 
 
964
 
          ssi2[i*4+2].y      += ssi2[i*4  ].height;
965
 
          ssi2[i*4+2].width  /= 2;
966
 
          ssi2[i*4+2].height -= ssi2[i*4  ].height;
967
 
 
968
 
          ssi2[i*4+3].x      += ssi2[i*4+2].width;
969
 
          ssi2[i*4+3].y      += ssi2[i*4+2].height;
970
 
          ssi2[i*4+3].width  -= ssi2[i*4+2].width;
971
 
          ssi2[i*4+3].height -= ssi2[i*4+2].height;
972
 
 
973
 
          ssi2[i*4+1].real_screen_p = False;
974
 
          ssi2[i*4+2].real_screen_p = False;
975
 
          ssi2[i*4+3].real_screen_p = False;
976
 
        }
977
 
 
978
 
      si->nscreens = ns2;
979
 
      free (si->screens);
980
 
      si->screens = ssi2;
981
 
      si->default_screen = &si->screens[DefaultScreen(si->dpy) * 4];
982
 
      si->xinerama_p = True;
983
 
    }
984
 
# endif /* QUAD_MODE */
985
 
 
986
 
  /* finish initializing the screens.
 
822
  update_screen_layout (si);
 
823
 
 
824
  /* Check to see whether fading is ever possible -- if any of the
 
825
     screens on the display has a PseudoColor visual, then fading can
 
826
     work (on at least some screens.)  If no screen has a PseudoColor
 
827
     visual, then don't bother ever trying to fade, because it will
 
828
     just cause a delay without causing any visible effect.
987
829
   */
988
830
  for (i = 0; i < si->nscreens; i++)
989
831
    {
990
832
      saver_screen_info *ssi = &si->screens[i];
991
 
      ssi->global = si;
992
 
 
993
 
      ssi->number = i;
994
 
      ssi->screen = ScreenOfDisplay (si->dpy, ssi->real_screen_number);
995
 
      ssi->poll_mouse_last_root_x = -1;
996
 
      ssi->poll_mouse_last_root_y = -1;
997
 
 
998
 
      if (!si->xinerama_p)
 
833
      if (has_writable_cells (ssi->screen, ssi->current_visual) ||
 
834
          get_visual (ssi->screen, "PseudoColor", True, False) ||
 
835
          get_visual (ssi->screen, "GrayScale", True, False))
999
836
        {
1000
 
          ssi->width  = WidthOfScreen  (ssi->screen);
1001
 
          ssi->height = HeightOfScreen (ssi->screen);
 
837
          si->fading_possible_p = True;
 
838
          break;
1002
839
        }
1003
 
 
1004
 
      /* Note: we can't use the resource ".visual" because Xt is SO FUCKED. */
1005
 
      ssi->default_visual =
1006
 
        get_visual_resource (ssi->screen, "visualID", "VisualID", False);
1007
 
 
1008
 
      ssi->current_visual = ssi->default_visual;
1009
 
      ssi->current_depth = visual_depth (ssi->screen, ssi->current_visual);
1010
 
 
1011
 
      /* Execute a subprocess to find the GL visual. */
1012
 
      ssi->best_gl_visual = get_best_gl_visual (ssi);
1013
 
 
1014
 
      if (ssi == si->default_screen)
1015
 
        /* Since this is the default screen, use the one already created. */
1016
 
        ssi->toplevel_shell = toplevel_shell;
1017
 
      else
1018
 
        /* Otherwise, each screen must have its own unmapped root widget. */
1019
 
        ssi->toplevel_shell =
1020
 
          XtVaAppCreateShell (progname, progclass, applicationShellWidgetClass,
1021
 
                              si->dpy,
1022
 
                              XtNscreen, ssi->screen,
1023
 
                              XtNvisual, ssi->current_visual,
1024
 
                              XtNdepth,  visual_depth (ssi->screen,
1025
 
                                                       ssi->current_visual),
1026
 
                              NULL);
1027
 
 
1028
 
      if (! found_any_writable_cells)
1029
 
        {
1030
 
          /* Check to see whether fading is ever possible -- if any of the
1031
 
             screens on the display has a PseudoColor visual, then fading can
1032
 
             work (on at least some screens.)  If no screen has a PseudoColor
1033
 
             visual, then don't bother ever trying to fade, because it will
1034
 
             just cause a delay without causing any visible effect.
1035
 
          */
1036
 
          if (has_writable_cells (ssi->screen, ssi->current_visual) ||
1037
 
              get_visual (ssi->screen, "PseudoColor", True, False) ||
1038
 
              get_visual (ssi->screen, "GrayScale", True, False))
1039
 
            found_any_writable_cells = True;
1040
 
        }
1041
840
    }
1042
841
 
1043
 
  si->fading_possible_p = found_any_writable_cells;
1044
 
 
1045
842
#ifdef HAVE_XF86VMODE_GAMMA
1046
843
  si->fading_possible_p = True;  /* if we can gamma fade, go for it */
1047
844
#endif
1068
865
  si->using_proc_interrupts = p->use_proc_interrupts;
1069
866
 
1070
867
#ifdef HAVE_XIDLE_EXTENSION
1071
 
  server_has_xidle_extension_p = query_xidle_extension (si);
 
868
  {
 
869
    int ev, er;
 
870
    server_has_xidle_extension_p = XidleQueryExtension (si->dpy, &ev, &er);
 
871
  }
1072
872
#endif
1073
873
#ifdef HAVE_SGI_SAVER_EXTENSION
1074
 
  server_has_sgi_saver_extension_p = query_sgi_saver_extension (si);
 
874
  server_has_sgi_saver_extension_p =
 
875
    XScreenSaverQueryExtension (si->dpy,
 
876
                                &si->sgi_saver_ext_event_number,
 
877
                                &si->sgi_saver_ext_error_number);
1075
878
#endif
1076
879
#ifdef HAVE_MIT_SAVER_EXTENSION
1077
 
  server_has_mit_saver_extension_p = query_mit_saver_extension (si);
 
880
  server_has_mit_saver_extension_p =
 
881
    XScreenSaverQueryExtension (si->dpy,
 
882
                                &si->mit_saver_ext_event_number,
 
883
                                &si->mit_saver_ext_error_number);
1078
884
#endif
1079
885
#ifdef HAVE_PROC_INTERRUPTS
1080
886
  system_has_proc_interrupts_p = query_proc_interrupts_available (si, &piwhy);
1115
921
                 blurb());
1116
922
    }
1117
923
 
1118
 
  /* These are incompatible (or at least, our support for them is...) */
1119
 
  if (si->xinerama_p && si->using_mit_saver_extension)
 
924
#ifdef HAVE_RANDR
 
925
  if (XRRQueryExtension (si->dpy,
 
926
                         &si->randr_event_number, &si->randr_error_number))
1120
927
    {
1121
 
      si->using_mit_saver_extension = False;
 
928
      int nscreens = ScreenCount (si->dpy);  /* number of *real* screens */
 
929
      int i;
 
930
 
1122
931
      if (p->verbose_p)
1123
 
        fprintf (stderr, "%s: Xinerama in use: disabling MIT-SCREEN-SAVER.\n",
1124
 
                 blurb());
 
932
        fprintf (stderr, "%s: selecting RANDR events\n", blurb());
 
933
      for (i = 0; i < nscreens; i++)
 
934
#  ifdef RRScreenChangeNotifyMask                 /* randr.h 1.5, 2002/09/29 */
 
935
        XRRSelectInput (si->dpy, RootWindow (si->dpy, i),
 
936
                        RRScreenChangeNotifyMask);
 
937
#  else  /* !RRScreenChangeNotifyMask */          /* Xrandr.h 1.4, 2001/06/07 */
 
938
        XRRScreenChangeSelectInput (si->dpy, RootWindow (si->dpy, i), True);
 
939
#  endif /* !RRScreenChangeNotifyMask */
1125
940
    }
1126
 
 
1127
 
#ifdef HAVE_RANDR
1128
 
  query_randr_extension (si);
1129
 
#endif
 
941
# endif /* HAVE_RANDR */
1130
942
 
1131
943
  if (!system_has_proc_interrupts_p)
1132
944
    {
1149
961
}
1150
962
 
1151
963
 
 
964
#ifdef DEBUG_MULTISCREEN
 
965
static void
 
966
debug_multiscreen_timer (XtPointer closure, XtIntervalId *id)
 
967
{
 
968
  saver_info *si = (saver_info *) closure;
 
969
  saver_preferences *p = &si->prefs;
 
970
  if (update_screen_layout (si))
 
971
    {
 
972
      if (p->verbose_p)
 
973
        {
 
974
          fprintf (stderr, "%s: new layout:\n", blurb());
 
975
          describe_monitor_layout (si);
 
976
        }
 
977
      resize_screensaver_window (si);
 
978
    }
 
979
  XtAppAddTimeOut (si->app, 1000*4, debug_multiscreen_timer, (XtPointer) si);
 
980
}
 
981
#endif /* DEBUG_MULTISCREEN */
 
982
 
 
983
 
1152
984
/* For the case where we aren't using an server extensions, select user events
1153
985
   on all the existing windows, and launch timers to select events on
1154
986
   newly-created windows as well.
1201
1033
 
1202
1034
  if (p->verbose_p)
1203
1035
    fprintf (stderr, " done.\n");
 
1036
 
 
1037
# ifdef DEBUG_MULTISCREEN
 
1038
  if (p->debug_p) debug_multiscreen_timer ((XtPointer) si, 0);
 
1039
# endif
1204
1040
}
1205
1041
 
1206
1042
 
1247
1083
{
1248
1084
  saver_preferences *p = &si->prefs;
1249
1085
  Bool ok_to_unblank;
 
1086
  int i;
1250
1087
 
1251
1088
  while (1)
1252
1089
    {
1342
1179
            }
1343
1180
        }
1344
1181
 
1345
 
      kill_screenhack (si);
 
1182
      for (i = 0; i < si->nscreens; i++)
 
1183
        kill_screenhack (&si->screens[i]);
1346
1184
 
1347
 
      if (!si->throttled_p)
1348
 
        spawn_screenhack (si, True);
1349
 
      else if (p->verbose_p)
 
1185
      raise_window (si, True, True, False);
 
1186
      if (si->throttled_p)
1350
1187
        fprintf (stderr, "%s: not launching hack (throttled.)\n", blurb());
 
1188
      else
 
1189
        for (i = 0; i < si->nscreens; i++)
 
1190
          spawn_screenhack (&si->screens[i]);
1351
1191
 
1352
1192
      /* Don't start the cycle timer in demo mode. */
1353
1193
      if (!si->demoing_p && p->cycle)
1418
1258
 
1419
1259
            was_locked = True;
1420
1260
            si->dbox_up_p = True;
1421
 
            suspend_screenhack (si, True);
 
1261
            for (i = 0; i < si->nscreens; i++)
 
1262
              suspend_screenhack (&si->screens[i], True);         /* suspend */
1422
1263
            XUndefineCursor (si->dpy, ssi->screensaver_window);
1423
1264
 
1424
1265
            ok_to_unblank = unlock_p (si);
1425
1266
 
1426
1267
            si->dbox_up_p = False;
1427
1268
            XDefineCursor (si->dpy, ssi->screensaver_window, ssi->cursor);
1428
 
            suspend_screenhack (si, False);     /* resume */
 
1269
            for (i = 0; i < si->nscreens; i++)
 
1270
              suspend_screenhack (&si->screens[i], False);         /* resume */
1429
1271
 
1430
1272
            if (!ok_to_unblank &&
1431
1273
                !screenhack_running_p (si))
1451
1293
                 blurb(), timestring ());
1452
1294
 
1453
1295
      /* Kill before unblanking, to stop drawing as soon as possible. */
1454
 
      kill_screenhack (si);
 
1296
      for (i = 0; i < si->nscreens; i++)
 
1297
        kill_screenhack (&si->screens[i]);
1455
1298
      unblank_screen (si);
1456
1299
 
1457
1300
      set_locked_p (si, False);
1530
1373
 
1531
1374
  shell = connect_to_server (si, &argc, argv);
1532
1375
  process_command_line (si, &argc, argv);
 
1376
  stderr_log_file (si);
1533
1377
  print_banner (si);
1534
1378
 
1535
1379
  load_init_file(si->dpy, p); /* must be before initialize_per_screen_info() */
1951
1795
                                  "exiting.");
1952
1796
          if (! until_idle_p)
1953
1797
            {
 
1798
              int i;
 
1799
              for (i = 0; i < si->nscreens; i++)
 
1800
                kill_screenhack (&si->screens[i]);
1954
1801
              unblank_screen (si);
1955
 
              kill_screenhack (si);
1956
1802
              XSync (si->dpy, False);
1957
1803
            }
1958
1804
          saver_exit (si, 0, 0);
1974
1820
                                  "restarting.");
1975
1821
          if (! until_idle_p)
1976
1822
            {
 
1823
              int i;
 
1824
              for (i = 0; i < si->nscreens; i++)
 
1825
                kill_screenhack (&si->screens[i]);
1977
1826
              unblank_screen (si);
1978
 
              kill_screenhack (si);
1979
1827
              XSync (si->dpy, False);
1980
1828
            }
1981
1829
 
2173
2021
{
2174
2022
  int i, j;
2175
2023
  static struct {
2176
 
    const char *name; const char *desc; Bool useful_p;
 
2024
    const char *name; const char *desc; 
 
2025
    Bool useful_p;
 
2026
    Status (*version_fn) (Display *, int *majP, int *minP);
2177
2027
  } exts[] = {
2178
2028
 
2179
2029
   { "SCREEN_SAVER", /* underscore */           "SGI Screen-Saver",
2180
2030
#     ifdef HAVE_SGI_SAVER_EXTENSION
2181
 
        True
 
2031
        True,  0
2182
2032
#     else
2183
 
        False
 
2033
        False, 0
2184
2034
#     endif
2185
2035
   }, { "SCREEN-SAVER", /* dash */              "SGI Screen-Saver",
2186
2036
#     ifdef HAVE_SGI_SAVER_EXTENSION
2187
 
        True
 
2037
        True,  0
2188
2038
#     else
2189
 
        False
 
2039
        False, 0
2190
2040
#     endif
2191
2041
   }, { "MIT-SCREEN-SAVER",                     "MIT Screen-Saver",
2192
2042
#     ifdef HAVE_MIT_SAVER_EXTENSION
2193
 
        True
 
2043
        True,  XScreenSaverQueryVersion
2194
2044
#     else
2195
 
        False
 
2045
        False, 0
2196
2046
#     endif
2197
2047
   }, { "XIDLE",                                "XIdle",           
2198
2048
#     ifdef HAVE_XIDLE_EXTENSION
2199
 
        True
 
2049
        True,  0
2200
2050
#     else
2201
 
        False
 
2051
        False, 0
2202
2052
#     endif
2203
2053
   }, { "SGI-VIDEO-CONTROL",                    "SGI Video-Control",
2204
2054
#     ifdef HAVE_SGI_VC_EXTENSION
2205
 
        True
 
2055
        True,  XSGIvcQueryVersion
2206
2056
#     else
2207
 
        False
 
2057
        False, 0
2208
2058
#     endif
2209
2059
   }, { "READDISPLAY",                          "SGI Read-Display",
2210
2060
#     ifdef HAVE_READ_DISPLAY_EXTENSION
2211
 
        True
 
2061
        True,  XReadDisplayQueryVersion
2212
2062
#     else
2213
 
        False
 
2063
        False, 0
2214
2064
#     endif
2215
2065
   }, { "MIT-SHM",                              "Shared Memory",   
2216
2066
#     ifdef HAVE_XSHM_EXTENSION
2217
 
        True
 
2067
        True, (Status (*) (Display*,int*,int*)) XShmQueryVersion /* 4 args */
2218
2068
#     else
2219
 
        False
 
2069
        False, 0
2220
2070
#     endif
2221
2071
   }, { "DOUBLE-BUFFER",                        "Double-Buffering",
2222
2072
#     ifdef HAVE_DOUBLE_BUFFER_EXTENSION
2223
 
        True
 
2073
        True, XdbeQueryExtension
2224
2074
#     else
2225
 
        False
 
2075
        False, 0
2226
2076
#     endif
2227
2077
   }, { "DPMS",                                 "Power Management",
2228
2078
#     ifdef HAVE_DPMS_EXTENSION
2229
 
        True
 
2079
        True,  DPMSGetVersion
2230
2080
#     else
2231
 
        False
 
2081
        False, 0
2232
2082
#     endif
2233
2083
   }, { "GLX",                                  "GLX",             
2234
2084
#     ifdef HAVE_GL
2235
 
        True
 
2085
        True,  0
2236
2086
#     else
2237
 
        False
 
2087
        False, 0
2238
2088
#     endif
2239
2089
   }, { "XFree86-VidModeExtension",             "XF86 Video-Mode", 
2240
2090
#     ifdef HAVE_XF86VMODE
2241
 
        True
2242
 
#     else
2243
 
        False
 
2091
        True,  XF86VidModeQueryVersion
 
2092
#     else
 
2093
        False, 0
 
2094
#     endif
 
2095
   }, { "XC-VidModeExtension",                  "XC Video-Mode", 
 
2096
#     ifdef HAVE_XF86VMODE
 
2097
        True,  XF86VidModeQueryVersion
 
2098
#     else
 
2099
        False, 0
 
2100
#     endif
 
2101
   }, { "XFree86-MISC",                         "XF86 Misc", 
 
2102
#     ifdef HAVE_XF86MISCSETGRABKEYSSTATE
 
2103
        True,  XF86MiscQueryVersion
 
2104
#     else
 
2105
        False, 0
 
2106
#     endif
 
2107
   }, { "XC-MISC",                              "XC Misc", 
 
2108
#     ifdef HAVE_XF86MISCSETGRABKEYSSTATE
 
2109
        True,  XF86MiscQueryVersion
 
2110
#     else
 
2111
        False, 0
2244
2112
#     endif
2245
2113
   }, { "XINERAMA",                             "Xinerama",
2246
2114
#     ifdef HAVE_XINERAMA
2247
 
        True
 
2115
        True,  XineramaQueryVersion
2248
2116
#     else
2249
 
        False
 
2117
        False, 0
2250
2118
#     endif
2251
2119
   }, { "RANDR",                                "Resize-and-Rotate",
2252
2120
#     ifdef HAVE_RANDR
2253
 
        True
 
2121
        True,  XRRQueryVersion
2254
2122
#     else
2255
 
        False
 
2123
        False, 0
2256
2124
#     endif
 
2125
   }, { "DRI",                                  "DRI",
 
2126
        True,  0
2257
2127
   }, { "Apple-DRI",                            "Apple-DRI (XDarwin)",
2258
 
        True
 
2128
        True,  0
2259
2129
   },
2260
2130
  };
2261
2131
 
2262
 
  fprintf (stderr, "%s: running on display \"%s\" (%d %sscreen%s).\n",
2263
 
           blurb(),
2264
 
           DisplayString(si->dpy),
2265
 
           si->nscreens,
2266
 
           (si->xinerama_p ? "Xinerama " : ""),
2267
 
           (si->nscreens == 1 ? "" : "s"));
 
2132
  fprintf (stderr, "%s: running on display \"%s\"\n", blurb(), 
 
2133
           DisplayString(si->dpy));
2268
2134
  fprintf (stderr, "%s: vendor is %s, %d.\n", blurb(),
2269
2135
           ServerVendor(si->dpy), VendorRelease(si->dpy));
2270
2136
 
2273
2139
    {
2274
2140
      int op = 0, event = 0, error = 0;
2275
2141
      char buf [255];
 
2142
      int maj = 0, min = 0;
 
2143
      int dummy1, dummy2, dummy3;
2276
2144
      int j;
 
2145
 
 
2146
      /* Most of the extension version functions take 3 args,
 
2147
         writing results into args 2 and 3, but some take more.
 
2148
         We only ever care about the first two results, but we
 
2149
         pass in three extra pointers just in case.
 
2150
       */
 
2151
      Status (*version_fn_2) (Display*,int*,int*,int*,int*,int*) =
 
2152
        (Status (*) (Display*,int*,int*,int*,int*,int*)) exts[i].version_fn;
 
2153
 
2277
2154
      if (!XQueryExtension (si->dpy, exts[i].name, &op, &event, &error))
2278
2155
        continue;
2279
2156
      sprintf (buf, "%s:   ", blurb());
2280
2157
      j = strlen (buf);
2281
2158
      strcat (buf, exts[i].desc);
 
2159
 
 
2160
      if (!version_fn_2)
 
2161
        ;
 
2162
      else if (version_fn_2 (si->dpy, &maj, &min, &dummy1, &dummy2, &dummy3))
 
2163
        sprintf (buf+strlen(buf), " (%d.%d)", maj, min);
 
2164
      else
 
2165
        strcat (buf, " (unavailable)");
 
2166
 
2282
2167
      if (!exts[i].useful_p)
2283
2168
        strcat (buf, " (disabled at compile time)");
2284
2169
      fprintf (stderr, "%s\n", buf);
2324
2209
        }
2325
2210
    }
2326
2211
 
2327
 
  if (si->xinerama_p)
2328
 
    {
2329
 
      fprintf (stderr, "%s: Xinerama layout:\n", blurb());
2330
 
      for (i = 0; i < si->nscreens; i++)
2331
 
        {
2332
 
          saver_screen_info *ssi = &si->screens[i];
2333
 
          fprintf (stderr, "%s:   %c %d/%d: %dx%d+%d+%d\n",
2334
 
                   blurb(),
2335
 
                   (ssi->real_screen_p ? '+' : ' '),
2336
 
                   ssi->number, ssi->real_screen_number,
2337
 
                   ssi->width, ssi->height, ssi->x, ssi->y);
2338
 
        }
2339
 
    }
 
2212
  describe_monitor_layout (si);
2340
2213
}
2341
2214
 
 
2215
 
2342
2216
Bool
2343
2217
display_is_on_console_p (saver_info *si)
2344
2218
{