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> |
… | |
… | |
319 | else |
319 | else |
320 | img->repeat_mode (RepeatNone); |
320 | img->repeat_mode (RepeatNone); |
321 | img->sub_rect (-x, -y, parent_width, parent_height)->replace (img); |
321 | img->sub_rect (-x, -y, parent_width, parent_height)->replace (img); |
322 | |
322 | |
323 | if (bg_flags & BG_IS_VALID) |
323 | if (bg_flags & BG_IS_VALID) |
324 | { |
324 | bg_img->draw (img, PictOpOver, image.alpha * 1. / 0xffff); |
325 | double factor = image.alpha * 1. / 0xffff; |
|
|
326 | bg_img->blend (img, factor)->replace (img); |
|
|
327 | } |
|
|
328 | |
325 | |
329 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
326 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
330 | img->convert_format (format, pix_colors [Color_bg])->replace (img); |
327 | img->convert_format (format, pix_colors [Color_bg])->replace (img); |
331 | |
328 | |
332 | delete bg_img; |
329 | delete bg_img; |
… | |
… | |
345 | v_align = defaultAlign; |
342 | v_align = defaultAlign; |
346 | |
343 | |
347 | img = 0; |
344 | img = 0; |
348 | } |
345 | } |
349 | |
346 | |
350 | bool |
347 | void |
351 | rxvt_image::set_file_geometry (rxvt_screen *s, const char *file) |
348 | rxvt_image::set_file_geometry (rxvt_screen *s, const char *file) |
352 | { |
349 | { |
353 | if (!file || !*file) |
350 | if (!file || !*file) |
354 | return false; |
351 | return; |
355 | |
352 | |
356 | const char *p = strchr (file, ';'); |
353 | const char *p = strchr (file, ';'); |
357 | |
354 | |
358 | if (p) |
355 | if (p) |
359 | { |
356 | { |
… | |
… | |
362 | memcpy (f, file, len); |
359 | memcpy (f, file, len); |
363 | f[len] = '\0'; |
360 | f[len] = '\0'; |
364 | file = f; |
361 | file = f; |
365 | } |
362 | } |
366 | |
363 | |
367 | bool ret = set_file (s, file); |
364 | set_file (s, file); |
368 | alpha = 0x8000; |
365 | alpha = 0x8000; |
369 | if (ret) |
|
|
370 | set_geometry (p ? p + 1 : ""); |
366 | set_geometry (p ? p + 1 : ""); |
371 | return ret; |
|
|
372 | } |
367 | } |
373 | |
368 | |
374 | bool |
369 | void |
375 | rxvt_image::set_file (rxvt_screen *s, const char *file) |
370 | rxvt_image::set_file (rxvt_screen *s, const char *file) |
376 | { |
371 | { |
|
|
372 | rxvt_img *img2 = rxvt_img::new_from_file (s, file); |
377 | delete img; |
373 | delete img; |
378 | img = rxvt_img::new_from_file (s, file); |
374 | img = img2; |
379 | return img != 0; |
|
|
380 | } |
375 | } |
381 | |
376 | |
382 | # endif /* BG_IMAGE_FROM_FILE */ |
377 | # endif /* BG_IMAGE_FROM_FILE */ |
383 | |
378 | |
384 | bool |
379 | bool |
… | |
… | |
539 | } |
534 | } |
540 | |
535 | |
541 | void |
536 | void |
542 | rxvt_term::bg_init () |
537 | rxvt_term::bg_init () |
543 | { |
538 | { |
|
|
539 | #if ENABLE_TRANSPARENCY |
|
|
540 | if (option (Opt_transparent)) |
|
|
541 | { |
|
|
542 | bg_set_transparent (); |
|
|
543 | |
|
|
544 | if (rs [Rs_blurradius]) |
|
|
545 | root_effects.set_blur (rs [Rs_blurradius]); |
|
|
546 | |
|
|
547 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
548 | root_effects.set_tint (pix_colors_focused [Color_tint]); |
|
|
549 | |
|
|
550 | if (rs [Rs_shade]) |
|
|
551 | root_effects.set_shade (rs [Rs_shade]); |
|
|
552 | |
|
|
553 | bg_set_root_pixmap (); |
|
|
554 | XSelectInput (dpy, display->root, PropertyChangeMask); |
|
|
555 | rootwin_ev.start (display, display->root); |
|
|
556 | } |
|
|
557 | #endif |
|
|
558 | |
544 | #if BG_IMAGE_FROM_FILE |
559 | #if BG_IMAGE_FROM_FILE |
545 | if (rs[Rs_backgroundPixmap]) |
560 | if (rs[Rs_backgroundPixmap]) |
546 | { |
561 | { |
547 | if (fimage.set_file_geometry (this, rs[Rs_backgroundPixmap]) |
562 | fimage.set_file_geometry (this, rs[Rs_backgroundPixmap]); |
548 | && !bg_window_position_sensitive ()) |
563 | if (!bg_window_position_sensitive ()) |
549 | update_background (); |
564 | update_background (); |
550 | } |
565 | } |
551 | #endif |
566 | #endif |
552 | } |
567 | } |
553 | |
568 | |