… | |
… | |
153 | } |
153 | } |
154 | #endif |
154 | #endif |
155 | |
155 | |
156 | rxvt_term::rxvt_term () |
156 | rxvt_term::rxvt_term () |
157 | : |
157 | : |
158 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
|
|
159 | rootwin_ev (this, &rxvt_term::rootwin_cb), |
|
|
160 | #endif |
|
|
161 | #if HAVE_BG_PIXMAP |
158 | #if HAVE_BG_PIXMAP |
162 | update_background_ev(this, &rxvt_term::update_background_cb), |
159 | update_background_ev(this, &rxvt_term::update_background_cb), |
163 | #endif |
160 | #endif |
164 | #ifdef HAVE_SCROLLBARS |
|
|
165 | scrollbar_ev (this, &rxvt_term::x_cb), |
|
|
166 | #endif |
|
|
167 | #ifdef CURSOR_BLINK |
161 | #ifdef CURSOR_BLINK |
168 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
162 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
169 | #endif |
163 | #endif |
170 | #ifdef TEXT_BLINK |
164 | #ifdef TEXT_BLINK |
171 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
165 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
… | |
… | |
180 | slip_wheel_ev (this, &rxvt_term::slip_wheel_cb), |
174 | slip_wheel_ev (this, &rxvt_term::slip_wheel_cb), |
181 | #endif |
175 | #endif |
182 | #ifdef POINTER_BLANK |
176 | #ifdef POINTER_BLANK |
183 | pointer_ev (this, &rxvt_term::pointer_cb), |
177 | pointer_ev (this, &rxvt_term::pointer_cb), |
184 | #endif |
178 | #endif |
|
|
179 | #ifndef NO_BELL |
|
|
180 | bell_ev (this, &rxvt_term::bell_cb), |
|
|
181 | #endif |
|
|
182 | child_ev (this, &rxvt_term::child_cb), |
|
|
183 | prepare_ev (this, &rxvt_term::prepare_cb), |
|
|
184 | flush_ev (this, &rxvt_term::flush_cb), |
|
|
185 | destroy_ev (this, &rxvt_term::destroy_cb), |
|
|
186 | pty_ev (this, &rxvt_term::pty_cb), |
|
|
187 | incr_ev (this, &rxvt_term::incr_cb) |
|
|
188 | { |
|
|
189 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
|
|
190 | callback_set (rootwin_ev , this, rxvt_term, rootwin_cb); |
|
|
191 | #endif |
|
|
192 | #ifdef HAVE_SCROLLBARS |
|
|
193 | callback_set (scrollbar_ev, this, rxvt_term, x_cb); |
|
|
194 | #endif |
185 | #ifdef USE_XIM |
195 | #ifdef USE_XIM |
186 | im_ev (this, &rxvt_term::im_cb), |
196 | callback_set (im_ev , this, rxvt_term, im_cb); |
187 | #endif |
197 | #endif |
188 | #ifndef NO_BELL |
198 | callback_set (termwin_ev , this, rxvt_term, x_cb); |
189 | bell_ev (this, &rxvt_term::bell_cb), |
199 | callback_set (vt_ev , this, rxvt_term, x_cb); |
190 | #endif |
200 | |
191 | termwin_ev (this, &rxvt_term::x_cb), |
|
|
192 | vt_ev (this, &rxvt_term::x_cb), |
|
|
193 | child_ev (this, &rxvt_term::child_cb), |
|
|
194 | check_ev (this, &rxvt_term::check_cb), |
|
|
195 | flush_ev (this, &rxvt_term::flush_cb), |
|
|
196 | destroy_ev (this, &rxvt_term::destroy_cb), |
|
|
197 | pty_ev (this, &rxvt_term::pty_cb), |
|
|
198 | incr_ev (this, &rxvt_term::incr_cb) |
|
|
199 | { |
|
|
200 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
201 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
201 | |
202 | |
202 | termlist.push_back (this); |
203 | termlist.push_back (this); |
203 | |
204 | |
204 | #ifdef KEYSYM_RESOURCE |
205 | #ifdef KEYSYM_RESOURCE |
… | |
… | |
284 | delete [] pix_colors_focused; |
285 | delete [] pix_colors_focused; |
285 | #if OFF_FOCUS_FADING |
286 | #if OFF_FOCUS_FADING |
286 | delete [] pix_colors_unfocused; |
287 | delete [] pix_colors_unfocused; |
287 | #endif |
288 | #endif |
288 | |
289 | |
|
|
290 | #ifdef HAVE_BG_PIXMAP |
|
|
291 | bgPixmap.destroy (); |
|
|
292 | #endif |
289 | displays.put (display); |
293 | displays.put (display); |
290 | |
294 | |
291 | scr_release (); |
295 | scr_release (); |
292 | |
296 | |
293 | /* clear all resources */ |
297 | /* clear all resources */ |
… | |
… | |
306 | delete argv; |
310 | delete argv; |
307 | |
311 | |
308 | #ifdef KEYSYM_RESOURCE |
312 | #ifdef KEYSYM_RESOURCE |
309 | delete keyboard; |
313 | delete keyboard; |
310 | #endif |
314 | #endif |
|
|
315 | #ifndef NO_RESOURCES |
|
|
316 | XrmDestroyDatabase (option_db); |
|
|
317 | #endif |
311 | } |
318 | } |
312 | |
319 | |
313 | // child has exited, usually destroys |
320 | // child has exited, usually destroys |
314 | void |
321 | void |
315 | rxvt_term::child_cb (child_watcher &w, int status) |
322 | rxvt_term::child_cb (ev::child &w, int status) |
316 | { |
323 | { |
317 | HOOK_INVOKE ((this, HOOK_CHILD_EXIT, DT_INT, status, DT_END)); |
324 | HOOK_INVOKE ((this, HOOK_CHILD_EXIT, DT_INT, status, DT_END)); |
318 | |
325 | |
319 | cmd_pid = 0; |
326 | cmd_pid = 0; |
320 | |
327 | |
… | |
… | |
348 | incr_ev.stop (); |
355 | incr_ev.stop (); |
349 | termwin_ev.stop (display); |
356 | termwin_ev.stop (display); |
350 | vt_ev.stop (display); |
357 | vt_ev.stop (display); |
351 | } |
358 | } |
352 | |
359 | |
353 | check_ev.stop (); |
360 | prepare_ev.stop (); |
354 | pty_ev.stop (); |
361 | pty_ev.stop (); |
355 | #ifdef CURSOR_BLINK |
362 | #ifdef CURSOR_BLINK |
356 | cursor_blink_ev.stop (); |
363 | cursor_blink_ev.stop (); |
357 | #endif |
364 | #endif |
358 | #ifdef TEXT_BLINK |
365 | #ifdef TEXT_BLINK |
… | |
… | |
366 | #endif |
373 | #endif |
367 | #ifdef POINTER_BLANK |
374 | #ifdef POINTER_BLANK |
368 | pointer_ev.stop (); |
375 | pointer_ev.stop (); |
369 | #endif |
376 | #endif |
370 | |
377 | |
371 | destroy_ev.start (0); |
378 | destroy_ev.start (); |
372 | } |
379 | } |
373 | |
380 | |
374 | void |
381 | void |
375 | rxvt_term::destroy_cb (time_watcher &w) |
382 | rxvt_term::destroy_cb (ev::idle &w, int revents) |
376 | { |
383 | { |
377 | make_current (); |
384 | make_current (); |
378 | |
385 | |
379 | delete this; |
386 | delete this; |
380 | } |
387 | } |
… | |
… | |
565 | init_command (cmd_argv); |
572 | init_command (cmd_argv); |
566 | |
573 | |
567 | free (cmd_argv); |
574 | free (cmd_argv); |
568 | |
575 | |
569 | if (pty->pty >= 0) |
576 | if (pty->pty >= 0) |
570 | pty_ev.start (pty->pty, EVENT_READ); |
577 | pty_ev.start (pty->pty, ev::READ); |
571 | |
578 | |
572 | check_ev.start (); |
579 | prepare_ev.start (); |
573 | |
580 | |
574 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
581 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
575 | |
582 | |
576 | #if ENABLE_XEMBED |
583 | #if ENABLE_XEMBED |
577 | if (rs[Rs_embed]) |
584 | if (rs[Rs_embed]) |
… | |
… | |
589 | return true; |
596 | return true; |
590 | } |
597 | } |
591 | |
598 | |
592 | static struct sig_handlers |
599 | static struct sig_handlers |
593 | { |
600 | { |
594 | sig_watcher sw_term, sw_int; |
601 | ev::sig sw_term, sw_int; |
595 | |
602 | |
596 | /* |
603 | /* |
597 | * Catch a fatal signal and tidy up before quitting |
604 | * Catch a fatal signal and tidy up before quitting |
598 | */ |
605 | */ |
599 | void |
606 | void |
600 | sig_term (sig_watcher &w) |
607 | sig_term (ev::sig &w, int revents) |
601 | { |
608 | { |
602 | rxvt_emergency_cleanup (); |
609 | rxvt_emergency_cleanup (); |
603 | signal (w.signum, SIG_DFL); |
610 | w.stop (); |
604 | kill (getpid (), w.signum); |
611 | kill (getpid (), w.signum); |
605 | } |
612 | } |
606 | |
613 | |
607 | sig_handlers () |
614 | sig_handlers () |
608 | : sw_term (this, &sig_handlers::sig_term), |
615 | : sw_term (this, &sig_handlers::sig_term), |
… | |
… | |
616 | void |
623 | void |
617 | rxvt_init () |
624 | rxvt_init () |
618 | { |
625 | { |
619 | ptytty::init (); |
626 | ptytty::init (); |
620 | |
627 | |
|
|
628 | if (!ev_default_loop (0)) |
|
|
629 | rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); |
|
|
630 | |
621 | rxvt_environ = environ; |
631 | rxvt_environ = environ; |
622 | |
632 | |
623 | signal (SIGHUP, SIG_IGN); |
633 | signal (SIGHUP, SIG_IGN); |
624 | signal (SIGPIPE, SIG_IGN); |
634 | signal (SIGPIPE, SIG_IGN); |
625 | |
635 | |
626 | sig_handlers.sw_term.start (SIGTERM); |
636 | sig_handlers.sw_term.start (SIGTERM); ev_unref (); |
627 | sig_handlers.sw_int.start (SIGINT); |
637 | sig_handlers.sw_int.start (SIGINT); ev_unref (); |
628 | |
638 | |
629 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
639 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
630 | /* signal (SIGURG, SIG_DFL); */ |
640 | /* signal (SIGURG, SIG_DFL); */ |
631 | |
641 | |
632 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
642 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
… | |
… | |
970 | if (isdigit (*color)) |
980 | if (isdigit (*color)) |
971 | { |
981 | { |
972 | i = atoi (color); |
982 | i = atoi (color); |
973 | |
983 | |
974 | if (i >= 8 && i <= 15) |
984 | if (i >= 8 && i <= 15) |
|
|
985 | { |
975 | { /* bright colors */ |
986 | /* bright colors */ |
976 | i -= 8; |
|
|
977 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
987 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; |
978 | goto done; |
988 | goto done; |
979 | } |
989 | } |
980 | |
990 | |
981 | if (i >= 0 && i <= 7) |
991 | if (i >= 0 && i <= 7) |
|
|
992 | { |
982 | { /* normal colors */ |
993 | /* normal colors */ |
983 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
994 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
984 | goto done; |
995 | goto done; |
985 | } |
996 | } |
986 | } |
997 | } |
987 | |
998 | |
… | |
… | |
992 | * so just keep gobbling up the colormap |
1003 | * so just keep gobbling up the colormap |
993 | */ |
1004 | */ |
994 | |
1005 | |
995 | pix_colors_focused[idx] = xcol; |
1006 | pix_colors_focused[idx] = xcol; |
996 | |
1007 | |
997 | /* XSetWindowAttributes attr; */ |
|
|
998 | /* Cursor cursor; */ |
|
|
999 | done: |
1008 | done: |
1000 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
1009 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
1001 | |
1010 | |
1002 | update_fade_color (idx); |
1011 | update_fade_color (idx); |
1003 | recolour_cursor (); |
1012 | recolour_cursor (); |
1004 | scr_recolour (); |
1013 | scr_recolour (); |
1005 | #endif /* XTERM_COLOR_CHANGE */ |
1014 | #endif /* XTERM_COLOR_CHANGE */ |
1006 | } |
1015 | } |
1007 | |
1016 | |
1008 | void |
1017 | void |
1009 | rxvt_term::recolour_cursor () |
1018 | rxvt_term::recolour_cursor () |
1010 | { |
1019 | { |
… | |
… | |
1027 | */ |
1036 | */ |
1028 | void |
1037 | void |
1029 | rxvt_term::set_colorfgbg () |
1038 | rxvt_term::set_colorfgbg () |
1030 | { |
1039 | { |
1031 | unsigned int i; |
1040 | unsigned int i; |
1032 | const char *xpmb = "\0"; |
1041 | const char *xpmb = ""; |
1033 | char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1]; |
1042 | char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1]; |
1034 | |
1043 | |
1035 | strcpy (fstr, "default"); |
1044 | strcpy (fstr, "default"); |
1036 | strcpy (bstr, "default"); |
1045 | strcpy (bstr, "default"); |
1037 | for (i = Color_Black; i <= Color_White; i++) |
1046 | for (i = Color_Black; i <= Color_White; i++) |
… | |
… | |
1703 | XFree (status_attr); |
1712 | XFree (status_attr); |
1704 | } |
1713 | } |
1705 | |
1714 | |
1706 | XFree (preedit_attr); |
1715 | XFree (preedit_attr); |
1707 | } |
1716 | } |
1708 | #endif /* USE_XIM */ |
1717 | #endif /* USE_XIM */ |
1709 | |
1718 | |
1710 | void |
1719 | void |
1711 | rxvt_term::get_window_origin (int &x, int &y) |
1720 | rxvt_term::get_window_origin (int &x, int &y) |
1712 | { |
1721 | { |
1713 | Window cr; |
1722 | Window cr; |
… | |
… | |
1735 | } |
1744 | } |
1736 | return None; |
1745 | return None; |
1737 | } |
1746 | } |
1738 | |
1747 | |
1739 | #ifdef HAVE_BG_PIXMAP |
1748 | #ifdef HAVE_BG_PIXMAP |
|
|
1749 | # if TRACE_PIXMAPS |
|
|
1750 | # undef update_background |
|
|
1751 | int rxvt_term::trace_update_background (const char *file, int line) |
|
|
1752 | { |
|
|
1753 | fprintf (stderr, "%s:%d:update_background()\n", file, line); |
|
|
1754 | update_background (); |
|
|
1755 | } |
|
|
1756 | # endif |
|
|
1757 | |
1740 | int |
1758 | int |
1741 | rxvt_term::update_background () |
1759 | rxvt_term::update_background () |
1742 | { |
1760 | { |
1743 | bgPixmap.invalidate (); |
1761 | bgPixmap.invalidate (); |
1744 | |
1762 | |
1745 | /* no chance of real time refresh if we are blurring ! */ |
1763 | /* no chance of real time refresh if we are blurring! */ |
1746 | if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) |
1764 | if (bgPixmap.invalid_since + 0.5 < ev::now () && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) |
1747 | bgPixmap.render (); |
1765 | bgPixmap.render (); |
1748 | else |
1766 | else |
1749 | { |
1767 | { |
1750 | update_background_ev.stop (); |
1768 | update_background_ev.stop (); |
|
|
1769 | |
1751 | if (!bgPixmap.need_client_side_rendering()) |
1770 | if (!bgPixmap.need_client_side_rendering()) |
1752 | update_background_ev.start (NOW + .05); |
1771 | update_background_ev.start (.05); |
1753 | else if (bgPixmap.flags & bgPixmap_t::blurNeeded) |
1772 | else if (bgPixmap.flags & bgPixmap_t::blurNeeded) |
1754 | update_background_ev.start (NOW + .2); /* very slow !!! */ |
1773 | update_background_ev.start (.20); /* very slow !!! */ |
1755 | else |
1774 | else |
1756 | update_background_ev.start (NOW + .07); |
1775 | update_background_ev.start (.07); |
1757 | } |
1776 | } |
|
|
1777 | |
1758 | return 0; |
1778 | return 0; |
1759 | } |
1779 | } |
1760 | |
1780 | |
1761 | void |
1781 | void |
1762 | rxvt_term::update_background_cb (time_watcher &w) |
1782 | rxvt_term::update_background_cb (ev::timer &w, int revents) |
1763 | { |
1783 | { |
1764 | bgPixmap.render (); |
1784 | bgPixmap.render (); |
1765 | } |
1785 | } |
1766 | |
1786 | |
1767 | #endif /* HAVE_BG_PIXMAP */ |
1787 | #endif /* HAVE_BG_PIXMAP */ |