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.33 by root, Mon Feb 20 22:40:35 2006 UTC

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.
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
179 if (!OPTION (Opt_transparent) || !am_transparent) 180 if (!OPTION (Opt_transparent) || !am_transparent)
180 XSetWindowBackground (xdisp, vt, pix_colors[Color_bg]); 181 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
181 182
182 return; 183 return;
183 } 184 }
184 185
185 gcvalue.foreground = pix_colors[Color_bg]; 186 gcvalue.foreground = pix_colors[Color_bg];
186 gc = XCreateGC (xdisp, vt, GCForeground, &gcvalue); 187 gc = XCreateGC (dpy, vt, GCForeground, &gcvalue);
187 188
188 if (bgPixmap.pixmap != None) 189 if (bgPixmap.pixmap != None)
189 { /* we have a specified pixmap */ 190 { /* we have a specified pixmap */
190 unsigned int w = bgPixmap.w, h = bgPixmap.h, 191 unsigned int w = bgPixmap.w, h = bgPixmap.h,
191 x = bgPixmap.x, y = bgPixmap.y; 192 x = bgPixmap.x, y = bgPixmap.y;
202 w = 0; /* tile */ 203 w = 0; /* tile */
203 204
204 if (!w) 205 if (!w)
205 { 206 {
206 /* basic X tiling - let the X server do it */ 207 /* basic X tiling - let the X server do it */
207 pixmap = XCreatePixmap (xdisp, vt, xpmw, xpmh, depth); 208 pixmap = XCreatePixmap (dpy, vt, xpmw, xpmh, depth);
208 209
209 XCopyArea (xdisp, 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);
210 XCopyArea (xdisp, 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);
211 XCopyArea (xdisp, 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);
212 XCopyArea (xdisp, 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);
213 } 214 }
214 else 215 else
215 { 216 {
216 float incr, p; 217 float incr, p;
217 Pixmap tmp; 218 Pixmap tmp;
218 219
219 pixmap = XCreatePixmap (xdisp, vt, width, height, depth); 220 pixmap = XCreatePixmap (dpy, vt, width, height, depth);
220 /* 221 /*
221 * horizontal scaling 222 * horizontal scaling
222 */ 223 */
223 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); 224 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw);
224 225
225 tmp = XCreatePixmap (xdisp, vt, width, xpmh, depth); 226 tmp = XCreatePixmap (dpy, vt, width, xpmh, depth);
226 XFillRectangle (xdisp, tmp, gc, 0, 0, width, xpmh); 227 XFillRectangle (dpy, tmp, gc, 0, 0, width, xpmh);
227 228
228 for ( /*nil */ ; x < w; x++, p += incr) 229 for ( /*nil */ ; x < w; x++, p += incr)
229 { 230 {
230 if (p >= xpmw) 231 if (p >= xpmw)
231 p = 0; 232 p = 0;
232 233
233 /* copy one column from the original pixmap to the tmp pixmap */ 234 /* 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); 235 XCopyArea (dpy, bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0);
235 } 236 }
236 237
237 /* 238 /*
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 (xdisp, pixmap, gc, 0, 0, width, y); 244 XFillRectangle (dpy, pixmap, gc, 0, 0, width, y);
244 245
245 if (h < height) 246 if (h < height)
246 XFillRectangle (xdisp, pixmap, gc, 0, (int)h, width, height - h + 1); 247 XFillRectangle (dpy, 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 (xdisp, tmp, pixmap, gc, 0, (int)p, width, 1, 0, (int)y); 255 XCopyArea (dpy, tmp, pixmap, gc, 0, (int)p, width, 1, 0, (int)y);
255 } 256 }
256 257
257 XFreePixmap (xdisp, tmp); 258 XFreePixmap (dpy, tmp);
258 } 259 }
259 } 260 }
260 261
261 XSetWindowBackgroundPixmap (xdisp, vt, pixmap); 262 XSetWindowBackgroundPixmap (dpy, vt, pixmap);
262 263
263 if (pixmap != None)
264 {
265 XFreePixmap (xdisp, pixmap);
266 pixmap = None;
267 }
268
269 XFreeGC (xdisp, gc); 264 XFreeGC (dpy, gc);
270 am_transparent = 0; 265 am_transparent = 0;
271} 266}
272 267
273/* 268/*
274 * Calculate tiling sizes and increments 269 * Calculate tiling sizes and increments
353 348
354 assert (file != NULL); 349 assert (file != NULL);
355 350
356 if (bgPixmap.pixmap != None) 351 if (bgPixmap.pixmap != None)
357 { 352 {
358 XFreePixmap (display->display, bgPixmap.pixmap); 353 XFreePixmap (dpy, bgPixmap.pixmap);
359 bgPixmap.pixmap = None; 354 bgPixmap.pixmap = None;
360 } 355 }
361 356
362 XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); 357 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
363 358
364 if (*file != '\0') 359 if (*file != '\0')
365 { 360 {
366 /* XWindowAttributes attr; */ 361 /* XWindowAttributes attr; */
367 362
368 /* 363 /*
369 * we already have the required attributes 364 * we already have the required attributes
370 */ 365 */
371 /* XGetWindowAttributes (display->display, vt, &attr); */ 366 /* XGetWindowAttributes (dpy, vt, &attr); */
372 367
373 xpmAttr.closeness = 30000; 368 xpmAttr.closeness = 30000;
374 xpmAttr.colormap = cmap; 369 xpmAttr.colormap = cmap;
375 xpmAttr.visual = visual; 370 xpmAttr.visual = visual;
376 xpmAttr.depth = depth; 371 xpmAttr.depth = depth;
378 | XpmDepth | XpmSize | XpmReturnPixels); 373 | XpmDepth | XpmSize | XpmReturnPixels);
379 374
380 /* search environment variables here too */ 375 /* search environment variables here too */
381 f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]); 376 f = (char *)rxvt_File_find (file, ".xpm", rs[Rs_path]);
382 if (f == NULL 377 if (f == NULL
383 || XpmReadFileToPixmap (display->display, display->root, f, 378 || XpmReadFileToPixmap (dpy, display->root, f,
384 &bgPixmap.pixmap, NULL, 379 &bgPixmap.pixmap, NULL,
385 &xpmAttr)) 380 &xpmAttr))
386 { 381 {
387 char *p; 382 char *p;
388 383

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines