summaryrefslogtreecommitdiff
blob: 9ce42c0a9c270edb882d0c23cf45586dcd9e242b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
diff -ru /tmp/mrxvt-0.4.2/src/command.c ./src/command.c
--- /tmp/mrxvt-0.4.2/src/command.c	2005-06-24 17:16:26.000000000 -0500
+++ ./src/command.c	2005-12-21 12:57:21.000000000 -0600
@@ -36,6 +36,12 @@
 /*
 ** $Id: noflicker-0.4.2.patch,v 1.1 2006/02/03 14:01:29 nelchael Exp $
 */
+/* Modified 2005-12-21 by Gautam Iyer <gautam@math.uchicago.edu>
+ *
+ *	1. Eliminated the "BadMatch" XError sometimes generated
+ *	2. Eliminated "flicker" seen when using a transparent shaded terminal
+ *	   while changing desktop pages.
+ */
 
 #include "../config.h"
 #include "rxvt.h"
@@ -3740,10 +3746,22 @@
 	}
 #endif
 
-#ifdef TRANSPARENT		/* XXX: maybe not needed - leave in for now */
+#ifdef TRANSPARENT
+	/*
+	 * Check to see if the previous position we grabbed the background is
+	 * different from the current window position. If yes, then update
+	 * everything.
+	 */
 	if (r->Options & Opt_transparent)	{
-		rxvt_check_our_parents(r);
-		r->h->want_full_refresh = 1;
+		if( !r->bgGrabbed
+		    || r->prevPos.x != ev->x
+		    || r->prevPos.y != ev->y
+		    || r->prevPos.width != ev->width
+		    || r->prevPos.height != ev->height
+		  ) {
+			rxvt_check_our_parents(r);
+			r->h->want_full_refresh = 1;
+		}
 	}
 #endif
 }
@@ -3782,7 +3800,9 @@
 	if (ev->atom != r->h->xa[XA_XROOTPMAPID])
 		return ;
 
-	if ((r->Options & Opt_transparent) && rxvt_check_our_parents(r)) {
+	if (r->Options & Opt_transparent) {
+		r->bgGrabbed = False;
+		rxvt_check_our_parents(r);
 		r->h->want_full_refresh = 1;
 	}
 #endif		/* TRANSPARENT */
@@ -4549,6 +4569,14 @@
 		0, 0, &sx, &sy, &cr);
 	nw = r->szHint.width;
 	nh = r->szHint.height;
+
+#if DEBUG_LEVEL
+	if( sx + nw <= 0 || sx >= (int) rootw || sy + nh <= 0 || sy >= (int) rooth) {
+	    DBG_MSG( 1, (stderr, "Possible error: grabbing offscreen (%d, %d, %u, %u)\n",
+			    sx, sy, nw, nh));
+	}
+#endif
+
 	*nx = *ny = 0;
 	if (sx < 0) {
 		nw += sx;
@@ -4707,8 +4735,14 @@
 		rootpixmap = *((Pixmap*) prop);
 		XFree(prop);
 	}
+	else r->bgGrabbed = False;
+
+	/*
+	 * Use "while" instead of "if" so we can break out if transparency
+	 * updates don't need to be performed.
+	 */
+	while (have_pixmap) {
 
-	if (have_pixmap) {
 		/*
 		** Copy XROOT pixmap transparency
 		*/
@@ -4716,13 +4750,21 @@
 		XImage*			imagetw;
 
 		/*
-		** handle BadMatch - usually because we're outside the
-		** pixmap. may need a delay here?
-		*/
-		r->h->allowedxerror = -1;
+		 * Calling get_parent_ximage when the terminal window is off
+		 * screen is pointless and generates a "Bad Match" XError while
+		 * calling XGetImage.
+		 */
+
+		if (	r->szHint.x + r->szHint.width  <= 0
+			|| r->szHint.x >= (int) wrootattr.width
+			|| r->szHint.y + r->szHint.height <= 0
+			|| r->szHint.y >= (int) wrootattr.height
+		   )
+			/* We're off screen. Don't update */
+			break;
+
 		imagetw = get_parent_ximage (r, rootpixmap,
 					wrootattr.width, wrootattr.height, &nx, &ny);
-		r->h->allowedxerror = 0;
 
 		if (NULL == imagetw) {
 			if (r->h->am_transparent && r->h->am_pixmap_trans) {
@@ -4746,10 +4788,18 @@
 			if ((!r->h->am_transparent || !r->h->am_pixmap_trans) &&
 				retvt)
 			*/
-			if (retvt)
+			if (retvt) {
+				r->bgGrabbed = True;
+				r->prevPos.x = r->szHint.x;
+				r->prevPos.y = r->szHint.y;
+				r->prevPos.width = r->szHint.width;
+				r->prevPos.height = r->szHint.height;
+
 				have_changed = 1;
+			}
 			r->h->am_transparent = r->h->am_pixmap_trans = 1;
 		}
+		break;
 	}
 
 	/*
diff -ru /tmp/mrxvt-0.4.2/src/init.c ./src/init.c
--- /tmp/mrxvt-0.4.2/src/init.c	2005-10-07 20:07:45.000000000 -0500
+++ ./src/init.c	2005-12-21 12:57:21.000000000 -0600
@@ -1927,6 +1927,10 @@
 	r->szHint.x = 0;
 	r->szHint.y = 0;
 
+#ifdef TRANSPARENT
+	r->bgGrabbed = False;
+#endif
+
 	/* Parse geometry */
 	if (r->h->rs[Rs_geometry])
 		flags = XParseGeometry(r->h->rs[Rs_geometry], &x, &y, &w, &h);
diff -ru /tmp/mrxvt-0.4.2/src/rxvtlib.h ./src/rxvtlib.h
--- /tmp/mrxvt-0.4.2/src/rxvtlib.h	2005-06-23 20:54:07.000000000 -0500
+++ ./src/rxvtlib.h	2005-12-21 12:57:21.000000000 -0600
@@ -757,6 +757,10 @@
 	unsigned long   Options;
 	unsigned long   Options2;
 	XSizeHints      szHint;
+#ifdef TRANSPARENT
+	XRectangle	prevPos;	/* previous onscreen position */
+	Bool		bgGrabbed;	/* weather the bg was succesfully grabbed at prevPos */
+#endif
 
 	/* hotkeys */
 	hotkeys_t*		hotkeys;