From 53d0c5c015d438172957a1ca0f31e1fb6fa9b150 Mon Sep 17 00:00:00 2001
From: Richard Grenville <pyxlcy@gmail.com>
Date: Tue, 11 Mar 2014 07:22:23 +0800
Subject: Misc: xr-glx-hybrid alias & minor fixes

- Add "xr-glx-hybrid" as an alias of "xr_glx_hybrid". (#163)

- Clear damage history in expose_root() and when root window size
  changes. Unfortunately this doesn't fix #181.
---
 common.h  | 14 ++++++++++++++
 compton.c |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/common.h b/common.h
index 7786f82b8..e87651c9e 100644
--- a/common.h
+++ b/common.h
@@ -1499,6 +1499,11 @@ parse_backend(session_t *ps, const char *str) {
     ps->o.backend = BKEND_XR_GLX_HYBRID;
     return true;
   }
+  // cju wants to use dashes
+  if (!strcasecmp(str, "xr-glx-hybrid")) {
+    ps->o.backend = BKEND_XR_GLX_HYBRID;
+    return true;
+  }
   printf_errf("(\"%s\"): Invalid backend argument.", str);
   return false;
 }
@@ -1788,6 +1793,15 @@ free_region(session_t *ps, XserverRegion *p) {
   }
 }
 
+/**
+ * Free all regions in ps->all_damage_last .
+ */
+static inline void
+free_all_damage_last(session_t *ps) {
+  for (int i = 0; i < CGLX_MAX_BUFFER_AGE; ++i)
+    free_region(ps, &ps->all_damage_last[i]);
+}
+
 /**
  * Crop a rectangle by another rectangle.
  *
diff --git a/compton.c b/compton.c
index 9d058767c..645aa5c57 100644
--- a/compton.c
+++ b/compton.c
@@ -2983,6 +2983,7 @@ configure_win(session_t *ps, XConfigureEvent *ce) {
 
     rebuild_screen_reg(ps);
     rebuild_shadow_exclude_reg(ps);
+    free_all_damage_last(ps);
 
 #ifdef CONFIG_VSYNC_OPENGL
     if (BKEND_GLX == ps->o.backend)
@@ -3275,6 +3276,7 @@ error(Display __attribute__((unused)) *dpy, XErrorEvent *ev) {
 
 static void
 expose_root(session_t *ps, XRectangle *rects, int nrects) {
+  free_all_damage_last(ps);
   XserverRegion region = XFixesCreateRegion(ps->dpy, rects, nrects);
   add_damage(ps, region);
 }
-- 
cgit v1.2.3

