… | |
… | |
161 | { |
161 | { |
162 | XGCValues gcvalue; |
162 | XGCValues gcvalue; |
163 | GC gc; |
163 | GC gc; |
164 | unsigned int width = TermWin_TotalWidth (); |
164 | unsigned int width = TermWin_TotalWidth (); |
165 | unsigned int height = TermWin_TotalHeight (); |
165 | unsigned int height = TermWin_TotalHeight (); |
|
|
166 | dDisp; |
166 | |
167 | |
167 | if (TermWin.pixmap != None) |
168 | if (TermWin.pixmap != None) |
168 | XFreePixmap (display->display, TermWin.pixmap); |
169 | XFreePixmap (disp, TermWin.pixmap); |
169 | |
170 | |
170 | if (bgPixmap.pixmap == None) |
171 | if (bgPixmap.pixmap == None) |
171 | { /* So be it: I'm not using pixmaps */ |
172 | { /* So be it: I'm not using pixmaps */ |
172 | TermWin.pixmap = None; |
173 | TermWin.pixmap = None; |
|
|
174 | |
173 | if (! (options & Opt_transparent) || am_transparent == 0) |
175 | if (!(options & Opt_transparent) || !am_transparent) |
174 | XSetWindowBackground (display->display, TermWin.vt, |
176 | XSetWindowBackground (disp, TermWin.vt, |
175 | pix_colors[Color_bg]); |
177 | pix_colors[Color_bg]); |
|
|
178 | |
176 | return; |
179 | return; |
177 | } |
180 | } |
178 | |
181 | |
179 | gcvalue.foreground = pix_colors[Color_bg]; |
182 | gcvalue.foreground = pix_colors[Color_bg]; |
180 | gc = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
183 | gc = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue); |
181 | |
184 | |
182 | if (bgPixmap.pixmap != None) |
185 | if (bgPixmap.pixmap != None) |
183 | { /* we have a specified pixmap */ |
186 | { /* we have a specified pixmap */ |
184 | unsigned int w = bgPixmap.w, h = bgPixmap.h, |
187 | unsigned int w = bgPixmap.w, h = bgPixmap.h, |
185 | x = bgPixmap.x, y = bgPixmap.y; |
188 | x = bgPixmap.x, y = bgPixmap.y; |
186 | unsigned int xpmh = xpmAttr.height, |
189 | unsigned int xpmh = xpmAttr.height, |
187 | xpmw = xpmAttr.width; |
190 | xpmw = xpmAttr.width; |
188 | |
191 | |
189 | /* |
192 | /* |
190 | * don't zoom pixmap too much nor expand really small pixmaps |
193 | * don't zoom pixmap too much nor expand really small pixmaps |
191 | */ |
194 | */ |
192 | if (w > 1000 || h > 1000) |
195 | if (w > 1000 || h > 1000) |
… | |
… | |
196 | w = 0; /* tile */ |
199 | w = 0; /* tile */ |
197 | |
200 | |
198 | if (w == 0) |
201 | if (w == 0) |
199 | { |
202 | { |
200 | /* basic X tiling - let the X server do it */ |
203 | /* basic X tiling - let the X server do it */ |
201 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
204 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
202 | xpmw, xpmh, |
205 | xpmw, xpmh, |
203 | (unsigned int)display->depth); |
206 | (unsigned int)display->depth); |
204 | XCopyArea (display->display, bgPixmap.pixmap, TermWin.pixmap, gc, |
207 | XCopyArea (disp, bgPixmap.pixmap, TermWin.pixmap, gc, |
205 | 0, 0, xpmw, xpmh, 0, 0); |
208 | 0, 0, xpmw, xpmh, 0, 0); |
206 | } |
209 | } |
207 | else |
210 | else |
208 | { |
211 | { |
209 | float incr, p; |
212 | float incr, p; |
210 | Pixmap tmp; |
213 | Pixmap tmp; |
211 | |
214 | |
212 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
215 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
213 | width, height, |
216 | width, height, |
214 | (unsigned int)display->depth); |
217 | (unsigned int)display->depth); |
215 | /* |
218 | /* |
216 | * horizontal scaling |
219 | * horizontal scaling |
217 | */ |
220 | */ |
218 | rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); |
221 | rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); |
219 | |
222 | |
220 | tmp = XCreatePixmap (display->display, TermWin.vt, |
223 | tmp = XCreatePixmap (disp, TermWin.vt, |
221 | width, xpmh, (unsigned int)display->depth); |
224 | width, xpmh, (unsigned int)display->depth); |
222 | XFillRectangle (display->display, tmp, gc, 0, 0, width, |
225 | XFillRectangle (disp, tmp, gc, 0, 0, width, |
223 | xpmh); |
226 | xpmh); |
224 | |
227 | |
225 | for ( /*nil */ ; x < w; x++, p += incr) |
228 | for ( /*nil */ ; x < w; x++, p += incr) |
226 | { |
229 | { |
227 | if (p >= xpmw) |
230 | if (p >= xpmw) |
228 | p = 0; |
231 | p = 0; |
229 | /* copy one column from the original pixmap to the tmp pixmap */ |
232 | /* copy one column from the original pixmap to the tmp pixmap */ |
230 | XCopyArea (display->display, bgPixmap.pixmap, tmp, gc, |
233 | XCopyArea (disp, bgPixmap.pixmap, tmp, gc, |
231 | (int)p, 0, 1, xpmh, (int)x, 0); |
234 | (int)p, 0, 1, xpmh, (int)x, 0); |
232 | } |
235 | } |
233 | |
236 | |
234 | /* |
237 | /* |
235 | * vertical scaling |
238 | * vertical scaling |
236 | */ |
239 | */ |
237 | rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); |
240 | rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); |
238 | |
241 | |
239 | if (y > 0) |
242 | if (y > 0) |
240 | XFillRectangle (display->display, TermWin.pixmap, gc, 0, 0, width, |
243 | XFillRectangle (disp, TermWin.pixmap, gc, 0, 0, width, y); |
241 | y); |
244 | |
242 | if (h < height) |
245 | if (h < height) |
243 | XFillRectangle (display->display, TermWin.pixmap, gc, 0, (int)h, |
246 | XFillRectangle (disp, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1); |
244 | width, height - h + 1); |
247 | |
245 | for ( /*nil */ ; y < h; y++, p += incr) |
248 | for ( /*nil */ ; y < h; y++, p += incr) |
246 | { |
249 | { |
247 | if (p >= xpmh) |
250 | if (p >= xpmh) |
248 | p = 0; |
251 | p = 0; |
|
|
252 | |
249 | /* copy one row from the tmp pixmap to the main pixmap */ |
253 | /* copy one row from the tmp pixmap to the main pixmap */ |
250 | XCopyArea (display->display, tmp, TermWin.pixmap, gc, |
254 | XCopyArea (disp, tmp, TermWin.pixmap, gc, |
251 | 0, (int)p, width, 1, 0, (int)y); |
255 | 0, (int)p, width, 1, 0, (int)y); |
252 | } |
256 | } |
|
|
257 | |
253 | XFreePixmap (display->display, tmp); |
258 | XFreePixmap (disp, tmp); |
254 | } |
259 | } |
255 | } |
260 | } |
256 | |
261 | |
257 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, TermWin.pixmap); |
262 | XSetWindowBackgroundPixmap (disp, TermWin.vt, TermWin.pixmap); |
258 | XFreeGC (display->display, gc); |
263 | XFreeGC (disp, gc); |
259 | am_transparent = 0; |
264 | am_transparent = 0; |
260 | |
|
|
261 | XClearWindow (display->display, TermWin.vt); |
|
|
262 | |
|
|
263 | XSync (display->display, False); |
|
|
264 | } |
265 | } |
265 | |
266 | |
266 | /* |
267 | /* |
267 | * Calculate tiling sizes and increments |
268 | * Calculate tiling sizes and increments |
268 | * At start, p == 0, incr == xpmwidthheight |
269 | * At start, p == 0, incr == xpmwidthheight |
… | |
… | |
341 | } |
342 | } |
342 | |
343 | |
343 | Pixmap |
344 | Pixmap |
344 | rxvt_term::set_bgPixmap (const char *file) |
345 | rxvt_term::set_bgPixmap (const char *file) |
345 | { |
346 | { |
346 | char *f; |
347 | char *f; |
347 | |
348 | |
348 | assert (file != NULL); |
349 | assert (file != NULL); |
349 | |
350 | |
350 | if (bgPixmap.pixmap != None) |
351 | if (bgPixmap.pixmap != None) |
351 | { |
352 | { |
352 | XFreePixmap (display->display, bgPixmap.pixmap); |
353 | XFreePixmap (display->display, bgPixmap.pixmap); |
353 | bgPixmap.pixmap = None; |
354 | bgPixmap.pixmap = None; |
354 | } |
355 | } |
|
|
356 | |
355 | XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); |
357 | XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); |
356 | |
358 | |
357 | if (*file != '\0') |
359 | if (*file != '\0') |
358 | { |
360 | { |
359 | /* XWindowAttributes attr; */ |
361 | /* XWindowAttributes attr; */ |
… | |
… | |
381 | |
383 | |
382 | /* semi-colon delimited */ |
384 | /* semi-colon delimited */ |
383 | if ((p = strchr (file, ';')) == NULL) |
385 | if ((p = strchr (file, ';')) == NULL) |
384 | p = strchr (file, '\0'); |
386 | p = strchr (file, '\0'); |
385 | |
387 | |
386 | rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.", (p - file), file); |
388 | rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.\n", (p - file), file); |
387 | } |
389 | } |
388 | |
390 | |
389 | free (f); |
391 | free (f); |
390 | } |
392 | } |
391 | |
393 | |