Make a dummy window with a name, so xrestop can point its finger at
[dana/xcompmgr.git] / xcompmgr.c
index 01d9188..9f90595 100644 (file)
@@ -322,6 +322,7 @@ run_fades (Display *dpy)
     int            now = get_time_in_milliseconds();
     fade    *f, *next;
     int            steps;
+    Bool    need_dequeue;
 
 #if 0
     printf ("run fades\n");
@@ -342,12 +343,13 @@ run_fades (Display *dpy)
        printf ("opacity now %g\n", f->cur);
 #endif
        w->opacity = f->cur * OPAQUE;
+       need_dequeue = False;
        if (f->step > 0)
        {
            if (f->cur >= f->finish)
            {
                w->opacity = f->finish*OPAQUE;
-               dequeue_fade (dpy, f);
+               need_dequeue = True;
            }
        }
        else
@@ -355,7 +357,7 @@ run_fades (Display *dpy)
            if (f->cur <= f->finish)
            {
                w->opacity = f->finish*OPAQUE;
-               dequeue_fade (dpy, f);
+               need_dequeue = True;
            }
        }
        determine_mode (dpy, w);
@@ -365,6 +367,9 @@ run_fades (Display *dpy)
            w->shadow = None;
            w->extents = win_extents(dpy, w);
        }
+       /* Must do this last as it might destroy f->w in callbacks */
+       if (need_dequeue)
+               dequeue_fade (dpy, f);
     }
     fade_time = now + fade_delta;
 }
@@ -942,6 +947,10 @@ paint_all (Display *dpy, XserverRegion region)
        /* never painted, ignore it */
        if (!w->damaged)
            continue;
+       /* if invisible, ignore it */
+       if (w->a.x + w->a.width < 1 || w->a.y + w->a.height < 1
+           || w->a.x >= root_width || w->a.y >= root_height)
+           continue;
        if (!w->picture)
        {
            XRenderPictureAttributes    pa;
@@ -1030,6 +1039,9 @@ paint_all (Display *dpy, XserverRegion region)
        case CompSimple:
            break;
        case CompServerShadows:
+           /* dont' bother drawing shadows on desktop windows */
+           if (w->windowType == winDesktopAtom)
+               break;
            set_ignore (dpy, NextRequest (dpy));
            if (w->opacity != OPAQUE && !w->shadowPict)
                w->shadowPict = solid_picture (dpy, True,
@@ -1044,7 +1056,8 @@ paint_all (Display *dpy, XserverRegion region)
                              w->shadow_width, w->shadow_height);
            break;
        case CompClientShadows:
-           if (w->shadow)
+           /* don't bother drawing shadows on desktop windows */
+           if (w->shadow && w->windowType != winDesktopAtom)
            {
                XRenderComposite (dpy, PictOpOver, blackPicture, w->shadow, rootBuffer,
                                  0, 0, 0, 0,
@@ -1825,7 +1838,7 @@ ev_window (XEvent *ev)
 void
 usage (char *program)
 {
-    fprintf (stderr, "%s v1.0\n", program);
+    fprintf (stderr, "%s v1.1.2\n", program);
     fprintf (stderr, "usage: %s [options]\n", program);
     fprintf (stderr, "Options\n");
     fprintf (stderr, "   -d display\n      Specifies which display should be managed.\n");
@@ -1833,6 +1846,9 @@ usage (char *program)
     fprintf (stderr, "   -o opacity\n      Specifies the translucency for client-side shadows. (default .75)\n");
     fprintf (stderr, "   -l left-offset\n      Specifies the left offset for client-side shadows. (default -15)\n");
     fprintf (stderr, "   -t top-offset\n      Specifies the top offset for clinet-side shadows. (default -15)\n");
+    fprintf (stderr, "   -I fade-in-step\n      Specifies the opacity change between steps while fading in. (default 0.028)\n");
+    fprintf (stderr, "   -O fade-out-step\n      Specifies the opacity change between steps while fading out. (default 0.03)\n");
+    fprintf (stderr, "   -D fade-delta-time\n      Specifies the time between steps in a fade in milliseconds. (default 10)\n");
     fprintf (stderr, "   -a\n      Use automatic server-side compositing. Faster, but no special effects.\n");
     fprintf (stderr, "   -c\n      Draw client-side shadows with fuzzy edges.\n");
     fprintf (stderr, "   -C\n      Avoid drawing shadows on dock/panel windows.\n");
@@ -1844,6 +1860,18 @@ usage (char *program)
     exit (1);
 }
 
+static void
+give_me_a_name (void)
+{
+    Window w;
+
+    w = XCreateSimpleWindow (dpy, RootWindow (dpy, 0), 0, 0, 1, 1, 0, None,
+                            None);
+
+    Xutf8SetWMProperties (dpy, w, "xcompmgr", "xcompmgr", NULL, 0, NULL, NULL,
+                         NULL);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -1868,12 +1896,27 @@ main (int argc, char **argv)
     char           *display = 0;
     int                    o;
 
-    while ((o = getopt (argc, argv, "d:r:o:l:t:scnfFCaS")) != -1)
+    while ((o = getopt (argc, argv, "D:I:O:d:r:o:l:t:scnfFCaS")) != -1)
     {
        switch (o) {
        case 'd':
            display = optarg;
            break;
+       case 'D':
+           fade_delta = atoi (optarg);
+           if (fade_delta < 1)
+               fade_delta = 10;
+           break;
+       case 'I':
+           fade_in_step = atof (optarg);
+           if (fade_in_step <= 0)
+               fade_in_step = 0.01;
+           break;
+       case 'O':
+           fade_out_step = atof (optarg);
+           if (fade_out_step <= 0)
+               fade_out_step = 0.01;
+           break;
        case 's':
            compMode = CompServerShadows;
            break;
@@ -1955,6 +1998,9 @@ main (int argc, char **argv)
        fprintf (stderr, "No XFixes extension\n");
        exit (1);
     }
+
+    give_me_a_name();
+
     /* get atoms */
     opacityAtom = XInternAtom (dpy, OPACITY_PROP, False);
     winTypeAtom = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", False);