--- rxvt-unicode/src/command.C 2005/12/31 17:16:17 1.219 +++ rxvt-unicode/src/command.C 2006/01/04 01:16:34 1.233 @@ -45,11 +45,17 @@ *----------------------------------------------------------------------*/ /*{{{ includes: */ -#include "../config.h" /* NECESSARY */ -#include "rxvt.h" /* NECESSARY */ +#include "../config.h" +#include "rxvt.h" +#include "rxvtperl.h" #include "version.h" #include "command.h" +#if HAVE_SCHED_YIELD +#undef HAVE_SCHED_YIELD // disabled for the time being +//# include +#endif + #ifdef KEYSYM_RESOURCE # include "keyboard.h" #endif @@ -157,12 +163,10 @@ x--; } } -#endif void rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) { -#if ENABLE_OVERLAY rxvt_fontset *fs = FONTSET (r); rxvt_font *f = (*fs)[fs->find_font (ch)]; wchar_t *chr, *alloc, ch2, *fname; @@ -240,8 +244,8 @@ if (alloc) delete [] alloc; # endif -#endif } +#endif void rxvt_term::commit_iso14755 () @@ -984,7 +988,7 @@ display->flush (); if (want_refresh && !flush_ev.active) - flush_ev.start (NOW + 0.01); + flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally } void @@ -1069,6 +1073,24 @@ } #endif +#if HAVE_SCHED_YIELD +static struct event_handler +{ + check_watcher cw_yield; + + void yield (check_watcher &w) + { + sched_yield (); + w.stop (); + } + + event_handler () + : cw_yield (this, &event_handler::yield) + { + } +} event_handler; +#endif + bool rxvt_term::pty_fill () { @@ -1076,7 +1098,7 @@ if (CBUFSIZ == n) { - rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); + rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); n = 0; } @@ -1084,14 +1106,21 @@ cmdbuf_ptr = cmdbuf_base; cmdbuf_endp = cmdbuf_ptr + n; - n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); + ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); - if (n > 0) + if (r > 0) { - cmdbuf_endp += n; + cmdbuf_endp += r; return true; } - else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) + else if (r < 0 && (errno == EAGAIN || errno == EINTR)) + { +#if HAVE_SCHED_YIELD + if (display->is_local) + event_handler.cw_yield.start (); +#endif + } + else { pty_ev.stop (); @@ -1674,6 +1703,9 @@ { focus = 1; want_refresh = 1; + + PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); + #if USE_XIM if (Input_Context != NULL) { @@ -1703,11 +1735,16 @@ focus = 0; want_refresh = 1; + PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); + #if ENABLE_FRILLS || ISO_14755 - iso14755buf = 0; -#endif -#if ENABLE_OVERLAY - scr_overlay_off (); + if (iso14755buf) + { + iso14755buf = 0; +# if ENABLE_OVERLAY + scr_overlay_off (); +# endif + } #endif #if USE_XIM if (Input_Context != NULL) @@ -1761,6 +1798,7 @@ int reportmode = 0, clickintime; bypass_keystate = ev.state & (ModMetaMask | ShiftMask); + if (!bypass_keystate) reportmode = !! (priv_modes & PrivMode_mouse_report); @@ -1819,48 +1857,49 @@ if (ev.button != MEvent.button) MEvent.clicks = 0; - switch (ev.button) - { - case Button1: - /* allow meta + click to select rectangular areas */ - /* should be done in screen.C */ + if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) + switch (ev.button) + { + case Button1: + /* allow meta + click to select rectangular areas */ + /* should be done in screen.C */ #if ENABLE_FRILLS - selection.rect = !!(ev.state & ModMetaMask); + selection.rect = !!(ev.state & ModMetaMask); #else - selection.rect = false; + selection.rect = false; #endif - /* allow shift+left click to extend selection */ - if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) - { - if (MEvent.button == Button1 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); - } - else - { - if (MEvent.button == Button1 && clickintime) - MEvent.clicks++; - else - MEvent.clicks = 1; + /* allow shift+left click to extend selection */ + if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) + { + if (MEvent.button == Button1 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); + } + else + { + if (MEvent.button == Button1 && clickintime) + MEvent.clicks++; + else + MEvent.clicks = 1; - selection_click (MEvent.clicks, ev.x, ev.y); - } + selection_click (MEvent.clicks, ev.x, ev.y); + } - MEvent.button = Button1; - break; + MEvent.button = Button1; + break; - case Button3: - if (MEvent.button == Button3 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); + case Button3: + if (MEvent.button == Button3 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); - MEvent.button = Button3; - break; - } - } + MEvent.button = Button3; + break; + } + } MEvent.time = ev.time; return; @@ -2688,6 +2727,7 @@ || (refresh_count >= refresh_limit * (nrow - 1))) { refreshnow = true; + refresh_count = 0; ch = NOCHAR; break; } @@ -2734,6 +2774,7 @@ { flag = true; scr_refresh (refresh_type); + flush_ev.stop (); } } @@ -3923,17 +3964,24 @@ case URxvt_view_up: case URxvt_view_down: - int lines = atoi (str); + { + int lines = atoi (str); - if (lines) - scr_page (op == URxvt_view_up ? UP : DN, lines); - else - { + if (lines) + scr_page (op == URxvt_view_up ? UP : DN, lines); + else scr_erase_savelines (); - } + } break; #endif + +#if ENABLE_PERL + case URxvt_perl: + if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) + ; // no responses yet + break; +#endif } } /*----------------------------------------------------------------------*/ @@ -4050,6 +4098,16 @@ /* extra handling for values with state unkept */ switch (arg[i]) { +#if ENABLE_STYLES + case 1021: + if (mode) + SET_OPTION (Opt_intensityStyles); + else + CLR_OPTION (Opt_intensityStyles); + + scr_touch (true); + break; +#endif case 1048: /* alternative cursor save */ case 1049: if (OPTION (Opt_secondaryScreen)) @@ -4142,13 +4200,6 @@ else CLR_OPTION (Opt_scrollTtyKeypress); break; -#if ENABLE_STYLES - case 1021: - if (state) - SET_OPTION (Opt_intensityStyles); - else - CLR_OPTION (Opt_intensityStyles); -#endif case 1047: /* secondary screen w/ clearing last */ if (OPTION (Opt_secondaryScreen)) if (current_screen != PRIMARY) @@ -4317,7 +4368,6 @@ scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); break; #endif - } } }