1 |
root |
1.34 |
/*----------------------------------------------------------------------* |
2 |
pcg |
1.12 |
* File: xpm.C |
3 |
pcg |
1.1 |
*----------------------------------------------------------------------* |
4 |
|
|
* |
5 |
|
|
* All portions of code are copyright by their respective author/s. |
6 |
|
|
* Copyright (c) 1997 Carsten Haitzler <raster@zip.com.au> |
7 |
|
|
* Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
8 |
|
|
* Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
9 |
root |
1.33 |
* Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
10 |
pcg |
1.1 |
* |
11 |
|
|
* This program is free software; you can redistribute it and/or modify |
12 |
|
|
* it under the terms of the GNU General Public License as published by |
13 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
14 |
|
|
* (at your option) any later version. |
15 |
|
|
* |
16 |
|
|
* This program is distributed in the hope that it will be useful, |
17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
|
|
* GNU General Public License for more details. |
20 |
|
|
* |
21 |
|
|
* You should have received a copy of the GNU General Public License |
22 |
|
|
* along with this program; if not, write to the Free Software |
23 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 |
|
|
*---------------------------------------------------------------------*/ |
25 |
|
|
|
26 |
|
|
#include "../config.h" /* NECESSARY */ |
27 |
|
|
#include "rxvt.h" /* NECESSARY */ |
28 |
|
|
|
29 |
|
|
#ifdef XPM_BACKGROUND |
30 |
|
|
|
31 |
|
|
/* |
32 |
|
|
* These GEOM strings indicate absolute size/position: |
33 |
|
|
* @ `WxH+X+Y' |
34 |
|
|
* @ `WxH+X' -> Y = X |
35 |
|
|
* @ `WxH' -> Y = X = 50 |
36 |
|
|
* @ `W+X+Y' -> H = W |
37 |
|
|
* @ `W+X' -> H = W, Y = X |
38 |
|
|
* @ `W' -> H = W, X = Y = 50 |
39 |
|
|
* @ `0xH' -> H *= H/100, X = Y = 50 (W unchanged) |
40 |
|
|
* @ `Wx0' -> W *= W/100, X = Y = 50 (H unchanged) |
41 |
|
|
* @ `=+X+Y' -> (H, W unchanged) |
42 |
|
|
* @ `=+X' -> Y = X (H, W unchanged) |
43 |
|
|
* |
44 |
|
|
* These GEOM strings adjust position relative to current position: |
45 |
|
|
* @ `+X+Y' |
46 |
|
|
* @ `+X' -> Y = X |
47 |
|
|
* |
48 |
|
|
* And this GEOM string is for querying current scale/position: |
49 |
|
|
* @ `?' |
50 |
|
|
*/ |
51 |
|
|
int |
52 |
pcg |
1.5 |
rxvt_term::scale_pixmap (const char *geom) |
53 |
pcg |
1.1 |
{ |
54 |
root |
1.28 |
int flags, changed = 0; |
55 |
|
|
int x = 0, y = 0; |
56 |
|
|
unsigned int w = 0, h = 0; |
57 |
|
|
unsigned int n; |
58 |
|
|
char *p; |
59 |
root |
1.35 |
bgPixmap_t *bgpixmap = &bgPixmap; |
60 |
pcg |
1.1 |
|
61 |
root |
1.28 |
#define MAXLEN_GEOM sizeof("[10000x10000+10000+10000]") |
62 |
pcg |
1.1 |
|
63 |
pcg |
1.7 |
if (geom == NULL) |
64 |
|
|
return 0; |
65 |
root |
1.28 |
|
66 |
|
|
char str[MAXLEN_GEOM]; |
67 |
|
|
|
68 |
root |
1.17 |
if (!strcmp (geom, "?")) |
69 |
pcg |
1.7 |
{ |
70 |
pcg |
1.9 |
sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
71 |
root |
1.28 |
min (bgpixmap->w, 32767), min (bgpixmap->h, 32767), |
72 |
|
|
min (bgpixmap->x, 32767), min (bgpixmap->y, 32767)); |
73 |
pcg |
1.11 |
process_xterm_seq (XTerm_title, str, CHAR_ST); |
74 |
pcg |
1.7 |
return 0; |
75 |
pcg |
1.1 |
} |
76 |
|
|
|
77 |
root |
1.17 |
if ((p = strchr (geom, ';')) == NULL) |
78 |
|
|
p = strchr (geom, '\0'); |
79 |
root |
1.28 |
|
80 |
pcg |
1.7 |
n = (p - geom); |
81 |
root |
1.35 |
if (n < MAXLEN_GEOM) |
82 |
pcg |
1.7 |
{ |
83 |
root |
1.17 |
strncpy (str, geom, n); |
84 |
pcg |
1.7 |
str[n] = '\0'; |
85 |
|
|
|
86 |
ayin |
1.51 |
if (strcmp(str, "auto") == 0) |
87 |
sasha |
1.38 |
{ |
88 |
ayin |
1.51 |
if (!bgpixmap->auto_resize) |
89 |
sasha |
1.38 |
changed++; |
90 |
ayin |
1.51 |
bgpixmap->auto_resize = True ; |
91 |
|
|
w = szHint.width ; |
92 |
sasha |
1.38 |
h = szHint.height ; |
93 |
|
|
flags = WidthValue|HeightValue ; |
94 |
|
|
} |
95 |
|
|
else |
96 |
|
|
{ |
97 |
ayin |
1.51 |
bgpixmap->auto_resize = False ; |
98 |
sasha |
1.38 |
flags = XParseGeometry (str, &x, &y, &w, &h); |
99 |
|
|
} |
100 |
root |
1.28 |
|
101 |
pcg |
1.7 |
if (!flags) |
102 |
|
|
{ |
103 |
|
|
flags |= WidthValue; |
104 |
|
|
w = 0; |
105 |
|
|
} /* default is tile */ |
106 |
root |
1.28 |
|
107 |
pcg |
1.7 |
if (flags & WidthValue) |
108 |
|
|
{ |
109 |
root |
1.28 |
if (!(flags & XValue)) |
110 |
pcg |
1.7 |
x = 50; |
111 |
root |
1.28 |
|
112 |
|
|
if (!(flags & HeightValue)) |
113 |
pcg |
1.7 |
h = w; |
114 |
root |
1.28 |
|
115 |
pcg |
1.7 |
if (w && !h) |
116 |
|
|
{ |
117 |
|
|
w = (bgpixmap->w * w) / 100; |
118 |
|
|
h = bgpixmap->h; |
119 |
|
|
} |
120 |
|
|
else if (h && !w) |
121 |
|
|
{ |
122 |
|
|
w = bgpixmap->w; |
123 |
|
|
h = (bgpixmap->h * h) / 100; |
124 |
|
|
} |
125 |
root |
1.28 |
|
126 |
|
|
min_it (w, 32767); |
127 |
|
|
min_it (h, 32767); |
128 |
|
|
|
129 |
pcg |
1.7 |
if (bgpixmap->w != (short)w) |
130 |
|
|
{ |
131 |
|
|
bgpixmap->w = (short)w; |
132 |
|
|
changed++; |
133 |
|
|
} |
134 |
root |
1.28 |
|
135 |
pcg |
1.7 |
if (bgpixmap->h != (short)h) |
136 |
|
|
{ |
137 |
|
|
bgpixmap->h = (short)h; |
138 |
|
|
changed++; |
139 |
|
|
} |
140 |
|
|
} |
141 |
root |
1.28 |
|
142 |
|
|
if (!(flags & YValue)) |
143 |
pcg |
1.7 |
{ |
144 |
|
|
if (flags & XNegative) |
145 |
|
|
flags |= YNegative; |
146 |
root |
1.28 |
|
147 |
pcg |
1.7 |
y = x; |
148 |
|
|
} |
149 |
|
|
|
150 |
root |
1.28 |
if (!(flags & WidthValue) && geom[0] != '=') |
151 |
pcg |
1.7 |
{ |
152 |
|
|
x += bgpixmap->x; |
153 |
|
|
y += bgpixmap->y; |
154 |
|
|
} |
155 |
root |
1.28 |
|
156 |
|
|
if (xpmAttr.width && xpmAttr.height) |
157 |
pcg |
1.7 |
{ |
158 |
root |
1.28 |
x = MOD(x, xpmAttr.width); |
159 |
|
|
y = MOD(y, xpmAttr.height); |
160 |
|
|
} |
161 |
|
|
|
162 |
pcg |
1.7 |
if (bgpixmap->x != x) |
163 |
|
|
{ |
164 |
|
|
bgpixmap->x = x; |
165 |
|
|
changed++; |
166 |
|
|
} |
167 |
root |
1.28 |
|
168 |
pcg |
1.7 |
if (bgpixmap->y != y) |
169 |
|
|
{ |
170 |
|
|
bgpixmap->y = y; |
171 |
|
|
changed++; |
172 |
|
|
} |
173 |
pcg |
1.1 |
} |
174 |
root |
1.28 |
|
175 |
pcg |
1.7 |
return changed; |
176 |
pcg |
1.1 |
} |
177 |
|
|
|
178 |
|
|
void |
179 |
pcg |
1.5 |
rxvt_term::resize_pixmap () |
180 |
pcg |
1.1 |
{ |
181 |
root |
1.27 |
XGCValues gcvalue; |
182 |
|
|
GC gc; |
183 |
pcg |
1.7 |
|
184 |
root |
1.24 |
if (pixmap != None) |
185 |
sasha |
1.38 |
{ |
186 |
|
|
XFreePixmap (dpy, pixmap); |
187 |
|
|
pixmap = None ; |
188 |
|
|
} |
189 |
pcg |
1.7 |
|
190 |
|
|
if (bgPixmap.pixmap == None) |
191 |
|
|
{ /* So be it: I'm not using pixmaps */ |
192 |
root |
1.24 |
pixmap = None; |
193 |
root |
1.20 |
|
194 |
root |
1.41 |
#ifdef ENABLE_TRANSPARENCY |
195 |
root |
1.37 |
if (!option (Opt_transparent) || !am_transparent) |
196 |
ayin |
1.36 |
#endif |
197 |
root |
1.31 |
XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
198 |
root |
1.20 |
|
199 |
pcg |
1.7 |
return; |
200 |
pcg |
1.1 |
} |
201 |
|
|
|
202 |
root |
1.17 |
gcvalue.foreground = pix_colors[Color_bg]; |
203 |
root |
1.31 |
gc = XCreateGC (dpy, vt, GCForeground, &gcvalue); |
204 |
pcg |
1.1 |
|
205 |
pcg |
1.7 |
if (bgPixmap.pixmap != None) |
206 |
|
|
{ /* we have a specified pixmap */ |
207 |
root |
1.28 |
unsigned int w = bgPixmap.w, h = bgPixmap.h, |
208 |
|
|
x = bgPixmap.x, y = bgPixmap.y; |
209 |
|
|
unsigned int xpmh = xpmAttr.height, |
210 |
|
|
xpmw = xpmAttr.width; |
211 |
pcg |
1.7 |
|
212 |
ayin |
1.51 |
if (bgPixmap.auto_resize) |
213 |
sasha |
1.38 |
{ |
214 |
ayin |
1.51 |
w = szHint.width ; |
215 |
sasha |
1.38 |
h = szHint.height ; |
216 |
ayin |
1.51 |
} |
217 |
pcg |
1.7 |
/* |
218 |
|
|
* don't zoom pixmap too much nor expand really small pixmaps |
219 |
|
|
*/ |
220 |
root |
1.28 |
if (w > 32767 || h > 32767) |
221 |
pcg |
1.7 |
w = 1; |
222 |
|
|
else if (width > (10 * xpmw) |
223 |
|
|
|| height > (10 * xpmh)) |
224 |
|
|
w = 0; /* tile */ |
225 |
|
|
|
226 |
root |
1.28 |
if (!w) |
227 |
pcg |
1.7 |
{ |
228 |
|
|
/* basic X tiling - let the X server do it */ |
229 |
root |
1.31 |
pixmap = XCreatePixmap (dpy, vt, xpmw, xpmh, depth); |
230 |
root |
1.28 |
|
231 |
root |
1.31 |
XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, y, xpmw - x, xpmh - y, 0, 0); |
232 |
|
|
XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y); |
233 |
|
|
XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0); |
234 |
|
|
XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y); |
235 |
pcg |
1.7 |
} |
236 |
|
|
else |
237 |
root |
1.41 |
#ifdef ENABLE_TRANSPARENCY |
238 |
sasha |
1.38 |
if (!option(Opt_transparent) || !am_transparent) |
239 |
|
|
/* will do that in check_our_parents otherwise */ |
240 |
|
|
#endif |
241 |
|
|
{ |
242 |
root |
1.47 |
ASImage *scaled_im = scale_asimage (asv, original_asim, w, h, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
243 |
ayin |
1.51 |
if (scaled_im) |
244 |
sasha |
1.38 |
{ |
245 |
sasha |
1.48 |
pixmap = asimage2pixmap(asv, display->root, scaled_im, gc, True); |
246 |
root |
1.47 |
destroy_asimage (&scaled_im); |
247 |
sasha |
1.38 |
} |
248 |
|
|
} |
249 |
pcg |
1.1 |
} |
250 |
root |
1.14 |
|
251 |
root |
1.31 |
XSetWindowBackgroundPixmap (dpy, vt, pixmap); |
252 |
root |
1.28 |
|
253 |
root |
1.31 |
XFreeGC (dpy, gc); |
254 |
root |
1.41 |
#ifdef ENABLE_TRANSPARENCY |
255 |
pcg |
1.7 |
am_transparent = 0; |
256 |
ayin |
1.36 |
#endif |
257 |
pcg |
1.1 |
} |
258 |
|
|
|
259 |
|
|
Pixmap |
260 |
pcg |
1.5 |
rxvt_term::set_bgPixmap (const char *file) |
261 |
pcg |
1.1 |
{ |
262 |
root |
1.21 |
char *f; |
263 |
pcg |
1.1 |
|
264 |
pcg |
1.9 |
assert (file != NULL); |
265 |
pcg |
1.1 |
|
266 |
pcg |
1.7 |
if (bgPixmap.pixmap != None) |
267 |
|
|
{ |
268 |
root |
1.31 |
XFreePixmap (dpy, bgPixmap.pixmap); |
269 |
pcg |
1.7 |
bgPixmap.pixmap = None; |
270 |
pcg |
1.1 |
} |
271 |
root |
1.19 |
|
272 |
root |
1.31 |
XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
273 |
pcg |
1.1 |
|
274 |
pcg |
1.7 |
if (*file != '\0') |
275 |
|
|
{ |
276 |
|
|
/* XWindowAttributes attr; */ |
277 |
|
|
|
278 |
|
|
/* |
279 |
|
|
* we already have the required attributes |
280 |
|
|
*/ |
281 |
root |
1.31 |
/* XGetWindowAttributes (dpy, vt, &attr); */ |
282 |
pcg |
1.7 |
|
283 |
ayin |
1.51 |
if (asimman == NULL) |
284 |
|
|
asimman = create_generic_imageman(rs[Rs_path]); |
285 |
sasha |
1.38 |
if ((f = strchr (file, ';')) == NULL) |
286 |
ayin |
1.51 |
original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); |
287 |
sasha |
1.38 |
else |
288 |
|
|
{ |
289 |
ayin |
1.42 |
size_t len = f - file; |
290 |
|
|
f = (char *)malloc (len + 1); |
291 |
|
|
strncpy (f, file, len); |
292 |
|
|
f[len] = '\0'; |
293 |
ayin |
1.51 |
original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); |
294 |
sasha |
1.38 |
free( f ); |
295 |
|
|
} |
296 |
|
|
if (original_asim) |
297 |
|
|
{ |
298 |
sasha |
1.48 |
bgPixmap.pixmap = asimage2pixmap (asv, display->root, original_asim, NULL, True); |
299 |
ayin |
1.51 |
xpmAttr.width = original_asim->width ; |
300 |
|
|
xpmAttr.height = original_asim->height ; |
301 |
sasha |
1.38 |
} |
302 |
pcg |
1.1 |
} |
303 |
pcg |
1.10 |
|
304 |
pcg |
1.7 |
resize_pixmap (); |
305 |
|
|
return bgPixmap.pixmap; |
306 |
pcg |
1.1 |
} |
307 |
|
|
|
308 |
|
|
#endif /* XPM_BACKGROUND */ |
309 |
ayin |
1.39 |
|
310 |
root |
1.41 |
#ifdef ENABLE_TRANSPARENCY |
311 |
ayin |
1.39 |
#if TINTING && !defined(HAVE_AFTERIMAGE) |
312 |
|
|
/* taken from aterm-0.4.2 */ |
313 |
|
|
|
314 |
|
|
typedef uint32_t RUINT32T; |
315 |
|
|
|
316 |
ayin |
1.43 |
static void |
317 |
|
|
ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
318 |
ayin |
1.39 |
{ |
319 |
|
|
int sh_r, sh_g, sh_b; |
320 |
|
|
RUINT32T mask_r, mask_g, mask_b; |
321 |
|
|
RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
322 |
|
|
unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
323 |
|
|
unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
324 |
|
|
int i; |
325 |
|
|
|
326 |
|
|
Visual *visual = term->visual; |
327 |
|
|
|
328 |
|
|
if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
329 |
|
|
|
330 |
|
|
/* for convenience */ |
331 |
|
|
mask_r = visual->red_mask; |
332 |
|
|
mask_g = visual->green_mask; |
333 |
|
|
mask_b = visual->blue_mask; |
334 |
|
|
|
335 |
|
|
/* boring lookup table pre-initialization */ |
336 |
|
|
switch (srcImage->bits_per_pixel) { |
337 |
|
|
case 15: |
338 |
|
|
if ((mask_r != 0x7c00) || |
339 |
|
|
(mask_g != 0x03e0) || |
340 |
|
|
(mask_b != 0x001f)) |
341 |
|
|
return; |
342 |
|
|
lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
343 |
|
|
lookup_r = lookup; |
344 |
|
|
lookup_g = lookup+32; |
345 |
|
|
lookup_b = lookup+32+32; |
346 |
|
|
sh_r = 10; |
347 |
|
|
sh_g = 5; |
348 |
|
|
sh_b = 0; |
349 |
|
|
break; |
350 |
|
|
case 16: |
351 |
|
|
if ((mask_r != 0xf800) || |
352 |
|
|
(mask_g != 0x07e0) || |
353 |
|
|
(mask_b != 0x001f)) |
354 |
|
|
return; |
355 |
|
|
lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
356 |
|
|
lookup_r = lookup; |
357 |
|
|
lookup_g = lookup+32; |
358 |
|
|
lookup_b = lookup+32+64; |
359 |
|
|
sh_r = 11; |
360 |
|
|
sh_g = 5; |
361 |
|
|
sh_b = 0; |
362 |
|
|
break; |
363 |
|
|
case 24: |
364 |
|
|
if ((mask_r != 0xff0000) || |
365 |
|
|
(mask_g != 0x00ff00) || |
366 |
|
|
(mask_b != 0x0000ff)) |
367 |
|
|
return; |
368 |
|
|
lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
369 |
|
|
lookup_r = lookup; |
370 |
|
|
lookup_g = lookup+256; |
371 |
|
|
lookup_b = lookup+256+256; |
372 |
|
|
sh_r = 16; |
373 |
|
|
sh_g = 8; |
374 |
|
|
sh_b = 0; |
375 |
|
|
break; |
376 |
|
|
case 32: |
377 |
|
|
if ((mask_r != 0xff0000) || |
378 |
|
|
(mask_g != 0x00ff00) || |
379 |
|
|
(mask_b != 0x0000ff)) |
380 |
|
|
return; |
381 |
|
|
lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
382 |
|
|
lookup_r = lookup; |
383 |
|
|
lookup_g = lookup+256; |
384 |
|
|
lookup_b = lookup+256+256; |
385 |
|
|
sh_r = 16; |
386 |
|
|
sh_g = 8; |
387 |
|
|
sh_b = 0; |
388 |
|
|
break; |
389 |
|
|
default: |
390 |
|
|
return; /* we do not support this color depth */ |
391 |
|
|
} |
392 |
|
|
|
393 |
|
|
/* prepare limits for color transformation (each channel is handled separately) */ |
394 |
|
|
if (shade < 0) { |
395 |
|
|
shade = -shade; |
396 |
|
|
if (shade < 0) shade = 0; |
397 |
|
|
if (shade > 100) shade = 100; |
398 |
|
|
|
399 |
|
|
lower_lim_r = 65535-rm; |
400 |
|
|
lower_lim_g = 65535-gm; |
401 |
|
|
lower_lim_b = 65535-bm; |
402 |
|
|
|
403 |
|
|
lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
404 |
|
|
lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
405 |
|
|
lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
406 |
|
|
|
407 |
|
|
upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
408 |
|
|
} else { |
409 |
|
|
if (shade < 0) shade = 0; |
410 |
|
|
if (shade > 100) shade = 100; |
411 |
|
|
|
412 |
|
|
lower_lim_r = lower_lim_g = lower_lim_b = 0; |
413 |
|
|
|
414 |
|
|
upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
415 |
|
|
upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
416 |
|
|
upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
417 |
|
|
} |
418 |
|
|
|
419 |
|
|
/* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
420 |
|
|
if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
421 |
|
|
{ |
422 |
|
|
unsigned int tmp; |
423 |
|
|
|
424 |
|
|
tmp = lower_lim_r; |
425 |
|
|
lower_lim_r = lower_lim_b; |
426 |
|
|
lower_lim_b = tmp; |
427 |
|
|
|
428 |
|
|
tmp = upper_lim_r; |
429 |
|
|
upper_lim_r = upper_lim_b; |
430 |
|
|
upper_lim_b = tmp; |
431 |
|
|
} |
432 |
|
|
|
433 |
|
|
/* fill our lookup tables */ |
434 |
|
|
for (i = 0; i <= mask_r>>sh_r; i++) |
435 |
|
|
{ |
436 |
|
|
RUINT32T tmp; |
437 |
|
|
tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
438 |
|
|
tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
439 |
|
|
lookup_r[i] = (tmp/65535)<<sh_r; |
440 |
|
|
} |
441 |
|
|
for (i = 0; i <= mask_g>>sh_g; i++) |
442 |
|
|
{ |
443 |
|
|
RUINT32T tmp; |
444 |
|
|
tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
445 |
|
|
tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
446 |
|
|
lookup_g[i] = (tmp/65535)<<sh_g; |
447 |
|
|
} |
448 |
|
|
for (i = 0; i <= mask_b>>sh_b; i++) |
449 |
|
|
{ |
450 |
|
|
RUINT32T tmp; |
451 |
|
|
tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
452 |
|
|
tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
453 |
|
|
lookup_b[i] = (tmp/65535)<<sh_b; |
454 |
|
|
} |
455 |
|
|
|
456 |
|
|
/* apply table to input image (replacing colors by newly calculated ones) */ |
457 |
|
|
switch (srcImage->bits_per_pixel) |
458 |
|
|
{ |
459 |
|
|
case 15: |
460 |
|
|
{ |
461 |
|
|
unsigned short *p1, *pf, *p, *pl; |
462 |
|
|
p1 = (unsigned short *) srcImage->data; |
463 |
|
|
pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
464 |
|
|
while (p1 < pf) |
465 |
|
|
{ |
466 |
|
|
p = p1; |
467 |
|
|
pl = p1 + srcImage->width; |
468 |
|
|
for (; p < pl; p++) |
469 |
|
|
{ |
470 |
|
|
*p = lookup_r[(*p & 0x7c00)>>10] | |
471 |
|
|
lookup_g[(*p & 0x03e0)>> 5] | |
472 |
|
|
lookup_b[(*p & 0x001f)]; |
473 |
|
|
} |
474 |
|
|
p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
475 |
|
|
} |
476 |
|
|
break; |
477 |
|
|
} |
478 |
|
|
case 16: |
479 |
|
|
{ |
480 |
|
|
unsigned short *p1, *pf, *p, *pl; |
481 |
|
|
p1 = (unsigned short *) srcImage->data; |
482 |
|
|
pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
483 |
|
|
while (p1 < pf) |
484 |
|
|
{ |
485 |
|
|
p = p1; |
486 |
|
|
pl = p1 + srcImage->width; |
487 |
|
|
for (; p < pl; p++) |
488 |
|
|
{ |
489 |
|
|
*p = lookup_r[(*p & 0xf800)>>11] | |
490 |
|
|
lookup_g[(*p & 0x07e0)>> 5] | |
491 |
|
|
lookup_b[(*p & 0x001f)]; |
492 |
|
|
} |
493 |
|
|
p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
494 |
|
|
} |
495 |
|
|
break; |
496 |
|
|
} |
497 |
|
|
case 24: |
498 |
|
|
{ |
499 |
|
|
unsigned char *p1, *pf, *p, *pl; |
500 |
|
|
p1 = (unsigned char *) srcImage->data; |
501 |
|
|
pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
502 |
|
|
while (p1 < pf) |
503 |
|
|
{ |
504 |
|
|
p = p1; |
505 |
|
|
pl = p1 + srcImage->width * 3; |
506 |
|
|
for (; p < pl; p += 3) |
507 |
|
|
{ |
508 |
|
|
p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
509 |
|
|
p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
510 |
|
|
p[2] = lookup_r[(p[2] & 0x0000ff)]; |
511 |
|
|
} |
512 |
|
|
p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
513 |
|
|
} |
514 |
|
|
break; |
515 |
|
|
} |
516 |
|
|
case 32: |
517 |
|
|
{ |
518 |
|
|
RUINT32T *p1, *pf, *p, *pl; |
519 |
|
|
p1 = (RUINT32T *) srcImage->data; |
520 |
|
|
pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
521 |
|
|
|
522 |
|
|
while (p1 < pf) |
523 |
|
|
{ |
524 |
|
|
p = p1; |
525 |
|
|
pl = p1 + srcImage->width; |
526 |
|
|
for (; p < pl; p++) |
527 |
|
|
{ |
528 |
|
|
*p = lookup_r[(*p & 0xff0000)>>16] | |
529 |
|
|
lookup_g[(*p & 0x00ff00)>> 8] | |
530 |
|
|
lookup_b[(*p & 0x0000ff)] | |
531 |
|
|
(*p & ~0xffffff); |
532 |
|
|
} |
533 |
|
|
p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
534 |
|
|
} |
535 |
|
|
break; |
536 |
|
|
} |
537 |
|
|
} |
538 |
|
|
|
539 |
|
|
free (lookup); |
540 |
|
|
} |
541 |
|
|
#endif |
542 |
|
|
|
543 |
|
|
/* |
544 |
|
|
* Check our parents are still who we think they are. |
545 |
|
|
* Do transparency updates if required |
546 |
|
|
*/ |
547 |
|
|
int |
548 |
|
|
rxvt_term::check_our_parents () |
549 |
|
|
{ |
550 |
|
|
check_our_parents_ev.stop (); |
551 |
|
|
check_our_parents_ev.start (NOW + .1); |
552 |
|
|
return 0; |
553 |
|
|
} |
554 |
|
|
|
555 |
|
|
void |
556 |
|
|
rxvt_term::check_our_parents_cb (time_watcher &w) |
557 |
|
|
{ |
558 |
sasha |
1.52 |
int i, pchanged, aformat, rootdepth; |
559 |
ayin |
1.39 |
unsigned long nitems, bytes_after; |
560 |
|
|
Atom atype; |
561 |
|
|
unsigned char *prop = NULL; |
562 |
|
|
Window root, oldp, *list; |
563 |
|
|
Pixmap rootpixmap = None; |
564 |
|
|
XWindowAttributes wattr, wrootattr; |
565 |
|
|
int sx, sy; |
566 |
|
|
Window cr; |
567 |
sasha |
1.52 |
unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
568 |
ayin |
1.39 |
|
569 |
|
|
pchanged = 0; |
570 |
|
|
|
571 |
|
|
if (!option (Opt_transparent)) |
572 |
|
|
return /*pchanged*/; /* Don't try any more */ |
573 |
|
|
|
574 |
sasha |
1.52 |
#if 0 |
575 |
|
|
struct timeval stv; |
576 |
|
|
gettimeofday (&stv,NULL); |
577 |
|
|
#define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
578 |
|
|
fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\ |
579 |
|
|
tv.tv_sec*1000000+tv.tv_usec-stv.tv_usec );}while(0) |
580 |
|
|
#else |
581 |
|
|
#define PRINT_BACKGROUND_OP_TIME do{}while(0) |
582 |
|
|
#endif |
583 |
|
|
|
584 |
|
|
|
585 |
ayin |
1.39 |
XGetWindowAttributes (dpy, display->root, &wrootattr); |
586 |
|
|
rootdepth = wrootattr.depth; |
587 |
|
|
|
588 |
|
|
XGetWindowAttributes (dpy, parent[0], &wattr); |
589 |
|
|
|
590 |
|
|
if (rootdepth != wattr.depth) |
591 |
|
|
{ |
592 |
|
|
if (am_transparent) |
593 |
|
|
{ |
594 |
|
|
pchanged = 1; |
595 |
|
|
XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
596 |
|
|
am_transparent = am_pixmap_trans = 0; |
597 |
|
|
} |
598 |
|
|
|
599 |
|
|
return /*pchanged*/; /* Don't try any more */ |
600 |
|
|
} |
601 |
|
|
|
602 |
|
|
/* Get all X ops out of the queue so that our information is up-to-date. */ |
603 |
|
|
XSync (dpy, False); |
604 |
|
|
|
605 |
|
|
XTranslateCoordinates (dpy, parent[0], display->root, |
606 |
|
|
0, 0, &sx, &sy, &cr); |
607 |
|
|
/* check if we are outside of the visible part of the virtual screen : */ |
608 |
ayin |
1.51 |
if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0 |
609 |
|
|
|| sx >= wrootattr.width || sy >= wrootattr.height ) |
610 |
ayin |
1.39 |
return /* 0 */ ; |
611 |
|
|
/* |
612 |
|
|
* Make the frame window set by the window manager have |
613 |
|
|
* the root background. Some window managers put multiple nested frame |
614 |
|
|
* windows for each client, so we have to take care about that. |
615 |
|
|
*/ |
616 |
|
|
i = (xa[XA_XROOTPMAP_ID] |
617 |
|
|
&& XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], |
618 |
|
|
0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
619 |
|
|
&nitems, &bytes_after, &prop) == Success); |
620 |
|
|
|
621 |
|
|
if (!i || prop == NULL) |
622 |
|
|
i = (xa[XA_ESETROOT_PMAP_ID] |
623 |
|
|
&& XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
624 |
|
|
0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
625 |
|
|
&nitems, &bytes_after, &prop) == Success); |
626 |
|
|
|
627 |
sasha |
1.52 |
/* TODO: the below logic needs to be cleaned up */ |
628 |
ayin |
1.39 |
if (!i || prop == NULL |
629 |
|
|
#if TINTING |
630 |
|
|
|| (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL |
631 |
|
|
#ifdef HAVE_AFTERIMAGE |
632 |
|
|
&& original_asim == NULL && rs[Rs_blurradius] == NULL |
633 |
|
|
#endif |
634 |
|
|
) |
635 |
|
|
#endif |
636 |
|
|
) |
637 |
sasha |
1.52 |
rootpixmap = None; |
638 |
ayin |
1.39 |
else |
639 |
|
|
{ |
640 |
sasha |
1.52 |
int junk; |
641 |
|
|
unsigned int ujunk; |
642 |
|
|
/* root pixmap may be bad - allow a error */ |
643 |
|
|
allowedxerror = -1; |
644 |
|
|
if ((rootpixmap = *(Pixmap *)prop) != None) |
645 |
|
|
if (!XGetGeometry (dpy, rootpixmap, &root, &junk, &junk, &rootpixmap_w, &rootpixmap_h, &ujunk, &ujunk)) |
646 |
|
|
rootpixmap = None; |
647 |
|
|
allowedxerror = 0; |
648 |
ayin |
1.39 |
} |
649 |
|
|
|
650 |
sasha |
1.52 |
if (prop != NULL) |
651 |
|
|
XFree (prop); |
652 |
|
|
|
653 |
|
|
if (rootpixmap != None) |
654 |
ayin |
1.39 |
{ |
655 |
sasha |
1.49 |
Bool success = False; |
656 |
ayin |
1.40 |
GC gc = NULL; |
657 |
ayin |
1.39 |
XGCValues gcvalue; |
658 |
sasha |
1.52 |
int shade = 100; |
659 |
|
|
rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
660 |
|
|
Bool whole_tint = False, no_tint = True; |
661 |
ayin |
1.51 |
|
662 |
sasha |
1.52 |
while (sx < 0) sx += (int)wrootattr.width; |
663 |
|
|
while (sy < 0) sy += (int)wrootattr.height; |
664 |
ayin |
1.39 |
|
665 |
|
|
#if TINTING |
666 |
sasha |
1.52 |
if (rs[Rs_shade]) |
667 |
|
|
shade = atoi (rs[Rs_shade]); |
668 |
|
|
if (ISSET_PIXCOLOR (Color_tint)) |
669 |
|
|
pix_colors_focused [Color_tint].get (c); |
670 |
sasha |
1.49 |
#define IS_COMPONENT_WHOLESOME(c) ((c) <=0x000700 || (c)>=0x00f700) |
671 |
sasha |
1.52 |
if (shade >= 100) |
672 |
|
|
whole_tint = (IS_COMPONENT_WHOLESOME(c.r) |
673 |
|
|
&& IS_COMPONENT_WHOLESOME(c.g) |
674 |
|
|
&& IS_COMPONENT_WHOLESOME(c.b)); |
675 |
|
|
no_tint = (c.r >= 0x00f700 && c.g >= 0x00f700 && c.b >= 0x00f700); |
676 |
sasha |
1.49 |
#undef IS_COMPONENT_WHOLESOME |
677 |
sasha |
1.52 |
#endif /* TINTING */ |
678 |
|
|
/* theer are no performance advantages to reusing same pixmap */ |
679 |
|
|
if (pixmap != None) |
680 |
|
|
XFreePixmap (dpy, pixmap); |
681 |
|
|
pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, rootdepth); |
682 |
|
|
|
683 |
|
|
#if 0 /* TODO : identify cases where this will be detrimental to performance : */ |
684 |
|
|
/* we want to tile root pixmap into our own pixmap in this cases : |
685 |
|
|
* 1) rootpixmap does not cover our window entirely |
686 |
|
|
* 2) whole_tint - we can use server-side tinting or tinting disabled |
687 |
|
|
*/ |
688 |
|
|
if ( whole_tint || no_tint || pmap_w < sx + szHint.width || pmap_h < sy + szHint.height) |
689 |
|
|
{ |
690 |
|
|
} |
691 |
|
|
#endif |
692 |
|
|
gcvalue.tile = rootpixmap; |
693 |
|
|
gcvalue.fill_style = FillTiled; |
694 |
|
|
gcvalue.ts_x_origin = -sx; |
695 |
|
|
gcvalue.ts_y_origin = -sy; |
696 |
|
|
gc = XCreateGC (dpy, rootpixmap, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcvalue); |
697 |
|
|
XFillRectangle (dpy, pixmap, gc, 0, 0, szHint.width, szHint.height); |
698 |
sasha |
1.49 |
|
699 |
|
|
#if TINTING |
700 |
sasha |
1.52 |
if (whole_tint && !no_tint) |
701 |
|
|
{ |
702 |
|
|
/* In this case we can tint image server-side getting significant |
703 |
|
|
* performance improvements, as we eliminate XImage transfer |
704 |
|
|
*/ |
705 |
|
|
gcvalue.foreground = Pixel (pix_colors_focused [Color_tint]); |
706 |
|
|
gcvalue.function = GXand; |
707 |
|
|
gcvalue.fill_style = FillSolid; |
708 |
|
|
XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcvalue); |
709 |
|
|
XFillRectangle (dpy, pixmap, gc, 0, 0, szHint.width, szHint.height); |
710 |
|
|
} |
711 |
|
|
#endif |
712 |
|
|
success = True; |
713 |
|
|
#ifdef HAVE_AFTERIMAGE |
714 |
|
|
if (rs[Rs_blurradius] || original_asim != NULL || (!whole_tint && (!no_tint || shade !=100))) |
715 |
|
|
{ |
716 |
|
|
ARGB32 tint = TINT_LEAVE_SAME; |
717 |
|
|
ASImage *back_im = NULL; |
718 |
|
|
|
719 |
|
|
back_im = pixmap2ximage (asv, pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, 100); |
720 |
|
|
if (back_im != NULL) |
721 |
|
|
{ |
722 |
|
|
if (!whole_tint && (!no_tint || shade !=100)) |
723 |
|
|
{ |
724 |
|
|
ShadingInfo as_shade; |
725 |
|
|
as_shade.shading = shade; |
726 |
|
|
as_shade.tintColor.red = c.r; |
727 |
|
|
as_shade.tintColor.green = c.g; |
728 |
|
|
as_shade.tintColor.blue = c.b; |
729 |
|
|
tint = shading2tint32 (&as_shade); |
730 |
|
|
} |
731 |
|
|
|
732 |
|
|
if (rs[Rs_blurradius] && back_im) |
733 |
|
|
{ |
734 |
sasha |
1.53 |
ASImage* tmp; |
735 |
|
|
int junk; |
736 |
|
|
unsigned int hr = 1, vr = 1; |
737 |
|
|
int flags = XParseGeometry (rs[Rs_blurradius], &junk, &junk, &hr, &vr); |
738 |
|
|
if (!(flags&WidthValue)) |
739 |
|
|
hr = 1; |
740 |
|
|
if (!(flags&HeightValue)) |
741 |
|
|
vr = hr; |
742 |
|
|
tmp = blur_asimage_gauss (asv, back_im, hr, vr, 0xFFFFFFFF, |
743 |
|
|
(original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
744 |
|
|
100, ASIMAGE_QUALITY_DEFAULT); |
745 |
sasha |
1.52 |
if (tmp) |
746 |
|
|
{ |
747 |
|
|
destroy_asimage (&back_im); |
748 |
|
|
back_im = tmp; |
749 |
|
|
} |
750 |
|
|
} |
751 |
|
|
|
752 |
|
|
if (original_asim != NULL) |
753 |
|
|
{ |
754 |
|
|
ASImageLayer *layers = create_image_layers (2); |
755 |
|
|
ASImage *merged_im = NULL; |
756 |
|
|
int fore_w, fore_h; |
757 |
|
|
|
758 |
|
|
layers[0].im = back_im; |
759 |
|
|
layers[0].clip_width = szHint.width; |
760 |
|
|
layers[0].clip_height = szHint.height; |
761 |
|
|
layers[0].tint = tint; |
762 |
|
|
layers[1].im = original_asim; |
763 |
|
|
if (bgPixmap.auto_resize) |
764 |
|
|
{ |
765 |
|
|
fore_w = szHint.width; |
766 |
|
|
fore_h = szHint.height; |
767 |
|
|
} |
768 |
|
|
else |
769 |
|
|
{ |
770 |
|
|
fore_w = bgPixmap.w; |
771 |
|
|
fore_h = bgPixmap.h; |
772 |
|
|
} |
773 |
|
|
if (fore_w != original_asim->width |
774 |
|
|
|| fore_h != original_asim->height) |
775 |
|
|
{ |
776 |
|
|
layers[1].im = scale_asimage (asv, |
777 |
|
|
original_asim, |
778 |
|
|
fore_w, fore_h, |
779 |
|
|
ASA_ASImage, 100, |
780 |
|
|
ASIMAGE_QUALITY_DEFAULT); |
781 |
|
|
} |
782 |
|
|
layers[1].clip_width = szHint.width; |
783 |
|
|
layers[1].clip_height = szHint.height; |
784 |
|
|
|
785 |
|
|
if (rs[Rs_blendtype]) |
786 |
|
|
{ |
787 |
|
|
layers[1].merge_scanlines = blend_scanlines_name2func (rs[Rs_blendtype]); |
788 |
|
|
if (layers[1].merge_scanlines == NULL) |
789 |
|
|
layers[1].merge_scanlines = alphablend_scanlines; |
790 |
|
|
} |
791 |
|
|
PRINT_BACKGROUND_OP_TIME; |
792 |
|
|
merged_im = merge_layers (asv, layers, 2, szHint.width, szHint.height, |
793 |
|
|
ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
794 |
|
|
if (layers[1].im != original_asim) |
795 |
|
|
destroy_asimage (&(layers[1].im)); |
796 |
|
|
free (layers); |
797 |
|
|
|
798 |
|
|
if (merged_im != NULL) |
799 |
|
|
{ |
800 |
|
|
destroy_asimage (&back_im); |
801 |
|
|
back_im = merged_im; |
802 |
|
|
} |
803 |
|
|
PRINT_BACKGROUND_OP_TIME; |
804 |
|
|
} |
805 |
|
|
else if (tint != TINT_LEAVE_SAME) |
806 |
|
|
{ |
807 |
|
|
ASImage* tmp = tile_asimage (asv, back_im, 0, 0, szHint.width, szHint.height, tint, ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
808 |
|
|
if (tmp) |
809 |
|
|
{ |
810 |
|
|
destroy_asimage (&back_im); |
811 |
|
|
back_im = tmp; |
812 |
|
|
} |
813 |
|
|
PRINT_BACKGROUND_OP_TIME; |
814 |
|
|
} |
815 |
|
|
asimage2drawable (asv, pixmap, back_im, gc, 0, 0, 0, 0, szHint.width, szHint.height, True); |
816 |
|
|
destroy_asimage (&back_im); |
817 |
|
|
} /* back_im != NULL */ |
818 |
|
|
else |
819 |
|
|
success = False; |
820 |
|
|
} |
821 |
|
|
#else /* HAVE_AFTERIMAGE */ |
822 |
sasha |
1.49 |
#if TINTING |
823 |
sasha |
1.52 |
if (!whole_tint && (!no_tint || shade !=100)) |
824 |
|
|
{ |
825 |
|
|
XImage *image = XGetImage (dpy, pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
826 |
|
|
success = False; |
827 |
|
|
if (image != NULL) |
828 |
|
|
{ |
829 |
|
|
PRINT_BACKGROUND_OP_TIME; |
830 |
|
|
if (gc == NULL) |
831 |
|
|
gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
832 |
|
|
if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
833 |
|
|
ShadeXImage (this, image, shade, c.r, c.g, c.b); |
834 |
|
|
XPutImage (dpy, pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
835 |
|
|
XDestroyImage (image); |
836 |
|
|
success = True; |
837 |
|
|
} |
838 |
|
|
} |
839 |
ayin |
1.51 |
#endif |
840 |
ayin |
1.39 |
#endif /* HAVE_AFTERIMAGE */ |
841 |
sasha |
1.52 |
PRINT_BACKGROUND_OP_TIME; |
842 |
|
|
|
843 |
ayin |
1.51 |
if (gc != NULL) |
844 |
ayin |
1.39 |
XFreeGC (dpy, gc); |
845 |
|
|
|
846 |
|
|
if (!success) |
847 |
|
|
{ |
848 |
|
|
if (am_transparent && am_pixmap_trans) |
849 |
|
|
{ |
850 |
|
|
pchanged = 1; |
851 |
|
|
if (pixmap != None) |
852 |
|
|
{ |
853 |
|
|
XFreePixmap (dpy, pixmap); |
854 |
|
|
pixmap = None; |
855 |
|
|
} |
856 |
|
|
} |
857 |
|
|
|
858 |
|
|
am_pixmap_trans = 0; |
859 |
|
|
} |
860 |
|
|
else |
861 |
|
|
{ |
862 |
|
|
XSetWindowBackgroundPixmap (dpy, parent[0], pixmap); |
863 |
|
|
XClearWindow (dpy, parent[0]); |
864 |
|
|
|
865 |
|
|
if (!am_transparent || !am_pixmap_trans) |
866 |
|
|
pchanged = 1; |
867 |
|
|
|
868 |
|
|
am_transparent = am_pixmap_trans = 1; |
869 |
|
|
} |
870 |
sasha |
1.52 |
} /* rootpixmap != None */ |
871 |
ayin |
1.39 |
|
872 |
|
|
if (am_pixmap_trans) |
873 |
|
|
XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
874 |
|
|
else |
875 |
|
|
{ |
876 |
|
|
unsigned int n; |
877 |
|
|
/* |
878 |
|
|
* InheritPixmap transparency |
879 |
|
|
*/ |
880 |
|
|
for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
881 |
|
|
{ |
882 |
|
|
oldp = parent[i]; |
883 |
|
|
XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n); |
884 |
|
|
XFree (list); |
885 |
|
|
|
886 |
|
|
if (parent[i] == display->root) |
887 |
|
|
{ |
888 |
|
|
if (oldp != None) |
889 |
|
|
pchanged = 1; |
890 |
|
|
|
891 |
|
|
break; |
892 |
|
|
} |
893 |
|
|
|
894 |
|
|
if (oldp != parent[i]) |
895 |
|
|
pchanged = 1; |
896 |
|
|
} |
897 |
|
|
|
898 |
|
|
n = 0; |
899 |
|
|
|
900 |
|
|
if (pchanged) |
901 |
|
|
for (; n < (unsigned int)i; n++) |
902 |
|
|
{ |
903 |
|
|
XGetWindowAttributes (dpy, parent[n], &wattr); |
904 |
|
|
|
905 |
|
|
if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
906 |
|
|
{ |
907 |
|
|
n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
908 |
|
|
break; |
909 |
|
|
} |
910 |
|
|
} |
911 |
|
|
|
912 |
|
|
if (n > (sizeof (parent) / sizeof (parent[0]))) |
913 |
|
|
{ |
914 |
|
|
XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]); |
915 |
|
|
XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
916 |
|
|
am_transparent = 0; |
917 |
|
|
/* XXX: also turn off Opt_transparent? */ |
918 |
|
|
} |
919 |
|
|
else |
920 |
|
|
{ |
921 |
|
|
for (n = 0; n < (unsigned int)i; n++) |
922 |
|
|
{ |
923 |
|
|
XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative); |
924 |
|
|
XClearWindow (dpy, parent[n]); |
925 |
|
|
} |
926 |
|
|
|
927 |
|
|
XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
928 |
|
|
am_transparent = 1; |
929 |
|
|
} |
930 |
|
|
|
931 |
|
|
for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
932 |
|
|
parent[i] = None; |
933 |
|
|
} |
934 |
|
|
|
935 |
|
|
if (scrollBar.win) |
936 |
|
|
{ |
937 |
|
|
XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
938 |
|
|
scrollBar.setIdle (); |
939 |
|
|
scrollbar_show (0); |
940 |
|
|
} |
941 |
|
|
|
942 |
|
|
if (am_transparent) |
943 |
|
|
{ |
944 |
|
|
want_refresh = want_full_refresh = 1; |
945 |
|
|
if (am_pixmap_trans) |
946 |
|
|
flush (); |
947 |
|
|
} |
948 |
|
|
|
949 |
|
|
// return pchanged; |
950 |
|
|
} |
951 |
|
|
#endif |