Branch: master

b68985f9 2014-01-18 18:04:14 Richard Grenville
Bug fix #163: xr_glx_hybrid: Flickering issue

xr_glx_hybrid backend: Attempt to fix flickering issue. Thanks to cju
for testing.
M compton.c
diff --git a/compton.c b/compton.c
index 3ddf46f..f539daa 100644
--- a/compton.c
+++ b/compton.c
@@ -1950,6 +1950,13 @@
       paint_bind_tex_real(ps, &ps->tgt_buffer,
           ps->root_width, ps->root_height, ps->depth,
           !ps->o.glx_no_rebind_pixmap);
+      // See #163
+      XSync(ps->dpy, False);
+      if (ps->o.vsync_use_glfinish)
+        glFinish();
+      else
+        glFlush();
+      glXWaitX();
       glx_render(ps, ps->tgt_buffer.ptex, 0, 0, 0, 0,
           ps->root_width, ps->root_height, 0, 1.0, false, region_real, NULL);
       // No break here!
53cb5d3a 2014-01-21 08:13:06 Richard Grenville
Bug fix: Fix access to freed memory due to invalid w->prev_trans

- Fix a bug that w->prev_trans sometimes points to freed memory.
  Probably related to #165.

- Add some more debugging printf()-s under DEBUG_EVENTS.
M compton.c
diff --git a/compton.c b/compton.c
index f539daa..3a14d82 100644
--- a/compton.c
+++ b/compton.c
@@ -1245,6 +1245,7 @@
       t = w;
     }
     else {
+      assert(w->destroyed == (w->fade_callback == destroy_callback));
       check_fade_fin(ps, w);
     }
 
@@ -2089,6 +2090,10 @@
 
   win *w = find_win(ps, id);
 
+#ifdef DEBUG_EVENTS
+  printf_dbgf("(%#010lx \"%s\"): %p\n", id, (w ? w->name: NULL), w);
+#endif
+
   // Don't care about window mapping if it's an InputOnly window
   // Try avoiding mapping a window twice
   if (!w || InputOnly == w->a.class
@@ -2824,6 +2829,10 @@
   // Allocate and initialize the new win structure
   win *new = malloc(sizeof(win));
 
+#ifdef DEBUG_EVENTS
+  printf_dbgf("(%#010lx): %p\n", id, new);
+#endif
+
   if (!new) {
     printf_errf("(%#010lx): Failed to allocate memory for the new window.", id);
     return false;
@@ -3078,10 +3087,18 @@
 
 static void
 finish_destroy_win(session_t *ps, Window id) {
-  win **prev, *w;
+  win **prev = NULL, *w = NULL;
+
+#ifdef DEBUG_EVENTS
+  printf_dbgf("(%#010lx): Starting...\n", id);
+#endif
 
   for (prev = &ps->list; (w = *prev); prev = &w->next) {
     if (w->id == id && w->destroyed) {
+#ifdef DEBUG_EVENTS
+		printf_dbgf("(%#010lx \"%s\"): %p\n", id, w->name, w);
+#endif
+
       finish_unmap_win(ps, w);
       *prev = w->next;
 
@@ -3090,6 +3107,12 @@
         ps->active_win = NULL;
 
       free_win_res(ps, w);
+
+      // Drop w from all prev_trans to avoid accessing freed memory in
+      // repair_win()
+      for (win *w2 = ps->list; w2; w2 = w2->next)
+        if (w == w2->prev_trans)
+          w2->prev_trans = NULL;
 
       free(w);
       break;
@@ -3106,6 +3129,10 @@
 destroy_win(session_t *ps, Window id) {
   win *w = find_win(ps, id);
 
+#ifdef DEBUG_EVENTS
+  printf_dbgf("(%#010lx \"%s\"): %p\n", id, (w ? w->name: NULL), w);
+#endif
+
   if (w) {
     unmap_win(ps, w);
 
9745bfe7 2014-02-27 08:08:30 Richard Grenville
Bug fix: Fix -S

Fix the broken -S.
M compton.c
diff --git a/compton.c b/compton.c
index 3a14d82..9d05876 100644
--- a/compton.c
+++ b/compton.c
@@ -5480,6 +5480,8 @@
         ps->o.config_file = mstrcpy(optarg);
       else if ('d' == o)
         ps->o.display = mstrcpy(optarg);
+      else if ('S' == o)
+        ps->o.synchronize = true;
       else if ('?' == o || ':' == o)
         usage(1);
     }
@@ -5532,6 +5534,7 @@
         usage(0);
         break;
       case 'd':
+      case 'S':
         break;
       P_CASELONG('D', fade_delta);
       case 'I':
@@ -5556,7 +5559,6 @@
       case 'F':
         fading_enable = true;
         break;
-      P_CASEBOOL('S', synchronize);
       P_CASELONG('r', shadow_radius);
       case 'o':
         ps->o.shadow_opacity = atof(optarg);
53d0c5c0 2014-03-10 18:22:23 Richard Grenville
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.
M common.h
M compton.c
diff --git a/common.h b/common.h
index 7786f82..e87651c 100644
--- a/common.h
+++ b/common.h
@@ -1499,6 +1499,11 @@
     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;
 }
@@ -1789,6 +1794,15 @@
 }
 
 /**
+ * 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.
  *
  * psrc and pdst cannot be the same.
diff --git a/compton.c b/compton.c
index 9d05876..645aa5c 100644
--- a/compton.c
+++ b/compton.c
@@ -2983,6 +2983,7 @@
 
     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 @@
 
 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);
 }
15bde6a8 2014-03-17 10:25:34 Richard Grenville
Bug fix #181: Add --xrender-sync{,-fence}

- Add --xrender-sync{,-fence} to deal with redraw lag issue on GLX
  backend. --xrender-sync-fence requires a sufficiently new xorg-server
  and libXext. NO_XSYNC=1 may be used to disable it at compile time.
  Thanks to tchebb for reporting and everybody else for testing. (#181)

- A bit code clean-up. Replace a few XSync() with XFlush() to minimize
  the latency.
M common.h
M compton.c
M compton.h
M opengl.c
M opengl.h
diff --git a/common.h b/common.h
index e87651c..d243dc0 100644
--- a/common.h
+++ b/common.h
@@ -55,9 +55,17 @@
 // #define CONFIG_DBUS 1
 // Whether to enable condition support.
 // #define CONFIG_C2 1
+// Whether to enable X Sync support.
+// #define CONFIG_XSYNC 1
+// Whether to enable GLX Sync support.
+// #define CONFIG_GLX_XSYNC 1
 
 #if !defined(CONFIG_C2) && defined(DEBUG_C2)
 #error Cannot enable c2 debugging without c2 support.
+#endif
+
+#if (!defined(CONFIG_XSYNC) || !defined(CONFIG_VSYNC_OPENGL)) && defined(CONFIG_GLX_SYNC)
+#error Cannot enable GL sync without X Sync / OpenGL support.
 #endif
 
 #ifndef COMPTON_VERSION
@@ -89,6 +97,9 @@
 #include <X11/extensions/shape.h>
 #include <X11/extensions/Xrandr.h>
 #include <X11/extensions/Xdbe.h>
+#ifdef CONFIG_XSYNC
+#include <X11/extensions/sync.h>
+#endif
 
 #ifdef CONFIG_XINERAMA
 #include <X11/extensions/Xinerama.h>
@@ -338,6 +349,16 @@
 typedef struct _glx_texture glx_texture_t;
 
 #ifdef CONFIG_VSYNC_OPENGL
+#ifdef DEBUG_GLX_DEBUG_CONTEXT
+typedef GLXContext (*f_glXCreateContextAttribsARB) (Display *dpy,
+    GLXFBConfig config, GLXContext share_context, Bool direct,
+    const int *attrib_list);
+typedef void (*GLDEBUGPROC) (GLenum source, GLenum type,
+    GLuint id, GLenum severity, GLsizei length, const GLchar* message,
+    GLvoid* userParam);
+typedef void (*f_DebugMessageCallback) (GLDEBUGPROC, void *userParam);
+#endif
+
 typedef int (*f_WaitVideoSync) (int, int, unsigned *);
 typedef int (*f_GetVideoSync) (unsigned *);
 
@@ -351,6 +372,47 @@
 typedef void (*f_ReleaseTexImageEXT) (Display *display, GLXDrawable drawable, int buffer);
 
 typedef void (*f_CopySubBuffer) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
+
+#ifdef CONFIG_GLX_SYNC
+// Looks like duplicate typedef of the same type is safe?
+typedef int64_t GLint64;
+typedef uint64_t GLuint64;
+typedef struct __GLsync *GLsync;
+
+#ifndef GL_SYNC_FLUSH_COMMANDS_BIT
+#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
+#endif
+
+#ifndef GL_TIMEOUT_IGNORED
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
+#endif
+
+#ifndef GL_ALREADY_SIGNALED
+#define GL_ALREADY_SIGNALED 0x911A
+#endif
+
+#ifndef GL_TIMEOUT_EXPIRED
 ** Diff limit reached (max: 250 lines) **
dbba28f9 2014-03-26 09:27:25 Richard Grenville
Misc: Add --xrender-sync{,-fence} as configuration file option

- Add --xrender-sync{,-fence} as configuration file option.

- Quit on encountering invalid opacity rule.

- Other small changes.
M common.h
M compton.c
M opengl.c
 ** Diff limit reached (max: 250 lines) **
b175464e 2014-04-19 06:41:26 Richard Grenville
Misc: Try to avoid evaluating conditions after window unmap & others

- Try to avoid evaluating conditions after window unmap/destruction.
  Unfortunately, frequently this doesn't work due to the asynchronous
  nature of X.

- Add _GTK_FRAME_EXTENTS exclusion rules to compton.sample.conf. Thanks
  to memeplex, hexchain, and others for info. (#189)

- Add debugging option --show-all-xerrors, and other debugging changes.
  Doc update.
M c2.c
M common.h
M compton.c
 ** Diff limit reached (max: 250 lines) **
5794e098 2014-04-19 08:52:20 Richard Grenville
Bug fix #190: Copy shadow/fade state from last paint on unmapped wins

Copy shadow/fade/color-inversion/background-blur state from last paint
on unmapped windows. I hope it doesn't have unexpected side effects.
(#190)
M common.h
M compton.c
M compton.h
 ** Diff limit reached (max: 250 lines) **
6a573808 2014-04-20 18:49:29 Richard Grenville
Misc: Fix a possible assert() failure
M compton.c
 ** Diff limit reached (max: 250 lines) **
5df42e8e 2014-04-21 09:45:27 Richard Grenville
Bug fix #191: Add rounded-corners detection to --unredir-if-possible

Add `bounding_shape` and `rounded_corners` as condition match target.
Deprecate --shadow-ignore-shaped. Add rounded-corners detection to
win_is_fullscreen(). Slightly modify win_rounded_corners() logic. Thanks
to tdryer for reporting. (#191)
M c2.c
M c2.h
M common.h
M compton.c
 ** Diff limit reached (max: 250 lines) **
6449cc20 2014-04-28 08:21:16 Richard Grenville
Bug fix #194: Fix assertion failure in some cases

Fix assertion failure when evaluating --unredir-if-possible-exclude or
--paint-exclude on unmapped windows. Thanks to ppuryear for reporting.
(#194)
M compton.c
 ** Diff limit reached (max: 250 lines) **
12225bca 2014-05-09 23:21:23 Richard Grenville
Bug fix #195: Pointer incompatibility with libconfig-1.3*

Fix pointer incompatibility with libconfig-1.3*. Thanks to
sstewartgallus for reporting. (#195)
M compton.c
 ** Diff limit reached (max: 250 lines) **
0fa155f5 2014-05-16 02:18:17 Richard Grenville
Feature: #183 custom window shader & #193 --no-fading-destroyed-argb

- Add --glx-fshader-win, which specifies a custom fragment shader for
  painting windows. compton-default-fshader-win.glsl is the shader with
  default behavior, and compton-fake-transparency-fshader-win.glsl
  provides a template of fake transparency. (#183)

- Add --force-win-blend to force all windows to be painted with
  blending.

- Add --no-fading-destroyed-argb, as a workaround of bugs in some WMs.
  (#193)
M common.h
M compton.c
M compton.h
M opengl.c
 ** Diff limit reached (max: 250 lines) **
8df5b1d5 2014-06-14 22:51:59 Richard Grenville
Misc #205: Add 2 long options & Update documentation

- Add two long variants of short options.

- Update documentation.
M compton.c
 ** Diff limit reached (max: 250 lines) **
1df3c865 2014-07-04 05:27:13 Michael Reed
whitespace cleanup
M opengl.h
 ** Diff limit reached (max: 250 lines) **
90c3a42d 2014-07-12 20:34:38 Richard Grenville
Misc: Add --version & --no-x-selection

- Add --version. (#206)

- Add --no-x-selection for debugging. (#207)
M common.h
M compton.c
 ** Diff limit reached (max: 250 lines) **
7e268e7b 2014-07-27 23:50:15 Richard Grenville
Improvement: Separate GLX parts from session_t & Attempt to fix #217

- Separate GLX parts from session_t into glx_session_t.

- Add --rererdir-on-root-change and --glx-reinit-on-root-change, as
  possible solutions for #217. Thanks to jlindgren90 for reporting.
M common.h
M compton.c
M compton.h
M opengl.c
M opengl.h
 ** Diff limit reached (max: 250 lines) **
d8f0aba7 2014-07-28 03:54:02 Richard Grenville
Misc #218: Warn about using --glx-no-rebind-pixmap on intel driver

Warn about using --glx-no-rebind-pixmap on xf86-video-intel. Thanks to
aktau for the info. (#218)
M compton.c
 ** Diff limit reached (max: 250 lines) **
66b420aa 2014-07-28 20:29:26 Richard Grenville
Misc: Fix compilation with NO_VSYNC_OPENGL_GLSL / NO_C2

Fix compilation with NO_VSYNC_OPENGL_GLSL / NO_C2.
M compton.c
M opengl.c
 ** Diff limit reached (max: 250 lines) **
ebab3dc5 2014-08-03 06:40:40 Richard Grenville
Bug fix: Fix X pixmap leakage in shadow_paint

- Fix X pixmap leakage in shadow_paint.

- Add the skeleton of a X resource leakage checker.
A xrescheck.c
A xrescheck.h
M common.h
M compton.c
 ** Diff limit reached (max: 250 lines) **
42448622 2014-08-05 18:32:53 Richard Grenville
Misc: Fix spelling mistakes

Still, "Guassian" -> "Gaussian". (#221)
M common.h
M compton.c
 ** Diff limit reached (max: 250 lines) **
69eb07bb 2014-08-06 13:42:57 mæp
fix crash caused by free of uninitialized pointer
M compton.h
 ** Diff limit reached (max: 250 lines) **
882d3873 2014-09-07 03:05:14 Richard Grenville
Misc: Add --no-name-pixmap

Add --no-name-pixmap to disable the usage of
XCompositeNameWindowPixmap(), for debugging.
M common.h
M compton.c
 ** Diff limit reached (max: 250 lines) **
886cdca8 2014-09-07 03:07:26 Richard Grenville
Merge branch 'richardgv-dev' of github.com:chjj/compton into richardgv-dev
M compton.h
 ** Diff limit reached (max: 250 lines) **
e3717f4f 2014-09-07 05:58:09 Richard Grenville
Misc #204: Add glx_take_screenshot() & others

- Add glx_take_screenshot() for taking a screenshot. With ImageMagick
  the output data could be viewed in this way:

    display -size [SCREEN-WIDTH]x[SCREEN-HEIGHT] -depth 8 -flip
    rgb:[PATH]

  (#204)

- Add D-Bus command `opts_get string:paint_on_overlay_id` to get X
  Composite overlay window ID. (#204)

- Code cleanup.
M common.h
M compton.c
M dbus.c
M opengl.c
 ** Diff limit reached (max: 250 lines) **
325fb4c2 2014-10-05 22:36:47 Richard Grenville
Bug fix #224: Flush after XUngrabServer()

Fix #224 by XFlush() after XUngrabServer(). Thanks to rathsky and smlx
for reporting.
M compton.c
 ** Diff limit reached (max: 250 lines) **
d74fed9b 2014-11-12 15:01:36 Timothy Pearson
Merge remote-tracking branch 'compton-update/master'

Conflicts:
	twin/compton-tde/common.h
	twin/compton-tde/compton.c
	twin/compton-tde/opengl.c
A xrescheck.c
A xrescheck.h
M twin/compton-tde/c2.c
M twin/compton-tde/c2.h
M twin/compton-tde/common.h
M twin/compton-tde/compton.c
M twin/compton-tde/compton.h
M twin/compton-tde/dbus.c
M twin/compton-tde/opengl.c
M twin/compton-tde/opengl.h
 ** Diff limit reached (max: 250 lines) **
8a7c1831 2014-11-12 15:05:06 Timothy Pearson
Add semi-automated update script
A twin/update_compton_tde
 ** Diff limit reached (max: 250 lines) **
5bb5839f 2014-11-12 15:14:24 Timothy Pearson
Fix compilation errors from changed compton API
M twin/compton-tde/compton.c
 ** Diff limit reached (max: 250 lines) **