… | |
… | |
170 | #endif |
170 | #endif |
171 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
171 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
172 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
172 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
173 | #endif |
173 | #endif |
174 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
174 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
175 | rootwin_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
175 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
176 | #endif |
176 | #endif |
177 | #ifdef HAVE_SCROLLBARS |
177 | #ifdef HAVE_SCROLLBARS |
178 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
178 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
179 | #endif |
179 | #endif |
180 | #ifdef USE_XIM |
180 | #ifdef USE_XIM |
… | |
… | |
276 | } |
276 | } |
277 | |
277 | |
278 | clear (); |
278 | clear (); |
279 | } |
279 | } |
280 | |
280 | |
281 | delete [] pix_colors_focused; |
|
|
282 | #if OFF_FOCUS_FADING |
|
|
283 | delete [] pix_colors_unfocused; |
|
|
284 | #endif |
|
|
285 | |
|
|
286 | #ifdef HAVE_BG_PIXMAP |
281 | #ifdef HAVE_BG_PIXMAP |
287 | bgPixmap.destroy (); |
282 | bgPixmap.destroy (); |
288 | #endif |
283 | #endif |
|
|
284 | display->flush (); /* ideally .put should do this */ |
289 | displays.put (display); |
285 | displays.put (display); |
290 | |
286 | |
291 | scr_release (); |
287 | scr_release (); |
292 | |
288 | |
293 | /* clear all resources */ |
289 | /* clear all resources */ |
… | |
… | |
515 | resize_scrollbar (); /* create and map scrollbar */ |
511 | resize_scrollbar (); /* create and map scrollbar */ |
516 | #endif |
512 | #endif |
517 | #ifdef HAVE_BG_PIXMAP |
513 | #ifdef HAVE_BG_PIXMAP |
518 | { |
514 | { |
519 | bgPixmap.set_target (this); |
515 | bgPixmap.set_target (this); |
|
|
516 | bgPixmap.invalidate (); |
520 | |
517 | |
521 | #ifdef ENABLE_TRANSPARENCY |
518 | #ifdef ENABLE_TRANSPARENCY |
522 | if (option (Opt_transparent)) |
519 | if (option (Opt_transparent)) |
523 | { |
520 | { |
524 | bgPixmap.set_transparent (); |
521 | bgPixmap.set_transparent (); |
|
|
522 | |
525 | #ifdef HAVE_AFTERIMAGE |
523 | #ifdef HAVE_AFTERIMAGE |
526 | if (rs [Rs_blurradius]) |
524 | if (rs [Rs_blurradius]) |
527 | bgPixmap.set_blur_radius (rs [Rs_blurradius]); |
525 | bgPixmap.set_blur_radius (rs [Rs_blurradius]); |
528 | #endif |
526 | #endif |
529 | if (ISSET_PIXCOLOR (Color_tint)) |
527 | if (ISSET_PIXCOLOR (Color_tint)) |
530 | bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
528 | bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
|
|
529 | |
531 | if (rs [Rs_shade]) |
530 | if (rs [Rs_shade]) |
532 | bgPixmap.set_shade (rs [Rs_shade]); |
531 | bgPixmap.set_shade (rs [Rs_shade]); |
533 | |
532 | |
534 | bgPixmap.set_root_pixmap (); |
533 | bgPixmap.set_root_pixmap (); |
535 | XSelectInput (dpy, display->root, PropertyChangeMask); |
534 | XSelectInput (dpy, display->root, PropertyChangeMask); |
536 | rootwin_ev.start (display, display->root); |
535 | rootwin_ev.start (display, display->root); |
537 | } |
536 | } |
538 | #endif |
537 | #endif |
539 | |
538 | |
540 | #ifdef BG_IMAGE_FROM_FILE |
539 | #ifdef BG_IMAGE_FROM_FILE |
541 | if (rs[Rs_backgroundPixmap] != NULL) |
540 | if (rs[Rs_backgroundPixmap]) |
542 | { |
541 | { |
543 | const char *p = rs[Rs_backgroundPixmap]; |
542 | const char *p = rs[Rs_backgroundPixmap]; |
544 | |
543 | |
545 | if ((p = strchr (p, ';')) != NULL) |
544 | if ((p = strchr (p, ';')) != 0) |
546 | { |
545 | { |
547 | p++; |
546 | p++; |
548 | bgPixmap.set_geometry (p); |
547 | bgPixmap.set_geometry (p); |
549 | } |
548 | } |
550 | else |
549 | else |
… | |
… | |
583 | } |
582 | } |
584 | #endif |
583 | #endif |
585 | |
584 | |
586 | XMapWindow (dpy, vt); |
585 | XMapWindow (dpy, vt); |
587 | XMapWindow (dpy, parent[0]); |
586 | XMapWindow (dpy, parent[0]); |
|
|
587 | |
|
|
588 | refresh_check (); |
588 | } |
589 | } |
589 | |
590 | |
590 | static struct sig_handlers |
591 | static struct sig_handlers |
591 | { |
592 | { |
592 | ev::sig sw_term, sw_int; |
593 | ev::sig sw_term, sw_int; |
… | |
… | |
635 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
636 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
636 | // TODO: handle this with exceptions and tolerate the memory loss |
637 | // TODO: handle this with exceptions and tolerate the memory loss |
637 | XSetIOErrorHandler (rxvt_xioerror_handler); |
638 | XSetIOErrorHandler (rxvt_xioerror_handler); |
638 | |
639 | |
639 | XrmInitialize (); |
640 | XrmInitialize (); |
640 | } |
|
|
641 | |
|
|
642 | /* ------------------------------------------------------------------------- * |
|
|
643 | * MEMORY ALLOCATION WRAPPERS * |
|
|
644 | * ------------------------------------------------------------------------- */ |
|
|
645 | void * |
|
|
646 | rxvt_malloc (size_t size) |
|
|
647 | { |
|
|
648 | void *p = malloc (size); |
|
|
649 | |
|
|
650 | if (!p) |
|
|
651 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
|
|
652 | |
|
|
653 | return p; |
|
|
654 | } |
|
|
655 | |
|
|
656 | void * |
|
|
657 | rxvt_calloc (size_t number, size_t size) |
|
|
658 | { |
|
|
659 | void *p = calloc (number, size); |
|
|
660 | |
|
|
661 | if (!p) |
|
|
662 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
|
|
663 | |
|
|
664 | return p; |
|
|
665 | } |
|
|
666 | |
|
|
667 | void * |
|
|
668 | rxvt_realloc (void *ptr, size_t size) |
|
|
669 | { |
|
|
670 | void *p = realloc (ptr, size); |
|
|
671 | |
|
|
672 | if (!p) |
|
|
673 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
|
|
674 | |
|
|
675 | return p; |
|
|
676 | } |
641 | } |
677 | |
642 | |
678 | /*----------------------------------------------------------------------*/ |
643 | /*----------------------------------------------------------------------*/ |
679 | /* |
644 | /* |
680 | * window size/position calculations for XSizeHint and other storage. |
645 | * window size/position calculations for XSizeHint and other storage. |
… | |
… | |
1712 | void |
1677 | void |
1713 | rxvt_term::get_window_origin (int &x, int &y) |
1678 | rxvt_term::get_window_origin (int &x, int &y) |
1714 | { |
1679 | { |
1715 | Window cr; |
1680 | Window cr; |
1716 | XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); |
1681 | XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); |
1717 | /* fprintf( stderr, "origin is %+d%+d\n", x, y);*/ |
1682 | /* fprintf (stderr, "origin is %+d%+d\n", x, y);*/ |
1718 | } |
1683 | } |
1719 | |
1684 | |
1720 | Pixmap |
1685 | Pixmap |
1721 | rxvt_term::get_pixmap_property (int prop_id) |
1686 | rxvt_term::get_pixmap_property (int prop_id) |
1722 | { |
1687 | { |
… | |
… | |
1729 | unsigned char *prop = NULL; |
1694 | unsigned char *prop = NULL; |
1730 | int result = XGetWindowProperty (dpy, display->root, xa[prop_id], |
1695 | int result = XGetWindowProperty (dpy, display->root, xa[prop_id], |
1731 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
1696 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
1732 | &nitems, &bytes_after, &prop); |
1697 | &nitems, &bytes_after, &prop); |
1733 | if (result == Success && prop && atype == XA_PIXMAP) |
1698 | if (result == Success && prop && atype == XA_PIXMAP) |
1734 | { |
|
|
1735 | return *(Pixmap *)prop; |
1699 | return *(Pixmap *)prop; |
1736 | } |
|
|
1737 | } |
1700 | } |
|
|
1701 | |
1738 | return None; |
1702 | return None; |
1739 | } |
1703 | } |
1740 | |
1704 | |
1741 | #ifdef HAVE_BG_PIXMAP |
1705 | #ifdef HAVE_BG_PIXMAP |
1742 | # if TRACE_PIXMAPS |
1706 | # if TRACE_PIXMAPS |
1743 | # undef update_background |
1707 | # undef update_background |
|
|
1708 | void |
1744 | int rxvt_term::trace_update_background (const char *file, int line) |
1709 | rxvt_term::trace_update_background (const char *file, int line) |
1745 | { |
1710 | { |
1746 | fprintf (stderr, "%s:%d:update_background()\n", file, line); |
1711 | fprintf (stderr, "%s:%d:update_background()\n", file, line); |
1747 | update_background (); |
1712 | update_background (); |
1748 | } |
1713 | } |
1749 | # endif |
1714 | # endif |
1750 | |
1715 | |
1751 | int |
1716 | void |
1752 | rxvt_term::update_background () |
1717 | rxvt_term::update_background () |
1753 | { |
1718 | { |
|
|
1719 | if (update_background_ev.is_active ()) |
|
|
1720 | return; |
|
|
1721 | |
1754 | bgPixmap.invalidate (); |
1722 | bgPixmap.invalidate (); |
1755 | |
1723 | |
1756 | /* no chance of real time refresh if we are blurring! */ |
1724 | ev_tstamp to_wait = 0.5 - (ev::now () - bgPixmap.valid_since); |
1757 | if (bgPixmap.invalid_since + 0.5 < ev::now () && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) |
1725 | |
|
|
1726 | if (to_wait <= 0.) |
1758 | bgPixmap.render (); |
1727 | bgPixmap.render (); |
1759 | else |
1728 | else |
1760 | { |
|
|
1761 | update_background_ev.stop (); |
|
|
1762 | |
|
|
1763 | if (!bgPixmap.need_client_side_rendering()) |
|
|
1764 | update_background_ev.start (.05); |
1729 | update_background_ev.start (to_wait); |
1765 | else if (bgPixmap.flags & bgPixmap_t::blurNeeded) |
|
|
1766 | update_background_ev.start (.20); /* very slow !!! */ |
|
|
1767 | else |
|
|
1768 | update_background_ev.start (.07); |
|
|
1769 | } |
|
|
1770 | |
|
|
1771 | return 0; |
|
|
1772 | } |
1730 | } |
1773 | |
1731 | |
1774 | void |
1732 | void |
1775 | rxvt_term::update_background_cb (ev::timer &w, int revents) |
1733 | rxvt_term::update_background_cb (ev::timer &w, int revents) |
1776 | { |
1734 | { |
1777 | make_current (); |
1735 | make_current (); |
|
|
1736 | |
|
|
1737 | update_background_ev.stop (); |
1778 | bgPixmap.render (); |
1738 | bgPixmap.render (); |
1779 | refresh_check (); |
1739 | refresh_check (); |
1780 | } |
1740 | } |
1781 | |
1741 | |
1782 | #endif /* HAVE_BG_PIXMAP */ |
1742 | #endif /* HAVE_BG_PIXMAP */ |