1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: command.C |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
… | |
… | |
49 | #include "rxvt.h" |
49 | #include "rxvt.h" |
50 | #include "rxvtperl.h" |
50 | #include "rxvtperl.h" |
51 | #include "version.h" |
51 | #include "version.h" |
52 | #include "command.h" |
52 | #include "command.h" |
53 | |
53 | |
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
|
|
58 | |
|
|
59 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
60 | # include "keyboard.h" |
55 | # include "keyboard.h" |
61 | #endif |
56 | #endif |
62 | |
57 | |
63 | #include <csignal> |
58 | #include <csignal> |
64 | |
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
|
|
63 | |
65 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
66 | |
65 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
|
|
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
67 | |
72 | #if ENABLE_FRILLS || ISO_14755 |
68 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
69 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
70 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
71 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
230 | # if !UNICODE3 |
226 | # if !UNICODE3 |
231 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
232 | ch = 0xfffd; |
228 | ch = 0xfffd; |
233 | # endif |
229 | # endif |
234 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
|
|
231 | |
|
|
232 | if (WCWIDTH (ch) >= 2) |
235 | scr_overlay_set (12, y, NOCHAR, r); |
233 | scr_overlay_set (12, y, NOCHAR, r); |
236 | } |
234 | } |
237 | |
235 | |
|
|
236 | // { |
|
|
237 | // char buf[4+4+3+1]; |
|
|
238 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
|
|
239 | // scr_overlay_set (0, 0, buf); |
|
|
240 | // } |
238 | scr_overlay_set (0, len , attr); |
241 | scr_overlay_set (0, len , attr); |
239 | scr_overlay_set (0, len + 1, fname); |
242 | scr_overlay_set (0, len + 1, fname); |
240 | |
243 | |
241 | free (fname); |
244 | free (fname); |
242 | |
245 | |
… | |
… | |
295 | |
298 | |
296 | return -1; |
299 | return -1; |
297 | } |
300 | } |
298 | #endif |
301 | #endif |
299 | |
302 | |
300 | /*{{{ Convert the keypress event into a string */ |
|
|
301 | void |
303 | void |
302 | rxvt_term::lookup_key (XKeyEvent &ev) |
304 | rxvt_term::key_press (XKeyEvent &ev) |
303 | { |
305 | { |
304 | int ctrl, meta, shft, len; |
306 | int ctrl, meta, shft, len; |
305 | unsigned int newlen; |
307 | unsigned int newlen; |
306 | KeySym keysym; |
308 | KeySym keysym; |
307 | #ifdef DEBUG_CMD |
|
|
308 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
309 | #endif |
|
|
310 | int valid_keysym; |
309 | int valid_keysym; |
311 | char kbuf[KBUFSZ]; |
310 | char kbuf[KBUFSZ]; |
|
|
311 | |
|
|
312 | #if ISO_14755 |
|
|
313 | if (iso14755buf & ISO_14755_52) |
|
|
314 | return; |
|
|
315 | #endif |
312 | |
316 | |
313 | /* |
317 | /* |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
318 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
315 | * escape sequence to toggle the Keypad. |
319 | * escape sequence to toggle the Keypad. |
316 | * |
320 | * |
… | |
… | |
464 | { |
468 | { |
465 | switch (keysym) |
469 | switch (keysym) |
466 | { |
470 | { |
467 | /* normal XTerm key bindings */ |
471 | /* normal XTerm key bindings */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
472 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
469 | selection_request (ev.time, 0, 0); |
473 | selection_request (ev.time); |
470 | return; |
474 | return; |
471 | #if TODO |
475 | #if TODO |
472 | /* rxvt extras */ |
476 | /* rxvt extras */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
477 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
474 | change_font (FONT_UP); |
478 | change_font (FONT_UP); |
… | |
… | |
493 | { |
497 | { |
494 | commit_iso14755 (); |
498 | commit_iso14755 (); |
495 | iso14755buf = ISO_14755_51; |
499 | iso14755buf = ISO_14755_51; |
496 | # if ISO_14755 |
500 | # if ISO_14755 |
497 | iso14755_51 (0); |
501 | iso14755_51 (0); |
|
|
502 | # endif |
|
|
503 | return; |
|
|
504 | } |
|
|
505 | else if (keysym == XK_BackSpace) |
|
|
506 | { |
|
|
507 | iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; |
|
|
508 | # if ISO_14755 |
|
|
509 | iso14755_51 (iso14755buf & ISO_14755_MASK); |
498 | # endif |
510 | # endif |
499 | return; |
511 | return; |
500 | } |
512 | } |
501 | else if ((hv = hex_keyval (ev)) >= 0) |
513 | else if ((hv = hex_keyval (ev)) >= 0) |
502 | { |
514 | { |
… | |
… | |
524 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
536 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
525 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
537 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
526 | # endif |
538 | # endif |
527 | } |
539 | } |
528 | #endif |
540 | #endif |
529 | |
541 | |
530 | #ifdef PRINTPIPE |
542 | #ifdef PRINTPIPE |
531 | if (keysym == XK_Print) |
543 | if (keysym == XK_Print) |
532 | { |
544 | { |
533 | scr_printscreen (ctrl | shft); |
545 | scr_printscreen (ctrl | shft); |
534 | return; |
546 | return; |
… | |
… | |
873 | return; |
885 | return; |
874 | |
886 | |
875 | if (len <= 0) |
887 | if (len <= 0) |
876 | return; /* not mapped */ |
888 | return; /* not mapped */ |
877 | |
889 | |
878 | if (OPTION (Opt_scrollTtyKeypress)) |
890 | if (option (Opt_scrollTtyKeypress)) |
879 | if (view_start) |
891 | if (view_start) |
880 | { |
892 | { |
881 | view_start = 0; |
893 | view_start = 0; |
882 | want_refresh = 1; |
894 | want_refresh = 1; |
883 | } |
895 | } |
… | |
… | |
905 | { |
917 | { |
906 | const char ch = C0_ESC; |
918 | const char ch = C0_ESC; |
907 | tt_write (&ch, 1); |
919 | tt_write (&ch, 1); |
908 | } |
920 | } |
909 | |
921 | |
910 | #if defined(DEBUG_CMD) |
|
|
911 | /* Display keyboard buffer contents */ |
|
|
912 | unsigned char *p; |
|
|
913 | int i; |
|
|
914 | |
|
|
915 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
916 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
917 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
918 | fprintf (stderr, "'\n"); |
|
|
919 | #endif /* DEBUG_CMD */ |
|
|
920 | tt_write (kbuf, (unsigned int)len); |
922 | tt_write (kbuf, (unsigned int)len); |
921 | } |
923 | } |
922 | /*}}} */ |
|
|
923 | |
924 | |
|
|
925 | void |
|
|
926 | rxvt_term::key_release (XKeyEvent &ev) |
|
|
927 | { |
|
|
928 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
929 | KeySym keysym; |
|
|
930 | |
|
|
931 | keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
932 | #endif |
|
|
933 | |
|
|
934 | #if ENABLE_FRILLS || ISO_14755 |
|
|
935 | // ISO 14755 support |
|
|
936 | if (iso14755buf) |
|
|
937 | if (iso14755buf & ISO_14755_52) |
|
|
938 | { |
|
|
939 | # if ENABLE_OVERLAY |
|
|
940 | scr_overlay_off (); |
|
|
941 | # endif |
|
|
942 | # if ISO_14755 |
|
|
943 | // iso14755 part 5.2 handling: release time |
|
|
944 | // first: controls |
|
|
945 | if ((ev.state & ControlMask) |
|
|
946 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
947 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
948 | { |
|
|
949 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
950 | commit_iso14755 (); |
|
|
951 | |
|
|
952 | return; |
|
|
953 | } |
|
|
954 | |
|
|
955 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
956 | if (i[0] == keysym) |
|
|
957 | { |
|
|
958 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
959 | commit_iso14755 (); |
|
|
960 | |
|
|
961 | return; |
|
|
962 | } |
|
|
963 | |
|
|
964 | scr_bell (); |
|
|
965 | # endif |
|
|
966 | iso14755buf = 0; |
|
|
967 | |
|
|
968 | return; |
|
|
969 | } |
|
|
970 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
971 | { |
|
|
972 | # if ENABLE_OVERLAY |
|
|
973 | scr_overlay_off (); |
|
|
974 | # endif |
|
|
975 | if (iso14755buf & ISO_14755_51) |
|
|
976 | commit_iso14755 (); |
|
|
977 | #if ISO_14755 |
|
|
978 | else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) |
|
|
979 | { |
|
|
980 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
981 | |
|
|
982 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
983 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
984 | } |
|
|
985 | # endif |
|
|
986 | else |
|
|
987 | iso14755buf = 0; |
|
|
988 | } |
|
|
989 | #endif |
|
|
990 | |
|
|
991 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
992 | return; |
|
|
993 | |
|
|
994 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
995 | if (!(ev.state & ControlMask)) |
|
|
996 | slip_wheel_ev.stop (); |
|
|
997 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
998 | mouse_slip_wheel_speed = 0; |
|
|
999 | #endif |
|
|
1000 | } |
|
|
1001 | |
924 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
1002 | #if defined (KEYSYM_RESOURCE) |
925 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
926 | /* attempt to `write' count to the input buffer */ |
|
|
927 | unsigned int |
1003 | unsigned int |
928 | rxvt_term::cmd_write (const char *str, unsigned int count) |
1004 | rxvt_term::cmd_write (const char *str, unsigned int count) |
929 | { |
1005 | { |
930 | unsigned int n, s; |
1006 | unsigned int n, s; |
931 | |
1007 | |
… | |
… | |
1008 | while (l->is_longer () && row < end_row); |
1084 | while (l->is_longer () && row < end_row); |
1009 | } |
1085 | } |
1010 | while (row < end_row); |
1086 | while (row < end_row); |
1011 | } |
1087 | } |
1012 | |
1088 | |
1013 | scr_refresh (refresh_type); |
1089 | scr_refresh (); |
1014 | scrollbar_show (1); |
1090 | scrollbar_show (1); |
1015 | #ifdef USE_XIM |
1091 | #ifdef USE_XIM |
1016 | IMSendSpot (); |
1092 | IMSendSpot (); |
1017 | #endif |
1093 | #endif |
1018 | } |
1094 | } |
… | |
… | |
1046 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1122 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1047 | { |
1123 | { |
1048 | hidden_cursor = !hidden_cursor; |
1124 | hidden_cursor = !hidden_cursor; |
1049 | want_refresh = 1; |
1125 | want_refresh = 1; |
1050 | |
1126 | |
1051 | w.start (w.at + BLINK_INTERVAL); |
1127 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1052 | } |
1128 | } |
1053 | #endif |
1129 | #endif |
1054 | |
1130 | |
1055 | #ifdef TEXT_BLINK |
1131 | #ifdef TEXT_BLINK |
1056 | void |
1132 | void |
… | |
… | |
1070 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1146 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1071 | { |
1147 | { |
1072 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1148 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1073 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1149 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1074 | { |
1150 | { |
1075 | refresh_type |= SMOOTH_REFRESH; |
|
|
1076 | want_refresh = 1; |
1151 | want_refresh = 1; |
1077 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1152 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1078 | } |
1153 | } |
1079 | } |
1154 | } |
1080 | #endif |
1155 | #endif |
… | |
… | |
1084 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1159 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1085 | { |
1160 | { |
1086 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1161 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1087 | { |
1162 | { |
1088 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1163 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1089 | refresh_type |= SMOOTH_REFRESH; |
|
|
1090 | want_refresh = 1; |
1164 | want_refresh = 1; |
1091 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1165 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1092 | } |
1166 | } |
1093 | } |
1167 | } |
1094 | #endif |
1168 | #endif |
… | |
… | |
1102 | : scr_page (UP, mouse_slip_wheel_speed)) |
1176 | : scr_page (UP, mouse_slip_wheel_speed)) |
1103 | { |
1177 | { |
1104 | if (view_start == top_row || view_start == 0) |
1178 | if (view_start == top_row || view_start == 0) |
1105 | mouse_slip_wheel_speed = 0; |
1179 | mouse_slip_wheel_speed = 0; |
1106 | |
1180 | |
1107 | refresh_type |= SMOOTH_REFRESH; |
|
|
1108 | want_refresh = 1; |
1181 | want_refresh = 1; |
1109 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1182 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1110 | } |
1183 | } |
1111 | } |
1184 | } |
1112 | #endif |
1185 | #endif |
1113 | |
1186 | |
1114 | #if HAVE_SCHED_YIELD |
1187 | #if LINUX_YIELD_HACK |
1115 | static struct event_handler |
1188 | static struct event_handler |
1116 | { |
1189 | { |
1117 | check_watcher cw_yield; |
1190 | check_watcher yield_ev; |
1118 | |
1191 | |
1119 | void yield (check_watcher &w) |
1192 | void yield_cb (check_watcher &w) |
1120 | { |
1193 | { |
1121 | sched_yield (); |
1194 | // this should really be sched_yield(), but the linux guys thought |
|
|
1195 | // that giving a process calling sched_yield () less cpu time than |
|
|
1196 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1197 | // allowed by the sus... as is returning ENOSYS. |
|
|
1198 | |
|
|
1199 | struct timespec ts = { 0, 0 }; |
|
|
1200 | nanosleep (&ts, 0); |
|
|
1201 | |
1122 | w.stop (); |
1202 | w.stop (); |
1123 | } |
1203 | } |
1124 | |
1204 | |
1125 | event_handler () |
1205 | event_handler () |
1126 | : cw_yield (this, &event_handler::yield) |
1206 | : yield_ev (this, &event_handler::yield_cb) |
1127 | { |
1207 | { |
1128 | } |
1208 | } |
1129 | } event_handler; |
1209 | } event_handler; |
1130 | #endif |
1210 | #endif |
1131 | |
1211 | |
… | |
… | |
1142 | |
1222 | |
1143 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1223 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1144 | cmdbuf_ptr = cmdbuf_base; |
1224 | cmdbuf_ptr = cmdbuf_base; |
1145 | cmdbuf_endp = cmdbuf_ptr + n; |
1225 | cmdbuf_endp = cmdbuf_ptr + n; |
1146 | |
1226 | |
1147 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1227 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1148 | |
1228 | |
1149 | if (r > 0) |
1229 | if (r > 0) |
1150 | { |
1230 | { |
1151 | cmdbuf_endp += r; |
1231 | cmdbuf_endp += r; |
1152 | return true; |
1232 | return true; |
1153 | } |
1233 | } |
1154 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1234 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1155 | { |
1235 | { |
1156 | #if HAVE_SCHED_YIELD |
1236 | #if LINUX_YIELD_HACK |
1157 | if (display->is_local) |
1237 | if (display->is_local) |
1158 | event_handler.cw_yield.start (); |
1238 | event_handler.yield_ev.start (); |
1159 | #endif |
1239 | #endif |
1160 | } |
1240 | } |
1161 | else |
1241 | else |
1162 | { |
1242 | { |
1163 | pty_ev.stop (); |
1243 | pty_ev.stop (); |
1164 | |
1244 | |
1165 | if (!OPTION (Opt_hold)) |
1245 | if (!option (Opt_hold)) |
1166 | destroy (); |
1246 | destroy (); |
1167 | } |
1247 | } |
1168 | |
1248 | |
1169 | return false; |
1249 | return false; |
1170 | } |
1250 | } |
1171 | |
1251 | |
1172 | void |
1252 | void |
1173 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1253 | rxvt_term::pty_cb (io_watcher &w, short revents) |
… | |
… | |
1185 | } |
1265 | } |
1186 | |
1266 | |
1187 | void |
1267 | void |
1188 | rxvt_term::pointer_unblank () |
1268 | rxvt_term::pointer_unblank () |
1189 | { |
1269 | { |
1190 | XDefineCursor (display->display, vt, TermWin_cursor); |
1270 | XDefineCursor (dpy, vt, TermWin_cursor); |
1191 | recolour_cursor (); |
1271 | recolour_cursor (); |
1192 | |
1272 | |
1193 | #ifdef POINTER_BLANK |
1273 | #ifdef POINTER_BLANK |
1194 | hidden_pointer = 0; |
1274 | hidden_pointer = 0; |
1195 | |
1275 | |
1196 | if (OPTION (Opt_pointerBlank)) |
1276 | if (option (Opt_pointerBlank)) |
1197 | pointer_ev.start (NOW + pointerBlankDelay); |
1277 | pointer_ev.start (NOW + pointerBlankDelay); |
1198 | #endif |
1278 | #endif |
1199 | } |
1279 | } |
1200 | |
1280 | |
1201 | #ifdef POINTER_BLANK |
1281 | #ifdef POINTER_BLANK |
1202 | void |
1282 | void |
1203 | rxvt_term::pointer_blank () |
1283 | rxvt_term::pointer_blank () |
1204 | { |
1284 | { |
1205 | if (!OPTION (Opt_pointerBlank)) |
1285 | if (!option (Opt_pointerBlank)) |
1206 | return; |
1286 | return; |
1207 | |
1287 | |
1208 | XDefineCursor (display->display, vt, display->blank_cursor); |
1288 | XDefineCursor (dpy, vt, display->blank_cursor); |
1209 | XFlush (display->display); |
1289 | XFlush (dpy); |
1210 | |
1290 | |
1211 | hidden_pointer = 1; |
1291 | hidden_pointer = 1; |
1212 | } |
1292 | } |
1213 | |
1293 | |
1214 | void |
1294 | void |
… | |
… | |
1287 | (32 + button_number + key_state), |
1367 | (32 + button_number + key_state), |
1288 | (32 + x + 1), |
1368 | (32 + x + 1), |
1289 | (32 + y + 1)); |
1369 | (32 + y + 1)); |
1290 | } |
1370 | } |
1291 | |
1371 | |
1292 | #ifdef USING_W11LIB |
|
|
1293 | void |
|
|
1294 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1295 | { |
|
|
1296 | rxvt_t *r = rxvt_get_r (); |
|
|
1297 | |
|
|
1298 | x_cb (*ev); |
|
|
1299 | } |
|
|
1300 | #endif |
|
|
1301 | |
|
|
1302 | /*{{{ process an X event */ |
1372 | /*{{{ process an X event */ |
1303 | void |
1373 | void |
1304 | rxvt_term::x_cb (XEvent &ev) |
1374 | rxvt_term::x_cb (XEvent &ev) |
1305 | { |
1375 | { |
1306 | make_current (); |
1376 | make_current (); |
1307 | |
1377 | |
1308 | dDisp; |
1378 | dLocal (Display *, dpy); |
1309 | |
1379 | |
1310 | if (ev.xany.window == vt |
1380 | if (ev.xany.window == vt |
|
|
1381 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1311 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1382 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1312 | return; |
1383 | return; |
1313 | |
1384 | |
1314 | // for XQueryPointer |
1385 | // for XQueryPointer |
1315 | Window unused_root, unused_child; |
1386 | Window unused_root, unused_child; |
… | |
… | |
1317 | unsigned int unused_mask; |
1388 | unsigned int unused_mask; |
1318 | |
1389 | |
1319 | switch (ev.type) |
1390 | switch (ev.type) |
1320 | { |
1391 | { |
1321 | case KeyPress: |
1392 | case KeyPress: |
1322 | #if ISO_14755 |
1393 | key_press (ev.xkey); |
1323 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1324 | #endif |
|
|
1325 | lookup_key (ev.xkey); |
|
|
1326 | |
|
|
1327 | break; |
1394 | break; |
1328 | |
1395 | |
1329 | case KeyRelease: |
1396 | case KeyRelease: |
1330 | { |
1397 | key_release (ev.xkey); |
1331 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
1332 | KeySym keysym; |
|
|
1333 | |
|
|
1334 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1335 | #endif |
|
|
1336 | |
|
|
1337 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1338 | // ISO 14755 support |
|
|
1339 | if (iso14755buf) |
|
|
1340 | if (iso14755buf & ISO_14755_52) |
|
|
1341 | { |
|
|
1342 | # if ENABLE_OVERLAY |
|
|
1343 | scr_overlay_off (); |
|
|
1344 | # endif |
|
|
1345 | # if ISO_14755 |
|
|
1346 | // iso14755 part 5.2 handling: release time |
|
|
1347 | // first: controls |
|
|
1348 | if ((ev.xkey.state & ControlMask) |
|
|
1349 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
1350 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
1351 | { |
|
|
1352 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
1353 | commit_iso14755 (); |
|
|
1354 | goto skip_switch; |
|
|
1355 | } |
|
|
1356 | |
|
|
1357 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1358 | if (i[0] == keysym) |
|
|
1359 | { |
|
|
1360 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1361 | commit_iso14755 (); |
|
|
1362 | goto skip_switch; |
|
|
1363 | } |
|
|
1364 | |
|
|
1365 | scr_bell (); |
|
|
1366 | # endif |
|
|
1367 | iso14755buf = 0; |
|
|
1368 | break; |
|
|
1369 | } |
|
|
1370 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1371 | { |
|
|
1372 | # if ENABLE_OVERLAY |
|
|
1373 | scr_overlay_off (); |
|
|
1374 | # endif |
|
|
1375 | if (iso14755buf & ISO_14755_51) |
|
|
1376 | commit_iso14755 (); |
|
|
1377 | #if ISO_14755 |
|
|
1378 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1379 | { |
|
|
1380 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1381 | |
|
|
1382 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1383 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1384 | } |
|
|
1385 | # endif |
|
|
1386 | else |
|
|
1387 | iso14755buf = 0; |
|
|
1388 | } |
|
|
1389 | #endif |
|
|
1390 | |
|
|
1391 | if (ev.xany.window == vt |
|
|
1392 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1393 | break; |
|
|
1394 | |
|
|
1395 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1396 | if (!(ev.xkey.state & ControlMask)) |
|
|
1397 | slip_wheel_ev.stop (); |
|
|
1398 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
1399 | mouse_slip_wheel_speed = 0; |
|
|
1400 | #endif |
|
|
1401 | break; |
1398 | break; |
1402 | } |
|
|
1403 | |
1399 | |
1404 | case ButtonPress: |
1400 | case ButtonPress: |
1405 | button_press (ev.xbutton); |
1401 | button_press (ev.xbutton); |
1406 | break; |
1402 | break; |
1407 | |
1403 | |
… | |
… | |
1409 | button_release (ev.xbutton); |
1405 | button_release (ev.xbutton); |
1410 | break; |
1406 | break; |
1411 | |
1407 | |
1412 | case ClientMessage: |
1408 | case ClientMessage: |
1413 | if (ev.xclient.format == 32 |
1409 | if (ev.xclient.format == 32 |
1414 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1410 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1415 | { |
1411 | { |
|
|
1412 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1413 | { |
|
|
1414 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1415 | { |
1416 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1416 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1417 | { |
|
|
1418 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1417 | destroy (); |
1419 | destroy (); |
|
|
1420 | } |
1418 | #if ENABLE_EWMH |
1421 | #if ENABLE_EWMH |
1419 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1422 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1420 | XSendEvent (disp, ev.xclient.window = display->root, |
1423 | XSendEvent (dpy, ev.xclient.window = display->root, |
1421 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1424 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1422 | &ev); |
1425 | &ev); |
|
|
1426 | #endif |
|
|
1427 | } |
|
|
1428 | } |
|
|
1429 | #if ENABLE_XEMBED |
|
|
1430 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1431 | { |
|
|
1432 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1433 | focus_in (); |
|
|
1434 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1435 | focus_out (); |
|
|
1436 | } |
1423 | #endif |
1437 | #endif |
1424 | } |
1438 | } |
1425 | #if ENABLE_XEMBED |
|
|
1426 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1427 | { |
|
|
1428 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1429 | focus_in (); |
|
|
1430 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1431 | focus_out (); |
|
|
1432 | } |
|
|
1433 | #endif |
|
|
1434 | #ifdef OFFIX_DND |
|
|
1435 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1436 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1437 | && (ev.xclient.data.l[0] == DndFile |
|
|
1438 | || ev.xclient.data.l[0] == DndDir |
|
|
1439 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1440 | { |
|
|
1441 | /* Get Dnd data */ |
|
|
1442 | Atom ActualType; |
|
|
1443 | int ActualFormat; |
|
|
1444 | unsigned char *data; |
|
|
1445 | unsigned long Size, RemainingBytes; |
|
|
1446 | |
|
|
1447 | XGetWindowProperty (disp, display->root, |
|
|
1448 | xa[XA_DNDSELECTION], |
|
|
1449 | 0L, 1000000L, |
|
|
1450 | False, AnyPropertyType, |
|
|
1451 | &ActualType, &ActualFormat, |
|
|
1452 | &Size, &RemainingBytes, |
|
|
1453 | &data); |
|
|
1454 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1455 | XFree (data); |
|
|
1456 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1457 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1458 | } |
|
|
1459 | #endif /* OFFIX_DND */ |
|
|
1460 | break; |
1439 | break; |
1461 | |
1440 | |
1462 | case MappingNotify: |
1441 | case MappingNotify: |
1463 | XRefreshKeyboardMapping (&ev.xmapping); |
1442 | XRefreshKeyboardMapping (&ev.xmapping); |
1464 | break; |
1443 | break; |
… | |
… | |
1487 | break; |
1466 | break; |
1488 | } |
1467 | } |
1489 | break; |
1468 | break; |
1490 | |
1469 | |
1491 | case FocusIn: |
1470 | case FocusIn: |
|
|
1471 | if (ev.xfocus.detail != NotifyInferior |
|
|
1472 | && ev.xfocus.detail != NotifyPointer |
|
|
1473 | && ev.xfocus.mode != NotifyGrab) |
1492 | focus_in (); |
1474 | focus_in (); |
1493 | break; |
1475 | break; |
1494 | |
1476 | |
1495 | case FocusOut: |
1477 | case FocusOut: |
|
|
1478 | if (ev.xfocus.detail != NotifyInferior |
|
|
1479 | && ev.xfocus.detail != NotifyPointer |
|
|
1480 | && ev.xfocus.mode != NotifyGrab) |
1496 | focus_out (); |
1481 | focus_out (); |
1497 | break; |
1482 | break; |
1498 | |
1483 | |
1499 | case ConfigureNotify: |
1484 | case ConfigureNotify: |
1500 | if (ev.xconfigure.window == parent[0]) |
1485 | if (ev.xconfigure.window == parent[0]) |
1501 | { |
1486 | { |
1502 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1487 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1503 | ; |
1488 | ; |
1504 | |
1489 | |
1505 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1490 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1506 | { |
1491 | { |
1507 | seen_resize = 1; |
1492 | seen_resize = 1; |
1508 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1493 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
|
|
1494 | #ifdef XPM_BACKGROUND |
|
|
1495 | if (!option (Opt_transparent) && bgPixmap.auto_resize) |
|
|
1496 | { |
|
|
1497 | resize_pixmap (); |
|
|
1498 | scr_touch (true); |
|
|
1499 | } |
|
|
1500 | #endif |
1509 | } |
1501 | } |
1510 | |
1502 | |
1511 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1503 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1504 | |
|
|
1505 | #ifdef TRANSPARENT |
1512 | if (OPTION (Opt_transparent)) |
1506 | if (option (Opt_transparent)) |
1513 | check_our_parents (); |
1507 | check_our_parents (); |
1514 | #endif |
1508 | #endif |
1515 | } |
1509 | } |
1516 | break; |
1510 | break; |
1517 | |
1511 | |
1518 | case PropertyNotify: |
1512 | case PropertyNotify: |
|
|
1513 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1519 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1514 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1520 | && ev.xproperty.state == PropertyNewValue) |
1515 | && ev.xproperty.state == PropertyNewValue) |
1521 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1516 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1522 | |
1517 | |
1523 | break; |
1518 | break; |
1524 | |
1519 | |
1525 | case SelectionClear: |
1520 | case SelectionClear: |
1526 | selection_clear (); |
1521 | selection_clear (); |
… | |
… | |
1562 | if (ev.xany.window == vt) |
1557 | if (ev.xany.window == vt) |
1563 | { |
1558 | { |
1564 | do |
1559 | do |
1565 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1560 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1566 | ev.xexpose.width, ev.xexpose.height, False); |
1561 | ev.xexpose.width, ev.xexpose.height, False); |
1567 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1562 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1568 | |
1563 | |
1569 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1564 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1570 | |
1565 | |
1571 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1566 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1572 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1567 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1573 | ev.xexpose.width, ev.xexpose.height, False); |
1568 | ev.xexpose.width, ev.xexpose.height, False); |
1574 | |
1569 | |
1575 | want_refresh = 1; |
1570 | want_refresh = 1; |
1576 | } |
1571 | } |
1577 | else |
1572 | else |
1578 | { |
1573 | { |
1579 | XEvent unused_event; |
1574 | XEvent unused_event; |
1580 | |
1575 | |
1581 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1576 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1582 | ; |
1577 | ; |
1583 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1578 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1584 | ; |
1579 | ; |
1585 | |
1580 | |
1586 | if (isScrollbarWindow (ev.xany.window)) |
1581 | if (isScrollbarWindow (ev.xany.window)) |
1587 | { |
1582 | { |
1588 | scrollBar.setIdle (); |
1583 | scrollBar.setIdle (); |
1589 | scrollbar_show (0); |
1584 | scrollbar_show (0); |
1590 | } |
1585 | } |
1591 | #ifdef MENUBAR |
|
|
1592 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1593 | menubar_expose (); |
|
|
1594 | #endif |
|
|
1595 | |
1586 | |
1596 | #ifdef TRANSPARENT |
1587 | #ifdef TRANSPARENT |
1597 | if (am_transparent && ev.xany.window == parent[0]) |
1588 | if (am_transparent && ev.xany.window == parent[0]) |
1598 | XClearWindow (disp, ev.xany.window); |
1589 | XClearWindow (dpy, ev.xany.window); |
1599 | #endif |
1590 | #endif |
1600 | } |
1591 | } |
1601 | break; |
1592 | break; |
1602 | |
1593 | |
1603 | case MotionNotify: |
1594 | case MotionNotify: |
1604 | #ifdef POINTER_BLANK |
1595 | #ifdef POINTER_BLANK |
1605 | if (hidden_pointer) |
1596 | if (hidden_pointer) |
1606 | pointer_unblank (); |
1597 | pointer_unblank (); |
1607 | #endif |
1598 | #endif |
1608 | #if MENUBAR |
|
|
1609 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1610 | { |
|
|
1611 | menubar_control (ev.xbutton); |
|
|
1612 | break; |
|
|
1613 | } |
|
|
1614 | #endif |
|
|
1615 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1599 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1616 | break; |
1600 | break; |
1617 | |
1601 | |
1618 | if (ev.xany.window == vt) |
1602 | if (ev.xany.window == vt) |
1619 | { |
1603 | { |
|
|
1604 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1620 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1605 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1621 | ; // nop |
1606 | ; // nop |
1622 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1607 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1623 | { |
1608 | { |
1624 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1609 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1625 | ; |
1610 | ; |
1626 | |
1611 | |
1627 | XQueryPointer (disp, vt, |
1612 | XQueryPointer (dpy, vt, |
1628 | &unused_root, &unused_child, |
1613 | &unused_root, &unused_child, |
1629 | &unused_root_x, &unused_root_y, |
1614 | &unused_root_x, &unused_root_y, |
1630 | &ev.xbutton.x, &ev.xbutton.y, |
1615 | &ev.xbutton.x, &ev.xbutton.y, |
1631 | &ev.xbutton.state); |
1616 | &ev.xbutton.state); |
1632 | #ifdef MOUSE_THRESHOLD |
1617 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1696 | #endif |
1681 | #endif |
1697 | } |
1682 | } |
1698 | } |
1683 | } |
1699 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1684 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1700 | { |
1685 | { |
1701 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1686 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1702 | MotionNotify, &ev)) |
1687 | MotionNotify, &ev)) |
1703 | ; |
1688 | ; |
1704 | |
1689 | |
1705 | XQueryPointer (disp, scrollBar.win, |
1690 | XQueryPointer (dpy, scrollBar.win, |
1706 | &unused_root, &unused_child, |
1691 | &unused_root, &unused_child, |
1707 | &unused_root_x, &unused_root_y, |
1692 | &unused_root_x, &unused_root_y, |
1708 | &ev.xbutton.x, &ev.xbutton.y, |
1693 | &ev.xbutton.x, &ev.xbutton.y, |
1709 | &unused_mask); |
1694 | &unused_mask); |
1710 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1695 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
… | |
… | |
1714 | scrollbar_show (1); |
1699 | scrollbar_show (1); |
1715 | } |
1700 | } |
1716 | break; |
1701 | break; |
1717 | } |
1702 | } |
1718 | |
1703 | |
1719 | skip_switch: ; |
|
|
1720 | |
|
|
1721 | #if defined(CURSOR_BLINK) |
1704 | #if defined(CURSOR_BLINK) |
1722 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1705 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
1723 | { |
1706 | { |
1724 | if (hidden_cursor) |
1707 | if (hidden_cursor) |
1725 | { |
1708 | { |
1726 | hidden_cursor = 0; |
1709 | hidden_cursor = 0; |
1727 | want_refresh = 1; |
1710 | want_refresh = 1; |
1728 | } |
1711 | } |
1729 | |
1712 | |
1730 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1713 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1731 | } |
1714 | } |
1732 | #endif |
1715 | #endif |
1733 | |
1716 | |
1734 | #if defined(POINTER_BLANK) |
1717 | #if defined(POINTER_BLANK) |
1735 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1718 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
1736 | { |
1719 | { |
1737 | if (ev.type == MotionNotify |
1720 | if (ev.type == MotionNotify |
1738 | || ev.type == ButtonPress |
1721 | || ev.type == ButtonPress |
1739 | || ev.type == ButtonRelease) |
1722 | || ev.type == ButtonRelease) |
1740 | if (hidden_pointer) |
1723 | if (hidden_pointer) |
… | |
… | |
1752 | if (!focus) |
1735 | if (!focus) |
1753 | { |
1736 | { |
1754 | focus = 1; |
1737 | focus = 1; |
1755 | want_refresh = 1; |
1738 | want_refresh = 1; |
1756 | |
1739 | |
1757 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1740 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1758 | |
1741 | |
1759 | #if USE_XIM |
1742 | #if USE_XIM |
1760 | if (Input_Context != NULL) |
1743 | if (Input_Context != NULL) |
1761 | { |
1744 | { |
1762 | IMSetStatusPosition (); |
1745 | IMSetPosition (); |
1763 | XSetICFocus (Input_Context); |
1746 | XSetICFocus (Input_Context); |
1764 | } |
1747 | } |
1765 | #endif |
1748 | #endif |
1766 | #if CURSOR_BLINK |
1749 | #if CURSOR_BLINK |
1767 | if (OPTION (Opt_cursorBlink)) |
1750 | if (option (Opt_cursorBlink)) |
1768 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1751 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1769 | #endif |
1752 | #endif |
1770 | #if OFF_FOCUS_FADING |
1753 | #if OFF_FOCUS_FADING |
1771 | if (rs[Rs_fade]) |
1754 | if (rs[Rs_fade]) |
1772 | { |
1755 | { |
1773 | pix_colors = pix_colors_focused; |
1756 | pix_colors = pix_colors_focused; |
1774 | scr_recolour (); |
1757 | scr_recolour (); |
|
|
1758 | } |
|
|
1759 | #endif |
|
|
1760 | #if ENABLE_FRILLS |
|
|
1761 | if (option (Opt_urgentOnBell)) |
|
|
1762 | { |
|
|
1763 | XWMHints *h; |
|
|
1764 | |
|
|
1765 | h = XGetWMHints(dpy, parent[0]); |
|
|
1766 | if (h != NULL) |
|
|
1767 | { |
|
|
1768 | h->flags &= ~XUrgencyHint; |
|
|
1769 | XSetWMHints(dpy, parent[0], h); |
|
|
1770 | } |
1775 | } |
1771 | } |
1776 | #endif |
1772 | #endif |
1777 | } |
1773 | } |
1778 | } |
1774 | } |
1779 | |
1775 | |
… | |
… | |
1799 | #if USE_XIM |
1795 | #if USE_XIM |
1800 | if (Input_Context != NULL) |
1796 | if (Input_Context != NULL) |
1801 | XUnsetICFocus (Input_Context); |
1797 | XUnsetICFocus (Input_Context); |
1802 | #endif |
1798 | #endif |
1803 | #if CURSOR_BLINK |
1799 | #if CURSOR_BLINK |
1804 | if (OPTION (Opt_cursorBlink)) |
1800 | if (option (Opt_cursorBlink)) |
1805 | cursor_blink_ev.stop (); |
1801 | cursor_blink_ev.stop (); |
1806 | hidden_cursor = 0; |
1802 | hidden_cursor = 0; |
1807 | #endif |
1803 | #endif |
1808 | #if OFF_FOCUS_FADING |
1804 | #if OFF_FOCUS_FADING |
1809 | if (rs[Rs_fade]) |
1805 | if (rs[Rs_fade]) |
… | |
… | |
1813 | } |
1809 | } |
1814 | #endif |
1810 | #endif |
1815 | } |
1811 | } |
1816 | } |
1812 | } |
1817 | |
1813 | |
1818 | #if TRANSPARENT |
1814 | void |
|
|
1815 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1816 | { |
|
|
1817 | #if OFF_FOCUS_FADING |
|
|
1818 | if (rs[Rs_fade]) |
|
|
1819 | { |
|
|
1820 | rgba c; |
|
|
1821 | pix_colors [Color_fade].get (c); |
|
|
1822 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1823 | } |
|
|
1824 | #endif |
|
|
1825 | } |
|
|
1826 | |
|
|
1827 | #if TRANSPARENT || ENABLE_PERL |
1819 | void |
1828 | void |
1820 | rxvt_term::rootwin_cb (XEvent &ev) |
1829 | rxvt_term::rootwin_cb (XEvent &ev) |
1821 | { |
1830 | { |
1822 | make_current (); |
1831 | make_current (); |
1823 | |
1832 | |
|
|
1833 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1834 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1835 | return; |
|
|
1836 | |
|
|
1837 | # if TRANSPARENT |
1824 | switch (ev.type) |
1838 | switch (ev.type) |
1825 | { |
1839 | { |
1826 | case PropertyNotify: |
1840 | case PropertyNotify: |
1827 | /* |
1841 | /* |
1828 | * if user used some Esetroot compatible prog to set the root bg, |
1842 | * if user used some Esetroot compatible prog to set the root bg, |
… | |
… | |
1832 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1846 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1833 | return; |
1847 | return; |
1834 | |
1848 | |
1835 | /* FALLTHROUGH */ |
1849 | /* FALLTHROUGH */ |
1836 | case ReparentNotify: |
1850 | case ReparentNotify: |
1837 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1851 | if (option (Opt_transparent)) |
1838 | want_refresh = want_full_refresh = 1; |
1852 | check_our_parents (); |
1839 | break; |
1853 | break; |
1840 | } |
1854 | } |
|
|
1855 | # endif |
1841 | } |
1856 | } |
1842 | #endif |
1857 | #endif |
1843 | |
1858 | |
1844 | void |
1859 | void |
1845 | rxvt_term::button_press (XButtonEvent &ev) |
1860 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1854 | /* |
1869 | /* |
1855 | * VT window processing of button press |
1870 | * VT window processing of button press |
1856 | */ |
1871 | */ |
1857 | if (ev.window == vt) |
1872 | if (ev.window == vt) |
1858 | { |
1873 | { |
|
|
1874 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1875 | return; |
|
|
1876 | |
1859 | #if ISO_14755 |
1877 | #if ISO_14755 |
1860 | // 5.4 |
1878 | // 5.4 |
1861 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1879 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1862 | { |
1880 | { |
1863 | iso14755_54 (ev.x, ev.y); |
1881 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1905 | else |
1923 | else |
1906 | { |
1924 | { |
1907 | if (ev.button != MEvent.button) |
1925 | if (ev.button != MEvent.button) |
1908 | MEvent.clicks = 0; |
1926 | MEvent.clicks = 0; |
1909 | |
1927 | |
1910 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1911 | switch (ev.button) |
1928 | switch (ev.button) |
1912 | { |
1929 | { |
1913 | case Button1: |
1930 | case Button1: |
1914 | /* allow meta + click to select rectangular areas */ |
1931 | /* allow meta + click to select rectangular areas */ |
1915 | /* should be done in screen.C */ |
1932 | /* should be done in screen.C */ |
1916 | #if ENABLE_FRILLS |
1933 | #if ENABLE_FRILLS |
1917 | selection.rect = !!(ev.state & ModMetaMask); |
1934 | selection.rect = !!(ev.state & ModMetaMask); |
1918 | #else |
1935 | #else |
1919 | selection.rect = false; |
1936 | selection.rect = false; |
1920 | #endif |
1937 | #endif |
1921 | |
1938 | |
1922 | /* allow shift+left click to extend selection */ |
1939 | /* allow shift+left click to extend selection */ |
1923 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1940 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1924 | { |
1941 | { |
1925 | if (MEvent.button == Button1 && clickintime) |
1942 | if (MEvent.button == Button1 && clickintime) |
1926 | selection_rotate (ev.x, ev.y); |
1943 | selection_rotate (ev.x, ev.y); |
1927 | else |
1944 | else |
1928 | selection_extend (ev.x, ev.y, 1); |
1945 | selection_extend (ev.x, ev.y, 1); |
1929 | } |
1946 | } |
1930 | else |
1947 | else |
1931 | { |
1948 | { |
1932 | if (MEvent.button == Button1 && clickintime) |
1949 | if (MEvent.button == Button1 && clickintime) |
1933 | MEvent.clicks++; |
1950 | MEvent.clicks++; |
1934 | else |
1951 | else |
1935 | MEvent.clicks = 1; |
1952 | MEvent.clicks = 1; |
1936 | |
1953 | |
1937 | selection_click (MEvent.clicks, ev.x, ev.y); |
1954 | selection_click (MEvent.clicks, ev.x, ev.y); |
1938 | } |
1955 | } |
1939 | |
1956 | |
1940 | MEvent.button = Button1; |
1957 | MEvent.button = Button1; |
1941 | break; |
1958 | break; |
1942 | |
1959 | |
1943 | case Button3: |
1960 | case Button3: |
1944 | if (MEvent.button == Button3 && clickintime) |
1961 | if (MEvent.button == Button3 && clickintime) |
1945 | selection_rotate (ev.x, ev.y); |
1962 | selection_rotate (ev.x, ev.y); |
1946 | else |
1963 | else |
1947 | selection_extend (ev.x, ev.y, 1); |
1964 | selection_extend (ev.x, ev.y, 1); |
1948 | |
1965 | |
1949 | MEvent.button = Button3; |
1966 | MEvent.button = Button3; |
1950 | break; |
1967 | break; |
1951 | } |
1968 | } |
1952 | } |
1969 | } |
1953 | |
1970 | |
1954 | MEvent.time = ev.time; |
1971 | MEvent.time = ev.time; |
1955 | return; |
1972 | return; |
1956 | } |
1973 | } |
1957 | |
1974 | |
… | |
… | |
2096 | } |
2113 | } |
2097 | } |
2114 | } |
2098 | |
2115 | |
2099 | return; |
2116 | return; |
2100 | } |
2117 | } |
2101 | |
|
|
2102 | #if MENUBAR |
|
|
2103 | /* |
|
|
2104 | * Menubar window processing of button press |
|
|
2105 | */ |
|
|
2106 | if (isMenuBarWindow (ev.window)) |
|
|
2107 | menubar_control (ev); |
|
|
2108 | #endif |
|
|
2109 | } |
2118 | } |
2110 | |
2119 | |
2111 | void |
2120 | void |
2112 | rxvt_term::button_release (XButtonEvent &ev) |
2121 | rxvt_term::button_release (XButtonEvent &ev) |
2113 | { |
2122 | { |
… | |
… | |
2119 | |
2128 | |
2120 | if (scrollbar_isUpDn ()) |
2129 | if (scrollbar_isUpDn ()) |
2121 | { |
2130 | { |
2122 | scrollBar.setIdle (); |
2131 | scrollBar.setIdle (); |
2123 | scrollbar_show (0); |
2132 | scrollbar_show (0); |
2124 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2125 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2126 | #endif |
|
|
2127 | } |
2133 | } |
2128 | |
2134 | |
2129 | #ifdef SELECTION_SCROLLING |
2135 | #ifdef SELECTION_SCROLLING |
2130 | if (sel_scroll_ev.active) |
2136 | if (sel_scroll_ev.active) |
2131 | sel_scroll_ev.stop(); |
2137 | sel_scroll_ev.stop(); |
2132 | #endif |
2138 | #endif |
2133 | |
2139 | |
2134 | if (ev.window == vt) |
2140 | if (ev.window == vt) |
2135 | { |
2141 | { |
|
|
2142 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2143 | return; |
|
|
2144 | |
2136 | #if ISO_14755 |
2145 | #if ISO_14755 |
2137 | // 5.4 |
2146 | // 5.4 |
2138 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2147 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2139 | return; |
2148 | return; |
2140 | #endif |
2149 | #endif |
|
|
2150 | |
2141 | if (reportmode) |
2151 | if (reportmode) |
2142 | { |
2152 | { |
2143 | /* mouse report from vt window */ |
2153 | /* mouse report from vt window */ |
2144 | /* don't report release of wheel "buttons" */ |
2154 | /* don't report release of wheel "buttons" */ |
2145 | if (ev.button >= 4) |
2155 | if (ev.button >= 4) |
… | |
… | |
2169 | if (priv_modes & PrivMode_mouse_report |
2179 | if (priv_modes & PrivMode_mouse_report |
2170 | && bypass_keystate |
2180 | && bypass_keystate |
2171 | && ev.button == Button1 && MEvent.clicks <= 1) |
2181 | && ev.button == Button1 && MEvent.clicks <= 1) |
2172 | selection_extend (ev.x, ev.y, 0); |
2182 | selection_extend (ev.x, ev.y, 0); |
2173 | |
2183 | |
2174 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2175 | return; |
|
|
2176 | |
|
|
2177 | switch (ev.button) |
2184 | switch (ev.button) |
2178 | { |
2185 | { |
2179 | case Button1: |
2186 | case Button1: |
2180 | case Button3: |
2187 | case Button3: |
2181 | selection_make (ev.time); |
2188 | selection_make (ev.time); |
2182 | break; |
2189 | break; |
|
|
2190 | |
2183 | case Button2: |
2191 | case Button2: |
2184 | selection_request (ev.time, ev.x, ev.y); |
2192 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2193 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2185 | break; |
2194 | break; |
|
|
2195 | |
2186 | #ifdef MOUSE_WHEEL |
2196 | #ifdef MOUSE_WHEEL |
2187 | case Button4: |
2197 | case Button4: |
2188 | case Button5: |
2198 | case Button5: |
2189 | { |
2199 | { |
2190 | int i; |
2200 | int i; |
… | |
… | |
2192 | |
2202 | |
2193 | v = ev.button == Button4 ? UP : DN; |
2203 | v = ev.button == Button4 ? UP : DN; |
2194 | |
2204 | |
2195 | if (ev.state & ShiftMask) |
2205 | if (ev.state & ShiftMask) |
2196 | i = 1; |
2206 | i = 1; |
2197 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2207 | else if (option (Opt_mouseWheelScrollPage)) |
2198 | i = nrow - 1; |
2208 | i = nrow - 1; |
2199 | else |
2209 | else |
2200 | i = 5; |
2210 | i = 5; |
2201 | |
2211 | |
2202 | # ifdef MOUSE_SLIP_WHEELING |
2212 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2222 | } |
2232 | } |
2223 | break; |
2233 | break; |
2224 | #endif |
2234 | #endif |
2225 | } |
2235 | } |
2226 | } |
2236 | } |
2227 | #ifdef MENUBAR |
|
|
2228 | else if (isMenuBarWindow (ev.window)) |
|
|
2229 | menubar_control (ev); |
|
|
2230 | #endif |
|
|
2231 | } |
2237 | } |
2232 | |
|
|
2233 | #ifdef TRANSPARENT |
|
|
2234 | #if TINTING |
|
|
2235 | /* taken from aterm-0.4.2 */ |
|
|
2236 | |
|
|
2237 | typedef uint32_t RUINT32T; |
|
|
2238 | |
|
|
2239 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2240 | { |
|
|
2241 | int sh_r, sh_g, sh_b; |
|
|
2242 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2243 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2244 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2245 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2246 | int i; |
|
|
2247 | |
|
|
2248 | Visual *visual = display->visual; |
|
|
2249 | |
|
|
2250 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2251 | |
|
|
2252 | /* for convenience */ |
|
|
2253 | mask_r = visual->red_mask; |
|
|
2254 | mask_g = visual->green_mask; |
|
|
2255 | mask_b = visual->blue_mask; |
|
|
2256 | |
|
|
2257 | /* boring lookup table pre-initialization */ |
|
|
2258 | switch (srcImage->bits_per_pixel) { |
|
|
2259 | case 15: |
|
|
2260 | if ((mask_r != 0x7c00) || |
|
|
2261 | (mask_g != 0x03e0) || |
|
|
2262 | (mask_b != 0x001f)) |
|
|
2263 | return; |
|
|
2264 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2265 | lookup_r = lookup; |
|
|
2266 | lookup_g = lookup+32; |
|
|
2267 | lookup_b = lookup+32+32; |
|
|
2268 | sh_r = 10; |
|
|
2269 | sh_g = 5; |
|
|
2270 | sh_b = 0; |
|
|
2271 | break; |
|
|
2272 | case 16: |
|
|
2273 | if ((mask_r != 0xf800) || |
|
|
2274 | (mask_g != 0x07e0) || |
|
|
2275 | (mask_b != 0x001f)) |
|
|
2276 | return; |
|
|
2277 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2278 | lookup_r = lookup; |
|
|
2279 | lookup_g = lookup+32; |
|
|
2280 | lookup_b = lookup+32+64; |
|
|
2281 | sh_r = 11; |
|
|
2282 | sh_g = 5; |
|
|
2283 | sh_b = 0; |
|
|
2284 | break; |
|
|
2285 | case 24: |
|
|
2286 | if ((mask_r != 0xff0000) || |
|
|
2287 | (mask_g != 0x00ff00) || |
|
|
2288 | (mask_b != 0x0000ff)) |
|
|
2289 | return; |
|
|
2290 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2291 | lookup_r = lookup; |
|
|
2292 | lookup_g = lookup+256; |
|
|
2293 | lookup_b = lookup+256+256; |
|
|
2294 | sh_r = 16; |
|
|
2295 | sh_g = 8; |
|
|
2296 | sh_b = 0; |
|
|
2297 | break; |
|
|
2298 | case 32: |
|
|
2299 | if ((mask_r != 0xff0000) || |
|
|
2300 | (mask_g != 0x00ff00) || |
|
|
2301 | (mask_b != 0x0000ff)) |
|
|
2302 | return; |
|
|
2303 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2304 | lookup_r = lookup; |
|
|
2305 | lookup_g = lookup+256; |
|
|
2306 | lookup_b = lookup+256+256; |
|
|
2307 | sh_r = 16; |
|
|
2308 | sh_g = 8; |
|
|
2309 | sh_b = 0; |
|
|
2310 | break; |
|
|
2311 | default: |
|
|
2312 | return; /* we do not support this color depth */ |
|
|
2313 | } |
|
|
2314 | |
|
|
2315 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2316 | if (shade < 0) { |
|
|
2317 | shade = -shade; |
|
|
2318 | if (shade < 0) shade = 0; |
|
|
2319 | if (shade > 100) shade = 100; |
|
|
2320 | |
|
|
2321 | lower_lim_r = 65535-rm; |
|
|
2322 | lower_lim_g = 65535-gm; |
|
|
2323 | lower_lim_b = 65535-bm; |
|
|
2324 | |
|
|
2325 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2326 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2327 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2328 | |
|
|
2329 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2330 | } else { |
|
|
2331 | if (shade < 0) shade = 0; |
|
|
2332 | if (shade > 100) shade = 100; |
|
|
2333 | |
|
|
2334 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2335 | |
|
|
2336 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2337 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2338 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2339 | } |
|
|
2340 | |
|
|
2341 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2342 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2343 | { |
|
|
2344 | unsigned int tmp; |
|
|
2345 | |
|
|
2346 | tmp = lower_lim_r; |
|
|
2347 | lower_lim_r = lower_lim_b; |
|
|
2348 | lower_lim_b = tmp; |
|
|
2349 | |
|
|
2350 | tmp = upper_lim_r; |
|
|
2351 | upper_lim_r = upper_lim_b; |
|
|
2352 | upper_lim_b = tmp; |
|
|
2353 | } |
|
|
2354 | |
|
|
2355 | /* fill our lookup tables */ |
|
|
2356 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2357 | { |
|
|
2358 | RUINT32T tmp; |
|
|
2359 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2360 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2361 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2362 | } |
|
|
2363 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2364 | { |
|
|
2365 | RUINT32T tmp; |
|
|
2366 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2367 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2368 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2369 | } |
|
|
2370 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2371 | { |
|
|
2372 | RUINT32T tmp; |
|
|
2373 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2374 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2375 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2376 | } |
|
|
2377 | |
|
|
2378 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2379 | switch (srcImage->bits_per_pixel) |
|
|
2380 | { |
|
|
2381 | case 15: |
|
|
2382 | { |
|
|
2383 | unsigned short *p1, *pf, *p, *pl; |
|
|
2384 | p1 = (unsigned short *) srcImage->data; |
|
|
2385 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2386 | while (p1 < pf) |
|
|
2387 | { |
|
|
2388 | p = p1; |
|
|
2389 | pl = p1 + srcImage->width; |
|
|
2390 | for (; p < pl; p++) |
|
|
2391 | { |
|
|
2392 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2393 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2394 | lookup_b[(*p & 0x001f)]; |
|
|
2395 | } |
|
|
2396 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2397 | } |
|
|
2398 | break; |
|
|
2399 | } |
|
|
2400 | case 16: |
|
|
2401 | { |
|
|
2402 | unsigned short *p1, *pf, *p, *pl; |
|
|
2403 | p1 = (unsigned short *) srcImage->data; |
|
|
2404 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2405 | while (p1 < pf) |
|
|
2406 | { |
|
|
2407 | p = p1; |
|
|
2408 | pl = p1 + srcImage->width; |
|
|
2409 | for (; p < pl; p++) |
|
|
2410 | { |
|
|
2411 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2412 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2413 | lookup_b[(*p & 0x001f)]; |
|
|
2414 | } |
|
|
2415 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2416 | } |
|
|
2417 | break; |
|
|
2418 | } |
|
|
2419 | case 24: |
|
|
2420 | { |
|
|
2421 | unsigned char *p1, *pf, *p, *pl; |
|
|
2422 | p1 = (unsigned char *) srcImage->data; |
|
|
2423 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2424 | while (p1 < pf) |
|
|
2425 | { |
|
|
2426 | p = p1; |
|
|
2427 | pl = p1 + srcImage->width * 3; |
|
|
2428 | for (; p < pl; p += 3) |
|
|
2429 | { |
|
|
2430 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2431 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2432 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2433 | } |
|
|
2434 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2435 | } |
|
|
2436 | break; |
|
|
2437 | } |
|
|
2438 | case 32: |
|
|
2439 | { |
|
|
2440 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2441 | p1 = (RUINT32T *) srcImage->data; |
|
|
2442 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2443 | |
|
|
2444 | while (p1 < pf) |
|
|
2445 | { |
|
|
2446 | p = p1; |
|
|
2447 | pl = p1 + srcImage->width; |
|
|
2448 | for (; p < pl; p++) |
|
|
2449 | { |
|
|
2450 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2451 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2452 | lookup_b[(*p & 0x0000ff)] | |
|
|
2453 | (*p & ~0xffffff); |
|
|
2454 | } |
|
|
2455 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2456 | } |
|
|
2457 | break; |
|
|
2458 | } |
|
|
2459 | } |
|
|
2460 | |
|
|
2461 | free (lookup); |
|
|
2462 | } |
|
|
2463 | #endif |
|
|
2464 | |
|
|
2465 | /* |
|
|
2466 | * Check our parents are still who we think they are. |
|
|
2467 | * Do transparency updates if required |
|
|
2468 | */ |
|
|
2469 | int |
|
|
2470 | rxvt_term::check_our_parents () |
|
|
2471 | { |
|
|
2472 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2473 | unsigned long nitems, bytes_after; |
|
|
2474 | Atom atype; |
|
|
2475 | unsigned char *prop = NULL; |
|
|
2476 | Window root, oldp, *list; |
|
|
2477 | Pixmap rootpixmap = None; |
|
|
2478 | XWindowAttributes wattr, wrootattr; |
|
|
2479 | dDisp; |
|
|
2480 | |
|
|
2481 | pchanged = 0; |
|
|
2482 | |
|
|
2483 | if (!OPTION (Opt_transparent)) |
|
|
2484 | return pchanged; /* Don't try any more */ |
|
|
2485 | |
|
|
2486 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2487 | rootdepth = wrootattr.depth; |
|
|
2488 | |
|
|
2489 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2490 | |
|
|
2491 | if (rootdepth != wattr.depth) |
|
|
2492 | { |
|
|
2493 | if (am_transparent) |
|
|
2494 | { |
|
|
2495 | pchanged = 1; |
|
|
2496 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2497 | am_transparent = am_pixmap_trans = 0; |
|
|
2498 | } |
|
|
2499 | |
|
|
2500 | return pchanged; /* Don't try any more */ |
|
|
2501 | } |
|
|
2502 | |
|
|
2503 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2504 | XSync (disp, False); |
|
|
2505 | |
|
|
2506 | /* |
|
|
2507 | * Make the frame window set by the window manager have |
|
|
2508 | * the root background. Some window managers put multiple nested frame |
|
|
2509 | * windows for each client, so we have to take care about that. |
|
|
2510 | */ |
|
|
2511 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2512 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2513 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2514 | &nitems, &bytes_after, &prop) == Success); |
|
|
2515 | |
|
|
2516 | if (!i || prop == NULL) |
|
|
2517 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2518 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2519 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2520 | &nitems, &bytes_after, &prop) == Success); |
|
|
2521 | |
|
|
2522 | if (!i || prop == NULL |
|
|
2523 | #if TINTING |
|
|
2524 | || !rs[Rs_color + Color_tint] |
|
|
2525 | #endif |
|
|
2526 | ) |
|
|
2527 | have_pixmap = 0; |
|
|
2528 | else |
|
|
2529 | { |
|
|
2530 | have_pixmap = 1; |
|
|
2531 | rootpixmap = *(Pixmap *)prop; |
|
|
2532 | XFree (prop); |
|
|
2533 | } |
|
|
2534 | |
|
|
2535 | if (have_pixmap) |
|
|
2536 | { |
|
|
2537 | /* |
|
|
2538 | * Copy display->root pixmap transparency |
|
|
2539 | */ |
|
|
2540 | int sx, sy, nx, ny; |
|
|
2541 | unsigned int nw, nh; |
|
|
2542 | Window cr; |
|
|
2543 | XImage *image; |
|
|
2544 | GC gc; |
|
|
2545 | XGCValues gcvalue; |
|
|
2546 | |
|
|
2547 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2548 | 0, 0, &sx, &sy, &cr); |
|
|
2549 | nw = (unsigned int)szHint.width; |
|
|
2550 | nh = (unsigned int)szHint.height; |
|
|
2551 | nx = ny = 0; |
|
|
2552 | |
|
|
2553 | if (sx < 0) |
|
|
2554 | { |
|
|
2555 | nw += sx; |
|
|
2556 | nx = -sx; |
|
|
2557 | sx = 0; |
|
|
2558 | } |
|
|
2559 | |
|
|
2560 | if (sy < 0) |
|
|
2561 | { |
|
|
2562 | nh += sy; |
|
|
2563 | ny = -sy; |
|
|
2564 | sy = 0; |
|
|
2565 | } |
|
|
2566 | |
|
|
2567 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2568 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2569 | |
|
|
2570 | XSync (disp, False); |
|
|
2571 | allowedxerror = -1; |
|
|
2572 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2573 | |
|
|
2574 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2575 | /* XXX: may need a delay here? */ |
|
|
2576 | allowedxerror = 0; |
|
|
2577 | |
|
|
2578 | if (image == NULL) |
|
|
2579 | { |
|
|
2580 | if (am_transparent && am_pixmap_trans) |
|
|
2581 | { |
|
|
2582 | pchanged = 1; |
|
|
2583 | if (pixmap != None) |
|
|
2584 | { |
|
|
2585 | XFreePixmap (disp, pixmap); |
|
|
2586 | pixmap = None; |
|
|
2587 | } |
|
|
2588 | } |
|
|
2589 | |
|
|
2590 | am_pixmap_trans = 0; |
|
|
2591 | } |
|
|
2592 | else |
|
|
2593 | { |
|
|
2594 | if (pixmap != None) |
|
|
2595 | XFreePixmap (disp, pixmap); |
|
|
2596 | |
|
|
2597 | #if TINTING |
|
|
2598 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2599 | { |
|
|
2600 | unsigned short rm, gm, bm; |
|
|
2601 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2602 | |
|
|
2603 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2604 | |
|
|
2605 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2606 | } |
|
|
2607 | #endif |
|
|
2608 | |
|
|
2609 | pixmap = XCreatePixmap (disp, vt, |
|
|
2610 | szHint.width, szHint.height, image->depth); |
|
|
2611 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2612 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2613 | nx, ny, image->width, image->height); |
|
|
2614 | XFreeGC (disp, gc); |
|
|
2615 | XDestroyImage (image); |
|
|
2616 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2617 | XClearWindow (disp, parent[0]); |
|
|
2618 | |
|
|
2619 | if (!am_transparent || !am_pixmap_trans) |
|
|
2620 | pchanged = 1; |
|
|
2621 | |
|
|
2622 | am_transparent = am_pixmap_trans = 1; |
|
|
2623 | } |
|
|
2624 | } |
|
|
2625 | |
|
|
2626 | if (am_pixmap_trans) |
|
|
2627 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2628 | else |
|
|
2629 | { |
|
|
2630 | unsigned int n; |
|
|
2631 | /* |
|
|
2632 | * InheritPixmap transparency |
|
|
2633 | */ |
|
|
2634 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2635 | { |
|
|
2636 | oldp = parent[i]; |
|
|
2637 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2638 | &parent[i], &list, &n); |
|
|
2639 | XFree (list); |
|
|
2640 | |
|
|
2641 | if (parent[i] == display->root) |
|
|
2642 | { |
|
|
2643 | if (oldp != None) |
|
|
2644 | pchanged = 1; |
|
|
2645 | |
|
|
2646 | break; |
|
|
2647 | } |
|
|
2648 | |
|
|
2649 | if (oldp != parent[i]) |
|
|
2650 | pchanged = 1; |
|
|
2651 | } |
|
|
2652 | |
|
|
2653 | n = 0; |
|
|
2654 | |
|
|
2655 | if (pchanged) |
|
|
2656 | { |
|
|
2657 | for (; n < (unsigned int)i; n++) |
|
|
2658 | { |
|
|
2659 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2660 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2661 | { |
|
|
2662 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2663 | break; |
|
|
2664 | } |
|
|
2665 | } |
|
|
2666 | } |
|
|
2667 | |
|
|
2668 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2669 | { |
|
|
2670 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2671 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2672 | am_transparent = 0; |
|
|
2673 | /* XXX: also turn off Opt_transparent? */ |
|
|
2674 | } |
|
|
2675 | else |
|
|
2676 | { |
|
|
2677 | #if WAIT_FOR_WM |
|
|
2678 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2679 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2680 | sleep (1); |
|
|
2681 | #endif |
|
|
2682 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2683 | { |
|
|
2684 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2685 | XClearWindow (disp, parent[n]); |
|
|
2686 | } |
|
|
2687 | |
|
|
2688 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2689 | am_transparent = 1; |
|
|
2690 | } |
|
|
2691 | |
|
|
2692 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2693 | parent[i] = None; |
|
|
2694 | } |
|
|
2695 | |
|
|
2696 | if (scrollBar.win) |
|
|
2697 | { |
|
|
2698 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2699 | scrollBar.setIdle (); |
|
|
2700 | scrollbar_show (0); |
|
|
2701 | } |
|
|
2702 | |
|
|
2703 | if (am_transparent) |
|
|
2704 | { |
|
|
2705 | want_refresh = want_full_refresh = 1; |
|
|
2706 | if (am_pixmap_trans) |
|
|
2707 | flush (); |
|
|
2708 | } |
|
|
2709 | |
|
|
2710 | return pchanged; |
|
|
2711 | } |
|
|
2712 | #endif |
|
|
2713 | |
2238 | |
2714 | /*}}} */ |
2239 | /*}}} */ |
2715 | |
2240 | |
2716 | bool |
2241 | bool |
2717 | rxvt_term::cmd_parse () |
2242 | rxvt_term::cmd_parse () |
… | |
… | |
2766 | if (ch == C0_LF) |
2291 | if (ch == C0_LF) |
2767 | nlines++; |
2292 | nlines++; |
2768 | |
2293 | |
2769 | refresh_count++; |
2294 | refresh_count++; |
2770 | |
2295 | |
2771 | if (!OPTION (Opt_jumpScroll) |
2296 | if (!option (Opt_jumpScroll) |
2772 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2297 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2773 | { |
2298 | { |
2774 | refreshnow = true; |
2299 | refreshnow = true; |
2775 | refresh_count = 0; |
2300 | refresh_count = 0; |
2776 | ch = NOCHAR; |
2301 | ch = NOCHAR; |
… | |
… | |
2778 | } |
2303 | } |
2779 | |
2304 | |
2780 | // scr_add_lines only works for nlines <= nrow - 1. |
2305 | // scr_add_lines only works for nlines <= nrow - 1. |
2781 | if (nlines >= nrow - 1) |
2306 | if (nlines >= nrow - 1) |
2782 | { |
2307 | { |
|
|
2308 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2783 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2309 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2784 | scr_add_lines (buf, str - buf, nlines); |
2310 | scr_add_lines (buf, str - buf, nlines); |
2785 | |
2311 | |
2786 | nlines = 0; |
2312 | nlines = 0; |
2787 | str = buf; |
2313 | str = buf; |
2788 | eol = str + min (ncol, UBUFSIZ); |
2314 | eol = str + min (ncol, UBUFSIZ); |
… | |
… | |
2803 | |
2329 | |
2804 | seq_begin = cmdbuf_ptr; |
2330 | seq_begin = cmdbuf_ptr; |
2805 | ch = next_char (); |
2331 | ch = next_char (); |
2806 | } |
2332 | } |
2807 | |
2333 | |
|
|
2334 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2808 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2335 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2809 | scr_add_lines (buf, str - buf, nlines); |
2336 | scr_add_lines (buf, str - buf, nlines); |
2810 | |
2337 | |
2811 | /* |
2338 | /* |
2812 | * If there have been a lot of new lines, then update the screen |
2339 | * If there have been a lot of new lines, then update the screen |
2813 | * What the heck I'll cheat and only refresh less than every page-full. |
2340 | * What the heck I'll cheat and only refresh less than every page-full. |
2814 | * the number of pages between refreshes is refresh_limit, which |
2341 | * the number of pages between refreshes is refresh_limit, which |
2815 | * is incremented here because we must be doing flat-out scrolling. |
2342 | * is incremented here because we must be doing flat-out scrolling. |
2816 | */ |
2343 | */ |
2817 | if (refreshnow) |
2344 | if (refreshnow) |
2818 | { |
2345 | { |
2819 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2346 | if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2820 | refresh_limit++; |
2347 | refresh_limit++; |
2821 | else |
2348 | else |
2822 | { |
2349 | { |
2823 | flag = true; |
2350 | flag = true; |
|
|
2351 | //TODO: due to popular request, implement "skipscroll" option here |
2824 | scr_refresh (refresh_type); |
2352 | scr_refresh (); |
2825 | want_refresh = 1; |
2353 | want_refresh = 1; |
2826 | } |
2354 | } |
2827 | } |
2355 | } |
2828 | |
2356 | |
2829 | } |
2357 | } |
… | |
… | |
2847 | return flag; |
2375 | return flag; |
2848 | } |
2376 | } |
2849 | |
2377 | |
2850 | // read the next character |
2378 | // read the next character |
2851 | wchar_t |
2379 | wchar_t |
2852 | rxvt_term::next_char () |
2380 | rxvt_term::next_char () NOTHROW |
2853 | { |
2381 | { |
2854 | while (cmdbuf_ptr < cmdbuf_endp) |
2382 | while (cmdbuf_ptr < cmdbuf_endp) |
2855 | { |
2383 | { |
2856 | // assume 7-bit to be ascii ALWAYS |
2384 | // assume 7-bit to be ascii ALWAYS |
2857 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2385 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2878 | return NOCHAR; |
2406 | return NOCHAR; |
2879 | } |
2407 | } |
2880 | |
2408 | |
2881 | // read the next octet |
2409 | // read the next octet |
2882 | uint32_t |
2410 | uint32_t |
2883 | rxvt_term::next_octet () |
2411 | rxvt_term::next_octet () NOTHROW |
2884 | { |
2412 | { |
2885 | return cmdbuf_ptr < cmdbuf_endp |
2413 | return cmdbuf_ptr < cmdbuf_endp |
2886 | ? (unsigned char)*cmdbuf_ptr++ |
2414 | ? (unsigned char)*cmdbuf_ptr++ |
2887 | : NOCHAR; |
2415 | : NOCHAR; |
2888 | } |
2416 | } |
|
|
2417 | |
|
|
2418 | static class out_of_input out_of_input; |
2889 | |
2419 | |
2890 | /* rxvt_cmd_getc () - Return next input character */ |
2420 | /* rxvt_cmd_getc () - Return next input character */ |
2891 | /* |
2421 | /* |
2892 | * Return the next input character after first passing any keyboard input |
2422 | * Return the next input character after first passing any keyboard input |
2893 | * to the command. |
2423 | * to the command. |
2894 | */ |
2424 | */ |
2895 | wchar_t |
2425 | wchar_t |
2896 | rxvt_term::cmd_getc () |
2426 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2897 | { |
2427 | { |
2898 | wchar_t c = next_char (); |
2428 | wchar_t c = next_char (); |
2899 | |
2429 | |
2900 | if (c == NOCHAR) |
2430 | if (c == NOCHAR) |
2901 | throw out_of_input; |
2431 | throw out_of_input; |
2902 | |
2432 | |
2903 | return c; |
2433 | return c; |
2904 | } |
2434 | } |
2905 | |
2435 | |
2906 | uint32_t |
2436 | uint32_t |
2907 | rxvt_term::cmd_get8 () |
2437 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2908 | { |
2438 | { |
2909 | uint32_t c = next_octet (); |
2439 | uint32_t c = next_octet (); |
2910 | |
2440 | |
2911 | if (c == NOCHAR) |
2441 | if (c == NOCHAR) |
2912 | throw out_of_input; |
2442 | throw out_of_input; |
… | |
… | |
2978 | { |
2508 | { |
2979 | if ((buf[len++] = cmd_getc ()) == 'i') |
2509 | if ((buf[len++] = cmd_getc ()) == 'i') |
2980 | break; /* done = 1 */ |
2510 | break; /* done = 1 */ |
2981 | } |
2511 | } |
2982 | } |
2512 | } |
2983 | |
2513 | |
2984 | for (i = 0; i < len; i++) |
2514 | for (i = 0; i < len; i++) |
2985 | if (putc (buf[i], fd) == EOF) |
2515 | if (putc (buf[i], fd) == EOF) |
2986 | { |
2516 | { |
2987 | done = 1; |
2517 | done = 1; |
2988 | break; |
2518 | break; |
… | |
… | |
3150 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2680 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3151 | break; |
2681 | break; |
3152 | case '+': |
2682 | case '+': |
3153 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2683 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3154 | break; |
2684 | break; |
3155 | #if ENABLE_FRILLS |
2685 | #if !ENABLE_MINIMAL |
3156 | case '6': |
2686 | case '6': |
3157 | scr_backindex (); |
2687 | scr_backindex (); |
3158 | break; |
2688 | break; |
3159 | #endif |
2689 | #endif |
3160 | case '7': |
2690 | case '7': |
3161 | scr_cursor (SAVE); |
2691 | scr_cursor (SAVE); |
3162 | break; |
2692 | break; |
3163 | case '8': |
2693 | case '8': |
3164 | scr_cursor (RESTORE); |
2694 | scr_cursor (RESTORE); |
3165 | break; |
2695 | break; |
3166 | #if ENABLE_FRILLS |
2696 | #if !ENABLE_MINIMAL |
3167 | case '9': |
2697 | case '9': |
3168 | scr_forwardindex (); |
2698 | scr_forwardindex (); |
3169 | break; |
2699 | break; |
3170 | #endif |
2700 | #endif |
3171 | case '=': |
2701 | case '=': |
… | |
… | |
3333 | ndef = get_byte_array_bit (csi_defaults, i); |
2863 | ndef = get_byte_array_bit (csi_defaults, i); |
3334 | for (p = 0; p < nargs; p++) |
2864 | for (p = 0; p < nargs; p++) |
3335 | if (arg[p] == -1) |
2865 | if (arg[p] == -1) |
3336 | arg[p] = ndef; |
2866 | arg[p] = ndef; |
3337 | |
2867 | |
3338 | #ifdef DEBUG_CMD |
|
|
3339 | fprintf (stderr, "CSI "); |
|
|
3340 | for (p = 0; p < nargs; p++) |
|
|
3341 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3342 | fprintf (stderr, "%c\n", ch); |
|
|
3343 | #endif |
|
|
3344 | |
|
|
3345 | /* |
2868 | /* |
3346 | * private mode handling |
2869 | * private mode handling |
3347 | */ |
2870 | */ |
3348 | if (priv) |
2871 | if (priv) |
3349 | { |
2872 | { |
3350 | switch (priv) |
2873 | switch (priv) |
3351 | { |
2874 | { |
3352 | case '>': |
2875 | case '>': |
3353 | if (ch == CSI_DA) /* secondary device attributes */ |
2876 | if (ch == CSI_DA) /* secondary device attributes */ |
3354 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
2877 | { |
|
|
2878 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
2879 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2880 | // |
|
|
2881 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2882 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
2883 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
2884 | // |
|
|
2885 | tt_printf ("\033[>%d;94;0c", 'U'); |
|
|
2886 | } |
3355 | break; |
2887 | break; |
3356 | case '?': |
2888 | case '?': |
3357 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2889 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3358 | process_terminal_mode (ch, priv, nargs, arg); |
2890 | process_terminal_mode (ch, priv, nargs, arg); |
3359 | break; |
2891 | break; |
… | |
… | |
3485 | break; |
3017 | break; |
3486 | case 6: /* CPR requested */ |
3018 | case 6: /* CPR requested */ |
3487 | scr_report_position (); |
3019 | scr_report_position (); |
3488 | break; |
3020 | break; |
3489 | case 7: /* unofficial extension */ |
3021 | case 7: /* unofficial extension */ |
3490 | if (OPTION (Opt_insecure)) |
3022 | if (option (Opt_insecure)) |
3491 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3023 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3492 | break; |
3024 | break; |
3493 | case 8: /* unofficial extension */ |
3025 | case 8: /* unofficial extension */ |
3494 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3026 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3495 | break; |
3027 | break; |
… | |
… | |
3562 | break; |
3094 | break; |
3563 | case CSI_75: |
3095 | case CSI_75: |
3564 | scr_cursor (RESTORE); |
3096 | scr_cursor (RESTORE); |
3565 | break; |
3097 | break; |
3566 | |
3098 | |
3567 | #if ENABLE_FRILLS |
3099 | #if !ENABLE_MINIMAL |
3568 | case CSI_74: |
3100 | case CSI_74: |
3569 | process_window_ops (arg, nargs); |
3101 | process_window_ops (arg, nargs); |
3570 | break; |
3102 | break; |
3571 | #endif |
3103 | #endif |
3572 | |
3104 | |
… | |
… | |
3579 | break; |
3111 | break; |
3580 | } |
3112 | } |
3581 | } |
3113 | } |
3582 | /*}}} */ |
3114 | /*}}} */ |
3583 | |
3115 | |
3584 | #if ENABLE_FRILLS |
3116 | #if !ENABLE_MINIMAL |
3585 | /* ARGSUSED */ |
3117 | /* ARGSUSED */ |
3586 | void |
3118 | void |
3587 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3119 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3588 | { |
3120 | { |
3589 | int x, y; |
3121 | int x, y; |
3590 | XWindowAttributes wattr; |
3122 | XWindowAttributes wattr; |
3591 | Window wdummy; |
3123 | Window wdummy; |
3592 | dDisp; |
3124 | |
|
|
3125 | dLocal (Display *, dpy); |
3593 | |
3126 | |
3594 | if (nargs == 0) |
3127 | if (nargs == 0) |
3595 | return; |
3128 | return; |
3596 | |
3129 | |
3597 | switch (args[0]) |
3130 | switch (args[0]) |
3598 | { |
3131 | { |
3599 | /* |
3132 | /* |
3600 | * commands |
3133 | * commands |
3601 | */ |
3134 | */ |
3602 | case 1: /* deiconify window */ |
3135 | case 1: /* deiconify window */ |
3603 | XMapWindow (disp, parent[0]); |
3136 | XMapWindow (dpy, parent[0]); |
3604 | break; |
3137 | break; |
3605 | case 2: /* iconify window */ |
3138 | case 2: /* iconify window */ |
3606 | XIconifyWindow (disp, parent[0], display->screen); |
3139 | XIconifyWindow (dpy, parent[0], display->screen); |
3607 | break; |
3140 | break; |
3608 | case 3: /* set position (pixels) */ |
3141 | case 3: /* set position (pixels) */ |
3609 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3142 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3610 | break; |
3143 | break; |
3611 | case 4: /* set size (pixels) */ |
3144 | case 4: /* set size (pixels) */ |
3612 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3145 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3613 | break; |
3146 | break; |
3614 | case 5: /* raise window */ |
3147 | case 5: /* raise window */ |
3615 | XRaiseWindow (disp, parent[0]); |
3148 | XRaiseWindow (dpy, parent[0]); |
3616 | break; |
3149 | break; |
3617 | case 6: /* lower window */ |
3150 | case 6: /* lower window */ |
3618 | XLowerWindow (disp, parent[0]); |
3151 | XLowerWindow (dpy, parent[0]); |
3619 | break; |
3152 | break; |
3620 | case 7: /* refresh window */ |
3153 | case 7: /* refresh window */ |
3621 | scr_touch (true); |
3154 | scr_touch (true); |
3622 | break; |
3155 | break; |
3623 | case 8: /* set size (chars) */ |
3156 | case 8: /* set size (chars) */ |
… | |
… | |
3630 | if (args[0] >= 24) /* set height (chars) */ |
3163 | if (args[0] >= 24) /* set height (chars) */ |
3631 | set_widthheight ((unsigned int)width, |
3164 | set_widthheight ((unsigned int)width, |
3632 | (unsigned int) (args[1] * fheight)); |
3165 | (unsigned int) (args[1] * fheight)); |
3633 | break; |
3166 | break; |
3634 | |
3167 | |
3635 | |
|
|
3636 | /* |
3168 | /* |
3637 | * reports - some output format copied from XTerm |
3169 | * reports - some output format copied from XTerm |
3638 | */ |
3170 | */ |
3639 | case 11: /* report window state */ |
3171 | case 11: /* report window state */ |
3640 | XGetWindowAttributes (disp, parent[0], &wattr); |
3172 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3641 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3173 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3642 | break; |
3174 | break; |
3643 | case 13: /* report window position */ |
3175 | case 13: /* report window position */ |
3644 | XGetWindowAttributes (disp, parent[0], &wattr); |
3176 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3645 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3177 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3646 | -wattr.border_width, -wattr.border_width, |
3178 | -wattr.border_width, -wattr.border_width, |
3647 | &x, &y, &wdummy); |
3179 | &x, &y, &wdummy); |
3648 | tt_printf ("\033[3;%d;%dt", x, y); |
3180 | tt_printf ("\033[3;%d;%dt", x, y); |
3649 | break; |
3181 | break; |
3650 | case 14: /* report window size (pixels) */ |
3182 | case 14: /* report window size (pixels) */ |
3651 | XGetWindowAttributes (disp, parent[0], &wattr); |
3183 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3652 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3184 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3653 | break; |
3185 | break; |
3654 | case 18: /* report text area size (chars) */ |
3186 | case 18: /* report text area size (chars) */ |
3655 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3187 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3656 | break; |
3188 | break; |
… | |
… | |
3658 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3190 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3659 | break; |
3191 | break; |
3660 | case 20: /* report icon label */ |
3192 | case 20: /* report icon label */ |
3661 | { |
3193 | { |
3662 | char *s; |
3194 | char *s; |
3663 | XGetIconName (disp, parent[0], &s); |
3195 | XGetIconName (dpy, parent[0], &s); |
3664 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3196 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3665 | XFree (s); |
3197 | XFree (s); |
3666 | } |
3198 | } |
3667 | break; |
3199 | break; |
3668 | case 21: /* report window title */ |
3200 | case 21: /* report window title */ |
3669 | { |
3201 | { |
3670 | char *s; |
3202 | char *s; |
3671 | XFetchName (disp, parent[0], &s); |
3203 | XFetchName (dpy, parent[0], &s); |
3672 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3204 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3673 | XFree (s); |
3205 | XFree (s); |
3674 | } |
3206 | } |
3675 | break; |
3207 | break; |
3676 | } |
3208 | } |
3677 | } |
3209 | } |
… | |
… | |
3704 | seen_esc = true; |
3236 | seen_esc = true; |
3705 | continue; |
3237 | continue; |
3706 | } |
3238 | } |
3707 | else if (ch == C0_BEL || ch == CHAR_ST) |
3239 | else if (ch == C0_BEL || ch == CHAR_ST) |
3708 | break; |
3240 | break; |
|
|
3241 | else if (ch == C0_SYN) |
|
|
3242 | ch = cmd_get8 (); |
3709 | else if (ch < 0x20) |
3243 | else if (ch < 0x20) |
3710 | return NULL; /* other control character - exit */ |
3244 | return NULL; /* other control character - exit */ |
3711 | |
3245 | |
3712 | seen_esc = false; |
3246 | seen_esc = false; |
3713 | |
3247 | |
3714 | if (n >= STRING_MAX - 1) |
3248 | if (n >= STRING_MAX - 1) |
3715 | // stop at some sane length |
3249 | // stop at some sane length |
3716 | return NULL; |
3250 | return NULL; |
3717 | |
3251 | |
3718 | if (ch == C0_SYN) |
|
|
3719 | string[n++] = cmd_get8 (); |
|
|
3720 | else |
|
|
3721 | string[n++] = ch; |
3252 | string[n++] = ch; |
3722 | } |
3253 | } |
3723 | |
3254 | |
3724 | string[n++] = '\0'; |
3255 | string[n++] = '\0'; |
3725 | |
3256 | |
3726 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3257 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
… | |
… | |
3777 | void |
3308 | void |
3778 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3309 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3779 | { |
3310 | { |
3780 | if (str[0] == '?' && !str[1]) |
3311 | if (str[0] == '?' && !str[1]) |
3781 | { |
3312 | { |
3782 | unsigned short r, g, b; |
3313 | rgba c; |
3783 | pix_colors_focused[color].get (display, r, g, b); |
3314 | pix_colors_focused[color].get (c); |
|
|
3315 | |
|
|
3316 | #if XFT |
|
|
3317 | if (c.a != rgba::MAX_CC) |
|
|
3318 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3319 | else |
|
|
3320 | #endif |
3784 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3321 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3785 | } |
3322 | } |
3786 | else |
3323 | else |
3787 | set_window_color (color, str); |
3324 | set_window_color (color, str); |
3788 | } |
3325 | } |
3789 | |
3326 | |
… | |
… | |
3791 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3328 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3792 | */ |
3329 | */ |
3793 | void |
3330 | void |
3794 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3331 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3795 | { |
3332 | { |
3796 | int changed = 0; |
|
|
3797 | int color; |
3333 | int color; |
3798 | char *buf, *name; |
3334 | char *buf, *name; |
3799 | bool query = str[0] == '?' && !str[1]; |
3335 | bool query = str[0] == '?' && !str[1]; |
3800 | int saveop = op; |
3336 | int saveop = op; |
3801 | dDisp; |
3337 | |
|
|
3338 | dLocal (Display *, dpy); |
3802 | |
3339 | |
3803 | assert (str != NULL); |
3340 | assert (str != NULL); |
|
|
3341 | |
|
|
3342 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3343 | return; |
|
|
3344 | |
3804 | switch (op) |
3345 | switch (op) |
3805 | { |
3346 | { |
3806 | case XTerm_name: |
3347 | case XTerm_name: |
3807 | set_title (str); |
3348 | set_title (str); |
3808 | /* FALLTHROUGH */ |
3349 | /* FALLTHROUGH */ |
… | |
… | |
3822 | unsigned long bytes_after; |
3363 | unsigned long bytes_after; |
3823 | unsigned char *value = 0; |
3364 | unsigned char *value = 0; |
3824 | const char *str = ""; |
3365 | const char *str = ""; |
3825 | |
3366 | |
3826 | if (prop |
3367 | if (prop |
3827 | && XGetWindowProperty (disp, parent[0], |
3368 | && XGetWindowProperty (dpy, parent[0], |
3828 | prop, 0, 1<<16, 0, AnyPropertyType, |
3369 | prop, 0, 1<<16, 0, AnyPropertyType, |
3829 | &actual_type, &actual_format, |
3370 | &actual_type, &actual_format, |
3830 | &nitems, &bytes_after, &value) == Success |
3371 | &nitems, &bytes_after, &value) == Success |
3831 | && actual_type != None |
3372 | && actual_type != None |
3832 | && actual_format == 8) |
3373 | && actual_format == 8) |
3833 | str = (const char *)(value); |
3374 | str = (const char *)(value); |
3834 | |
3375 | |
3835 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3376 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3836 | |
3377 | |
3837 | XFree (value); |
3378 | XFree (value); |
3838 | } |
3379 | } |
3839 | else |
3380 | else |
3840 | { |
3381 | { |
… | |
… | |
3844 | { |
3385 | { |
3845 | *eq = 0; |
3386 | *eq = 0; |
3846 | set_utf8_property (display->atom (str), eq + 1); |
3387 | set_utf8_property (display->atom (str), eq + 1); |
3847 | } |
3388 | } |
3848 | else |
3389 | else |
3849 | XDeleteProperty (disp, parent[0], |
3390 | XDeleteProperty (dpy, parent[0], |
3850 | display->atom (str)); |
3391 | display->atom (str)); |
3851 | } |
3392 | } |
3852 | break; |
3393 | break; |
3853 | |
3394 | |
3854 | case XTerm_Color: |
3395 | case XTerm_Color: |
… | |
… | |
3864 | break; |
3405 | break; |
3865 | |
3406 | |
3866 | if ((buf = strchr (name, ';')) != NULL) |
3407 | if ((buf = strchr (name, ';')) != NULL) |
3867 | *buf++ = '\0'; |
3408 | *buf++ = '\0'; |
3868 | |
3409 | |
3869 | if (name[0] == '?' && !name[1]) |
3410 | process_color_seq (op, color, name, resp); |
3870 | { |
|
|
3871 | unsigned short r, g, b; |
|
|
3872 | pix_colors_focused[color].get (display, r, g, b); |
|
|
3873 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3874 | } |
|
|
3875 | else |
|
|
3876 | set_window_color (color, name); |
|
|
3877 | } |
3411 | } |
3878 | break; |
3412 | break; |
3879 | case XTerm_Color00: |
3413 | case XTerm_Color00: |
3880 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3414 | process_color_seq (op, Color_fg, str, resp); |
3881 | break; |
3415 | break; |
3882 | case XTerm_Color01: |
3416 | case XTerm_Color01: |
3883 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3417 | process_color_seq (op, Color_bg, str, resp); |
3884 | break; |
3418 | break; |
3885 | #ifndef NO_CURSORCOLOR |
3419 | #ifndef NO_CURSORCOLOR |
3886 | case XTerm_Color_cursor: |
3420 | case XTerm_Color_cursor: |
3887 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3421 | process_color_seq (op, Color_cursor, str, resp); |
3888 | break; |
3422 | break; |
3889 | #endif |
3423 | #endif |
3890 | case XTerm_Color_pointer_fg: |
3424 | case XTerm_Color_pointer_fg: |
3891 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3425 | process_color_seq (op, Color_pointer_fg, str, resp); |
3892 | break; |
3426 | break; |
3893 | case XTerm_Color_pointer_bg: |
3427 | case XTerm_Color_pointer_bg: |
3894 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3428 | process_color_seq (op, Color_pointer_bg, str, resp); |
3895 | break; |
3429 | break; |
3896 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3430 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3897 | case XTerm_Color_RV: |
3431 | case XTerm_Color_RV: |
3898 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3432 | process_color_seq (op, Color_RV, str, resp); |
3899 | break; |
3433 | break; |
3900 | case Rxvt_Color_BD: |
3434 | case Rxvt_Color_BD: |
3901 | case URxvt_Color_BD: |
3435 | case URxvt_Color_BD: |
3902 | process_color_seq (op, Color_BD, str, resp); |
3436 | process_color_seq (op, Color_BD, str, resp); |
3903 | break; |
3437 | break; |
3904 | case Rxvt_Color_UL: |
3438 | case Rxvt_Color_UL: |
3905 | case URxvt_Color_UL: |
3439 | case URxvt_Color_UL: |
3906 | process_color_seq (op, Color_UL, str, resp); |
3440 | process_color_seq (op, Color_UL, str, resp); |
3907 | break; |
3441 | break; |
3908 | case URxvt_Color_IT: |
3442 | case URxvt_Color_IT: |
3909 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3443 | process_color_seq (op, Color_IT, str, resp); |
3910 | break; |
3444 | break; |
3911 | #endif |
3445 | #endif |
3912 | #if TRANSPARENT && TINTING |
3446 | #if TRANSPARENT && TINTING |
3913 | case URxvt_Color_tint: |
3447 | case URxvt_Color_tint: |
3914 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3448 | process_color_seq (op, Color_tint, str, resp); |
|
|
3449 | |
3915 | check_our_parents (); |
3450 | check_our_parents (); |
|
|
3451 | |
3916 | if (am_transparent) |
3452 | if (am_transparent) |
3917 | want_full_refresh = want_refresh = 1; |
3453 | want_full_refresh = want_refresh = 1; |
|
|
3454 | |
3918 | break; |
3455 | break; |
3919 | #endif |
3456 | #endif |
3920 | |
3457 | |
3921 | case Rxvt_Pixmap: |
3458 | case Rxvt_Pixmap: |
|
|
3459 | { |
3922 | if (*str != ';') |
3460 | if (*str != ';') |
3923 | { |
3461 | { |
3924 | #if XPM_BACKGROUND |
3462 | #if XPM_BACKGROUND |
3925 | scale_pixmap (""); /* reset to default scaling */ |
3463 | scale_pixmap (""); /* reset to default scaling */ |
3926 | set_bgPixmap (str); /* change pixmap */ |
3464 | set_bgPixmap (str); /* change pixmap */ |
3927 | scr_touch (true); |
3465 | scr_touch (true); |
3928 | #endif |
3466 | #endif |
3929 | } |
3467 | } |
3930 | |
3468 | |
|
|
3469 | int changed = 0; |
|
|
3470 | |
3931 | while ((str = strchr (str, ';')) != NULL) |
3471 | while ((str = strchr (str, ';')) != NULL) |
3932 | { |
3472 | { |
3933 | str++; |
3473 | str++; |
3934 | #if XPM_BACKGROUND |
3474 | #if XPM_BACKGROUND |
3935 | changed += scale_pixmap (str); |
3475 | changed += scale_pixmap (str); |
3936 | #endif |
3476 | #endif |
3937 | } |
3477 | } |
3938 | |
3478 | |
3939 | if (changed) |
3479 | if (changed) |
3940 | { |
3480 | { |
3941 | #ifdef XPM_BACKGROUND |
3481 | #ifdef XPM_BACKGROUND |
3942 | resize_pixmap (); |
3482 | resize_pixmap (); |
3943 | scr_touch (true); |
3483 | scr_touch (true); |
3944 | #endif |
3484 | #endif |
3945 | } |
3485 | } |
|
|
3486 | #if TRANSPARENT && defined(HAVE_AFTERIMAGE) |
|
|
3487 | if (option (Opt_transparent)) |
|
|
3488 | check_our_parents (); |
|
|
3489 | #endif |
|
|
3490 | } |
3946 | break; |
3491 | break; |
3947 | |
3492 | |
3948 | case Rxvt_restoreFG: |
3493 | case Rxvt_restoreFG: |
3949 | set_window_color (Color_fg, str); |
3494 | set_window_color (Color_fg, str); |
3950 | break; |
3495 | break; |
… | |
… | |
3954 | |
3499 | |
3955 | case XTerm_logfile: |
3500 | case XTerm_logfile: |
3956 | // TODO, when secure mode? |
3501 | // TODO, when secure mode? |
3957 | break; |
3502 | break; |
3958 | |
3503 | |
3959 | #ifdef MENUBAR |
|
|
3960 | case URxvt_Menu: |
|
|
3961 | if (OPTION (Opt_insecure)) |
|
|
3962 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3963 | break; |
|
|
3964 | #endif |
|
|
3965 | #if 0 |
3504 | #if 0 |
3966 | case Rxvt_dumpscreen: /* no error notices */ |
3505 | case Rxvt_dumpscreen: /* no error notices */ |
3967 | { |
3506 | { |
3968 | int fd; |
3507 | int fd; |
3969 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3508 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
… | |
… | |
3982 | case URxvt_italicFont: |
3521 | case URxvt_italicFont: |
3983 | case URxvt_boldItalicFont: |
3522 | case URxvt_boldItalicFont: |
3984 | #endif |
3523 | #endif |
3985 | if (query) |
3524 | if (query) |
3986 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3525 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3987 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3526 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3988 | ? fontset[op - URxvt_font]->fontdesc : "", |
3527 | ? fontset[op - URxvt_font]->fontdesc : "", |
3989 | resp); |
3528 | resp); |
3990 | else |
3529 | else |
3991 | { |
3530 | { |
3992 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3531 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3995 | allocated.push_back ((void *)res); |
3534 | allocated.push_back ((void *)res); |
3996 | set_fonts (); |
3535 | set_fonts (); |
3997 | } |
3536 | } |
3998 | break; |
3537 | break; |
3999 | |
3538 | |
4000 | #if ENABLE_FRILLS |
3539 | case URxvt_version: |
|
|
3540 | if (query) |
|
|
3541 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3542 | op, |
|
|
3543 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3544 | resp); |
|
|
3545 | break; |
|
|
3546 | |
|
|
3547 | #if !ENABLE_MINIMAL |
4001 | case URxvt_locale: |
3548 | case URxvt_locale: |
4002 | if (query) |
3549 | if (query) |
4003 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3550 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
4004 | else |
3551 | else |
4005 | { |
3552 | { |
4006 | set_locale (str); |
3553 | set_locale (str); |
4007 | pty.set_utf8_mode (enc_utf8); |
3554 | pty->set_utf8_mode (enc_utf8); |
4008 | init_xlocale (); |
3555 | init_xlocale (); |
4009 | } |
3556 | } |
4010 | break; |
3557 | break; |
4011 | |
3558 | |
4012 | case URxvt_view_up: |
3559 | case URxvt_view_up: |
… | |
… | |
4023 | break; |
3570 | break; |
4024 | #endif |
3571 | #endif |
4025 | |
3572 | |
4026 | #if ENABLE_PERL |
3573 | #if ENABLE_PERL |
4027 | case URxvt_perl: |
3574 | case URxvt_perl: |
4028 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3575 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
4029 | ; // no responses yet |
3576 | ; // no responses yet |
4030 | break; |
3577 | break; |
4031 | #endif |
3578 | #endif |
4032 | } |
3579 | } |
4033 | } |
3580 | } |
… | |
… | |
4065 | return state; |
3612 | return state; |
4066 | } |
3613 | } |
4067 | |
3614 | |
4068 | /* we're not using priv _yet_ */ |
3615 | /* we're not using priv _yet_ */ |
4069 | void |
3616 | void |
4070 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3617 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4071 | { |
3618 | { |
4072 | unsigned int i, j; |
3619 | unsigned int i, j; |
4073 | int state; |
3620 | int state; |
4074 | |
3621 | |
4075 | static const struct |
3622 | static const struct |
… | |
… | |
4086 | { 5, PrivMode_rVideo }, |
3633 | { 5, PrivMode_rVideo }, |
4087 | { 6, PrivMode_relOrigin }, |
3634 | { 6, PrivMode_relOrigin }, |
4088 | { 7, PrivMode_Autowrap }, |
3635 | { 7, PrivMode_Autowrap }, |
4089 | // 8, bi-directional support mode |
3636 | // 8, bi-directional support mode |
4090 | { 9, PrivMode_MouseX10 }, |
3637 | { 9, PrivMode_MouseX10 }, |
4091 | #ifdef menuBar_esc |
|
|
4092 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4093 | #endif |
|
|
4094 | // 18, 19 printing-related |
3638 | // 18, 19 printing-related |
4095 | { 25, PrivMode_VisibleCursor }, |
3639 | { 25, PrivMode_VisibleCursor }, |
4096 | #ifdef scrollBar_esc |
3640 | #ifdef scrollBar_esc |
4097 | { scrollBar_esc, PrivMode_scrollBar }, |
3641 | { scrollBar_esc, PrivMode_scrollBar }, |
4098 | #endif |
3642 | #endif |
… | |
… | |
4152 | scr_touch (true); |
3696 | scr_touch (true); |
4153 | break; |
3697 | break; |
4154 | #endif |
3698 | #endif |
4155 | case 1048: /* alternative cursor save */ |
3699 | case 1048: /* alternative cursor save */ |
4156 | case 1049: |
3700 | case 1049: |
4157 | if (OPTION (Opt_secondaryScreen)) |
3701 | if (option (Opt_secondaryScreen)) |
4158 | if (mode == 0) |
3702 | if (mode == 0) |
4159 | scr_cursor (RESTORE); |
3703 | scr_cursor (RESTORE); |
4160 | else if (mode == 1) |
3704 | else if (mode == 1) |
4161 | scr_cursor (SAVE); |
3705 | scr_cursor (SAVE); |
4162 | break; |
3706 | break; |
… | |
… | |
4193 | /* case 8: - auto repeat, can't do on a per window basis */ |
3737 | /* case 8: - auto repeat, can't do on a per window basis */ |
4194 | case 9: /* X10 mouse reporting */ |
3738 | case 9: /* X10 mouse reporting */ |
4195 | if (state) /* orthogonal */ |
3739 | if (state) /* orthogonal */ |
4196 | priv_modes &= ~PrivMode_MouseX11; |
3740 | priv_modes &= ~PrivMode_MouseX11; |
4197 | break; |
3741 | break; |
4198 | #ifdef menuBar_esc |
|
|
4199 | case menuBar_esc: |
|
|
4200 | #ifdef MENUBAR |
|
|
4201 | map_menuBar (state); |
|
|
4202 | #endif |
|
|
4203 | break; |
|
|
4204 | #endif |
|
|
4205 | #ifdef scrollBar_esc |
3742 | #ifdef scrollBar_esc |
4206 | case scrollBar_esc: |
3743 | case scrollBar_esc: |
4207 | if (scrollbar_mapping (state)) |
3744 | if (scrollbar_mapping (state)) |
4208 | { |
3745 | { |
4209 | resize_all_windows (0, 0, 0); |
3746 | resize_all_windows (0, 0, 0); |
… | |
… | |
4234 | break; |
3771 | break; |
4235 | case 1011: /* scroll to bottom on key press */ |
3772 | case 1011: /* scroll to bottom on key press */ |
4236 | set_option (Opt_scrollTtyKeypress, state); |
3773 | set_option (Opt_scrollTtyKeypress, state); |
4237 | break; |
3774 | break; |
4238 | case 1047: /* secondary screen w/ clearing last */ |
3775 | case 1047: /* secondary screen w/ clearing last */ |
4239 | if (OPTION (Opt_secondaryScreen)) |
3776 | if (option (Opt_secondaryScreen)) |
4240 | if (current_screen != PRIMARY) |
3777 | if (current_screen != PRIMARY) |
4241 | scr_erase_screen (2); |
3778 | scr_erase_screen (2); |
4242 | scr_change_screen (state); |
3779 | scr_change_screen (state); |
4243 | break; |
3780 | break; |
4244 | case 1049: /* secondary screen w/ clearing first */ |
3781 | case 1049: /* secondary screen w/ clearing first */ |
4245 | scr_change_screen (state); |
3782 | scr_change_screen (state); |
4246 | if (OPTION (Opt_secondaryScreen)) |
3783 | if (option (Opt_secondaryScreen)) |
4247 | if (current_screen != PRIMARY) |
3784 | if (current_screen != PRIMARY) |
4248 | scr_erase_screen (2); |
3785 | scr_erase_screen (2); |
4249 | break; |
3786 | break; |
4250 | default: |
3787 | default: |
4251 | break; |
3788 | break; |
… | |
… | |
4379 | scr_color (Color_bg, Color_bg); |
3916 | scr_color (Color_bg, Color_bg); |
4380 | break; |
3917 | break; |
4381 | |
3918 | |
4382 | //case 50: // not variable spacing |
3919 | //case 50: // not variable spacing |
4383 | |
3920 | |
4384 | #if ENABLE_FRILLS |
3921 | #if !ENABLE_MINIMAL |
4385 | case 90: |
3922 | case 90: |
4386 | case 91: /* set bright fg color */ |
3923 | case 91: /* set bright fg color */ |
4387 | case 92: |
3924 | case 92: |
4388 | case 93: |
3925 | case 93: |
4389 | case 94: |
3926 | case 94: |
… | |
… | |
4454 | rxvt_term::tt_write (const char *data, unsigned int len) |
3991 | rxvt_term::tt_write (const char *data, unsigned int len) |
4455 | { |
3992 | { |
4456 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
3993 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4457 | return; |
3994 | return; |
4458 | |
3995 | |
4459 | if (pty.pty < 0) |
3996 | if (pty->pty < 0) |
4460 | return; |
3997 | return; |
4461 | |
3998 | |
4462 | if (v_buflen == 0) |
3999 | if (v_buflen == 0) |
4463 | { |
4000 | { |
4464 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4001 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4465 | |
4002 | |
4466 | if ((unsigned int)written == len) |
4003 | if ((unsigned int)written == len) |
4467 | return; |
4004 | return; |
4468 | |
4005 | |
4469 | data += written; |
4006 | data += written; |
… | |
… | |
4478 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4015 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4479 | } |
4016 | } |
4480 | |
4017 | |
4481 | void rxvt_term::pty_write () |
4018 | void rxvt_term::pty_write () |
4482 | { |
4019 | { |
4483 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4020 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4484 | |
4021 | |
4485 | if (written > 0) |
4022 | if (written > 0) |
4486 | { |
4023 | { |
4487 | v_buflen -= written; |
4024 | v_buflen -= written; |
4488 | |
4025 | |