--- rxvt-unicode/src/command.C 2003/11/25 17:11:33 1.6 +++ rxvt-unicode/src/command.C 2003/11/27 10:12:10 1.9 @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: command.c *----------------------------------------------------------------------* - * $Id: command.C,v 1.6 2003/11/25 17:11:33 pcg Exp $ + * $Id: command.C,v 1.9 2003/11/27 10:12:10 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -706,15 +706,19 @@ void rxvt_term::blink_cb (time_watcher &w) { + SET_R (this); + w.at += BLINK_INTERVAL; hidden_cursor = !hidden_cursor; want_refresh = 1; - flush(); + flush (); } void rxvt_term::x_cb (io_watcher &w, short revents) { + SET_R (this); + process_x_events (); flush (); @@ -776,7 +780,7 @@ } bool -rxvt_term::pty_fill (size_t count) +rxvt_term::pty_fill () { ssize_t n = cmdbuf_endp - cmdbuf_ptr; @@ -784,7 +788,7 @@ cmdbuf_ptr = cmdbuf_base; cmdbuf_endp = cmdbuf_ptr + n; - n = read (cmd_fd, cmdbuf_endp, count); + n = read (cmd_fd, cmdbuf_endp, BUFSIZ - n); if (n > 0) { @@ -794,15 +798,19 @@ else if (n < 0 && errno == EAGAIN) return false; - rxvt_clean_exit(); - exit(EXIT_FAILURE); /* bad order of events? */ + destroy (); } void rxvt_term::pty_cb (io_watcher &w, short revents) { - while (pty_fill (BUFSIZ - (cmdbuf_endp - cmdbuf_ptr))) + SET_R (this); + + // loop, but don't allow a single term to monopolize us + // the number of loops is fully arbitrary, and thus wrong + for (int i = 7; i-- && pty_fill (); ) { + //TODO: /* once we know the shell is running, send the screen size. Again! */ //ch = rxvt_cmd_getc(aR); /* wait for something */ //rxvt_tt_winsize(cmd_fd, TermWin.ncol, TermWin.nrow, cmd_pid); @@ -923,7 +931,9 @@ #endif } + if (XPending (Xdisplay)) process_x_events (); XFlush (Xdisplay); + if (XPending (Xdisplay)) process_x_events (); } /* rxvt_cmd_getc() - Return next input character */ @@ -944,7 +954,7 @@ // incomplete sequences should occur rarely, still, a better solution // would be preferred. either setjmp/longjmp or better design. fcntl (R->cmd_fd, F_SETFL, 0); - R->pty_fill (1); + R->pty_fill (); fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK); } @@ -1008,20 +1018,21 @@ #endif } -#ifdef POINTER_BLANK void rxvt_term::pointer_unblank () { - if (!(Options & Opt_pointerBlank)) - return; - XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor); rxvt_recolour_cursor (this); + +#ifdef POINTER_BLANK hidden_pointer = 0; - pointer_ev.start (NOW + pointerBlankDelay); + if (Options & Opt_pointerBlank) + pointer_ev.start (NOW + pointerBlankDelay); +#endif } +#ifdef POINTER_BLANK void rxvt_term::pointer_blank () { @@ -1039,6 +1050,8 @@ void rxvt_term::pointer_cb (time_watcher &w) { + SET_R (this); + pointer_blank (); } #endif @@ -1245,10 +1258,10 @@ case ClientMessage: if (ev->xclient.format == 32 && (Atom)ev->xclient.data.l[0] == R->xa[XA_WMDELETEWINDOW]) - exit(EXIT_SUCCESS); + R->destroy (); #ifdef OFFIX_DND /* OffiX Dnd (drag 'n' drop) protocol */ - if (ev->xclient.message_type == R->xa[XA_DNDPROTOCOL] + else if (ev->xclient.message_type == R->xa[XA_DNDPROTOCOL] && (ev->xclient.data.l[0] == DndFile || ev->xclient.data.l[0] == DndDir || ev->xclient.data.l[0] == DndLink)) { @@ -1290,17 +1303,18 @@ * which ought to make things real slow! */ case VisibilityNotify: - switch (ev->xvisibility.state) { - case VisibilityUnobscured: - R->refresh_type = FAST_REFRESH; - break; - case VisibilityPartiallyObscured: - R->refresh_type = SLOW_REFRESH; - break; - default: - R->refresh_type = NO_REFRESH; - break; - } + switch (ev->xvisibility.state) + { + case VisibilityUnobscured: + R->refresh_type = FAST_REFRESH; + break; + case VisibilityPartiallyObscured: + R->refresh_type = SLOW_REFRESH; + break; + default: + R->refresh_type = NO_REFRESH; + break; + } break; case FocusIn: