~ubuntu-branches/ubuntu/lucid/xscreensaver/lucid

« back to all changes in this revision

Viewing changes to hacks/crystal.c

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2007-12-06 09:53:12 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20071206095312-fkzcwe4vqm50z208
Tags: 5.04-1ubuntu1
* Merge from debian unstable, remaining changes:
  - split xscreensaver into xscreensaver, xscreensaver-data (hacks we ship),
    xscreensaver-data-extra (hacks in universe). split out gl hacks for
    universe to xscreensaver-gl-extra
  - use fridge for rss screensavers
  - create and install .desktop files for gnome-screensaver

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 */
70
70
 
71
71
#ifdef STANDALONE
72
 
# define PROGCLASS              "Crystal"
73
 
# define HACK_INIT              init_crystal
74
 
# define HACK_DRAW              draw_crystal
75
 
# define crystal_opts   xlockmore_opts
76
72
# define DEFAULTS               "*delay:                60000   \n" \
77
73
                                                 "*count:                -500   \n" \
78
74
                                                 "*cycles:                200   \n" \
79
75
                                                 "*size:                  -15   \n" \
80
 
                                                 "*ncolors:               100   \n" \
81
 
                                                 "*fullrandom:   True   \n" \
82
 
                                                 "*verbose:             False   \n"
 
76
                                                 "*ncolors:               100   \n"
 
77
# define reshape_crystal 0
 
78
# define crystal_handle_event 0
83
79
# include "xlockmore.h"         /* in xscreensaver distribution */
84
80
#else /* STANDALONE */
85
81
# include "xlock.h"                     /* in xlockmore distribution */
96
92
#define DEF_MAXSIZE "False"
97
93
#define DEF_CYCLE "True"
98
94
 
 
95
#undef NRAND
 
96
#define NRAND(n)           ( (n) ? (int) (LRAND() % (n)) : 0)
 
97
 
99
98
#define min(a,b) ((a) <= (b) ? (a) : (b))
100
99
 
101
 
#ifdef STANDALONE
102
 
void release_crystal(ModeInfo * mi);
103
 
#endif
104
 
 
105
100
static int  nx, ny;
106
101
 
107
102
static Bool unit_cell, grid_cell, centre, maxsize, cycle_p;
143
138
        {"-/+shift", "turn on/off colour cycling"}
144
139
};
145
140
 
146
 
ModeSpecOpt crystal_opts =
 
141
ENTRYPOINT ModeSpecOpt crystal_opts =
147
142
{sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
148
143
 
149
144
#ifdef USE_MODULES
560
555
        }
561
556
}
562
557
 
563
 
void
 
558
ENTRYPOINT void init_crystal(ModeInfo * mi);
 
559
ENTRYPOINT void release_crystal(ModeInfo * mi);
 
560
 
 
561
 
 
562
ENTRYPOINT void
564
563
draw_crystal(ModeInfo * mi)
565
564
{
566
565
        Display    *display = MI_DISPLAY(mi);
567
566
        crystalstruct *cryst = &crystals[MI_SCREEN(mi)];
568
567
        int         i;
569
568
 
 
569
#ifdef HAVE_COCOA       /* Don't second-guess Quartz's double-buffering */
 
570
    XClearWindow(MI_DISPLAY(mi), MI_WINDOW(mi));
 
571
#endif
 
572
 
570
573
        if (cryst->no_colors) {
571
574
                release_crystal(mi);
572
575
                init_crystal(mi);
618
621
        XSetFunction(display, cryst->gc, GXcopy);
619
622
}
620
623
 
621
 
void
 
624
ENTRYPOINT void
622
625
refresh_crystal(ModeInfo * mi)
623
626
{
624
627
        Display    *display = MI_DISPLAY(mi);
785
788
        XSetFunction(display, cryst->gc, GXcopy);
786
789
}
787
790
 
788
 
void
 
791
ENTRYPOINT void
789
792
release_crystal(ModeInfo * mi)
790
793
{
791
794
        Display    *display = MI_DISPLAY(mi);
821
824
        }
822
825
}
823
826
 
824
 
void
 
827
ENTRYPOINT void
825
828
init_crystal(ModeInfo * mi)
826
829
{
827
830
        Display    *display = MI_DISPLAY(mi);
980
983
                        cryst->offset_w = (int) (cryst->b * 0.5);
981
984
                }
982
985
        } else {
 
986
                int max_repeat = 10;
983
987
                cryst->offset_w = -1;
984
 
                while (cryst->offset_w < 4 || (int) (cryst->offset_w - cryst->b *
985
 
                                    sin((cryst->gamma - 90) * PI_RAD)) < 4) {
 
988
                while (max_repeat-- && 
 
989
                  (cryst->offset_w < 4 || (int) (cryst->offset_w - cryst->b *
 
990
                                    sin((cryst->gamma - 90) * PI_RAD)) < 4)
 
991
                           ) {
986
992
                        cryst->b = NRAND((int) (cryst->win_height / (cos((cryst->gamma - 90) *
987
993
                                            PI_RAD))) - cell_min) + cell_min;
988
994
                        if (cryst->planegroup > 8)
1259
1265
                crystal_setupatom(atom0, cryst->gamma);
1260
1266
                crystal_drawatom(mi, atom0);
1261
1267
        }
1262
 
        XSync(display, False);
1263
1268
        XSetFunction(display, cryst->gc, GXcopy);
1264
1269
}
 
1270
 
 
1271
XSCREENSAVER_MODULE ("Crystal", crystal)