[PATCH 4/5] Prevent flicker on root background pixmap change.

Forest Bond forest at alittletooquiet.net
Sun Jun 13 08:58:37 PDT 2010


Changes to the root background pixmap would previously cause the new
image to flicker into visibility briefy before windows were redrawn
over it.  This was apparently caused by calling XClearWindow when the
_XROOTPMAP_ID property on the root window changed.

This patch fixes this by dropping the XClearWindow call and providing
a new function ("damage_screen") to force a redraw of the entire screen.

Most programs that change the root window pixmap will call XClearWindow,
anyway, so xcompmgr doing the same is redundant.  However, dropping
the call makes it possible to use the _XROOTPMAP_ID property of the root
window to pass new pixmaps to xcompmgr from another process.  The other
process can then neglect to call XClearWindow, resulting in a
flicker-free change to the new background image.

Signed-off-by: Forest Bond <forest at alittletooquiet.net>
---
 xcompmgr.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/xcompmgr.c b/xcompmgr.c
index bd731f0..a345bbe 100644
--- a/xcompmgr.c
+++ b/xcompmgr.c
@@ -129,6 +129,7 @@ static int		composite_event, composite_error;
 static int		render_event, render_error;
 static Bool		synchronize;
 static int		composite_opcode;
+static Bool		screen_damaged = False;
 
 /* find these once and be done with it */
 static Atom		opacityAtom;
@@ -945,7 +946,7 @@ paint_all (Display *dpy, XserverRegion region)
 	    continue;
 #endif
 	/* never painted, ignore it */
-	if (!w->damaged)
+	if ((!screen_damaged) && (!w->damaged))
 	{
 #if DEBUG_REPAINT
 	    printf (" [not damaged: 0x%x]", w->id);
@@ -1128,6 +1129,7 @@ paint_all (Display *dpy, XserverRegion region)
 	XRenderComposite (dpy, PictOpSrc, rootBuffer, None, rootPicture,
 			  0, 0, 0, 0, 0, 0, root_width, root_height);
     }
+    screen_damaged = False;
 }
 
 static void
@@ -1776,6 +1778,22 @@ damage_win (Display *dpy, XDamageNotifyEvent *de)
 	repair_win (dpy, w);
 }
 
+static void
+damage_screen (Display *dpy)
+{
+	XserverRegion region;
+	XRectangle r;
+
+	r.x = 0;
+	r.y = 0;
+	r.width = root_width;
+	r.height = root_height;
+
+	region = XFixesCreateRegion (dpy, &r, 1);
+	add_damage (dpy, region);
+	screen_damaged = True;
+}
+
 static int
 error (Display *dpy, XErrorEvent *ev)
 {
@@ -2263,9 +2281,9 @@ main (int argc, char **argv)
 		    {
 			if (rootTile)
 			{
-			    XClearArea (dpy, root, 0, 0, 0, 0, True);
 			    XRenderFreePicture (dpy, rootTile);
 			    rootTile = None;
+			    damage_screen (dpy);
 			    break;
 			}
 		    }
@@ -2302,12 +2320,13 @@ main (int argc, char **argv)
 	} while (QLength (dpy));
 	if (allDamage && !autoRedirect)
 	{
-	    static int	paint;
 	    paint_all (dpy, allDamage);
-	    paint++;
 	    XSync (dpy, False);
 	    allDamage = None;
 	    clipChanged = False;
 	}
     }
+
+    XClearArea (dpy, root, 0, 0, 0, 0, True);
+    XSync (dpy, False);
 }
-- 
1.7.0.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100613/2801e486/attachment.pgp>


More information about the xorg-devel mailing list