ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/xpm.C
(Generate patch)

Comparing rxvt-unicode/src/xpm.C (file contents):
Revision 1.20 by root, Wed Jan 26 07:08:15 2005 UTC vs.
Revision 1.25 by root, Wed Dec 21 14:19:19 2005 UTC

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
30static 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 }
161{ 162{
162 XGCValues gcvalue; 163 XGCValues gcvalue;
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 ();
167 dDisp;
166 168
167 if (TermWin.pixmap != None) 169 if (pixmap != None)
168 XFreePixmap (display->display, TermWin.pixmap); 170 XFreePixmap (disp, pixmap);
169 171
170 if (bgPixmap.pixmap == None) 172 if (bgPixmap.pixmap == None)
171 { /* So be it: I'm not using pixmaps */ 173 { /* So be it: I'm not using pixmaps */
172 TermWin.pixmap = None; 174 pixmap = None;
173 175
174 if (!(options & Opt_transparent) || !am_transparent) 176 if (!(options & Opt_transparent) || !am_transparent)
175 XSetWindowBackground (display->display, TermWin.vt, 177 XSetWindowBackground (disp, vt,
176 pix_colors[Color_bg]); 178 pix_colors[Color_bg]);
177 179
178 return; 180 return;
179 } 181 }
180 182
181 gcvalue.foreground = pix_colors[Color_bg]; 183 gcvalue.foreground = pix_colors[Color_bg];
182 gc = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 184 gc = XCreateGC (disp, vt, GCForeground, &gcvalue);
183 185
184 if (bgPixmap.pixmap != None) 186 if (bgPixmap.pixmap != None)
185 { /* we have a specified pixmap */ 187 { /* we have a specified pixmap */
186 unsigned int w = bgPixmap.w, h = bgPixmap.h, 188 unsigned int w = bgPixmap.w, h = bgPixmap.h,
187 x = bgPixmap.x, y = bgPixmap.y; 189 x = bgPixmap.x, y = bgPixmap.y;
198 w = 0; /* tile */ 200 w = 0; /* tile */
199 201
200 if (w == 0) 202 if (w == 0)
201 { 203 {
202 /* basic X tiling - let the X server do it */ 204 /* basic X tiling - let the X server do it */
203 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 205 pixmap = XCreatePixmap (disp, vt,
204 xpmw, xpmh, 206 xpmw, xpmh,
205 (unsigned int)display->depth); 207 (unsigned int)display->depth);
206 XCopyArea (display->display, bgPixmap.pixmap, TermWin.pixmap, gc, 208 XCopyArea (disp, bgPixmap.pixmap, pixmap, gc,
207 0, 0, xpmw, xpmh, 0, 0); 209 0, 0, xpmw, xpmh, 0, 0);
208 } 210 }
209 else 211 else
210 { 212 {
211 float incr, p; 213 float incr, p;
212 Pixmap tmp; 214 Pixmap tmp;
213 215
214 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 216 pixmap = XCreatePixmap (disp, vt,
215 width, height, 217 width, height,
216 (unsigned int)display->depth); 218 (unsigned int)display->depth);
217 /* 219 /*
218 * horizontal scaling 220 * horizontal scaling
219 */ 221 */
220 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); 222 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw);
221 223
222 tmp = XCreatePixmap (display->display, TermWin.vt, 224 tmp = XCreatePixmap (disp, vt,
223 width, xpmh, (unsigned int)display->depth); 225 width, xpmh, (unsigned int)display->depth);
224 XFillRectangle (display->display, tmp, gc, 0, 0, width, 226 XFillRectangle (disp, tmp, gc, 0, 0, width,
225 xpmh); 227 xpmh);
226 228
227 for ( /*nil */ ; x < w; x++, p += incr) 229 for ( /*nil */ ; x < w; x++, p += incr)
228 { 230 {
229 if (p >= xpmw) 231 if (p >= xpmw)
230 p = 0; 232 p = 0;
231 /* copy one column from the original pixmap to the tmp pixmap */ 233 /* copy one column from the original pixmap to the tmp pixmap */
232 XCopyArea (display->display, bgPixmap.pixmap, tmp, gc, 234 XCopyArea (disp, bgPixmap.pixmap, tmp, gc,
233 (int)p, 0, 1, xpmh, (int)x, 0); 235 (int)p, 0, 1, xpmh, (int)x, 0);
234 } 236 }
235 237
236 /* 238 /*
237 * vertical scaling 239 * vertical scaling
238 */ 240 */
239 rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); 241 rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh);
240 242
241 if (y > 0) 243 if (y > 0)
242 XFillRectangle (display->display, TermWin.pixmap, gc, 0, 0, width, y); 244 XFillRectangle (disp, pixmap, gc, 0, 0, width, y);
243 245
244 if (h < height) 246 if (h < height)
245 XFillRectangle (display->display, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1); 247 XFillRectangle (disp, pixmap, gc, 0, (int)h, width, height - h + 1);
246 248
247 for ( /*nil */ ; y < h; y++, p += incr) 249 for ( /*nil */ ; y < h; y++, p += incr)
248 { 250 {
249 if (p >= xpmh) 251 if (p >= xpmh)
250 p = 0; 252 p = 0;
251 253
252 /* copy one row from the tmp pixmap to the main pixmap */ 254 /* copy one row from the tmp pixmap to the main pixmap */
253 XCopyArea (display->display, tmp, TermWin.pixmap, gc, 255 XCopyArea (disp, tmp, pixmap, gc,
254 0, (int)p, width, 1, 0, (int)y); 256 0, (int)p, width, 1, 0, (int)y);
255 } 257 }
256 258
257 XFreePixmap (display->display, tmp); 259 XFreePixmap (disp, tmp);
258 } 260 }
259 } 261 }
260 262
261 XSetWindowBackgroundPixmap (display->display, TermWin.vt, TermWin.pixmap); 263 XSetWindowBackgroundPixmap (disp, vt, pixmap);
262 XFreeGC (display->display, gc); 264 XFreeGC (disp, gc);
263 am_transparent = 0; 265 am_transparent = 0;
264} 266}
265 267
266/* 268/*
267 * Calculate tiling sizes and increments 269 * Calculate tiling sizes and increments
268 * At start, p == 0, incr == xpmwidthheight 270 * At start, p == 0, incr == xpmwidthheight
269 */ 271 */
270/* INTPROTO */
271static void 272static void
272rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight) 273rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight)
273{ 274{
274 unsigned int cwh, cxy; 275 unsigned int cwh, cxy;
275 float cincr, cp; 276 float cincr, cp;
341} 342}
342 343
343Pixmap 344Pixmap
344rxvt_term::set_bgPixmap (const char *file) 345rxvt_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 }
355 356
356 XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); 357 XSetWindowBackground (display->display, vt, pix_colors[Color_bg]);
357 358
358 if (*file != '\0') 359 if (*file != '\0')
359 { 360 {
360 /* XWindowAttributes attr; */ 361 /* XWindowAttributes attr; */
361 362
362 /* 363 /*
363 * we already have the required attributes 364 * we already have the required attributes
364 */ 365 */
365 /* XGetWindowAttributes (display->display, TermWin.vt, &attr); */ 366 /* XGetWindowAttributes (display->display, vt, &attr); */
366 367
367 xpmAttr.closeness = 30000; 368 xpmAttr.closeness = 30000;
368 xpmAttr.colormap = display->cmap; 369 xpmAttr.colormap = display->cmap;
369 xpmAttr.visual = display->visual; 370 xpmAttr.visual = display->visual;
370 xpmAttr.depth = display->depth; 371 xpmAttr.depth = display->depth;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines