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.28 by root, Wed Jan 18 17:49:47 2006 UTC vs.
Revision 1.35 by root, Fri Aug 18 23:03:31 2006 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);
166void 167void
167rxvt_term::resize_pixmap () 168rxvt_term::resize_pixmap ()
168{ 169{
169 XGCValues gcvalue; 170 XGCValues gcvalue;
170 GC gc; 171 GC gc;
171 dDisp;
172 172
173 if (pixmap != None) 173 if (pixmap != None)
174 XFreePixmap (disp, pixmap); 174 XFreePixmap (dpy, pixmap);
175 175
176 if (bgPixmap.pixmap == None) 176 if (bgPixmap.pixmap == None)
177 { /* So be it: I'm not using pixmaps */ 177 { /* So be it: I'm not using pixmaps */
178 pixmap = None; 178 pixmap = None;
179 179
180 if (!OPTION (Opt_transparent) || !am_transparent) 180 if (!OPTION (Opt_transparent) || !am_transparent)
181 XSetWindowBackground (disp, vt, pix_colors[Color_bg]); 181 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
182 182
183 return; 183 return;
184 } 184 }
185 185
186 gcvalue.foreground = pix_colors[Color_bg]; 186 gcvalue.foreground = pix_colors[Color_bg];
187 gc = XCreateGC (disp, vt, GCForeground, &gcvalue); 187 gc = XCreateGC (dpy, vt, GCForeground, &gcvalue);
188 188
189 if (bgPixmap.pixmap != None) 189 if (bgPixmap.pixmap != None)
190 { /* we have a specified pixmap */ 190 { /* we have a specified pixmap */
191 unsigned int w = bgPixmap.w, h = bgPixmap.h, 191 unsigned int w = bgPixmap.w, h = bgPixmap.h,
192 x = bgPixmap.x, y = bgPixmap.y; 192 x = bgPixmap.x, y = bgPixmap.y;
203 w = 0; /* tile */ 203 w = 0; /* tile */
204 204
205 if (!w) 205 if (!w)
206 { 206 {
207 /* basic X tiling - let the X server do it */ 207 /* basic X tiling - let the X server do it */
208 pixmap = XCreatePixmap (disp, vt, xpmw, xpmh, display->depth); 208 pixmap = XCreatePixmap (dpy, vt, xpmw, xpmh, depth);
209 209
210 XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, x, y, xpmw - x, xpmh - y, 0, 0); 210 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, y, xpmw - x, xpmh - y, 0, 0);
211 XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y); 211 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, x, 0, xpmw - x, y, 0, xpmh - y);
212 XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0); 212 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, y, x, xpmh - y, xpmw - x, 0);
213 XCopyArea (disp, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y); 213 XCopyArea (dpy, bgPixmap.pixmap, pixmap, gc, 0, 0, x, y, xpmw - x, xpmh - y);
214 } 214 }
215 else 215 else
216 { 216 {
217 float incr, p; 217 float incr, p;
218 Pixmap tmp; 218 Pixmap tmp;
219 219
220 pixmap = XCreatePixmap (disp, vt, width, height, 220 pixmap = XCreatePixmap (dpy, vt, width, height, depth);
221 (unsigned int)display->depth);
222 /* 221 /*
223 * horizontal scaling 222 * horizontal scaling
224 */ 223 */
225 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); 224 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw);
226 225
227 tmp = XCreatePixmap (disp, vt, width, xpmh, (unsigned int)display->depth); 226 tmp = XCreatePixmap (dpy, vt, width, xpmh, depth);
228 XFillRectangle (disp, tmp, gc, 0, 0, width, xpmh); 227 XFillRectangle (dpy, tmp, gc, 0, 0, width, xpmh);
229 228
230 for ( /*nil */ ; x < w; x++, p += incr) 229 for ( /*nil */ ; x < w; x++, p += incr)
231 { 230 {
232 if (p >= xpmw) 231 if (p >= xpmw)
233 p = 0; 232 p = 0;
234 233
235 /* copy one column from the original pixmap to the tmp pixmap */ 234 /* copy one column from the original pixmap to the tmp pixmap */
236 XCopyArea (disp, bgPixmap.pixmap, tmp, gc, 235 XCopyArea (dpy, bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0);
237 (int)p, 0, 1, xpmh, (int)x, 0);
238 } 236 }
239 237
240 /* 238 /*
241 * vertical scaling 239 * vertical scaling
242 */ 240 */
243 rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); 241 rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh);
244 242
245 if (y > 0) 243 if (y > 0)
246 XFillRectangle (disp, pixmap, gc, 0, 0, width, y); 244 XFillRectangle (dpy, pixmap, gc, 0, 0, width, y);
247 245
248 if (h < height) 246 if (h < height)
249 XFillRectangle (disp, pixmap, gc, 0, (int)h, width, height - h + 1); 247 XFillRectangle (dpy, pixmap, gc, 0, (int)h, width, height - h + 1);
250 248
251 for ( /*nil */ ; y < h; y++, p += incr) 249 for ( /*nil */ ; y < h; y++, p += incr)
252 { 250 {
253 if (p >= xpmh) 251 if (p >= xpmh)
254 p = 0; 252 p = 0;
255 253
256 /* copy one row from the tmp pixmap to the main pixmap */ 254 /* copy one row from the tmp pixmap to the main pixmap */
257 XCopyArea (disp, tmp, pixmap, gc, 255 XCopyArea (dpy, tmp, pixmap, gc, 0, (int)p, width, 1, 0, (int)y);
258 0, (int)p, width, 1, 0, (int)y);
259 } 256 }
260 257
261 XFreePixmap (disp, tmp); 258 XFreePixmap (dpy, tmp);
262 } 259 }
263 } 260 }
264 261
265 XSetWindowBackgroundPixmap (disp, vt, pixmap); 262 XSetWindowBackgroundPixmap (dpy, vt, pixmap);
266 263
267 if (pixmap != None)
268 {
269 XFreePixmap (disp, pixmap);
270 pixmap = None;
271 }
272
273 XFreeGC (disp, gc); 264 XFreeGC (dpy, gc);
274 am_transparent = 0; 265 am_transparent = 0;
275} 266}
276 267
277/* 268/*
278 * Calculate tiling sizes and increments 269 * Calculate tiling sizes and increments
357 348
358 assert (file != NULL); 349 assert (file != NULL);
359 350
360 if (bgPixmap.pixmap != None) 351 if (bgPixmap.pixmap != None)
361 { 352 {
362 XFreePixmap (display->display, bgPixmap.pixmap); 353 XFreePixmap (dpy, bgPixmap.pixmap);
363 bgPixmap.pixmap = None; 354 bgPixmap.pixmap = None;
364 } 355 }
365 356
366 XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); 357 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
367 358
368 if (*file != '\0') 359 if (*file != '\0')
369 { 360 {
370 /* XWindowAttributes attr; */ 361 /* XWindowAttributes attr; */
371 362
372 /* 363 /*
373 * we already have the required attributes 364 * we already have the required attributes
374 */ 365 */
375 /* XGetWindowAttributes (display->display, vt, &attr); */ 366 /* XGetWindowAttributes (dpy, vt, &attr); */
376 367
377 xpmAttr.closeness = 30000; 368 xpmAttr.closeness = 30000;
378 xpmAttr.colormap = display->cmap; 369 xpmAttr.colormap = cmap;
379 xpmAttr.visual = display->visual; 370 xpmAttr.visual = visual;
380 xpmAttr.depth = display->depth; 371 xpmAttr.depth = depth;
381 xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | 372 xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual
382 XpmDepth | XpmSize | XpmReturnPixels); 373 | XpmDepth | XpmSize | XpmReturnPixels);
383 374
384 /* search environment variables here too */ 375 /* search environment variables here too */
385 f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]); 376 f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]);
386 if (f == NULL 377 if (f == NULL
387 || XpmReadFileToPixmap (display->display, display->root, f, 378 || XpmReadFileToPixmap (dpy, display->root, f,
388 &bgPixmap.pixmap, NULL, 379 &bgPixmap.pixmap, NULL,
389 &xpmAttr)) 380 &xpmAttr))
390 { 381 {
391 char *p; 382 char *p;
392 383
393 /* semi-colon delimited */ 384 /* semi-colon delimited */
394 if ((p = strchr (file, ';')) == NULL) 385 if ((p = strchr (file, ';')) == NULL)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines