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.243 by sf-exg, Sun Jun 17 17:06:47 2012 UTC vs.
Revision 1.255 by sf-exg, Mon Dec 31 12:05:34 2012 UTC

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)
254 flags &= ~IM_IS_SIZE_SENSITIVE; 251 flags &= ~IM_IS_SIZE_SENSITIVE;
255 252
256 return changed; 253 return changed;
257} 254}
258 255
259void 256bool
260rxvt_term::get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y) 257rxvt_term::render_image (rxvt_image &image)
261{ 258{
262 int image_width = image.img->w; 259 int image_width = image.img->w;
263 int image_height = image.img->h; 260 int image_height = image.img->h;
264 int parent_width = szHint.width; 261 int parent_width = szHint.width;
265 int parent_height = szHint.height; 262 int parent_height = szHint.height;
266 int h_scale = min (image.h_scale, 32767 * 100 / parent_width); 263 int h_scale = min (image.h_scale, 32767 * 100 / parent_width);
267 int v_scale = min (image.v_scale, 32767 * 100 / parent_height); 264 int v_scale = min (image.v_scale, 32767 * 100 / parent_height);
268 265
266 int w;
267 int h;
268 int x;
269 int y;
270
269 w = h_scale * parent_width / 100; 271 w = h_scale * parent_width / 100;
270 h = v_scale * parent_height / 100; 272 h = v_scale * parent_height / 100;
271 273
272 if (image.flags & IM_KEEP_ASPECT) 274 if (image.flags & IM_KEEP_ASPECT)
273 { 275 {
288 else 290 else
289 { 291 {
290 x = make_align_position (image.h_align, parent_width, w); 292 x = make_align_position (image.h_align, parent_width, w);
291 y = make_align_position (image.v_align, parent_height, h); 293 y = make_align_position (image.v_align, parent_height, h);
292 } 294 }
293}
294
295bool
296rxvt_term::render_image (rxvt_image &image)
297{
298 int parent_width = szHint.width;
299 int parent_height = szHint.height;
300
301 int x = 0;
302 int y = 0;
303 int w = 0;
304 int h = 0;
305
306 get_image_geometry (image, w, h, x, y);
307 295
308 if (!(image.flags & IM_ROOT_ALIGN) 296 if (!(image.flags & IM_ROOT_ALIGN)
309 && (x >= parent_width 297 && (x >= parent_width
310 || y >= parent_height 298 || y >= parent_height
311 || x + w <= 0 299 || x + w <= 0
318 img->repeat_mode (RepeatNormal); 306 img->repeat_mode (RepeatNormal);
319 else 307 else
320 img->repeat_mode (RepeatNone); 308 img->repeat_mode (RepeatNone);
321 img->sub_rect (-x, -y, parent_width, parent_height)->replace (img); 309 img->sub_rect (-x, -y, parent_width, parent_height)->replace (img);
322 310
323 if (bg_flags & BG_IS_VALID) 311 if (bg_img)
324 { 312 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 313
329 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 314 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
330 img->convert_format (format, pix_colors [Color_bg])->replace (img); 315 img->convert_format (format, pix_colors [Color_bg])->replace (img);
331 316
332 delete bg_img; 317 delete bg_img;
440 } 425 }
441 426
442 return false; 427 return false;
443} 428}
444 429
445# if ENABLE_TRANSPARENCY 430# if BG_IMAGE_FROM_ROOT
446/* 431/*
447 * Builds a pixmap of the same size as the terminal window that contains 432 * Builds a pixmap of the same size as the terminal window that contains
448 * the tiled portion of the root pixmap that is supposed to be covered by 433 * the tiled portion of the root pixmap that is supposed to be covered by
449 * our window. 434 * our window.
450 */ 435 */
462 int sx, sy; 447 int sx, sy;
463 448
464 sx = parent_x; 449 sx = parent_x;
465 sy = parent_y; 450 sy = parent_y;
466 451
467 if (!root_img)
468 return false;
469
470 /* check if we are outside of the visible part of the virtual screen : */ 452 /* check if we are outside of the visible part of the virtual screen : */
471 if (sx + parent_width <= 0 || sy + parent_height <= 0 453 if (sx + parent_width <= 0 || sy + parent_height <= 0
472 || sx >= root_width || sy >= root_height) 454 || sx >= root_width || sy >= root_height)
473 return 0; 455 return 0;
474 456
489 delete bg_img; 471 delete bg_img;
490 bg_img = img; 472 bg_img = img;
491 473
492 return true; 474 return true;
493} 475}
494 476# endif /* BG_IMAGE_FROM_ROOT */
495void
496rxvt_term::bg_set_root_pixmap ()
497{
498 delete root_img;
499 root_img = rxvt_img::new_from_root (this);
500}
501# endif /* ENABLE_TRANSPARENCY */
502 477
503void 478void
504rxvt_term::bg_render () 479rxvt_term::bg_render ()
505{ 480{
506 if (bg_flags & BG_INHIBIT_RENDER) 481 if (bg_flags & BG_INHIBIT_RENDER)
507 return; 482 return;
508 483
509 bg_invalidate (); 484 delete bg_img;
510# if ENABLE_TRANSPARENCY 485 bg_img = 0;
511 if (bg_flags & BG_IS_TRANSPARENT) 486 bg_flags = 0;
512 { 487
513 /* we need to re-generate transparency pixmap in that case ! */ 488 if (!mapped)
489 return;
490
491# if BG_IMAGE_FROM_ROOT
492 if (root_img)
514 if (render_root_image ()) 493 if (render_root_image ())
515 bg_flags |= BG_IS_VALID; 494 bg_flags |= BG_IS_TRANSPARENT;
516 }
517# endif 495# endif
518 496
519# if BG_IMAGE_FROM_FILE 497# if BG_IMAGE_FROM_FILE
520 if (fimage.img) 498 if (fimage.img)
521 {
522 if (render_image (fimage)) 499 render_image (fimage);
523 bg_flags |= BG_IS_VALID;
524 }
525# endif 500# endif
526
527 if (!(bg_flags & BG_IS_VALID))
528 {
529 delete bg_img;
530 bg_img = 0;
531 }
532 501
533 scr_recolour (false); 502 scr_recolour (false);
534 bg_flags |= BG_NEEDS_REFRESH; 503 bg_flags |= BG_NEEDS_REFRESH;
535 504
536 bg_valid_since = ev::now (); 505 bg_valid_since = ev::now ();
537} 506}
538 507
539void 508void
540rxvt_term::bg_init () 509rxvt_term::bg_init ()
541{ 510{
542#if ENABLE_TRANSPARENCY 511#if BG_IMAGE_FROM_ROOT
543 if (option (Opt_transparent)) 512 if (option (Opt_transparent))
544 { 513 {
545 bg_set_transparent ();
546
547 if (rs [Rs_blurradius]) 514 if (rs [Rs_blurradius])
548 root_effects.set_blur (rs [Rs_blurradius]); 515 root_effects.set_blur (rs [Rs_blurradius]);
549 516
550 if (ISSET_PIXCOLOR (Color_tint)) 517 if (ISSET_PIXCOLOR (Color_tint))
551 root_effects.set_tint (pix_colors_focused [Color_tint]); 518 root_effects.set_tint (pix_colors_focused [Color_tint]);
552 519
553 if (rs [Rs_shade]) 520 if (rs [Rs_shade])
554 root_effects.set_shade (rs [Rs_shade]); 521 root_effects.set_shade (rs [Rs_shade]);
555 522
556 bg_set_root_pixmap (); 523 rxvt_img::new_from_root (this)->replace (root_img);
557 XSelectInput (dpy, display->root, PropertyChangeMask); 524 XSelectInput (dpy, display->root, PropertyChangeMask);
558 rootwin_ev.start (display, display->root); 525 rootwin_ev.start (display, display->root);
559 } 526 }
560#endif 527#endif
561 528

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines