~ubuntu-branches/ubuntu/karmic/xscreensaver/karmic

« back to all changes in this revision

Viewing changes to hacks/ifs.c

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Hildebrandt
  • Date: 2006-07-29 23:00:43 UTC
  • mfrom: (1.1.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: james.westby@ubuntu.com-20060729230043-3ergkicskbntet5n
Tags: 4.24-5
remove /usr/doc/xscreensaver link to finish /usr/doc ->
/usr/share/doc transition (closes: #380394)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
#include "screenhack.h"
36
36
 
37
 
static float myrandom(float up)
 
37
static float
 
38
myrandom(float up)
38
39
{
39
 
  return(((float)random()/RAND_MAX)*up);
 
40
        return(((float)random()/RAND_MAX)*up);
40
41
}
41
42
 
42
43
static int delay;
44
45
static int length;
45
46
static int mode;
46
47
static Bool notranslate, noscale, norotate;
47
 
float ht,wt;
48
 
float hs,ws;
49
 
int width,height;
50
 
float r;
51
 
long wcol;
52
 
int coloffset;
53
 
 
54
 
float nx,ny;
55
 
 
56
 
int count;
 
48
static float ht,wt;
 
49
static float hs,ws;
 
50
static int width,height;
 
51
static long wcol;
 
52
 
 
53
static int count;
57
54
 
58
55
/*X stuff*/
59
 
GC gc;
60
 
Window w;
61
 
Display *dpy;
62
 
Pixmap backbuffer;
63
 
XColor *colours;
64
 
int ncolours;
65
 
int screen_num;
 
56
static GC gc;
 
57
static Window w;
 
58
static Display *dpy;
 
59
static Pixmap backbuffer;
 
60
static XColor *colours;
 
61
static int ncolours;
 
62
static int screen_num;
66
63
 
67
 
int blackColor, whiteColor;
 
64
static int blackColor, whiteColor;
68
65
 
69
66
char *progclass = "IFS";
70
67
 
71
68
char *defaults [] = {
72
 
  ".lensnum:    3",
73
 
  ".length:     9",
74
 
  ".mode:     0",
75
 
  ".colors:     200",
76
 
  "*delay:      10000",
77
 
  "*notranslate:  False",
78
 
  "*noscale:    False",
79
 
  "*norotate:   False",
 
69
  ".lensnum:            3",
 
70
  ".length:                     9",
 
71
  ".mode:                       0",
 
72
  ".colors:                     200",
 
73
  "*delay:                      10000",
 
74
  "*notranslate:        False",
 
75
  "*noscale:            False",
 
76
  "*norotate:           False",
80
77
  0
81
78
};
82
79
 
83
80
XrmOptionDescRec options [] = {
84
 
  { "-detail",    ".length",    XrmoptionSepArg, 0 },
85
 
  { "-delay",   ".delay",   XrmoptionSepArg, 0 },
86
 
  { "-mode",    ".mode",    XrmoptionSepArg, 0 },
87
 
  { "-colors",    ".colors",    XrmoptionSepArg, 0 },
88
 
  { "-functions", ".lensnum",   XrmoptionSepArg, 0 },
89
 
  { "-notranslate", ".notranslate", XrmoptionNoArg,  "True" },
90
 
  { "-noscale",   ".noscale",   XrmoptionNoArg,  "True" },
91
 
  { "-norotate",  ".norotate",  XrmoptionNoArg,  "True" },
 
81
  { "-detail",          ".length",              XrmoptionSepArg, 0 },
 
82
  { "-delay",           ".delay",               XrmoptionSepArg, 0 },
 
83
  { "-mode",            ".mode",                XrmoptionSepArg, 0 },
 
84
  { "-colors",          ".colors",              XrmoptionSepArg, 0 },
 
85
  { "-functions",       ".lensnum",     XrmoptionSepArg, 0 },
 
86
  { "-notranslate",     ".notranslate", XrmoptionNoArg,  "True" },
 
87
  { "-noscale",         ".noscale",             XrmoptionNoArg,  "True" },
 
88
  { "-norotate",        ".norotate",    XrmoptionNoArg,  "True" },
92
89
  { 0, 0, 0, 0 }
93
90
};
94
91
 
95
92
/*Takes the average of two colours, with some nifty bit-shifting*/
96
 
static long blend(long c1, long c2)
 
93
static long
 
94
blend(long c1, long c2)
97
95
{
98
 
  long R1=(c1 & 0xFF0000) >> 16;
99
 
  long R2=(c2 & 0xFF0000) >> 16;
100
 
  long G1=(c1 & 0x00FF00) >> 8;
101
 
  long G2=(c2 & 0x00FF00) >> 8;
102
 
  long B1=(c1 & 0x0000FF);
103
 
  long B2=(c2 & 0x0000FF);
104
 
  
105
 
  return (((R1+R2)/2 << 16) | ((G1+G2)/2 << 8) | ((B1+B2)/2));
 
96
        long R1=(c1 & 0xFF0000) >> 16;
 
97
        long R2=(c2 & 0xFF0000) >> 16;
 
98
        long G1=(c1 & 0x00FF00) >> 8;
 
99
        long G2=(c2 & 0x00FF00) >> 8;
 
100
        long B1=(c1 & 0x0000FF);
 
101
        long B2=(c2 & 0x0000FF);
 
102
        
 
103
        return (((R1+R2)/2 << 16) | ((G1+G2)/2 << 8) | ((B1+B2)/2));
106
104
}
107
105
 
108
106
/*Draw a point on the backbuffer*/
109
 
static void sp(float x, float y, long c)
 
107
static void
 
108
sp(float x, float y, long c)
110
109
{
111
 
  x+=16;    x*=wt;
112
 
  y=16.5-y; y*=ht;
113
 
  if(x<0 || x>=width || y<0 || y>=height) return;
114
 
  XSetForeground(dpy, gc, c);
115
 
  XDrawPoint(dpy, backbuffer, gc, (int)x, (int)y);
 
110
        x+=16;    x*=wt;
 
111
        y=16.5-y; y*=ht;
 
112
        if(x<0 || x>=width || y<0 || y>=height) return;
 
113
        XSetForeground(dpy, gc, c);
 
114
        XDrawPoint(dpy, backbuffer, gc, (int)x, (int)y);
116
115
}
117
116
 
118
117
/*Copy backbuffer to front buffer and clear backbuffer*/
119
 
static void draw(void)
 
118
static void
 
119
draw(void)
120
120
{
121
 
  XCopyArea(  dpy,
122
 
              backbuffer, w,
123
 
              gc,
124
 
              0, 0,
125
 
              width, height,
126
 
              0, 0);
127
 
  
128
 
  XSetForeground(dpy, gc, blackColor);
129
 
  XFillRectangle( dpy,
130
 
                  backbuffer,
131
 
                  gc,
132
 
                  0, 0,
133
 
                  width, height);
 
121
        XCopyArea( dpy,
 
122
                   backbuffer, w,
 
123
                   gc,
 
124
                   0, 0,
 
125
                   width, height,
 
126
                   0, 0);
 
127
        
 
128
        XSetForeground(dpy, gc, blackColor);
 
129
        XFillRectangle( dpy,
 
130
                        backbuffer,
 
131
                        gc,
 
132
                        0, 0,
 
133
                        width, height);
134
134
}
135
135
 
136
136
typedef struct {
137
 
  float r,s,tx,ty;
138
 
  /*Rotation, Scale, Translation X & Y*/
139
 
  float ra,raa,sa,txa,tya;
140
 
  
141
 
  int co;
142
 
} Lens; 
143
 
 
144
 
 
145
 
static void CreateLens(float nr, 
146
 
        float ns, 
147
 
        float nx, 
148
 
        float ny, 
149
 
        int nco,
150
 
        Lens *newlens)
151
 
{
152
 
  newlens->ra=newlens->raa=newlens->sa=newlens->txa=newlens->tya=0;
153
 
  if(!norotate) newlens->r=nr;
154
 
  else newlens->r=0;
155
 
    
156
 
  if(!noscale) newlens->s=ns;
157
 
  else newlens->s=0.5;
158
 
    
159
 
  if(!notranslate) {
160
 
    newlens->tx=nx;
161
 
    newlens->ty=ny;
162
 
  } else {
163
 
    newlens->tx=nx;
164
 
    newlens->tx=ny;
165
 
  }
166
 
    
167
 
  newlens->co=nco;
168
 
}
169
 
  
170
 
static float stepx(float x, float y, Lens *l)
171
 
{
172
 
  return l->s*cos(l->r)*x+l->s*sin(l->r)*y+l->tx;
173
 
}
174
 
 
175
 
static float stepy(float x, float y, Lens *l)
176
 
{
177
 
  return l->s*sin(l->r)*-x+l->s*cos(l->r)*y+l->ty;
178
 
}
179
 
 
180
 
static void mutate(Lens *l)
181
 
{
182
 
  if(!norotate) {
183
 
    l->raa+=myrandom(0.002)-0.001;
184
 
    l->ra+=l->raa;
185
 
    l->r +=l->ra;
186
 
    if(l->ra>0.07  || l->ra<-0.07)  l->ra/=1.4;
187
 
    if(l->raa>0.005 || l->raa<-0.005) l->raa/=1.2;
188
 
  }
189
 
  if(!noscale) {
190
 
    l->sa+=myrandom(0.01)-0.005;
191
 
    l->s +=l->sa;
192
 
    if(l->s>0.4) l->sa -=0.004;
193
 
    if(l->s<-0.4) l->sa +=0.004;
194
 
    if(l->sa>0.07  || l->sa<-0.07)  l->sa/=1.4;
195
 
  }
196
 
  if(!notranslate) {
197
 
    l->txa+=myrandom(0.004)-0.002;
198
 
    l->tya+=myrandom(0.004)-0.002;
199
 
    l->tx+=l->txa;
200
 
    l->ty+=l->tya;
201
 
    if(l->tx>6)  l->txa-=0.004;
202
 
    if(l->ty>6)  l->tya-=0.004;
203
 
    if(l->tx<-6)  l->txa+=0.004;
204
 
    if(l->ty<-6)  l->tya+=0.004;
205
 
    if(l->txa>0.05 || l->txa<-0.05) l->txa/=1.7;
206
 
    if(l->tya>0.05 || l->tya<-0.05) l->tya/=1.7;
207
 
  }
208
 
  
209
 
  /*Groovy, colour-shifting functions!*/
210
 
  l->co++;
211
 
  l->co %= ncolours;
 
137
        float r,s,tx,ty;
 
138
        /*Rotation, Scale, Translation X & Y*/
 
139
        float ro,rt,rc;
 
140
        /*Old Rotation, Rotation Target, Rotation Counter*/
 
141
        float so,st,sc;
 
142
        /*Old Scale, Scale Target, Scale Counter*/
 
143
        float sa,txa,tya;
 
144
        /*Scale change, Translation change*/
 
145
        
 
146
        int co;
 
147
} Lens; 
 
148
 
 
149
 
 
150
static void
 
151
CreateLens( float nr, 
 
152
            float ns, 
 
153
            float nx, 
 
154
            float ny, 
 
155
            int nco,
 
156
            Lens *newlens)
 
157
{
 
158
        newlens->sa=newlens->txa=newlens->tya=0;
 
159
        if(!norotate) newlens->r=nr;
 
160
        else newlens->r=0;
 
161
        
 
162
        if(!noscale) newlens->s=ns;
 
163
        else newlens->s=0.5;
 
164
        
 
165
        if(!notranslate) {
 
166
                newlens->tx=nx;
 
167
                newlens->ty=ny;
 
168
        } else {
 
169
                newlens->tx=nx;
 
170
                newlens->tx=ny;
 
171
        }
 
172
 
 
173
        newlens->rc=newlens->sc=1;
 
174
        newlens->co=nco;
 
175
}
 
176
        
 
177
static float
 
178
stepx(float x, float y, Lens *l)
 
179
{
 
180
        return l->s*cos(l->r)*x+l->s*sin(l->r)*y+l->tx;
 
181
}
 
182
static float
 
183
stepy(float x, float y, Lens *l)
 
184
{
 
185
        return l->s*sin(l->r)*-x+l->s*cos(l->r)*y+l->ty;
 
186
}
 
187
static void
 
188
mutate(Lens *l)
 
189
{
 
190
        if(!norotate) {
 
191
                float factor;
 
192
                if(l->rc >= 1) {
 
193
                        l->rc= 0;
 
194
                        l->ro = l->rt;
 
195
                        l->rt = myrandom(4)-2;
 
196
                }
 
197
                factor = (sin((-M_PI / 2.0) + M_PI * l->rc) + 1.0) / 2.0;
 
198
                l->r=l->ro + (l->rt - l->ro) * factor;
 
199
                l->rc+=0.01;
 
200
                
 
201
        }
 
202
        if(!noscale) {
 
203
                float factor;
 
204
                if(l->sc >= 1) {
 
205
                        /*Reset counter, obtain new target value*/
 
206
                        l->sc= 0;
 
207
                        l->so = l->st;
 
208
                        l->st = myrandom(2)-1;
 
209
                }
 
210
                factor = (sin((-M_PI / 2.0) + M_PI * l->sc) + 1.0) / 2.0;
 
211
                /* Take average of old target and new target, using factor to *
 
212
                 * weight. It's computed sinusoidally, resulting in smooth,   *
 
213
                 * rhythmic transitions.                                      */
 
214
                l->s=l->so + (l->st - l->so) * factor;
 
215
                l->sc+=0.01;
 
216
        }
 
217
        if(!notranslate) {
 
218
                l->txa+=myrandom(0.004)-0.002;
 
219
                l->tya+=myrandom(0.004)-0.002;
 
220
                l->tx+=l->txa;
 
221
                l->ty+=l->tya;
 
222
                if(l->tx>6)  l->txa-=0.004;
 
223
                if(l->ty>6)  l->tya-=0.004;
 
224
                if(l->tx<-6)  l->txa+=0.004;
 
225
                if(l->ty<-6)  l->tya+=0.004;
 
226
                if(l->txa>0.05 || l->txa<-0.05) l->txa/=1.7;
 
227
                if(l->tya>0.05 || l->tya<-0.05) l->tya/=1.7;
 
228
        }
 
229
        
 
230
        /*Groovy, colour-shifting functions!*/
 
231
        l->co++;
 
232
        l->co %= ncolours;
212
233
}
213
234
 
214
235
Lens **lenses;
215
236
 
216
237
/* Calls itself <lensnum> times - with results from each lens/function.  *
217
238
 * After <length> calls to itself, it stops iterating and draws a point. */
218
 
static void iterate(float x, float y, long curcol, int length)
 
239
static void
 
240
iterate(float x, float y, long curcol, int length)
219
241
{
220
 
  int i;
221
 
  if(length == 0) {
222
 
    sp(x,y,curcol);
223
 
  } else {
224
 
    /*iterate(lenses[0].stepx(x,y),lenses[0].stepy(x,y),length-1);
225
 
      iterate(lenses[1].stepx(x,y),lenses[1].stepy(x,y),length-1);
226
 
      iterate(lenses[2].stepx(x,y),lenses[2].stepy(x,y),length-1);*/
227
 
    for(i=0;i<lensnum;i++) {
228
 
      switch(mode) {
229
 
      case 0 : iterate(stepx( x, y, lenses[i]), stepy( x, y, lenses[i]), blend( curcol,colours[(int)lenses[i]->co].pixel ), length-1); break;
230
 
      case 1 : iterate(stepx( x, y, lenses[i]), stepy( x, y, lenses[i]), colours[(int)lenses[i]->co].pixel, length-1); break;
231
 
      case 2 : iterate(stepx( x, y, lenses[i]), stepy( x, y, lenses[i]), curcol, length-1); break;
232
 
      default: exit(0);
233
 
      }
234
 
    }
235
 
  }
236
 
  count++;
 
242
        int i;
 
243
        if(length == 0) {
 
244
                sp(x,y,curcol);
 
245
        } else {
 
246
                for(i=0;i<lensnum;i++) {
 
247
                        switch(mode) {
 
248
                                case 0 : iterate(stepx( x, y, lenses[i]), stepy( x, y, lenses[i]), blend( curcol,colours[(int)lenses[i]->co].pixel ), length-1); break;
 
249
                                case 1 : iterate(stepx( x, y, lenses[i]), stepy( x, y, lenses[i]), colours[(int)lenses[i]->co].pixel, length-1); break;
 
250
                                case 2 : iterate(stepx( x, y, lenses[i]), stepy( x, y, lenses[i]), curcol, length-1); break;
 
251
                                default: exit(0);
 
252
                        }
 
253
                }
 
254
        }
 
255
        count++;
237
256
}
238
257
 
239
258
/* Come on and iterate, iterate, iterate and sing... *
240
259
 * Yeah, this function just calls iterate, mutate,   *
241
260
 * and then draws everything.                        */
242
 
static void step(void)
 
261
static void
 
262
step(void)
243
263
{
244
 
  int i;
245
 
  if(mode == 2) {
246
 
    wcol++;
247
 
    wcol %= ncolours;
248
 
    iterate(0,0,colours[wcol].pixel,length);
249
 
  } else {
250
 
    iterate(0,0,0xFFFFFF,length);
251
 
  }
252
 
  
253
 
  
254
 
  count=0;
255
 
  
256
 
  for(i=0;i<lensnum;i++) {
257
 
    mutate(lenses[i]);
258
 
  }
259
 
  draw();
 
264
        int i;
 
265
        if(mode == 2) {
 
266
                wcol++;
 
267
                wcol %= ncolours;
 
268
                iterate(0,0,colours[wcol].pixel,length);
 
269
        } else {
 
270
                iterate(0,0,0xFFFFFF,length);
 
271
        }
 
272
        
 
273
        
 
274
        count=0;
 
275
        
 
276
        for(i=0;i<lensnum;i++) {
 
277
                mutate(lenses[i]);
 
278
        }
 
279
        draw();
260
280
}
261
281
 
262
 
static void init_ifs(void)
 
282
static void
 
283
init_ifs(void)
263
284
{
264
 
  Window rw;
265
 
  int i;
266
 
  XWindowAttributes xgwa;
267
 
  
268
 
  delay = get_integer_resource("delay", "Delay");
269
 
  length = get_integer_resource("length", "Detail");
270
 
  mode = get_integer_resource("mode", "Mode");
271
 
 
272
 
  norotate    = get_boolean_resource("norotate", "NoRotate");
273
 
  noscale     = get_boolean_resource("noscale", "NoScale");
274
 
  notranslate = get_boolean_resource("notranslate", "NoTranslate");
275
 
 
276
 
  lensnum = get_integer_resource("lensnum", "Functions");
277
 
  
278
 
  lenses = malloc(sizeof(Lens)*lensnum);
279
 
  
280
 
  for(i=0;i<lensnum;i++) {
281
 
    lenses[i]=malloc(sizeof(Lens));
282
 
  }
283
 
  
284
 
  /*Thanks go to Dad for teaching me how to allocate memory for struct**s . */
285
 
  
286
 
  XGetWindowAttributes (dpy, w, &xgwa);
287
 
  width=xgwa.width;
288
 
  height=xgwa.height;
289
 
  
290
 
  /*Initialise all this X shizzle*/
291
 
  blackColor = BlackPixel(dpy, DefaultScreen(dpy));
292
 
  whiteColor = WhitePixel(dpy, DefaultScreen(dpy));
293
 
  rw = RootWindow(dpy, screen_num);
294
 
  screen_num = DefaultScreen(dpy);
295
 
  gc = XCreateGC(dpy, rw, 0, NULL);
296
 
  
297
 
  /* Do me some colourmap magic. If we're using blend mode, this is just   *
298
 
   * for the nice colours - we're still using true/hicolour. Screw me if   *
299
 
   * I'm going to work out how to blend with colourmaps - I'm too young to *
300
 
   * die!! On a sidenote, this is mostly stolen from halftone because I    *
301
 
   * don't really know what the hell I'm doing, here.                      */
302
 
  ncolours = get_integer_resource("colors", "Colors");
303
 
  if(ncolours < lensnum) ncolours=lensnum; /*apparently you're allowed to do this kind of thing...*/
304
 
  colours = (XColor *)calloc(ncolours, sizeof(XColor));
305
 
  make_smooth_colormap (  dpy,
306
 
                          xgwa.visual,
307
 
                          xgwa.colormap,
308
 
                          colours,
309
 
                          &ncolours,
310
 
                          True, 0, False);
311
 
  /*No, I didn't have a clue what that really did... hopefully I have some colours in an array, now.*/
312
 
  wcol = (int)myrandom(ncolours);
313
 
    
314
 
  /*Double buffering - I can't be bothered working out the XDBE thingy*/
315
 
  backbuffer = XCreatePixmap(dpy, w, width, height, XDefaultDepth(dpy, screen_num));
316
 
  
317
 
  /*Scaling factor*/
318
 
  wt=width/32;
319
 
  ht=height/24;
320
 
  
321
 
  ws=400;
322
 
  hs=400;
323
 
 
324
 
  /*Colourmapped colours for the general prettiness*/
325
 
  for(i=0;i<lensnum;i++) {
326
 
    CreateLens( myrandom(1)-0.5,
327
 
                myrandom(1),
328
 
                myrandom(4)-2,
329
 
                myrandom(4)+2,
330
 
                myrandom(ncolours),
331
 
                lenses[i]);
332
 
  }
 
285
        Window rw;
 
286
        int i;
 
287
        XWindowAttributes xgwa;
 
288
        
 
289
        delay = get_integer_resource("delay", "Delay");
 
290
        length = get_integer_resource("length", "Detail");
 
291
        mode = get_integer_resource("mode", "Mode");
 
292
 
 
293
        norotate    = get_boolean_resource("norotate", "NoRotate");
 
294
        noscale     = get_boolean_resource("noscale", "NoScale");
 
295
        notranslate = get_boolean_resource("notranslate", "NoTranslate");
 
296
 
 
297
        lensnum = get_integer_resource("lensnum", "Functions");
 
298
        
 
299
        lenses = malloc(sizeof(Lens)*lensnum);
 
300
        
 
301
        for(i=0;i<lensnum;i++) {
 
302
                lenses[i]=malloc(sizeof(Lens));
 
303
        }
 
304
        
 
305
        /*Thanks go to Dad for teaching me how to allocate memory for struct**s . */
 
306
        
 
307
        XGetWindowAttributes (dpy, w, &xgwa);
 
308
        width=xgwa.width;
 
309
        height=xgwa.height;
 
310
        
 
311
        /*Initialise all this X shizzle*/
 
312
        blackColor = BlackPixel(dpy, DefaultScreen(dpy));
 
313
        whiteColor = WhitePixel(dpy, DefaultScreen(dpy));
 
314
        rw = RootWindow(dpy, screen_num);
 
315
        screen_num = DefaultScreen(dpy);
 
316
        gc = XCreateGC(dpy, rw, 0, NULL);
 
317
        
 
318
        /* Do me some colourmap magic. If we're using blend mode, this is just   *
 
319
         * for the nice colours - we're still using true/hicolour. Screw me if   *
 
320
         * I'm going to work out how to blend with colourmaps - I'm too young to *
 
321
         * die!! On a sidenote, this is mostly stolen from halftone because I    *
 
322
         * don't really know what the hell I'm doing, here.                      */
 
323
        ncolours = get_integer_resource("colors", "Colors");
 
324
        if(ncolours < lensnum) ncolours=lensnum; /*apparently you're allowed to do this kind of thing...*/
 
325
        colours = (XColor *)calloc(ncolours, sizeof(XColor));
 
326
        make_smooth_colormap ( dpy,
 
327
                               xgwa.visual,
 
328
                               xgwa.colormap,
 
329
                           colours,
 
330
                           &ncolours,
 
331
                           True, 0, False);
 
332
        /*No, I didn't have a clue what that really did... hopefully I have some colours in an array, now.*/
 
333
        wcol = (int)myrandom(ncolours);
 
334
                
 
335
        /*Double buffering - I can't be bothered working out the XDBE thingy*/
 
336
        backbuffer = XCreatePixmap(dpy, w, width, height, XDefaultDepth(dpy, screen_num));
 
337
        
 
338
        /*Scaling factor*/
 
339
        wt=width/32;
 
340
        ht=height/24;
 
341
        
 
342
        ws=400;
 
343
        hs=400;
 
344
 
 
345
        /*Colourmapped colours for the general prettiness*/
 
346
        for(i=0;i<lensnum;i++) {
 
347
                CreateLens(     myrandom(1)-0.5,
 
348
                            myrandom(1),
 
349
                            myrandom(4)-2,
 
350
                            myrandom(4)+2,
 
351
                            myrandom(ncolours),
 
352
                            lenses[i]);
 
353
        }
333
354
}
334
355
 
335
356
void
336
357
screenhack (Display *display, Window window)
337
358
{
338
 
  dpy = display;
339
 
  w   = window;
340
 
  
341
 
  init_ifs();
342
 
  
343
 
  while (1) {
344
 
    step();
345
 
    screenhack_handle_events(dpy);
346
 
    if (delay) usleep(delay);
347
 
  }
 
359
        dpy = display;
 
360
        w   = window;
 
361
        
 
362
        init_ifs();
 
363
        
 
364
        while (1) {
 
365
                step();
 
366
                screenhack_handle_events(dpy);
 
367
                if (delay) usleep(delay);
 
368
        }
348
369
}