… | |
… | |
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | *---------------------------------------------------------------------*/ |
23 | *---------------------------------------------------------------------*/ |
24 | |
24 | |
25 | #include "../config.h" /* NECESSARY */ |
25 | #include "../config.h" /* NECESSARY */ |
26 | #include "rxvt.h" /* NECESSARY */ |
26 | #include "rxvt.h" /* NECESSARY */ |
27 | #include "xpm.intpro" /* PROTOS for internal routines */ |
|
|
28 | |
27 | |
29 | #ifdef XPM_BACKGROUND |
28 | #ifdef XPM_BACKGROUND |
|
|
29 | |
|
|
30 | static void rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight); |
30 | |
31 | |
31 | /* |
32 | /* |
32 | * These GEOM strings indicate absolute size/position: |
33 | * These GEOM strings indicate absolute size/position: |
33 | * @ `WxH+X+Y' |
34 | * @ `WxH+X+Y' |
34 | * @ `WxH+X' -> Y = X |
35 | * @ `WxH+X' -> Y = X |
… | |
… | |
135 | if (flags & XNegative) |
136 | if (flags & XNegative) |
136 | x += 100; |
137 | x += 100; |
137 | if (flags & YNegative) |
138 | if (flags & YNegative) |
138 | y += 100; |
139 | y += 100; |
139 | } |
140 | } |
140 | MIN_IT (x, 100); |
141 | min_it (x, 100); |
141 | MIN_IT (y, 100); |
142 | min_it (y, 100); |
142 | MAX_IT (x, 0); |
143 | max_it (x, 0); |
143 | MAX_IT (y, 0); |
144 | max_it (y, 0); |
144 | if (bgpixmap->x != x) |
145 | if (bgpixmap->x != x) |
145 | { |
146 | { |
146 | bgpixmap->x = x; |
147 | bgpixmap->x = x; |
147 | changed++; |
148 | changed++; |
148 | } |
149 | } |
… | |
… | |
163 | GC gc; |
164 | GC gc; |
164 | unsigned int width = TermWin_TotalWidth (); |
165 | unsigned int width = TermWin_TotalWidth (); |
165 | unsigned int height = TermWin_TotalHeight (); |
166 | unsigned int height = TermWin_TotalHeight (); |
166 | dDisp; |
167 | dDisp; |
167 | |
168 | |
168 | if (TermWin.pixmap != None) |
169 | if (pixmap != None) |
169 | XFreePixmap (disp, TermWin.pixmap); |
170 | XFreePixmap (disp, pixmap); |
170 | |
171 | |
171 | if (bgPixmap.pixmap == None) |
172 | if (bgPixmap.pixmap == None) |
172 | { /* So be it: I'm not using pixmaps */ |
173 | { /* So be it: I'm not using pixmaps */ |
173 | TermWin.pixmap = None; |
174 | pixmap = None; |
174 | |
175 | |
175 | if (!(options & Opt_transparent) || !am_transparent) |
176 | if (!OPTION (Opt_transparent) || !am_transparent) |
176 | XSetWindowBackground (disp, TermWin.vt, |
177 | XSetWindowBackground (disp, vt, |
177 | pix_colors[Color_bg]); |
178 | pix_colors[Color_bg]); |
178 | |
179 | |
179 | return; |
180 | return; |
180 | } |
181 | } |
181 | |
182 | |
182 | gcvalue.foreground = pix_colors[Color_bg]; |
183 | gcvalue.foreground = pix_colors[Color_bg]; |
183 | gc = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue); |
184 | gc = XCreateGC (disp, vt, GCForeground, &gcvalue); |
184 | |
185 | |
185 | if (bgPixmap.pixmap != None) |
186 | if (bgPixmap.pixmap != None) |
186 | { /* we have a specified pixmap */ |
187 | { /* we have a specified pixmap */ |
187 | unsigned int w = bgPixmap.w, h = bgPixmap.h, |
188 | unsigned int w = bgPixmap.w, h = bgPixmap.h, |
188 | x = bgPixmap.x, y = bgPixmap.y; |
189 | x = bgPixmap.x, y = bgPixmap.y; |
… | |
… | |
199 | w = 0; /* tile */ |
200 | w = 0; /* tile */ |
200 | |
201 | |
201 | if (w == 0) |
202 | if (w == 0) |
202 | { |
203 | { |
203 | /* basic X tiling - let the X server do it */ |
204 | /* basic X tiling - let the X server do it */ |
204 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
205 | pixmap = XCreatePixmap (disp, vt, |
205 | xpmw, xpmh, |
206 | xpmw, xpmh, |
206 | (unsigned int)display->depth); |
207 | (unsigned int)display->depth); |
207 | XCopyArea (disp, bgPixmap.pixmap, TermWin.pixmap, gc, |
208 | XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, |
208 | 0, 0, xpmw, xpmh, 0, 0); |
209 | 0, 0, xpmw, xpmh, 0, 0); |
209 | } |
210 | } |
210 | else |
211 | else |
211 | { |
212 | { |
212 | float incr, p; |
213 | float incr, p; |
213 | Pixmap tmp; |
214 | Pixmap tmp; |
214 | |
215 | |
215 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
216 | pixmap = XCreatePixmap (disp, vt, |
216 | width, height, |
217 | width, height, |
217 | (unsigned int)display->depth); |
218 | (unsigned int)display->depth); |
218 | /* |
219 | /* |
219 | * horizontal scaling |
220 | * horizontal scaling |
220 | */ |
221 | */ |
221 | rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); |
222 | rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); |
222 | |
223 | |
223 | tmp = XCreatePixmap (disp, TermWin.vt, |
224 | tmp = XCreatePixmap (disp, vt, |
224 | width, xpmh, (unsigned int)display->depth); |
225 | width, xpmh, (unsigned int)display->depth); |
225 | XFillRectangle (disp, tmp, gc, 0, 0, width, |
226 | XFillRectangle (disp, tmp, gc, 0, 0, width, |
226 | xpmh); |
227 | xpmh); |
227 | |
228 | |
228 | for ( /*nil */ ; x < w; x++, p += incr) |
229 | for ( /*nil */ ; x < w; x++, p += incr) |
… | |
… | |
238 | * vertical scaling |
239 | * vertical scaling |
239 | */ |
240 | */ |
240 | rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); |
241 | rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); |
241 | |
242 | |
242 | if (y > 0) |
243 | if (y > 0) |
243 | XFillRectangle (disp, TermWin.pixmap, gc, 0, 0, width, y); |
244 | XFillRectangle (disp, pixmap, gc, 0, 0, width, y); |
244 | |
245 | |
245 | if (h < height) |
246 | if (h < height) |
246 | XFillRectangle (disp, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1); |
247 | XFillRectangle (disp, pixmap, gc, 0, (int)h, width, height - h + 1); |
247 | |
248 | |
248 | for ( /*nil */ ; y < h; y++, p += incr) |
249 | for ( /*nil */ ; y < h; y++, p += incr) |
249 | { |
250 | { |
250 | if (p >= xpmh) |
251 | if (p >= xpmh) |
251 | p = 0; |
252 | p = 0; |
252 | |
253 | |
253 | /* copy one row from the tmp pixmap to the main pixmap */ |
254 | /* copy one row from the tmp pixmap to the main pixmap */ |
254 | XCopyArea (disp, tmp, TermWin.pixmap, gc, |
255 | XCopyArea (disp, tmp, pixmap, gc, |
255 | 0, (int)p, width, 1, 0, (int)y); |
256 | 0, (int)p, width, 1, 0, (int)y); |
256 | } |
257 | } |
257 | |
258 | |
258 | XFreePixmap (disp, tmp); |
259 | XFreePixmap (disp, tmp); |
259 | } |
260 | } |
260 | } |
261 | } |
261 | |
262 | |
262 | XSetWindowBackgroundPixmap (disp, TermWin.vt, TermWin.pixmap); |
263 | XSetWindowBackgroundPixmap (disp, vt, pixmap); |
263 | XFreeGC (disp, gc); |
264 | XFreeGC (disp, gc); |
264 | am_transparent = 0; |
265 | am_transparent = 0; |
265 | } |
266 | } |
266 | |
267 | |
267 | /* |
268 | /* |
268 | * Calculate tiling sizes and increments |
269 | * Calculate tiling sizes and increments |
269 | * At start, p == 0, incr == xpmwidthheight |
270 | * At start, p == 0, incr == xpmwidthheight |
270 | */ |
271 | */ |
271 | /* INTPROTO */ |
|
|
272 | static void |
272 | static void |
273 | rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight) |
273 | rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight) |
274 | { |
274 | { |
275 | unsigned int cwh, cxy; |
275 | unsigned int cwh, cxy; |
276 | float cincr, cp; |
276 | float cincr, cp; |
… | |
… | |
352 | { |
352 | { |
353 | XFreePixmap (display->display, bgPixmap.pixmap); |
353 | XFreePixmap (display->display, bgPixmap.pixmap); |
354 | bgPixmap.pixmap = None; |
354 | bgPixmap.pixmap = None; |
355 | } |
355 | } |
356 | |
356 | |
357 | XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); |
357 | XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); |
358 | |
358 | |
359 | if (*file != '\0') |
359 | if (*file != '\0') |
360 | { |
360 | { |
361 | /* XWindowAttributes attr; */ |
361 | /* XWindowAttributes attr; */ |
362 | |
362 | |
363 | /* |
363 | /* |
364 | * we already have the required attributes |
364 | * we already have the required attributes |
365 | */ |
365 | */ |
366 | /* XGetWindowAttributes (display->display, TermWin.vt, &attr); */ |
366 | /* XGetWindowAttributes (display->display, vt, &attr); */ |
367 | |
367 | |
368 | xpmAttr.closeness = 30000; |
368 | xpmAttr.closeness = 30000; |
369 | xpmAttr.colormap = display->cmap; |
369 | xpmAttr.colormap = display->cmap; |
370 | xpmAttr.visual = display->visual; |
370 | xpmAttr.visual = display->visual; |
371 | xpmAttr.depth = display->depth; |
371 | xpmAttr.depth = display->depth; |