http://packetstormsecurity.org/UNIX/admin/xscreensaver-4.00.tar.gz
[xscreensaver] / hacks / distort.c
index 4218418f201628b8b54c2969a506736196883d0e..ffaaa53e6b186539bfac5a44d77f4a5c8f76bda1 100644 (file)
@@ -113,6 +113,8 @@ static void init_distort(Display *dpy, Window window)
        if (get_boolean_resource("bounce", "Boolean"))
                effect = &move_lense;
 
+       XGetWindowAttributes (dpy, window, &xgwa);
+
        if (effect == NULL && radius == 0 && speed == 0 && number == 0
                && !blackhole && !vortex && !magnify && !reflect) {
 /* if no cmdline options are given, randomly choose one of:
@@ -201,6 +203,9 @@ static void init_distort(Display *dpy, Window window)
                 abort(); break;
                }
 
+        /* but if the window is small, reduce default radius */
+        if (xgwa.width < radius * 8)
+          radius = xgwa.width/8;
        }
 
        if (delay < 0)
@@ -222,7 +227,6 @@ static void init_distort(Display *dpy, Window window)
        if (draw == NULL)
                draw = &plain_draw;
 
-       XGetWindowAttributes (dpy, window, &xgwa);
        black_pixel = BlackPixelOfScreen( xgwa.screen );
 
        gcv.function = GXcopy;
@@ -533,9 +537,9 @@ static void plain_draw(int k)
                XShmPutImage(g_dpy, g_window, gc, buffer_map, 0, 0, xy_coo[k].x, xy_coo[k].y,
                                2*radius+speed+2, 2*radius+speed+2, False);
        else
-# endif
 
        if (!use_shm)
+# endif
                XPutImage(g_dpy, g_window, gc, buffer_map, 0, 0, xy_coo[k].x, xy_coo[k].y,
                                2*radius+speed+2, 2*radius+speed+2);