--- rxvt-unicode/src/command.C 2007/09/18 22:27:41 1.358 +++ rxvt-unicode/src/command.C 2007/11/11 04:08:00 1.363 @@ -598,10 +598,10 @@ break; #ifdef XK_KP_Left + case XK_KP_Left: /* \033Ot or standard */ case XK_KP_Up: /* \033Ox or standard */ - case XK_KP_Down: /* \033Or or standard */ case XK_KP_Right: /* \033Ov or standard */ - case XK_KP_Left: /* \033Ot or standard */ + case XK_KP_Down: /* \033Or or standard */ if (kp) { strcpy (kbuf, "\033OZ"); @@ -1036,8 +1036,8 @@ rxvt_term::flush () { flush_ev.stop (); - -#ifdef HAVE_BG_PIXMAP + +#ifdef HAVE_BG_PIXMAP if (bgPixmap.check_clearChanged ()) { // scr_clear (true); This needs to be researched further! @@ -1096,18 +1096,18 @@ } void -rxvt_term::check_cb (check_watcher &w) +rxvt_term::prepare_cb (ev::prepare &w, int revents) { make_current (); display->flush (); if (want_refresh && !flush_ev.active) - flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally + flush_ev.start (1. / 60.); // refresh at max. 60 hz normally } void -rxvt_term::flush_cb (time_watcher &w) +rxvt_term::flush_cb (ev::timer &w, int revents) { make_current (); @@ -1117,57 +1117,54 @@ #ifdef CURSOR_BLINK void -rxvt_term::cursor_blink_cb (time_watcher &w) +rxvt_term::cursor_blink_cb (ev::timer &w, int revents) { hidden_cursor = !hidden_cursor; want_refresh = 1; - - w.start (w.at + CURSOR_BLINK_INTERVAL); } #endif #ifdef TEXT_BLINK void -rxvt_term::text_blink_cb (time_watcher &w) +rxvt_term::text_blink_cb (ev::timer &w, int revents) { if (scr_refresh_rend (RS_Blink, RS_Blink)) { hidden_text = !hidden_text; want_refresh = 1; - w.start (w.at + TEXT_BLINK_INTERVAL); } } #endif #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING void -rxvt_term::cont_scroll_cb (time_watcher &w) +rxvt_term::cont_scroll_cb (ev::timer &w, int revents) { if ((scrollbar_isUp() || scrollbar_isDn()) && scr_page (scrollbar_isUp() ? UP : DN, 1)) - { - want_refresh = 1; - w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); - } + want_refresh = 1; + else + w.stop (); } #endif #ifdef SELECTION_SCROLLING void -rxvt_term::sel_scroll_cb (time_watcher &w) +rxvt_term::sel_scroll_cb (ev::timer &w, int revents) { if (scr_page (scroll_selection_dir, scroll_selection_lines)) { selection_extend (selection_save_x, selection_save_y, selection_save_state); want_refresh = 1; - w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); } + else + w.stop (); } #endif #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) void -rxvt_term::slip_wheel_cb (time_watcher &w) +rxvt_term::slip_wheel_cb (ev::timer &w, int revents) { if (mouse_slip_wheel_speed == 0 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) @@ -1177,17 +1174,18 @@ mouse_slip_wheel_speed = 0; want_refresh = 1; - w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); } + else + w.stop (); } #endif #if LINUX_YIELD_HACK static struct event_handler { - check_watcher yield_ev; + ev::prepare yield_ev; - void yield_cb (check_watcher &w) + void yield_cb (ev::prepare &w, int revents) { // this should really be sched_yield(), but the linux guys thought // that giving a process calling sched_yield () less cpu time than @@ -1248,17 +1246,17 @@ } void -rxvt_term::pty_cb (io_watcher &w, short revents) +rxvt_term::pty_cb (ev::io &w, int revents) { make_current (); - if (revents & EVENT_READ) + if (revents & ev::READ) // loop, but don't allow a single term to monopolize us while (pty_fill ()) if (cmd_parse ()) break; - if (revents & EVENT_WRITE) + if (revents & ev::WRITE) pty_write (); } @@ -1272,7 +1270,7 @@ hidden_pointer = 0; if (option (Opt_pointerBlank)) - pointer_ev.start (NOW + pointerBlankDelay); + pointer_ev.start (pointerBlankDelay); #endif } @@ -1290,7 +1288,7 @@ } void -rxvt_term::pointer_cb (time_watcher &w) +rxvt_term::pointer_cb (ev::timer &w, int revents) { make_current (); @@ -1303,10 +1301,17 @@ { int button_number, key_state = 0; int x, y; + int code = 32; - x = ev.x; - y = ev.y; - pixel_position (&x, &y); + x = Pixel2Col (ev.x); + y = Pixel2Row (ev.y); + if (ev.type == MotionNotify) { + if (x == mouse_row && y == mouse_col) + return; + mouse_row = x; + mouse_col = y; + code += 32; + } if (MEvent.button == AnyButton) button_number = 3; @@ -1362,7 +1367,7 @@ #endif tt_printf ("\033[M%c%c%c", - (32 + button_number + key_state), + (code + button_number + key_state), (32 + x + 1), (32 + y + 1)); } @@ -1524,7 +1529,7 @@ case MapNotify: mapped = 1; #ifdef TEXT_BLINK - text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); + text_blink_ev.start (TEXT_BLINK_INTERVAL); #endif HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); break; @@ -1579,6 +1584,9 @@ if (hidden_pointer) pointer_unblank (); #endif + if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) + || priv_modes & PrivMode_MouseAnyEvent) + mouse_report (ev.xbutton); if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) break; @@ -1623,7 +1631,7 @@ * already in the middle of scrolling. */ if (!sel_scroll_ev.active) - sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); + sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); /* save the event params so we can highlight * the selection in the pending-scroll loop @@ -1692,7 +1700,7 @@ want_refresh = 1; } - cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); + cursor_blink_ev.again (); } #endif @@ -1730,7 +1738,7 @@ #endif #if CURSOR_BLINK if (option (Opt_cursorBlink)) - cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); + cursor_blink_ev.start (CURSOR_BLINK_INTERVAL, CURSOR_BLINK_INTERVAL); #endif #if OFF_FOCUS_FADING if (rs[Rs_fade]) @@ -1778,6 +1786,7 @@ #if CURSOR_BLINK if (option (Opt_cursorBlink)) cursor_blink_ev.stop (); + hidden_cursor = 0; #endif #if OFF_FOCUS_FADING @@ -2020,7 +2029,7 @@ if (upordown) { #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); + cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); #endif if (scr_page (upordown < 0 ? UP : DN, 1)) { @@ -2193,10 +2202,7 @@ if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; - if (slip_wheel_ev.at < NOW) - slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; - - slip_wheel_ev.start (); + slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); } else { @@ -2274,7 +2280,7 @@ { refresh_count = 0; - if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.) + if (!option (Opt_skipScroll) || ev::ev_time () > ev::now () + 1. / 60.) { refreshnow = true; ch = NOCHAR; @@ -2851,10 +2857,10 @@ // 'U' for rxvt-unicode != 7.[34] (where it was broken). // // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt - // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify - // that we do not support xterm mouse reporting (should be 95 when we do). + // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later + // versions. // - tt_printf ("\033[>%d;94;0c", 'U'); + tt_printf ("\033[>%d;95;0c", 'U'); } break; case '?': @@ -3629,8 +3635,8 @@ #endif { 1000, PrivMode_MouseX11 }, // 1001 Use Hilite Mouse Tracking. NYI, TODO - // 1002 Use Cell Motion Mouse Tracking. NYI, TODO - // 1003 Use All Motion Mouse Tracking. NYI, TODO + { 1002, PrivMode_MouseBtnEvent }, + { 1003, PrivMode_MouseAnyEvent }, { 1010, PrivMode_TtyOutputInh }, // rxvt extension { 1011, PrivMode_Keypress }, // rxvt extension // 1035 enable modifiers for alt, numlock NYI @@ -3714,7 +3720,7 @@ /* case 8: - auto repeat, can't do on a per window basis */ case 9: /* X10 mouse reporting */ if (state) /* orthogonal */ - priv_modes &= ~PrivMode_MouseX11; + priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); break; #ifdef scrollBar_esc case scrollBar_esc: @@ -3737,12 +3743,22 @@ /* case 67: - backspace key */ case 1000: /* X11 mouse reporting */ if (state) /* orthogonal */ - priv_modes &= ~PrivMode_MouseX10; + priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); break; #if 0 case 1001: break; /* X11 mouse highlighting */ #endif + case 1002: + case 1003: + if (state) { + priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); + priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; + vt_emask_mouse = PointerMotionMask; + } else + vt_emask_mouse = NoEventMask; + vt_select_input (); + break; case 1010: /* scroll to bottom on TTY output inhibit */ set_option (Opt_scrollTtyOutput, !state); break; @@ -3989,7 +4005,7 @@ memcpy (v_buffer + v_buflen, data, len); v_buflen += len; - pty_ev.set (EVENT_READ | EVENT_WRITE); + pty_ev.set (ev::READ | ev::WRITE); } void rxvt_term::pty_write () @@ -4005,14 +4021,14 @@ free (v_buffer); v_buffer = 0; - pty_ev.set (EVENT_READ); + pty_ev.set (ev::READ); return; } memmove (v_buffer, v_buffer + written, v_buflen); } else if (written != -1 || (errno != EAGAIN && errno != EINTR)) - pty_ev.set (EVENT_READ); + pty_ev.set (ev::READ); } /*----------------------- end-of-file (C source) -----------------------*/