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.14 by root, Mon Aug 2 04:20:48 2004 UTC vs.
Revision 1.22 by root, Wed Feb 16 20:32:05 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
61#define MAXLEN_GEOM sizeof("[1000x1000+1000+1000]") 62#define MAXLEN_GEOM sizeof("[1000x1000+1000+1000]")
62 63
63 if (geom == NULL) 64 if (geom == NULL)
64 return 0; 65 return 0;
65 str = (char *)rxvt_malloc (MAXLEN_GEOM + 1); 66 str = (char *)rxvt_malloc (MAXLEN_GEOM + 1);
66 if (!STRCMP (geom, "?")) 67 if (!strcmp (geom, "?"))
67 { 68 {
68 sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ 69 sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */
69 min (bgpixmap->w, 9999), min (bgpixmap->h, 9999), 70 min (bgpixmap->w, 9999), min (bgpixmap->h, 9999),
70 min (bgpixmap->x, 9999), min (bgpixmap->y, 9999)); 71 min (bgpixmap->x, 9999), min (bgpixmap->y, 9999));
71 process_xterm_seq (XTerm_title, str, CHAR_ST); 72 process_xterm_seq (XTerm_title, str, CHAR_ST);
72 free (str); 73 free (str);
73 return 0; 74 return 0;
74 } 75 }
75 76
76 if ((p = STRCHR (geom, ';')) == NULL) 77 if ((p = strchr (geom, ';')) == NULL)
77 p = STRCHR (geom, '\0'); 78 p = strchr (geom, '\0');
78 n = (p - geom); 79 n = (p - geom);
79 if (n <= MAXLEN_GEOM) 80 if (n <= MAXLEN_GEOM)
80 { 81 {
81 STRNCPY (str, geom, n); 82 strncpy (str, geom, n);
82 str[n] = '\0'; 83 str[n] = '\0';
83 84
84 flags = XParseGeometry (str, &x, &y, &w, &h); 85 flags = XParseGeometry (str, &x, &y, &w, &h);
85 if (!flags) 86 if (!flags)
86 { 87 {
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 (TermWin.pixmap != None)
168 XFreePixmap (display->display, TermWin.pixmap); 170 XFreePixmap (disp, TermWin.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 TermWin.pixmap = None;
175
173 if (! (Options & Opt_transparent) || am_transparent == 0) 176 if (!(options & Opt_transparent) || !am_transparent)
174 XSetWindowBackground (display->display, TermWin.vt, 177 XSetWindowBackground (disp, TermWin.vt,
175 PixColors[Color_bg]); 178 pix_colors[Color_bg]);
179
176 return; 180 return;
177 } 181 }
178 182
179 gcvalue.foreground = PixColors[Color_bg]; 183 gcvalue.foreground = pix_colors[Color_bg];
180 gc = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 184 gc = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue);
181 185
182 if (bgPixmap.pixmap != None) 186 if (bgPixmap.pixmap != None)
183 { /* we have a specified pixmap */ 187 { /* we have a specified pixmap */
184 unsigned int w = bgPixmap.w, h = bgPixmap.h, 188 unsigned int w = bgPixmap.w, h = bgPixmap.h,
185 x = bgPixmap.x, y = bgPixmap.y; 189 x = bgPixmap.x, y = bgPixmap.y;
186 unsigned int xpmh = xpmAttr.height, 190 unsigned int xpmh = xpmAttr.height,
187 xpmw = xpmAttr.width; 191 xpmw = xpmAttr.width;
188 192
189 /* 193 /*
190 * don't zoom pixmap too much nor expand really small pixmaps 194 * don't zoom pixmap too much nor expand really small pixmaps
191 */ 195 */
192 if (w > 1000 || h > 1000) 196 if (w > 1000 || h > 1000)
196 w = 0; /* tile */ 200 w = 0; /* tile */
197 201
198 if (w == 0) 202 if (w == 0)
199 { 203 {
200 /* basic X tiling - let the X server do it */ 204 /* basic X tiling - let the X server do it */
201 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 205 TermWin.pixmap = XCreatePixmap (disp, TermWin.vt,
202 xpmw, xpmh, 206 xpmw, xpmh,
203 (unsigned int)display->depth); 207 (unsigned int)display->depth);
204 XCopyArea (display->display, bgPixmap.pixmap, TermWin.pixmap, gc, 208 XCopyArea (disp, bgPixmap.pixmap, TermWin.pixmap, gc,
205 0, 0, xpmw, xpmh, 0, 0); 209 0, 0, xpmw, xpmh, 0, 0);
206 } 210 }
207 else 211 else
208 { 212 {
209 float incr, p; 213 float incr, p;
210 Pixmap tmp; 214 Pixmap tmp;
211 215
212 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 216 TermWin.pixmap = XCreatePixmap (disp, TermWin.vt,
213 width, height, 217 width, height,
214 (unsigned int)display->depth); 218 (unsigned int)display->depth);
215 /* 219 /*
216 * horizontal scaling 220 * horizontal scaling
217 */ 221 */
218 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); 222 rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw);
219 223
220 tmp = XCreatePixmap (display->display, TermWin.vt, 224 tmp = XCreatePixmap (disp, TermWin.vt,
221 width, xpmh, (unsigned int)display->depth); 225 width, xpmh, (unsigned int)display->depth);
222 XFillRectangle (display->display, tmp, gc, 0, 0, width, 226 XFillRectangle (disp, tmp, gc, 0, 0, width,
223 xpmh); 227 xpmh);
224 228
225 for ( /*nil */ ; x < w; x++, p += incr) 229 for ( /*nil */ ; x < w; x++, p += incr)
226 { 230 {
227 if (p >= xpmw) 231 if (p >= xpmw)
228 p = 0; 232 p = 0;
229 /* copy one column from the original pixmap to the tmp pixmap */ 233 /* copy one column from the original pixmap to the tmp pixmap */
230 XCopyArea (display->display, bgPixmap.pixmap, tmp, gc, 234 XCopyArea (disp, bgPixmap.pixmap, tmp, gc,
231 (int)p, 0, 1, xpmh, (int)x, 0); 235 (int)p, 0, 1, xpmh, (int)x, 0);
232 } 236 }
233 237
234 /* 238 /*
235 * vertical scaling 239 * vertical scaling
236 */ 240 */
237 rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); 241 rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh);
238 242
239 if (y > 0) 243 if (y > 0)
240 XFillRectangle (display->display, TermWin.pixmap, gc, 0, 0, width, 244 XFillRectangle (disp, TermWin.pixmap, gc, 0, 0, width, y);
241 y); 245
242 if (h < height) 246 if (h < height)
243 XFillRectangle (display->display, TermWin.pixmap, gc, 0, (int)h, 247 XFillRectangle (disp, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1);
244 width, height - h + 1); 248
245 for ( /*nil */ ; y < h; y++, p += incr) 249 for ( /*nil */ ; y < h; y++, p += incr)
246 { 250 {
247 if (p >= xpmh) 251 if (p >= xpmh)
248 p = 0; 252 p = 0;
253
249 /* copy one row from the tmp pixmap to the main pixmap */ 254 /* copy one row from the tmp pixmap to the main pixmap */
250 XCopyArea (display->display, tmp, TermWin.pixmap, gc, 255 XCopyArea (disp, tmp, TermWin.pixmap, gc,
251 0, (int)p, width, 1, 0, (int)y); 256 0, (int)p, width, 1, 0, (int)y);
252 } 257 }
258
253 XFreePixmap (display->display, tmp); 259 XFreePixmap (disp, tmp);
254 } 260 }
255 } 261 }
256 262
257 XSetWindowBackgroundPixmap (display->display, TermWin.vt, TermWin.pixmap); 263 XSetWindowBackgroundPixmap (disp, TermWin.vt, TermWin.pixmap);
258 XFreeGC (display->display, gc); 264 XFreeGC (disp, gc);
259 am_transparent = 0; 265 am_transparent = 0;
260
261 XClearWindow (display->display, TermWin.vt);
262
263 XSync (display->display, False);
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
341} 343}
342 344
343Pixmap 345Pixmap
344rxvt_term::set_bgPixmap (const char *file) 346rxvt_term::set_bgPixmap (const char *file)
345{ 347{
346 char *f; 348 char *f;
347 349
348 assert (file != NULL); 350 assert (file != NULL);
349 351
350 if (bgPixmap.pixmap != None) 352 if (bgPixmap.pixmap != None)
351 { 353 {
352 XFreePixmap (display->display, bgPixmap.pixmap); 354 XFreePixmap (display->display, bgPixmap.pixmap);
353 bgPixmap.pixmap = None; 355 bgPixmap.pixmap = None;
354 } 356 }
357
355 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); 358 XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]);
356 359
357 if (*file != '\0') 360 if (*file != '\0')
358 { 361 {
359 /* XWindowAttributes attr; */ 362 /* XWindowAttributes attr; */
360 363
378 &xpmAttr)) 381 &xpmAttr))
379 { 382 {
380 char *p; 383 char *p;
381 384
382 /* semi-colon delimited */ 385 /* semi-colon delimited */
383 if ((p = STRCHR (file, ';')) == NULL) 386 if ((p = strchr (file, ';')) == NULL)
384 p = STRCHR (file, '\0'); 387 p = strchr (file, '\0');
385 388
386 rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.", (p - file), file); 389 rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.\n", (p - file), file);
387 } 390 }
388 391
389 free (f); 392 free (f);
390 } 393 }
391 394

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines