From 56ce896febd64448b9252272c73b8ebd1756af1e Mon Sep 17 00:00:00 2001 From: Richard Grenville Date: Thu, 8 Nov 2012 19:39:13 +0800 Subject: [PATCH] Bug fix: Shape update of opaque windows not handled correctly - Fix a bug that causes rendering issues if a opaque window changes shape. - Remove abundant handling code in paint_preprocess() when generating border_size as border_size() is no longer relying on XFixesCreateRegionFromWindow() right now by default. - Add extra code to print backtrace in DEBUG_ALLOC_REG. - Move initialization of fade_time closer to first paint. --- src/compton.c | 16 +++++----------- src/compton.h | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/compton.c b/src/compton.c index 6b25c0f..cc0a03c 100644 --- a/src/compton.c +++ b/src/compton.c @@ -1428,15 +1428,7 @@ paint_preprocess(Display *dpy, win *list) { // Fetch bounding region if (!w->border_size) { - // Build a border_size ourselves if window is not shaped, to avoid - // getting an invalid border_size region from X if the window is - // unmapped/destroyed - if (!w->bounding_shaped) { - w->border_size = win_get_region(dpy, w); - } - else if (IsUnmapped != w->a.map_state) { - w->border_size = border_size(dpy, w); - } + w->border_size = border_size(dpy, w); } // Fetch window extents @@ -3220,6 +3212,8 @@ ev_shape_notify(XShapeEvent *ev) { // Redo bounding shape detection and rounded corner detection win_update_shape(dpy, w); + + update_reg_ignore_expire(w); } /** @@ -4478,8 +4472,6 @@ main(int argc, char **argv) { get_cfg(argc, argv); - fade_time = get_time_ms(); - dpy = XOpenDisplay(opts.display); if (!dpy) { fprintf(stderr, "Can't open display\n"); @@ -4659,6 +4651,8 @@ main(int argc, char **argv) { reg_ignore_expire = True; + fade_time = get_time_ms(); + t = paint_preprocess(dpy, list); paint_all(dpy, None, t); diff --git a/src/compton.h b/src/compton.h index b3a0516..d7ec6a4 100644 --- a/src/compton.h +++ b/src/compton.h @@ -89,12 +89,42 @@ #include #endif +static void +print_timestamp(void); + #ifdef DEBUG_ALLOC_REG + +#include +#define BACKTRACE_SIZE 5 + +/** + * Print current backtrace, excluding the first two items. + * + * Stolen from glibc manual. + */ +static inline void +print_backtrace(void) { + void *array[BACKTRACE_SIZE]; + size_t size; + char **strings; + + size = backtrace(array, BACKTRACE_SIZE); + strings = backtrace_symbols(array, size); + + for (size_t i = 2; i < size; i++) + printf ("%s\n", strings[i]); + + free(strings); +} + static inline XserverRegion XFixesCreateRegion_(Display *dpy, XRectangle *p, int n, const char *func, int line) { XserverRegion reg = XFixesCreateRegion(dpy, p, n); + print_timestamp(); printf("%#010lx: XFixesCreateRegion() in %s():%d\n", reg, func, line); + print_backtrace(); + fflush(stdout); return reg; } @@ -102,7 +132,9 @@ static inline void XFixesDestroyRegion_(Display *dpy, XserverRegion reg, const char *func, int line) { XFixesDestroyRegion(dpy, reg); + print_timestamp(); printf("%#010lx: XFixesDestroyRegion() in %s():%d\n", reg, func, line); + fflush(stdout); } #define XFixesCreateRegion(dpy, p, n) XFixesCreateRegion_(dpy, p, n, __func__, __LINE__) @@ -668,7 +700,7 @@ get_time_timespec(void) { * * Used for debugging. */ -static inline void +static void print_timestamp(void) { struct timeval tm, diff;