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.254 by sf-exg, Sun Dec 30 20:28:31 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 (root_img)
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 (root_img)
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)
318 img->repeat_mode (RepeatNormal); 315 img->repeat_mode (RepeatNormal);
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_img)
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 */
464 int sx, sy; 456 int sx, sy;
465 457
466 sx = parent_x; 458 sx = parent_x;
467 sy = parent_y; 459 sy = parent_y;
468 460
469 if (!root_img)
470 return false;
471
472 /* check if we are outside of the visible part of the virtual screen : */ 461 /* check if we are outside of the visible part of the virtual screen : */
473 if (sx + parent_width <= 0 || sy + parent_height <= 0 462 if (sx + parent_width <= 0 || sy + parent_height <= 0
474 || sx >= root_width || sy >= root_height) 463 || sx >= root_width || sy >= root_height)
475 return 0; 464 return 0;
476 465
498rxvt_term::bg_set_root_pixmap () 487rxvt_term::bg_set_root_pixmap ()
499{ 488{
500 delete root_img; 489 delete root_img;
501 root_img = rxvt_img::new_from_root (this); 490 root_img = rxvt_img::new_from_root (this);
502} 491}
503# endif /* ENABLE_TRANSPARENCY */ 492# endif /* BG_IMAGE_FROM_ROOT */
504 493
505void 494void
506rxvt_term::bg_render () 495rxvt_term::bg_render ()
507{ 496{
508 if (bg_flags & BG_INHIBIT_RENDER) 497 if (bg_flags & BG_INHIBIT_RENDER)
509 return; 498 return;
510 499
511 bg_invalidate (); 500 delete bg_img;
512# if ENABLE_TRANSPARENCY 501 bg_img = 0;
513 if (bg_flags & BG_IS_TRANSPARENT) 502 bg_flags = 0;
514 { 503
515 /* we need to re-generate transparency pixmap in that case ! */ 504 if (!mapped)
505 return;
506
507# if BG_IMAGE_FROM_ROOT
508 if (root_img)
516 if (render_root_image ()) 509 if (render_root_image ())
517 bg_flags |= BG_IS_VALID; 510 bg_flags |= BG_IS_TRANSPARENT;
518 }
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)
523 {
524 if (render_image (fimage)) 515 render_image (fimage);
525 bg_flags |= BG_IS_VALID;
526 }
527# endif 516# endif
528
529 if (!(bg_flags & BG_IS_VALID))
530 {
531 delete bg_img;
532 bg_img = 0;
533 }
534 517
535 scr_recolour (false); 518 scr_recolour (false);
536 bg_flags |= BG_NEEDS_REFRESH; 519 bg_flags |= BG_NEEDS_REFRESH;
537 520
538 bg_valid_since = ev::now (); 521 bg_valid_since = ev::now ();
539} 522}
540 523
541void 524void
542rxvt_term::bg_init () 525rxvt_term::bg_init ()
543{ 526{
527#if BG_IMAGE_FROM_ROOT
528 if (option (Opt_transparent))
529 {
530 if (rs [Rs_blurradius])
531 root_effects.set_blur (rs [Rs_blurradius]);
532
533 if (ISSET_PIXCOLOR (Color_tint))
534 root_effects.set_tint (pix_colors_focused [Color_tint]);
535
536 if (rs [Rs_shade])
537 root_effects.set_shade (rs [Rs_shade]);
538
539 bg_set_root_pixmap ();
540 XSelectInput (dpy, display->root, PropertyChangeMask);
541 rootwin_ev.start (display, display->root);
542 }
543#endif
544
544#if BG_IMAGE_FROM_FILE 545#if BG_IMAGE_FROM_FILE
545 if (rs[Rs_backgroundPixmap]) 546 if (rs[Rs_backgroundPixmap])
546 { 547 {
547 if (fimage.set_file_geometry (this, rs[Rs_backgroundPixmap]) 548 fimage.set_file_geometry (this, rs[Rs_backgroundPixmap]);
548 && !bg_window_position_sensitive ()) 549 if (!bg_window_position_sensitive ())
549 update_background (); 550 update_background ();
550 } 551 }
551#endif 552#endif
552} 553}
553 554

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines