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.29 by root, Wed Jan 25 21:03:04 2006 UTC vs.
Revision 1.37 by root, Tue May 1 21:30:01 2007 UTC

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.
55 int flags, changed = 0; 56 int flags, changed = 0;
56 int x = 0, y = 0; 57 int x = 0, y = 0;
57 unsigned int w = 0, h = 0; 58 unsigned int w = 0, h = 0;
58 unsigned int n; 59 unsigned int n;
59 char *p; 60 char *p;
60 bgPixmap_t *bgpixmap = & (bgPixmap); 61 bgPixmap_t *bgpixmap = &bgPixmap;
61 62
62#define MAXLEN_GEOM sizeof("[10000x10000+10000+10000]") 63#define MAXLEN_GEOM sizeof("[10000x10000+10000+10000]")
63 64
64 if (geom == NULL) 65 if (geom == NULL)
65 return 0; 66 return 0;
77 78
78 if ((p = strchr (geom, ';')) == NULL) 79 if ((p = strchr (geom, ';')) == NULL)
79 p = strchr (geom, '\0'); 80 p = strchr (geom, '\0');
80 81
81 n = (p - geom); 82 n = (p - geom);
82 if (n <= MAXLEN_GEOM) 83 if (n < MAXLEN_GEOM)
83 { 84 {
84 strncpy (str, geom, n); 85 strncpy (str, geom, n);
85 str[n] = '\0'; 86 str[n] = '\0';
86 87
87 flags = XParseGeometry (str, &x, &y, &w, &h); 88 flags = XParseGeometry (str, &x, &y, &w, &h);
168{ 169{
169 XGCValues gcvalue; 170 XGCValues gcvalue;
170 GC gc; 171 GC gc;
171 172
172 if (pixmap != None) 173 if (pixmap != None)
173 XFreePixmap (xdisp, pixmap); 174 XFreePixmap (dpy, pixmap);
174 175
175 if (bgPixmap.pixmap == None) 176 if (bgPixmap.pixmap == None)
176 { /* So be it: I'm not using pixmaps */ 177 { /* So be it: I'm not using pixmaps */
177 pixmap = None; 178 pixmap = None;
178 179
180#ifdef TRANSPARENT
179 if (!OPTION (Opt_transparent) || !am_transparent) 181 if (!option (Opt_transparent) || !am_transparent)
182#endif
180 XSetWindowBackground (xdisp, vt, pix_colors[Color_bg]); 183 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
181 184
182 return; 185 return;
183 } 186 }
184 187
185 gcvalue.foreground = pix_colors[Color_bg]; 188 gcvalue.foreground = pix_colors[Color_bg];
186 gc = XCreateGC (xdisp, vt, GCForeground, &gcvalue); 189 gc = XCreateGC (dpy, vt, GCForeground, &gcvalue);
187 190
188 if (bgPixmap.pixmap != None) 191 if (bgPixmap.pixmap != None)
189 { /* we have a specified pixmap */ 192 { /* we have a specified pixmap */
190 unsigned int w = bgPixmap.w, h = bgPixmap.h, 193 unsigned int w = bgPixmap.w, h = bgPixmap.h,
191 x = bgPixmap.x, y = bgPixmap.y; 194 x = bgPixmap.x, y = bgPixmap.y;
202 w = 0; /* tile */ 205 w = 0; /* tile */
203 206
204 if (!w) 207 if (!w)
205 { 208 {
206 /* basic X tiling - let the X server do it */ 209 /* basic X tiling - let the X server do it */
207 pixmap = XCreatePixmap (xdisp, vt, xpmw, xpmh, depth); 210 pixmap = XCreatePixmap (dpy, vt, xpmw, xpmh, depth);
208 211
209 XCopyArea (xdisp, bgPixmap.pixmap, pixmap, gc, x, y, xpmw - x, xpmh - y, 0, 0); 212 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, y, xpmw - x, xpmh - y, 0, 0);
210 XCopyArea (xdisp, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y); 213 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y);
211 XCopyArea (xdisp, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0); 214 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0);
212 XCopyArea (xdisp, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y); 215 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y);
213 } 216 }
214 else 217 else
215 { 218 {
216 float incr, p; 219 float incr, p;
217 Pixmap tmp; 220 Pixmap tmp;
218 221
219 pixmap = XCreatePixmap (xdisp, vt, width, height, depth); 222 pixmap = XCreatePixmap (dpy, vt, width, height, depth);
220 /* 223 /*
221 * horizontal scaling 224 * horizontal scaling
222 */ 225 */
223 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); 226 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw);
224 227
225 tmp = XCreatePixmap (xdisp, vt, width, xpmh, depth); 228 tmp = XCreatePixmap (dpy, vt, width, xpmh, depth);
226 XFillRectangle (xdisp, tmp, gc, 0, 0, width, xpmh); 229 XFillRectangle (dpy, tmp, gc, 0, 0, width, xpmh);
227 230
228 for ( /*nil */ ; x < w; x++, p += incr) 231 for ( /*nil */ ; x < w; x++, p += incr)
229 { 232 {
230 if (p >= xpmw) 233 if (p >= xpmw)
231 p = 0; 234 p = 0;
232 235
233 /* copy one column from the original pixmap to the tmp pixmap */ 236 /* copy one column from the original pixmap to the tmp pixmap */
234 XCopyArea (xdisp, bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0); 237 XCopyArea (dpy, bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0);
235 } 238 }
236 239
237 /* 240 /*
238 * vertical scaling 241 * vertical scaling
239 */ 242 */
240 rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); 243 rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh);
241 244
242 if (y > 0) 245 if (y > 0)
243 XFillRectangle (xdisp, pixmap, gc, 0, 0, width, y); 246 XFillRectangle (dpy, pixmap, gc, 0, 0, width, y);
244 247
245 if (h < height) 248 if (h < height)
246 XFillRectangle (xdisp, pixmap, gc, 0, (int)h, width, height - h + 1); 249 XFillRectangle (dpy, pixmap, gc, 0, (int)h, width, height - h + 1);
247 250
248 for ( /*nil */ ; y < h; y++, p += incr) 251 for ( /*nil */ ; y < h; y++, p += incr)
249 { 252 {
250 if (p >= xpmh) 253 if (p >= xpmh)
251 p = 0; 254 p = 0;
252 255
253 /* copy one row from the tmp pixmap to the main pixmap */ 256 /* copy one row from the tmp pixmap to the main pixmap */
254 XCopyArea (xdisp, tmp, pixmap, gc, 0, (int)p, width, 1, 0, (int)y); 257 XCopyArea (dpy, tmp, pixmap, gc, 0, (int)p, width, 1, 0, (int)y);
255 } 258 }
256 259
257 XFreePixmap (xdisp, tmp); 260 XFreePixmap (dpy, tmp);
258 } 261 }
259 } 262 }
260 263
261 XSetWindowBackgroundPixmap (xdisp, vt, pixmap); 264 XSetWindowBackgroundPixmap (dpy, vt, pixmap);
262 265
263 if (pixmap != None)
264 {
265 XFreePixmap (xdisp, pixmap);
266 pixmap = None;
267 }
268
269 XFreeGC (xdisp, gc); 266 XFreeGC (dpy, gc);
267#ifdef TRANSPARENT
270 am_transparent = 0; 268 am_transparent = 0;
269#endif
271} 270}
272 271
273/* 272/*
274 * Calculate tiling sizes and increments 273 * Calculate tiling sizes and increments
275 * At start, p == 0, incr == xpmwidthheight 274 * At start, p == 0, incr == xpmwidthheight
353 352
354 assert (file != NULL); 353 assert (file != NULL);
355 354
356 if (bgPixmap.pixmap != None) 355 if (bgPixmap.pixmap != None)
357 { 356 {
358 XFreePixmap (display->display, bgPixmap.pixmap); 357 XFreePixmap (dpy, bgPixmap.pixmap);
359 bgPixmap.pixmap = None; 358 bgPixmap.pixmap = None;
360 } 359 }
361 360
362 XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); 361 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
363 362
364 if (*file != '\0') 363 if (*file != '\0')
365 { 364 {
366 /* XWindowAttributes attr; */ 365 /* XWindowAttributes attr; */
367 366
368 /* 367 /*
369 * we already have the required attributes 368 * we already have the required attributes
370 */ 369 */
371 /* XGetWindowAttributes (display->display, vt, &attr); */ 370 /* XGetWindowAttributes (dpy, vt, &attr); */
372 371
373 xpmAttr.closeness = 30000; 372 xpmAttr.closeness = 30000;
374 xpmAttr.colormap = cmap; 373 xpmAttr.colormap = cmap;
375 xpmAttr.visual = visual; 374 xpmAttr.visual = visual;
376 xpmAttr.depth = depth; 375 xpmAttr.depth = depth;
378 | XpmDepth | XpmSize | XpmReturnPixels); 377 | XpmDepth | XpmSize | XpmReturnPixels);
379 378
380 /* search environment variables here too */ 379 /* search environment variables here too */
381 f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]); 380 f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]);
382 if (f == NULL 381 if (f == NULL
383 || XpmReadFileToPixmap (display->display, display->root, f, 382 || XpmReadFileToPixmap (dpy, display->root, f,
384 &bgPixmap.pixmap, NULL, 383 &bgPixmap.pixmap, NULL,
385 &xpmAttr)) 384 &xpmAttr))
386 { 385 {
387 char *p; 386 char *p;
388 387

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines