… | |
… | |
1127 | { |
1127 | { |
1128 | // this should really be sched_yield(), but the linux guys thought |
1128 | // this should really be sched_yield(), but the linux guys thought |
1129 | // that giving a process calling sched_yield () less cpu time than |
1129 | // that giving a process calling sched_yield () less cpu time than |
1130 | // ones with high nice levels is a useful thing to do. It surely is is |
1130 | // ones with high nice levels is a useful thing to do. It surely is is |
1131 | // allowed by the sus... as is returning ENOSYS. |
1131 | // allowed by the sus... as is returning ENOSYS. |
|
|
1132 | // since the linux guys additionally thought that breaking the only |
|
|
1133 | // known workaroudn against their unusable sched_yield hack is cool, |
|
|
1134 | // we just nanosleep a bit and hope for the best. |
1132 | |
1135 | |
1133 | struct timespec ts = { 0, 0 }; |
1136 | struct timespec ts = { 0, 1000 }; |
1134 | nanosleep (&ts, 0); |
1137 | nanosleep (&ts, 0); |
1135 | |
1138 | |
1136 | w.stop (); |
1139 | w.stop (); |
1137 | } |
1140 | } |
1138 | |
1141 | |
… | |
… | |
1683 | |
1686 | |
1684 | refresh_check (); |
1687 | refresh_check (); |
1685 | } |
1688 | } |
1686 | |
1689 | |
1687 | void |
1690 | void |
|
|
1691 | rxvt_term::set_urgency (bool enable) |
|
|
1692 | { |
|
|
1693 | if (enable == urgency_hint) |
|
|
1694 | return; |
|
|
1695 | |
|
|
1696 | if (XWMHints *h = XGetWMHints (dpy, parent[0])) |
|
|
1697 | { |
|
|
1698 | h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); |
|
|
1699 | XSetWMHints (dpy, parent[0], h); |
|
|
1700 | urgency_hint = enable; |
|
|
1701 | } |
|
|
1702 | } |
|
|
1703 | |
|
|
1704 | void |
1688 | rxvt_term::focus_in () |
1705 | rxvt_term::focus_in () |
1689 | { |
1706 | { |
1690 | if (!focus) |
1707 | if (!focus) |
1691 | { |
1708 | { |
1692 | focus = 1; |
1709 | focus = 1; |
1693 | want_refresh = 1; |
1710 | want_refresh = 1; |
1694 | |
|
|
1695 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1696 | |
1711 | |
1697 | #if USE_XIM |
1712 | #if USE_XIM |
1698 | if (Input_Context != NULL) |
1713 | if (Input_Context != NULL) |
1699 | { |
1714 | { |
1700 | IMSetPosition (); |
1715 | IMSetPosition (); |
… | |
… | |
1712 | scr_recolour (); |
1727 | scr_recolour (); |
1713 | } |
1728 | } |
1714 | #endif |
1729 | #endif |
1715 | #if ENABLE_FRILLS |
1730 | #if ENABLE_FRILLS |
1716 | if (option (Opt_urgentOnBell)) |
1731 | if (option (Opt_urgentOnBell)) |
1717 | { |
1732 | set_urgency (0); |
1718 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1719 | { |
|
|
1720 | h->flags &= ~XUrgencyHint; |
|
|
1721 | XSetWMHints (dpy, parent[0], h); |
|
|
1722 | } |
|
|
1723 | } |
|
|
1724 | #endif |
1733 | #endif |
|
|
1734 | |
|
|
1735 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1725 | } |
1736 | } |
1726 | } |
1737 | } |
1727 | |
1738 | |
1728 | void |
1739 | void |
1729 | rxvt_term::focus_out () |
1740 | rxvt_term::focus_out () |
… | |
… | |
1731 | if (focus) |
1742 | if (focus) |
1732 | { |
1743 | { |
1733 | focus = 0; |
1744 | focus = 0; |
1734 | want_refresh = 1; |
1745 | want_refresh = 1; |
1735 | |
1746 | |
1736 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1747 | #if ENABLE_FRILLS |
1737 | |
1748 | if (option (Opt_urgentOnBell)) |
|
|
1749 | set_urgency (0); |
|
|
1750 | #endif |
1738 | #if ENABLE_FRILLS || ISO_14755 |
1751 | #if ENABLE_FRILLS || ISO_14755 |
1739 | if (iso14755buf) |
1752 | if (iso14755buf) |
1740 | { |
1753 | { |
1741 | iso14755buf = 0; |
1754 | iso14755buf = 0; |
1742 | # if ISO_14755 |
1755 | # if ISO_14755 |
… | |
… | |
1759 | { |
1772 | { |
1760 | pix_colors = pix_colors_unfocused; |
1773 | pix_colors = pix_colors_unfocused; |
1761 | scr_recolour (); |
1774 | scr_recolour (); |
1762 | } |
1775 | } |
1763 | #endif |
1776 | #endif |
|
|
1777 | |
|
|
1778 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1764 | } |
1779 | } |
1765 | } |
1780 | } |
1766 | |
1781 | |
1767 | void |
1782 | void |
1768 | rxvt_term::update_fade_color (unsigned int idx) |
1783 | rxvt_term::update_fade_color (unsigned int idx) |
… | |
… | |
2179 | wchar_t ch = NOCHAR; |
2194 | wchar_t ch = NOCHAR; |
2180 | char *seq_begin; // remember start of esc-sequence here |
2195 | char *seq_begin; // remember start of esc-sequence here |
2181 | |
2196 | |
2182 | for (;;) |
2197 | for (;;) |
2183 | { |
2198 | { |
2184 | if (ch == NOCHAR) |
2199 | if (expect_false (ch == NOCHAR)) |
2185 | { |
2200 | { |
2186 | seq_begin = cmdbuf_ptr; |
2201 | seq_begin = cmdbuf_ptr; |
2187 | ch = next_char (); |
2202 | ch = next_char (); |
2188 | |
2203 | |
2189 | if (ch == NOCHAR) |
2204 | if (ch == NOCHAR) |
2190 | break; |
2205 | break; |
2191 | } |
2206 | } |
2192 | |
2207 | |
2193 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2208 | if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) |
2194 | { |
2209 | { |
2195 | if (!seen_input) |
2210 | if (expect_false (!seen_input)) |
2196 | { |
2211 | { |
2197 | seen_input = 1; |
2212 | seen_input = 1; |
2198 | // many badly-written programs (e.g. jed) contain a race condition: |
2213 | // many badly-written programs (e.g. jed) contain a race condition: |
2199 | // they first read the screensize and then install a SIGWINCH handler. |
2214 | // they first read the screensize and then install a SIGWINCH handler. |
2200 | // some window managers resize the window early, and these programs |
2215 | // some window managers resize the window early, and these programs |
… | |
… | |
2213 | wchar_t *str = buf; |
2228 | wchar_t *str = buf; |
2214 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2229 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2215 | |
2230 | |
2216 | for (;;) |
2231 | for (;;) |
2217 | { |
2232 | { |
2218 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2233 | if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) |
2219 | break; |
2234 | break; |
2220 | |
2235 | |
2221 | *str++ = ch; |
2236 | *str++ = ch; |
2222 | |
2237 | |
2223 | if (ch == C0_LF || str >= eol) |
2238 | if (expect_false (ch == C0_LF || str >= eol)) |
2224 | { |
2239 | { |
2225 | if (ch == C0_LF) |
2240 | if (ch == C0_LF) |
2226 | nlines++; |
2241 | nlines++; |
2227 | |
2242 | |
2228 | refresh_count++; |
2243 | refresh_count++; |
… | |
… | |
2310 | rxvt_term::next_char () NOTHROW |
2325 | rxvt_term::next_char () NOTHROW |
2311 | { |
2326 | { |
2312 | while (cmdbuf_ptr < cmdbuf_endp) |
2327 | while (cmdbuf_ptr < cmdbuf_endp) |
2313 | { |
2328 | { |
2314 | // assume 7-bit to be ascii ALWAYS |
2329 | // assume 7-bit to be ascii ALWAYS |
2315 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2330 | if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) |
2316 | return *cmdbuf_ptr++; |
2331 | return *cmdbuf_ptr++; |
2317 | |
2332 | |
2318 | wchar_t wc; |
2333 | wchar_t wc; |
2319 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2334 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2320 | |
2335 | |
… | |
… | |
2381 | /*----------------------------------------------------------------------*/ |
2396 | /*----------------------------------------------------------------------*/ |
2382 | #ifdef PRINTPIPE |
2397 | #ifdef PRINTPIPE |
2383 | FILE * |
2398 | FILE * |
2384 | rxvt_term::popen_printer () |
2399 | rxvt_term::popen_printer () |
2385 | { |
2400 | { |
2386 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2401 | FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); |
2387 | |
2402 | |
2388 | if (stream == NULL) |
2403 | if (stream == NULL) |
2389 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2404 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2390 | |
2405 | |
2391 | return stream; |
2406 | return stream; |
… | |
… | |
2402 | * simulate attached vt100 printer |
2417 | * simulate attached vt100 printer |
2403 | */ |
2418 | */ |
2404 | void |
2419 | void |
2405 | rxvt_term::process_print_pipe () |
2420 | rxvt_term::process_print_pipe () |
2406 | { |
2421 | { |
2407 | int done; |
2422 | FILE *fd = popen_printer (); |
2408 | FILE *fd; |
|
|
2409 | |
2423 | |
2410 | if ((fd = popen_printer ()) == NULL) |
2424 | if (!fd) |
2411 | return; |
2425 | return; |
2412 | |
2426 | |
2413 | /* |
2427 | /* |
2414 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2428 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2415 | * is received. |
2429 | * is received. |
2416 | */ |
2430 | */ |
2417 | for (done = 0; !done;) |
2431 | for (int done = 0; !done; ) |
2418 | { |
2432 | { |
2419 | unsigned char buf[8]; |
2433 | unsigned char buf[8]; |
2420 | unicode_t ch; |
2434 | unicode_t ch; |
2421 | unsigned int i, len; |
2435 | unsigned int i, len; |
2422 | |
2436 | |
… | |
… | |
3510 | break; |
3524 | break; |
3511 | #endif |
3525 | #endif |
3512 | |
3526 | |
3513 | #if ENABLE_PERL |
3527 | #if ENABLE_PERL |
3514 | case URxvt_perl: |
3528 | case URxvt_perl: |
3515 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
3529 | HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END)); |
3516 | ; // no responses yet |
|
|
3517 | break; |
3530 | break; |
3518 | #endif |
3531 | #endif |
3519 | } |
3532 | } |
3520 | } |
3533 | } |
3521 | /*----------------------------------------------------------------------*/ |
3534 | /*----------------------------------------------------------------------*/ |