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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines