1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: xpm.C |
2 | * File: xpm.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1997 Carsten Haitzler <raster@zip.com.au> |
6 | * Copyright (c) 1997 Carsten Haitzler <raster@zip.com.au> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
8 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
8 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
|
|
9 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
9 | * |
10 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License as published by |
12 | * it under the terms of the GNU General Public License as published by |
12 | * the Free Software Foundation; either version 2 of the License, or |
13 | * the Free Software Foundation; either version 2 of the License, or |
13 | * (at your option) any later version. |
14 | * (at your option) any later version. |
… | |
… | |
23 | *---------------------------------------------------------------------*/ |
24 | *---------------------------------------------------------------------*/ |
24 | |
25 | |
25 | #include "../config.h" /* NECESSARY */ |
26 | #include "../config.h" /* NECESSARY */ |
26 | #include "rxvt.h" /* NECESSARY */ |
27 | #include "rxvt.h" /* NECESSARY */ |
27 | |
28 | |
|
|
29 | /* |
|
|
30 | * Pixmap geometry string interpretation : |
|
|
31 | * Each geometry string contains zero or one scale/position |
|
|
32 | * adjustment and may optionally be followed by a colon and one or more |
|
|
33 | * colon-delimited pixmap operations. |
|
|
34 | * The following table shows the valid geometry strings and their |
|
|
35 | * affects on the background image : |
|
|
36 | * |
|
|
37 | * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. |
|
|
38 | * W and H are percentages of the terminal window size. |
|
|
39 | * X and Y are also percentages; e.g., +50+50 centers |
|
|
40 | * the image in the window. |
|
|
41 | * WxH+X Assumes Y == X |
|
|
42 | * WxH Assumes Y == X == 50 (centers the image) |
|
|
43 | * W+X+Y Assumes H == W |
|
|
44 | * W+X Assumes H == W and Y == X |
|
|
45 | * W Assumes H == W and Y == X == 50 |
|
|
46 | * |
|
|
47 | * Adjusting position only : |
|
|
48 | * =+X+Y Set position to X% by Y% (absolute). |
|
|
49 | * =+X Set position to X% by X%. |
|
|
50 | * +X+Y Adjust position horizontally X% and vertically Y% |
|
|
51 | * from current position (relative). |
|
|
52 | * +X Adjust position horizontally X% and vertically X% |
|
|
53 | * from current position. |
|
|
54 | * |
|
|
55 | * Adjusting scale only : |
|
|
56 | * Wx0 Multiply horizontal scaling factor by W% |
|
|
57 | * 0xH Multiply vertical scaling factor by H% |
|
|
58 | * 0x0 No scaling (show image at normal size). |
|
|
59 | * |
|
|
60 | * Pixmap Operations : (should be prepended by a colon) |
|
|
61 | * tile Tile image. Scaling/position modifiers above will affect |
|
|
62 | * the tile size and origin. |
|
|
63 | * propscale When scaling, scale proportionally. That is, maintain the |
|
|
64 | * proper aspect ratio for the image. Any portion of the |
|
|
65 | * background not covered by the image is filled with the |
|
|
66 | * current background color. |
|
|
67 | * hscale Scale horizontally, tile vertically ? |
|
|
68 | * vscale Tile horizontally, scale vertically ? |
|
|
69 | * scale Scale both up and down |
|
|
70 | * auto Same as 100x100+50+50 |
|
|
71 | */ |
|
|
72 | |
|
|
73 | #ifdef HAVE_BG_PIXMAP |
|
|
74 | bool |
|
|
75 | bgPixmap_t::window_size_sensitive () |
|
|
76 | { |
28 | #ifdef XPM_BACKGROUND |
77 | #ifdef XPM_BACKGROUND |
|
|
78 | #ifdef HAVE_AFTERIMAGE |
|
|
79 | if (original_asim != NULL) |
|
|
80 | #endif |
|
|
81 | { |
|
|
82 | if (h_scale != 0 || v_scale != 0) |
|
|
83 | return true; |
|
|
84 | } |
|
|
85 | #endif |
|
|
86 | #ifdef ENABLE_TRANSPARENCY |
|
|
87 | if (flags & bgPmap_Transparent) |
|
|
88 | return true; |
|
|
89 | #endif |
|
|
90 | return false; |
|
|
91 | } |
29 | |
92 | |
30 | static void rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight); |
93 | #ifdef XPM_BACKGROUND |
31 | |
94 | static inline bool |
32 | /* |
95 | check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value) |
33 | * These GEOM strings indicate absolute size/position: |
|
|
34 | * @ `WxH+X+Y' |
|
|
35 | * @ `WxH+X' -> Y = X |
|
|
36 | * @ `WxH' -> Y = X = 50 |
|
|
37 | * @ `W+X+Y' -> H = W |
|
|
38 | * @ `W+X' -> H = W, Y = X |
|
|
39 | * @ `W' -> H = W, X = Y = 50 |
|
|
40 | * @ `0xH' -> H *= H/100, X = Y = 50 (W unchanged) |
|
|
41 | * @ `Wx0' -> W *= W/100, X = Y = 50 (H unchanged) |
|
|
42 | * @ `=+X+Y' -> (H, W unchanged) |
|
|
43 | * @ `=+X' -> Y = X (H, W unchanged) |
|
|
44 | * |
|
|
45 | * These GEOM strings adjust position relative to current position: |
|
|
46 | * @ `+X+Y' |
|
|
47 | * @ `+X' -> Y = X |
|
|
48 | * |
|
|
49 | * And this GEOM string is for querying current scale/position: |
|
|
50 | * @ `?' |
|
|
51 | */ |
|
|
52 | int |
|
|
53 | rxvt_term::scale_pixmap (const char *geom) |
|
|
54 | { |
96 | { |
|
|
97 | if (geom_flags & flag) |
|
|
98 | { |
|
|
99 | if (new_value > 1000) |
|
|
100 | new_value = 1000; |
|
|
101 | if (new_value != scale) |
|
|
102 | { |
|
|
103 | scale = new_value; |
|
|
104 | return true; |
|
|
105 | } |
|
|
106 | } |
|
|
107 | return false; |
|
|
108 | } |
|
|
109 | |
|
|
110 | static inline bool |
|
|
111 | check_set_align_value (int geom_flags, int flag, int &align, int new_value) |
|
|
112 | { |
|
|
113 | if (geom_flags & flag) |
|
|
114 | { |
|
|
115 | if (new_value < -100) |
|
|
116 | new_value = -100; |
|
|
117 | else if (new_value > 200) |
|
|
118 | new_value = 200; |
|
|
119 | if (new_value != align) |
|
|
120 | { |
|
|
121 | align = new_value; |
|
|
122 | return true; |
|
|
123 | } |
|
|
124 | } |
|
|
125 | return false; |
|
|
126 | } |
|
|
127 | |
|
|
128 | static inline int |
|
|
129 | make_align_position (int align, int window_size, int image_size) |
|
|
130 | { |
|
|
131 | int diff = window_size - image_size; |
|
|
132 | int smaller = MIN (image_size,window_size); |
|
|
133 | |
|
|
134 | if (align >= 0 && align <= 50) |
|
|
135 | return diff * align / 100; |
|
|
136 | else if (align > 50 && align <= 100) |
|
|
137 | return window_size - image_size + diff * align / 100; |
|
|
138 | else if (align > 100 && align <= 200 ) |
|
|
139 | return ((align - 100) * smaller / 100) + window_size - smaller; |
|
|
140 | else if (align > -100 && align < 0) |
|
|
141 | return ((align + 100) * smaller / 100) - image_size; |
|
|
142 | return 0; |
|
|
143 | } |
|
|
144 | |
|
|
145 | static inline void |
|
|
146 | make_clip_rectangle (int pos, int size, int target_size, int &clip_pos, int &clip_size) |
|
|
147 | { |
|
|
148 | if (size <= 0) |
|
|
149 | { /* special case - tiling */ |
|
|
150 | clip_pos = pos; |
|
|
151 | clip_size = target_size; |
|
|
152 | } |
|
|
153 | else if (pos < 0) |
|
|
154 | { |
|
|
155 | clip_pos = 0; |
|
|
156 | clip_size = MIN (target_size, size + pos); |
|
|
157 | } |
|
|
158 | else |
|
|
159 | { |
|
|
160 | clip_pos = pos; |
|
|
161 | clip_size = size; |
|
|
162 | if (pos < target_size && (int)clip_size > target_size - pos) |
|
|
163 | clip_pos = target_size - pos; |
|
|
164 | } |
|
|
165 | } |
|
|
166 | |
|
|
167 | bool |
|
|
168 | bgPixmap_t::handle_geometry (const char *geom) |
|
|
169 | { |
55 | int flags, changed = 0; |
170 | int geom_flags = 0, changed = 0; |
56 | int x = 0, y = 0; |
171 | int x = 0, y = 0; |
57 | unsigned int w = 0, h = 0; |
172 | unsigned int w = 0, h = 0; |
58 | unsigned int n; |
173 | unsigned int n; |
|
|
174 | unsigned long new_flags = (flags&(~bgPmap_geometryFlags)); |
59 | char *p; |
175 | char *p; |
60 | bgPixmap_t *bgpixmap = & (bgPixmap); |
176 | #define MAXLEN_GEOM 256 /* could be longer then regular geometry string */ |
61 | |
|
|
62 | #define MAXLEN_GEOM sizeof("[10000x10000+10000+10000]") |
|
|
63 | |
177 | |
64 | if (geom == NULL) |
178 | if (geom == NULL) |
65 | return 0; |
179 | return false; |
66 | |
180 | |
67 | char str[MAXLEN_GEOM]; |
181 | char str[MAXLEN_GEOM]; |
68 | |
182 | |
69 | if (!strcmp (geom, "?")) |
183 | if (!strcmp (geom, "?")) |
70 | { |
184 | { |
|
|
185 | #if 0 /* TODO: */ |
71 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
186 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
72 | min (bgpixmap->w, 32767), min (bgpixmap->h, 32767), |
187 | min (h_scale, 32767), min (v_scale, 32767), |
73 | min (bgpixmap->x, 32767), min (bgpixmap->y, 32767)); |
188 | min (h_align, 32767), min (v_align, 32767)); |
74 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
189 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
|
|
190 | #endif |
75 | return 0; |
191 | return false; |
76 | } |
192 | } |
77 | |
193 | while (isspace(*geom)) ++geom; |
78 | if ((p = strchr (geom, ';')) == NULL) |
194 | if ((p = strchr (geom, ';')) == NULL) |
79 | p = strchr (geom, '\0'); |
195 | p = strchr (geom, '\0'); |
80 | |
196 | |
81 | n = (p - geom); |
197 | n = (p - geom); |
82 | if (n <= MAXLEN_GEOM) |
198 | if (n < MAXLEN_GEOM) |
83 | { |
199 | { |
|
|
200 | char *ops; |
|
|
201 | new_flags |= bgPmap_geometrySet; |
|
|
202 | |
84 | strncpy (str, geom, n); |
203 | strncpy (str, geom, n); |
85 | str[n] = '\0'; |
204 | str[n] = '\0'; |
86 | |
205 | if (str[0] == ':') |
87 | flags = XParseGeometry (str, &x, &y, &w, &h); |
206 | ops = &str[0]; |
88 | |
207 | else if (str[0] != 'x' && str[0] != 'X' && isalpha(str[0])) |
89 | if (!flags) |
208 | ops = &str[0]; |
|
|
209 | else |
90 | { |
210 | { |
91 | flags |= WidthValue; |
211 | char *tmp; |
92 | w = 0; |
212 | ops = strchr (str, ':'); |
93 | } /* default is tile */ |
213 | if (ops != NULL) |
94 | |
|
|
95 | if (flags & WidthValue) |
|
|
96 | { |
|
|
97 | if (!(flags & XValue)) |
|
|
98 | x = 50; |
|
|
99 | |
|
|
100 | if (!(flags & HeightValue)) |
|
|
101 | h = w; |
|
|
102 | |
|
|
103 | if (w && !h) |
|
|
104 | { |
214 | { |
105 | w = (bgpixmap->w * w) / 100; |
215 | for (tmp = ops-1; tmp >= str && isspace(*tmp); --tmp); |
106 | h = bgpixmap->h; |
216 | *(++tmp) = '\0'; |
|
|
217 | if (ops == tmp) ++ops; |
107 | } |
218 | } |
108 | else if (h && !w) |
219 | } |
|
|
220 | |
|
|
221 | if (ops > str || ops == NULL) |
|
|
222 | { |
|
|
223 | /* we have geometry string - let's handle it prior to applying ops */ |
|
|
224 | geom_flags = XParseGeometry (str, &x, &y, &w, &h); |
|
|
225 | |
|
|
226 | if ((geom_flags & XValue) && !(geom_flags & YValue)) |
109 | { |
227 | { |
110 | w = bgpixmap->w; |
228 | y = x; |
111 | h = (bgpixmap->h * h) / 100; |
229 | geom_flags |= YValue; |
112 | } |
230 | } |
113 | |
231 | |
114 | min_it (w, 32767); |
232 | if (flags & bgPmap_geometrySet) |
115 | min_it (h, 32767); |
233 | {/* new geometry is an adjustment to the old one ! */ |
116 | |
234 | if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) |
117 | if (bgpixmap->w != (short)w) |
235 | { |
|
|
236 | if (w == 0 && h != 0) |
|
|
237 | { |
|
|
238 | w = h_scale; |
|
|
239 | h = (v_scale * h) / 100; |
|
|
240 | } |
|
|
241 | else if (h == 0 && w != 0) |
|
|
242 | { |
|
|
243 | w = (h_scale * w) / 100; |
|
|
244 | h = v_scale; |
|
|
245 | } |
|
|
246 | } |
|
|
247 | if (geom_flags & XValue) |
|
|
248 | { |
|
|
249 | if (str[0] != '=') |
|
|
250 | { |
|
|
251 | y += v_align; |
|
|
252 | x += h_align; |
|
|
253 | } |
|
|
254 | } |
|
|
255 | } |
|
|
256 | else /* setting up geometry from scratch */ |
118 | { |
257 | { |
119 | bgpixmap->w = (short)w; |
258 | if (!(geom_flags & XValue)) |
120 | changed++; |
259 | {/* use default geometry - centered */ |
|
|
260 | x = y = bgPmap_defaultAlign; |
|
|
261 | } |
|
|
262 | else if (!(geom_flags & YValue)) |
|
|
263 | y = x; |
|
|
264 | |
|
|
265 | if ((geom_flags & (WidthValue|HeightValue)) == 0) |
|
|
266 | {/* use default geometry - scaled */ |
|
|
267 | w = h = bgPmap_defaultScale; |
|
|
268 | } |
|
|
269 | else if (geom_flags & WidthValue) |
|
|
270 | { |
|
|
271 | if (!(geom_flags & HeightValue)) |
|
|
272 | h = w; |
|
|
273 | } |
|
|
274 | else |
|
|
275 | w = h; |
121 | } |
276 | } |
|
|
277 | } /* done parsing geometry string */ |
|
|
278 | else if (!(flags & bgPmap_geometrySet)) |
|
|
279 | { /* default geometry - scaled and centered */ |
|
|
280 | x = y = bgPmap_defaultAlign; |
|
|
281 | w = h = bgPmap_defaultScale; |
|
|
282 | } |
|
|
283 | |
|
|
284 | if (!(flags & bgPmap_geometrySet)) |
|
|
285 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
122 | |
286 | |
123 | if (bgpixmap->h != (short)h) |
287 | if (ops) |
|
|
288 | { |
|
|
289 | while (*ops) |
124 | { |
290 | { |
125 | bgpixmap->h = (short)h; |
291 | while (*ops == ':' || isspace(*ops)) ++ops; |
|
|
292 | #define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) |
|
|
293 | if (CHECK_GEOM_OPS("tile")) |
|
|
294 | { |
|
|
295 | w = h = 0; |
|
|
296 | geom_flags |= WidthValue|HeightValue; |
|
|
297 | } |
|
|
298 | else if (CHECK_GEOM_OPS("propscale")) |
|
|
299 | { |
|
|
300 | if (w == 0 && h == 0) |
|
|
301 | { |
|
|
302 | w = 100; |
|
|
303 | geom_flags |= WidthValue; |
|
|
304 | } |
|
|
305 | new_flags |= bgPmap_propScale; |
|
|
306 | } |
|
|
307 | else if (CHECK_GEOM_OPS("hscale")) |
|
|
308 | { |
|
|
309 | if (w == 0) |
|
|
310 | w = 100; |
|
|
311 | h = 0; |
|
|
312 | geom_flags |= WidthValue|HeightValue; |
|
|
313 | } |
|
|
314 | else if (CHECK_GEOM_OPS("vscale")) |
|
|
315 | { |
|
|
316 | if (h == 0) |
|
|
317 | h = 100; |
|
|
318 | w = 0; |
|
|
319 | geom_flags |= WidthValue|HeightValue; |
|
|
320 | } |
|
|
321 | else if (CHECK_GEOM_OPS("scale")) |
|
|
322 | { |
|
|
323 | if (h == 0) |
|
|
324 | h = 100; |
|
|
325 | if (w == 0) |
|
|
326 | w = 100; |
|
|
327 | geom_flags |= WidthValue|HeightValue; |
|
|
328 | } |
|
|
329 | else if (CHECK_GEOM_OPS("auto")) |
|
|
330 | { |
|
|
331 | w = h = 100; |
|
|
332 | x = y = 50; |
|
|
333 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
|
|
334 | } |
|
|
335 | #undef CHECK_GEOM_OPS |
|
|
336 | while (*ops != ':' && *ops != '\0') ++ops; |
|
|
337 | } /* done parsing ops */ |
|
|
338 | } |
|
|
339 | |
|
|
340 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) |
|
|
341 | ++changed; |
|
|
342 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) |
|
|
343 | ++changed; |
|
|
344 | if (check_set_align_value (geom_flags, XValue, h_align, x)) |
|
|
345 | ++changed; |
|
|
346 | if (check_set_align_value (geom_flags, YValue, v_align, y)) |
|
|
347 | ++changed; |
|
|
348 | } |
|
|
349 | |
|
|
350 | if (new_flags != flags) |
|
|
351 | { |
|
|
352 | flags = new_flags; |
126 | changed++; |
353 | changed++; |
|
|
354 | } |
|
|
355 | //fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
|
|
356 | // flags, h_scale, v_scale, h_align, v_align); |
|
|
357 | return (changed > 0); |
|
|
358 | } |
|
|
359 | |
|
|
360 | #ifdef HAVE_AFTERIMAGE |
|
|
361 | bool |
|
|
362 | bgPixmap_t::render_asim (rxvt_term *target, ASImage *background, ARGB32 background_tint) |
|
|
363 | { |
|
|
364 | if (target == NULL) |
|
|
365 | return false; |
|
|
366 | |
|
|
367 | int target_width = (int)target->szHint.width; |
|
|
368 | int target_height = (int)target->szHint.height; |
|
|
369 | int new_pmap_width = target_width, new_pmap_height = target_height; |
|
|
370 | ASImage *result = NULL; |
|
|
371 | |
|
|
372 | int x = 0; |
|
|
373 | int y = 0; |
|
|
374 | int w = h_scale * target_width / 100; |
|
|
375 | int h = v_scale * target_height / 100; |
|
|
376 | |
|
|
377 | if (original_asim) |
|
|
378 | { |
|
|
379 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
|
|
380 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
|
|
381 | } |
|
|
382 | |
|
|
383 | int dst_x, dst_y; |
|
|
384 | int clip_width, clip_height; |
|
|
385 | |
|
|
386 | make_clip_rectangle (x, w, target_width, dst_x, clip_width); |
|
|
387 | make_clip_rectangle (y, h, target_height, dst_y, clip_height); |
|
|
388 | |
|
|
389 | /* TODO : actuall scaling code :) */ |
|
|
390 | if (dst_x >= target_width || dst_y >= target_height |
|
|
391 | || clip_width <= 0 || clip_height <= 0 || original_asim == NULL) |
|
|
392 | { |
|
|
393 | result = background; |
|
|
394 | dst_x = dst_y = 0; |
|
|
395 | if (background) |
|
|
396 | { |
|
|
397 | new_pmap_width = clip_width = background->width; |
|
|
398 | new_pmap_height = clip_height = background->height; |
|
|
399 | } |
|
|
400 | else |
|
|
401 | new_pmap_width = new_pmap_height = 0; |
|
|
402 | } |
|
|
403 | else |
|
|
404 | { |
|
|
405 | result = original_asim; |
|
|
406 | if ((w > 0 && w != original_asim->width) |
|
|
407 | || (h > 0 && h != original_asim->height)) |
|
|
408 | { |
|
|
409 | result = scale_asimage (target->asv, original_asim, |
|
|
410 | w > 0 ? w : original_asim->width, |
|
|
411 | h > 0 ? h : original_asim->height, |
|
|
412 | background ? ASA_ASImage : ASA_XImage, |
|
|
413 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
414 | } |
|
|
415 | if (background == NULL) |
|
|
416 | {/* if tiling - pixmap has to be sized exactly as the image */ |
|
|
417 | if (h_scale == 0) |
|
|
418 | new_pmap_width = result->width; |
|
|
419 | if (v_scale == 0) |
|
|
420 | new_pmap_height = result->height; |
|
|
421 | } |
|
|
422 | else |
|
|
423 | {/* if blending background and image - pixmap has to be sized same as target window */ |
|
|
424 | ASImageLayer *layers = create_image_layers (2); |
|
|
425 | ASImage *merged_im = NULL; |
|
|
426 | |
|
|
427 | layers[0].im = background; |
|
|
428 | layers[0].clip_width = target_width; |
|
|
429 | layers[0].clip_height = target_height; |
|
|
430 | layers[0].tint = background_tint; |
|
|
431 | layers[1].im = result; |
|
|
432 | if (w <= 0) |
|
|
433 | {/* tile horizontally */ |
|
|
434 | layers[1].dst_x = dst_x - (int)result->width; |
|
|
435 | layers[1].clip_width = result->width; |
127 | } |
436 | } |
|
|
437 | else |
|
|
438 | {/* clip horizontally */ |
|
|
439 | layers[1].dst_x = dst_x; |
|
|
440 | layers[1].clip_width = clip_width; |
128 | } |
441 | } |
129 | |
442 | if (h <= 0) |
130 | if (!(flags & YValue)) |
443 | { |
|
|
444 | layers[1].dst_y = dst_y - (int)result->height; |
|
|
445 | layers[1].clip_height = result->height; |
|
|
446 | } |
|
|
447 | else |
|
|
448 | { |
|
|
449 | layers[1].dst_y = dst_y; |
|
|
450 | layers[1].clip_height = clip_height; |
|
|
451 | } |
|
|
452 | if (target->rs[Rs_blendtype]) |
|
|
453 | { |
|
|
454 | layers[1].merge_scanlines = blend_scanlines_name2func (target->rs[Rs_blendtype]); |
|
|
455 | if (layers[1].merge_scanlines == NULL) |
|
|
456 | layers[1].merge_scanlines = alphablend_scanlines; |
|
|
457 | } |
|
|
458 | ASImage *tmp = merge_layers (target->asv, layers, 2, target_width, target_height, |
|
|
459 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
|
|
460 | if (tmp) |
|
|
461 | { |
|
|
462 | if (result != original_asim) |
|
|
463 | destroy_asimage (&result); |
|
|
464 | result = tmp; |
|
|
465 | dst_x = dst_y = 0; |
|
|
466 | clip_width = target_width; |
|
|
467 | clip_height = target_height; |
|
|
468 | } |
|
|
469 | free (layers); |
131 | { |
470 | } |
132 | if (flags & XNegative) |
471 | } |
133 | flags |= YNegative; |
|
|
134 | |
472 | |
135 | y = x; |
473 | if (pixmap) |
|
|
474 | { |
|
|
475 | if (result == NULL |
|
|
476 | || pmap_width != new_pmap_width |
|
|
477 | || pmap_height != new_pmap_height |
|
|
478 | || pmap_depth != target->depth) |
136 | } |
479 | { |
137 | |
480 | XFreePixmap (target->dpy, pixmap); |
138 | if (!(flags & WidthValue) && geom[0] != '=') |
481 | pixmap = None; |
139 | { |
482 | } |
140 | x += bgpixmap->x; |
483 | } |
141 | y += bgpixmap->y; |
484 | |
|
|
485 | if (result) |
|
|
486 | { |
|
|
487 | XGCValues gcv; |
|
|
488 | GC gc; |
|
|
489 | |
|
|
490 | /* create Pixmap */ |
|
|
491 | if (pixmap == None) |
142 | } |
492 | { |
143 | |
493 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
144 | if (xpmAttr.width && xpmAttr.height) |
494 | pmap_width = new_pmap_width; |
|
|
495 | pmap_height = new_pmap_height; |
|
|
496 | pmap_depth = target->depth; |
145 | { |
497 | } |
146 | x = MOD(x, xpmAttr.width); |
498 | /* fill with background color ( if result's not completely overlapping it)*/ |
147 | y = MOD(y, xpmAttr.height); |
499 | gcv.foreground = target->pix_colors[Color_bg]; |
|
|
500 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
|
|
501 | |
|
|
502 | if (dst_x > 0 || dst_y > 0 |
|
|
503 | || dst_x + clip_width < new_pmap_width |
|
|
504 | || dst_y + clip_height < new_pmap_height) |
148 | } |
505 | { |
149 | |
506 | XFillRectangle (target->dpy, pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); |
150 | if (bgpixmap->x != x) |
|
|
151 | { |
507 | } |
152 | bgpixmap->x = x; |
508 | /* put result on pixmap */ |
153 | changed++; |
509 | asimage2drawable (target->asv, pixmap, result, gc, 0, 0, dst_x, dst_y, clip_width, clip_height, True); |
154 | } |
|
|
155 | |
510 | |
156 | if (bgpixmap->y != y) |
511 | /* set target's background to pixmap */ |
157 | { |
512 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
158 | bgpixmap->y = y; |
513 | |
159 | changed++; |
514 | XFreeGC (target->dpy, gc); |
160 | } |
515 | } |
|
|
516 | else |
161 | } |
517 | { |
|
|
518 | /* set target background to a pixel */ |
|
|
519 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
|
|
520 | } |
162 | |
521 | |
163 | return changed; |
522 | return true; |
164 | } |
523 | } |
|
|
524 | #endif |
165 | |
525 | |
166 | void |
526 | void |
167 | rxvt_term::resize_pixmap () |
527 | rxvt_term::resize_pixmap () |
168 | { |
528 | { |
169 | XGCValues gcvalue; |
529 | XGCValues gcvalue; |
170 | GC gc; |
530 | GC gc; |
171 | dDisp; |
531 | unsigned int w = bgPixmap.h_scale*szHint.width/100; |
172 | |
532 | unsigned int h = bgPixmap.v_scale*szHint.height/100; |
173 | if (pixmap != None) |
533 | int x = bgPixmap.h_align*szHint.width/100; |
174 | XFreePixmap (disp, pixmap); |
534 | int y = bgPixmap.v_align*szHint.height/100; |
175 | |
535 | #ifdef HAVE_AFTERIMAGE |
|
|
536 | ASImage *im = bgPixmap.original_asim; |
|
|
537 | #else |
|
|
538 | void *im = NULL; |
|
|
539 | #endif |
|
|
540 | /* preliminary cleanup - this needs to be integrated with check_our_parents() code */ |
176 | if (bgPixmap.pixmap == None) |
541 | if (bgPixmap.pixmap != None) |
|
|
542 | { |
|
|
543 | XFreePixmap (dpy, bgPixmap.pixmap); |
|
|
544 | bgPixmap.pixmap = None ; |
|
|
545 | } |
|
|
546 | #ifdef ENABLE_TRANSPARENCY |
|
|
547 | if (option(Opt_transparent) && am_transparent) |
|
|
548 | { |
|
|
549 | /* we need to re-generate transparency pixmap in that case ! */ |
|
|
550 | check_our_parents (); |
|
|
551 | return; |
|
|
552 | } |
|
|
553 | #endif |
|
|
554 | |
|
|
555 | if (im == NULL) |
177 | { /* So be it: I'm not using pixmaps */ |
556 | { /* So be it: I'm not using pixmaps */ |
178 | pixmap = None; |
|
|
179 | |
|
|
180 | if (!OPTION (Opt_transparent) || !am_transparent) |
|
|
181 | XSetWindowBackground (disp, vt, pix_colors[Color_bg]); |
557 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
182 | |
|
|
183 | return; |
558 | return; |
184 | } |
559 | } |
185 | |
560 | |
186 | gcvalue.foreground = pix_colors[Color_bg]; |
561 | gcvalue.foreground = pix_colors[Color_bg]; |
187 | gc = XCreateGC (disp, vt, GCForeground, &gcvalue); |
562 | gc = XCreateGC (dpy, vt, GCForeground, &gcvalue); |
188 | |
563 | |
189 | if (bgPixmap.pixmap != None) |
|
|
190 | { /* we have a specified pixmap */ |
|
|
191 | unsigned int w = bgPixmap.w, h = bgPixmap.h, |
|
|
192 | x = bgPixmap.x, y = bgPixmap.y; |
|
|
193 | unsigned int xpmh = xpmAttr.height, |
|
|
194 | xpmw = xpmAttr.width; |
|
|
195 | |
|
|
196 | /* |
|
|
197 | * don't zoom pixmap too much nor expand really small pixmaps |
564 | /* don't zoom pixmap too much nor expand really small pixmaps */ |
198 | */ |
565 | if (w > 16000) |
199 | if (w > 32767 || h > 32767) |
|
|
200 | w = 1; |
566 | w = 1; |
201 | else if (width > (10 * xpmw) |
567 | if (h > 16000) |
202 | || height > (10 * xpmh)) |
568 | h = 1; |
203 | w = 0; /* tile */ |
569 | |
|
|
570 | #ifdef HAVE_AFTERIMAGE |
|
|
571 | if (w == 0) |
|
|
572 | w = im->width; |
|
|
573 | if (h == 0) |
|
|
574 | h = im->height; |
204 | |
575 | |
205 | if (!w) |
576 | if (w != im->width || h != im->height) |
206 | { |
577 | { |
207 | /* basic X tiling - let the X server do it */ |
578 | ASImage *tmp = scale_asimage (asv, im, w, h, (x == 0 && y == 0)?ASA_XImage:ASA_ASImage, 0, ASIMAGE_QUALITY_DEFAULT); |
208 | pixmap = XCreatePixmap (disp, vt, xpmw, xpmh, display->depth); |
579 | if (tmp != NULL) |
209 | |
580 | im = tmp; |
210 | XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, x, y, xpmw - x, xpmh - y, 0, 0); |
581 | } |
211 | XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y); |
582 | bgPixmap.pmap_width = MIN(w,szHint.width); |
212 | XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0); |
583 | bgPixmap.pmap_height = MIN(h,szHint.height); |
213 | XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y); |
584 | #if 0 /* TODO: fix that! */ |
|
|
585 | if (x != 0 || y != 0) |
|
|
586 | { |
|
|
587 | ASImage *tmp = tile_asimage (asv, im, x, y, w, h, TINT_LEAVE_SAME, ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
|
|
588 | if (tmp != NULL) |
214 | } |
589 | { |
215 | else |
590 | if (im != bgPixmap.original_asim) |
|
|
591 | destroy_asimage (&im); |
|
|
592 | im = tmp; |
216 | { |
593 | } |
217 | float incr, p; |
|
|
218 | Pixmap tmp; |
|
|
219 | |
|
|
220 | pixmap = XCreatePixmap (disp, vt, width, height, |
|
|
221 | (unsigned int)display->depth); |
|
|
222 | /* |
|
|
223 | * horizontal scaling |
|
|
224 | */ |
|
|
225 | rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); |
|
|
226 | |
|
|
227 | tmp = XCreatePixmap (disp, vt, width, xpmh, (unsigned int)display->depth); |
|
|
228 | XFillRectangle (disp, tmp, gc, 0, 0, width, xpmh); |
|
|
229 | |
|
|
230 | for ( /*nil */ ; x < w; x++, p += incr) |
|
|
231 | { |
|
|
232 | if (p >= xpmw) |
|
|
233 | p = 0; |
|
|
234 | |
|
|
235 | /* copy one column from the original pixmap to the tmp pixmap */ |
|
|
236 | XCopyArea (disp, bgPixmap.pixmap, tmp, gc, |
|
|
237 | (int)p, 0, 1, xpmh, (int)x, 0); |
|
|
238 | } |
|
|
239 | |
|
|
240 | /* |
|
|
241 | * vertical scaling |
|
|
242 | */ |
|
|
243 | rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); |
|
|
244 | |
|
|
245 | if (y > 0) |
|
|
246 | XFillRectangle (disp, pixmap, gc, 0, 0, width, y); |
|
|
247 | |
|
|
248 | if (h < height) |
|
|
249 | XFillRectangle (disp, pixmap, gc, 0, (int)h, width, height - h + 1); |
|
|
250 | |
|
|
251 | for ( /*nil */ ; y < h; y++, p += incr) |
|
|
252 | { |
|
|
253 | if (p >= xpmh) |
|
|
254 | p = 0; |
|
|
255 | |
|
|
256 | /* copy one row from the tmp pixmap to the main pixmap */ |
|
|
257 | XCopyArea (disp, tmp, pixmap, gc, |
|
|
258 | 0, (int)p, width, 1, 0, (int)y); |
|
|
259 | } |
|
|
260 | |
|
|
261 | XFreePixmap (disp, tmp); |
|
|
262 | } |
|
|
263 | } |
594 | } |
|
|
595 | #endif |
|
|
596 | bgPixmap.pixmap = XCreatePixmap (dpy, vt, bgPixmap.pmap_width, bgPixmap.pmap_height, depth); |
|
|
597 | bgPixmap.pmap_depth = depth; |
264 | |
598 | |
|
|
599 | asimage2drawable (asv, bgPixmap.pixmap, im, gc, 0, 0, 0, 0, bgPixmap.pmap_width, bgPixmap.pmap_height, True); |
|
|
600 | |
|
|
601 | if (im != bgPixmap.original_asim) |
|
|
602 | destroy_asimage (&im); |
|
|
603 | #endif |
|
|
604 | if( bgPixmap.pixmap ) |
265 | XSetWindowBackgroundPixmap (disp, vt, pixmap); |
605 | XSetWindowBackgroundPixmap (dpy, vt, bgPixmap.pixmap); |
266 | |
606 | |
267 | if (pixmap != None) |
|
|
268 | { |
|
|
269 | XFreePixmap (disp, pixmap); |
|
|
270 | pixmap = None; |
|
|
271 | } |
|
|
272 | |
|
|
273 | XFreeGC (disp, gc); |
607 | XFreeGC (dpy, gc); |
274 | am_transparent = 0; |
|
|
275 | } |
608 | } |
276 | |
609 | |
277 | /* |
610 | void |
278 | * Calculate tiling sizes and increments |
|
|
279 | * At start, p == 0, incr == xpmwidthheight |
|
|
280 | */ |
|
|
281 | static void |
|
|
282 | rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight) |
|
|
283 | { |
|
|
284 | unsigned int cwh, cxy; |
|
|
285 | float cincr, cp; |
|
|
286 | |
|
|
287 | cp = 0; |
|
|
288 | cincr = (float)xpmwidthheight; |
|
|
289 | cxy = *xy; |
|
|
290 | cwh = *wh; |
|
|
291 | if (cwh == 1) |
|
|
292 | { /* display one image, no horizontal/vertical scaling */ |
|
|
293 | cincr = (float)widthheight; |
|
|
294 | if (xpmwidthheight <= widthheight) |
|
|
295 | { |
|
|
296 | cwh = xpmwidthheight; |
|
|
297 | cxy = (cxy * (widthheight - cwh)) / 100; /* beware! order */ |
|
|
298 | cwh += cxy; |
|
|
299 | } |
|
|
300 | else |
|
|
301 | { |
|
|
302 | cxy = 0; |
|
|
303 | cwh = widthheight; |
|
|
304 | } |
|
|
305 | } |
|
|
306 | else if (cwh < 10) |
|
|
307 | { /* fit WH images across/down screen */ |
|
|
308 | cincr *= cwh; |
|
|
309 | cxy = 0; |
|
|
310 | cwh = widthheight; |
|
|
311 | } |
|
|
312 | else |
|
|
313 | { |
|
|
314 | cincr *= 100.0 / cwh; |
|
|
315 | if (cwh < 100) |
|
|
316 | { /* contract */ |
|
|
317 | float pos; |
|
|
318 | |
|
|
319 | cwh = (cwh * widthheight) / 100; |
|
|
320 | pos = (float)cxy / 100 * widthheight - (cwh / 2); |
|
|
321 | |
|
|
322 | cxy = (widthheight - cwh); |
|
|
323 | if (pos <= 0) |
|
|
324 | cxy = 0; |
|
|
325 | else if (pos < cxy) |
|
|
326 | cxy = (int) pos; |
|
|
327 | cwh += cxy; |
|
|
328 | } |
|
|
329 | else |
|
|
330 | { /* expand */ |
|
|
331 | if (cxy > 0) |
|
|
332 | { /* position */ |
|
|
333 | float pos; |
|
|
334 | |
|
|
335 | pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2); |
|
|
336 | cp = xpmwidthheight - cincr; |
|
|
337 | if (pos <= 0) |
|
|
338 | cp = 0; |
|
|
339 | else if (pos < cp) |
|
|
340 | cp = pos; |
|
|
341 | } |
|
|
342 | cxy = 0; |
|
|
343 | cwh = widthheight; |
|
|
344 | } |
|
|
345 | } |
|
|
346 | cincr /= widthheight; |
|
|
347 | *wh = cwh; |
|
|
348 | *xy = cxy; |
|
|
349 | *incr = cincr; |
|
|
350 | *p = cp; |
|
|
351 | } |
|
|
352 | |
|
|
353 | Pixmap |
|
|
354 | rxvt_term::set_bgPixmap (const char *file) |
611 | rxvt_term::set_bgPixmap (const char *file) |
355 | { |
612 | { |
356 | char *f; |
613 | char *f; |
357 | |
614 | |
358 | assert (file != NULL); |
615 | assert (file != NULL); |
359 | |
616 | |
360 | if (bgPixmap.pixmap != None) |
617 | if (bgPixmap.pixmap != None) |
361 | { |
618 | { |
362 | XFreePixmap (display->display, bgPixmap.pixmap); |
619 | XFreePixmap (dpy, bgPixmap.pixmap); |
363 | bgPixmap.pixmap = None; |
620 | bgPixmap.pixmap = None; |
364 | } |
621 | } |
365 | |
622 | |
366 | XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); |
623 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
367 | |
|
|
368 | if (*file != '\0') |
624 | if (*file != '\0') |
369 | { |
625 | { |
370 | /* XWindowAttributes attr; */ |
626 | #ifdef HAVE_AFTERIMAGE |
|
|
627 | if (asimman == NULL) |
|
|
628 | asimman = create_generic_imageman(rs[Rs_path]); |
|
|
629 | if ((f = strchr (file, ';')) == NULL) |
|
|
630 | bgPixmap.original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); |
|
|
631 | else |
|
|
632 | { |
|
|
633 | size_t len = f - file; |
|
|
634 | f = (char *)malloc (len + 1); |
|
|
635 | strncpy (f, file, len); |
|
|
636 | f[len] = '\0'; |
|
|
637 | bgPixmap.original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); |
|
|
638 | free( f ); |
|
|
639 | } |
|
|
640 | #endif |
|
|
641 | } |
371 | |
642 | |
|
|
643 | resize_pixmap (); |
|
|
644 | } |
|
|
645 | |
|
|
646 | #endif /* XPM_BACKGROUND */ |
|
|
647 | #endif /* HAVE_BG_PIXMAP */ |
|
|
648 | |
|
|
649 | #ifdef ENABLE_TRANSPARENCY |
|
|
650 | #ifndef HAVE_AFTERIMAGE |
|
|
651 | /* taken from aterm-0.4.2 */ |
|
|
652 | |
|
|
653 | typedef uint32_t RUINT32T; |
|
|
654 | |
|
|
655 | static void |
|
|
656 | ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
657 | { |
|
|
658 | int sh_r, sh_g, sh_b; |
|
|
659 | RUINT32T mask_r, mask_g, mask_b; |
|
|
660 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
661 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
662 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
663 | int i; |
|
|
664 | |
|
|
665 | Visual *visual = term->visual; |
|
|
666 | |
|
|
667 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
668 | |
|
|
669 | /* for convenience */ |
|
|
670 | mask_r = visual->red_mask; |
|
|
671 | mask_g = visual->green_mask; |
|
|
672 | mask_b = visual->blue_mask; |
|
|
673 | |
|
|
674 | /* boring lookup table pre-initialization */ |
|
|
675 | switch (srcImage->bits_per_pixel) { |
|
|
676 | case 15: |
|
|
677 | if ((mask_r != 0x7c00) || |
|
|
678 | (mask_g != 0x03e0) || |
|
|
679 | (mask_b != 0x001f)) |
|
|
680 | return; |
|
|
681 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
682 | lookup_r = lookup; |
|
|
683 | lookup_g = lookup+32; |
|
|
684 | lookup_b = lookup+32+32; |
|
|
685 | sh_r = 10; |
|
|
686 | sh_g = 5; |
|
|
687 | sh_b = 0; |
|
|
688 | break; |
|
|
689 | case 16: |
|
|
690 | if ((mask_r != 0xf800) || |
|
|
691 | (mask_g != 0x07e0) || |
|
|
692 | (mask_b != 0x001f)) |
|
|
693 | return; |
|
|
694 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
695 | lookup_r = lookup; |
|
|
696 | lookup_g = lookup+32; |
|
|
697 | lookup_b = lookup+32+64; |
|
|
698 | sh_r = 11; |
|
|
699 | sh_g = 5; |
|
|
700 | sh_b = 0; |
|
|
701 | break; |
|
|
702 | case 24: |
|
|
703 | if ((mask_r != 0xff0000) || |
|
|
704 | (mask_g != 0x00ff00) || |
|
|
705 | (mask_b != 0x0000ff)) |
|
|
706 | return; |
|
|
707 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
708 | lookup_r = lookup; |
|
|
709 | lookup_g = lookup+256; |
|
|
710 | lookup_b = lookup+256+256; |
|
|
711 | sh_r = 16; |
|
|
712 | sh_g = 8; |
|
|
713 | sh_b = 0; |
|
|
714 | break; |
|
|
715 | case 32: |
|
|
716 | if ((mask_r != 0xff0000) || |
|
|
717 | (mask_g != 0x00ff00) || |
|
|
718 | (mask_b != 0x0000ff)) |
|
|
719 | return; |
|
|
720 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
721 | lookup_r = lookup; |
|
|
722 | lookup_g = lookup+256; |
|
|
723 | lookup_b = lookup+256+256; |
|
|
724 | sh_r = 16; |
|
|
725 | sh_g = 8; |
|
|
726 | sh_b = 0; |
|
|
727 | break; |
|
|
728 | default: |
|
|
729 | return; /* we do not support this color depth */ |
|
|
730 | } |
|
|
731 | |
|
|
732 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
733 | if (shade < 0) { |
|
|
734 | shade = -shade; |
|
|
735 | if (shade < 0) shade = 0; |
|
|
736 | if (shade > 100) shade = 100; |
|
|
737 | |
|
|
738 | lower_lim_r = 65535-rm; |
|
|
739 | lower_lim_g = 65535-gm; |
|
|
740 | lower_lim_b = 65535-bm; |
|
|
741 | |
|
|
742 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
743 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
744 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
745 | |
|
|
746 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
747 | } else { |
|
|
748 | if (shade < 0) shade = 0; |
|
|
749 | if (shade > 100) shade = 100; |
|
|
750 | |
|
|
751 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
752 | |
|
|
753 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
754 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
755 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
756 | } |
|
|
757 | |
|
|
758 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
759 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
760 | { |
|
|
761 | unsigned int tmp; |
|
|
762 | |
|
|
763 | tmp = lower_lim_r; |
|
|
764 | lower_lim_r = lower_lim_b; |
|
|
765 | lower_lim_b = tmp; |
|
|
766 | |
|
|
767 | tmp = upper_lim_r; |
|
|
768 | upper_lim_r = upper_lim_b; |
|
|
769 | upper_lim_b = tmp; |
|
|
770 | } |
|
|
771 | |
|
|
772 | /* fill our lookup tables */ |
|
|
773 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
774 | { |
|
|
775 | RUINT32T tmp; |
|
|
776 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
777 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
778 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
779 | } |
|
|
780 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
781 | { |
|
|
782 | RUINT32T tmp; |
|
|
783 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
784 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
785 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
786 | } |
|
|
787 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
788 | { |
|
|
789 | RUINT32T tmp; |
|
|
790 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
791 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
792 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
793 | } |
|
|
794 | |
|
|
795 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
796 | switch (srcImage->bits_per_pixel) |
|
|
797 | { |
|
|
798 | case 15: |
|
|
799 | { |
|
|
800 | unsigned short *p1, *pf, *p, *pl; |
|
|
801 | p1 = (unsigned short *) srcImage->data; |
|
|
802 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
803 | while (p1 < pf) |
372 | /* |
804 | { |
373 | * we already have the required attributes |
805 | p = p1; |
|
|
806 | pl = p1 + srcImage->width; |
|
|
807 | for (; p < pl; p++) |
|
|
808 | { |
|
|
809 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
810 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
811 | lookup_b[(*p & 0x001f)]; |
|
|
812 | } |
|
|
813 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
814 | } |
|
|
815 | break; |
|
|
816 | } |
|
|
817 | case 16: |
|
|
818 | { |
|
|
819 | unsigned short *p1, *pf, *p, *pl; |
|
|
820 | p1 = (unsigned short *) srcImage->data; |
|
|
821 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
822 | while (p1 < pf) |
|
|
823 | { |
|
|
824 | p = p1; |
|
|
825 | pl = p1 + srcImage->width; |
|
|
826 | for (; p < pl; p++) |
|
|
827 | { |
|
|
828 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
829 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
830 | lookup_b[(*p & 0x001f)]; |
|
|
831 | } |
|
|
832 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
833 | } |
|
|
834 | break; |
|
|
835 | } |
|
|
836 | case 24: |
|
|
837 | { |
|
|
838 | unsigned char *p1, *pf, *p, *pl; |
|
|
839 | p1 = (unsigned char *) srcImage->data; |
|
|
840 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
841 | while (p1 < pf) |
|
|
842 | { |
|
|
843 | p = p1; |
|
|
844 | pl = p1 + srcImage->width * 3; |
|
|
845 | for (; p < pl; p += 3) |
|
|
846 | { |
|
|
847 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
848 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
849 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
850 | } |
|
|
851 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
852 | } |
|
|
853 | break; |
|
|
854 | } |
|
|
855 | case 32: |
|
|
856 | { |
|
|
857 | RUINT32T *p1, *pf, *p, *pl; |
|
|
858 | p1 = (RUINT32T *) srcImage->data; |
|
|
859 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
860 | |
|
|
861 | while (p1 < pf) |
|
|
862 | { |
|
|
863 | p = p1; |
|
|
864 | pl = p1 + srcImage->width; |
|
|
865 | for (; p < pl; p++) |
|
|
866 | { |
|
|
867 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
868 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
869 | lookup_b[(*p & 0x0000ff)] | |
|
|
870 | (*p & ~0xffffff); |
|
|
871 | } |
|
|
872 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
873 | } |
|
|
874 | break; |
|
|
875 | } |
|
|
876 | } |
|
|
877 | |
|
|
878 | free (lookup); |
|
|
879 | } |
|
|
880 | #endif |
|
|
881 | |
|
|
882 | /* |
|
|
883 | * Check our parents are still who we think they are. |
|
|
884 | * Do transparency updates if required |
|
|
885 | */ |
|
|
886 | int |
|
|
887 | rxvt_term::check_our_parents () |
|
|
888 | { |
|
|
889 | check_our_parents_ev.stop (); |
|
|
890 | check_our_parents_ev.start (NOW + .1); |
|
|
891 | return 0; |
|
|
892 | } |
|
|
893 | |
|
|
894 | void |
|
|
895 | rxvt_term::check_our_parents_cb (time_watcher &w) |
|
|
896 | { |
|
|
897 | int i, pchanged, aformat, rootdepth; |
|
|
898 | unsigned long nitems, bytes_after; |
|
|
899 | Atom atype; |
|
|
900 | unsigned char *prop = NULL; |
|
|
901 | Window root, oldp, *list; |
|
|
902 | Pixmap rootpixmap = None; |
|
|
903 | XWindowAttributes wattr, wrootattr; |
|
|
904 | int sx, sy; |
|
|
905 | Window cr; |
|
|
906 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
|
|
907 | |
|
|
908 | pchanged = 0; |
|
|
909 | |
|
|
910 | if (!option (Opt_transparent)) |
|
|
911 | return /*pchanged*/; /* Don't try any more */ |
|
|
912 | |
|
|
913 | #if 0 |
|
|
914 | struct timeval stv; |
|
|
915 | gettimeofday (&stv,NULL); |
|
|
916 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
|
|
917 | fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\ |
|
|
918 | tv.tv_sec*1000000+tv.tv_usec-stv.tv_usec );}while(0) |
|
|
919 | #else |
|
|
920 | #define PRINT_BACKGROUND_OP_TIME do{}while(0) |
|
|
921 | #endif |
|
|
922 | |
|
|
923 | |
|
|
924 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
|
|
925 | rootdepth = wrootattr.depth; |
|
|
926 | |
|
|
927 | XGetWindowAttributes (dpy, parent[0], &wattr); |
|
|
928 | |
|
|
929 | if (rootdepth != wattr.depth) |
|
|
930 | { |
|
|
931 | if (am_transparent) |
|
|
932 | { |
|
|
933 | pchanged = 1; |
|
|
934 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
|
|
935 | am_transparent = am_pixmap_trans = 0; |
|
|
936 | } |
|
|
937 | |
|
|
938 | return /*pchanged*/; /* Don't try any more */ |
|
|
939 | } |
|
|
940 | |
|
|
941 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
942 | XSync (dpy, False); |
|
|
943 | |
|
|
944 | XTranslateCoordinates (dpy, parent[0], display->root, |
|
|
945 | 0, 0, &sx, &sy, &cr); |
|
|
946 | /* check if we are outside of the visible part of the virtual screen : */ |
|
|
947 | if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0 |
|
|
948 | || sx >= wrootattr.width || sy >= wrootattr.height ) |
|
|
949 | return /* 0 */ ; |
|
|
950 | /* |
|
|
951 | * Make the frame window set by the window manager have |
|
|
952 | * the root background. Some window managers put multiple nested frame |
|
|
953 | * windows for each client, so we have to take care about that. |
|
|
954 | */ |
|
|
955 | i = (xa[XA_XROOTPMAP_ID] |
|
|
956 | && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], |
|
|
957 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
958 | &nitems, &bytes_after, &prop) == Success); |
|
|
959 | |
|
|
960 | if (!i || prop == NULL) |
|
|
961 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
962 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
963 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
964 | &nitems, &bytes_after, &prop) == Success); |
|
|
965 | |
|
|
966 | if (!i || prop == NULL) |
|
|
967 | rootpixmap = None; |
|
|
968 | else |
|
|
969 | { |
|
|
970 | int junk; |
|
|
971 | unsigned int ujunk; |
|
|
972 | /* root pixmap may be bad - allow a error */ |
|
|
973 | allowedxerror = -1; |
|
|
974 | if ((rootpixmap = *(Pixmap *)prop) != None) |
|
|
975 | if (!XGetGeometry (dpy, rootpixmap, &root, &junk, &junk, &rootpixmap_w, &rootpixmap_h, &ujunk, &ujunk)) |
|
|
976 | rootpixmap = None; |
|
|
977 | allowedxerror = 0; |
|
|
978 | } |
|
|
979 | |
|
|
980 | if (prop != NULL) |
|
|
981 | XFree (prop); |
|
|
982 | |
|
|
983 | if (rootpixmap != None) |
|
|
984 | { |
|
|
985 | Bool success = False; |
|
|
986 | GC gc = NULL; |
|
|
987 | XGCValues gcvalue; |
|
|
988 | int shade = 100; |
|
|
989 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
990 | Bool whole_tint = False, no_tint = True; |
|
|
991 | |
|
|
992 | while (sx < 0) sx += (int)wrootattr.width; |
|
|
993 | while (sy < 0) sy += (int)wrootattr.height; |
|
|
994 | |
|
|
995 | if (rs[Rs_shade]) |
|
|
996 | shade = atoi (rs[Rs_shade]); |
|
|
997 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
998 | pix_colors_focused [Color_tint].get (c); |
|
|
999 | #define IS_COMPONENT_WHOLESOME(c) ((c) <=0x000700 || (c)>=0x00f700) |
|
|
1000 | if (shade >= 100) |
|
|
1001 | whole_tint = (IS_COMPONENT_WHOLESOME(c.r) |
|
|
1002 | && IS_COMPONENT_WHOLESOME(c.g) |
|
|
1003 | && IS_COMPONENT_WHOLESOME(c.b)); |
|
|
1004 | no_tint = (c.r >= 0x00f700 && c.g >= 0x00f700 && c.b >= 0x00f700); |
|
|
1005 | #undef IS_COMPONENT_WHOLESOME |
|
|
1006 | /* theer are no performance advantages to reusing same pixmap */ |
|
|
1007 | if (bgPixmap.pixmap != None) |
|
|
1008 | XFreePixmap (dpy, bgPixmap.pixmap); |
|
|
1009 | bgPixmap.pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, rootdepth); |
|
|
1010 | bgPixmap.pmap_width = szHint.width; |
|
|
1011 | bgPixmap.pmap_height = szHint.height; |
|
|
1012 | bgPixmap.pmap_depth = rootdepth; |
|
|
1013 | |
|
|
1014 | #if 0 /* TODO : identify cases where this will be detrimental to performance : */ |
|
|
1015 | /* we want to tile root pixmap into our own pixmap in this cases : |
|
|
1016 | * 1) rootpixmap does not cover our window entirely |
|
|
1017 | * 2) whole_tint - we can use server-side tinting or tinting disabled |
374 | */ |
1018 | */ |
375 | /* XGetWindowAttributes (display->display, vt, &attr); */ |
1019 | if ( whole_tint || no_tint || pmap_w < sx + szHint.width || pmap_h < sy + szHint.height) |
376 | |
|
|
377 | xpmAttr.closeness = 30000; |
|
|
378 | xpmAttr.colormap = display->cmap; |
|
|
379 | xpmAttr.visual = display->visual; |
|
|
380 | xpmAttr.depth = display->depth; |
|
|
381 | xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | |
|
|
382 | XpmDepth | XpmSize | XpmReturnPixels); |
|
|
383 | |
|
|
384 | /* search environment variables here too */ |
|
|
385 | f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]); |
|
|
386 | if (f == NULL |
|
|
387 | || XpmReadFileToPixmap (display->display, display->root, f, |
|
|
388 | &bgPixmap.pixmap, NULL, |
|
|
389 | &xpmAttr)) |
|
|
390 | { |
|
|
391 | char *p; |
|
|
392 | |
|
|
393 | /* semi-colon delimited */ |
|
|
394 | if ((p = strchr (file, ';')) == NULL) |
|
|
395 | p = strchr (file, '\0'); |
|
|
396 | |
|
|
397 | rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.\n", (p - file), file); |
|
|
398 | } |
1020 | { |
|
|
1021 | } |
|
|
1022 | #endif |
|
|
1023 | gcvalue.tile = rootpixmap; |
|
|
1024 | gcvalue.fill_style = FillTiled; |
|
|
1025 | gcvalue.ts_x_origin = -sx; |
|
|
1026 | gcvalue.ts_y_origin = -sy; |
|
|
1027 | gc = XCreateGC (dpy, rootpixmap, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcvalue); |
|
|
1028 | XFillRectangle (dpy, bgPixmap.pixmap, gc, 0, 0, szHint.width, szHint.height); |
399 | |
1029 | |
400 | free (f); |
1030 | if (whole_tint && !no_tint) |
|
|
1031 | { |
|
|
1032 | /* In this case we can tint image server-side getting significant |
|
|
1033 | * performance improvements, as we eliminate XImage transfer |
|
|
1034 | */ |
|
|
1035 | gcvalue.foreground = Pixel (pix_colors_focused [Color_tint]); |
|
|
1036 | gcvalue.function = GXand; |
|
|
1037 | gcvalue.fill_style = FillSolid; |
|
|
1038 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcvalue); |
|
|
1039 | XFillRectangle (dpy, bgPixmap.pixmap, gc, 0, 0, szHint.width, szHint.height); |
|
|
1040 | } |
|
|
1041 | success = True; |
|
|
1042 | #ifdef HAVE_AFTERIMAGE |
|
|
1043 | if (rs[Rs_blurradius] || bgPixmap.original_asim != NULL || (!whole_tint && (!no_tint || shade !=100))) |
|
|
1044 | { |
|
|
1045 | ARGB32 tint = TINT_LEAVE_SAME; |
|
|
1046 | ASImage *back_im = NULL; |
|
|
1047 | |
|
|
1048 | back_im = pixmap2ximage (asv, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, 100); |
|
|
1049 | if (back_im != NULL) |
|
|
1050 | { |
|
|
1051 | if (!whole_tint && (!no_tint || shade !=100)) |
|
|
1052 | { |
|
|
1053 | ShadingInfo as_shade; |
|
|
1054 | as_shade.shading = shade; |
|
|
1055 | as_shade.tintColor.red = c.r; |
|
|
1056 | as_shade.tintColor.green = c.g; |
|
|
1057 | as_shade.tintColor.blue = c.b; |
|
|
1058 | tint = shading2tint32 (&as_shade); |
|
|
1059 | } |
|
|
1060 | |
|
|
1061 | if (rs[Rs_blurradius] && back_im) |
|
|
1062 | { |
|
|
1063 | ASImage* tmp; |
|
|
1064 | int junk; |
|
|
1065 | unsigned int hr = 1, vr = 1; |
|
|
1066 | int flags = XParseGeometry (rs[Rs_blurradius], &junk, &junk, &hr, &vr); |
|
|
1067 | if (!(flags&WidthValue)) |
|
|
1068 | hr = 1; |
|
|
1069 | if (!(flags&HeightValue)) |
|
|
1070 | vr = hr; |
|
|
1071 | tmp = blur_asimage_gauss (asv, back_im, hr, vr, 0xFFFFFFFF, |
|
|
1072 | (bgPixmap.original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
1073 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1074 | if (tmp) |
|
|
1075 | { |
|
|
1076 | destroy_asimage (&back_im); |
|
|
1077 | back_im = tmp; |
|
|
1078 | } |
|
|
1079 | } |
|
|
1080 | |
|
|
1081 | if (bgPixmap.original_asim != NULL) |
|
|
1082 | { |
|
|
1083 | ASImageLayer *layers = create_image_layers (2); |
|
|
1084 | ASImage *merged_im = NULL; |
|
|
1085 | int fore_w, fore_h; |
|
|
1086 | |
|
|
1087 | layers[0].im = back_im; |
|
|
1088 | layers[0].clip_width = szHint.width; |
|
|
1089 | layers[0].clip_height = szHint.height; |
|
|
1090 | layers[0].tint = tint; |
|
|
1091 | layers[1].im = bgPixmap.original_asim; |
|
|
1092 | |
|
|
1093 | fore_w = (bgPixmap.h_scale == 0) ? bgPixmap.original_asim->width : bgPixmap.h_scale*szHint.width/100; |
|
|
1094 | fore_h = (bgPixmap.v_scale == 0) ? bgPixmap.original_asim->height : bgPixmap.v_scale*szHint.height/100; |
|
|
1095 | |
|
|
1096 | if (fore_w != bgPixmap.original_asim->width |
|
|
1097 | || fore_h != bgPixmap.original_asim->height) |
|
|
1098 | { |
|
|
1099 | layers[1].im = scale_asimage (asv, |
|
|
1100 | bgPixmap.original_asim, |
|
|
1101 | fore_w, fore_h, |
|
|
1102 | ASA_ASImage, 100, |
|
|
1103 | ASIMAGE_QUALITY_DEFAULT); |
|
|
1104 | } |
|
|
1105 | layers[1].clip_width = szHint.width; |
|
|
1106 | layers[1].clip_height = szHint.height; |
|
|
1107 | |
|
|
1108 | if (rs[Rs_blendtype]) |
|
|
1109 | { |
|
|
1110 | layers[1].merge_scanlines = blend_scanlines_name2func (rs[Rs_blendtype]); |
|
|
1111 | if (layers[1].merge_scanlines == NULL) |
|
|
1112 | layers[1].merge_scanlines = alphablend_scanlines; |
|
|
1113 | } |
|
|
1114 | PRINT_BACKGROUND_OP_TIME; |
|
|
1115 | merged_im = merge_layers (asv, layers, 2, szHint.width, szHint.height, |
|
|
1116 | ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT); |
|
|
1117 | if (layers[1].im != bgPixmap.original_asim) |
|
|
1118 | destroy_asimage (&(layers[1].im)); |
|
|
1119 | free (layers); |
|
|
1120 | |
|
|
1121 | if (merged_im != NULL) |
|
|
1122 | { |
|
|
1123 | destroy_asimage (&back_im); |
|
|
1124 | back_im = merged_im; |
|
|
1125 | } |
|
|
1126 | PRINT_BACKGROUND_OP_TIME; |
|
|
1127 | } |
|
|
1128 | else if (tint != TINT_LEAVE_SAME) |
|
|
1129 | { |
|
|
1130 | ASImage* tmp = tile_asimage (asv, back_im, 0, 0, szHint.width, szHint.height, tint, ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1131 | if (tmp) |
|
|
1132 | { |
|
|
1133 | destroy_asimage (&back_im); |
|
|
1134 | back_im = tmp; |
|
|
1135 | } |
|
|
1136 | PRINT_BACKGROUND_OP_TIME; |
|
|
1137 | } |
|
|
1138 | asimage2drawable (asv, bgPixmap.pixmap, back_im, gc, 0, 0, 0, 0, szHint.width, szHint.height, True); |
|
|
1139 | destroy_asimage (&back_im); |
|
|
1140 | } /* back_im != NULL */ |
|
|
1141 | else |
|
|
1142 | success = False; |
|
|
1143 | } |
|
|
1144 | #else /* HAVE_AFTERIMAGE */ |
|
|
1145 | if (!whole_tint && (!no_tint || shade !=100)) |
|
|
1146 | { |
|
|
1147 | XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
|
|
1148 | success = False; |
|
|
1149 | if (image != NULL) |
|
|
1150 | { |
|
|
1151 | PRINT_BACKGROUND_OP_TIME; |
|
|
1152 | if (gc == NULL) |
|
|
1153 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
|
|
1154 | if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
|
|
1155 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
|
|
1156 | XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
|
|
1157 | XDestroyImage (image); |
|
|
1158 | success = True; |
|
|
1159 | } |
|
|
1160 | } |
|
|
1161 | #endif /* HAVE_AFTERIMAGE */ |
|
|
1162 | PRINT_BACKGROUND_OP_TIME; |
|
|
1163 | |
|
|
1164 | if (gc != NULL) |
|
|
1165 | XFreeGC (dpy, gc); |
|
|
1166 | |
|
|
1167 | if (!success) |
|
|
1168 | { |
|
|
1169 | if (am_transparent && am_pixmap_trans) |
|
|
1170 | { |
|
|
1171 | pchanged = 1; |
|
|
1172 | if (bgPixmap.pixmap != None) |
|
|
1173 | { |
|
|
1174 | XFreePixmap (dpy, bgPixmap.pixmap); |
|
|
1175 | bgPixmap.pixmap = None; |
|
|
1176 | } |
|
|
1177 | } |
|
|
1178 | |
|
|
1179 | am_pixmap_trans = 0; |
|
|
1180 | } |
|
|
1181 | else |
|
|
1182 | { |
|
|
1183 | XSetWindowBackgroundPixmap (dpy, parent[0], bgPixmap.pixmap); |
|
|
1184 | XClearWindow (dpy, parent[0]); |
|
|
1185 | |
|
|
1186 | if (!am_transparent || !am_pixmap_trans) |
|
|
1187 | pchanged = 1; |
|
|
1188 | |
|
|
1189 | am_transparent = am_pixmap_trans = 1; |
|
|
1190 | } |
|
|
1191 | } /* rootpixmap != None */ |
|
|
1192 | |
|
|
1193 | if (am_pixmap_trans) |
|
|
1194 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
|
|
1195 | else |
|
|
1196 | return; |
|
|
1197 | |
|
|
1198 | if (scrollBar.win) |
401 | } |
1199 | { |
|
|
1200 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
|
|
1201 | scrollBar.setIdle (); |
|
|
1202 | scrollbar_show (0); |
|
|
1203 | } |
402 | |
1204 | |
403 | resize_pixmap (); |
1205 | if (am_transparent) |
404 | return bgPixmap.pixmap; |
1206 | { |
|
|
1207 | want_refresh = want_full_refresh = 1; |
|
|
1208 | if (am_pixmap_trans) |
|
|
1209 | flush (); |
|
|
1210 | } |
|
|
1211 | |
|
|
1212 | // return pchanged; |
405 | } |
1213 | } |
406 | |
1214 | #endif |
407 | #endif /* XPM_BACKGROUND */ |
|
|