1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: command.c |
2 | * File: command.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: command.C,v 1.14 2003/12/08 23:14:40 pcg Exp $ |
4 | * $Id: command.C,v 1.15 2003/12/16 23:04:13 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> |
… | |
… | |
1146 | { |
1146 | { |
1147 | int i, want_timeout; |
1147 | int i, want_timeout; |
1148 | Window unused_root, unused_child; |
1148 | Window unused_root, unused_child; |
1149 | int unused_root_x, unused_root_y; |
1149 | int unused_root_x, unused_root_y; |
1150 | unsigned int unused_mask; |
1150 | unsigned int unused_mask; |
1151 | struct timeval tp; |
|
|
1152 | |
1151 | |
1153 | #ifdef DEBUG_X |
1152 | #ifdef DEBUG_X |
1154 | const char *const eventnames[] = |
1153 | const char *const eventnames[] = |
1155 | { /* mason - this matches my system */ |
1154 | { /* mason - this matches my system */ |
1156 | "", |
1155 | "", |
… | |
… | |
1187 | "SelectionNotify", |
1186 | "SelectionNotify", |
1188 | "ColormapNotify", |
1187 | "ColormapNotify", |
1189 | "ClientMessage", |
1188 | "ClientMessage", |
1190 | "MappingNotify" |
1189 | "MappingNotify" |
1191 | }; |
1190 | }; |
|
|
1191 | #endif |
|
|
1192 | |
|
|
1193 | #ifdef DEBUG_X |
|
|
1194 | struct timeval tp; |
1192 | struct tm *ltt; |
1195 | struct tm *ltt; |
1193 | #endif |
|
|
1194 | |
|
|
1195 | /* |
|
|
1196 | * check if we need to get the time for any timeouts |
|
|
1197 | */ |
|
|
1198 | |
|
|
1199 | for (i = NUM_TIMEOUTS; i--; ) |
|
|
1200 | if (R->timeout[i].tv_sec) { |
|
|
1201 | want_timeout = 1; |
|
|
1202 | break; |
|
|
1203 | } |
|
|
1204 | |
|
|
1205 | #ifndef DEBUG_X |
|
|
1206 | if (want_timeout) |
|
|
1207 | #endif |
|
|
1208 | (void)gettimeofday(&tp, NULL); |
1196 | (void)gettimeofday(&tp, NULL); |
1209 | |
|
|
1210 | #ifdef DEBUG_X |
|
|
1211 | ltt = localtime(&(tp.tv_sec)); |
1197 | ltt = localtime(&(tp.tv_sec)); |
1212 | D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial)); |
1198 | D_X((stderr, "Event: %-16s %-7s %08lx (%4d-%02d-%02d %02d:%02d:%02d.%.6ld) %s %lu", eventnames[ev->type], (ev->xany.window == R->TermWin.parent[0] ? "parent" : (ev->xany.window == R->TermWin.vt ? "vt" : (ev->xany.window == R->scrollBar.win ? "scroll" : (ev->xany.window == R->menuBar.win ? "menubar" : "UNKNOWN")))), (ev->xany.window == R->TermWin.parent[0] ? R->TermWin.parent[0] : (ev->xany.window == R->TermWin.vt ? R->TermWin.vt : (ev->xany.window == R->scrollBar.win ? R->scrollBar.win : (ev->xany.window == R->menuBar.win ? R->menuBar.win : 0)))), ltt->tm_year + 1900, ltt->tm_mon + 1, ltt->tm_mday, ltt->tm_hour, ltt->tm_min, ltt->tm_sec, tp.tv_usec, ev->xany.send_event ? "S" : " ", ev->xany.serial)); |
1213 | #endif |
1199 | #endif |
1214 | |
|
|
1215 | /* X event timeouts */ |
|
|
1216 | if (want_timeout) |
|
|
1217 | for (i = NUM_TIMEOUTS; i--; ) { |
|
|
1218 | if (R->timeout[i].tv_sec == 0) |
|
|
1219 | continue; |
|
|
1220 | if ((tp.tv_sec < R->timeout[i].tv_sec) |
|
|
1221 | || (tp.tv_sec == R->timeout[i].tv_sec |
|
|
1222 | && tp.tv_usec < R->timeout[i].tv_usec)) |
|
|
1223 | continue; |
|
|
1224 | R->timeout[i].tv_sec = 0; |
|
|
1225 | switch(i) { |
|
|
1226 | case TIMEOUT_INCR: |
|
|
1227 | rxvt_print_error("data loss: timeout on INCR selection paste"); |
|
|
1228 | R->selection_wait = Sel_none; |
|
|
1229 | break; |
|
|
1230 | default: |
|
|
1231 | break; |
|
|
1232 | } |
|
|
1233 | } |
|
|
1234 | |
1200 | |
1235 | switch (ev->type) { |
1201 | switch (ev->type) { |
1236 | case KeyPress: |
1202 | case KeyPress: |
1237 | rxvt_lookup_key(aR_ (XKeyEvent *)ev); |
1203 | rxvt_lookup_key(aR_ (XKeyEvent *)ev); |
1238 | break; |
1204 | break; |