… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
31 | * |
31 | * |
32 | * This program is free software; you can redistribute it and/or modify |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
33 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
35 | * (at your option) any later version. |
… | |
… | |
64 | |
64 | |
65 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
66 | |
66 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
68 | |
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
|
|
72 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
70 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
76 | #define ISO_14755_52 0x20000000UL // keycap (section 5.2) |
73 | #define ISO_14755_52 0x20000000UL // keycap (section 5.2) |
… | |
… | |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
144 | || !IN_RANGE_EXC (y, 0, nrow)) |
148 | return; |
145 | return; |
149 | |
146 | |
150 | for (;;) |
147 | for (;;) |
151 | { |
148 | { |
152 | const line_t &l = ROW(y - view_start); |
149 | const line_t &l = ROW(y + view_start); |
153 | |
150 | |
154 | text_t t = l.t[x]; |
151 | text_t t = l.t[x]; |
155 | |
152 | |
156 | if (t != NOCHAR || !x) |
153 | if (t != NOCHAR || !x) |
157 | { |
154 | { |
… | |
… | |
302 | rxvt_term::lookup_key (XKeyEvent &ev) |
299 | rxvt_term::lookup_key (XKeyEvent &ev) |
303 | { |
300 | { |
304 | int ctrl, meta, shft, len; |
301 | int ctrl, meta, shft, len; |
305 | unsigned int newlen; |
302 | unsigned int newlen; |
306 | KeySym keysym; |
303 | KeySym keysym; |
307 | #ifdef DEBUG_CMD |
|
|
308 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
309 | #endif |
|
|
310 | int valid_keysym; |
304 | int valid_keysym; |
311 | char kbuf[KBUFSZ]; |
305 | char kbuf[KBUFSZ]; |
312 | |
306 | |
313 | /* |
307 | /* |
314 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
308 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
… | |
… | |
443 | scr_move_to (0, 1); |
437 | scr_move_to (0, 1); |
444 | return; |
438 | return; |
445 | } |
439 | } |
446 | else if (keysym == XK_End) |
440 | else if (keysym == XK_End) |
447 | { |
441 | { |
448 | scr_move_to (1, 0); |
442 | scr_move_to (1, 1); |
449 | return; |
443 | return; |
450 | } |
444 | } |
451 | } |
445 | } |
452 | #endif |
446 | #endif |
453 | } |
447 | } |
… | |
… | |
464 | { |
458 | { |
465 | switch (keysym) |
459 | switch (keysym) |
466 | { |
460 | { |
467 | /* normal XTerm key bindings */ |
461 | /* normal XTerm key bindings */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
462 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
469 | selection_request (ev.time, 0, 0); |
463 | selection_request (ev.time); |
470 | return; |
464 | return; |
471 | #if TODO |
465 | #if TODO |
472 | /* rxvt extras */ |
466 | /* rxvt extras */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
467 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
474 | change_font (FONT_UP); |
468 | change_font (FONT_UP); |
… | |
… | |
867 | #endif |
861 | #endif |
868 | /* nil */ ; |
862 | /* nil */ ; |
869 | } |
863 | } |
870 | } |
864 | } |
871 | |
865 | |
|
|
866 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
867 | return; |
|
|
868 | |
872 | if (len <= 0) |
869 | if (len <= 0) |
873 | return; /* not mapped */ |
870 | return; /* not mapped */ |
874 | |
871 | |
875 | if (OPTION (Opt_scrollTtyKeypress)) |
872 | if (OPTION (Opt_scrollTtyKeypress)) |
876 | if (view_start) |
873 | if (view_start) |
… | |
… | |
902 | { |
899 | { |
903 | const char ch = C0_ESC; |
900 | const char ch = C0_ESC; |
904 | tt_write (&ch, 1); |
901 | tt_write (&ch, 1); |
905 | } |
902 | } |
906 | |
903 | |
907 | #if defined(DEBUG_CMD) |
|
|
908 | /* Display keyboard buffer contents */ |
|
|
909 | unsigned char *p; |
|
|
910 | int i; |
|
|
911 | |
|
|
912 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
913 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
914 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
915 | fprintf (stderr, "'\n"); |
|
|
916 | #endif /* DEBUG_CMD */ |
|
|
917 | tt_write (kbuf, (unsigned int)len); |
904 | tt_write (kbuf, (unsigned int)len); |
918 | } |
905 | } |
919 | /*}}} */ |
906 | /*}}} */ |
920 | |
907 | |
921 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
908 | #if defined (KEYSYM_RESOURCE) |
922 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
923 | /* attempt to `write' count to the input buffer */ |
|
|
924 | unsigned int |
909 | unsigned int |
925 | rxvt_term::cmd_write (const char *str, unsigned int count) |
910 | rxvt_term::cmd_write (const char *str, unsigned int count) |
926 | { |
911 | { |
927 | unsigned int n, s; |
912 | unsigned int n, s; |
928 | |
913 | |
… | |
… | |
967 | } |
952 | } |
968 | #endif |
953 | #endif |
969 | |
954 | |
970 | if (want_refresh) |
955 | if (want_refresh) |
971 | { |
956 | { |
|
|
957 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
958 | { |
|
|
959 | int row = view_start; |
|
|
960 | int end_row = row + nrow; |
|
|
961 | |
|
|
962 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
963 | --row; |
|
|
964 | |
|
|
965 | do |
|
|
966 | { |
|
|
967 | int start_row = row; |
|
|
968 | line_t *l; |
|
|
969 | |
|
|
970 | do |
|
|
971 | { |
|
|
972 | l = &ROW (row++); |
|
|
973 | |
|
|
974 | if (!(l->f & LINE_FILTERED)) |
|
|
975 | { |
|
|
976 | // line not filtered, mark it as filtered |
|
|
977 | l->f |= LINE_FILTERED; |
|
|
978 | while (l->is_longer ()) |
|
|
979 | { |
|
|
980 | l = &ROW (row++); |
|
|
981 | l->f |= LINE_FILTERED; |
|
|
982 | } |
|
|
983 | |
|
|
984 | // and filter it |
|
|
985 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
986 | |
|
|
987 | break; |
|
|
988 | } |
|
|
989 | } |
|
|
990 | while (l->is_longer () && row < end_row); |
|
|
991 | } |
|
|
992 | while (row < end_row); |
|
|
993 | } |
|
|
994 | |
972 | scr_refresh (refresh_type); |
995 | scr_refresh (); |
973 | scrollbar_show (1); |
996 | scrollbar_show (1); |
974 | #ifdef USE_XIM |
997 | #ifdef USE_XIM |
975 | IMSendSpot (); |
998 | IMSendSpot (); |
976 | #endif |
999 | #endif |
977 | } |
1000 | } |
… | |
… | |
980 | } |
1003 | } |
981 | |
1004 | |
982 | void |
1005 | void |
983 | rxvt_term::check_cb (check_watcher &w) |
1006 | rxvt_term::check_cb (check_watcher &w) |
984 | { |
1007 | { |
985 | SET_R (this); |
1008 | make_current (); |
986 | SET_LOCALE (locale); |
|
|
987 | |
1009 | |
988 | display->flush (); |
1010 | display->flush (); |
989 | |
1011 | |
990 | if (want_refresh && !flush_ev.active) |
1012 | if (want_refresh && !flush_ev.active) |
991 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1013 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
992 | } |
1014 | } |
993 | |
1015 | |
994 | void |
1016 | void |
995 | rxvt_term::flush_cb (time_watcher &w) |
1017 | rxvt_term::flush_cb (time_watcher &w) |
996 | { |
1018 | { |
997 | SET_R (this); |
1019 | make_current (); |
998 | SET_LOCALE (locale); |
|
|
999 | |
1020 | |
1000 | refresh_limit = 1; |
1021 | refresh_limit = 1; |
1001 | refresh_count = 0; |
1022 | refresh_count = 0; |
1002 | flush (); |
1023 | flush (); |
1003 | } |
1024 | } |
… | |
… | |
1007 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1028 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1008 | { |
1029 | { |
1009 | hidden_cursor = !hidden_cursor; |
1030 | hidden_cursor = !hidden_cursor; |
1010 | want_refresh = 1; |
1031 | want_refresh = 1; |
1011 | |
1032 | |
1012 | w.start (w.at + BLINK_INTERVAL); |
1033 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1013 | } |
1034 | } |
1014 | #endif |
1035 | #endif |
1015 | |
1036 | |
1016 | #ifdef TEXT_BLINK |
1037 | #ifdef TEXT_BLINK |
1017 | void |
1038 | void |
… | |
… | |
1031 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1052 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1032 | { |
1053 | { |
1033 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1054 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1034 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1055 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1035 | { |
1056 | { |
1036 | refresh_type |= SMOOTH_REFRESH; |
|
|
1037 | want_refresh = 1; |
1057 | want_refresh = 1; |
1038 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1058 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1039 | } |
1059 | } |
1040 | } |
1060 | } |
1041 | #endif |
1061 | #endif |
… | |
… | |
1045 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1065 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1046 | { |
1066 | { |
1047 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1067 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1048 | { |
1068 | { |
1049 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1069 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1050 | refresh_type |= SMOOTH_REFRESH; |
|
|
1051 | want_refresh = 1; |
1070 | want_refresh = 1; |
1052 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1053 | } |
1072 | } |
1054 | } |
1073 | } |
1055 | #endif |
1074 | #endif |
… | |
… | |
1060 | { |
1079 | { |
1061 | if (mouse_slip_wheel_speed == 0 |
1080 | if (mouse_slip_wheel_speed == 0 |
1062 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1081 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1063 | : scr_page (UP, mouse_slip_wheel_speed)) |
1082 | : scr_page (UP, mouse_slip_wheel_speed)) |
1064 | { |
1083 | { |
1065 | if (view_start == nsaved || |
1084 | if (view_start == top_row || view_start == 0) |
1066 | view_start == 0) |
|
|
1067 | mouse_slip_wheel_speed = 0; |
1085 | mouse_slip_wheel_speed = 0; |
1068 | |
1086 | |
1069 | refresh_type |= SMOOTH_REFRESH; |
|
|
1070 | want_refresh = 1; |
1087 | want_refresh = 1; |
1071 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1088 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1072 | } |
1089 | } |
1073 | } |
1090 | } |
1074 | #endif |
1091 | #endif |
… | |
… | |
1104 | |
1121 | |
1105 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1122 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1106 | cmdbuf_ptr = cmdbuf_base; |
1123 | cmdbuf_ptr = cmdbuf_base; |
1107 | cmdbuf_endp = cmdbuf_ptr + n; |
1124 | cmdbuf_endp = cmdbuf_ptr + n; |
1108 | |
1125 | |
1109 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1126 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1110 | |
1127 | |
1111 | if (r > 0) |
1128 | if (r > 0) |
1112 | { |
1129 | { |
1113 | cmdbuf_endp += r; |
1130 | cmdbuf_endp += r; |
1114 | return true; |
1131 | return true; |
… | |
… | |
1132 | } |
1149 | } |
1133 | |
1150 | |
1134 | void |
1151 | void |
1135 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1152 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1136 | { |
1153 | { |
1137 | SET_R (this); |
1154 | make_current (); |
1138 | SET_LOCALE (locale); |
|
|
1139 | |
1155 | |
1140 | if (revents & EVENT_READ) |
1156 | if (revents & EVENT_READ) |
1141 | // loop, but don't allow a single term to monopolize us |
1157 | // loop, but don't allow a single term to monopolize us |
1142 | while (pty_fill ()) |
1158 | while (pty_fill ()) |
1143 | if (cmd_parse ()) |
1159 | if (cmd_parse ()) |
… | |
… | |
1163 | |
1179 | |
1164 | #ifdef POINTER_BLANK |
1180 | #ifdef POINTER_BLANK |
1165 | void |
1181 | void |
1166 | rxvt_term::pointer_blank () |
1182 | rxvt_term::pointer_blank () |
1167 | { |
1183 | { |
1168 | if (! OPTION (Opt_pointerBlank)) |
1184 | if (!OPTION (Opt_pointerBlank)) |
1169 | return; |
1185 | return; |
1170 | |
1186 | |
1171 | XDefineCursor (display->display, vt, display->blank_cursor); |
1187 | XDefineCursor (display->display, vt, display->blank_cursor); |
1172 | XFlush (display->display); |
1188 | XFlush (display->display); |
1173 | |
1189 | |
… | |
… | |
1175 | } |
1191 | } |
1176 | |
1192 | |
1177 | void |
1193 | void |
1178 | rxvt_term::pointer_cb (time_watcher &w) |
1194 | rxvt_term::pointer_cb (time_watcher &w) |
1179 | { |
1195 | { |
1180 | SET_R (this); |
1196 | make_current (); |
1181 | SET_LOCALE (locale); |
|
|
1182 | |
1197 | |
1183 | pointer_blank (); |
1198 | pointer_blank (); |
1184 | } |
1199 | } |
1185 | #endif |
1200 | #endif |
1186 | |
1201 | |
… | |
… | |
1251 | (32 + button_number + key_state), |
1266 | (32 + button_number + key_state), |
1252 | (32 + x + 1), |
1267 | (32 + x + 1), |
1253 | (32 + y + 1)); |
1268 | (32 + y + 1)); |
1254 | } |
1269 | } |
1255 | |
1270 | |
1256 | #ifdef USING_W11LIB |
|
|
1257 | void |
|
|
1258 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1259 | { |
|
|
1260 | rxvt_t *r = rxvt_get_r (); |
|
|
1261 | |
|
|
1262 | x_cb (*ev); |
|
|
1263 | } |
|
|
1264 | #endif |
|
|
1265 | |
|
|
1266 | /*{{{ process an X event */ |
1271 | /*{{{ process an X event */ |
1267 | void |
1272 | void |
1268 | rxvt_term::x_cb (XEvent &ev) |
1273 | rxvt_term::x_cb (XEvent &ev) |
1269 | { |
1274 | { |
1270 | dDisp; |
1275 | make_current (); |
1271 | |
1276 | |
1272 | SET_R (this); |
1277 | dLocal (Display *, xdisp); |
1273 | SET_LOCALE (locale); |
|
|
1274 | |
1278 | |
1275 | #if defined(CURSOR_BLINK) |
1279 | if (ev.xany.window == vt |
1276 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1280 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1277 | { |
1281 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1278 | if (hidden_cursor) |
1282 | return; |
1279 | { |
|
|
1280 | hidden_cursor = 0; |
|
|
1281 | want_refresh = 1; |
|
|
1282 | } |
|
|
1283 | |
1283 | |
1284 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1284 | // for XQueryPointer |
1285 | } |
|
|
1286 | #endif |
|
|
1287 | |
|
|
1288 | #if defined(POINTER_BLANK) |
|
|
1289 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1290 | { |
|
|
1291 | if (ev.type == MotionNotify |
|
|
1292 | || ev.type == ButtonPress |
|
|
1293 | || ev.type == ButtonRelease) |
|
|
1294 | if (hidden_pointer) |
|
|
1295 | pointer_unblank (); |
|
|
1296 | |
|
|
1297 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1298 | pointer_blank (); |
|
|
1299 | } |
|
|
1300 | #endif |
|
|
1301 | |
|
|
1302 | Window unused_root, unused_child; |
1285 | Window unused_root, unused_child; |
1303 | int unused_root_x, unused_root_y; |
1286 | int unused_root_x, unused_root_y; |
1304 | unsigned int unused_mask; |
1287 | unsigned int unused_mask; |
1305 | |
1288 | |
1306 | switch (ev.type) |
1289 | switch (ev.type) |
… | |
… | |
1313 | |
1296 | |
1314 | break; |
1297 | break; |
1315 | |
1298 | |
1316 | case KeyRelease: |
1299 | case KeyRelease: |
1317 | { |
1300 | { |
1318 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1301 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
1319 | KeySym ks; |
1302 | KeySym keysym; |
1320 | |
1303 | |
1321 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1304 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1322 | #endif |
1305 | #endif |
1323 | |
1306 | |
1324 | #if ENABLE_FRILLS || ISO_14755 |
1307 | #if ENABLE_FRILLS || ISO_14755 |
1325 | // ISO 14755 support |
1308 | // ISO 14755 support |
1326 | if (iso14755buf) |
1309 | if (iso14755buf) |
… | |
… | |
1331 | # endif |
1314 | # endif |
1332 | # if ISO_14755 |
1315 | # if ISO_14755 |
1333 | // iso14755 part 5.2 handling: release time |
1316 | // iso14755 part 5.2 handling: release time |
1334 | // first: controls |
1317 | // first: controls |
1335 | if ((ev.xkey.state & ControlMask) |
1318 | if ((ev.xkey.state & ControlMask) |
1336 | && ((ks >= 0x40 && ks <= 0x5f) |
1319 | && ((keysym >= 0x40 && keysym <= 0x5f) |
1337 | || (ks >= 0x61 && ks <= 0x7f))) |
1320 | || (keysym >= 0x61 && keysym <= 0x7f))) |
1338 | { |
1321 | { |
1339 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
1322 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
1340 | commit_iso14755 (); |
1323 | commit_iso14755 (); |
1341 | return; // case-break; |
1324 | goto skip_switch; |
1342 | } |
1325 | } |
1343 | |
1326 | |
1344 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1327 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
1345 | if (i[0] == ks) |
1328 | if (i[0] == keysym) |
1346 | { |
1329 | { |
1347 | iso14755buf = ISO_14755_51 | i[1]; |
1330 | iso14755buf = ISO_14755_51 | i[1]; |
1348 | commit_iso14755 (); |
1331 | commit_iso14755 (); |
1349 | return; // case-break; |
1332 | goto skip_switch; |
1350 | } |
1333 | } |
1351 | |
1334 | |
1352 | scr_bell (); |
1335 | scr_bell (); |
1353 | # endif |
1336 | # endif |
1354 | iso14755buf = 0; |
1337 | iso14755buf = 0; |
… | |
… | |
1373 | else |
1356 | else |
1374 | iso14755buf = 0; |
1357 | iso14755buf = 0; |
1375 | } |
1358 | } |
1376 | #endif |
1359 | #endif |
1377 | |
1360 | |
|
|
1361 | if (ev.xany.window == vt |
|
|
1362 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1363 | break; |
|
|
1364 | |
1378 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1365 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1379 | if (!(ev.xkey.state & ControlMask)) |
1366 | if (!(ev.xkey.state & ControlMask)) |
1380 | slip_wheel_ev.stop (); |
1367 | slip_wheel_ev.stop (); |
1381 | else if (ks == XK_Control_L || ks == XK_Control_R) |
1368 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
1382 | mouse_slip_wheel_speed = 0; |
1369 | mouse_slip_wheel_speed = 0; |
1383 | #endif |
1370 | #endif |
1384 | break; |
1371 | break; |
1385 | } |
1372 | } |
1386 | |
1373 | |
… | |
… | |
1392 | button_release (ev.xbutton); |
1379 | button_release (ev.xbutton); |
1393 | break; |
1380 | break; |
1394 | |
1381 | |
1395 | case ClientMessage: |
1382 | case ClientMessage: |
1396 | if (ev.xclient.format == 32 |
1383 | if (ev.xclient.format == 32 |
1397 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1384 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1398 | { |
1385 | { |
|
|
1386 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1387 | { |
|
|
1388 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1389 | { |
1399 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1390 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1391 | { |
|
|
1392 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1400 | destroy (); |
1393 | destroy (); |
|
|
1394 | } |
1401 | #if ENABLE_EWMH |
1395 | #if ENABLE_EWMH |
1402 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1396 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1403 | XSendEvent (disp, ev.xclient.window = display->root, |
1397 | XSendEvent (xdisp, ev.xclient.window = display->root, |
1404 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1398 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1405 | &ev); |
1399 | &ev); |
|
|
1400 | #endif |
|
|
1401 | } |
|
|
1402 | } |
|
|
1403 | #if ENABLE_XEMBED |
|
|
1404 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1405 | { |
|
|
1406 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1407 | focus_in (); |
|
|
1408 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1409 | focus_out (); |
|
|
1410 | } |
1406 | #endif |
1411 | #endif |
1407 | } |
1412 | } |
1408 | #if ENABLE_XEMBED |
|
|
1409 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1410 | { |
|
|
1411 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1412 | focus_in (); |
|
|
1413 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1414 | focus_out (); |
|
|
1415 | } |
|
|
1416 | #endif |
|
|
1417 | #ifdef OFFIX_DND |
|
|
1418 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1419 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1420 | && (ev.xclient.data.l[0] == DndFile |
|
|
1421 | || ev.xclient.data.l[0] == DndDir |
|
|
1422 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1423 | { |
|
|
1424 | /* Get Dnd data */ |
|
|
1425 | Atom ActualType; |
|
|
1426 | int ActualFormat; |
|
|
1427 | unsigned char *data; |
|
|
1428 | unsigned long Size, RemainingBytes; |
|
|
1429 | |
|
|
1430 | XGetWindowProperty (disp, display->root, |
|
|
1431 | xa[XA_DNDSELECTION], |
|
|
1432 | 0L, 1000000L, |
|
|
1433 | False, AnyPropertyType, |
|
|
1434 | &ActualType, &ActualFormat, |
|
|
1435 | &Size, &RemainingBytes, |
|
|
1436 | &data); |
|
|
1437 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1438 | XFree (data); |
|
|
1439 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1440 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1441 | } |
|
|
1442 | #endif /* OFFIX_DND */ |
|
|
1443 | break; |
1413 | break; |
1444 | |
1414 | |
1445 | case MappingNotify: |
1415 | case MappingNotify: |
1446 | XRefreshKeyboardMapping (&ev.xmapping); |
1416 | XRefreshKeyboardMapping (&ev.xmapping); |
1447 | break; |
1417 | break; |
… | |
… | |
1480 | break; |
1450 | break; |
1481 | |
1451 | |
1482 | case ConfigureNotify: |
1452 | case ConfigureNotify: |
1483 | if (ev.xconfigure.window == parent[0]) |
1453 | if (ev.xconfigure.window == parent[0]) |
1484 | { |
1454 | { |
1485 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1455 | while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1486 | ; |
1456 | ; |
1487 | |
1457 | |
1488 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1458 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1489 | { |
1459 | { |
1490 | seen_resize = 1; |
1460 | seen_resize = 1; |
1491 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1461 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1492 | } |
1462 | } |
1493 | |
1463 | |
|
|
1464 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
|
|
1465 | |
1494 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1466 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1495 | if (OPTION (Opt_transparent)) |
1467 | if (OPTION (Opt_transparent)) |
1496 | check_our_parents (); |
1468 | check_our_parents (); |
1497 | #endif |
1469 | #endif |
1498 | } |
1470 | } |
1499 | break; |
1471 | break; |
1500 | |
1472 | |
1501 | case PropertyNotify: |
1473 | case PropertyNotify: |
|
|
1474 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1502 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1475 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1503 | && ev.xproperty.state == PropertyNewValue) |
1476 | && ev.xproperty.state == PropertyNewValue) |
1504 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1477 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1505 | |
1478 | |
1506 | break; |
1479 | break; |
1507 | |
1480 | |
1508 | case SelectionClear: |
1481 | case SelectionClear: |
1509 | selection_clear (); |
1482 | selection_clear (); |
… | |
… | |
1514 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1487 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1515 | break; |
1488 | break; |
1516 | |
1489 | |
1517 | case SelectionRequest: |
1490 | case SelectionRequest: |
1518 | selection_send (ev.xselectionrequest); |
1491 | selection_send (ev.xselectionrequest); |
|
|
1492 | break; |
|
|
1493 | |
|
|
1494 | case MapNotify: |
|
|
1495 | mapped = 1; |
|
|
1496 | #ifdef TEXT_BLINK |
|
|
1497 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1498 | #endif |
|
|
1499 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1519 | break; |
1500 | break; |
1520 | |
1501 | |
1521 | case UnmapNotify: |
1502 | case UnmapNotify: |
1522 | mapped = 0; |
1503 | mapped = 0; |
1523 | #ifdef TEXT_BLINK |
1504 | #ifdef TEXT_BLINK |
1524 | text_blink_ev.stop (); |
1505 | text_blink_ev.stop (); |
1525 | #endif |
1506 | #endif |
1526 | break; |
1507 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1527 | |
|
|
1528 | case MapNotify: |
|
|
1529 | mapped = 1; |
|
|
1530 | #ifdef TEXT_BLINK |
|
|
1531 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1532 | #endif |
|
|
1533 | break; |
1508 | break; |
1534 | |
1509 | |
1535 | #ifdef TRANSPARENT |
1510 | #ifdef TRANSPARENT |
1536 | case ReparentNotify: |
1511 | case ReparentNotify: |
1537 | rootwin_cb (ev); |
1512 | rootwin_cb (ev); |
… | |
… | |
1543 | if (ev.xany.window == vt) |
1518 | if (ev.xany.window == vt) |
1544 | { |
1519 | { |
1545 | do |
1520 | do |
1546 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1521 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1547 | ev.xexpose.width, ev.xexpose.height, False); |
1522 | ev.xexpose.width, ev.xexpose.height, False); |
1548 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1523 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); |
1549 | |
1524 | |
1550 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1525 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1551 | |
1526 | |
1552 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1527 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) |
1553 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1528 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1554 | ev.xexpose.width, ev.xexpose.height, False); |
1529 | ev.xexpose.width, ev.xexpose.height, False); |
1555 | |
1530 | |
1556 | scr_refresh (refresh_type); |
1531 | want_refresh = 1; |
1557 | } |
1532 | } |
1558 | else |
1533 | else |
1559 | { |
1534 | { |
1560 | XEvent unused_event; |
1535 | XEvent unused_event; |
1561 | |
1536 | |
1562 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1537 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) |
1563 | ; |
1538 | ; |
1564 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1539 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) |
1565 | ; |
1540 | ; |
1566 | |
1541 | |
1567 | if (isScrollbarWindow (ev.xany.window)) |
1542 | if (isScrollbarWindow (ev.xany.window)) |
1568 | { |
1543 | { |
1569 | scrollBar.setIdle (); |
1544 | scrollBar.setIdle (); |
1570 | scrollbar_show (0); |
1545 | scrollbar_show (0); |
1571 | } |
1546 | } |
1572 | #ifdef MENUBAR |
|
|
1573 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1574 | menubar_expose (); |
|
|
1575 | #endif |
|
|
1576 | |
1547 | |
1577 | #ifdef TRANSPARENT |
1548 | #ifdef TRANSPARENT |
1578 | if (am_transparent && ev.xany.window == parent[0]) |
1549 | if (am_transparent && ev.xany.window == parent[0]) |
1579 | XClearWindow (disp, ev.xany.window); |
1550 | XClearWindow (xdisp, ev.xany.window); |
1580 | #endif |
1551 | #endif |
1581 | } |
1552 | } |
1582 | break; |
1553 | break; |
1583 | |
1554 | |
1584 | case MotionNotify: |
1555 | case MotionNotify: |
1585 | #ifdef POINTER_BLANK |
1556 | #ifdef POINTER_BLANK |
1586 | if (hidden_pointer) |
1557 | if (hidden_pointer) |
1587 | pointer_unblank (); |
1558 | pointer_unblank (); |
1588 | #endif |
1559 | #endif |
1589 | #if MENUBAR |
|
|
1590 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1591 | { |
|
|
1592 | menubar_control (ev.xbutton); |
|
|
1593 | break; |
|
|
1594 | } |
|
|
1595 | #endif |
|
|
1596 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1560 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1597 | break; |
1561 | break; |
1598 | |
1562 | |
1599 | if (ev.xany.window == vt) |
1563 | if (ev.xany.window == vt) |
1600 | { |
1564 | { |
|
|
1565 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1566 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1567 | ; // nop |
1601 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1568 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1602 | { |
1569 | { |
1603 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1570 | while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) |
1604 | ; |
1571 | ; |
1605 | |
1572 | |
1606 | XQueryPointer (disp, vt, |
1573 | XQueryPointer (xdisp, vt, |
1607 | &unused_root, &unused_child, |
1574 | &unused_root, &unused_child, |
1608 | &unused_root_x, &unused_root_y, |
1575 | &unused_root_x, &unused_root_y, |
1609 | &ev.xbutton.x, &ev.xbutton.y, |
1576 | &ev.xbutton.x, &ev.xbutton.y, |
1610 | &ev.xbutton.state); |
1577 | &ev.xbutton.state); |
1611 | #ifdef MOUSE_THRESHOLD |
1578 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1675 | #endif |
1642 | #endif |
1676 | } |
1643 | } |
1677 | } |
1644 | } |
1678 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1645 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1679 | { |
1646 | { |
1680 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1647 | while (XCheckTypedWindowEvent (xdisp, scrollBar.win, |
1681 | MotionNotify, &ev)) |
1648 | MotionNotify, &ev)) |
1682 | ; |
1649 | ; |
1683 | |
1650 | |
1684 | XQueryPointer (disp, scrollBar.win, |
1651 | XQueryPointer (xdisp, scrollBar.win, |
1685 | &unused_root, &unused_child, |
1652 | &unused_root, &unused_child, |
1686 | &unused_root_x, &unused_root_y, |
1653 | &unused_root_x, &unused_root_y, |
1687 | &ev.xbutton.x, &ev.xbutton.y, |
1654 | &ev.xbutton.x, &ev.xbutton.y, |
1688 | &unused_mask); |
1655 | &unused_mask); |
1689 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1656 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1690 | scrollbar_size ()); |
1657 | scrollbar_size ()); |
1691 | scr_refresh (refresh_type); |
1658 | want_refresh = 1; |
1692 | refresh_limit = 0; |
1659 | refresh_limit = 0; |
1693 | scrollbar_show (1); |
1660 | scrollbar_show (1); |
1694 | } |
1661 | } |
1695 | break; |
1662 | break; |
1696 | } |
1663 | } |
|
|
1664 | |
|
|
1665 | skip_switch: ; |
|
|
1666 | |
|
|
1667 | #if defined(CURSOR_BLINK) |
|
|
1668 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1669 | { |
|
|
1670 | if (hidden_cursor) |
|
|
1671 | { |
|
|
1672 | hidden_cursor = 0; |
|
|
1673 | want_refresh = 1; |
|
|
1674 | } |
|
|
1675 | |
|
|
1676 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1677 | } |
|
|
1678 | #endif |
|
|
1679 | |
|
|
1680 | #if defined(POINTER_BLANK) |
|
|
1681 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1682 | { |
|
|
1683 | if (ev.type == MotionNotify |
|
|
1684 | || ev.type == ButtonPress |
|
|
1685 | || ev.type == ButtonRelease) |
|
|
1686 | if (hidden_pointer) |
|
|
1687 | pointer_unblank (); |
|
|
1688 | |
|
|
1689 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1690 | pointer_blank (); |
|
|
1691 | } |
|
|
1692 | #endif |
1697 | } |
1693 | } |
1698 | |
1694 | |
1699 | void |
1695 | void |
1700 | rxvt_term::focus_in () |
1696 | rxvt_term::focus_in () |
1701 | { |
1697 | { |
1702 | if (!focus) |
1698 | if (!focus) |
1703 | { |
1699 | { |
1704 | focus = 1; |
1700 | focus = 1; |
1705 | want_refresh = 1; |
1701 | want_refresh = 1; |
1706 | |
1702 | |
1707 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1703 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1708 | |
1704 | |
1709 | #if USE_XIM |
1705 | #if USE_XIM |
1710 | if (Input_Context != NULL) |
1706 | if (Input_Context != NULL) |
1711 | { |
1707 | { |
1712 | IMSetStatusPosition (); |
1708 | IMSetStatusPosition (); |
1713 | XSetICFocus (Input_Context); |
1709 | XSetICFocus (Input_Context); |
1714 | } |
1710 | } |
1715 | #endif |
1711 | #endif |
1716 | #if CURSOR_BLINK |
1712 | #if CURSOR_BLINK |
1717 | if (OPTION (Opt_cursorBlink)) |
1713 | if (OPTION (Opt_cursorBlink)) |
1718 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1714 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1719 | #endif |
1715 | #endif |
1720 | #if OFF_FOCUS_FADING |
1716 | #if OFF_FOCUS_FADING |
1721 | if (rs[Rs_fade]) |
1717 | if (rs[Rs_fade]) |
1722 | { |
1718 | { |
1723 | pix_colors = pix_colors_focused; |
1719 | pix_colors = pix_colors_focused; |
… | |
… | |
1733 | if (focus) |
1729 | if (focus) |
1734 | { |
1730 | { |
1735 | focus = 0; |
1731 | focus = 0; |
1736 | want_refresh = 1; |
1732 | want_refresh = 1; |
1737 | |
1733 | |
1738 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1734 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1739 | |
1735 | |
1740 | #if ENABLE_FRILLS || ISO_14755 |
1736 | #if ENABLE_FRILLS || ISO_14755 |
1741 | if (iso14755buf) |
1737 | if (iso14755buf) |
1742 | { |
1738 | { |
1743 | iso14755buf = 0; |
1739 | iso14755buf = 0; |
… | |
… | |
1767 | |
1763 | |
1768 | #if TRANSPARENT |
1764 | #if TRANSPARENT |
1769 | void |
1765 | void |
1770 | rxvt_term::rootwin_cb (XEvent &ev) |
1766 | rxvt_term::rootwin_cb (XEvent &ev) |
1771 | { |
1767 | { |
1772 | SET_R (this); |
1768 | make_current (); |
1773 | SET_LOCALE (locale); |
|
|
1774 | |
1769 | |
1775 | switch (ev.type) |
1770 | switch (ev.type) |
1776 | { |
1771 | { |
1777 | case PropertyNotify: |
1772 | case PropertyNotify: |
1778 | /* |
1773 | /* |
… | |
… | |
1805 | /* |
1800 | /* |
1806 | * VT window processing of button press |
1801 | * VT window processing of button press |
1807 | */ |
1802 | */ |
1808 | if (ev.window == vt) |
1803 | if (ev.window == vt) |
1809 | { |
1804 | { |
|
|
1805 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1806 | return; |
|
|
1807 | |
1810 | #if ISO_14755 |
1808 | #if ISO_14755 |
1811 | // 5.4 |
1809 | // 5.4 |
1812 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1810 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1813 | { |
1811 | { |
1814 | iso14755_54 (ev.x, ev.y); |
1812 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1826 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1824 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1827 | if (ev.button == MEvent.button && clickintime) |
1825 | if (ev.button == MEvent.button && clickintime) |
1828 | { |
1826 | { |
1829 | /* same button, within alloted time */ |
1827 | /* same button, within alloted time */ |
1830 | MEvent.clicks++; |
1828 | MEvent.clicks++; |
|
|
1829 | |
1831 | if (MEvent.clicks > 1) |
1830 | if (MEvent.clicks > 1) |
1832 | { |
1831 | { |
1833 | /* only report double clicks */ |
1832 | /* only report double clicks */ |
1834 | MEvent.clicks = 2; |
1833 | MEvent.clicks = 2; |
1835 | mouse_report (ev); |
1834 | mouse_report (ev); |
… | |
… | |
1855 | else |
1854 | else |
1856 | { |
1855 | { |
1857 | if (ev.button != MEvent.button) |
1856 | if (ev.button != MEvent.button) |
1858 | MEvent.clicks = 0; |
1857 | MEvent.clicks = 0; |
1859 | |
1858 | |
1860 | if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) |
|
|
1861 | switch (ev.button) |
1859 | switch (ev.button) |
1862 | { |
1860 | { |
1863 | case Button1: |
1861 | case Button1: |
1864 | /* allow meta + click to select rectangular areas */ |
1862 | /* allow meta + click to select rectangular areas */ |
1865 | /* should be done in screen.C */ |
1863 | /* should be done in screen.C */ |
1866 | #if ENABLE_FRILLS |
1864 | #if ENABLE_FRILLS |
1867 | selection.rect = !!(ev.state & ModMetaMask); |
1865 | selection.rect = !!(ev.state & ModMetaMask); |
1868 | #else |
1866 | #else |
1869 | selection.rect = false; |
1867 | selection.rect = false; |
1870 | #endif |
1868 | #endif |
1871 | |
1869 | |
1872 | /* allow shift+left click to extend selection */ |
1870 | /* allow shift+left click to extend selection */ |
1873 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1871 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1874 | { |
1872 | { |
1875 | if (MEvent.button == Button1 && clickintime) |
1873 | if (MEvent.button == Button1 && clickintime) |
1876 | selection_rotate (ev.x, ev.y); |
1874 | selection_rotate (ev.x, ev.y); |
1877 | else |
1875 | else |
1878 | selection_extend (ev.x, ev.y, 1); |
1876 | selection_extend (ev.x, ev.y, 1); |
1879 | } |
1877 | } |
1880 | else |
1878 | else |
1881 | { |
1879 | { |
1882 | if (MEvent.button == Button1 && clickintime) |
1880 | if (MEvent.button == Button1 && clickintime) |
1883 | MEvent.clicks++; |
1881 | MEvent.clicks++; |
1884 | else |
1882 | else |
1885 | MEvent.clicks = 1; |
1883 | MEvent.clicks = 1; |
1886 | |
1884 | |
1887 | selection_click (MEvent.clicks, ev.x, ev.y); |
1885 | selection_click (MEvent.clicks, ev.x, ev.y); |
1888 | } |
1886 | } |
1889 | |
1887 | |
1890 | MEvent.button = Button1; |
1888 | MEvent.button = Button1; |
1891 | break; |
1889 | break; |
1892 | |
1890 | |
1893 | case Button3: |
1891 | case Button3: |
1894 | if (MEvent.button == Button3 && clickintime) |
1892 | if (MEvent.button == Button3 && clickintime) |
1895 | selection_rotate (ev.x, ev.y); |
1893 | selection_rotate (ev.x, ev.y); |
1896 | else |
1894 | else |
1897 | selection_extend (ev.x, ev.y, 1); |
1895 | selection_extend (ev.x, ev.y, 1); |
1898 | |
1896 | |
1899 | MEvent.button = Button3; |
1897 | MEvent.button = Button3; |
1900 | break; |
1898 | break; |
1901 | } |
1899 | } |
1902 | } |
1900 | } |
1903 | |
1901 | |
1904 | MEvent.time = ev.time; |
1902 | MEvent.time = ev.time; |
1905 | return; |
1903 | return; |
1906 | } |
1904 | } |
1907 | |
1905 | |
… | |
… | |
2043 | } |
2041 | } |
2044 | |
2042 | |
2045 | break; |
2043 | break; |
2046 | } |
2044 | } |
2047 | } |
2045 | } |
|
|
2046 | |
2048 | return; |
2047 | return; |
2049 | } |
2048 | } |
2050 | #if MENUBAR |
|
|
2051 | /* |
|
|
2052 | * Menubar window processing of button press |
|
|
2053 | */ |
|
|
2054 | if (isMenuBarWindow (ev.window)) |
|
|
2055 | menubar_control (ev); |
|
|
2056 | #endif |
|
|
2057 | } |
2049 | } |
2058 | |
2050 | |
2059 | void |
2051 | void |
2060 | rxvt_term::button_release (XButtonEvent &ev) |
2052 | rxvt_term::button_release (XButtonEvent &ev) |
2061 | { |
2053 | { |
… | |
… | |
2067 | |
2059 | |
2068 | if (scrollbar_isUpDn ()) |
2060 | if (scrollbar_isUpDn ()) |
2069 | { |
2061 | { |
2070 | scrollBar.setIdle (); |
2062 | scrollBar.setIdle (); |
2071 | scrollbar_show (0); |
2063 | scrollbar_show (0); |
2072 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2073 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2074 | #endif |
|
|
2075 | } |
2064 | } |
2076 | |
2065 | |
2077 | #ifdef SELECTION_SCROLLING |
2066 | #ifdef SELECTION_SCROLLING |
2078 | if (sel_scroll_ev.active) |
2067 | if (sel_scroll_ev.active) |
2079 | sel_scroll_ev.stop(); |
2068 | sel_scroll_ev.stop(); |
2080 | #endif |
2069 | #endif |
2081 | |
2070 | |
2082 | if (ev.window == vt) |
2071 | if (ev.window == vt) |
2083 | { |
2072 | { |
|
|
2073 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2074 | return; |
|
|
2075 | |
2084 | #if ISO_14755 |
2076 | #if ISO_14755 |
2085 | // 5.4 |
2077 | // 5.4 |
2086 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2078 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2087 | return; |
2079 | return; |
2088 | #endif |
2080 | #endif |
|
|
2081 | |
2089 | if (reportmode) |
2082 | if (reportmode) |
2090 | { |
2083 | { |
2091 | /* mouse report from vt window */ |
2084 | /* mouse report from vt window */ |
2092 | /* don't report release of wheel "buttons" */ |
2085 | /* don't report release of wheel "buttons" */ |
2093 | if (ev.button >= 4) |
2086 | if (ev.button >= 4) |
… | |
… | |
2123 | { |
2116 | { |
2124 | case Button1: |
2117 | case Button1: |
2125 | case Button3: |
2118 | case Button3: |
2126 | selection_make (ev.time); |
2119 | selection_make (ev.time); |
2127 | break; |
2120 | break; |
|
|
2121 | |
2128 | case Button2: |
2122 | case Button2: |
2129 | selection_request (ev.time, ev.x, ev.y); |
2123 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2124 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2130 | break; |
2125 | break; |
|
|
2126 | |
2131 | #ifdef MOUSE_WHEEL |
2127 | #ifdef MOUSE_WHEEL |
2132 | case Button4: |
2128 | case Button4: |
2133 | case Button5: |
2129 | case Button5: |
2134 | { |
2130 | { |
2135 | int i; |
2131 | int i; |
… | |
… | |
2157 | slip_wheel_ev.start (); |
2153 | slip_wheel_ev.start (); |
2158 | } |
2154 | } |
2159 | else |
2155 | else |
2160 | { |
2156 | { |
2161 | # endif |
2157 | # endif |
2162 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2163 | scr_page (v, i); |
2158 | scr_page (v, i); |
2164 | scr_refresh (SMOOTH_REFRESH); |
|
|
2165 | scrollbar_show (1); |
2159 | scrollbar_show (1); |
2166 | # else |
|
|
2167 | while (i--) |
|
|
2168 | { |
|
|
2169 | scr_page (v, 1); |
|
|
2170 | scr_refresh (SMOOTH_REFRESH); |
|
|
2171 | scrollbar_show (1); |
|
|
2172 | } |
|
|
2173 | # endif |
|
|
2174 | # ifdef MOUSE_SLIP_WHEELING |
2160 | # ifdef MOUSE_SLIP_WHEELING |
2175 | } |
2161 | } |
2176 | #endif |
2162 | # endif |
2177 | } |
2163 | } |
2178 | break; |
2164 | break; |
2179 | #endif |
2165 | #endif |
2180 | } |
2166 | } |
2181 | } |
2167 | } |
2182 | #ifdef MENUBAR |
|
|
2183 | else if (isMenuBarWindow (ev.window)) |
|
|
2184 | menubar_control (ev); |
|
|
2185 | #endif |
|
|
2186 | } |
2168 | } |
2187 | |
2169 | |
2188 | #ifdef TRANSPARENT |
2170 | #ifdef TRANSPARENT |
2189 | #if TINTING |
2171 | #if TINTING |
2190 | /* taken from aterm-0.4.2 */ |
2172 | /* taken from aterm-0.4.2 */ |
2191 | |
2173 | |
2192 | typedef uint32_t RUINT32T; |
2174 | typedef uint32_t RUINT32T; |
2193 | |
2175 | |
2194 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
2176 | void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
2195 | { |
2177 | { |
2196 | int sh_r, sh_g, sh_b; |
2178 | int sh_r, sh_g, sh_b; |
2197 | RUINT32T mask_r, mask_g, mask_b; |
2179 | RUINT32T mask_r, mask_g, mask_b; |
2198 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2180 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2199 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2181 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2200 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2182 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2201 | int i; |
2183 | int i; |
2202 | |
2184 | |
2203 | Visual *visual = display->visual; |
2185 | Visual *visual = term->visual; |
2204 | |
2186 | |
2205 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2187 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2206 | |
2188 | |
2207 | /* for convenience */ |
2189 | /* for convenience */ |
2208 | mask_r = visual->red_mask; |
2190 | mask_r = visual->red_mask; |
… | |
… | |
2429 | Atom atype; |
2411 | Atom atype; |
2430 | unsigned char *prop = NULL; |
2412 | unsigned char *prop = NULL; |
2431 | Window root, oldp, *list; |
2413 | Window root, oldp, *list; |
2432 | Pixmap rootpixmap = None; |
2414 | Pixmap rootpixmap = None; |
2433 | XWindowAttributes wattr, wrootattr; |
2415 | XWindowAttributes wattr, wrootattr; |
2434 | dDisp; |
|
|
2435 | |
2416 | |
2436 | pchanged = 0; |
2417 | pchanged = 0; |
2437 | |
2418 | |
2438 | if (!OPTION (Opt_transparent)) |
2419 | if (!OPTION (Opt_transparent)) |
2439 | return pchanged; /* Don't try any more */ |
2420 | return pchanged; /* Don't try any more */ |
2440 | |
2421 | |
2441 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2422 | XGetWindowAttributes (xdisp, display->root, &wrootattr); |
2442 | rootdepth = wrootattr.depth; |
2423 | rootdepth = wrootattr.depth; |
2443 | |
2424 | |
2444 | XGetWindowAttributes (disp, parent[0], &wattr); |
2425 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
2445 | |
2426 | |
2446 | if (rootdepth != wattr.depth) |
2427 | if (rootdepth != wattr.depth) |
2447 | { |
2428 | { |
2448 | if (am_transparent) |
2429 | if (am_transparent) |
2449 | { |
2430 | { |
2450 | pchanged = 1; |
2431 | pchanged = 1; |
2451 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2432 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2452 | am_transparent = am_pixmap_trans = 0; |
2433 | am_transparent = am_pixmap_trans = 0; |
2453 | } |
2434 | } |
2454 | |
2435 | |
2455 | return pchanged; /* Don't try any more */ |
2436 | return pchanged; /* Don't try any more */ |
2456 | } |
2437 | } |
2457 | |
2438 | |
2458 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2439 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2459 | XSync (disp, False); |
2440 | XSync (xdisp, False); |
2460 | |
2441 | |
2461 | /* |
2442 | /* |
2462 | * Make the frame window set by the window manager have |
2443 | * Make the frame window set by the window manager have |
2463 | * the root background. Some window managers put multiple nested frame |
2444 | * the root background. Some window managers put multiple nested frame |
2464 | * windows for each client, so we have to take care about that. |
2445 | * windows for each client, so we have to take care about that. |
2465 | */ |
2446 | */ |
2466 | i = (xa[XA_XROOTPMAP_ID] |
2447 | i = (xa[XA_XROOTPMAP_ID] |
2467 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2448 | && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], |
2468 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2449 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2469 | &nitems, &bytes_after, &prop) == Success); |
2450 | &nitems, &bytes_after, &prop) == Success); |
2470 | |
2451 | |
2471 | if (!i || prop == NULL) |
2452 | if (!i || prop == NULL) |
2472 | i = (xa[XA_ESETROOT_PMAP_ID] |
2453 | i = (xa[XA_ESETROOT_PMAP_ID] |
2473 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2454 | && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2474 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2455 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2475 | &nitems, &bytes_after, &prop) == Success); |
2456 | &nitems, &bytes_after, &prop) == Success); |
2476 | |
2457 | |
2477 | if (!i || prop == NULL |
2458 | if (!i || prop == NULL |
2478 | #if TINTING |
2459 | #if TINTING |
… | |
… | |
2497 | Window cr; |
2478 | Window cr; |
2498 | XImage *image; |
2479 | XImage *image; |
2499 | GC gc; |
2480 | GC gc; |
2500 | XGCValues gcvalue; |
2481 | XGCValues gcvalue; |
2501 | |
2482 | |
2502 | XTranslateCoordinates (disp, parent[0], display->root, |
2483 | XTranslateCoordinates (xdisp, parent[0], display->root, |
2503 | 0, 0, &sx, &sy, &cr); |
2484 | 0, 0, &sx, &sy, &cr); |
2504 | nw = (unsigned int)szHint.width; |
2485 | nw = (unsigned int)szHint.width; |
2505 | nh = (unsigned int)szHint.height; |
2486 | nh = (unsigned int)szHint.height; |
2506 | nx = ny = 0; |
2487 | nx = ny = 0; |
2507 | |
2488 | |
… | |
… | |
2520 | } |
2501 | } |
2521 | |
2502 | |
2522 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2503 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2523 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2504 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2524 | |
2505 | |
2525 | XSync (disp, False); |
2506 | XSync (xdisp, False); |
2526 | allowedxerror = -1; |
2507 | allowedxerror = -1; |
2527 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2508 | image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2528 | |
2509 | |
2529 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2510 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2530 | /* XXX: may need a delay here? */ |
2511 | /* XXX: may need a delay here? */ |
2531 | allowedxerror = 0; |
2512 | allowedxerror = 0; |
2532 | |
2513 | |
… | |
… | |
2535 | if (am_transparent && am_pixmap_trans) |
2516 | if (am_transparent && am_pixmap_trans) |
2536 | { |
2517 | { |
2537 | pchanged = 1; |
2518 | pchanged = 1; |
2538 | if (pixmap != None) |
2519 | if (pixmap != None) |
2539 | { |
2520 | { |
2540 | XFreePixmap (disp, pixmap); |
2521 | XFreePixmap (xdisp, pixmap); |
2541 | pixmap = None; |
2522 | pixmap = None; |
2542 | } |
2523 | } |
2543 | } |
2524 | } |
2544 | |
2525 | |
2545 | am_pixmap_trans = 0; |
2526 | am_pixmap_trans = 0; |
2546 | } |
2527 | } |
2547 | else |
2528 | else |
2548 | { |
2529 | { |
2549 | if (pixmap != None) |
2530 | if (pixmap != None) |
2550 | XFreePixmap (disp, pixmap); |
2531 | XFreePixmap (xdisp, pixmap); |
2551 | |
2532 | |
2552 | #if TINTING |
2533 | #if TINTING |
2553 | if (ISSET_PIXCOLOR (Color_tint)) |
2534 | if (ISSET_PIXCOLOR (Color_tint)) |
2554 | { |
2535 | { |
2555 | unsigned short rm, gm, bm; |
2536 | unsigned short rm, gm, bm; |
2556 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2537 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2557 | |
2538 | |
2558 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
2539 | pix_colors_focused[Color_tint].get (this, rm, gm, bm); |
2559 | |
2540 | |
2560 | ShadeXImage (display, image, shade, rm, gm, bm); |
2541 | ShadeXImage (this, image, shade, rm, gm, bm); |
2561 | } |
2542 | } |
2562 | #endif |
2543 | #endif |
2563 | |
2544 | |
2564 | pixmap = XCreatePixmap (disp, vt, |
2545 | pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); |
2565 | szHint.width, szHint.height, image->depth); |
|
|
2566 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
2546 | gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); |
2567 | XPutImage (disp, pixmap, gc, image, 0, 0, |
2547 | XPutImage (xdisp, pixmap, gc, image, 0, 0, |
2568 | nx, ny, image->width, image->height); |
2548 | nx, ny, image->width, image->height); |
2569 | XFreeGC (disp, gc); |
2549 | XFreeGC (xdisp, gc); |
2570 | XDestroyImage (image); |
2550 | XDestroyImage (image); |
2571 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
2551 | XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); |
2572 | XClearWindow (disp, parent[0]); |
2552 | XClearWindow (xdisp, parent[0]); |
2573 | |
2553 | |
2574 | if (!am_transparent || !am_pixmap_trans) |
2554 | if (!am_transparent || !am_pixmap_trans) |
2575 | pchanged = 1; |
2555 | pchanged = 1; |
2576 | |
2556 | |
2577 | am_transparent = am_pixmap_trans = 1; |
2557 | am_transparent = am_pixmap_trans = 1; |
2578 | } |
2558 | } |
2579 | } |
2559 | } |
2580 | |
2560 | |
2581 | if (am_pixmap_trans) |
2561 | if (am_pixmap_trans) |
2582 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2562 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2583 | else |
2563 | else |
2584 | { |
2564 | { |
2585 | unsigned int n; |
2565 | unsigned int n; |
2586 | /* |
2566 | /* |
2587 | * InheritPixmap transparency |
2567 | * InheritPixmap transparency |
2588 | */ |
2568 | */ |
2589 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2569 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2590 | { |
2570 | { |
2591 | oldp = parent[i]; |
2571 | oldp = parent[i]; |
2592 | XQueryTree (disp, parent[i - 1], &root, |
2572 | XQueryTree (xdisp, parent[i - 1], &root, |
2593 | &parent[i], &list, &n); |
2573 | &parent[i], &list, &n); |
2594 | XFree (list); |
2574 | XFree (list); |
2595 | |
2575 | |
2596 | if (parent[i] == display->root) |
2576 | if (parent[i] == display->root) |
2597 | { |
2577 | { |
… | |
… | |
2609 | |
2589 | |
2610 | if (pchanged) |
2590 | if (pchanged) |
2611 | { |
2591 | { |
2612 | for (; n < (unsigned int)i; n++) |
2592 | for (; n < (unsigned int)i; n++) |
2613 | { |
2593 | { |
2614 | XGetWindowAttributes (disp, parent[n], &wattr); |
2594 | XGetWindowAttributes (xdisp, parent[n], &wattr); |
2615 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2595 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2616 | { |
2596 | { |
2617 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2597 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2618 | break; |
2598 | break; |
2619 | } |
2599 | } |
2620 | } |
2600 | } |
2621 | } |
2601 | } |
2622 | |
2602 | |
2623 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2603 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2624 | { |
2604 | { |
2625 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
2605 | XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); |
2626 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
2606 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2627 | am_transparent = 0; |
2607 | am_transparent = 0; |
2628 | /* XXX: also turn off Opt_transparent? */ |
2608 | /* XXX: also turn off Opt_transparent? */ |
2629 | } |
2609 | } |
2630 | else |
2610 | else |
2631 | { |
2611 | { |
2632 | #if WAIT_FOR_WM |
|
|
2633 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2634 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2635 | sleep (1); |
|
|
2636 | #endif |
|
|
2637 | for (n = 0; n < (unsigned int)i; n++) |
2612 | for (n = 0; n < (unsigned int)i; n++) |
2638 | { |
2613 | { |
2639 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2614 | XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); |
2640 | XClearWindow (disp, parent[n]); |
2615 | XClearWindow (xdisp, parent[n]); |
2641 | } |
2616 | } |
2642 | |
2617 | |
2643 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
2618 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2644 | am_transparent = 1; |
2619 | am_transparent = 1; |
2645 | } |
2620 | } |
2646 | |
2621 | |
2647 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2622 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2648 | parent[i] = None; |
2623 | parent[i] = None; |
2649 | } |
2624 | } |
2650 | |
2625 | |
2651 | if (scrollBar.win) |
2626 | if (scrollBar.win) |
2652 | { |
2627 | { |
2653 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2628 | XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); |
2654 | scrollBar.setIdle (); |
2629 | scrollBar.setIdle (); |
2655 | scrollbar_show (0); |
2630 | scrollbar_show (0); |
2656 | } |
2631 | } |
2657 | |
2632 | |
2658 | if (am_transparent) |
2633 | if (am_transparent) |
… | |
… | |
2670 | |
2645 | |
2671 | bool |
2646 | bool |
2672 | rxvt_term::cmd_parse () |
2647 | rxvt_term::cmd_parse () |
2673 | { |
2648 | { |
2674 | bool flag = false; |
2649 | bool flag = false; |
2675 | unicode_t ch = NOCHAR; |
2650 | wchar_t ch = NOCHAR; |
2676 | char *seq_begin; // remember start of esc-sequence here |
2651 | char *seq_begin; // remember start of esc-sequence here |
2677 | |
2652 | |
2678 | for (;;) |
2653 | for (;;) |
2679 | { |
2654 | { |
2680 | if (ch == NOCHAR) |
2655 | if (ch == NOCHAR) |
2681 | { |
2656 | { |
2682 | seq_begin = cmdbuf_ptr; |
2657 | seq_begin = cmdbuf_ptr; |
2683 | ch = next_char (); |
2658 | ch = next_char (); |
2684 | } |
|
|
2685 | |
2659 | |
2686 | if (ch == NOCHAR) // TODO: improve |
2660 | if (ch == NOCHAR) |
2687 | break; |
2661 | break; |
|
|
2662 | } |
2688 | |
2663 | |
2689 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2664 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2690 | { |
2665 | { |
2691 | if (!seen_input) |
2666 | if (!seen_input) |
2692 | { |
2667 | { |
… | |
… | |
2701 | if (seen_resize && cmd_pid) |
2676 | if (seen_resize && cmd_pid) |
2702 | kill (-cmd_pid, SIGWINCH); |
2677 | kill (-cmd_pid, SIGWINCH); |
2703 | } |
2678 | } |
2704 | |
2679 | |
2705 | /* Read a text string from the input buffer */ |
2680 | /* Read a text string from the input buffer */ |
2706 | unicode_t buf[UBUFSIZ]; |
2681 | wchar_t buf[UBUFSIZ]; |
2707 | bool refreshnow = false; |
2682 | bool refreshnow = false; |
2708 | int nlines = 0; |
2683 | int nlines = 0; |
2709 | unicode_t *str = buf; |
2684 | wchar_t *str = buf; |
2710 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2685 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2711 | |
2686 | |
2712 | for (;;) |
2687 | for (;;) |
2713 | { |
2688 | { |
2714 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2689 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2715 | break; |
2690 | break; |
… | |
… | |
2733 | } |
2708 | } |
2734 | |
2709 | |
2735 | // scr_add_lines only works for nlines <= nrow - 1. |
2710 | // scr_add_lines only works for nlines <= nrow - 1. |
2736 | if (nlines >= nrow - 1) |
2711 | if (nlines >= nrow - 1) |
2737 | { |
2712 | { |
|
|
2713 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2738 | if (!PERL_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2714 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2739 | scr_add_lines (buf, nlines, str - buf); |
2715 | scr_add_lines (buf, str - buf, nlines); |
2740 | |
2716 | |
2741 | nlines = 0; |
2717 | nlines = 0; |
2742 | str = buf; |
2718 | str = buf; |
2743 | eol = str + min (ncol, UBUFSIZ); |
2719 | eol = str + min (ncol, UBUFSIZ); |
2744 | } |
2720 | } |
… | |
… | |
2758 | |
2734 | |
2759 | seq_begin = cmdbuf_ptr; |
2735 | seq_begin = cmdbuf_ptr; |
2760 | ch = next_char (); |
2736 | ch = next_char (); |
2761 | } |
2737 | } |
2762 | |
2738 | |
|
|
2739 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2763 | if (!PERL_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) |
2740 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2764 | scr_add_lines (buf, nlines, str - buf); |
2741 | scr_add_lines (buf, str - buf, nlines); |
2765 | |
2742 | |
2766 | /* |
2743 | /* |
2767 | * If there have been a lot of new lines, then update the screen |
2744 | * If there have been a lot of new lines, then update the screen |
2768 | * What the heck I'll cheat and only refresh less than every page-full. |
2745 | * What the heck I'll cheat and only refresh less than every page-full. |
2769 | * the number of pages between refreshes is refresh_limit, which |
2746 | * the number of pages between refreshes is refresh_limit, which |
… | |
… | |
2774 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2751 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2775 | refresh_limit++; |
2752 | refresh_limit++; |
2776 | else |
2753 | else |
2777 | { |
2754 | { |
2778 | flag = true; |
2755 | flag = true; |
2779 | scr_refresh (refresh_type); |
2756 | scr_refresh (); |
2780 | flush_ev.stop (); |
2757 | want_refresh = 1; |
2781 | } |
2758 | } |
2782 | } |
2759 | } |
2783 | |
2760 | |
2784 | } |
2761 | } |
2785 | else |
2762 | else |
… | |
… | |
2800 | } |
2777 | } |
2801 | |
2778 | |
2802 | return flag; |
2779 | return flag; |
2803 | } |
2780 | } |
2804 | |
2781 | |
2805 | // read the next octet |
|
|
2806 | unicode_t |
|
|
2807 | rxvt_term::next_octet () |
|
|
2808 | { |
|
|
2809 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2810 | ? *cmdbuf_ptr++ |
|
|
2811 | : NOCHAR; |
|
|
2812 | } |
|
|
2813 | |
|
|
2814 | // read the next character |
2782 | // read the next character |
2815 | unicode_t |
2783 | wchar_t |
2816 | rxvt_term::next_char () |
2784 | rxvt_term::next_char () NOTHROW |
2817 | { |
2785 | { |
2818 | while (cmdbuf_ptr < cmdbuf_endp) |
2786 | while (cmdbuf_ptr < cmdbuf_endp) |
2819 | { |
2787 | { |
2820 | // assume 7-bit to be ascii ALWAYS |
2788 | // assume 7-bit to be ascii ALWAYS |
2821 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2789 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2830 | cmdbuf_ptr = cmdbuf_endp; |
2798 | cmdbuf_ptr = cmdbuf_endp; |
2831 | break; |
2799 | break; |
2832 | } |
2800 | } |
2833 | |
2801 | |
2834 | if (len == (size_t)-1) |
2802 | if (len == (size_t)-1) |
2835 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2803 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2836 | |
2804 | |
2837 | // assume wchar == unicode |
2805 | // assume wchar == unicode |
2838 | cmdbuf_ptr += len; |
2806 | cmdbuf_ptr += len; |
2839 | return wc & UNICODE_MASK; |
2807 | return wc & UNICODE_MASK; |
2840 | } |
2808 | } |
2841 | |
2809 | |
2842 | return NOCHAR; |
2810 | return NOCHAR; |
2843 | } |
2811 | } |
|
|
2812 | |
|
|
2813 | // read the next octet |
|
|
2814 | uint32_t |
|
|
2815 | rxvt_term::next_octet () NOTHROW |
|
|
2816 | { |
|
|
2817 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2818 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2819 | : NOCHAR; |
|
|
2820 | } |
|
|
2821 | |
|
|
2822 | static class out_of_input out_of_input; |
2844 | |
2823 | |
2845 | /* rxvt_cmd_getc () - Return next input character */ |
2824 | /* rxvt_cmd_getc () - Return next input character */ |
2846 | /* |
2825 | /* |
2847 | * Return the next input character after first passing any keyboard input |
2826 | * Return the next input character after first passing any keyboard input |
2848 | * to the command. |
2827 | * to the command. |
2849 | */ |
2828 | */ |
2850 | unicode_t |
2829 | wchar_t |
2851 | rxvt_term::cmd_getc () |
2830 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2852 | { |
2831 | { |
2853 | unicode_t c = next_char (); |
2832 | wchar_t c = next_char (); |
2854 | |
2833 | |
2855 | if (c == NOCHAR) |
2834 | if (c == NOCHAR) |
2856 | throw out_of_input; |
2835 | throw out_of_input; |
2857 | |
2836 | |
2858 | return c; |
2837 | return c; |
2859 | } |
2838 | } |
2860 | |
2839 | |
2861 | unicode_t |
2840 | uint32_t |
2862 | rxvt_term::cmd_get8 () |
2841 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2863 | { |
2842 | { |
2864 | unicode_t c = next_octet (); |
2843 | uint32_t c = next_octet (); |
2865 | |
2844 | |
2866 | if (c == NOCHAR) |
2845 | if (c == NOCHAR) |
2867 | throw out_of_input; |
2846 | throw out_of_input; |
2868 | |
2847 | |
2869 | return c; |
2848 | return c; |
… | |
… | |
3136 | break; |
3115 | break; |
3137 | |
3116 | |
3138 | /* 8.3.87: NEXT LINE */ |
3117 | /* 8.3.87: NEXT LINE */ |
3139 | case C1_NEL: /* ESC E */ |
3118 | case C1_NEL: /* ESC E */ |
3140 | { |
3119 | { |
3141 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
3120 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3142 | scr_add_lines (nlcr, 1, 2); |
3121 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3143 | } |
3122 | } |
3144 | break; |
3123 | break; |
3145 | |
3124 | |
3146 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3125 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3147 | case C1_ESA: /* ESC G */ |
3126 | case C1_ESA: /* ESC G */ |
… | |
… | |
3288 | ndef = get_byte_array_bit (csi_defaults, i); |
3267 | ndef = get_byte_array_bit (csi_defaults, i); |
3289 | for (p = 0; p < nargs; p++) |
3268 | for (p = 0; p < nargs; p++) |
3290 | if (arg[p] == -1) |
3269 | if (arg[p] == -1) |
3291 | arg[p] = ndef; |
3270 | arg[p] = ndef; |
3292 | |
3271 | |
3293 | #ifdef DEBUG_CMD |
|
|
3294 | fprintf (stderr, "CSI "); |
|
|
3295 | for (p = 0; p < nargs; p++) |
|
|
3296 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3297 | fprintf (stderr, "%c\n", ch); |
|
|
3298 | #endif |
|
|
3299 | |
|
|
3300 | /* |
3272 | /* |
3301 | * private mode handling |
3273 | * private mode handling |
3302 | */ |
3274 | */ |
3303 | if (priv) |
3275 | if (priv) |
3304 | { |
3276 | { |
3305 | switch (priv) |
3277 | switch (priv) |
3306 | { |
3278 | { |
3307 | case '>': |
3279 | case '>': |
3308 | if (ch == CSI_DA) /* secondary device attributes */ |
3280 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
3281 | { |
|
|
3282 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3283 | // 'U' for rxvt-unicode <= 7.2, and Mm85 (e.g. 7385 for 7.3) for later versions. |
|
|
3284 | // |
|
|
3285 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3286 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3287 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3288 | // |
3309 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3289 | tt_printf ("\033[>%c%c85;94;0c", VERSION[0], VERSION[1]); |
|
|
3290 | } |
3310 | break; |
3291 | break; |
3311 | case '?': |
3292 | case '?': |
3312 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3293 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3313 | process_terminal_mode (ch, priv, nargs, arg); |
3294 | process_terminal_mode (ch, priv, nargs, arg); |
3314 | break; |
3295 | break; |
… | |
… | |
3542 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3523 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3543 | { |
3524 | { |
3544 | int x, y; |
3525 | int x, y; |
3545 | XWindowAttributes wattr; |
3526 | XWindowAttributes wattr; |
3546 | Window wdummy; |
3527 | Window wdummy; |
3547 | dDisp; |
3528 | |
|
|
3529 | dLocal (Display *, xdisp); |
3548 | |
3530 | |
3549 | if (nargs == 0) |
3531 | if (nargs == 0) |
3550 | return; |
3532 | return; |
3551 | |
3533 | |
3552 | switch (args[0]) |
3534 | switch (args[0]) |
3553 | { |
3535 | { |
3554 | /* |
3536 | /* |
3555 | * commands |
3537 | * commands |
3556 | */ |
3538 | */ |
3557 | case 1: /* deiconify window */ |
3539 | case 1: /* deiconify window */ |
3558 | XMapWindow (disp, parent[0]); |
3540 | XMapWindow (xdisp, parent[0]); |
3559 | break; |
3541 | break; |
3560 | case 2: /* iconify window */ |
3542 | case 2: /* iconify window */ |
3561 | XIconifyWindow (disp, parent[0], display->screen); |
3543 | XIconifyWindow (xdisp, parent[0], display->screen); |
3562 | break; |
3544 | break; |
3563 | case 3: /* set position (pixels) */ |
3545 | case 3: /* set position (pixels) */ |
3564 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3546 | XMoveWindow (xdisp, parent[0], args[1], args[2]); |
3565 | break; |
3547 | break; |
3566 | case 4: /* set size (pixels) */ |
3548 | case 4: /* set size (pixels) */ |
3567 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3549 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3568 | break; |
3550 | break; |
3569 | case 5: /* raise window */ |
3551 | case 5: /* raise window */ |
3570 | XRaiseWindow (disp, parent[0]); |
3552 | XRaiseWindow (xdisp, parent[0]); |
3571 | break; |
3553 | break; |
3572 | case 6: /* lower window */ |
3554 | case 6: /* lower window */ |
3573 | XLowerWindow (disp, parent[0]); |
3555 | XLowerWindow (xdisp, parent[0]); |
3574 | break; |
3556 | break; |
3575 | case 7: /* refresh window */ |
3557 | case 7: /* refresh window */ |
3576 | scr_touch (true); |
3558 | scr_touch (true); |
3577 | break; |
3559 | break; |
3578 | case 8: /* set size (chars) */ |
3560 | case 8: /* set size (chars) */ |
… | |
… | |
3590 | |
3572 | |
3591 | /* |
3573 | /* |
3592 | * reports - some output format copied from XTerm |
3574 | * reports - some output format copied from XTerm |
3593 | */ |
3575 | */ |
3594 | case 11: /* report window state */ |
3576 | case 11: /* report window state */ |
3595 | XGetWindowAttributes (disp, parent[0], &wattr); |
3577 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3596 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3578 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3597 | break; |
3579 | break; |
3598 | case 13: /* report window position */ |
3580 | case 13: /* report window position */ |
3599 | XGetWindowAttributes (disp, parent[0], &wattr); |
3581 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3600 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3582 | XTranslateCoordinates (xdisp, parent[0], wattr.root, |
3601 | -wattr.border_width, -wattr.border_width, |
3583 | -wattr.border_width, -wattr.border_width, |
3602 | &x, &y, &wdummy); |
3584 | &x, &y, &wdummy); |
3603 | tt_printf ("\033[3;%d;%dt", x, y); |
3585 | tt_printf ("\033[3;%d;%dt", x, y); |
3604 | break; |
3586 | break; |
3605 | case 14: /* report window size (pixels) */ |
3587 | case 14: /* report window size (pixels) */ |
3606 | XGetWindowAttributes (disp, parent[0], &wattr); |
3588 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3607 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3589 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3608 | break; |
3590 | break; |
3609 | case 18: /* report text area size (chars) */ |
3591 | case 18: /* report text area size (chars) */ |
3610 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3592 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3611 | break; |
3593 | break; |
… | |
… | |
3613 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3595 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3614 | break; |
3596 | break; |
3615 | case 20: /* report icon label */ |
3597 | case 20: /* report icon label */ |
3616 | { |
3598 | { |
3617 | char *s; |
3599 | char *s; |
3618 | XGetIconName (disp, parent[0], &s); |
3600 | XGetIconName (xdisp, parent[0], &s); |
3619 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3601 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3620 | XFree (s); |
3602 | XFree (s); |
3621 | } |
3603 | } |
3622 | break; |
3604 | break; |
3623 | case 21: /* report window title */ |
3605 | case 21: /* report window title */ |
3624 | { |
3606 | { |
3625 | char *s; |
3607 | char *s; |
3626 | XFetchName (disp, parent[0], &s); |
3608 | XFetchName (xdisp, parent[0], &s); |
3627 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3609 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3628 | XFree (s); |
3610 | XFree (s); |
3629 | } |
3611 | } |
3630 | break; |
3612 | break; |
3631 | } |
3613 | } |
… | |
… | |
3733 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3715 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3734 | { |
3716 | { |
3735 | if (str[0] == '?' && !str[1]) |
3717 | if (str[0] == '?' && !str[1]) |
3736 | { |
3718 | { |
3737 | unsigned short r, g, b; |
3719 | unsigned short r, g, b; |
3738 | pix_colors_focused[color].get (display, r, g, b); |
3720 | pix_colors_focused[color].get (this, r, g, b); |
3739 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3721 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3740 | } |
3722 | } |
3741 | else |
3723 | else |
3742 | set_window_color (color, str); |
3724 | set_window_color (color, str); |
3743 | } |
3725 | } |
… | |
… | |
3746 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3728 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3747 | */ |
3729 | */ |
3748 | void |
3730 | void |
3749 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3731 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3750 | { |
3732 | { |
3751 | int changed = 0; |
|
|
3752 | int color; |
3733 | int color; |
3753 | char *buf, *name; |
3734 | char *buf, *name; |
3754 | bool query = str[0] == '?' && !str[1]; |
3735 | bool query = str[0] == '?' && !str[1]; |
3755 | int saveop = op; |
3736 | int saveop = op; |
3756 | dDisp; |
3737 | |
|
|
3738 | dLocal (Display *, xdisp); |
3757 | |
3739 | |
3758 | assert (str != NULL); |
3740 | assert (str != NULL); |
3759 | switch (op) |
3741 | switch (op) |
3760 | { |
3742 | { |
3761 | case XTerm_name: |
3743 | case XTerm_name: |
… | |
… | |
3777 | unsigned long bytes_after; |
3759 | unsigned long bytes_after; |
3778 | unsigned char *value = 0; |
3760 | unsigned char *value = 0; |
3779 | const char *str = ""; |
3761 | const char *str = ""; |
3780 | |
3762 | |
3781 | if (prop |
3763 | if (prop |
3782 | && XGetWindowProperty (disp, parent[0], |
3764 | && XGetWindowProperty (xdisp, parent[0], |
3783 | prop, 0, 1<<16, 0, AnyPropertyType, |
3765 | prop, 0, 1<<16, 0, AnyPropertyType, |
3784 | &actual_type, &actual_format, |
3766 | &actual_type, &actual_format, |
3785 | &nitems, &bytes_after, &value) == Success |
3767 | &nitems, &bytes_after, &value) == Success |
3786 | && actual_type != None |
3768 | && actual_type != None |
3787 | && actual_format == 8) |
3769 | && actual_format == 8) |
… | |
… | |
3799 | { |
3781 | { |
3800 | *eq = 0; |
3782 | *eq = 0; |
3801 | set_utf8_property (display->atom (str), eq + 1); |
3783 | set_utf8_property (display->atom (str), eq + 1); |
3802 | } |
3784 | } |
3803 | else |
3785 | else |
3804 | XDeleteProperty (disp, parent[0], |
3786 | XDeleteProperty (xdisp, parent[0], |
3805 | display->atom (str)); |
3787 | display->atom (str)); |
3806 | } |
3788 | } |
3807 | break; |
3789 | break; |
3808 | |
3790 | |
3809 | case XTerm_Color: |
3791 | case XTerm_Color: |
… | |
… | |
3811 | { |
3793 | { |
3812 | if ((name = strchr (buf, ';')) == NULL) |
3794 | if ((name = strchr (buf, ';')) == NULL) |
3813 | break; |
3795 | break; |
3814 | |
3796 | |
3815 | *name++ = '\0'; |
3797 | *name++ = '\0'; |
3816 | color = atoi (buf); |
3798 | color = atoi (buf) + minCOLOR; |
3817 | |
3799 | |
3818 | if (color < 0 || color >= TOTAL_COLORS) |
3800 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3819 | break; |
3801 | break; |
3820 | |
3802 | |
3821 | if ((buf = strchr (name, ';')) != NULL) |
3803 | if ((buf = strchr (name, ';')) != NULL) |
3822 | *buf++ = '\0'; |
3804 | *buf++ = '\0'; |
3823 | |
3805 | |
3824 | if (name[0] == '?' && !name[1]) |
3806 | if (name[0] == '?' && !name[1]) |
3825 | { |
3807 | { |
3826 | unsigned short r, g, b; |
3808 | unsigned short r, g, b; |
3827 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3809 | pix_colors_focused[color].get (this, r, g, b); |
3828 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3810 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3829 | } |
3811 | } |
3830 | else |
3812 | else |
3831 | set_window_color (color + minCOLOR, name); |
3813 | set_window_color (color, name); |
3832 | } |
3814 | } |
3833 | break; |
3815 | break; |
3834 | case XTerm_Color00: |
3816 | case XTerm_Color00: |
3835 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3817 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3836 | break; |
3818 | break; |
3837 | case XTerm_Color01: |
3819 | case XTerm_Color01: |
3838 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3820 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3839 | break; |
3821 | break; |
3840 | #ifndef NO_CURSORCOLOR |
3822 | #ifndef NO_CURSORCOLOR |
3841 | case XTerm_Color_cursor: |
3823 | case XTerm_Color_cursor: |
3842 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3824 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3843 | break; |
3825 | break; |
… | |
… | |
3847 | break; |
3829 | break; |
3848 | case XTerm_Color_pointer_bg: |
3830 | case XTerm_Color_pointer_bg: |
3849 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3831 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3850 | break; |
3832 | break; |
3851 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3833 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3852 | case XTerm_Color_BD: |
|
|
3853 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3854 | break; |
|
|
3855 | case XTerm_Color_UL: |
|
|
3856 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3857 | break; |
|
|
3858 | case XTerm_Color_RV: |
3834 | case XTerm_Color_RV: |
3859 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3835 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3836 | break; |
|
|
3837 | case Rxvt_Color_BD: |
|
|
3838 | case URxvt_Color_BD: |
|
|
3839 | process_color_seq (op, Color_BD, str, resp); |
|
|
3840 | break; |
|
|
3841 | case Rxvt_Color_UL: |
|
|
3842 | case URxvt_Color_UL: |
|
|
3843 | process_color_seq (op, Color_UL, str, resp); |
3860 | break; |
3844 | break; |
3861 | case URxvt_Color_IT: |
3845 | case URxvt_Color_IT: |
3862 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3846 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3863 | break; |
3847 | break; |
3864 | #endif |
3848 | #endif |
… | |
… | |
3869 | if (am_transparent) |
3853 | if (am_transparent) |
3870 | want_full_refresh = want_refresh = 1; |
3854 | want_full_refresh = want_refresh = 1; |
3871 | break; |
3855 | break; |
3872 | #endif |
3856 | #endif |
3873 | |
3857 | |
3874 | case XTerm_Pixmap: |
3858 | case Rxvt_Pixmap: |
|
|
3859 | { |
3875 | if (*str != ';') |
3860 | if (*str != ';') |
3876 | { |
3861 | { |
3877 | #if XPM_BACKGROUND |
3862 | #if XPM_BACKGROUND |
3878 | scale_pixmap (""); /* reset to default scaling */ |
3863 | scale_pixmap (""); /* reset to default scaling */ |
3879 | set_bgPixmap (str); /* change pixmap */ |
3864 | set_bgPixmap (str); /* change pixmap */ |
3880 | #endif |
|
|
3881 | scr_touch (true); |
3865 | scr_touch (true); |
|
|
3866 | #endif |
3882 | } |
3867 | } |
|
|
3868 | |
|
|
3869 | int changed = 0; |
|
|
3870 | |
3883 | while ((str = strchr (str, ';')) != NULL) |
3871 | while ((str = strchr (str, ';')) != NULL) |
3884 | { |
3872 | { |
3885 | str++; |
3873 | str++; |
3886 | #if XPM_BACKGROUND |
3874 | #if XPM_BACKGROUND |
3887 | changed += scale_pixmap (str); |
3875 | changed += scale_pixmap (str); |
3888 | #endif |
3876 | #endif |
3889 | } |
3877 | } |
3890 | |
3878 | |
3891 | if (changed) |
3879 | if (changed) |
3892 | { |
3880 | { |
3893 | #ifdef XPM_BACKGROUND |
3881 | #ifdef XPM_BACKGROUND |
3894 | resize_pixmap (); |
3882 | resize_pixmap (); |
3895 | #endif |
|
|
3896 | scr_touch (true); |
3883 | scr_touch (true); |
|
|
3884 | #endif |
3897 | } |
3885 | } |
|
|
3886 | } |
3898 | break; |
3887 | break; |
3899 | |
3888 | |
3900 | case XTerm_restoreFG: |
3889 | case Rxvt_restoreFG: |
3901 | set_window_color (Color_fg, str); |
3890 | set_window_color (Color_fg, str); |
3902 | break; |
3891 | break; |
3903 | case XTerm_restoreBG: |
3892 | case Rxvt_restoreBG: |
3904 | set_window_color (Color_bg, str); |
3893 | set_window_color (Color_bg, str); |
3905 | break; |
3894 | break; |
3906 | |
3895 | |
3907 | case XTerm_logfile: |
3896 | case XTerm_logfile: |
3908 | // TODO, when secure mode? |
3897 | // TODO, when secure mode? |
3909 | break; |
3898 | break; |
3910 | |
3899 | |
3911 | #ifdef MENUBAR |
|
|
3912 | case URxvt_Menu: |
|
|
3913 | if (OPTION (Opt_insecure)) |
|
|
3914 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3915 | break; |
|
|
3916 | #endif |
|
|
3917 | #if 0 |
3900 | #if 0 |
3918 | case XTerm_dumpscreen: /* no error notices */ |
3901 | case Rxvt_dumpscreen: /* no error notices */ |
3919 | { |
3902 | { |
3920 | int fd; |
3903 | int fd; |
3921 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3904 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3922 | { |
3905 | { |
3923 | scr_dump (fd); |
3906 | scr_dump (fd); |
… | |
… | |
3954 | if (query) |
3937 | if (query) |
3955 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3938 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3956 | else |
3939 | else |
3957 | { |
3940 | { |
3958 | set_locale (str); |
3941 | set_locale (str); |
3959 | pty.set_utf8_mode (enc_utf8); |
3942 | pty->set_utf8_mode (enc_utf8); |
3960 | init_xlocale (); |
3943 | init_xlocale (); |
3961 | } |
3944 | } |
3962 | break; |
3945 | break; |
3963 | |
3946 | |
3964 | case URxvt_view_up: |
3947 | case URxvt_view_up: |
… | |
… | |
3975 | break; |
3958 | break; |
3976 | #endif |
3959 | #endif |
3977 | |
3960 | |
3978 | #if ENABLE_PERL |
3961 | #if ENABLE_PERL |
3979 | case URxvt_perl: |
3962 | case URxvt_perl: |
3980 | if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) |
3963 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3981 | ; // no responses yet |
3964 | ; // no responses yet |
3982 | break; |
3965 | break; |
3983 | #endif |
3966 | #endif |
3984 | } |
3967 | } |
3985 | } |
3968 | } |
… | |
… | |
4017 | return state; |
4000 | return state; |
4018 | } |
4001 | } |
4019 | |
4002 | |
4020 | /* we're not using priv _yet_ */ |
4003 | /* we're not using priv _yet_ */ |
4021 | void |
4004 | void |
4022 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4005 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4023 | { |
4006 | { |
4024 | unsigned int i, j; |
4007 | unsigned int i, j; |
4025 | int state; |
4008 | int state; |
4026 | |
4009 | |
4027 | static const struct |
4010 | static const struct |
… | |
… | |
4038 | { 5, PrivMode_rVideo }, |
4021 | { 5, PrivMode_rVideo }, |
4039 | { 6, PrivMode_relOrigin }, |
4022 | { 6, PrivMode_relOrigin }, |
4040 | { 7, PrivMode_Autowrap }, |
4023 | { 7, PrivMode_Autowrap }, |
4041 | // 8, bi-directional support mode |
4024 | // 8, bi-directional support mode |
4042 | { 9, PrivMode_MouseX10 }, |
4025 | { 9, PrivMode_MouseX10 }, |
4043 | #ifdef menuBar_esc |
|
|
4044 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4045 | #endif |
|
|
4046 | // 18, 19 printing-related |
4026 | // 18, 19 printing-related |
4047 | { 25, PrivMode_VisibleCursor }, |
4027 | { 25, PrivMode_VisibleCursor }, |
4048 | #ifdef scrollBar_esc |
4028 | #ifdef scrollBar_esc |
4049 | { scrollBar_esc, PrivMode_scrollBar }, |
4029 | { scrollBar_esc, PrivMode_scrollBar }, |
4050 | #endif |
4030 | #endif |
… | |
… | |
4097 | /* extra handling for values with state unkept */ |
4077 | /* extra handling for values with state unkept */ |
4098 | switch (arg[i]) |
4078 | switch (arg[i]) |
4099 | { |
4079 | { |
4100 | #if ENABLE_STYLES |
4080 | #if ENABLE_STYLES |
4101 | case 1021: |
4081 | case 1021: |
4102 | if (mode) |
4082 | set_option (Opt_intensityStyles, mode); |
4103 | SET_OPTION (Opt_intensityStyles); |
|
|
4104 | else |
|
|
4105 | CLR_OPTION (Opt_intensityStyles); |
|
|
4106 | |
4083 | |
4107 | scr_touch (true); |
4084 | scr_touch (true); |
4108 | break; |
4085 | break; |
4109 | #endif |
4086 | #endif |
4110 | case 1048: /* alternative cursor save */ |
4087 | case 1048: /* alternative cursor save */ |
… | |
… | |
4132 | case 3: /* 80/132 */ |
4109 | case 3: /* 80/132 */ |
4133 | if (priv_modes & PrivMode_132OK) |
4110 | if (priv_modes & PrivMode_132OK) |
4134 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4111 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4135 | break; |
4112 | break; |
4136 | case 4: /* smooth scrolling */ |
4113 | case 4: /* smooth scrolling */ |
4137 | if (!state) |
4114 | set_option (Opt_jumpScroll, !state); |
4138 | SET_OPTION (Opt_jumpScroll); |
|
|
4139 | else |
|
|
4140 | CLR_OPTION (Opt_jumpScroll); |
|
|
4141 | break; |
4115 | break; |
4142 | case 5: /* reverse video */ |
4116 | case 5: /* reverse video */ |
4143 | scr_rvideo_mode (state); |
4117 | scr_rvideo_mode (state); |
4144 | break; |
4118 | break; |
4145 | case 6: /* relative/absolute origins */ |
4119 | case 6: /* relative/absolute origins */ |
… | |
… | |
4151 | /* case 8: - auto repeat, can't do on a per window basis */ |
4125 | /* case 8: - auto repeat, can't do on a per window basis */ |
4152 | case 9: /* X10 mouse reporting */ |
4126 | case 9: /* X10 mouse reporting */ |
4153 | if (state) /* orthogonal */ |
4127 | if (state) /* orthogonal */ |
4154 | priv_modes &= ~PrivMode_MouseX11; |
4128 | priv_modes &= ~PrivMode_MouseX11; |
4155 | break; |
4129 | break; |
4156 | #ifdef menuBar_esc |
|
|
4157 | case menuBar_esc: |
|
|
4158 | #ifdef MENUBAR |
|
|
4159 | map_menuBar (state); |
|
|
4160 | #endif |
|
|
4161 | break; |
|
|
4162 | #endif |
|
|
4163 | #ifdef scrollBar_esc |
4130 | #ifdef scrollBar_esc |
4164 | case scrollBar_esc: |
4131 | case scrollBar_esc: |
4165 | if (scrollbar_mapping (state)) |
4132 | if (scrollbar_mapping (state)) |
4166 | { |
4133 | { |
4167 | resize_all_windows (0, 0, 0); |
4134 | resize_all_windows (0, 0, 0); |
… | |
… | |
4186 | #if 0 |
4153 | #if 0 |
4187 | case 1001: |
4154 | case 1001: |
4188 | break; /* X11 mouse highlighting */ |
4155 | break; /* X11 mouse highlighting */ |
4189 | #endif |
4156 | #endif |
4190 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4157 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4191 | if (!state) |
4158 | set_option (Opt_scrollTtyOutput, !state); |
4192 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4193 | else |
|
|
4194 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4195 | break; |
4159 | break; |
4196 | case 1011: /* scroll to bottom on key press */ |
4160 | case 1011: /* scroll to bottom on key press */ |
4197 | if (state) |
4161 | set_option (Opt_scrollTtyKeypress, state); |
4198 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4199 | else |
|
|
4200 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4201 | break; |
4162 | break; |
4202 | case 1047: /* secondary screen w/ clearing last */ |
4163 | case 1047: /* secondary screen w/ clearing last */ |
4203 | if (OPTION (Opt_secondaryScreen)) |
4164 | if (OPTION (Opt_secondaryScreen)) |
4204 | if (current_screen != PRIMARY) |
4165 | if (current_screen != PRIMARY) |
4205 | scr_erase_screen (2); |
4166 | scr_erase_screen (2); |
… | |
… | |
4415 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4376 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4416 | |
4377 | |
4417 | void |
4378 | void |
4418 | rxvt_term::tt_write (const char *data, unsigned int len) |
4379 | rxvt_term::tt_write (const char *data, unsigned int len) |
4419 | { |
4380 | { |
|
|
4381 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
4382 | return; |
|
|
4383 | |
|
|
4384 | if (pty->pty < 0) |
|
|
4385 | return; |
|
|
4386 | |
4420 | if (v_buflen == 0) |
4387 | if (v_buflen == 0) |
4421 | { |
4388 | { |
4422 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4389 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4423 | |
4390 | |
4424 | if ((unsigned int)written == len) |
4391 | if ((unsigned int)written == len) |
4425 | return; |
4392 | return; |
4426 | |
4393 | |
4427 | data += written; |
4394 | data += written; |
… | |
… | |
4436 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4403 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4437 | } |
4404 | } |
4438 | |
4405 | |
4439 | void rxvt_term::pty_write () |
4406 | void rxvt_term::pty_write () |
4440 | { |
4407 | { |
4441 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4408 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4442 | |
4409 | |
4443 | if (written > 0) |
4410 | if (written > 0) |
4444 | { |
4411 | { |
4445 | v_buflen -= written; |
4412 | v_buflen -= written; |
4446 | |
4413 | |