1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: command.c |
2 | * File: command.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: command.C,v 1.5 2003/11/25 15:44:38 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> |
… | |
… | |
666 | |
666 | |
667 | XNextEvent (Xdisplay, &xev); |
667 | XNextEvent (Xdisplay, &xev); |
668 | |
668 | |
669 | #if defined(CURSOR_BLINK) |
669 | #if defined(CURSOR_BLINK) |
670 | if ((Options & Opt_cursorBlink) |
670 | if ((Options & Opt_cursorBlink) |
671 | && xev.type == KeyPress) { |
671 | && xev.type == KeyPress) |
|
|
672 | { |
672 | if (hidden_cursor) { |
673 | if (hidden_cursor) |
|
|
674 | { |
673 | hidden_cursor = 0; |
675 | hidden_cursor = 0; |
674 | want_refresh = 1; |
676 | want_refresh = 1; |
675 | } |
677 | } |
|
|
678 | |
676 | blink_ev.start (NOW + BLINK_INTERVAL); |
679 | blink_ev.start (NOW + BLINK_INTERVAL); |
677 | } |
680 | } |
678 | #endif |
681 | #endif |
679 | |
682 | |
680 | #if defined(POINTER_BLANK) |
683 | #if defined(POINTER_BLANK) |
681 | if ((Options & Opt_pointerBlank) |
684 | if ((Options & Opt_pointerBlank) |
682 | && (pointerBlankDelay > 0)) { |
685 | && (pointerBlankDelay > 0)) |
|
|
686 | { |
683 | if (xev.type == MotionNotify |
687 | if (xev.type == MotionNotify |
684 | || xev.type == ButtonPress |
688 | || xev.type == ButtonPress |
685 | || xev.type == ButtonRelease) { |
689 | || xev.type == ButtonRelease) |
686 | if (hidden_pointer) |
690 | if (hidden_pointer) |
687 | rxvt_pointer_unblank(aR); |
691 | pointer_unblank (); |
688 | want_motion_time = 1; |
692 | |
689 | } |
|
|
690 | if (xev.type == KeyPress && hidden_pointer == 0) |
693 | if (xev.type == KeyPress && hidden_pointer == 0) |
691 | rxvt_pointer_blank (this); |
694 | pointer_blank (); |
692 | } |
695 | } |
693 | #endif |
696 | #endif |
694 | |
697 | |
695 | #ifdef USE_XIM |
698 | #ifdef USE_XIM |
696 | if (!XFilterEvent (&xev, xev.xany.window)) |
699 | if (!XFilterEvent (&xev, xev.xany.window)) |
697 | #endif |
700 | #endif |
… | |
… | |
943 | fcntl (R->cmd_fd, F_SETFL, 0); |
946 | fcntl (R->cmd_fd, F_SETFL, 0); |
944 | R->pty_fill (1); |
947 | R->pty_fill (1); |
945 | fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK); |
948 | fcntl (R->cmd_fd, F_SETFL, O_NONBLOCK); |
946 | } |
949 | } |
947 | |
950 | |
|
|
951 | #if 0 |
948 | #define TIMEOUT_USEC 5000 |
952 | #define TIMEOUT_USEC 5000 |
949 | fd_set readfds; |
953 | fd_set readfds; |
950 | int quick_timeout, select_res; |
954 | int quick_timeout, select_res; |
951 | int want_motion_time, want_keypress_time; |
955 | int want_motion_time, want_keypress_time; |
952 | struct timeval value; |
956 | struct timeval value; |
… | |
… | |
957 | for (;;) { |
961 | for (;;) { |
958 | /* loop until we can return something */ |
962 | /* loop until we can return something */ |
959 | |
963 | |
960 | if (R->v_bufstr < R->v_bufptr) /* output any pending chars */ |
964 | if (R->v_bufstr < R->v_bufptr) /* output any pending chars */ |
961 | rxvt_tt_write(aR_ NULL, 0); |
965 | rxvt_tt_write(aR_ NULL, 0); |
962 | |
|
|
963 | #if defined(POINTER_BLANK) || defined(CURSOR_BLINK) |
|
|
964 | tp.tv_sec = 0; /* presume == 0 implies time not yet retrieved */ |
|
|
965 | #endif |
|
|
966 | #if defined(CURSOR_BLINK) |
|
|
967 | want_keypress_time = 0; |
|
|
968 | #endif |
|
|
969 | #if defined(POINTER_BLANK) |
|
|
970 | want_motion_time = 0; |
|
|
971 | #endif |
|
|
972 | |
|
|
973 | if (XPending (R->Xdisplay)) |
|
|
974 | { |
|
|
975 | R->process_x_events (); |
|
|
976 | |
|
|
977 | /* in case button actions pushed chars to cmdbuf */ |
|
|
978 | if (R->cmdbuf_ptr < R->cmdbuf_endp) |
|
|
979 | return *R->cmdbuf_ptr++; |
|
|
980 | } |
|
|
981 | |
|
|
982 | #if defined(CURSOR_BLINK) |
|
|
983 | if (want_keypress_time) { |
|
|
984 | (void)gettimeofday(&tp, NULL); |
|
|
985 | R->lastcursorchange.tv_sec = tp.tv_sec; |
|
|
986 | R->lastcursorchange.tv_usec = tp.tv_usec; |
|
|
987 | } |
|
|
988 | #endif |
|
|
989 | #if defined(POINTER_BLANK) |
|
|
990 | if (want_motion_time) { |
|
|
991 | if (!tp.tv_sec) |
|
|
992 | (void)gettimeofday(&tp, NULL); |
|
|
993 | R->lastmotion.tv_sec = tp.tv_sec; |
|
|
994 | R->lastmotion.tv_usec = tp.tv_usec; |
|
|
995 | } |
|
|
996 | #endif |
|
|
997 | |
|
|
998 | /* |
|
|
999 | * the command input buffer is empty and we have no pending X events |
|
|
1000 | */ |
|
|
1001 | quick_timeout = 0; |
|
|
1002 | |
966 | |
1003 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
967 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1004 | if (R->mouse_slip_wheel_speed) { |
968 | if (R->mouse_slip_wheel_speed) { |
1005 | quick_timeout = 1; |
969 | quick_timeout = 1; |
1006 | if (!R->mouse_slip_wheel_delay-- |
970 | if (!R->mouse_slip_wheel_delay-- |
… | |
… | |
1036 | R->want_refresh = 1; |
1000 | R->want_refresh = 1; |
1037 | } |
1001 | } |
1038 | } |
1002 | } |
1039 | #endif /* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */ |
1003 | #endif /* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */ |
1040 | |
1004 | |
1041 | FD_ZERO(&readfds); |
|
|
1042 | FD_SET(R->cmd_fd, &readfds); |
|
|
1043 | FD_SET(R->Xfd, &readfds); |
|
|
1044 | value.tv_usec = TIMEOUT_USEC; |
|
|
1045 | value.tv_sec = 0; |
|
|
1046 | |
|
|
1047 | if (!R->TermWin.mapped) |
|
|
1048 | quick_timeout = 0; |
|
|
1049 | else { |
|
|
1050 | quick_timeout |= R->want_refresh; |
|
|
1051 | #ifdef TRANSPARENT |
1005 | #ifdef TRANSPARENT |
1052 | quick_timeout |= R->want_full_refresh; |
1006 | quick_timeout |= R->want_full_refresh; |
1053 | #endif |
1007 | #endif |
1054 | } |
|
|
1055 | |
|
|
1056 | #if defined(POINTER_BLANK) || defined(CURSOR_BLINK) |
|
|
1057 | { |
|
|
1058 | int set_quick_timeout = 0; |
|
|
1059 | long csdiff, psdiff; |
|
|
1060 | |
|
|
1061 | #define BLINK_TIME 500000L |
|
|
1062 | csdiff = psdiff = 60000000L; /* or, say, LONG_MAX */ |
|
|
1063 | # if defined(CURSOR_BLINK) |
|
|
1064 | if (R->Options & Opt_cursorBlink) { |
|
|
1065 | if (!tp.tv_sec) /* didn't get it before so get it now */ |
|
|
1066 | (void)gettimeofday(&tp, NULL); |
|
|
1067 | |
|
|
1068 | csdiff = (tp.tv_sec - R->lastcursorchange.tv_sec) * 1000000L |
|
|
1069 | + tp.tv_usec - R->lastcursorchange.tv_usec; |
|
|
1070 | if (csdiff > BLINK_TIME) { /* XXX: settable blink times */ |
|
|
1071 | R->lastcursorchange.tv_sec = tp.tv_sec; |
|
|
1072 | R->lastcursorchange.tv_usec = tp.tv_usec; |
|
|
1073 | R->hidden_cursor = !R->hidden_cursor; |
|
|
1074 | csdiff = 0; |
|
|
1075 | } else |
|
|
1076 | csdiff = BLINK_TIME - csdiff; |
|
|
1077 | set_quick_timeout = 1; |
|
|
1078 | } |
|
|
1079 | # endif |
1008 | #endif |
|
|
1009 | } |
|
|
1010 | |
1080 | # if defined(POINTER_BLANK) |
1011 | #ifdef POINTER_BLANK |
1081 | /* |
|
|
1082 | * If we haven't moved the pointer for a while |
|
|
1083 | */ |
|
|
1084 | if ((R->Options & Opt_pointerBlank) |
|
|
1085 | && (R->pointerBlankDelay > 0) |
|
|
1086 | && (R->hidden_pointer == 0)) { |
|
|
1087 | long pdelay; |
|
|
1088 | |
|
|
1089 | if (!tp.tv_sec) /* didn't get it before so get it now */ |
|
|
1090 | (void)gettimeofday(&tp, NULL); |
|
|
1091 | psdiff = (tp.tv_sec - R->lastmotion.tv_sec) * 1000000L |
|
|
1092 | + tp.tv_usec - R->lastmotion.tv_usec; |
|
|
1093 | pdelay = R->pointerBlankDelay * 1000000L; |
|
|
1094 | if (psdiff >= pdelay) |
|
|
1095 | rxvt_pointer_blank(aR); |
|
|
1096 | else { |
|
|
1097 | set_quick_timeout = 1; |
|
|
1098 | psdiff = pdelay - psdiff; |
|
|
1099 | } |
|
|
1100 | } |
|
|
1101 | # endif |
|
|
1102 | if (!quick_timeout && set_quick_timeout) { |
|
|
1103 | MIN_IT(csdiff, psdiff); |
|
|
1104 | value.tv_sec = csdiff / 1000000L; |
|
|
1105 | value.tv_usec = csdiff % 1000000L; |
|
|
1106 | quick_timeout = 1; |
|
|
1107 | } |
|
|
1108 | } |
|
|
1109 | #endif |
|
|
1110 | |
|
|
1111 | if ((select_res = select(R->num_fds, &readfds, NULL, NULL, |
|
|
1112 | (quick_timeout ? &value : NULL))) == 0) { |
|
|
1113 | /* select statement timed out - we're not hard and fast scrolling */ |
|
|
1114 | R->refresh_limit = 1; |
|
|
1115 | } |
|
|
1116 | #if defined(CURSOR_BLINK) |
|
|
1117 | if (R->Options & Opt_cursorBlink) |
|
|
1118 | R->want_refresh = 1; |
|
|
1119 | #endif |
|
|
1120 | } |
|
|
1121 | } |
|
|
1122 | |
|
|
1123 | /* EXTPROTO */ |
|
|
1124 | void |
1012 | void |
1125 | rxvt_pointer_unblank(pR) |
1013 | rxvt_term::pointer_unblank () |
1126 | { |
1014 | { |
|
|
1015 | if (!(Options & Opt_pointerBlank)) |
|
|
1016 | return; |
|
|
1017 | |
1127 | XDefineCursor(R->Xdisplay, R->TermWin.vt, R->TermWin_cursor); |
1018 | XDefineCursor (Xdisplay, TermWin.vt, TermWin_cursor); |
1128 | rxvt_recolour_cursor(aR); |
1019 | rxvt_recolour_cursor (this); |
1129 | #ifdef POINTER_BLANK |
|
|
1130 | R->hidden_pointer = 0; |
1020 | hidden_pointer = 0; |
1131 | if (R->pointerBlankDelay > 0) { |
|
|
1132 | struct timeval tp; |
|
|
1133 | |
1021 | |
1134 | (void)gettimeofday(&tp, NULL); |
1022 | pointer_ev.start (NOW + pointerBlankDelay); |
1135 | R->lastmotion.tv_sec = tp.tv_sec; |
|
|
1136 | R->lastmotion.tv_usec = tp.tv_usec; |
|
|
1137 | } |
|
|
1138 | #endif |
|
|
1139 | } |
1023 | } |
1140 | |
1024 | |
1141 | #ifdef POINTER_BLANK |
|
|
1142 | /* INTPROTO */ |
|
|
1143 | void |
1025 | void |
1144 | rxvt_pointer_blank(pR) |
1026 | rxvt_term::pointer_blank () |
1145 | { |
1027 | { |
|
|
1028 | pointer_ev.stop (); |
|
|
1029 | |
|
|
1030 | if (!(Options & Opt_pointerBlank)) |
|
|
1031 | return; |
|
|
1032 | |
1146 | XDefineCursor(R->Xdisplay, R->TermWin.vt, R->pointer_blank); |
1033 | XDefineCursor (Xdisplay, TermWin.vt, blank_cursor); |
1147 | XFlush(R->Xdisplay); |
1034 | XFlush (Xdisplay); |
|
|
1035 | |
1148 | R->hidden_pointer = 1; |
1036 | hidden_pointer = 1; |
|
|
1037 | } |
|
|
1038 | |
|
|
1039 | void |
|
|
1040 | rxvt_term::pointer_cb (time_watcher &w) |
|
|
1041 | { |
|
|
1042 | pointer_blank (); |
1149 | } |
1043 | } |
1150 | #endif |
1044 | #endif |
1151 | |
1045 | |
1152 | /* INTPROTO */ |
1046 | /* INTPROTO */ |
1153 | void |
1047 | void |
… | |
… | |
1556 | break; |
1450 | break; |
1557 | |
1451 | |
1558 | case MotionNotify: |
1452 | case MotionNotify: |
1559 | #ifdef POINTER_BLANK |
1453 | #ifdef POINTER_BLANK |
1560 | if (R->hidden_pointer) |
1454 | if (R->hidden_pointer) |
1561 | rxvt_pointer_unblank(aR); |
1455 | R->pointer_unblank (); |
1562 | #endif |
1456 | #endif |
1563 | #if MENUBAR |
1457 | #if MENUBAR |
1564 | if (isMenuBarWindow(ev->xany.window)) { |
1458 | if (isMenuBarWindow(ev->xany.window)) { |
1565 | rxvt_menubar_control(aR_ &(ev->xbutton)); |
1459 | rxvt_menubar_control(aR_ &(ev->xbutton)); |
1566 | break; |
1460 | break; |