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) |
… | |
… | |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
148 | return; |
144 | return; |
149 | |
145 | |
150 | for (;;) |
146 | for (;;) |
151 | { |
147 | { |
152 | const line_t &l = ROW(y - view_start); |
148 | const line_t &l = ROW(y + view_start); |
153 | |
149 | |
154 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
155 | |
151 | |
156 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
157 | { |
153 | { |
… | |
… | |
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 | * |
… | |
… | |
443 | scr_move_to (0, 1); |
447 | scr_move_to (0, 1); |
444 | return; |
448 | return; |
445 | } |
449 | } |
446 | else if (keysym == XK_End) |
450 | else if (keysym == XK_End) |
447 | { |
451 | { |
448 | scr_move_to (1, 0); |
452 | scr_move_to (1, 1); |
449 | return; |
453 | return; |
450 | } |
454 | } |
451 | } |
455 | } |
452 | #endif |
456 | #endif |
453 | } |
457 | } |
… | |
… | |
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 | |
… | |
… | |
972 | |
1048 | |
973 | if (want_refresh) |
1049 | if (want_refresh) |
974 | { |
1050 | { |
975 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
1051 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
976 | { |
1052 | { |
977 | int row = -view_start; |
1053 | int row = view_start; |
978 | int end_row = row + nrow; |
1054 | int end_row = row + nrow; |
979 | |
1055 | |
980 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
1056 | while (row > top_row && ROW (row - 1).is_longer ()) |
981 | --row; |
1057 | --row; |
982 | |
1058 | |
983 | do |
1059 | do |
984 | { |
1060 | { |
985 | int start_row = row; |
1061 | int start_row = row; |
… | |
… | |
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 | } |
… | |
… | |
1021 | } |
1097 | } |
1022 | |
1098 | |
1023 | void |
1099 | void |
1024 | rxvt_term::check_cb (check_watcher &w) |
1100 | rxvt_term::check_cb (check_watcher &w) |
1025 | { |
1101 | { |
1026 | SET_R (this); |
1102 | make_current (); |
1027 | SET_LOCALE (locale); |
|
|
1028 | |
1103 | |
1029 | display->flush (); |
1104 | display->flush (); |
1030 | |
1105 | |
1031 | if (want_refresh && !flush_ev.active) |
1106 | if (want_refresh && !flush_ev.active) |
1032 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1107 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1033 | } |
1108 | } |
1034 | |
1109 | |
1035 | void |
1110 | void |
1036 | rxvt_term::flush_cb (time_watcher &w) |
1111 | rxvt_term::flush_cb (time_watcher &w) |
1037 | { |
1112 | { |
1038 | SET_R (this); |
1113 | make_current (); |
1039 | SET_LOCALE (locale); |
|
|
1040 | |
1114 | |
1041 | refresh_limit = 1; |
1115 | refresh_limit = 1; |
1042 | refresh_count = 0; |
1116 | refresh_count = 0; |
1043 | flush (); |
1117 | flush (); |
1044 | } |
1118 | } |
… | |
… | |
1048 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1122 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1049 | { |
1123 | { |
1050 | hidden_cursor = !hidden_cursor; |
1124 | hidden_cursor = !hidden_cursor; |
1051 | want_refresh = 1; |
1125 | want_refresh = 1; |
1052 | |
1126 | |
1053 | w.start (w.at + BLINK_INTERVAL); |
1127 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1054 | } |
1128 | } |
1055 | #endif |
1129 | #endif |
1056 | |
1130 | |
1057 | #ifdef TEXT_BLINK |
1131 | #ifdef TEXT_BLINK |
1058 | void |
1132 | void |
… | |
… | |
1072 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1146 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1073 | { |
1147 | { |
1074 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1148 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1075 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1149 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1076 | { |
1150 | { |
1077 | refresh_type |= SMOOTH_REFRESH; |
|
|
1078 | want_refresh = 1; |
1151 | want_refresh = 1; |
1079 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1152 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1080 | } |
1153 | } |
1081 | } |
1154 | } |
1082 | #endif |
1155 | #endif |
… | |
… | |
1086 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1159 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1087 | { |
1160 | { |
1088 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1161 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1089 | { |
1162 | { |
1090 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1163 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1091 | refresh_type |= SMOOTH_REFRESH; |
|
|
1092 | want_refresh = 1; |
1164 | want_refresh = 1; |
1093 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1165 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1094 | } |
1166 | } |
1095 | } |
1167 | } |
1096 | #endif |
1168 | #endif |
… | |
… | |
1101 | { |
1173 | { |
1102 | if (mouse_slip_wheel_speed == 0 |
1174 | if (mouse_slip_wheel_speed == 0 |
1103 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1175 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1104 | : scr_page (UP, mouse_slip_wheel_speed)) |
1176 | : scr_page (UP, mouse_slip_wheel_speed)) |
1105 | { |
1177 | { |
1106 | if (view_start == nsaved || |
1178 | if (view_start == top_row || view_start == 0) |
1107 | view_start == 0) |
|
|
1108 | mouse_slip_wheel_speed = 0; |
1179 | mouse_slip_wheel_speed = 0; |
1109 | |
1180 | |
1110 | refresh_type |= SMOOTH_REFRESH; |
|
|
1111 | want_refresh = 1; |
1181 | want_refresh = 1; |
1112 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1182 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1113 | } |
1183 | } |
1114 | } |
1184 | } |
1115 | #endif |
1185 | #endif |
1116 | |
1186 | |
1117 | #if HAVE_SCHED_YIELD |
1187 | #if LINUX_YIELD_HACK |
1118 | static struct event_handler |
1188 | static struct event_handler |
1119 | { |
1189 | { |
1120 | check_watcher cw_yield; |
1190 | check_watcher yield_ev; |
1121 | |
1191 | |
1122 | void yield (check_watcher &w) |
1192 | void yield_cb (check_watcher &w) |
1123 | { |
1193 | { |
1124 | 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 | |
1125 | w.stop (); |
1202 | w.stop (); |
1126 | } |
1203 | } |
1127 | |
1204 | |
1128 | event_handler () |
1205 | event_handler () |
1129 | : cw_yield (this, &event_handler::yield) |
1206 | : yield_ev (this, &event_handler::yield_cb) |
1130 | { |
1207 | { |
1131 | } |
1208 | } |
1132 | } event_handler; |
1209 | } event_handler; |
1133 | #endif |
1210 | #endif |
1134 | |
1211 | |
… | |
… | |
1145 | |
1222 | |
1146 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1223 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1147 | cmdbuf_ptr = cmdbuf_base; |
1224 | cmdbuf_ptr = cmdbuf_base; |
1148 | cmdbuf_endp = cmdbuf_ptr + n; |
1225 | cmdbuf_endp = cmdbuf_ptr + n; |
1149 | |
1226 | |
1150 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1227 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1151 | |
1228 | |
1152 | if (r > 0) |
1229 | if (r > 0) |
1153 | { |
1230 | { |
1154 | cmdbuf_endp += r; |
1231 | cmdbuf_endp += r; |
1155 | return true; |
1232 | return true; |
1156 | } |
1233 | } |
1157 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1234 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1158 | { |
1235 | { |
1159 | #if HAVE_SCHED_YIELD |
1236 | #if LINUX_YIELD_HACK |
1160 | if (display->is_local) |
1237 | if (display->is_local) |
1161 | event_handler.cw_yield.start (); |
1238 | event_handler.yield_ev.start (); |
1162 | #endif |
1239 | #endif |
1163 | } |
1240 | } |
1164 | else |
1241 | else |
1165 | { |
1242 | { |
1166 | pty_ev.stop (); |
1243 | pty_ev.stop (); |
1167 | |
1244 | |
1168 | if (!OPTION (Opt_hold)) |
1245 | if (!option (Opt_hold)) |
1169 | destroy (); |
1246 | destroy (); |
1170 | } |
1247 | } |
1171 | |
1248 | |
1172 | return false; |
1249 | return false; |
1173 | } |
1250 | } |
1174 | |
1251 | |
1175 | void |
1252 | void |
1176 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1253 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1177 | { |
1254 | { |
1178 | SET_R (this); |
1255 | make_current (); |
1179 | SET_LOCALE (locale); |
|
|
1180 | |
1256 | |
1181 | if (revents & EVENT_READ) |
1257 | if (revents & EVENT_READ) |
1182 | // loop, but don't allow a single term to monopolize us |
1258 | // loop, but don't allow a single term to monopolize us |
1183 | while (pty_fill ()) |
1259 | while (pty_fill ()) |
1184 | if (cmd_parse ()) |
1260 | if (cmd_parse ()) |
… | |
… | |
1189 | } |
1265 | } |
1190 | |
1266 | |
1191 | void |
1267 | void |
1192 | rxvt_term::pointer_unblank () |
1268 | rxvt_term::pointer_unblank () |
1193 | { |
1269 | { |
1194 | XDefineCursor (display->display, vt, TermWin_cursor); |
1270 | XDefineCursor (dpy, vt, TermWin_cursor); |
1195 | recolour_cursor (); |
1271 | recolour_cursor (); |
1196 | |
1272 | |
1197 | #ifdef POINTER_BLANK |
1273 | #ifdef POINTER_BLANK |
1198 | hidden_pointer = 0; |
1274 | hidden_pointer = 0; |
1199 | |
1275 | |
1200 | if (OPTION (Opt_pointerBlank)) |
1276 | if (option (Opt_pointerBlank)) |
1201 | pointer_ev.start (NOW + pointerBlankDelay); |
1277 | pointer_ev.start (NOW + pointerBlankDelay); |
1202 | #endif |
1278 | #endif |
1203 | } |
1279 | } |
1204 | |
1280 | |
1205 | #ifdef POINTER_BLANK |
1281 | #ifdef POINTER_BLANK |
1206 | void |
1282 | void |
1207 | rxvt_term::pointer_blank () |
1283 | rxvt_term::pointer_blank () |
1208 | { |
1284 | { |
1209 | if (!OPTION (Opt_pointerBlank)) |
1285 | if (!option (Opt_pointerBlank)) |
1210 | return; |
1286 | return; |
1211 | |
1287 | |
1212 | XDefineCursor (display->display, vt, display->blank_cursor); |
1288 | XDefineCursor (dpy, vt, display->blank_cursor); |
1213 | XFlush (display->display); |
1289 | XFlush (dpy); |
1214 | |
1290 | |
1215 | hidden_pointer = 1; |
1291 | hidden_pointer = 1; |
1216 | } |
1292 | } |
1217 | |
1293 | |
1218 | void |
1294 | void |
1219 | rxvt_term::pointer_cb (time_watcher &w) |
1295 | rxvt_term::pointer_cb (time_watcher &w) |
1220 | { |
1296 | { |
1221 | SET_R (this); |
1297 | make_current (); |
1222 | SET_LOCALE (locale); |
|
|
1223 | |
1298 | |
1224 | pointer_blank (); |
1299 | pointer_blank (); |
1225 | } |
1300 | } |
1226 | #endif |
1301 | #endif |
1227 | |
1302 | |
… | |
… | |
1292 | (32 + button_number + key_state), |
1367 | (32 + button_number + key_state), |
1293 | (32 + x + 1), |
1368 | (32 + x + 1), |
1294 | (32 + y + 1)); |
1369 | (32 + y + 1)); |
1295 | } |
1370 | } |
1296 | |
1371 | |
1297 | #ifdef USING_W11LIB |
|
|
1298 | void |
|
|
1299 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1300 | { |
|
|
1301 | rxvt_t *r = rxvt_get_r (); |
|
|
1302 | |
|
|
1303 | x_cb (*ev); |
|
|
1304 | } |
|
|
1305 | #endif |
|
|
1306 | |
|
|
1307 | /*{{{ process an X event */ |
1372 | /*{{{ process an X event */ |
1308 | void |
1373 | void |
1309 | rxvt_term::x_cb (XEvent &ev) |
1374 | rxvt_term::x_cb (XEvent &ev) |
1310 | { |
1375 | { |
1311 | dDisp; |
1376 | make_current (); |
1312 | |
1377 | |
1313 | SET_R (this); |
1378 | dLocal (Display *, dpy); |
1314 | SET_LOCALE (locale); |
|
|
1315 | |
1379 | |
1316 | if (ev.xany.window == vt |
1380 | if (ev.xany.window == vt |
|
|
1381 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1317 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1382 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1318 | return; |
1383 | return; |
1319 | |
1384 | |
|
|
1385 | // for XQueryPointer |
1320 | Window unused_root, unused_child; |
1386 | Window unused_root, unused_child; |
1321 | int unused_root_x, unused_root_y; |
1387 | int unused_root_x, unused_root_y; |
1322 | unsigned int unused_mask; |
1388 | unsigned int unused_mask; |
1323 | |
1389 | |
1324 | switch (ev.type) |
1390 | switch (ev.type) |
1325 | { |
1391 | { |
1326 | case KeyPress: |
1392 | case KeyPress: |
1327 | #if ISO_14755 |
1393 | key_press (ev.xkey); |
1328 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1329 | #endif |
|
|
1330 | lookup_key (ev.xkey); |
|
|
1331 | |
|
|
1332 | break; |
1394 | break; |
1333 | |
1395 | |
1334 | case KeyRelease: |
1396 | case KeyRelease: |
1335 | { |
1397 | key_release (ev.xkey); |
1336 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
1337 | KeySym keysym; |
|
|
1338 | |
|
|
1339 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1340 | #endif |
|
|
1341 | |
|
|
1342 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1343 | // ISO 14755 support |
|
|
1344 | if (iso14755buf) |
|
|
1345 | if (iso14755buf & ISO_14755_52) |
|
|
1346 | { |
|
|
1347 | # if ENABLE_OVERLAY |
|
|
1348 | scr_overlay_off (); |
|
|
1349 | # endif |
|
|
1350 | # if ISO_14755 |
|
|
1351 | // iso14755 part 5.2 handling: release time |
|
|
1352 | // first: controls |
|
|
1353 | if ((ev.xkey.state & ControlMask) |
|
|
1354 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
1355 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
1356 | { |
|
|
1357 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
1358 | commit_iso14755 (); |
|
|
1359 | goto skip_switch; |
|
|
1360 | } |
|
|
1361 | |
|
|
1362 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1363 | if (i[0] == keysym) |
|
|
1364 | { |
|
|
1365 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1366 | commit_iso14755 (); |
|
|
1367 | goto skip_switch; |
|
|
1368 | } |
|
|
1369 | |
|
|
1370 | scr_bell (); |
|
|
1371 | # endif |
|
|
1372 | iso14755buf = 0; |
|
|
1373 | break; |
|
|
1374 | } |
|
|
1375 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1376 | { |
|
|
1377 | # if ENABLE_OVERLAY |
|
|
1378 | scr_overlay_off (); |
|
|
1379 | # endif |
|
|
1380 | if (iso14755buf & ISO_14755_51) |
|
|
1381 | commit_iso14755 (); |
|
|
1382 | #if ISO_14755 |
|
|
1383 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1384 | { |
|
|
1385 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1386 | |
|
|
1387 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1388 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1389 | } |
|
|
1390 | # endif |
|
|
1391 | else |
|
|
1392 | iso14755buf = 0; |
|
|
1393 | } |
|
|
1394 | #endif |
|
|
1395 | |
|
|
1396 | if (ev.xany.window == vt |
|
|
1397 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1398 | break; |
|
|
1399 | |
|
|
1400 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1401 | if (!(ev.xkey.state & ControlMask)) |
|
|
1402 | slip_wheel_ev.stop (); |
|
|
1403 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
1404 | mouse_slip_wheel_speed = 0; |
|
|
1405 | #endif |
|
|
1406 | break; |
1398 | break; |
1407 | } |
|
|
1408 | |
1399 | |
1409 | case ButtonPress: |
1400 | case ButtonPress: |
1410 | button_press (ev.xbutton); |
1401 | button_press (ev.xbutton); |
1411 | break; |
1402 | break; |
1412 | |
1403 | |
… | |
… | |
1414 | button_release (ev.xbutton); |
1405 | button_release (ev.xbutton); |
1415 | break; |
1406 | break; |
1416 | |
1407 | |
1417 | case ClientMessage: |
1408 | case ClientMessage: |
1418 | if (ev.xclient.format == 32 |
1409 | if (ev.xclient.format == 32 |
1419 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1410 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1420 | { |
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 | { |
1421 | 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))) |
1422 | destroy (); |
1419 | destroy (); |
|
|
1420 | } |
1423 | #if ENABLE_EWMH |
1421 | #if ENABLE_EWMH |
1424 | 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]) |
1425 | XSendEvent (disp, ev.xclient.window = display->root, |
1423 | XSendEvent (dpy, ev.xclient.window = display->root, |
1426 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1424 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1427 | &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 | } |
1428 | #endif |
1437 | #endif |
1429 | } |
1438 | } |
1430 | #if ENABLE_XEMBED |
|
|
1431 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1432 | { |
|
|
1433 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1434 | focus_in (); |
|
|
1435 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1436 | focus_out (); |
|
|
1437 | } |
|
|
1438 | #endif |
|
|
1439 | #ifdef OFFIX_DND |
|
|
1440 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1441 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1442 | && (ev.xclient.data.l[0] == DndFile |
|
|
1443 | || ev.xclient.data.l[0] == DndDir |
|
|
1444 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1445 | { |
|
|
1446 | /* Get Dnd data */ |
|
|
1447 | Atom ActualType; |
|
|
1448 | int ActualFormat; |
|
|
1449 | unsigned char *data; |
|
|
1450 | unsigned long Size, RemainingBytes; |
|
|
1451 | |
|
|
1452 | XGetWindowProperty (disp, display->root, |
|
|
1453 | xa[XA_DNDSELECTION], |
|
|
1454 | 0L, 1000000L, |
|
|
1455 | False, AnyPropertyType, |
|
|
1456 | &ActualType, &ActualFormat, |
|
|
1457 | &Size, &RemainingBytes, |
|
|
1458 | &data); |
|
|
1459 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1460 | XFree (data); |
|
|
1461 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1462 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1463 | } |
|
|
1464 | #endif /* OFFIX_DND */ |
|
|
1465 | break; |
1439 | break; |
1466 | |
1440 | |
1467 | case MappingNotify: |
1441 | case MappingNotify: |
1468 | XRefreshKeyboardMapping (&ev.xmapping); |
1442 | XRefreshKeyboardMapping (&ev.xmapping); |
1469 | break; |
1443 | break; |
… | |
… | |
1492 | break; |
1466 | break; |
1493 | } |
1467 | } |
1494 | break; |
1468 | break; |
1495 | |
1469 | |
1496 | case FocusIn: |
1470 | case FocusIn: |
|
|
1471 | if (ev.xfocus.detail != NotifyInferior |
|
|
1472 | && ev.xfocus.detail != NotifyPointer |
|
|
1473 | && ev.xfocus.mode != NotifyGrab) |
1497 | focus_in (); |
1474 | focus_in (); |
1498 | break; |
1475 | break; |
1499 | |
1476 | |
1500 | case FocusOut: |
1477 | case FocusOut: |
|
|
1478 | if (ev.xfocus.detail != NotifyInferior |
|
|
1479 | && ev.xfocus.detail != NotifyPointer |
|
|
1480 | && ev.xfocus.mode != NotifyGrab) |
1501 | focus_out (); |
1481 | focus_out (); |
1502 | break; |
1482 | break; |
1503 | |
1483 | |
1504 | case ConfigureNotify: |
1484 | case ConfigureNotify: |
1505 | if (ev.xconfigure.window == parent[0]) |
1485 | if (ev.xconfigure.window == parent[0]) |
1506 | { |
1486 | { |
1507 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1487 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1508 | ; |
1488 | ; |
1509 | |
1489 | |
1510 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1490 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1511 | { |
1491 | { |
1512 | seen_resize = 1; |
1492 | seen_resize = 1; |
1513 | 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 |
1514 | } |
1501 | } |
1515 | |
1502 | |
1516 | #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 |
1517 | if (OPTION (Opt_transparent)) |
1506 | if (option (Opt_transparent)) |
1518 | check_our_parents (); |
1507 | check_our_parents (); |
1519 | #endif |
1508 | #endif |
1520 | } |
1509 | } |
1521 | break; |
1510 | break; |
1522 | |
1511 | |
1523 | case PropertyNotify: |
1512 | case PropertyNotify: |
|
|
1513 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1524 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1514 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1525 | && ev.xproperty.state == PropertyNewValue) |
1515 | && ev.xproperty.state == PropertyNewValue) |
1526 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1516 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1527 | |
1517 | |
1528 | break; |
1518 | break; |
1529 | |
1519 | |
1530 | case SelectionClear: |
1520 | case SelectionClear: |
1531 | selection_clear (); |
1521 | selection_clear (); |
… | |
… | |
1567 | if (ev.xany.window == vt) |
1557 | if (ev.xany.window == vt) |
1568 | { |
1558 | { |
1569 | do |
1559 | do |
1570 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1560 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1571 | ev.xexpose.width, ev.xexpose.height, False); |
1561 | ev.xexpose.width, ev.xexpose.height, False); |
1572 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1562 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1573 | |
1563 | |
1574 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1564 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1575 | |
1565 | |
1576 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1566 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1577 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1567 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1578 | ev.xexpose.width, ev.xexpose.height, False); |
1568 | ev.xexpose.width, ev.xexpose.height, False); |
1579 | |
1569 | |
1580 | want_refresh = 1; |
1570 | want_refresh = 1; |
1581 | } |
1571 | } |
1582 | else |
1572 | else |
1583 | { |
1573 | { |
1584 | XEvent unused_event; |
1574 | XEvent unused_event; |
1585 | |
1575 | |
1586 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1576 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1587 | ; |
1577 | ; |
1588 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1578 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1589 | ; |
1579 | ; |
1590 | |
1580 | |
1591 | if (isScrollbarWindow (ev.xany.window)) |
1581 | if (isScrollbarWindow (ev.xany.window)) |
1592 | { |
1582 | { |
1593 | scrollBar.setIdle (); |
1583 | scrollBar.setIdle (); |
1594 | scrollbar_show (0); |
1584 | scrollbar_show (0); |
1595 | } |
1585 | } |
1596 | #ifdef MENUBAR |
|
|
1597 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1598 | menubar_expose (); |
|
|
1599 | #endif |
|
|
1600 | |
1586 | |
1601 | #ifdef TRANSPARENT |
1587 | #ifdef TRANSPARENT |
1602 | if (am_transparent && ev.xany.window == parent[0]) |
1588 | if (am_transparent && ev.xany.window == parent[0]) |
1603 | XClearWindow (disp, ev.xany.window); |
1589 | XClearWindow (dpy, ev.xany.window); |
1604 | #endif |
1590 | #endif |
1605 | } |
1591 | } |
1606 | break; |
1592 | break; |
1607 | |
1593 | |
1608 | case MotionNotify: |
1594 | case MotionNotify: |
1609 | printf ("motion notify\n");//D |
|
|
1610 | #ifdef POINTER_BLANK |
1595 | #ifdef POINTER_BLANK |
1611 | if (hidden_pointer) |
1596 | if (hidden_pointer) |
1612 | pointer_unblank (); |
1597 | pointer_unblank (); |
1613 | #endif |
1598 | #endif |
1614 | #if MENUBAR |
|
|
1615 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1616 | { |
|
|
1617 | menubar_control (ev.xbutton); |
|
|
1618 | break; |
|
|
1619 | } |
|
|
1620 | #endif |
|
|
1621 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1599 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1622 | break; |
1600 | break; |
1623 | |
1601 | |
1624 | if (ev.xany.window == vt) |
1602 | if (ev.xany.window == vt) |
1625 | { |
1603 | { |
|
|
1604 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1626 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1605 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1627 | ; // nop |
1606 | ; // nop |
1628 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1607 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1629 | { |
1608 | { |
1630 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1609 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1631 | ; |
1610 | ; |
1632 | |
1611 | |
1633 | XQueryPointer (disp, vt, |
1612 | XQueryPointer (dpy, vt, |
1634 | &unused_root, &unused_child, |
1613 | &unused_root, &unused_child, |
1635 | &unused_root_x, &unused_root_y, |
1614 | &unused_root_x, &unused_root_y, |
1636 | &ev.xbutton.x, &ev.xbutton.y, |
1615 | &ev.xbutton.x, &ev.xbutton.y, |
1637 | &ev.xbutton.state); |
1616 | &ev.xbutton.state); |
1638 | #ifdef MOUSE_THRESHOLD |
1617 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1702 | #endif |
1681 | #endif |
1703 | } |
1682 | } |
1704 | } |
1683 | } |
1705 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1684 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1706 | { |
1685 | { |
1707 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1686 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1708 | MotionNotify, &ev)) |
1687 | MotionNotify, &ev)) |
1709 | ; |
1688 | ; |
1710 | |
1689 | |
1711 | XQueryPointer (disp, scrollBar.win, |
1690 | XQueryPointer (dpy, scrollBar.win, |
1712 | &unused_root, &unused_child, |
1691 | &unused_root, &unused_child, |
1713 | &unused_root_x, &unused_root_y, |
1692 | &unused_root_x, &unused_root_y, |
1714 | &ev.xbutton.x, &ev.xbutton.y, |
1693 | &ev.xbutton.x, &ev.xbutton.y, |
1715 | &unused_mask); |
1694 | &unused_mask); |
1716 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1695 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
… | |
… | |
1720 | scrollbar_show (1); |
1699 | scrollbar_show (1); |
1721 | } |
1700 | } |
1722 | break; |
1701 | break; |
1723 | } |
1702 | } |
1724 | |
1703 | |
1725 | skip_switch: ; |
|
|
1726 | |
|
|
1727 | #if defined(CURSOR_BLINK) |
1704 | #if defined(CURSOR_BLINK) |
1728 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1705 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
1729 | { |
1706 | { |
1730 | if (hidden_cursor) |
1707 | if (hidden_cursor) |
1731 | { |
1708 | { |
1732 | hidden_cursor = 0; |
1709 | hidden_cursor = 0; |
1733 | want_refresh = 1; |
1710 | want_refresh = 1; |
1734 | } |
1711 | } |
1735 | |
1712 | |
1736 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1713 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1737 | } |
1714 | } |
1738 | #endif |
1715 | #endif |
1739 | |
1716 | |
1740 | #if defined(POINTER_BLANK) |
1717 | #if defined(POINTER_BLANK) |
1741 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1718 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
1742 | { |
1719 | { |
1743 | if (ev.type == MotionNotify |
1720 | if (ev.type == MotionNotify |
1744 | || ev.type == ButtonPress |
1721 | || ev.type == ButtonPress |
1745 | || ev.type == ButtonRelease) |
1722 | || ev.type == ButtonRelease) |
1746 | if (hidden_pointer) |
1723 | if (hidden_pointer) |
… | |
… | |
1758 | if (!focus) |
1735 | if (!focus) |
1759 | { |
1736 | { |
1760 | focus = 1; |
1737 | focus = 1; |
1761 | want_refresh = 1; |
1738 | want_refresh = 1; |
1762 | |
1739 | |
1763 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1740 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1764 | |
1741 | |
1765 | #if USE_XIM |
1742 | #if USE_XIM |
1766 | if (Input_Context != NULL) |
1743 | if (Input_Context != NULL) |
1767 | { |
1744 | { |
1768 | IMSetStatusPosition (); |
1745 | IMSetPosition (); |
1769 | XSetICFocus (Input_Context); |
1746 | XSetICFocus (Input_Context); |
1770 | } |
1747 | } |
1771 | #endif |
1748 | #endif |
1772 | #if CURSOR_BLINK |
1749 | #if CURSOR_BLINK |
1773 | if (OPTION (Opt_cursorBlink)) |
1750 | if (option (Opt_cursorBlink)) |
1774 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1751 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1775 | #endif |
1752 | #endif |
1776 | #if OFF_FOCUS_FADING |
1753 | #if OFF_FOCUS_FADING |
1777 | if (rs[Rs_fade]) |
1754 | if (rs[Rs_fade]) |
1778 | { |
1755 | { |
1779 | pix_colors = pix_colors_focused; |
1756 | pix_colors = pix_colors_focused; |
1780 | 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 | } |
1781 | } |
1771 | } |
1782 | #endif |
1772 | #endif |
1783 | } |
1773 | } |
1784 | } |
1774 | } |
1785 | |
1775 | |
… | |
… | |
1805 | #if USE_XIM |
1795 | #if USE_XIM |
1806 | if (Input_Context != NULL) |
1796 | if (Input_Context != NULL) |
1807 | XUnsetICFocus (Input_Context); |
1797 | XUnsetICFocus (Input_Context); |
1808 | #endif |
1798 | #endif |
1809 | #if CURSOR_BLINK |
1799 | #if CURSOR_BLINK |
1810 | if (OPTION (Opt_cursorBlink)) |
1800 | if (option (Opt_cursorBlink)) |
1811 | cursor_blink_ev.stop (); |
1801 | cursor_blink_ev.stop (); |
1812 | hidden_cursor = 0; |
1802 | hidden_cursor = 0; |
1813 | #endif |
1803 | #endif |
1814 | #if OFF_FOCUS_FADING |
1804 | #if OFF_FOCUS_FADING |
1815 | if (rs[Rs_fade]) |
1805 | if (rs[Rs_fade]) |
… | |
… | |
1819 | } |
1809 | } |
1820 | #endif |
1810 | #endif |
1821 | } |
1811 | } |
1822 | } |
1812 | } |
1823 | |
1813 | |
1824 | #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 |
1825 | void |
1828 | void |
1826 | rxvt_term::rootwin_cb (XEvent &ev) |
1829 | rxvt_term::rootwin_cb (XEvent &ev) |
1827 | { |
1830 | { |
1828 | SET_R (this); |
1831 | make_current (); |
1829 | SET_LOCALE (locale); |
|
|
1830 | |
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 |
1831 | switch (ev.type) |
1838 | switch (ev.type) |
1832 | { |
1839 | { |
1833 | case PropertyNotify: |
1840 | case PropertyNotify: |
1834 | /* |
1841 | /* |
1835 | * 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, |
… | |
… | |
1839 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1846 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1840 | return; |
1847 | return; |
1841 | |
1848 | |
1842 | /* FALLTHROUGH */ |
1849 | /* FALLTHROUGH */ |
1843 | case ReparentNotify: |
1850 | case ReparentNotify: |
1844 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1851 | if (option (Opt_transparent)) |
1845 | want_refresh = want_full_refresh = 1; |
1852 | check_our_parents (); |
1846 | break; |
1853 | break; |
1847 | } |
1854 | } |
|
|
1855 | # endif |
1848 | } |
1856 | } |
1849 | #endif |
1857 | #endif |
1850 | |
1858 | |
1851 | void |
1859 | void |
1852 | rxvt_term::button_press (XButtonEvent &ev) |
1860 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1861 | /* |
1869 | /* |
1862 | * VT window processing of button press |
1870 | * VT window processing of button press |
1863 | */ |
1871 | */ |
1864 | if (ev.window == vt) |
1872 | if (ev.window == vt) |
1865 | { |
1873 | { |
|
|
1874 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1875 | return; |
|
|
1876 | |
1866 | #if ISO_14755 |
1877 | #if ISO_14755 |
1867 | // 5.4 |
1878 | // 5.4 |
1868 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1879 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1869 | { |
1880 | { |
1870 | iso14755_54 (ev.x, ev.y); |
1881 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1912 | else |
1923 | else |
1913 | { |
1924 | { |
1914 | if (ev.button != MEvent.button) |
1925 | if (ev.button != MEvent.button) |
1915 | MEvent.clicks = 0; |
1926 | MEvent.clicks = 0; |
1916 | |
1927 | |
1917 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1918 | switch (ev.button) |
1928 | switch (ev.button) |
1919 | { |
1929 | { |
1920 | case Button1: |
1930 | case Button1: |
1921 | /* allow meta + click to select rectangular areas */ |
1931 | /* allow meta + click to select rectangular areas */ |
1922 | /* should be done in screen.C */ |
1932 | /* should be done in screen.C */ |
1923 | #if ENABLE_FRILLS |
1933 | #if ENABLE_FRILLS |
1924 | selection.rect = !!(ev.state & ModMetaMask); |
1934 | selection.rect = !!(ev.state & ModMetaMask); |
1925 | #else |
1935 | #else |
1926 | selection.rect = false; |
1936 | selection.rect = false; |
1927 | #endif |
1937 | #endif |
1928 | |
1938 | |
1929 | /* allow shift+left click to extend selection */ |
1939 | /* allow shift+left click to extend selection */ |
1930 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1940 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1931 | { |
1941 | { |
1932 | if (MEvent.button == Button1 && clickintime) |
1942 | if (MEvent.button == Button1 && clickintime) |
1933 | selection_rotate (ev.x, ev.y); |
1943 | selection_rotate (ev.x, ev.y); |
1934 | else |
1944 | else |
1935 | selection_extend (ev.x, ev.y, 1); |
1945 | selection_extend (ev.x, ev.y, 1); |
1936 | } |
1946 | } |
1937 | else |
1947 | else |
1938 | { |
1948 | { |
1939 | if (MEvent.button == Button1 && clickintime) |
1949 | if (MEvent.button == Button1 && clickintime) |
1940 | MEvent.clicks++; |
1950 | MEvent.clicks++; |
1941 | else |
1951 | else |
1942 | MEvent.clicks = 1; |
1952 | MEvent.clicks = 1; |
1943 | |
1953 | |
1944 | selection_click (MEvent.clicks, ev.x, ev.y); |
1954 | selection_click (MEvent.clicks, ev.x, ev.y); |
1945 | } |
1955 | } |
1946 | |
1956 | |
1947 | MEvent.button = Button1; |
1957 | MEvent.button = Button1; |
1948 | break; |
1958 | break; |
1949 | |
1959 | |
1950 | case Button3: |
1960 | case Button3: |
1951 | if (MEvent.button == Button3 && clickintime) |
1961 | if (MEvent.button == Button3 && clickintime) |
1952 | selection_rotate (ev.x, ev.y); |
1962 | selection_rotate (ev.x, ev.y); |
1953 | else |
1963 | else |
1954 | selection_extend (ev.x, ev.y, 1); |
1964 | selection_extend (ev.x, ev.y, 1); |
1955 | |
1965 | |
1956 | MEvent.button = Button3; |
1966 | MEvent.button = Button3; |
1957 | break; |
1967 | break; |
1958 | } |
1968 | } |
1959 | } |
1969 | } |
1960 | |
1970 | |
1961 | MEvent.time = ev.time; |
1971 | MEvent.time = ev.time; |
1962 | return; |
1972 | return; |
1963 | } |
1973 | } |
1964 | |
1974 | |
… | |
… | |
2103 | } |
2113 | } |
2104 | } |
2114 | } |
2105 | |
2115 | |
2106 | return; |
2116 | return; |
2107 | } |
2117 | } |
2108 | |
|
|
2109 | #if MENUBAR |
|
|
2110 | /* |
|
|
2111 | * Menubar window processing of button press |
|
|
2112 | */ |
|
|
2113 | if (isMenuBarWindow (ev.window)) |
|
|
2114 | menubar_control (ev); |
|
|
2115 | #endif |
|
|
2116 | } |
2118 | } |
2117 | |
2119 | |
2118 | void |
2120 | void |
2119 | rxvt_term::button_release (XButtonEvent &ev) |
2121 | rxvt_term::button_release (XButtonEvent &ev) |
2120 | { |
2122 | { |
… | |
… | |
2126 | |
2128 | |
2127 | if (scrollbar_isUpDn ()) |
2129 | if (scrollbar_isUpDn ()) |
2128 | { |
2130 | { |
2129 | scrollBar.setIdle (); |
2131 | scrollBar.setIdle (); |
2130 | scrollbar_show (0); |
2132 | scrollbar_show (0); |
2131 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2132 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2133 | #endif |
|
|
2134 | } |
2133 | } |
2135 | |
2134 | |
2136 | #ifdef SELECTION_SCROLLING |
2135 | #ifdef SELECTION_SCROLLING |
2137 | if (sel_scroll_ev.active) |
2136 | if (sel_scroll_ev.active) |
2138 | sel_scroll_ev.stop(); |
2137 | sel_scroll_ev.stop(); |
2139 | #endif |
2138 | #endif |
2140 | |
2139 | |
2141 | if (ev.window == vt) |
2140 | if (ev.window == vt) |
2142 | { |
2141 | { |
|
|
2142 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2143 | return; |
|
|
2144 | |
2143 | #if ISO_14755 |
2145 | #if ISO_14755 |
2144 | // 5.4 |
2146 | // 5.4 |
2145 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2147 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2146 | return; |
2148 | return; |
2147 | #endif |
2149 | #endif |
|
|
2150 | |
2148 | if (reportmode) |
2151 | if (reportmode) |
2149 | { |
2152 | { |
2150 | /* mouse report from vt window */ |
2153 | /* mouse report from vt window */ |
2151 | /* don't report release of wheel "buttons" */ |
2154 | /* don't report release of wheel "buttons" */ |
2152 | if (ev.button >= 4) |
2155 | if (ev.button >= 4) |
… | |
… | |
2176 | if (priv_modes & PrivMode_mouse_report |
2179 | if (priv_modes & PrivMode_mouse_report |
2177 | && bypass_keystate |
2180 | && bypass_keystate |
2178 | && ev.button == Button1 && MEvent.clicks <= 1) |
2181 | && ev.button == Button1 && MEvent.clicks <= 1) |
2179 | selection_extend (ev.x, ev.y, 0); |
2182 | selection_extend (ev.x, ev.y, 0); |
2180 | |
2183 | |
2181 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2182 | return; |
|
|
2183 | |
|
|
2184 | switch (ev.button) |
2184 | switch (ev.button) |
2185 | { |
2185 | { |
2186 | case Button1: |
2186 | case Button1: |
2187 | case Button3: |
2187 | case Button3: |
2188 | selection_make (ev.time); |
2188 | selection_make (ev.time); |
2189 | break; |
2189 | break; |
|
|
2190 | |
2190 | case Button2: |
2191 | case Button2: |
2191 | 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); |
2192 | break; |
2194 | break; |
|
|
2195 | |
2193 | #ifdef MOUSE_WHEEL |
2196 | #ifdef MOUSE_WHEEL |
2194 | case Button4: |
2197 | case Button4: |
2195 | case Button5: |
2198 | case Button5: |
2196 | { |
2199 | { |
2197 | int i; |
2200 | int i; |
… | |
… | |
2199 | |
2202 | |
2200 | v = ev.button == Button4 ? UP : DN; |
2203 | v = ev.button == Button4 ? UP : DN; |
2201 | |
2204 | |
2202 | if (ev.state & ShiftMask) |
2205 | if (ev.state & ShiftMask) |
2203 | i = 1; |
2206 | i = 1; |
2204 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2207 | else if (option (Opt_mouseWheelScrollPage)) |
2205 | i = nrow - 1; |
2208 | i = nrow - 1; |
2206 | else |
2209 | else |
2207 | i = 5; |
2210 | i = 5; |
2208 | |
2211 | |
2209 | # ifdef MOUSE_SLIP_WHEELING |
2212 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2229 | } |
2232 | } |
2230 | break; |
2233 | break; |
2231 | #endif |
2234 | #endif |
2232 | } |
2235 | } |
2233 | } |
2236 | } |
2234 | #ifdef MENUBAR |
|
|
2235 | else if (isMenuBarWindow (ev.window)) |
|
|
2236 | menubar_control (ev); |
|
|
2237 | #endif |
|
|
2238 | } |
2237 | } |
2239 | |
|
|
2240 | #ifdef TRANSPARENT |
|
|
2241 | #if TINTING |
|
|
2242 | /* taken from aterm-0.4.2 */ |
|
|
2243 | |
|
|
2244 | typedef uint32_t RUINT32T; |
|
|
2245 | |
|
|
2246 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2247 | { |
|
|
2248 | int sh_r, sh_g, sh_b; |
|
|
2249 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2250 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2251 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2252 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2253 | int i; |
|
|
2254 | |
|
|
2255 | Visual *visual = display->visual; |
|
|
2256 | |
|
|
2257 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2258 | |
|
|
2259 | /* for convenience */ |
|
|
2260 | mask_r = visual->red_mask; |
|
|
2261 | mask_g = visual->green_mask; |
|
|
2262 | mask_b = visual->blue_mask; |
|
|
2263 | |
|
|
2264 | /* boring lookup table pre-initialization */ |
|
|
2265 | switch (srcImage->bits_per_pixel) { |
|
|
2266 | case 15: |
|
|
2267 | if ((mask_r != 0x7c00) || |
|
|
2268 | (mask_g != 0x03e0) || |
|
|
2269 | (mask_b != 0x001f)) |
|
|
2270 | return; |
|
|
2271 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2272 | lookup_r = lookup; |
|
|
2273 | lookup_g = lookup+32; |
|
|
2274 | lookup_b = lookup+32+32; |
|
|
2275 | sh_r = 10; |
|
|
2276 | sh_g = 5; |
|
|
2277 | sh_b = 0; |
|
|
2278 | break; |
|
|
2279 | case 16: |
|
|
2280 | if ((mask_r != 0xf800) || |
|
|
2281 | (mask_g != 0x07e0) || |
|
|
2282 | (mask_b != 0x001f)) |
|
|
2283 | return; |
|
|
2284 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2285 | lookup_r = lookup; |
|
|
2286 | lookup_g = lookup+32; |
|
|
2287 | lookup_b = lookup+32+64; |
|
|
2288 | sh_r = 11; |
|
|
2289 | sh_g = 5; |
|
|
2290 | sh_b = 0; |
|
|
2291 | break; |
|
|
2292 | case 24: |
|
|
2293 | if ((mask_r != 0xff0000) || |
|
|
2294 | (mask_g != 0x00ff00) || |
|
|
2295 | (mask_b != 0x0000ff)) |
|
|
2296 | return; |
|
|
2297 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2298 | lookup_r = lookup; |
|
|
2299 | lookup_g = lookup+256; |
|
|
2300 | lookup_b = lookup+256+256; |
|
|
2301 | sh_r = 16; |
|
|
2302 | sh_g = 8; |
|
|
2303 | sh_b = 0; |
|
|
2304 | break; |
|
|
2305 | case 32: |
|
|
2306 | if ((mask_r != 0xff0000) || |
|
|
2307 | (mask_g != 0x00ff00) || |
|
|
2308 | (mask_b != 0x0000ff)) |
|
|
2309 | return; |
|
|
2310 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2311 | lookup_r = lookup; |
|
|
2312 | lookup_g = lookup+256; |
|
|
2313 | lookup_b = lookup+256+256; |
|
|
2314 | sh_r = 16; |
|
|
2315 | sh_g = 8; |
|
|
2316 | sh_b = 0; |
|
|
2317 | break; |
|
|
2318 | default: |
|
|
2319 | return; /* we do not support this color depth */ |
|
|
2320 | } |
|
|
2321 | |
|
|
2322 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2323 | if (shade < 0) { |
|
|
2324 | shade = -shade; |
|
|
2325 | if (shade < 0) shade = 0; |
|
|
2326 | if (shade > 100) shade = 100; |
|
|
2327 | |
|
|
2328 | lower_lim_r = 65535-rm; |
|
|
2329 | lower_lim_g = 65535-gm; |
|
|
2330 | lower_lim_b = 65535-bm; |
|
|
2331 | |
|
|
2332 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2333 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2334 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2335 | |
|
|
2336 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2337 | } else { |
|
|
2338 | if (shade < 0) shade = 0; |
|
|
2339 | if (shade > 100) shade = 100; |
|
|
2340 | |
|
|
2341 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2342 | |
|
|
2343 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2344 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2345 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2346 | } |
|
|
2347 | |
|
|
2348 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2349 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2350 | { |
|
|
2351 | unsigned int tmp; |
|
|
2352 | |
|
|
2353 | tmp = lower_lim_r; |
|
|
2354 | lower_lim_r = lower_lim_b; |
|
|
2355 | lower_lim_b = tmp; |
|
|
2356 | |
|
|
2357 | tmp = upper_lim_r; |
|
|
2358 | upper_lim_r = upper_lim_b; |
|
|
2359 | upper_lim_b = tmp; |
|
|
2360 | } |
|
|
2361 | |
|
|
2362 | /* fill our lookup tables */ |
|
|
2363 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2364 | { |
|
|
2365 | RUINT32T tmp; |
|
|
2366 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2367 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2368 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2369 | } |
|
|
2370 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2371 | { |
|
|
2372 | RUINT32T tmp; |
|
|
2373 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2374 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2375 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2376 | } |
|
|
2377 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2378 | { |
|
|
2379 | RUINT32T tmp; |
|
|
2380 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2381 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2382 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2383 | } |
|
|
2384 | |
|
|
2385 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2386 | switch (srcImage->bits_per_pixel) |
|
|
2387 | { |
|
|
2388 | case 15: |
|
|
2389 | { |
|
|
2390 | unsigned short *p1, *pf, *p, *pl; |
|
|
2391 | p1 = (unsigned short *) srcImage->data; |
|
|
2392 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2393 | while (p1 < pf) |
|
|
2394 | { |
|
|
2395 | p = p1; |
|
|
2396 | pl = p1 + srcImage->width; |
|
|
2397 | for (; p < pl; p++) |
|
|
2398 | { |
|
|
2399 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2400 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2401 | lookup_b[(*p & 0x001f)]; |
|
|
2402 | } |
|
|
2403 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2404 | } |
|
|
2405 | break; |
|
|
2406 | } |
|
|
2407 | case 16: |
|
|
2408 | { |
|
|
2409 | unsigned short *p1, *pf, *p, *pl; |
|
|
2410 | p1 = (unsigned short *) srcImage->data; |
|
|
2411 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2412 | while (p1 < pf) |
|
|
2413 | { |
|
|
2414 | p = p1; |
|
|
2415 | pl = p1 + srcImage->width; |
|
|
2416 | for (; p < pl; p++) |
|
|
2417 | { |
|
|
2418 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2419 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2420 | lookup_b[(*p & 0x001f)]; |
|
|
2421 | } |
|
|
2422 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2423 | } |
|
|
2424 | break; |
|
|
2425 | } |
|
|
2426 | case 24: |
|
|
2427 | { |
|
|
2428 | unsigned char *p1, *pf, *p, *pl; |
|
|
2429 | p1 = (unsigned char *) srcImage->data; |
|
|
2430 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2431 | while (p1 < pf) |
|
|
2432 | { |
|
|
2433 | p = p1; |
|
|
2434 | pl = p1 + srcImage->width * 3; |
|
|
2435 | for (; p < pl; p += 3) |
|
|
2436 | { |
|
|
2437 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2438 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2439 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2440 | } |
|
|
2441 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2442 | } |
|
|
2443 | break; |
|
|
2444 | } |
|
|
2445 | case 32: |
|
|
2446 | { |
|
|
2447 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2448 | p1 = (RUINT32T *) srcImage->data; |
|
|
2449 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2450 | |
|
|
2451 | while (p1 < pf) |
|
|
2452 | { |
|
|
2453 | p = p1; |
|
|
2454 | pl = p1 + srcImage->width; |
|
|
2455 | for (; p < pl; p++) |
|
|
2456 | { |
|
|
2457 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2458 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2459 | lookup_b[(*p & 0x0000ff)] | |
|
|
2460 | (*p & ~0xffffff); |
|
|
2461 | } |
|
|
2462 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2463 | } |
|
|
2464 | break; |
|
|
2465 | } |
|
|
2466 | } |
|
|
2467 | |
|
|
2468 | free (lookup); |
|
|
2469 | } |
|
|
2470 | #endif |
|
|
2471 | |
|
|
2472 | /* |
|
|
2473 | * Check our parents are still who we think they are. |
|
|
2474 | * Do transparency updates if required |
|
|
2475 | */ |
|
|
2476 | int |
|
|
2477 | rxvt_term::check_our_parents () |
|
|
2478 | { |
|
|
2479 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2480 | unsigned long nitems, bytes_after; |
|
|
2481 | Atom atype; |
|
|
2482 | unsigned char *prop = NULL; |
|
|
2483 | Window root, oldp, *list; |
|
|
2484 | Pixmap rootpixmap = None; |
|
|
2485 | XWindowAttributes wattr, wrootattr; |
|
|
2486 | dDisp; |
|
|
2487 | |
|
|
2488 | pchanged = 0; |
|
|
2489 | |
|
|
2490 | if (!OPTION (Opt_transparent)) |
|
|
2491 | return pchanged; /* Don't try any more */ |
|
|
2492 | |
|
|
2493 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2494 | rootdepth = wrootattr.depth; |
|
|
2495 | |
|
|
2496 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2497 | |
|
|
2498 | if (rootdepth != wattr.depth) |
|
|
2499 | { |
|
|
2500 | if (am_transparent) |
|
|
2501 | { |
|
|
2502 | pchanged = 1; |
|
|
2503 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2504 | am_transparent = am_pixmap_trans = 0; |
|
|
2505 | } |
|
|
2506 | |
|
|
2507 | return pchanged; /* Don't try any more */ |
|
|
2508 | } |
|
|
2509 | |
|
|
2510 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2511 | XSync (disp, False); |
|
|
2512 | |
|
|
2513 | /* |
|
|
2514 | * Make the frame window set by the window manager have |
|
|
2515 | * the root background. Some window managers put multiple nested frame |
|
|
2516 | * windows for each client, so we have to take care about that. |
|
|
2517 | */ |
|
|
2518 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2519 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2520 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2521 | &nitems, &bytes_after, &prop) == Success); |
|
|
2522 | |
|
|
2523 | if (!i || prop == NULL) |
|
|
2524 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2525 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2526 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2527 | &nitems, &bytes_after, &prop) == Success); |
|
|
2528 | |
|
|
2529 | if (!i || prop == NULL |
|
|
2530 | #if TINTING |
|
|
2531 | || !rs[Rs_color + Color_tint] |
|
|
2532 | #endif |
|
|
2533 | ) |
|
|
2534 | have_pixmap = 0; |
|
|
2535 | else |
|
|
2536 | { |
|
|
2537 | have_pixmap = 1; |
|
|
2538 | rootpixmap = *(Pixmap *)prop; |
|
|
2539 | XFree (prop); |
|
|
2540 | } |
|
|
2541 | |
|
|
2542 | if (have_pixmap) |
|
|
2543 | { |
|
|
2544 | /* |
|
|
2545 | * Copy display->root pixmap transparency |
|
|
2546 | */ |
|
|
2547 | int sx, sy, nx, ny; |
|
|
2548 | unsigned int nw, nh; |
|
|
2549 | Window cr; |
|
|
2550 | XImage *image; |
|
|
2551 | GC gc; |
|
|
2552 | XGCValues gcvalue; |
|
|
2553 | |
|
|
2554 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2555 | 0, 0, &sx, &sy, &cr); |
|
|
2556 | nw = (unsigned int)szHint.width; |
|
|
2557 | nh = (unsigned int)szHint.height; |
|
|
2558 | nx = ny = 0; |
|
|
2559 | |
|
|
2560 | if (sx < 0) |
|
|
2561 | { |
|
|
2562 | nw += sx; |
|
|
2563 | nx = -sx; |
|
|
2564 | sx = 0; |
|
|
2565 | } |
|
|
2566 | |
|
|
2567 | if (sy < 0) |
|
|
2568 | { |
|
|
2569 | nh += sy; |
|
|
2570 | ny = -sy; |
|
|
2571 | sy = 0; |
|
|
2572 | } |
|
|
2573 | |
|
|
2574 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2575 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2576 | |
|
|
2577 | XSync (disp, False); |
|
|
2578 | allowedxerror = -1; |
|
|
2579 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2580 | |
|
|
2581 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2582 | /* XXX: may need a delay here? */ |
|
|
2583 | allowedxerror = 0; |
|
|
2584 | |
|
|
2585 | if (image == NULL) |
|
|
2586 | { |
|
|
2587 | if (am_transparent && am_pixmap_trans) |
|
|
2588 | { |
|
|
2589 | pchanged = 1; |
|
|
2590 | if (pixmap != None) |
|
|
2591 | { |
|
|
2592 | XFreePixmap (disp, pixmap); |
|
|
2593 | pixmap = None; |
|
|
2594 | } |
|
|
2595 | } |
|
|
2596 | |
|
|
2597 | am_pixmap_trans = 0; |
|
|
2598 | } |
|
|
2599 | else |
|
|
2600 | { |
|
|
2601 | if (pixmap != None) |
|
|
2602 | XFreePixmap (disp, pixmap); |
|
|
2603 | |
|
|
2604 | #if TINTING |
|
|
2605 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2606 | { |
|
|
2607 | unsigned short rm, gm, bm; |
|
|
2608 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2609 | |
|
|
2610 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2611 | |
|
|
2612 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2613 | } |
|
|
2614 | #endif |
|
|
2615 | |
|
|
2616 | pixmap = XCreatePixmap (disp, vt, |
|
|
2617 | szHint.width, szHint.height, image->depth); |
|
|
2618 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2619 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2620 | nx, ny, image->width, image->height); |
|
|
2621 | XFreeGC (disp, gc); |
|
|
2622 | XDestroyImage (image); |
|
|
2623 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2624 | XClearWindow (disp, parent[0]); |
|
|
2625 | |
|
|
2626 | if (!am_transparent || !am_pixmap_trans) |
|
|
2627 | pchanged = 1; |
|
|
2628 | |
|
|
2629 | am_transparent = am_pixmap_trans = 1; |
|
|
2630 | } |
|
|
2631 | } |
|
|
2632 | |
|
|
2633 | if (am_pixmap_trans) |
|
|
2634 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2635 | else |
|
|
2636 | { |
|
|
2637 | unsigned int n; |
|
|
2638 | /* |
|
|
2639 | * InheritPixmap transparency |
|
|
2640 | */ |
|
|
2641 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2642 | { |
|
|
2643 | oldp = parent[i]; |
|
|
2644 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2645 | &parent[i], &list, &n); |
|
|
2646 | XFree (list); |
|
|
2647 | |
|
|
2648 | if (parent[i] == display->root) |
|
|
2649 | { |
|
|
2650 | if (oldp != None) |
|
|
2651 | pchanged = 1; |
|
|
2652 | |
|
|
2653 | break; |
|
|
2654 | } |
|
|
2655 | |
|
|
2656 | if (oldp != parent[i]) |
|
|
2657 | pchanged = 1; |
|
|
2658 | } |
|
|
2659 | |
|
|
2660 | n = 0; |
|
|
2661 | |
|
|
2662 | if (pchanged) |
|
|
2663 | { |
|
|
2664 | for (; n < (unsigned int)i; n++) |
|
|
2665 | { |
|
|
2666 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2667 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2668 | { |
|
|
2669 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2670 | break; |
|
|
2671 | } |
|
|
2672 | } |
|
|
2673 | } |
|
|
2674 | |
|
|
2675 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2676 | { |
|
|
2677 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2678 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2679 | am_transparent = 0; |
|
|
2680 | /* XXX: also turn off Opt_transparent? */ |
|
|
2681 | } |
|
|
2682 | else |
|
|
2683 | { |
|
|
2684 | #if WAIT_FOR_WM |
|
|
2685 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2686 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2687 | sleep (1); |
|
|
2688 | #endif |
|
|
2689 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2690 | { |
|
|
2691 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2692 | XClearWindow (disp, parent[n]); |
|
|
2693 | } |
|
|
2694 | |
|
|
2695 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2696 | am_transparent = 1; |
|
|
2697 | } |
|
|
2698 | |
|
|
2699 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2700 | parent[i] = None; |
|
|
2701 | } |
|
|
2702 | |
|
|
2703 | if (scrollBar.win) |
|
|
2704 | { |
|
|
2705 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2706 | scrollBar.setIdle (); |
|
|
2707 | scrollbar_show (0); |
|
|
2708 | } |
|
|
2709 | |
|
|
2710 | if (am_transparent) |
|
|
2711 | { |
|
|
2712 | want_refresh = want_full_refresh = 1; |
|
|
2713 | if (am_pixmap_trans) |
|
|
2714 | flush (); |
|
|
2715 | } |
|
|
2716 | |
|
|
2717 | return pchanged; |
|
|
2718 | } |
|
|
2719 | #endif |
|
|
2720 | |
2238 | |
2721 | /*}}} */ |
2239 | /*}}} */ |
2722 | |
2240 | |
2723 | bool |
2241 | bool |
2724 | rxvt_term::cmd_parse () |
2242 | rxvt_term::cmd_parse () |
… | |
… | |
2773 | if (ch == C0_LF) |
2291 | if (ch == C0_LF) |
2774 | nlines++; |
2292 | nlines++; |
2775 | |
2293 | |
2776 | refresh_count++; |
2294 | refresh_count++; |
2777 | |
2295 | |
2778 | if (!OPTION (Opt_jumpScroll) |
2296 | if (!option (Opt_jumpScroll) |
2779 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2297 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2780 | { |
2298 | { |
2781 | refreshnow = true; |
2299 | refreshnow = true; |
2782 | refresh_count = 0; |
2300 | refresh_count = 0; |
2783 | ch = NOCHAR; |
2301 | ch = NOCHAR; |
… | |
… | |
2785 | } |
2303 | } |
2786 | |
2304 | |
2787 | // scr_add_lines only works for nlines <= nrow - 1. |
2305 | // scr_add_lines only works for nlines <= nrow - 1. |
2788 | if (nlines >= nrow - 1) |
2306 | if (nlines >= nrow - 1) |
2789 | { |
2307 | { |
|
|
2308 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2790 | 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)))) |
2791 | scr_add_lines (buf, str - buf, nlines); |
2310 | scr_add_lines (buf, str - buf, nlines); |
2792 | |
2311 | |
2793 | nlines = 0; |
2312 | nlines = 0; |
2794 | str = buf; |
2313 | str = buf; |
2795 | eol = str + min (ncol, UBUFSIZ); |
2314 | eol = str + min (ncol, UBUFSIZ); |
… | |
… | |
2810 | |
2329 | |
2811 | seq_begin = cmdbuf_ptr; |
2330 | seq_begin = cmdbuf_ptr; |
2812 | ch = next_char (); |
2331 | ch = next_char (); |
2813 | } |
2332 | } |
2814 | |
2333 | |
|
|
2334 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2815 | 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)))) |
2816 | scr_add_lines (buf, str - buf, nlines); |
2336 | scr_add_lines (buf, str - buf, nlines); |
2817 | |
2337 | |
2818 | /* |
2338 | /* |
2819 | * 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 |
2820 | * 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. |
2821 | * the number of pages between refreshes is refresh_limit, which |
2341 | * the number of pages between refreshes is refresh_limit, which |
2822 | * is incremented here because we must be doing flat-out scrolling. |
2342 | * is incremented here because we must be doing flat-out scrolling. |
2823 | */ |
2343 | */ |
2824 | if (refreshnow) |
2344 | if (refreshnow) |
2825 | { |
2345 | { |
2826 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2346 | if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2827 | refresh_limit++; |
2347 | refresh_limit++; |
2828 | else |
2348 | else |
2829 | { |
2349 | { |
2830 | flag = true; |
2350 | flag = true; |
|
|
2351 | //TODO: due to popular request, implement "skipscroll" option here |
2831 | scr_refresh (refresh_type); |
2352 | scr_refresh (); |
2832 | want_refresh = 1; |
2353 | want_refresh = 1; |
2833 | } |
2354 | } |
2834 | } |
2355 | } |
2835 | |
2356 | |
2836 | } |
2357 | } |
… | |
… | |
2854 | return flag; |
2375 | return flag; |
2855 | } |
2376 | } |
2856 | |
2377 | |
2857 | // read the next character |
2378 | // read the next character |
2858 | wchar_t |
2379 | wchar_t |
2859 | rxvt_term::next_char () |
2380 | rxvt_term::next_char () NOTHROW |
2860 | { |
2381 | { |
2861 | while (cmdbuf_ptr < cmdbuf_endp) |
2382 | while (cmdbuf_ptr < cmdbuf_endp) |
2862 | { |
2383 | { |
2863 | // assume 7-bit to be ascii ALWAYS |
2384 | // assume 7-bit to be ascii ALWAYS |
2864 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2385 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2885 | return NOCHAR; |
2406 | return NOCHAR; |
2886 | } |
2407 | } |
2887 | |
2408 | |
2888 | // read the next octet |
2409 | // read the next octet |
2889 | uint32_t |
2410 | uint32_t |
2890 | rxvt_term::next_octet () |
2411 | rxvt_term::next_octet () NOTHROW |
2891 | { |
2412 | { |
2892 | return cmdbuf_ptr < cmdbuf_endp |
2413 | return cmdbuf_ptr < cmdbuf_endp |
2893 | ? (unsigned char)*cmdbuf_ptr++ |
2414 | ? (unsigned char)*cmdbuf_ptr++ |
2894 | : NOCHAR; |
2415 | : NOCHAR; |
2895 | } |
2416 | } |
|
|
2417 | |
|
|
2418 | static class out_of_input out_of_input; |
2896 | |
2419 | |
2897 | /* rxvt_cmd_getc () - Return next input character */ |
2420 | /* rxvt_cmd_getc () - Return next input character */ |
2898 | /* |
2421 | /* |
2899 | * Return the next input character after first passing any keyboard input |
2422 | * Return the next input character after first passing any keyboard input |
2900 | * to the command. |
2423 | * to the command. |
2901 | */ |
2424 | */ |
2902 | wchar_t |
2425 | wchar_t |
2903 | rxvt_term::cmd_getc () |
2426 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2904 | { |
2427 | { |
2905 | wchar_t c = next_char (); |
2428 | wchar_t c = next_char (); |
2906 | |
2429 | |
2907 | if (c == NOCHAR) |
2430 | if (c == NOCHAR) |
2908 | throw out_of_input; |
2431 | throw out_of_input; |
2909 | |
2432 | |
2910 | return c; |
2433 | return c; |
2911 | } |
2434 | } |
2912 | |
2435 | |
2913 | uint32_t |
2436 | uint32_t |
2914 | rxvt_term::cmd_get8 () |
2437 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2915 | { |
2438 | { |
2916 | uint32_t c = next_octet (); |
2439 | uint32_t c = next_octet (); |
2917 | |
2440 | |
2918 | if (c == NOCHAR) |
2441 | if (c == NOCHAR) |
2919 | throw out_of_input; |
2442 | throw out_of_input; |
… | |
… | |
2985 | { |
2508 | { |
2986 | if ((buf[len++] = cmd_getc ()) == 'i') |
2509 | if ((buf[len++] = cmd_getc ()) == 'i') |
2987 | break; /* done = 1 */ |
2510 | break; /* done = 1 */ |
2988 | } |
2511 | } |
2989 | } |
2512 | } |
2990 | |
2513 | |
2991 | for (i = 0; i < len; i++) |
2514 | for (i = 0; i < len; i++) |
2992 | if (putc (buf[i], fd) == EOF) |
2515 | if (putc (buf[i], fd) == EOF) |
2993 | { |
2516 | { |
2994 | done = 1; |
2517 | done = 1; |
2995 | break; |
2518 | break; |
… | |
… | |
3157 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2680 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3158 | break; |
2681 | break; |
3159 | case '+': |
2682 | case '+': |
3160 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2683 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3161 | break; |
2684 | break; |
3162 | #if ENABLE_FRILLS |
2685 | #if !ENABLE_MINIMAL |
3163 | case '6': |
2686 | case '6': |
3164 | scr_backindex (); |
2687 | scr_backindex (); |
3165 | break; |
2688 | break; |
3166 | #endif |
2689 | #endif |
3167 | case '7': |
2690 | case '7': |
3168 | scr_cursor (SAVE); |
2691 | scr_cursor (SAVE); |
3169 | break; |
2692 | break; |
3170 | case '8': |
2693 | case '8': |
3171 | scr_cursor (RESTORE); |
2694 | scr_cursor (RESTORE); |
3172 | break; |
2695 | break; |
3173 | #if ENABLE_FRILLS |
2696 | #if !ENABLE_MINIMAL |
3174 | case '9': |
2697 | case '9': |
3175 | scr_forwardindex (); |
2698 | scr_forwardindex (); |
3176 | break; |
2699 | break; |
3177 | #endif |
2700 | #endif |
3178 | case '=': |
2701 | case '=': |
… | |
… | |
3340 | ndef = get_byte_array_bit (csi_defaults, i); |
2863 | ndef = get_byte_array_bit (csi_defaults, i); |
3341 | for (p = 0; p < nargs; p++) |
2864 | for (p = 0; p < nargs; p++) |
3342 | if (arg[p] == -1) |
2865 | if (arg[p] == -1) |
3343 | arg[p] = ndef; |
2866 | arg[p] = ndef; |
3344 | |
2867 | |
3345 | #ifdef DEBUG_CMD |
|
|
3346 | fprintf (stderr, "CSI "); |
|
|
3347 | for (p = 0; p < nargs; p++) |
|
|
3348 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3349 | fprintf (stderr, "%c\n", ch); |
|
|
3350 | #endif |
|
|
3351 | |
|
|
3352 | /* |
2868 | /* |
3353 | * private mode handling |
2869 | * private mode handling |
3354 | */ |
2870 | */ |
3355 | if (priv) |
2871 | if (priv) |
3356 | { |
2872 | { |
3357 | switch (priv) |
2873 | switch (priv) |
3358 | { |
2874 | { |
3359 | case '>': |
2875 | case '>': |
3360 | if (ch == CSI_DA) /* secondary device attributes */ |
2876 | if (ch == CSI_DA) /* secondary device attributes */ |
3361 | 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 | } |
3362 | break; |
2887 | break; |
3363 | case '?': |
2888 | case '?': |
3364 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2889 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3365 | process_terminal_mode (ch, priv, nargs, arg); |
2890 | process_terminal_mode (ch, priv, nargs, arg); |
3366 | break; |
2891 | break; |
… | |
… | |
3492 | break; |
3017 | break; |
3493 | case 6: /* CPR requested */ |
3018 | case 6: /* CPR requested */ |
3494 | scr_report_position (); |
3019 | scr_report_position (); |
3495 | break; |
3020 | break; |
3496 | case 7: /* unofficial extension */ |
3021 | case 7: /* unofficial extension */ |
3497 | if (OPTION (Opt_insecure)) |
3022 | if (option (Opt_insecure)) |
3498 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3023 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3499 | break; |
3024 | break; |
3500 | case 8: /* unofficial extension */ |
3025 | case 8: /* unofficial extension */ |
3501 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3026 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3502 | break; |
3027 | break; |
… | |
… | |
3569 | break; |
3094 | break; |
3570 | case CSI_75: |
3095 | case CSI_75: |
3571 | scr_cursor (RESTORE); |
3096 | scr_cursor (RESTORE); |
3572 | break; |
3097 | break; |
3573 | |
3098 | |
3574 | #if ENABLE_FRILLS |
3099 | #if !ENABLE_MINIMAL |
3575 | case CSI_74: |
3100 | case CSI_74: |
3576 | process_window_ops (arg, nargs); |
3101 | process_window_ops (arg, nargs); |
3577 | break; |
3102 | break; |
3578 | #endif |
3103 | #endif |
3579 | |
3104 | |
… | |
… | |
3586 | break; |
3111 | break; |
3587 | } |
3112 | } |
3588 | } |
3113 | } |
3589 | /*}}} */ |
3114 | /*}}} */ |
3590 | |
3115 | |
3591 | #if ENABLE_FRILLS |
3116 | #if !ENABLE_MINIMAL |
3592 | /* ARGSUSED */ |
3117 | /* ARGSUSED */ |
3593 | void |
3118 | void |
3594 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3119 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3595 | { |
3120 | { |
3596 | int x, y; |
3121 | int x, y; |
3597 | XWindowAttributes wattr; |
3122 | XWindowAttributes wattr; |
3598 | Window wdummy; |
3123 | Window wdummy; |
3599 | dDisp; |
3124 | |
|
|
3125 | dLocal (Display *, dpy); |
3600 | |
3126 | |
3601 | if (nargs == 0) |
3127 | if (nargs == 0) |
3602 | return; |
3128 | return; |
3603 | |
3129 | |
3604 | switch (args[0]) |
3130 | switch (args[0]) |
3605 | { |
3131 | { |
3606 | /* |
3132 | /* |
3607 | * commands |
3133 | * commands |
3608 | */ |
3134 | */ |
3609 | case 1: /* deiconify window */ |
3135 | case 1: /* deiconify window */ |
3610 | XMapWindow (disp, parent[0]); |
3136 | XMapWindow (dpy, parent[0]); |
3611 | break; |
3137 | break; |
3612 | case 2: /* iconify window */ |
3138 | case 2: /* iconify window */ |
3613 | XIconifyWindow (disp, parent[0], display->screen); |
3139 | XIconifyWindow (dpy, parent[0], display->screen); |
3614 | break; |
3140 | break; |
3615 | case 3: /* set position (pixels) */ |
3141 | case 3: /* set position (pixels) */ |
3616 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3142 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3617 | break; |
3143 | break; |
3618 | case 4: /* set size (pixels) */ |
3144 | case 4: /* set size (pixels) */ |
3619 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3145 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3620 | break; |
3146 | break; |
3621 | case 5: /* raise window */ |
3147 | case 5: /* raise window */ |
3622 | XRaiseWindow (disp, parent[0]); |
3148 | XRaiseWindow (dpy, parent[0]); |
3623 | break; |
3149 | break; |
3624 | case 6: /* lower window */ |
3150 | case 6: /* lower window */ |
3625 | XLowerWindow (disp, parent[0]); |
3151 | XLowerWindow (dpy, parent[0]); |
3626 | break; |
3152 | break; |
3627 | case 7: /* refresh window */ |
3153 | case 7: /* refresh window */ |
3628 | scr_touch (true); |
3154 | scr_touch (true); |
3629 | break; |
3155 | break; |
3630 | case 8: /* set size (chars) */ |
3156 | case 8: /* set size (chars) */ |
… | |
… | |
3637 | if (args[0] >= 24) /* set height (chars) */ |
3163 | if (args[0] >= 24) /* set height (chars) */ |
3638 | set_widthheight ((unsigned int)width, |
3164 | set_widthheight ((unsigned int)width, |
3639 | (unsigned int) (args[1] * fheight)); |
3165 | (unsigned int) (args[1] * fheight)); |
3640 | break; |
3166 | break; |
3641 | |
3167 | |
3642 | |
|
|
3643 | /* |
3168 | /* |
3644 | * reports - some output format copied from XTerm |
3169 | * reports - some output format copied from XTerm |
3645 | */ |
3170 | */ |
3646 | case 11: /* report window state */ |
3171 | case 11: /* report window state */ |
3647 | XGetWindowAttributes (disp, parent[0], &wattr); |
3172 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3648 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3173 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3649 | break; |
3174 | break; |
3650 | case 13: /* report window position */ |
3175 | case 13: /* report window position */ |
3651 | XGetWindowAttributes (disp, parent[0], &wattr); |
3176 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3652 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3177 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3653 | -wattr.border_width, -wattr.border_width, |
3178 | -wattr.border_width, -wattr.border_width, |
3654 | &x, &y, &wdummy); |
3179 | &x, &y, &wdummy); |
3655 | tt_printf ("\033[3;%d;%dt", x, y); |
3180 | tt_printf ("\033[3;%d;%dt", x, y); |
3656 | break; |
3181 | break; |
3657 | case 14: /* report window size (pixels) */ |
3182 | case 14: /* report window size (pixels) */ |
3658 | XGetWindowAttributes (disp, parent[0], &wattr); |
3183 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3659 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3184 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3660 | break; |
3185 | break; |
3661 | case 18: /* report text area size (chars) */ |
3186 | case 18: /* report text area size (chars) */ |
3662 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3187 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3663 | break; |
3188 | break; |
… | |
… | |
3665 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3190 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3666 | break; |
3191 | break; |
3667 | case 20: /* report icon label */ |
3192 | case 20: /* report icon label */ |
3668 | { |
3193 | { |
3669 | char *s; |
3194 | char *s; |
3670 | XGetIconName (disp, parent[0], &s); |
3195 | XGetIconName (dpy, parent[0], &s); |
3671 | 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 */ |
3672 | XFree (s); |
3197 | XFree (s); |
3673 | } |
3198 | } |
3674 | break; |
3199 | break; |
3675 | case 21: /* report window title */ |
3200 | case 21: /* report window title */ |
3676 | { |
3201 | { |
3677 | char *s; |
3202 | char *s; |
3678 | XFetchName (disp, parent[0], &s); |
3203 | XFetchName (dpy, parent[0], &s); |
3679 | 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 */ |
3680 | XFree (s); |
3205 | XFree (s); |
3681 | } |
3206 | } |
3682 | break; |
3207 | break; |
3683 | } |
3208 | } |
3684 | } |
3209 | } |
… | |
… | |
3711 | seen_esc = true; |
3236 | seen_esc = true; |
3712 | continue; |
3237 | continue; |
3713 | } |
3238 | } |
3714 | else if (ch == C0_BEL || ch == CHAR_ST) |
3239 | else if (ch == C0_BEL || ch == CHAR_ST) |
3715 | break; |
3240 | break; |
|
|
3241 | else if (ch == C0_SYN) |
|
|
3242 | ch = cmd_get8 (); |
3716 | else if (ch < 0x20) |
3243 | else if (ch < 0x20) |
3717 | return NULL; /* other control character - exit */ |
3244 | return NULL; /* other control character - exit */ |
3718 | |
3245 | |
3719 | seen_esc = false; |
3246 | seen_esc = false; |
3720 | |
3247 | |
3721 | if (n >= STRING_MAX - 1) |
3248 | if (n >= STRING_MAX - 1) |
3722 | // stop at some sane length |
3249 | // stop at some sane length |
3723 | return NULL; |
3250 | return NULL; |
3724 | |
3251 | |
3725 | if (ch == C0_SYN) |
|
|
3726 | string[n++] = cmd_get8 (); |
|
|
3727 | else |
|
|
3728 | string[n++] = ch; |
3252 | string[n++] = ch; |
3729 | } |
3253 | } |
3730 | |
3254 | |
3731 | string[n++] = '\0'; |
3255 | string[n++] = '\0'; |
3732 | |
3256 | |
3733 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3257 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
… | |
… | |
3784 | void |
3308 | void |
3785 | 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) |
3786 | { |
3310 | { |
3787 | if (str[0] == '?' && !str[1]) |
3311 | if (str[0] == '?' && !str[1]) |
3788 | { |
3312 | { |
3789 | unsigned short r, g, b; |
3313 | rgba c; |
3790 | 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 |
3791 | 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); |
3792 | } |
3322 | } |
3793 | else |
3323 | else |
3794 | set_window_color (color, str); |
3324 | set_window_color (color, str); |
3795 | } |
3325 | } |
3796 | |
3326 | |
… | |
… | |
3798 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3328 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3799 | */ |
3329 | */ |
3800 | void |
3330 | void |
3801 | 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) |
3802 | { |
3332 | { |
3803 | int changed = 0; |
|
|
3804 | int color; |
3333 | int color; |
3805 | char *buf, *name; |
3334 | char *buf, *name; |
3806 | bool query = str[0] == '?' && !str[1]; |
3335 | bool query = str[0] == '?' && !str[1]; |
3807 | int saveop = op; |
3336 | int saveop = op; |
3808 | dDisp; |
3337 | |
|
|
3338 | dLocal (Display *, dpy); |
3809 | |
3339 | |
3810 | 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 | |
3811 | switch (op) |
3345 | switch (op) |
3812 | { |
3346 | { |
3813 | case XTerm_name: |
3347 | case XTerm_name: |
3814 | set_title (str); |
3348 | set_title (str); |
3815 | /* FALLTHROUGH */ |
3349 | /* FALLTHROUGH */ |
… | |
… | |
3829 | unsigned long bytes_after; |
3363 | unsigned long bytes_after; |
3830 | unsigned char *value = 0; |
3364 | unsigned char *value = 0; |
3831 | const char *str = ""; |
3365 | const char *str = ""; |
3832 | |
3366 | |
3833 | if (prop |
3367 | if (prop |
3834 | && XGetWindowProperty (disp, parent[0], |
3368 | && XGetWindowProperty (dpy, parent[0], |
3835 | prop, 0, 1<<16, 0, AnyPropertyType, |
3369 | prop, 0, 1<<16, 0, AnyPropertyType, |
3836 | &actual_type, &actual_format, |
3370 | &actual_type, &actual_format, |
3837 | &nitems, &bytes_after, &value) == Success |
3371 | &nitems, &bytes_after, &value) == Success |
3838 | && actual_type != None |
3372 | && actual_type != None |
3839 | && actual_format == 8) |
3373 | && actual_format == 8) |
3840 | str = (const char *)(value); |
3374 | str = (const char *)(value); |
3841 | |
3375 | |
3842 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3376 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3843 | |
3377 | |
3844 | XFree (value); |
3378 | XFree (value); |
3845 | } |
3379 | } |
3846 | else |
3380 | else |
3847 | { |
3381 | { |
… | |
… | |
3851 | { |
3385 | { |
3852 | *eq = 0; |
3386 | *eq = 0; |
3853 | set_utf8_property (display->atom (str), eq + 1); |
3387 | set_utf8_property (display->atom (str), eq + 1); |
3854 | } |
3388 | } |
3855 | else |
3389 | else |
3856 | XDeleteProperty (disp, parent[0], |
3390 | XDeleteProperty (dpy, parent[0], |
3857 | display->atom (str)); |
3391 | display->atom (str)); |
3858 | } |
3392 | } |
3859 | break; |
3393 | break; |
3860 | |
3394 | |
3861 | case XTerm_Color: |
3395 | case XTerm_Color: |
… | |
… | |
3871 | break; |
3405 | break; |
3872 | |
3406 | |
3873 | if ((buf = strchr (name, ';')) != NULL) |
3407 | if ((buf = strchr (name, ';')) != NULL) |
3874 | *buf++ = '\0'; |
3408 | *buf++ = '\0'; |
3875 | |
3409 | |
3876 | if (name[0] == '?' && !name[1]) |
3410 | process_color_seq (op, color, name, resp); |
3877 | { |
|
|
3878 | unsigned short r, g, b; |
|
|
3879 | pix_colors_focused[color].get (display, r, g, b); |
|
|
3880 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3881 | } |
|
|
3882 | else |
|
|
3883 | set_window_color (color, name); |
|
|
3884 | } |
3411 | } |
3885 | break; |
3412 | break; |
3886 | case XTerm_Color00: |
3413 | case XTerm_Color00: |
3887 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3414 | process_color_seq (op, Color_fg, str, resp); |
3888 | break; |
3415 | break; |
3889 | case XTerm_Color01: |
3416 | case XTerm_Color01: |
3890 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3417 | process_color_seq (op, Color_bg, str, resp); |
3891 | break; |
3418 | break; |
3892 | #ifndef NO_CURSORCOLOR |
3419 | #ifndef NO_CURSORCOLOR |
3893 | case XTerm_Color_cursor: |
3420 | case XTerm_Color_cursor: |
3894 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3421 | process_color_seq (op, Color_cursor, str, resp); |
3895 | break; |
3422 | break; |
3896 | #endif |
3423 | #endif |
3897 | case XTerm_Color_pointer_fg: |
3424 | case XTerm_Color_pointer_fg: |
3898 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3425 | process_color_seq (op, Color_pointer_fg, str, resp); |
3899 | break; |
3426 | break; |
3900 | case XTerm_Color_pointer_bg: |
3427 | case XTerm_Color_pointer_bg: |
3901 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3428 | process_color_seq (op, Color_pointer_bg, str, resp); |
3902 | break; |
3429 | break; |
3903 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3430 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3904 | case XTerm_Color_RV: |
3431 | case XTerm_Color_RV: |
3905 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3432 | process_color_seq (op, Color_RV, str, resp); |
3906 | break; |
3433 | break; |
3907 | case Rxvt_Color_BD: |
3434 | case Rxvt_Color_BD: |
3908 | case URxvt_Color_BD: |
3435 | case URxvt_Color_BD: |
3909 | process_color_seq (op, Color_BD, str, resp); |
3436 | process_color_seq (op, Color_BD, str, resp); |
3910 | break; |
3437 | break; |
3911 | case Rxvt_Color_UL: |
3438 | case Rxvt_Color_UL: |
3912 | case URxvt_Color_UL: |
3439 | case URxvt_Color_UL: |
3913 | process_color_seq (op, Color_UL, str, resp); |
3440 | process_color_seq (op, Color_UL, str, resp); |
3914 | break; |
3441 | break; |
3915 | case URxvt_Color_IT: |
3442 | case URxvt_Color_IT: |
3916 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3443 | process_color_seq (op, Color_IT, str, resp); |
3917 | break; |
3444 | break; |
3918 | #endif |
3445 | #endif |
3919 | #if TRANSPARENT && TINTING |
3446 | #if TRANSPARENT && TINTING |
3920 | case URxvt_Color_tint: |
3447 | case URxvt_Color_tint: |
3921 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3448 | process_color_seq (op, Color_tint, str, resp); |
|
|
3449 | |
3922 | check_our_parents (); |
3450 | check_our_parents (); |
|
|
3451 | |
3923 | if (am_transparent) |
3452 | if (am_transparent) |
3924 | want_full_refresh = want_refresh = 1; |
3453 | want_full_refresh = want_refresh = 1; |
|
|
3454 | |
3925 | break; |
3455 | break; |
3926 | #endif |
3456 | #endif |
3927 | |
3457 | |
3928 | case Rxvt_Pixmap: |
3458 | case Rxvt_Pixmap: |
|
|
3459 | { |
3929 | if (*str != ';') |
3460 | if (*str != ';') |
3930 | { |
3461 | { |
3931 | #if XPM_BACKGROUND |
3462 | #if XPM_BACKGROUND |
3932 | scale_pixmap (""); /* reset to default scaling */ |
3463 | scale_pixmap (""); /* reset to default scaling */ |
3933 | set_bgPixmap (str); /* change pixmap */ |
3464 | set_bgPixmap (str); /* change pixmap */ |
3934 | scr_touch (true); |
3465 | scr_touch (true); |
3935 | #endif |
3466 | #endif |
3936 | } |
3467 | } |
3937 | |
3468 | |
|
|
3469 | int changed = 0; |
|
|
3470 | |
3938 | while ((str = strchr (str, ';')) != NULL) |
3471 | while ((str = strchr (str, ';')) != NULL) |
3939 | { |
3472 | { |
3940 | str++; |
3473 | str++; |
3941 | #if XPM_BACKGROUND |
3474 | #if XPM_BACKGROUND |
3942 | changed += scale_pixmap (str); |
3475 | changed += scale_pixmap (str); |
3943 | #endif |
3476 | #endif |
3944 | } |
3477 | } |
3945 | |
3478 | |
3946 | if (changed) |
3479 | if (changed) |
3947 | { |
3480 | { |
3948 | #ifdef XPM_BACKGROUND |
3481 | #ifdef XPM_BACKGROUND |
3949 | resize_pixmap (); |
3482 | resize_pixmap (); |
3950 | scr_touch (true); |
3483 | scr_touch (true); |
3951 | #endif |
3484 | #endif |
3952 | } |
3485 | } |
|
|
3486 | #if TRANSPARENT && defined(HAVE_AFTERIMAGE) |
|
|
3487 | if (option (Opt_transparent)) |
|
|
3488 | check_our_parents (); |
|
|
3489 | #endif |
|
|
3490 | } |
3953 | break; |
3491 | break; |
3954 | |
3492 | |
3955 | case Rxvt_restoreFG: |
3493 | case Rxvt_restoreFG: |
3956 | set_window_color (Color_fg, str); |
3494 | set_window_color (Color_fg, str); |
3957 | break; |
3495 | break; |
… | |
… | |
3961 | |
3499 | |
3962 | case XTerm_logfile: |
3500 | case XTerm_logfile: |
3963 | // TODO, when secure mode? |
3501 | // TODO, when secure mode? |
3964 | break; |
3502 | break; |
3965 | |
3503 | |
3966 | #ifdef MENUBAR |
|
|
3967 | case URxvt_Menu: |
|
|
3968 | if (OPTION (Opt_insecure)) |
|
|
3969 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3970 | break; |
|
|
3971 | #endif |
|
|
3972 | #if 0 |
3504 | #if 0 |
3973 | case Rxvt_dumpscreen: /* no error notices */ |
3505 | case Rxvt_dumpscreen: /* no error notices */ |
3974 | { |
3506 | { |
3975 | int fd; |
3507 | int fd; |
3976 | 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) |
… | |
… | |
3989 | case URxvt_italicFont: |
3521 | case URxvt_italicFont: |
3990 | case URxvt_boldItalicFont: |
3522 | case URxvt_boldItalicFont: |
3991 | #endif |
3523 | #endif |
3992 | if (query) |
3524 | if (query) |
3993 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3525 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3994 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3526 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3995 | ? fontset[op - URxvt_font]->fontdesc : "", |
3527 | ? fontset[op - URxvt_font]->fontdesc : "", |
3996 | resp); |
3528 | resp); |
3997 | else |
3529 | else |
3998 | { |
3530 | { |
3999 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3531 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
4002 | allocated.push_back ((void *)res); |
3534 | allocated.push_back ((void *)res); |
4003 | set_fonts (); |
3535 | set_fonts (); |
4004 | } |
3536 | } |
4005 | break; |
3537 | break; |
4006 | |
3538 | |
4007 | #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 |
4008 | case URxvt_locale: |
3548 | case URxvt_locale: |
4009 | if (query) |
3549 | if (query) |
4010 | 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); |
4011 | else |
3551 | else |
4012 | { |
3552 | { |
4013 | set_locale (str); |
3553 | set_locale (str); |
4014 | pty.set_utf8_mode (enc_utf8); |
3554 | pty->set_utf8_mode (enc_utf8); |
4015 | init_xlocale (); |
3555 | init_xlocale (); |
4016 | } |
3556 | } |
4017 | break; |
3557 | break; |
4018 | |
3558 | |
4019 | case URxvt_view_up: |
3559 | case URxvt_view_up: |
… | |
… | |
4030 | break; |
3570 | break; |
4031 | #endif |
3571 | #endif |
4032 | |
3572 | |
4033 | #if ENABLE_PERL |
3573 | #if ENABLE_PERL |
4034 | case URxvt_perl: |
3574 | case URxvt_perl: |
4035 | 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))) |
4036 | ; // no responses yet |
3576 | ; // no responses yet |
4037 | break; |
3577 | break; |
4038 | #endif |
3578 | #endif |
4039 | } |
3579 | } |
4040 | } |
3580 | } |
… | |
… | |
4072 | return state; |
3612 | return state; |
4073 | } |
3613 | } |
4074 | |
3614 | |
4075 | /* we're not using priv _yet_ */ |
3615 | /* we're not using priv _yet_ */ |
4076 | void |
3616 | void |
4077 | 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) |
4078 | { |
3618 | { |
4079 | unsigned int i, j; |
3619 | unsigned int i, j; |
4080 | int state; |
3620 | int state; |
4081 | |
3621 | |
4082 | static const struct |
3622 | static const struct |
… | |
… | |
4093 | { 5, PrivMode_rVideo }, |
3633 | { 5, PrivMode_rVideo }, |
4094 | { 6, PrivMode_relOrigin }, |
3634 | { 6, PrivMode_relOrigin }, |
4095 | { 7, PrivMode_Autowrap }, |
3635 | { 7, PrivMode_Autowrap }, |
4096 | // 8, bi-directional support mode |
3636 | // 8, bi-directional support mode |
4097 | { 9, PrivMode_MouseX10 }, |
3637 | { 9, PrivMode_MouseX10 }, |
4098 | #ifdef menuBar_esc |
|
|
4099 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4100 | #endif |
|
|
4101 | // 18, 19 printing-related |
3638 | // 18, 19 printing-related |
4102 | { 25, PrivMode_VisibleCursor }, |
3639 | { 25, PrivMode_VisibleCursor }, |
4103 | #ifdef scrollBar_esc |
3640 | #ifdef scrollBar_esc |
4104 | { scrollBar_esc, PrivMode_scrollBar }, |
3641 | { scrollBar_esc, PrivMode_scrollBar }, |
4105 | #endif |
3642 | #endif |
… | |
… | |
4159 | scr_touch (true); |
3696 | scr_touch (true); |
4160 | break; |
3697 | break; |
4161 | #endif |
3698 | #endif |
4162 | case 1048: /* alternative cursor save */ |
3699 | case 1048: /* alternative cursor save */ |
4163 | case 1049: |
3700 | case 1049: |
4164 | if (OPTION (Opt_secondaryScreen)) |
3701 | if (option (Opt_secondaryScreen)) |
4165 | if (mode == 0) |
3702 | if (mode == 0) |
4166 | scr_cursor (RESTORE); |
3703 | scr_cursor (RESTORE); |
4167 | else if (mode == 1) |
3704 | else if (mode == 1) |
4168 | scr_cursor (SAVE); |
3705 | scr_cursor (SAVE); |
4169 | break; |
3706 | break; |
… | |
… | |
4200 | /* 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 */ |
4201 | case 9: /* X10 mouse reporting */ |
3738 | case 9: /* X10 mouse reporting */ |
4202 | if (state) /* orthogonal */ |
3739 | if (state) /* orthogonal */ |
4203 | priv_modes &= ~PrivMode_MouseX11; |
3740 | priv_modes &= ~PrivMode_MouseX11; |
4204 | break; |
3741 | break; |
4205 | #ifdef menuBar_esc |
|
|
4206 | case menuBar_esc: |
|
|
4207 | #ifdef MENUBAR |
|
|
4208 | map_menuBar (state); |
|
|
4209 | #endif |
|
|
4210 | break; |
|
|
4211 | #endif |
|
|
4212 | #ifdef scrollBar_esc |
3742 | #ifdef scrollBar_esc |
4213 | case scrollBar_esc: |
3743 | case scrollBar_esc: |
4214 | if (scrollbar_mapping (state)) |
3744 | if (scrollbar_mapping (state)) |
4215 | { |
3745 | { |
4216 | resize_all_windows (0, 0, 0); |
3746 | resize_all_windows (0, 0, 0); |
… | |
… | |
4241 | break; |
3771 | break; |
4242 | case 1011: /* scroll to bottom on key press */ |
3772 | case 1011: /* scroll to bottom on key press */ |
4243 | set_option (Opt_scrollTtyKeypress, state); |
3773 | set_option (Opt_scrollTtyKeypress, state); |
4244 | break; |
3774 | break; |
4245 | case 1047: /* secondary screen w/ clearing last */ |
3775 | case 1047: /* secondary screen w/ clearing last */ |
4246 | if (OPTION (Opt_secondaryScreen)) |
3776 | if (option (Opt_secondaryScreen)) |
4247 | if (current_screen != PRIMARY) |
3777 | if (current_screen != PRIMARY) |
4248 | scr_erase_screen (2); |
3778 | scr_erase_screen (2); |
4249 | scr_change_screen (state); |
3779 | scr_change_screen (state); |
4250 | break; |
3780 | break; |
4251 | case 1049: /* secondary screen w/ clearing first */ |
3781 | case 1049: /* secondary screen w/ clearing first */ |
4252 | scr_change_screen (state); |
3782 | scr_change_screen (state); |
4253 | if (OPTION (Opt_secondaryScreen)) |
3783 | if (option (Opt_secondaryScreen)) |
4254 | if (current_screen != PRIMARY) |
3784 | if (current_screen != PRIMARY) |
4255 | scr_erase_screen (2); |
3785 | scr_erase_screen (2); |
4256 | break; |
3786 | break; |
4257 | default: |
3787 | default: |
4258 | break; |
3788 | break; |
… | |
… | |
4386 | scr_color (Color_bg, Color_bg); |
3916 | scr_color (Color_bg, Color_bg); |
4387 | break; |
3917 | break; |
4388 | |
3918 | |
4389 | //case 50: // not variable spacing |
3919 | //case 50: // not variable spacing |
4390 | |
3920 | |
4391 | #if ENABLE_FRILLS |
3921 | #if !ENABLE_MINIMAL |
4392 | case 90: |
3922 | case 90: |
4393 | case 91: /* set bright fg color */ |
3923 | case 91: /* set bright fg color */ |
4394 | case 92: |
3924 | case 92: |
4395 | case 93: |
3925 | case 93: |
4396 | case 94: |
3926 | case 94: |
… | |
… | |
4461 | rxvt_term::tt_write (const char *data, unsigned int len) |
3991 | rxvt_term::tt_write (const char *data, unsigned int len) |
4462 | { |
3992 | { |
4463 | 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))) |
4464 | return; |
3994 | return; |
4465 | |
3995 | |
4466 | if (pty.pty < 0) |
3996 | if (pty->pty < 0) |
4467 | return; |
3997 | return; |
4468 | |
3998 | |
4469 | if (v_buflen == 0) |
3999 | if (v_buflen == 0) |
4470 | { |
4000 | { |
4471 | 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)); |
4472 | |
4002 | |
4473 | if ((unsigned int)written == len) |
4003 | if ((unsigned int)written == len) |
4474 | return; |
4004 | return; |
4475 | |
4005 | |
4476 | data += written; |
4006 | data += written; |
… | |
… | |
4485 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4015 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4486 | } |
4016 | } |
4487 | |
4017 | |
4488 | void rxvt_term::pty_write () |
4018 | void rxvt_term::pty_write () |
4489 | { |
4019 | { |
4490 | 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)); |
4491 | |
4021 | |
4492 | if (written > 0) |
4022 | if (written > 0) |
4493 | { |
4023 | { |
4494 | v_buflen -= written; |
4024 | v_buflen -= written; |
4495 | |
4025 | |