ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.4 by pcg, Tue Nov 25 15:25:16 2003 UTC vs.
Revision 1.6 by pcg, Tue Nov 25 17:11:33 2003 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: command.c 2 * File: command.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: command.C,v 1.4 2003/11/25 15:25:16 pcg Exp $ 4 * $Id: command.C,v 1.6 2003/11/25 17:11:33 pcg Exp $
5 * 5 *
6 * All portions of code are copyright by their respective author/s. 6 * All portions of code are copyright by their respective author/s.
7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
8 * - original version 8 * - original version
9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
663 do 663 do
664 { 664 {
665 XEvent xev; 665 XEvent xev;
666 666
667 XNextEvent (Xdisplay, &xev); 667 XNextEvent (Xdisplay, &xev);
668
668#if defined(CURSOR_BLINK) 669#if defined(CURSOR_BLINK)
669 if ((Options & Opt_cursorBlink) 670 if ((Options & Opt_cursorBlink)
670 && xev.type == KeyPress) { 671 && xev.type == KeyPress)
672 {
671 if (hidden_cursor) { 673 if (hidden_cursor)
674 {
672 hidden_cursor = 0; 675 hidden_cursor = 0;
673 want_refresh = 1; 676 want_refresh = 1;
674 } 677 }
675 want_keypress_time = 1; 678
679 blink_ev.start (NOW + BLINK_INTERVAL);
676 } 680 }
677#endif 681#endif
678 682
679#if defined(POINTER_BLANK) 683#if defined(POINTER_BLANK)
680 if ((Options & Opt_pointerBlank) 684 if ((Options & Opt_pointerBlank)
681 && (pointerBlankDelay > 0)) { 685 && (pointerBlankDelay > 0))
686 {
682 if (xev.type == MotionNotify 687 if (xev.type == MotionNotify
683 || xev.type == ButtonPress 688 || xev.type == ButtonPress
684 || xev.type == ButtonRelease) { 689 || xev.type == ButtonRelease)
685 if (hidden_pointer) 690 if (hidden_pointer)
686 rxvt_pointer_unblank(aR); 691 pointer_unblank ();
687 want_motion_time = 1; 692
688 }
689 if (xev.type == KeyPress && hidden_pointer == 0) 693 if (xev.type == KeyPress && hidden_pointer == 0)
690 rxvt_pointer_blank (this); 694 pointer_blank ();
691 } 695 }
692#endif 696#endif
693 697
694#ifdef USE_XIM 698#ifdef USE_XIM
695 if (!XFilterEvent (&xev, xev.xany.window)) 699 if (!XFilterEvent (&xev, xev.xany.window))
696#endif 700#endif
697 rxvt_process_x_event (this, &xev); 701 rxvt_process_x_event (this, &xev);
698 } 702 }
699 while (XPending (Xdisplay)); 703 while (XPending (Xdisplay));
704}
705
706void
707rxvt_term::blink_cb (time_watcher &w)
708{
709 w.at += BLINK_INTERVAL;
710 hidden_cursor = !hidden_cursor;
711 want_refresh = 1;
712 flush();
700} 713}
701 714
702void 715void
703rxvt_term::x_cb (io_watcher &w, short revents) 716rxvt_term::x_cb (io_watcher &w, short revents)
704{ 717{
933 fcntl (R->cmd_fd, F_SETFL, 0); 946 fcntl (R->cmd_fd, F_SETFL, 0);
934 R->pty_fill (1); 947 R->pty_fill (1);
935 fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK); 948 fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK);
936 } 949 }
937 950
951#if 0
938#define TIMEOUT_USEC 5000 952#define TIMEOUT_USEC 5000
939 fd_set readfds; 953 fd_set readfds;
940 int quick_timeout, select_res; 954 int quick_timeout, select_res;
941 int want_motion_time, want_keypress_time; 955 int want_motion_time, want_keypress_time;
942 struct timeval value; 956 struct timeval value;
947 for (;;) { 961 for (;;) {
948 /* loop until we can return something */ 962 /* loop until we can return something */
949 963
950 if (R->v_bufstr < R->v_bufptr) /* output any pending chars */ 964 if (R->v_bufstr < R->v_bufptr) /* output any pending chars */
951 rxvt_tt_write(aR_ NULL, 0); 965 rxvt_tt_write(aR_ NULL, 0);
952
953#if defined(POINTER_BLANK) || defined(CURSOR_BLINK)
954 tp.tv_sec = 0; /* presume == 0 implies time not yet retrieved */
955#endif
956#if defined(CURSOR_BLINK)
957 want_keypress_time = 0;
958#endif
959#if defined(POINTER_BLANK)
960 want_motion_time = 0;
961#endif
962
963 if (XPending (R->Xdisplay))
964 {
965 R->process_x_events ();
966
967 /* in case button actions pushed chars to cmdbuf */
968 if (R->cmdbuf_ptr < R->cmdbuf_endp)
969 return *R->cmdbuf_ptr++;
970 }
971
972#if defined(CURSOR_BLINK)
973 if (want_keypress_time) {
974 (void)gettimeofday(&tp, NULL);
975 R->lastcursorchange.tv_sec = tp.tv_sec;
976 R->lastcursorchange.tv_usec = tp.tv_usec;
977 }
978#endif
979#if defined(POINTER_BLANK)
980 if (want_motion_time) {
981 if (!tp.tv_sec)
982 (void)gettimeofday(&tp, NULL);
983 R->lastmotion.tv_sec = tp.tv_sec;
984 R->lastmotion.tv_usec = tp.tv_usec;
985 }
986#endif
987
988/*
989 * the command input buffer is empty and we have no pending X events
990 */
991 quick_timeout = 0;
992 966
993#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 967#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
994 if (R->mouse_slip_wheel_speed) { 968 if (R->mouse_slip_wheel_speed) {
995 quick_timeout = 1; 969 quick_timeout = 1;
996 if (!R->mouse_slip_wheel_delay-- 970 if (!R->mouse_slip_wheel_delay--
1026 R->want_refresh = 1; 1000 R->want_refresh = 1;
1027 } 1001 }
1028 } 1002 }
1029#endif /* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */ 1003#endif /* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */
1030 1004
1031 FD_ZERO(&readfds);
1032 FD_SET(R->cmd_fd, &readfds);
1033 FD_SET(R->Xfd, &readfds);
1034 value.tv_usec = TIMEOUT_USEC;
1035 value.tv_sec = 0;
1036
1037 if (!R->TermWin.mapped)
1038 quick_timeout = 0;
1039 else {
1040 quick_timeout |= R->want_refresh;
1041#ifdef TRANSPARENT 1005#ifdef TRANSPARENT
1042 quick_timeout |= R->want_full_refresh; 1006 quick_timeout |= R->want_full_refresh;
1043#endif 1007#endif
1044 }
1045
1046#if defined(POINTER_BLANK) || defined(CURSOR_BLINK)
1047 {
1048 int set_quick_timeout = 0;
1049 long csdiff, psdiff;
1050
1051#define BLINK_TIME 500000L
1052 csdiff = psdiff = 60000000L; /* or, say, LONG_MAX */
1053# if defined(CURSOR_BLINK)
1054 if (R->Options & Opt_cursorBlink) {
1055 if (!tp.tv_sec) /* didn't get it before so get it now */
1056 (void)gettimeofday(&tp, NULL);
1057
1058 csdiff = (tp.tv_sec - R->lastcursorchange.tv_sec) * 1000000L
1059 + tp.tv_usec - R->lastcursorchange.tv_usec;
1060 if (csdiff > BLINK_TIME) { /* XXX: settable blink times */
1061 R->lastcursorchange.tv_sec = tp.tv_sec;
1062 R->lastcursorchange.tv_usec = tp.tv_usec;
1063 R->hidden_cursor = !R->hidden_cursor;
1064 csdiff = 0;
1065 } else
1066 csdiff = BLINK_TIME - csdiff;
1067 set_quick_timeout = 1;
1068 }
1069# endif 1008#endif
1009}
1010
1070# if defined(POINTER_BLANK) 1011#ifdef POINTER_BLANK
1071 /*
1072 * If we haven't moved the pointer for a while
1073 */
1074 if ((R->Options & Opt_pointerBlank)
1075 && (R->pointerBlankDelay > 0)
1076 && (R->hidden_pointer == 0)) {
1077 long pdelay;
1078
1079 if (!tp.tv_sec) /* didn't get it before so get it now */
1080 (void)gettimeofday(&tp, NULL);
1081 psdiff = (tp.tv_sec - R->lastmotion.tv_sec) * 1000000L
1082 + tp.tv_usec - R->lastmotion.tv_usec;
1083 pdelay = R->pointerBlankDelay * 1000000L;
1084 if (psdiff >= pdelay)
1085 rxvt_pointer_blank(aR);
1086 else {
1087 set_quick_timeout = 1;
1088 psdiff = pdelay - psdiff;
1089 }
1090 }
1091# endif
1092 if (!quick_timeout && set_quick_timeout) {
1093 MIN_IT(csdiff, psdiff);
1094 value.tv_sec = csdiff / 1000000L;
1095 value.tv_usec = csdiff % 1000000L;
1096 quick_timeout = 1;
1097 }
1098 }
1099#endif
1100
1101 if ((select_res = select(R->num_fds, &readfds, NULL, NULL,
1102 (quick_timeout ? &value : NULL))) == 0) {
1103 /* select statement timed out - we're not hard and fast scrolling */
1104 R->refresh_limit = 1;
1105 }
1106#if defined(CURSOR_BLINK)
1107 if (R->Options & Opt_cursorBlink)
1108 R->want_refresh = 1;
1109#endif
1110 }
1111}
1112
1113/* EXTPROTO */
1114void 1012void
1115rxvt_pointer_unblank(pR) 1013rxvt_term::pointer_unblank ()
1116{ 1014{
1015 if (!(Options & Opt_pointerBlank))
1016 return;
1017
1117 XDefineCursor(R->Xdisplay, R->TermWin.vt, R->TermWin_cursor); 1018 XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor);
1118 rxvt_recolour_cursor(aR); 1019 rxvt_recolour_cursor (this);
1119#ifdef POINTER_BLANK
1120 R->hidden_pointer = 0; 1020 hidden_pointer = 0;
1121 if (R->pointerBlankDelay > 0) {
1122 struct timeval tp;
1123 1021
1124 (void)gettimeofday(&tp, NULL); 1022 pointer_ev.start (NOW + pointerBlankDelay);
1125 R->lastmotion.tv_sec = tp.tv_sec;
1126 R->lastmotion.tv_usec = tp.tv_usec;
1127 }
1128#endif
1129} 1023}
1130 1024
1131#ifdef POINTER_BLANK
1132/* INTPROTO */
1133void 1025void
1134rxvt_pointer_blank(pR) 1026rxvt_term::pointer_blank ()
1135{ 1027{
1028 pointer_ev.stop ();
1029
1030 if (!(Options & Opt_pointerBlank))
1031 return;
1032
1136 XDefineCursor(R->Xdisplay, R->TermWin.vt, R->pointer_blank); 1033 XDefineCursor (Xdisplay, TermWin.vt, blank_cursor);
1137 XFlush(R->Xdisplay); 1034 XFlush (Xdisplay);
1035
1138 R->hidden_pointer = 1; 1036 hidden_pointer = 1;
1037}
1038
1039void
1040rxvt_term::pointer_cb (time_watcher &w)
1041{
1042 pointer_blank ();
1139} 1043}
1140#endif 1044#endif
1141 1045
1142/* INTPROTO */ 1046/* INTPROTO */
1143void 1047void
1405 R->want_refresh = 1; 1309 R->want_refresh = 1;
1406#ifdef USE_XIM 1310#ifdef USE_XIM
1407 if (R->Input_Context != NULL) 1311 if (R->Input_Context != NULL)
1408 XSetICFocus(R->Input_Context); 1312 XSetICFocus(R->Input_Context);
1409#endif 1313#endif
1314#ifdef CURSOR_BLINK
1315 if (R->Options & Opt_cursorBlink)
1316 R->blink_ev.start (NOW + BLINK_INTERVAL);
1317#endif
1410 } 1318 }
1411 break; 1319 break;
1412 1320
1413 case FocusOut: 1321 case FocusOut:
1414 if (R->TermWin.focus) { 1322 if (R->TermWin.focus) {
1415 R->TermWin.focus = 0; 1323 R->TermWin.focus = 0;
1416 R->want_refresh = 1; 1324 R->want_refresh = 1;
1417#ifdef USE_XIM 1325#ifdef USE_XIM
1418 if (R->Input_Context != NULL) 1326 if (R->Input_Context != NULL)
1419 XUnsetICFocus(R->Input_Context); 1327 XUnsetICFocus(R->Input_Context);
1328#endif
1329#ifdef CURSOR_BLINK
1330 if (R->Options & Opt_cursorBlink)
1331 R->blink_ev.stop ();
1332 R->hidden_cursor = 0;
1420#endif 1333#endif
1421 } 1334 }
1422 break; 1335 break;
1423 1336
1424 case ConfigureNotify: 1337 case ConfigureNotify:
1537 break; 1450 break;
1538 1451
1539 case MotionNotify: 1452 case MotionNotify:
1540#ifdef POINTER_BLANK 1453#ifdef POINTER_BLANK
1541 if (R->hidden_pointer) 1454 if (R->hidden_pointer)
1542 rxvt_pointer_unblank(aR); 1455 R->pointer_unblank ();
1543#endif 1456#endif
1544#if MENUBAR 1457#if MENUBAR
1545 if (isMenuBarWindow(ev->xany.window)) { 1458 if (isMenuBarWindow(ev->xany.window)) {
1546 rxvt_menubar_control(aR_ &(ev->xbutton)); 1459 rxvt_menubar_control(aR_ &(ev->xbutton));
1547 break; 1460 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines