ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.C
(Generate patch)

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.240 by sf-exg, Mon Jun 11 13:23:01 2012 UTC vs.
Revision 1.248 by sf-exg, Sun Dec 30 11:34:43 2012 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: background.C - former xpm.C 2 * File: background.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) 2005-2008 Marc Lehmann <schmorp@schmorp.de> 6 * Copyright (c) 2005-2008 Marc Lehmann <schmorp@schmorp.de>
7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
28#ifdef HAVE_BG_PIXMAP 28#ifdef HAVE_BG_PIXMAP
29 29
30void 30void
31rxvt_term::bg_destroy () 31rxvt_term::bg_destroy ()
32{ 32{
33# if ENABLE_TRANSPARENCY 33# if BG_IMAGE_FROM_ROOT
34 delete root_img; 34 delete root_img;
35 root_img = 0; 35 root_img = 0;
36# endif 36# endif
37 37
38# if BG_IMAGE_FROM_FILE 38# if BG_IMAGE_FROM_FILE
39 fimage.destroy (); 39 fimage.destroy ();
40# endif 40# endif
41
42 delete bg_img;
43 bg_img = 0;
44} 41}
45 42
46bool 43bool
47rxvt_term::bg_window_size_sensitive () 44rxvt_term::bg_window_size_sensitive ()
48{ 45{
49# if ENABLE_TRANSPARENCY 46# if BG_IMAGE_FROM_ROOT
50 if (bg_flags & BG_IS_TRANSPARENT) 47 if (option (Opt_transparent))
51 return true; 48 return true;
52# endif 49# endif
53 50
54# if BG_IMAGE_FROM_FILE 51# if BG_IMAGE_FROM_FILE
55 if (fimage.img) 52 if (fimage.img)
65} 62}
66 63
67bool 64bool
68rxvt_term::bg_window_position_sensitive () 65rxvt_term::bg_window_position_sensitive ()
69{ 66{
70# if ENABLE_TRANSPARENCY 67# if BG_IMAGE_FROM_ROOT
71 if (bg_flags & BG_IS_TRANSPARENT) 68 if (option (Opt_transparent))
72 return true; 69 return true;
73# endif 70# endif
74 71
75# if BG_IMAGE_FROM_FILE 72# if BG_IMAGE_FROM_FILE
76 if (fimage.img) 73 if (fimage.img)
319 else 316 else
320 img->repeat_mode (RepeatNone); 317 img->repeat_mode (RepeatNone);
321 img->sub_rect (-x, -y, parent_width, parent_height)->replace (img); 318 img->sub_rect (-x, -y, parent_width, parent_height)->replace (img);
322 319
323 if (bg_flags & BG_IS_VALID) 320 if (bg_flags & BG_IS_VALID)
324 { 321 img->draw (bg_img, PictOpOver, image.alpha * 1. / 0xffff);
325 double factor = image.alpha * 1. / 0xffff;
326 bg_img->blend (img, factor)->replace (img);
327 }
328 322
329 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 323 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
330 img->convert_format (format, pix_colors [Color_bg])->replace (img); 324 img->convert_format (format, pix_colors [Color_bg])->replace (img);
331 325
332 delete bg_img; 326 delete bg_img;
345 v_align = defaultAlign; 339 v_align = defaultAlign;
346 340
347 img = 0; 341 img = 0;
348} 342}
349 343
350bool 344void
351rxvt_image::set_file_geometry (rxvt_screen *s, const char *file) 345rxvt_image::set_file_geometry (rxvt_screen *s, const char *file)
352{ 346{
353 if (!file || !*file) 347 if (!file || !*file)
354 return false; 348 return;
355 349
356 const char *p = strchr (file, ';'); 350 const char *p = strchr (file, ';');
357 351
358 if (p) 352 if (p)
359 { 353 {
362 memcpy (f, file, len); 356 memcpy (f, file, len);
363 f[len] = '\0'; 357 f[len] = '\0';
364 file = f; 358 file = f;
365 } 359 }
366 360
367 bool ret = set_file (s, file); 361 set_file (s, file);
368 alpha = 0x8000; 362 alpha = 0x8000;
369 if (ret)
370 set_geometry (p ? p + 1 : ""); 363 set_geometry (p ? p + 1 : "");
371 return ret;
372} 364}
373 365
374bool 366void
375rxvt_image::set_file (rxvt_screen *s, const char *file) 367rxvt_image::set_file (rxvt_screen *s, const char *file)
376{ 368{
369 rxvt_img *img2 = rxvt_img::new_from_file (s, file);
377 delete img; 370 delete img;
378 img = rxvt_img::new_from_file (s, file); 371 img = img2;
379 return img != 0;
380} 372}
381 373
382# endif /* BG_IMAGE_FROM_FILE */ 374# endif /* BG_IMAGE_FROM_FILE */
383 375
384bool 376bool
442 } 434 }
443 435
444 return false; 436 return false;
445} 437}
446 438
447# if ENABLE_TRANSPARENCY 439# if BG_IMAGE_FROM_ROOT
448/* 440/*
449 * Builds a pixmap of the same size as the terminal window that contains 441 * Builds a pixmap of the same size as the terminal window that contains
450 * the tiled portion of the root pixmap that is supposed to be covered by 442 * the tiled portion of the root pixmap that is supposed to be covered by
451 * our window. 443 * our window.
452 */ 444 */
498rxvt_term::bg_set_root_pixmap () 490rxvt_term::bg_set_root_pixmap ()
499{ 491{
500 delete root_img; 492 delete root_img;
501 root_img = rxvt_img::new_from_root (this); 493 root_img = rxvt_img::new_from_root (this);
502} 494}
503# endif /* ENABLE_TRANSPARENCY */ 495# endif /* BG_IMAGE_FROM_ROOT */
504 496
505void 497void
506rxvt_term::bg_render () 498rxvt_term::bg_render ()
507{ 499{
508 if (bg_flags & BG_INHIBIT_RENDER) 500 if (bg_flags & BG_INHIBIT_RENDER)
509 return; 501 return;
510 502
511 bg_invalidate (); 503 bg_invalidate ();
512# if ENABLE_TRANSPARENCY 504# if BG_IMAGE_FROM_ROOT
513 if (bg_flags & BG_IS_TRANSPARENT) 505 if (option (Opt_transparent))
514 { 506 {
515 /* we need to re-generate transparency pixmap in that case ! */ 507 /* we need to re-generate transparency pixmap in that case ! */
516 if (render_root_image ()) 508 if (render_root_image ())
517 bg_flags |= BG_IS_VALID; 509 bg_flags |= BG_IS_VALID | BG_IS_TRANSPARENT;
518 } 510 }
519# endif 511# endif
520 512
521# if BG_IMAGE_FROM_FILE 513# if BG_IMAGE_FROM_FILE
522 if (fimage.img) 514 if (fimage.img)
539} 531}
540 532
541void 533void
542rxvt_term::bg_init () 534rxvt_term::bg_init ()
543{ 535{
536#if BG_IMAGE_FROM_ROOT
537 if (option (Opt_transparent))
538 {
539 if (rs [Rs_blurradius])
540 root_effects.set_blur (rs [Rs_blurradius]);
541
542 if (ISSET_PIXCOLOR (Color_tint))
543 root_effects.set_tint (pix_colors_focused [Color_tint]);
544
545 if (rs [Rs_shade])
546 root_effects.set_shade (rs [Rs_shade]);
547
548 bg_set_root_pixmap ();
549 XSelectInput (dpy, display->root, PropertyChangeMask);
550 rootwin_ev.start (display, display->root);
551 }
552#endif
553
544#if BG_IMAGE_FROM_FILE 554#if BG_IMAGE_FROM_FILE
545 if (rs[Rs_backgroundPixmap]) 555 if (rs[Rs_backgroundPixmap])
546 { 556 {
547 if (fimage.set_file_geometry (this, rs[Rs_backgroundPixmap]) 557 fimage.set_file_geometry (this, rs[Rs_backgroundPixmap]);
548 && !bg_window_position_sensitive ()) 558 if (!bg_window_position_sensitive ())
549 update_background (); 559 update_background ();
550 } 560 }
551#endif 561#endif
552} 562}
553 563

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines