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> |
… | |
… | |
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. |
… | |
… | |
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 | # include <sched.h> |
|
|
56 | #endif |
|
|
57 | |
|
|
58 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
59 | # include "keyboard.h" |
55 | # include "keyboard.h" |
60 | #endif |
56 | #endif |
61 | |
57 | |
62 | #include <csignal> |
58 | #include <csignal> |
63 | |
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
|
|
63 | |
64 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
65 | |
65 | |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | |
|
|
68 | // exception thrown when the command parser runs out of input data |
|
|
69 | class out_of_input { } out_of_input; |
|
|
70 | |
67 | |
71 | #if ENABLE_FRILLS || ISO_14755 |
68 | #if ENABLE_FRILLS || ISO_14755 |
72 | |
69 | |
73 | #define ISO_14755_STARTED 0x80000000UL |
70 | #define ISO_14755_STARTED 0x80000000UL |
74 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
71 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
146 | || !IN_RANGE_EXC (y, 0, nrow)) |
143 | || !IN_RANGE_EXC (y, 0, nrow)) |
147 | return; |
144 | return; |
148 | |
145 | |
149 | for (;;) |
146 | for (;;) |
150 | { |
147 | { |
151 | const line_t &l = ROW(y - view_start); |
148 | const line_t &l = ROW(y + view_start); |
152 | |
149 | |
153 | text_t t = l.t[x]; |
150 | text_t t = l.t[x]; |
154 | |
151 | |
155 | if (t != NOCHAR || !x) |
152 | if (t != NOCHAR || !x) |
156 | { |
153 | { |
… | |
… | |
229 | # if !UNICODE3 |
226 | # if !UNICODE3 |
230 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
231 | ch = 0xfffd; |
228 | ch = 0xfffd; |
232 | # endif |
229 | # endif |
233 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
|
|
231 | |
|
|
232 | if (WCWIDTH (ch) >= 2) |
234 | scr_overlay_set (12, y, NOCHAR, r); |
233 | scr_overlay_set (12, y, NOCHAR, r); |
235 | } |
234 | } |
236 | |
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 | // } |
237 | scr_overlay_set (0, len , attr); |
241 | scr_overlay_set (0, len , attr); |
238 | scr_overlay_set (0, len + 1, fname); |
242 | scr_overlay_set (0, len + 1, fname); |
239 | |
243 | |
240 | free (fname); |
244 | free (fname); |
241 | |
245 | |
… | |
… | |
267 | mb[0] = ch[0]; |
271 | mb[0] = ch[0]; |
268 | len = 1; |
272 | len = 1; |
269 | } |
273 | } |
270 | |
274 | |
271 | if (len > 0) |
275 | if (len > 0) |
272 | tt_write ((unsigned char *)mb, len); |
276 | tt_write (mb, len); |
273 | else |
277 | else |
274 | scr_bell (); |
278 | scr_bell (); |
275 | } |
279 | } |
276 | |
280 | |
277 | iso14755buf = 0; |
281 | iso14755buf = 0; |
… | |
… | |
294 | |
298 | |
295 | return -1; |
299 | return -1; |
296 | } |
300 | } |
297 | #endif |
301 | #endif |
298 | |
302 | |
299 | /*{{{ Convert the keypress event into a string */ |
|
|
300 | void |
303 | void |
301 | rxvt_term::lookup_key (XKeyEvent &ev) |
304 | rxvt_term::key_press (XKeyEvent &ev) |
302 | { |
305 | { |
303 | int ctrl, meta, shft, len; |
306 | int ctrl, meta, shft, len; |
304 | unsigned int newlen; |
307 | unsigned int newlen; |
305 | KeySym keysym; |
308 | KeySym keysym; |
306 | #ifdef DEBUG_CMD |
|
|
307 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
308 | #endif |
|
|
309 | int valid_keysym; |
309 | int valid_keysym; |
310 | unsigned char kbuf[KBUFSZ]; |
310 | char kbuf[KBUFSZ]; |
|
|
311 | |
|
|
312 | #if ISO_14755 |
|
|
313 | if (iso14755buf & ISO_14755_52) |
|
|
314 | return; |
|
|
315 | #endif |
311 | |
316 | |
312 | /* |
317 | /* |
313 | * 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 |
314 | * escape sequence to toggle the Keypad. |
319 | * escape sequence to toggle the Keypad. |
315 | * |
320 | * |
… | |
… | |
333 | Status status_return; |
338 | Status status_return; |
334 | |
339 | |
335 | #if 0 |
340 | #if 0 |
336 | #ifdef X_HAVE_UTF8_STRING |
341 | #ifdef X_HAVE_UTF8_STRING |
337 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
342 | if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful |
338 | len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, |
343 | len = Xutf8LookupString (Input_Context, &ev, kbuf, |
339 | KBUFSZ, &keysym, &status_return); |
344 | KBUFSZ, &keysym, &status_return); |
340 | else |
345 | else |
341 | #endif |
346 | #endif |
342 | #endif |
347 | #endif |
343 | { |
348 | { |
… | |
… | |
380 | || status_return == XLookupBoth; |
385 | || status_return == XLookupBoth; |
381 | } |
386 | } |
382 | else |
387 | else |
383 | #endif |
388 | #endif |
384 | { |
389 | { |
385 | len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); |
390 | len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); |
386 | valid_keysym = keysym != NoSymbol; |
391 | valid_keysym = keysym != NoSymbol; |
387 | } |
392 | } |
388 | |
393 | |
389 | if (valid_keysym) |
394 | if (valid_keysym) |
390 | { |
395 | { |
… | |
… | |
442 | scr_move_to (0, 1); |
447 | scr_move_to (0, 1); |
443 | return; |
448 | return; |
444 | } |
449 | } |
445 | else if (keysym == XK_End) |
450 | else if (keysym == XK_End) |
446 | { |
451 | { |
447 | scr_move_to (1, 0); |
452 | scr_move_to (1, 1); |
448 | return; |
453 | return; |
449 | } |
454 | } |
450 | } |
455 | } |
451 | #endif |
456 | #endif |
452 | } |
457 | } |
… | |
… | |
463 | { |
468 | { |
464 | switch (keysym) |
469 | switch (keysym) |
465 | { |
470 | { |
466 | /* normal XTerm key bindings */ |
471 | /* normal XTerm key bindings */ |
467 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
472 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
468 | selection_request (ev.time, 0, 0); |
473 | selection_request (ev.time); |
469 | return; |
474 | return; |
470 | #if TODO |
475 | #if TODO |
471 | /* rxvt extras */ |
476 | /* rxvt extras */ |
472 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
477 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
473 | change_font (FONT_UP); |
478 | change_font (FONT_UP); |
… | |
… | |
492 | { |
497 | { |
493 | commit_iso14755 (); |
498 | commit_iso14755 (); |
494 | iso14755buf = ISO_14755_51; |
499 | iso14755buf = ISO_14755_51; |
495 | # if ISO_14755 |
500 | # if ISO_14755 |
496 | 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); |
497 | # endif |
510 | # endif |
498 | return; |
511 | return; |
499 | } |
512 | } |
500 | else if ((hv = hex_keyval (ev)) >= 0) |
513 | else if ((hv = hex_keyval (ev)) >= 0) |
501 | { |
514 | { |
… | |
… | |
523 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
536 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
524 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
537 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
525 | # endif |
538 | # endif |
526 | } |
539 | } |
527 | #endif |
540 | #endif |
528 | |
541 | |
529 | #ifdef PRINTPIPE |
542 | #ifdef PRINTPIPE |
530 | if (keysym == XK_Print) |
543 | if (keysym == XK_Print) |
531 | { |
544 | { |
532 | scr_printscreen (ctrl | shft); |
545 | scr_printscreen (ctrl | shft); |
533 | return; |
546 | return; |
… | |
… | |
854 | { |
867 | { |
855 | #ifdef META8_OPTION |
868 | #ifdef META8_OPTION |
856 | /* set 8-bit on */ |
869 | /* set 8-bit on */ |
857 | if (meta && (meta_char == 0x80)) |
870 | if (meta && (meta_char == 0x80)) |
858 | { |
871 | { |
859 | unsigned char *ch; |
872 | char *ch; |
860 | |
873 | |
861 | for (ch = kbuf; ch < kbuf + len; ch++) |
874 | for (ch = kbuf; ch < kbuf + len; ch++) |
862 | *ch |= 0x80; |
875 | *ch |= 0x80; |
863 | |
876 | |
864 | meta = 0; |
877 | meta = 0; |
… | |
… | |
866 | #endif |
879 | #endif |
867 | /* nil */ ; |
880 | /* nil */ ; |
868 | } |
881 | } |
869 | } |
882 | } |
870 | |
883 | |
|
|
884 | if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) |
|
|
885 | return; |
|
|
886 | |
871 | if (len <= 0) |
887 | if (len <= 0) |
872 | return; /* not mapped */ |
888 | return; /* not mapped */ |
873 | |
889 | |
874 | if (OPTION (Opt_scrollTtyKeypress)) |
890 | if (option (Opt_scrollTtyKeypress)) |
875 | if (view_start) |
891 | if (view_start) |
876 | { |
892 | { |
877 | view_start = 0; |
893 | view_start = 0; |
878 | want_refresh = 1; |
894 | want_refresh = 1; |
879 | } |
895 | } |
… | |
… | |
897 | #ifdef META8_OPTION |
913 | #ifdef META8_OPTION |
898 | && meta_char == C0_ESC |
914 | && meta_char == C0_ESC |
899 | #endif |
915 | #endif |
900 | ) |
916 | ) |
901 | { |
917 | { |
902 | const unsigned char ch = C0_ESC; |
918 | const char ch = C0_ESC; |
903 | tt_write (&ch, 1); |
919 | tt_write (&ch, 1); |
904 | } |
920 | } |
905 | |
921 | |
906 | #if defined(DEBUG_CMD) |
|
|
907 | /* Display keyboard buffer contents */ |
|
|
908 | unsigned char *p; |
|
|
909 | int i; |
|
|
910 | |
|
|
911 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
912 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
913 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
914 | fprintf (stderr, "'\n"); |
|
|
915 | #endif /* DEBUG_CMD */ |
|
|
916 | tt_write (kbuf, (unsigned int)len); |
922 | tt_write (kbuf, (unsigned int)len); |
917 | } |
923 | } |
918 | /*}}} */ |
|
|
919 | |
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 | |
920 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
1002 | #if defined (KEYSYM_RESOURCE) |
921 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
922 | /* attempt to `write' count to the input buffer */ |
|
|
923 | unsigned int |
1003 | unsigned int |
924 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
1004 | rxvt_term::cmd_write (const char *str, unsigned int count) |
925 | { |
1005 | { |
926 | unsigned int n, s; |
1006 | unsigned int n, s; |
927 | |
1007 | |
928 | n = cmdbuf_ptr - cmdbuf_base; |
1008 | n = cmdbuf_ptr - cmdbuf_base; |
929 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
1009 | s = cmdbuf_base + CBUFSIZ - 1 - cmdbuf_endp; |
… | |
… | |
966 | } |
1046 | } |
967 | #endif |
1047 | #endif |
968 | |
1048 | |
969 | if (want_refresh) |
1049 | if (want_refresh) |
970 | { |
1050 | { |
|
|
1051 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
|
|
1052 | { |
|
|
1053 | int row = view_start; |
|
|
1054 | int end_row = row + nrow; |
|
|
1055 | |
|
|
1056 | while (row > top_row && ROW (row - 1).is_longer ()) |
|
|
1057 | --row; |
|
|
1058 | |
|
|
1059 | do |
|
|
1060 | { |
|
|
1061 | int start_row = row; |
|
|
1062 | line_t *l; |
|
|
1063 | |
|
|
1064 | do |
|
|
1065 | { |
|
|
1066 | l = &ROW (row++); |
|
|
1067 | |
|
|
1068 | if (!(l->f & LINE_FILTERED)) |
|
|
1069 | { |
|
|
1070 | // line not filtered, mark it as filtered |
|
|
1071 | l->f |= LINE_FILTERED; |
|
|
1072 | while (l->is_longer ()) |
|
|
1073 | { |
|
|
1074 | l = &ROW (row++); |
|
|
1075 | l->f |= LINE_FILTERED; |
|
|
1076 | } |
|
|
1077 | |
|
|
1078 | // and filter it |
|
|
1079 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
|
|
1080 | |
|
|
1081 | break; |
|
|
1082 | } |
|
|
1083 | } |
|
|
1084 | while (l->is_longer () && row < end_row); |
|
|
1085 | } |
|
|
1086 | while (row < end_row); |
|
|
1087 | } |
|
|
1088 | |
971 | scr_refresh (refresh_type); |
1089 | scr_refresh (); |
972 | scrollbar_show (1); |
1090 | scrollbar_show (1); |
973 | #ifdef USE_XIM |
1091 | #ifdef USE_XIM |
974 | IMSendSpot (); |
1092 | IMSendSpot (); |
975 | #endif |
1093 | #endif |
976 | } |
1094 | } |
… | |
… | |
979 | } |
1097 | } |
980 | |
1098 | |
981 | void |
1099 | void |
982 | rxvt_term::check_cb (check_watcher &w) |
1100 | rxvt_term::check_cb (check_watcher &w) |
983 | { |
1101 | { |
984 | SET_R (this); |
1102 | make_current (); |
985 | SET_LOCALE (locale); |
|
|
986 | |
1103 | |
987 | display->flush (); |
1104 | display->flush (); |
988 | |
1105 | |
989 | if (want_refresh && !flush_ev.active) |
1106 | if (want_refresh && !flush_ev.active) |
990 | 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 |
991 | } |
1108 | } |
992 | |
1109 | |
993 | void |
1110 | void |
994 | rxvt_term::flush_cb (time_watcher &w) |
1111 | rxvt_term::flush_cb (time_watcher &w) |
995 | { |
1112 | { |
996 | SET_R (this); |
1113 | make_current (); |
997 | SET_LOCALE (locale); |
|
|
998 | |
1114 | |
999 | refresh_limit = 1; |
1115 | refresh_limit = 1; |
1000 | refresh_count = 0; |
1116 | refresh_count = 0; |
1001 | flush (); |
1117 | flush (); |
1002 | } |
1118 | } |
… | |
… | |
1006 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1122 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1007 | { |
1123 | { |
1008 | hidden_cursor = !hidden_cursor; |
1124 | hidden_cursor = !hidden_cursor; |
1009 | want_refresh = 1; |
1125 | want_refresh = 1; |
1010 | |
1126 | |
1011 | w.start (w.at + BLINK_INTERVAL); |
1127 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1012 | } |
1128 | } |
1013 | #endif |
1129 | #endif |
1014 | |
1130 | |
1015 | #ifdef TEXT_BLINK |
1131 | #ifdef TEXT_BLINK |
1016 | void |
1132 | void |
… | |
… | |
1030 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1146 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1031 | { |
1147 | { |
1032 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1148 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1033 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1149 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1034 | { |
1150 | { |
1035 | refresh_type |= SMOOTH_REFRESH; |
|
|
1036 | want_refresh = 1; |
1151 | want_refresh = 1; |
1037 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1152 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1038 | } |
1153 | } |
1039 | } |
1154 | } |
1040 | #endif |
1155 | #endif |
… | |
… | |
1044 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1159 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1045 | { |
1160 | { |
1046 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1161 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1047 | { |
1162 | { |
1048 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1163 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1049 | refresh_type |= SMOOTH_REFRESH; |
|
|
1050 | want_refresh = 1; |
1164 | want_refresh = 1; |
1051 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1165 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1052 | } |
1166 | } |
1053 | } |
1167 | } |
1054 | #endif |
1168 | #endif |
… | |
… | |
1059 | { |
1173 | { |
1060 | if (mouse_slip_wheel_speed == 0 |
1174 | if (mouse_slip_wheel_speed == 0 |
1061 | || 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) |
1062 | : scr_page (UP, mouse_slip_wheel_speed)) |
1176 | : scr_page (UP, mouse_slip_wheel_speed)) |
1063 | { |
1177 | { |
1064 | if (view_start == nsaved || |
1178 | if (view_start == top_row || view_start == 0) |
1065 | view_start == 0) |
|
|
1066 | mouse_slip_wheel_speed = 0; |
1179 | mouse_slip_wheel_speed = 0; |
1067 | |
1180 | |
1068 | refresh_type |= SMOOTH_REFRESH; |
|
|
1069 | want_refresh = 1; |
1181 | want_refresh = 1; |
1070 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1182 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1071 | } |
1183 | } |
1072 | } |
1184 | } |
1073 | #endif |
1185 | #endif |
1074 | |
1186 | |
1075 | #if HAVE_SCHED_YIELD |
1187 | #if LINUX_YIELD_HACK |
1076 | static struct event_handler |
1188 | static struct event_handler |
1077 | { |
1189 | { |
1078 | check_watcher cw_yield; |
1190 | check_watcher yield_ev; |
1079 | |
1191 | |
1080 | void yield (check_watcher &w) |
1192 | void yield_cb (check_watcher &w) |
1081 | { |
1193 | { |
1082 | 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 | |
1083 | w.stop (); |
1202 | w.stop (); |
1084 | } |
1203 | } |
1085 | |
1204 | |
1086 | event_handler () |
1205 | event_handler () |
1087 | : cw_yield (this, &event_handler::yield) |
1206 | : yield_ev (this, &event_handler::yield_cb) |
1088 | { |
1207 | { |
1089 | } |
1208 | } |
1090 | } event_handler; |
1209 | } event_handler; |
1091 | #endif |
1210 | #endif |
1092 | |
1211 | |
… | |
… | |
1095 | { |
1214 | { |
1096 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1215 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
1097 | |
1216 | |
1098 | if (CBUFSIZ == n) |
1217 | if (CBUFSIZ == n) |
1099 | { |
1218 | { |
1100 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
1219 | rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); |
1101 | n = 0; |
1220 | n = 0; |
1102 | } |
1221 | } |
1103 | |
1222 | |
1104 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1223 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1105 | cmdbuf_ptr = cmdbuf_base; |
1224 | cmdbuf_ptr = cmdbuf_base; |
1106 | cmdbuf_endp = cmdbuf_ptr + n; |
1225 | cmdbuf_endp = cmdbuf_ptr + n; |
1107 | |
1226 | |
1108 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1227 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1109 | |
1228 | |
1110 | if (r > 0) |
1229 | if (r > 0) |
1111 | { |
1230 | { |
1112 | cmdbuf_endp += r; |
1231 | cmdbuf_endp += r; |
1113 | return true; |
1232 | return true; |
1114 | } |
1233 | } |
1115 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1234 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1116 | { |
1235 | { |
1117 | #if HAVE_SCHED_YIELD |
1236 | #if LINUX_YIELD_HACK |
|
|
1237 | if (display->is_local) |
1118 | event_handler.cw_yield.start (); |
1238 | event_handler.yield_ev.start (); |
1119 | #endif |
1239 | #endif |
1120 | } |
1240 | } |
1121 | else |
1241 | else |
1122 | { |
1242 | { |
1123 | pty_ev.stop (); |
1243 | pty_ev.stop (); |
1124 | |
1244 | |
1125 | if (!OPTION (Opt_hold)) |
1245 | if (!option (Opt_hold)) |
1126 | destroy (); |
1246 | destroy (); |
1127 | } |
1247 | } |
1128 | |
1248 | |
1129 | return false; |
1249 | return false; |
1130 | } |
1250 | } |
1131 | |
1251 | |
1132 | void |
1252 | void |
1133 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1253 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1134 | { |
1254 | { |
1135 | SET_R (this); |
1255 | make_current (); |
1136 | SET_LOCALE (locale); |
|
|
1137 | |
1256 | |
1138 | if (revents & EVENT_READ) |
1257 | if (revents & EVENT_READ) |
1139 | // loop, but don't allow a single term to monopolize us |
1258 | // loop, but don't allow a single term to monopolize us |
1140 | while (pty_fill ()) |
1259 | while (pty_fill ()) |
1141 | if (cmd_parse ()) |
1260 | if (cmd_parse ()) |
… | |
… | |
1146 | } |
1265 | } |
1147 | |
1266 | |
1148 | void |
1267 | void |
1149 | rxvt_term::pointer_unblank () |
1268 | rxvt_term::pointer_unblank () |
1150 | { |
1269 | { |
1151 | XDefineCursor (display->display, vt, TermWin_cursor); |
1270 | XDefineCursor (dpy, vt, TermWin_cursor); |
1152 | recolour_cursor (); |
1271 | recolour_cursor (); |
1153 | |
1272 | |
1154 | #ifdef POINTER_BLANK |
1273 | #ifdef POINTER_BLANK |
1155 | hidden_pointer = 0; |
1274 | hidden_pointer = 0; |
1156 | |
1275 | |
1157 | if (OPTION (Opt_pointerBlank)) |
1276 | if (option (Opt_pointerBlank)) |
1158 | pointer_ev.start (NOW + pointerBlankDelay); |
1277 | pointer_ev.start (NOW + pointerBlankDelay); |
1159 | #endif |
1278 | #endif |
1160 | } |
1279 | } |
1161 | |
1280 | |
1162 | #ifdef POINTER_BLANK |
1281 | #ifdef POINTER_BLANK |
1163 | void |
1282 | void |
1164 | rxvt_term::pointer_blank () |
1283 | rxvt_term::pointer_blank () |
1165 | { |
1284 | { |
1166 | if (! OPTION (Opt_pointerBlank)) |
1285 | if (!option (Opt_pointerBlank)) |
1167 | return; |
1286 | return; |
1168 | |
1287 | |
1169 | XDefineCursor (display->display, vt, display->blank_cursor); |
1288 | XDefineCursor (dpy, vt, display->blank_cursor); |
1170 | XFlush (display->display); |
1289 | XFlush (dpy); |
1171 | |
1290 | |
1172 | hidden_pointer = 1; |
1291 | hidden_pointer = 1; |
1173 | } |
1292 | } |
1174 | |
1293 | |
1175 | void |
1294 | void |
1176 | rxvt_term::pointer_cb (time_watcher &w) |
1295 | rxvt_term::pointer_cb (time_watcher &w) |
1177 | { |
1296 | { |
1178 | SET_R (this); |
1297 | make_current (); |
1179 | SET_LOCALE (locale); |
|
|
1180 | |
1298 | |
1181 | pointer_blank (); |
1299 | pointer_blank (); |
1182 | } |
1300 | } |
1183 | #endif |
1301 | #endif |
1184 | |
1302 | |
… | |
… | |
1249 | (32 + button_number + key_state), |
1367 | (32 + button_number + key_state), |
1250 | (32 + x + 1), |
1368 | (32 + x + 1), |
1251 | (32 + y + 1)); |
1369 | (32 + y + 1)); |
1252 | } |
1370 | } |
1253 | |
1371 | |
1254 | #ifdef USING_W11LIB |
|
|
1255 | void |
|
|
1256 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1257 | { |
|
|
1258 | rxvt_t *r = rxvt_get_r (); |
|
|
1259 | |
|
|
1260 | x_cb (*ev); |
|
|
1261 | } |
|
|
1262 | #endif |
|
|
1263 | |
|
|
1264 | /*{{{ process an X event */ |
1372 | /*{{{ process an X event */ |
1265 | void |
1373 | void |
1266 | rxvt_term::x_cb (XEvent &ev) |
1374 | rxvt_term::x_cb (XEvent &ev) |
1267 | { |
1375 | { |
1268 | dDisp; |
1376 | make_current (); |
1269 | |
1377 | |
1270 | SET_R (this); |
1378 | dLocal (Display *, dpy); |
1271 | SET_LOCALE (locale); |
|
|
1272 | |
1379 | |
1273 | #if defined(CURSOR_BLINK) |
1380 | if (ev.xany.window == vt |
1274 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1381 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1275 | { |
1382 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1276 | if (hidden_cursor) |
1383 | return; |
1277 | { |
|
|
1278 | hidden_cursor = 0; |
|
|
1279 | want_refresh = 1; |
|
|
1280 | } |
|
|
1281 | |
1384 | |
1282 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1385 | // for XQueryPointer |
1283 | } |
|
|
1284 | #endif |
|
|
1285 | |
|
|
1286 | #if defined(POINTER_BLANK) |
|
|
1287 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1288 | { |
|
|
1289 | if (ev.type == MotionNotify |
|
|
1290 | || ev.type == ButtonPress |
|
|
1291 | || ev.type == ButtonRelease) |
|
|
1292 | if (hidden_pointer) |
|
|
1293 | pointer_unblank (); |
|
|
1294 | |
|
|
1295 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1296 | pointer_blank (); |
|
|
1297 | } |
|
|
1298 | #endif |
|
|
1299 | |
|
|
1300 | Window unused_root, unused_child; |
1386 | Window unused_root, unused_child; |
1301 | int unused_root_x, unused_root_y; |
1387 | int unused_root_x, unused_root_y; |
1302 | unsigned int unused_mask; |
1388 | unsigned int unused_mask; |
1303 | |
1389 | |
1304 | switch (ev.type) |
1390 | switch (ev.type) |
1305 | { |
1391 | { |
1306 | case KeyPress: |
1392 | case KeyPress: |
1307 | #if ISO_14755 |
1393 | key_press (ev.xkey); |
1308 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1309 | #endif |
|
|
1310 | lookup_key (ev.xkey); |
|
|
1311 | |
|
|
1312 | break; |
1394 | break; |
1313 | |
1395 | |
1314 | case KeyRelease: |
1396 | case KeyRelease: |
1315 | { |
1397 | key_release (ev.xkey); |
1316 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
|
|
1317 | KeySym ks; |
|
|
1318 | |
|
|
1319 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1320 | #endif |
|
|
1321 | |
|
|
1322 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1323 | // ISO 14755 support |
|
|
1324 | if (iso14755buf) |
|
|
1325 | if (iso14755buf & ISO_14755_52) |
|
|
1326 | { |
|
|
1327 | # if ENABLE_OVERLAY |
|
|
1328 | scr_overlay_off (); |
|
|
1329 | # endif |
|
|
1330 | # if ISO_14755 |
|
|
1331 | // iso14755 part 5.2 handling: release time |
|
|
1332 | // first: controls |
|
|
1333 | if ((ev.xkey.state & ControlMask) |
|
|
1334 | && ((ks >= 0x40 && ks <= 0x5f) |
|
|
1335 | || (ks >= 0x61 && ks <= 0x7f))) |
|
|
1336 | { |
|
|
1337 | iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); |
|
|
1338 | commit_iso14755 (); |
|
|
1339 | return; // case-break; |
|
|
1340 | } |
|
|
1341 | |
|
|
1342 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1343 | if (i[0] == ks) |
|
|
1344 | { |
|
|
1345 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1346 | commit_iso14755 (); |
|
|
1347 | return; // case-break; |
|
|
1348 | } |
|
|
1349 | |
|
|
1350 | scr_bell (); |
|
|
1351 | # endif |
|
|
1352 | iso14755buf = 0; |
|
|
1353 | break; |
|
|
1354 | } |
|
|
1355 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1356 | { |
|
|
1357 | # if ENABLE_OVERLAY |
|
|
1358 | scr_overlay_off (); |
|
|
1359 | # endif |
|
|
1360 | if (iso14755buf & ISO_14755_51) |
|
|
1361 | commit_iso14755 (); |
|
|
1362 | #if ISO_14755 |
|
|
1363 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1364 | { |
|
|
1365 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1366 | |
|
|
1367 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1368 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1369 | } |
|
|
1370 | # endif |
|
|
1371 | else |
|
|
1372 | iso14755buf = 0; |
|
|
1373 | } |
|
|
1374 | #endif |
|
|
1375 | |
|
|
1376 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1377 | if (!(ev.xkey.state & ControlMask)) |
|
|
1378 | slip_wheel_ev.stop (); |
|
|
1379 | else if (ks == XK_Control_L || ks == XK_Control_R) |
|
|
1380 | mouse_slip_wheel_speed = 0; |
|
|
1381 | #endif |
|
|
1382 | break; |
1398 | break; |
1383 | } |
|
|
1384 | |
1399 | |
1385 | case ButtonPress: |
1400 | case ButtonPress: |
1386 | button_press (ev.xbutton); |
1401 | button_press (ev.xbutton); |
1387 | break; |
1402 | break; |
1388 | |
1403 | |
… | |
… | |
1390 | button_release (ev.xbutton); |
1405 | button_release (ev.xbutton); |
1391 | break; |
1406 | break; |
1392 | |
1407 | |
1393 | case ClientMessage: |
1408 | case ClientMessage: |
1394 | if (ev.xclient.format == 32 |
1409 | if (ev.xclient.format == 32 |
1395 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1410 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1396 | { |
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 | { |
1397 | 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))) |
1398 | destroy (); |
1419 | destroy (); |
|
|
1420 | } |
1399 | #if ENABLE_EWMH |
1421 | #if ENABLE_EWMH |
1400 | 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]) |
1401 | XSendEvent (disp, ev.xclient.window = display->root, |
1423 | XSendEvent (dpy, ev.xclient.window = display->root, |
1402 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1424 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1403 | &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 | } |
1404 | #endif |
1437 | #endif |
1405 | } |
1438 | } |
1406 | #if ENABLE_XEMBED |
|
|
1407 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1408 | { |
|
|
1409 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1410 | focus_in (); |
|
|
1411 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1412 | focus_out (); |
|
|
1413 | } |
|
|
1414 | #endif |
|
|
1415 | #ifdef OFFIX_DND |
|
|
1416 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1417 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1418 | && (ev.xclient.data.l[0] == DndFile |
|
|
1419 | || ev.xclient.data.l[0] == DndDir |
|
|
1420 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1421 | { |
|
|
1422 | /* Get Dnd data */ |
|
|
1423 | Atom ActualType; |
|
|
1424 | int ActualFormat; |
|
|
1425 | unsigned char *data; |
|
|
1426 | unsigned long Size, RemainingBytes; |
|
|
1427 | |
|
|
1428 | XGetWindowProperty (disp, display->root, |
|
|
1429 | xa[XA_DNDSELECTION], |
|
|
1430 | 0L, 1000000L, |
|
|
1431 | False, AnyPropertyType, |
|
|
1432 | &ActualType, &ActualFormat, |
|
|
1433 | &Size, &RemainingBytes, |
|
|
1434 | &data); |
|
|
1435 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1436 | XFree (data); |
|
|
1437 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1438 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1439 | } |
|
|
1440 | #endif /* OFFIX_DND */ |
|
|
1441 | break; |
1439 | break; |
1442 | |
1440 | |
1443 | case MappingNotify: |
1441 | case MappingNotify: |
1444 | XRefreshKeyboardMapping (&ev.xmapping); |
1442 | XRefreshKeyboardMapping (&ev.xmapping); |
1445 | break; |
1443 | break; |
… | |
… | |
1468 | break; |
1466 | break; |
1469 | } |
1467 | } |
1470 | break; |
1468 | break; |
1471 | |
1469 | |
1472 | case FocusIn: |
1470 | case FocusIn: |
|
|
1471 | if (ev.xfocus.detail != NotifyInferior |
|
|
1472 | && ev.xfocus.detail != NotifyPointer |
|
|
1473 | && ev.xfocus.mode != NotifyGrab) |
1473 | focus_in (); |
1474 | focus_in (); |
1474 | break; |
1475 | break; |
1475 | |
1476 | |
1476 | case FocusOut: |
1477 | case FocusOut: |
|
|
1478 | if (ev.xfocus.detail != NotifyInferior |
|
|
1479 | && ev.xfocus.detail != NotifyPointer |
|
|
1480 | && ev.xfocus.mode != NotifyGrab) |
1477 | focus_out (); |
1481 | focus_out (); |
1478 | break; |
1482 | break; |
1479 | |
1483 | |
1480 | case ConfigureNotify: |
1484 | case ConfigureNotify: |
1481 | if (ev.xconfigure.window == parent[0]) |
1485 | if (ev.xconfigure.window == parent[0]) |
1482 | { |
1486 | { |
1483 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1487 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1484 | ; |
1488 | ; |
1485 | |
1489 | |
1486 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1490 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1487 | { |
1491 | { |
1488 | seen_resize = 1; |
1492 | seen_resize = 1; |
1489 | 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 |
1490 | } |
1501 | } |
1491 | |
1502 | |
1492 | #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 |
1493 | if (OPTION (Opt_transparent)) |
1506 | if (option (Opt_transparent)) |
1494 | check_our_parents (); |
1507 | check_our_parents (); |
1495 | #endif |
1508 | #endif |
1496 | } |
1509 | } |
1497 | break; |
1510 | break; |
1498 | |
1511 | |
1499 | case PropertyNotify: |
1512 | case PropertyNotify: |
|
|
1513 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1500 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1514 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1501 | && ev.xproperty.state == PropertyNewValue) |
1515 | && ev.xproperty.state == PropertyNewValue) |
1502 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1516 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1503 | |
1517 | |
1504 | break; |
1518 | break; |
1505 | |
1519 | |
1506 | case SelectionClear: |
1520 | case SelectionClear: |
1507 | selection_clear (); |
1521 | selection_clear (); |
… | |
… | |
1512 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1526 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1513 | break; |
1527 | break; |
1514 | |
1528 | |
1515 | case SelectionRequest: |
1529 | case SelectionRequest: |
1516 | selection_send (ev.xselectionrequest); |
1530 | selection_send (ev.xselectionrequest); |
|
|
1531 | break; |
|
|
1532 | |
|
|
1533 | case MapNotify: |
|
|
1534 | mapped = 1; |
|
|
1535 | #ifdef TEXT_BLINK |
|
|
1536 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1537 | #endif |
|
|
1538 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1517 | break; |
1539 | break; |
1518 | |
1540 | |
1519 | case UnmapNotify: |
1541 | case UnmapNotify: |
1520 | mapped = 0; |
1542 | mapped = 0; |
1521 | #ifdef TEXT_BLINK |
1543 | #ifdef TEXT_BLINK |
1522 | text_blink_ev.stop (); |
1544 | text_blink_ev.stop (); |
1523 | #endif |
1545 | #endif |
1524 | break; |
1546 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1525 | |
|
|
1526 | case MapNotify: |
|
|
1527 | mapped = 1; |
|
|
1528 | #ifdef TEXT_BLINK |
|
|
1529 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
1530 | #endif |
|
|
1531 | break; |
1547 | break; |
1532 | |
1548 | |
1533 | #ifdef TRANSPARENT |
1549 | #ifdef TRANSPARENT |
1534 | case ReparentNotify: |
1550 | case ReparentNotify: |
1535 | rootwin_cb (ev); |
1551 | rootwin_cb (ev); |
… | |
… | |
1541 | if (ev.xany.window == vt) |
1557 | if (ev.xany.window == vt) |
1542 | { |
1558 | { |
1543 | do |
1559 | do |
1544 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1560 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1545 | ev.xexpose.width, ev.xexpose.height, False); |
1561 | ev.xexpose.width, ev.xexpose.height, False); |
1546 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1562 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1547 | |
1563 | |
1548 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1564 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1549 | |
1565 | |
1550 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1566 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1551 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1567 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1552 | ev.xexpose.width, ev.xexpose.height, False); |
1568 | ev.xexpose.width, ev.xexpose.height, False); |
1553 | |
1569 | |
1554 | scr_refresh (refresh_type); |
1570 | want_refresh = 1; |
1555 | } |
1571 | } |
1556 | else |
1572 | else |
1557 | { |
1573 | { |
1558 | XEvent unused_event; |
1574 | XEvent unused_event; |
1559 | |
1575 | |
1560 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1576 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1561 | ; |
1577 | ; |
1562 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1578 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1563 | ; |
1579 | ; |
1564 | |
1580 | |
1565 | if (isScrollbarWindow (ev.xany.window)) |
1581 | if (isScrollbarWindow (ev.xany.window)) |
1566 | { |
1582 | { |
1567 | scrollBar.setIdle (); |
1583 | scrollBar.setIdle (); |
1568 | scrollbar_show (0); |
1584 | scrollbar_show (0); |
1569 | } |
1585 | } |
1570 | #ifdef MENUBAR |
|
|
1571 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1572 | menubar_expose (); |
|
|
1573 | #endif |
|
|
1574 | |
1586 | |
1575 | #ifdef TRANSPARENT |
1587 | #ifdef TRANSPARENT |
1576 | if (am_transparent && ev.xany.window == parent[0]) |
1588 | if (am_transparent && ev.xany.window == parent[0]) |
1577 | XClearWindow (disp, ev.xany.window); |
1589 | XClearWindow (dpy, ev.xany.window); |
1578 | #endif |
1590 | #endif |
1579 | } |
1591 | } |
1580 | break; |
1592 | break; |
1581 | |
1593 | |
1582 | case MotionNotify: |
1594 | case MotionNotify: |
1583 | #ifdef POINTER_BLANK |
1595 | #ifdef POINTER_BLANK |
1584 | if (hidden_pointer) |
1596 | if (hidden_pointer) |
1585 | pointer_unblank (); |
1597 | pointer_unblank (); |
1586 | #endif |
1598 | #endif |
1587 | #if MENUBAR |
|
|
1588 | if (isMenuBarWindow (ev.xany.window)) |
|
|
1589 | { |
|
|
1590 | menubar_control (ev.xbutton); |
|
|
1591 | break; |
|
|
1592 | } |
|
|
1593 | #endif |
|
|
1594 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1599 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1595 | break; |
1600 | break; |
1596 | |
1601 | |
1597 | if (ev.xany.window == vt) |
1602 | if (ev.xany.window == vt) |
1598 | { |
1603 | { |
|
|
1604 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
|
|
1605 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
|
|
1606 | ; // nop |
1599 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1607 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1600 | { |
1608 | { |
1601 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1609 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1602 | ; |
1610 | ; |
1603 | |
1611 | |
1604 | XQueryPointer (disp, vt, |
1612 | XQueryPointer (dpy, vt, |
1605 | &unused_root, &unused_child, |
1613 | &unused_root, &unused_child, |
1606 | &unused_root_x, &unused_root_y, |
1614 | &unused_root_x, &unused_root_y, |
1607 | &ev.xbutton.x, &ev.xbutton.y, |
1615 | &ev.xbutton.x, &ev.xbutton.y, |
1608 | &ev.xbutton.state); |
1616 | &ev.xbutton.state); |
1609 | #ifdef MOUSE_THRESHOLD |
1617 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1673 | #endif |
1681 | #endif |
1674 | } |
1682 | } |
1675 | } |
1683 | } |
1676 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1684 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1677 | { |
1685 | { |
1678 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1686 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1679 | MotionNotify, &ev)) |
1687 | MotionNotify, &ev)) |
1680 | ; |
1688 | ; |
1681 | |
1689 | |
1682 | XQueryPointer (disp, scrollBar.win, |
1690 | XQueryPointer (dpy, scrollBar.win, |
1683 | &unused_root, &unused_child, |
1691 | &unused_root, &unused_child, |
1684 | &unused_root_x, &unused_root_y, |
1692 | &unused_root_x, &unused_root_y, |
1685 | &ev.xbutton.x, &ev.xbutton.y, |
1693 | &ev.xbutton.x, &ev.xbutton.y, |
1686 | &unused_mask); |
1694 | &unused_mask); |
1687 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1695 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1688 | scrollbar_size ()); |
1696 | scrollbar_size ()); |
1689 | scr_refresh (refresh_type); |
1697 | want_refresh = 1; |
1690 | refresh_limit = 0; |
1698 | refresh_limit = 0; |
1691 | scrollbar_show (1); |
1699 | scrollbar_show (1); |
1692 | } |
1700 | } |
1693 | break; |
1701 | break; |
1694 | } |
1702 | } |
|
|
1703 | |
|
|
1704 | #if defined(CURSOR_BLINK) |
|
|
1705 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
|
|
1706 | { |
|
|
1707 | if (hidden_cursor) |
|
|
1708 | { |
|
|
1709 | hidden_cursor = 0; |
|
|
1710 | want_refresh = 1; |
|
|
1711 | } |
|
|
1712 | |
|
|
1713 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
|
|
1714 | } |
|
|
1715 | #endif |
|
|
1716 | |
|
|
1717 | #if defined(POINTER_BLANK) |
|
|
1718 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
|
|
1719 | { |
|
|
1720 | if (ev.type == MotionNotify |
|
|
1721 | || ev.type == ButtonPress |
|
|
1722 | || ev.type == ButtonRelease) |
|
|
1723 | if (hidden_pointer) |
|
|
1724 | pointer_unblank (); |
|
|
1725 | |
|
|
1726 | if (ev.type == KeyPress && hidden_pointer == 0) |
|
|
1727 | pointer_blank (); |
|
|
1728 | } |
|
|
1729 | #endif |
1695 | } |
1730 | } |
1696 | |
1731 | |
1697 | void |
1732 | void |
1698 | rxvt_term::focus_in () |
1733 | rxvt_term::focus_in () |
1699 | { |
1734 | { |
1700 | if (!focus) |
1735 | if (!focus) |
1701 | { |
1736 | { |
1702 | focus = 1; |
1737 | focus = 1; |
1703 | want_refresh = 1; |
1738 | want_refresh = 1; |
1704 | |
1739 | |
1705 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1740 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1706 | |
1741 | |
1707 | #if USE_XIM |
1742 | #if USE_XIM |
1708 | if (Input_Context != NULL) |
1743 | if (Input_Context != NULL) |
1709 | { |
1744 | { |
1710 | IMSetStatusPosition (); |
1745 | IMSetPosition (); |
1711 | XSetICFocus (Input_Context); |
1746 | XSetICFocus (Input_Context); |
1712 | } |
1747 | } |
1713 | #endif |
1748 | #endif |
1714 | #if CURSOR_BLINK |
1749 | #if CURSOR_BLINK |
1715 | if (OPTION (Opt_cursorBlink)) |
1750 | if (option (Opt_cursorBlink)) |
1716 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1751 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1717 | #endif |
1752 | #endif |
1718 | #if OFF_FOCUS_FADING |
1753 | #if OFF_FOCUS_FADING |
1719 | if (rs[Rs_fade]) |
1754 | if (rs[Rs_fade]) |
1720 | { |
1755 | { |
1721 | pix_colors = pix_colors_focused; |
1756 | pix_colors = pix_colors_focused; |
1722 | scr_recolour (); |
1757 | scr_recolour (); |
1723 | } |
1758 | } |
1724 | #endif |
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 | } |
|
|
1771 | } |
|
|
1772 | #endif |
1725 | } |
1773 | } |
1726 | } |
1774 | } |
1727 | |
1775 | |
1728 | void |
1776 | void |
1729 | rxvt_term::focus_out () |
1777 | rxvt_term::focus_out () |
… | |
… | |
1731 | if (focus) |
1779 | if (focus) |
1732 | { |
1780 | { |
1733 | focus = 0; |
1781 | focus = 0; |
1734 | want_refresh = 1; |
1782 | want_refresh = 1; |
1735 | |
1783 | |
1736 | PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1784 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1737 | |
1785 | |
1738 | #if ENABLE_FRILLS || ISO_14755 |
1786 | #if ENABLE_FRILLS || ISO_14755 |
1739 | if (iso14755buf) |
1787 | if (iso14755buf) |
1740 | { |
1788 | { |
1741 | iso14755buf = 0; |
1789 | iso14755buf = 0; |
… | |
… | |
1747 | #if USE_XIM |
1795 | #if USE_XIM |
1748 | if (Input_Context != NULL) |
1796 | if (Input_Context != NULL) |
1749 | XUnsetICFocus (Input_Context); |
1797 | XUnsetICFocus (Input_Context); |
1750 | #endif |
1798 | #endif |
1751 | #if CURSOR_BLINK |
1799 | #if CURSOR_BLINK |
1752 | if (OPTION (Opt_cursorBlink)) |
1800 | if (option (Opt_cursorBlink)) |
1753 | cursor_blink_ev.stop (); |
1801 | cursor_blink_ev.stop (); |
1754 | hidden_cursor = 0; |
1802 | hidden_cursor = 0; |
1755 | #endif |
1803 | #endif |
1756 | #if OFF_FOCUS_FADING |
1804 | #if OFF_FOCUS_FADING |
1757 | if (rs[Rs_fade]) |
1805 | if (rs[Rs_fade]) |
… | |
… | |
1761 | } |
1809 | } |
1762 | #endif |
1810 | #endif |
1763 | } |
1811 | } |
1764 | } |
1812 | } |
1765 | |
1813 | |
1766 | #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 |
1767 | void |
1828 | void |
1768 | rxvt_term::rootwin_cb (XEvent &ev) |
1829 | rxvt_term::rootwin_cb (XEvent &ev) |
1769 | { |
1830 | { |
1770 | SET_R (this); |
1831 | make_current (); |
1771 | SET_LOCALE (locale); |
|
|
1772 | |
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 |
1773 | switch (ev.type) |
1838 | switch (ev.type) |
1774 | { |
1839 | { |
1775 | case PropertyNotify: |
1840 | case PropertyNotify: |
1776 | /* |
1841 | /* |
1777 | * 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, |
… | |
… | |
1781 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1846 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1782 | return; |
1847 | return; |
1783 | |
1848 | |
1784 | /* FALLTHROUGH */ |
1849 | /* FALLTHROUGH */ |
1785 | case ReparentNotify: |
1850 | case ReparentNotify: |
1786 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
1851 | if (option (Opt_transparent)) |
1787 | want_refresh = want_full_refresh = 1; |
1852 | check_our_parents (); |
1788 | break; |
1853 | break; |
1789 | } |
1854 | } |
|
|
1855 | # endif |
1790 | } |
1856 | } |
1791 | #endif |
1857 | #endif |
1792 | |
1858 | |
1793 | void |
1859 | void |
1794 | rxvt_term::button_press (XButtonEvent &ev) |
1860 | rxvt_term::button_press (XButtonEvent &ev) |
1795 | { |
1861 | { |
1796 | int reportmode = 0, clickintime; |
1862 | int reportmode = 0, clickintime; |
1797 | |
1863 | |
1798 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
1864 | bypass_keystate = ev.state & (ModMetaMask | ShiftMask); |
|
|
1865 | |
1799 | if (!bypass_keystate) |
1866 | if (!bypass_keystate) |
1800 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1867 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
1801 | |
1868 | |
1802 | /* |
1869 | /* |
1803 | * VT window processing of button press |
1870 | * VT window processing of button press |
1804 | */ |
1871 | */ |
1805 | if (ev.window == vt) |
1872 | if (ev.window == vt) |
1806 | { |
1873 | { |
|
|
1874 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1875 | return; |
|
|
1876 | |
1807 | #if ISO_14755 |
1877 | #if ISO_14755 |
1808 | // 5.4 |
1878 | // 5.4 |
1809 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1879 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1810 | { |
1880 | { |
1811 | iso14755_54 (ev.x, ev.y); |
1881 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1823 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1893 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1824 | if (ev.button == MEvent.button && clickintime) |
1894 | if (ev.button == MEvent.button && clickintime) |
1825 | { |
1895 | { |
1826 | /* same button, within alloted time */ |
1896 | /* same button, within alloted time */ |
1827 | MEvent.clicks++; |
1897 | MEvent.clicks++; |
|
|
1898 | |
1828 | if (MEvent.clicks > 1) |
1899 | if (MEvent.clicks > 1) |
1829 | { |
1900 | { |
1830 | /* only report double clicks */ |
1901 | /* only report double clicks */ |
1831 | MEvent.clicks = 2; |
1902 | MEvent.clicks = 2; |
1832 | mouse_report (ev); |
1903 | mouse_report (ev); |
… | |
… | |
1864 | #else |
1935 | #else |
1865 | selection.rect = false; |
1936 | selection.rect = false; |
1866 | #endif |
1937 | #endif |
1867 | |
1938 | |
1868 | /* allow shift+left click to extend selection */ |
1939 | /* allow shift+left click to extend selection */ |
1869 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1940 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1870 | { |
1941 | { |
1871 | if (MEvent.button == Button1 && clickintime) |
1942 | if (MEvent.button == Button1 && clickintime) |
1872 | selection_rotate (ev.x, ev.y); |
1943 | selection_rotate (ev.x, ev.y); |
1873 | else |
1944 | else |
1874 | selection_extend (ev.x, ev.y, 1); |
1945 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
2039 | } |
2110 | } |
2040 | |
2111 | |
2041 | break; |
2112 | break; |
2042 | } |
2113 | } |
2043 | } |
2114 | } |
|
|
2115 | |
2044 | return; |
2116 | return; |
2045 | } |
2117 | } |
2046 | #if MENUBAR |
|
|
2047 | /* |
|
|
2048 | * Menubar window processing of button press |
|
|
2049 | */ |
|
|
2050 | if (isMenuBarWindow (ev.window)) |
|
|
2051 | menubar_control (ev); |
|
|
2052 | #endif |
|
|
2053 | } |
2118 | } |
2054 | |
2119 | |
2055 | void |
2120 | void |
2056 | rxvt_term::button_release (XButtonEvent &ev) |
2121 | rxvt_term::button_release (XButtonEvent &ev) |
2057 | { |
2122 | { |
… | |
… | |
2063 | |
2128 | |
2064 | if (scrollbar_isUpDn ()) |
2129 | if (scrollbar_isUpDn ()) |
2065 | { |
2130 | { |
2066 | scrollBar.setIdle (); |
2131 | scrollBar.setIdle (); |
2067 | scrollbar_show (0); |
2132 | scrollbar_show (0); |
2068 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2069 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2070 | #endif |
|
|
2071 | } |
2133 | } |
2072 | |
2134 | |
2073 | #ifdef SELECTION_SCROLLING |
2135 | #ifdef SELECTION_SCROLLING |
2074 | if (sel_scroll_ev.active) |
2136 | if (sel_scroll_ev.active) |
2075 | sel_scroll_ev.stop(); |
2137 | sel_scroll_ev.stop(); |
2076 | #endif |
2138 | #endif |
2077 | |
2139 | |
2078 | if (ev.window == vt) |
2140 | if (ev.window == vt) |
2079 | { |
2141 | { |
|
|
2142 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2143 | return; |
|
|
2144 | |
2080 | #if ISO_14755 |
2145 | #if ISO_14755 |
2081 | // 5.4 |
2146 | // 5.4 |
2082 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2147 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2083 | return; |
2148 | return; |
2084 | #endif |
2149 | #endif |
|
|
2150 | |
2085 | if (reportmode) |
2151 | if (reportmode) |
2086 | { |
2152 | { |
2087 | /* mouse report from vt window */ |
2153 | /* mouse report from vt window */ |
2088 | /* don't report release of wheel "buttons" */ |
2154 | /* don't report release of wheel "buttons" */ |
2089 | if (ev.button >= 4) |
2155 | if (ev.button >= 4) |
… | |
… | |
2119 | { |
2185 | { |
2120 | case Button1: |
2186 | case Button1: |
2121 | case Button3: |
2187 | case Button3: |
2122 | selection_make (ev.time); |
2188 | selection_make (ev.time); |
2123 | break; |
2189 | break; |
|
|
2190 | |
2124 | case Button2: |
2191 | case Button2: |
2125 | 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); |
2126 | break; |
2194 | break; |
|
|
2195 | |
2127 | #ifdef MOUSE_WHEEL |
2196 | #ifdef MOUSE_WHEEL |
2128 | case Button4: |
2197 | case Button4: |
2129 | case Button5: |
2198 | case Button5: |
2130 | { |
2199 | { |
2131 | int i; |
2200 | int i; |
… | |
… | |
2133 | |
2202 | |
2134 | v = ev.button == Button4 ? UP : DN; |
2203 | v = ev.button == Button4 ? UP : DN; |
2135 | |
2204 | |
2136 | if (ev.state & ShiftMask) |
2205 | if (ev.state & ShiftMask) |
2137 | i = 1; |
2206 | i = 1; |
2138 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2207 | else if (option (Opt_mouseWheelScrollPage)) |
2139 | i = nrow - 1; |
2208 | i = nrow - 1; |
2140 | else |
2209 | else |
2141 | i = 5; |
2210 | i = 5; |
2142 | |
2211 | |
2143 | # ifdef MOUSE_SLIP_WHEELING |
2212 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2153 | slip_wheel_ev.start (); |
2222 | slip_wheel_ev.start (); |
2154 | } |
2223 | } |
2155 | else |
2224 | else |
2156 | { |
2225 | { |
2157 | # endif |
2226 | # endif |
2158 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2159 | scr_page (v, i); |
2227 | scr_page (v, i); |
2160 | scr_refresh (SMOOTH_REFRESH); |
|
|
2161 | scrollbar_show (1); |
2228 | scrollbar_show (1); |
2162 | # else |
|
|
2163 | while (i--) |
|
|
2164 | { |
|
|
2165 | scr_page (v, 1); |
|
|
2166 | scr_refresh (SMOOTH_REFRESH); |
|
|
2167 | scrollbar_show (1); |
|
|
2168 | } |
|
|
2169 | # endif |
|
|
2170 | # ifdef MOUSE_SLIP_WHEELING |
2229 | # ifdef MOUSE_SLIP_WHEELING |
2171 | } |
2230 | } |
2172 | #endif |
2231 | # endif |
2173 | } |
2232 | } |
2174 | break; |
2233 | break; |
2175 | #endif |
2234 | #endif |
2176 | } |
2235 | } |
2177 | } |
2236 | } |
2178 | #ifdef MENUBAR |
|
|
2179 | else if (isMenuBarWindow (ev.window)) |
|
|
2180 | menubar_control (ev); |
|
|
2181 | #endif |
|
|
2182 | } |
2237 | } |
2183 | |
|
|
2184 | #ifdef TRANSPARENT |
|
|
2185 | #if TINTING |
|
|
2186 | /* taken from aterm-0.4.2 */ |
|
|
2187 | |
|
|
2188 | typedef uint32_t RUINT32T; |
|
|
2189 | |
|
|
2190 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2191 | { |
|
|
2192 | int sh_r, sh_g, sh_b; |
|
|
2193 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2194 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2195 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2196 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2197 | int i; |
|
|
2198 | |
|
|
2199 | Visual *visual = display->visual; |
|
|
2200 | |
|
|
2201 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2202 | |
|
|
2203 | /* for convenience */ |
|
|
2204 | mask_r = visual->red_mask; |
|
|
2205 | mask_g = visual->green_mask; |
|
|
2206 | mask_b = visual->blue_mask; |
|
|
2207 | |
|
|
2208 | /* boring lookup table pre-initialization */ |
|
|
2209 | switch (srcImage->bits_per_pixel) { |
|
|
2210 | case 15: |
|
|
2211 | if ((mask_r != 0x7c00) || |
|
|
2212 | (mask_g != 0x03e0) || |
|
|
2213 | (mask_b != 0x001f)) |
|
|
2214 | return; |
|
|
2215 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2216 | lookup_r = lookup; |
|
|
2217 | lookup_g = lookup+32; |
|
|
2218 | lookup_b = lookup+32+32; |
|
|
2219 | sh_r = 10; |
|
|
2220 | sh_g = 5; |
|
|
2221 | sh_b = 0; |
|
|
2222 | break; |
|
|
2223 | case 16: |
|
|
2224 | if ((mask_r != 0xf800) || |
|
|
2225 | (mask_g != 0x07e0) || |
|
|
2226 | (mask_b != 0x001f)) |
|
|
2227 | return; |
|
|
2228 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2229 | lookup_r = lookup; |
|
|
2230 | lookup_g = lookup+32; |
|
|
2231 | lookup_b = lookup+32+64; |
|
|
2232 | sh_r = 11; |
|
|
2233 | sh_g = 5; |
|
|
2234 | sh_b = 0; |
|
|
2235 | break; |
|
|
2236 | case 24: |
|
|
2237 | if ((mask_r != 0xff0000) || |
|
|
2238 | (mask_g != 0x00ff00) || |
|
|
2239 | (mask_b != 0x0000ff)) |
|
|
2240 | return; |
|
|
2241 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2242 | lookup_r = lookup; |
|
|
2243 | lookup_g = lookup+256; |
|
|
2244 | lookup_b = lookup+256+256; |
|
|
2245 | sh_r = 16; |
|
|
2246 | sh_g = 8; |
|
|
2247 | sh_b = 0; |
|
|
2248 | break; |
|
|
2249 | case 32: |
|
|
2250 | if ((mask_r != 0xff0000) || |
|
|
2251 | (mask_g != 0x00ff00) || |
|
|
2252 | (mask_b != 0x0000ff)) |
|
|
2253 | return; |
|
|
2254 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2255 | lookup_r = lookup; |
|
|
2256 | lookup_g = lookup+256; |
|
|
2257 | lookup_b = lookup+256+256; |
|
|
2258 | sh_r = 16; |
|
|
2259 | sh_g = 8; |
|
|
2260 | sh_b = 0; |
|
|
2261 | break; |
|
|
2262 | default: |
|
|
2263 | return; /* we do not support this color depth */ |
|
|
2264 | } |
|
|
2265 | |
|
|
2266 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2267 | if (shade < 0) { |
|
|
2268 | shade = -shade; |
|
|
2269 | if (shade < 0) shade = 0; |
|
|
2270 | if (shade > 100) shade = 100; |
|
|
2271 | |
|
|
2272 | lower_lim_r = 65535-rm; |
|
|
2273 | lower_lim_g = 65535-gm; |
|
|
2274 | lower_lim_b = 65535-bm; |
|
|
2275 | |
|
|
2276 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2277 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2278 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2279 | |
|
|
2280 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2281 | } else { |
|
|
2282 | if (shade < 0) shade = 0; |
|
|
2283 | if (shade > 100) shade = 100; |
|
|
2284 | |
|
|
2285 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2286 | |
|
|
2287 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2288 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2289 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2290 | } |
|
|
2291 | |
|
|
2292 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2293 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2294 | { |
|
|
2295 | unsigned int tmp; |
|
|
2296 | |
|
|
2297 | tmp = lower_lim_r; |
|
|
2298 | lower_lim_r = lower_lim_b; |
|
|
2299 | lower_lim_b = tmp; |
|
|
2300 | |
|
|
2301 | tmp = upper_lim_r; |
|
|
2302 | upper_lim_r = upper_lim_b; |
|
|
2303 | upper_lim_b = tmp; |
|
|
2304 | } |
|
|
2305 | |
|
|
2306 | /* fill our lookup tables */ |
|
|
2307 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2308 | { |
|
|
2309 | RUINT32T tmp; |
|
|
2310 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2311 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2312 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2313 | } |
|
|
2314 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2315 | { |
|
|
2316 | RUINT32T tmp; |
|
|
2317 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2318 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2319 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2320 | } |
|
|
2321 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2322 | { |
|
|
2323 | RUINT32T tmp; |
|
|
2324 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2325 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2326 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2327 | } |
|
|
2328 | |
|
|
2329 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2330 | switch (srcImage->bits_per_pixel) |
|
|
2331 | { |
|
|
2332 | case 15: |
|
|
2333 | { |
|
|
2334 | unsigned short *p1, *pf, *p, *pl; |
|
|
2335 | p1 = (unsigned short *) srcImage->data; |
|
|
2336 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2337 | while (p1 < pf) |
|
|
2338 | { |
|
|
2339 | p = p1; |
|
|
2340 | pl = p1 + srcImage->width; |
|
|
2341 | for (; p < pl; p++) |
|
|
2342 | { |
|
|
2343 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2344 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2345 | lookup_b[(*p & 0x001f)]; |
|
|
2346 | } |
|
|
2347 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2348 | } |
|
|
2349 | break; |
|
|
2350 | } |
|
|
2351 | case 16: |
|
|
2352 | { |
|
|
2353 | unsigned short *p1, *pf, *p, *pl; |
|
|
2354 | p1 = (unsigned short *) srcImage->data; |
|
|
2355 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2356 | while (p1 < pf) |
|
|
2357 | { |
|
|
2358 | p = p1; |
|
|
2359 | pl = p1 + srcImage->width; |
|
|
2360 | for (; p < pl; p++) |
|
|
2361 | { |
|
|
2362 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2363 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2364 | lookup_b[(*p & 0x001f)]; |
|
|
2365 | } |
|
|
2366 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2367 | } |
|
|
2368 | break; |
|
|
2369 | } |
|
|
2370 | case 24: |
|
|
2371 | { |
|
|
2372 | unsigned char *p1, *pf, *p, *pl; |
|
|
2373 | p1 = (unsigned char *) srcImage->data; |
|
|
2374 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2375 | while (p1 < pf) |
|
|
2376 | { |
|
|
2377 | p = p1; |
|
|
2378 | pl = p1 + srcImage->width * 3; |
|
|
2379 | for (; p < pl; p += 3) |
|
|
2380 | { |
|
|
2381 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2382 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2383 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2384 | } |
|
|
2385 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2386 | } |
|
|
2387 | break; |
|
|
2388 | } |
|
|
2389 | case 32: |
|
|
2390 | { |
|
|
2391 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2392 | p1 = (RUINT32T *) srcImage->data; |
|
|
2393 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2394 | |
|
|
2395 | while (p1 < pf) |
|
|
2396 | { |
|
|
2397 | p = p1; |
|
|
2398 | pl = p1 + srcImage->width; |
|
|
2399 | for (; p < pl; p++) |
|
|
2400 | { |
|
|
2401 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2402 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2403 | lookup_b[(*p & 0x0000ff)] | |
|
|
2404 | (*p & ~0xffffff); |
|
|
2405 | } |
|
|
2406 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2407 | } |
|
|
2408 | break; |
|
|
2409 | } |
|
|
2410 | } |
|
|
2411 | |
|
|
2412 | free (lookup); |
|
|
2413 | } |
|
|
2414 | #endif |
|
|
2415 | |
|
|
2416 | /* |
|
|
2417 | * Check our parents are still who we think they are. |
|
|
2418 | * Do transparency updates if required |
|
|
2419 | */ |
|
|
2420 | int |
|
|
2421 | rxvt_term::check_our_parents () |
|
|
2422 | { |
|
|
2423 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2424 | unsigned long nitems, bytes_after; |
|
|
2425 | Atom atype; |
|
|
2426 | unsigned char *prop = NULL; |
|
|
2427 | Window root, oldp, *list; |
|
|
2428 | Pixmap rootpixmap = None; |
|
|
2429 | XWindowAttributes wattr, wrootattr; |
|
|
2430 | dDisp; |
|
|
2431 | |
|
|
2432 | pchanged = 0; |
|
|
2433 | |
|
|
2434 | if (!OPTION (Opt_transparent)) |
|
|
2435 | return pchanged; /* Don't try any more */ |
|
|
2436 | |
|
|
2437 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2438 | rootdepth = wrootattr.depth; |
|
|
2439 | |
|
|
2440 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2441 | |
|
|
2442 | if (rootdepth != wattr.depth) |
|
|
2443 | { |
|
|
2444 | if (am_transparent) |
|
|
2445 | { |
|
|
2446 | pchanged = 1; |
|
|
2447 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2448 | am_transparent = am_pixmap_trans = 0; |
|
|
2449 | } |
|
|
2450 | |
|
|
2451 | return pchanged; /* Don't try any more */ |
|
|
2452 | } |
|
|
2453 | |
|
|
2454 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2455 | XSync (disp, False); |
|
|
2456 | |
|
|
2457 | /* |
|
|
2458 | * Make the frame window set by the window manager have |
|
|
2459 | * the root background. Some window managers put multiple nested frame |
|
|
2460 | * windows for each client, so we have to take care about that. |
|
|
2461 | */ |
|
|
2462 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2463 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2464 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2465 | &nitems, &bytes_after, &prop) == Success); |
|
|
2466 | |
|
|
2467 | if (!i || prop == NULL) |
|
|
2468 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2469 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2470 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2471 | &nitems, &bytes_after, &prop) == Success); |
|
|
2472 | |
|
|
2473 | if (!i || prop == NULL |
|
|
2474 | #if TINTING |
|
|
2475 | || !rs[Rs_color + Color_tint] |
|
|
2476 | #endif |
|
|
2477 | ) |
|
|
2478 | have_pixmap = 0; |
|
|
2479 | else |
|
|
2480 | { |
|
|
2481 | have_pixmap = 1; |
|
|
2482 | rootpixmap = *(Pixmap *)prop; |
|
|
2483 | XFree (prop); |
|
|
2484 | } |
|
|
2485 | |
|
|
2486 | if (have_pixmap) |
|
|
2487 | { |
|
|
2488 | /* |
|
|
2489 | * Copy display->root pixmap transparency |
|
|
2490 | */ |
|
|
2491 | int sx, sy, nx, ny; |
|
|
2492 | unsigned int nw, nh; |
|
|
2493 | Window cr; |
|
|
2494 | XImage *image; |
|
|
2495 | GC gc; |
|
|
2496 | XGCValues gcvalue; |
|
|
2497 | |
|
|
2498 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2499 | 0, 0, &sx, &sy, &cr); |
|
|
2500 | nw = (unsigned int)szHint.width; |
|
|
2501 | nh = (unsigned int)szHint.height; |
|
|
2502 | nx = ny = 0; |
|
|
2503 | |
|
|
2504 | if (sx < 0) |
|
|
2505 | { |
|
|
2506 | nw += sx; |
|
|
2507 | nx = -sx; |
|
|
2508 | sx = 0; |
|
|
2509 | } |
|
|
2510 | |
|
|
2511 | if (sy < 0) |
|
|
2512 | { |
|
|
2513 | nh += sy; |
|
|
2514 | ny = -sy; |
|
|
2515 | sy = 0; |
|
|
2516 | } |
|
|
2517 | |
|
|
2518 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2519 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2520 | |
|
|
2521 | XSync (disp, False); |
|
|
2522 | allowedxerror = -1; |
|
|
2523 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2524 | |
|
|
2525 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2526 | /* XXX: may need a delay here? */ |
|
|
2527 | allowedxerror = 0; |
|
|
2528 | |
|
|
2529 | if (image == NULL) |
|
|
2530 | { |
|
|
2531 | if (am_transparent && am_pixmap_trans) |
|
|
2532 | { |
|
|
2533 | pchanged = 1; |
|
|
2534 | if (pixmap != None) |
|
|
2535 | { |
|
|
2536 | XFreePixmap (disp, pixmap); |
|
|
2537 | pixmap = None; |
|
|
2538 | } |
|
|
2539 | } |
|
|
2540 | |
|
|
2541 | am_pixmap_trans = 0; |
|
|
2542 | } |
|
|
2543 | else |
|
|
2544 | { |
|
|
2545 | if (pixmap != None) |
|
|
2546 | XFreePixmap (disp, pixmap); |
|
|
2547 | |
|
|
2548 | #if TINTING |
|
|
2549 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2550 | { |
|
|
2551 | unsigned short rm, gm, bm; |
|
|
2552 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2553 | |
|
|
2554 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2555 | |
|
|
2556 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2557 | } |
|
|
2558 | #endif |
|
|
2559 | |
|
|
2560 | pixmap = XCreatePixmap (disp, vt, |
|
|
2561 | szHint.width, szHint.height, image->depth); |
|
|
2562 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2563 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2564 | nx, ny, image->width, image->height); |
|
|
2565 | XFreeGC (disp, gc); |
|
|
2566 | XDestroyImage (image); |
|
|
2567 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2568 | XClearWindow (disp, parent[0]); |
|
|
2569 | |
|
|
2570 | if (!am_transparent || !am_pixmap_trans) |
|
|
2571 | pchanged = 1; |
|
|
2572 | |
|
|
2573 | am_transparent = am_pixmap_trans = 1; |
|
|
2574 | } |
|
|
2575 | } |
|
|
2576 | |
|
|
2577 | if (am_pixmap_trans) |
|
|
2578 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2579 | else |
|
|
2580 | { |
|
|
2581 | unsigned int n; |
|
|
2582 | /* |
|
|
2583 | * InheritPixmap transparency |
|
|
2584 | */ |
|
|
2585 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2586 | { |
|
|
2587 | oldp = parent[i]; |
|
|
2588 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2589 | &parent[i], &list, &n); |
|
|
2590 | XFree (list); |
|
|
2591 | |
|
|
2592 | if (parent[i] == display->root) |
|
|
2593 | { |
|
|
2594 | if (oldp != None) |
|
|
2595 | pchanged = 1; |
|
|
2596 | |
|
|
2597 | break; |
|
|
2598 | } |
|
|
2599 | |
|
|
2600 | if (oldp != parent[i]) |
|
|
2601 | pchanged = 1; |
|
|
2602 | } |
|
|
2603 | |
|
|
2604 | n = 0; |
|
|
2605 | |
|
|
2606 | if (pchanged) |
|
|
2607 | { |
|
|
2608 | for (; n < (unsigned int)i; n++) |
|
|
2609 | { |
|
|
2610 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2611 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2612 | { |
|
|
2613 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2614 | break; |
|
|
2615 | } |
|
|
2616 | } |
|
|
2617 | } |
|
|
2618 | |
|
|
2619 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2620 | { |
|
|
2621 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2622 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2623 | am_transparent = 0; |
|
|
2624 | /* XXX: also turn off Opt_transparent? */ |
|
|
2625 | } |
|
|
2626 | else |
|
|
2627 | { |
|
|
2628 | #if WAIT_FOR_WM |
|
|
2629 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2630 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2631 | sleep (1); |
|
|
2632 | #endif |
|
|
2633 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2634 | { |
|
|
2635 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2636 | XClearWindow (disp, parent[n]); |
|
|
2637 | } |
|
|
2638 | |
|
|
2639 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2640 | am_transparent = 1; |
|
|
2641 | } |
|
|
2642 | |
|
|
2643 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2644 | parent[i] = None; |
|
|
2645 | } |
|
|
2646 | |
|
|
2647 | if (scrollBar.win) |
|
|
2648 | { |
|
|
2649 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2650 | scrollBar.setIdle (); |
|
|
2651 | scrollbar_show (0); |
|
|
2652 | } |
|
|
2653 | |
|
|
2654 | if (am_transparent) |
|
|
2655 | { |
|
|
2656 | want_refresh = want_full_refresh = 1; |
|
|
2657 | if (am_pixmap_trans) |
|
|
2658 | flush (); |
|
|
2659 | } |
|
|
2660 | |
|
|
2661 | return pchanged; |
|
|
2662 | } |
|
|
2663 | #endif |
|
|
2664 | |
2238 | |
2665 | /*}}} */ |
2239 | /*}}} */ |
2666 | |
2240 | |
2667 | bool |
2241 | bool |
2668 | rxvt_term::cmd_parse () |
2242 | rxvt_term::cmd_parse () |
2669 | { |
2243 | { |
2670 | bool flag = false; |
2244 | bool flag = false; |
2671 | unicode_t ch = NOCHAR; |
2245 | wchar_t ch = NOCHAR; |
2672 | unsigned char *seq_begin; // remember start of esc-sequence here |
2246 | char *seq_begin; // remember start of esc-sequence here |
2673 | |
2247 | |
2674 | for (;;) |
2248 | for (;;) |
2675 | { |
2249 | { |
2676 | if (ch == NOCHAR) |
2250 | if (ch == NOCHAR) |
2677 | { |
2251 | { |
2678 | seq_begin = cmdbuf_ptr; |
2252 | seq_begin = cmdbuf_ptr; |
2679 | ch = next_char (); |
2253 | ch = next_char (); |
2680 | } |
|
|
2681 | |
2254 | |
2682 | if (ch == NOCHAR) // TODO: improve |
2255 | if (ch == NOCHAR) |
2683 | break; |
2256 | break; |
|
|
2257 | } |
2684 | |
2258 | |
2685 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2259 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2686 | { |
2260 | { |
2687 | if (!seen_input) |
2261 | if (!seen_input) |
2688 | { |
2262 | { |
… | |
… | |
2697 | if (seen_resize && cmd_pid) |
2271 | if (seen_resize && cmd_pid) |
2698 | kill (-cmd_pid, SIGWINCH); |
2272 | kill (-cmd_pid, SIGWINCH); |
2699 | } |
2273 | } |
2700 | |
2274 | |
2701 | /* Read a text string from the input buffer */ |
2275 | /* Read a text string from the input buffer */ |
2702 | unicode_t buf[UBUFSIZ]; |
2276 | wchar_t buf[UBUFSIZ]; |
2703 | bool refreshnow = false; |
2277 | bool refreshnow = false; |
2704 | int nlines = 0; |
2278 | int nlines = 0; |
2705 | unicode_t *str = buf; |
2279 | wchar_t *str = buf; |
2706 | unicode_t *eol = str + min (ncol, UBUFSIZ); |
2280 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2707 | |
2281 | |
2708 | for (;;) |
2282 | for (;;) |
2709 | { |
2283 | { |
2710 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2284 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2711 | break; |
2285 | break; |
… | |
… | |
2717 | if (ch == C0_LF) |
2291 | if (ch == C0_LF) |
2718 | nlines++; |
2292 | nlines++; |
2719 | |
2293 | |
2720 | refresh_count++; |
2294 | refresh_count++; |
2721 | |
2295 | |
2722 | if (!OPTION (Opt_jumpScroll) |
2296 | if (!option (Opt_jumpScroll) |
2723 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2297 | || (refresh_count >= refresh_limit * (nrow - 1))) |
2724 | { |
2298 | { |
2725 | refreshnow = true; |
2299 | refreshnow = true; |
2726 | refresh_count = 0; |
2300 | refresh_count = 0; |
2727 | ch = NOCHAR; |
2301 | ch = NOCHAR; |
… | |
… | |
2729 | } |
2303 | } |
2730 | |
2304 | |
2731 | // scr_add_lines only works for nlines <= nrow - 1. |
2305 | // scr_add_lines only works for nlines <= nrow - 1. |
2732 | if (nlines >= nrow - 1) |
2306 | if (nlines >= nrow - 1) |
2733 | { |
2307 | { |
|
|
2308 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2309 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2734 | scr_add_lines (buf, nlines, str - buf); |
2310 | scr_add_lines (buf, str - buf, nlines); |
|
|
2311 | |
2735 | nlines = 0; |
2312 | nlines = 0; |
2736 | str = buf; |
2313 | str = buf; |
2737 | eol = str + min (ncol, UBUFSIZ); |
2314 | eol = str + min (ncol, UBUFSIZ); |
2738 | } |
2315 | } |
2739 | |
2316 | |
… | |
… | |
2752 | |
2329 | |
2753 | seq_begin = cmdbuf_ptr; |
2330 | seq_begin = cmdbuf_ptr; |
2754 | ch = next_char (); |
2331 | ch = next_char (); |
2755 | } |
2332 | } |
2756 | |
2333 | |
|
|
2334 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
|
|
2335 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2757 | scr_add_lines (buf, nlines, str - buf); |
2336 | scr_add_lines (buf, str - buf, nlines); |
2758 | |
2337 | |
2759 | /* |
2338 | /* |
2760 | * 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 |
2761 | * 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. |
2762 | * the number of pages between refreshes is refresh_limit, which |
2341 | * the number of pages between refreshes is refresh_limit, which |
2763 | * is incremented here because we must be doing flat-out scrolling. |
2342 | * is incremented here because we must be doing flat-out scrolling. |
2764 | */ |
2343 | */ |
2765 | if (refreshnow) |
2344 | if (refreshnow) |
2766 | { |
2345 | { |
2767 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2346 | if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2768 | refresh_limit++; |
2347 | refresh_limit++; |
2769 | else |
2348 | else |
2770 | { |
2349 | { |
2771 | flag = true; |
2350 | flag = true; |
|
|
2351 | //TODO: due to popular request, implement "skipscroll" option here |
2772 | scr_refresh (refresh_type); |
2352 | scr_refresh (); |
2773 | flush_ev.stop (); |
2353 | want_refresh = 1; |
2774 | } |
2354 | } |
2775 | } |
2355 | } |
2776 | |
2356 | |
2777 | } |
2357 | } |
2778 | else |
2358 | else |
… | |
… | |
2793 | } |
2373 | } |
2794 | |
2374 | |
2795 | return flag; |
2375 | return flag; |
2796 | } |
2376 | } |
2797 | |
2377 | |
2798 | // read the next octet |
|
|
2799 | unicode_t |
|
|
2800 | rxvt_term::next_octet () |
|
|
2801 | { |
|
|
2802 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2803 | ? *cmdbuf_ptr++ |
|
|
2804 | : NOCHAR; |
|
|
2805 | } |
|
|
2806 | |
|
|
2807 | // read the next character |
2378 | // read the next character |
2808 | unicode_t |
2379 | wchar_t |
2809 | rxvt_term::next_char () |
2380 | rxvt_term::next_char () NOTHROW |
2810 | { |
2381 | { |
2811 | while (cmdbuf_ptr < cmdbuf_endp) |
2382 | while (cmdbuf_ptr < cmdbuf_endp) |
2812 | { |
2383 | { |
2813 | // assume 7-bit to be ascii ALWAYS |
2384 | // assume 7-bit to be ascii ALWAYS |
2814 | if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2385 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2815 | return *cmdbuf_ptr++; |
2386 | return *cmdbuf_ptr++; |
2816 | |
2387 | |
2817 | wchar_t wc; |
2388 | wchar_t wc; |
2818 | size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2389 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2819 | |
2390 | |
2820 | if (len == (size_t)-2) |
2391 | if (len == (size_t)-2) |
2821 | { |
2392 | { |
2822 | // the mbstate stores incomplete sequences. didn't know this :/ |
2393 | // the mbstate stores incomplete sequences. didn't know this :/ |
2823 | cmdbuf_ptr = cmdbuf_endp; |
2394 | cmdbuf_ptr = cmdbuf_endp; |
2824 | break; |
2395 | break; |
2825 | } |
2396 | } |
2826 | |
2397 | |
2827 | if (len == (size_t)-1) |
2398 | if (len == (size_t)-1) |
2828 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2399 | return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2829 | |
2400 | |
2830 | // assume wchar == unicode |
2401 | // assume wchar == unicode |
2831 | cmdbuf_ptr += len; |
2402 | cmdbuf_ptr += len; |
2832 | return wc & UNICODE_MASK; |
2403 | return wc & UNICODE_MASK; |
2833 | } |
2404 | } |
2834 | |
2405 | |
2835 | return NOCHAR; |
2406 | return NOCHAR; |
2836 | } |
2407 | } |
|
|
2408 | |
|
|
2409 | // read the next octet |
|
|
2410 | uint32_t |
|
|
2411 | rxvt_term::next_octet () NOTHROW |
|
|
2412 | { |
|
|
2413 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2414 | ? (unsigned char)*cmdbuf_ptr++ |
|
|
2415 | : NOCHAR; |
|
|
2416 | } |
|
|
2417 | |
|
|
2418 | static class out_of_input out_of_input; |
2837 | |
2419 | |
2838 | /* rxvt_cmd_getc () - Return next input character */ |
2420 | /* rxvt_cmd_getc () - Return next input character */ |
2839 | /* |
2421 | /* |
2840 | * Return the next input character after first passing any keyboard input |
2422 | * Return the next input character after first passing any keyboard input |
2841 | * to the command. |
2423 | * to the command. |
2842 | */ |
2424 | */ |
2843 | unicode_t |
2425 | wchar_t |
2844 | rxvt_term::cmd_getc () |
2426 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2845 | { |
2427 | { |
2846 | unicode_t c = next_char (); |
2428 | wchar_t c = next_char (); |
2847 | |
2429 | |
2848 | if (c == NOCHAR) |
2430 | if (c == NOCHAR) |
2849 | throw out_of_input; |
2431 | throw out_of_input; |
2850 | |
2432 | |
2851 | return c; |
2433 | return c; |
2852 | } |
2434 | } |
2853 | |
2435 | |
2854 | unicode_t |
2436 | uint32_t |
2855 | rxvt_term::cmd_get8 () |
2437 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2856 | { |
2438 | { |
2857 | unicode_t c = next_octet (); |
2439 | uint32_t c = next_octet (); |
2858 | |
2440 | |
2859 | if (c == NOCHAR) |
2441 | if (c == NOCHAR) |
2860 | throw out_of_input; |
2442 | throw out_of_input; |
2861 | |
2443 | |
2862 | return c; |
2444 | return c; |
… | |
… | |
2926 | { |
2508 | { |
2927 | if ((buf[len++] = cmd_getc ()) == 'i') |
2509 | if ((buf[len++] = cmd_getc ()) == 'i') |
2928 | break; /* done = 1 */ |
2510 | break; /* done = 1 */ |
2929 | } |
2511 | } |
2930 | } |
2512 | } |
2931 | |
2513 | |
2932 | for (i = 0; i < len; i++) |
2514 | for (i = 0; i < len; i++) |
2933 | if (putc (buf[i], fd) == EOF) |
2515 | if (putc (buf[i], fd) == EOF) |
2934 | { |
2516 | { |
2935 | done = 1; |
2517 | done = 1; |
2936 | break; |
2518 | break; |
… | |
… | |
2962 | case C0_ESC: |
2544 | case C0_ESC: |
2963 | process_escape_seq (); |
2545 | process_escape_seq (); |
2964 | break; |
2546 | break; |
2965 | case C0_ENQ: /* terminal Status */ |
2547 | case C0_ENQ: /* terminal Status */ |
2966 | if (rs[Rs_answerbackstring]) |
2548 | if (rs[Rs_answerbackstring]) |
2967 | tt_write ((const unsigned char *)rs[Rs_answerbackstring], |
2549 | tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); |
2968 | (unsigned int)strlen (rs[Rs_answerbackstring])); |
|
|
2969 | else |
2550 | else |
2970 | tt_write ((unsigned char *)VT100_ANS, |
2551 | tt_write (VT100_ANS, strlen (VT100_ANS)); |
2971 | (unsigned int)strlen (VT100_ANS)); |
|
|
2972 | break; |
2552 | break; |
2973 | case C0_BEL: /* bell */ |
2553 | case C0_BEL: /* bell */ |
2974 | scr_bell (); |
2554 | scr_bell (); |
2975 | break; |
2555 | break; |
2976 | case C0_BS: /* backspace */ |
2556 | case C0_BS: /* backspace */ |
… | |
… | |
3100 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2680 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3101 | break; |
2681 | break; |
3102 | case '+': |
2682 | case '+': |
3103 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2683 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3104 | break; |
2684 | break; |
3105 | #if ENABLE_FRILLS |
2685 | #if !ENABLE_MINIMAL |
3106 | case '6': |
2686 | case '6': |
3107 | scr_backindex (); |
2687 | scr_backindex (); |
3108 | break; |
2688 | break; |
3109 | #endif |
2689 | #endif |
3110 | case '7': |
2690 | case '7': |
3111 | scr_cursor (SAVE); |
2691 | scr_cursor (SAVE); |
3112 | break; |
2692 | break; |
3113 | case '8': |
2693 | case '8': |
3114 | scr_cursor (RESTORE); |
2694 | scr_cursor (RESTORE); |
3115 | break; |
2695 | break; |
3116 | #if ENABLE_FRILLS |
2696 | #if !ENABLE_MINIMAL |
3117 | case '9': |
2697 | case '9': |
3118 | scr_forwardindex (); |
2698 | scr_forwardindex (); |
3119 | break; |
2699 | break; |
3120 | #endif |
2700 | #endif |
3121 | case '=': |
2701 | case '=': |
… | |
… | |
3131 | break; |
2711 | break; |
3132 | |
2712 | |
3133 | /* 8.3.87: NEXT LINE */ |
2713 | /* 8.3.87: NEXT LINE */ |
3134 | case C1_NEL: /* ESC E */ |
2714 | case C1_NEL: /* ESC E */ |
3135 | { |
2715 | { |
3136 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
2716 | wchar_t nlcr[] = { C0_LF, C0_CR }; |
3137 | scr_add_lines (nlcr, 1, 2); |
2717 | scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); |
3138 | } |
2718 | } |
3139 | break; |
2719 | break; |
3140 | |
2720 | |
3141 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2721 | /* kidnapped escape sequence: Should be 8.3.48 */ |
3142 | case C1_ESA: /* ESC G */ |
2722 | case C1_ESA: /* ESC G */ |
… | |
… | |
3164 | process_dcs_seq (); |
2744 | process_dcs_seq (); |
3165 | break; |
2745 | break; |
3166 | |
2746 | |
3167 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
2747 | /* 8.3.110: SINGLE CHARACTER INTRODUCER */ |
3168 | case C1_SCI: /* ESC Z */ |
2748 | case C1_SCI: /* ESC Z */ |
3169 | tt_write ((const unsigned char *)ESCZ_ANSWER, |
2749 | tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); |
3170 | (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); |
|
|
3171 | break; /* steal obsolete ESC [ c */ |
2750 | break; /* steal obsolete ESC [ c */ |
3172 | |
2751 | |
3173 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
2752 | /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ |
3174 | case C1_CSI: /* ESC [ */ |
2753 | case C1_CSI: /* ESC [ */ |
3175 | process_csi_seq (); |
2754 | process_csi_seq (); |
… | |
… | |
3284 | ndef = get_byte_array_bit (csi_defaults, i); |
2863 | ndef = get_byte_array_bit (csi_defaults, i); |
3285 | for (p = 0; p < nargs; p++) |
2864 | for (p = 0; p < nargs; p++) |
3286 | if (arg[p] == -1) |
2865 | if (arg[p] == -1) |
3287 | arg[p] = ndef; |
2866 | arg[p] = ndef; |
3288 | |
2867 | |
3289 | #ifdef DEBUG_CMD |
|
|
3290 | fprintf (stderr, "CSI "); |
|
|
3291 | for (p = 0; p < nargs; p++) |
|
|
3292 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3293 | fprintf (stderr, "%c\n", ch); |
|
|
3294 | #endif |
|
|
3295 | |
|
|
3296 | /* |
2868 | /* |
3297 | * private mode handling |
2869 | * private mode handling |
3298 | */ |
2870 | */ |
3299 | if (priv) |
2871 | if (priv) |
3300 | { |
2872 | { |
3301 | switch (priv) |
2873 | switch (priv) |
3302 | { |
2874 | { |
3303 | case '>': |
2875 | case '>': |
3304 | if (ch == CSI_DA) /* secondary device attributes */ |
2876 | if (ch == CSI_DA) /* secondary device attributes */ |
3305 | 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 | } |
3306 | break; |
2887 | break; |
3307 | case '?': |
2888 | case '?': |
3308 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2889 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3309 | process_terminal_mode (ch, priv, nargs, arg); |
2890 | process_terminal_mode (ch, priv, nargs, arg); |
3310 | break; |
2891 | break; |
… | |
… | |
3419 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3000 | case CSI_SU: /* 8.3.148: (1) SCROLL UP */ |
3420 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3001 | scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); |
3421 | break; |
3002 | break; |
3422 | |
3003 | |
3423 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3004 | case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ |
3424 | tt_write ((const unsigned char *)VT100_ANS, |
3005 | tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); |
3425 | (unsigned int) (sizeof (VT100_ANS) - 1)); |
|
|
3426 | break; |
3006 | break; |
3427 | |
3007 | |
3428 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3008 | case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ |
3429 | process_sgr_mode (nargs, arg); |
3009 | process_sgr_mode (nargs, arg); |
3430 | break; |
3010 | break; |
… | |
… | |
3437 | break; |
3017 | break; |
3438 | case 6: /* CPR requested */ |
3018 | case 6: /* CPR requested */ |
3439 | scr_report_position (); |
3019 | scr_report_position (); |
3440 | break; |
3020 | break; |
3441 | case 7: /* unofficial extension */ |
3021 | case 7: /* unofficial extension */ |
3442 | if (OPTION (Opt_insecure)) |
3022 | if (option (Opt_insecure)) |
3443 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3023 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3444 | break; |
3024 | break; |
3445 | case 8: /* unofficial extension */ |
3025 | case 8: /* unofficial extension */ |
3446 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3026 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3447 | break; |
3027 | break; |
… | |
… | |
3514 | break; |
3094 | break; |
3515 | case CSI_75: |
3095 | case CSI_75: |
3516 | scr_cursor (RESTORE); |
3096 | scr_cursor (RESTORE); |
3517 | break; |
3097 | break; |
3518 | |
3098 | |
3519 | #if ENABLE_FRILLS |
3099 | #if !ENABLE_MINIMAL |
3520 | case CSI_74: |
3100 | case CSI_74: |
3521 | process_window_ops (arg, nargs); |
3101 | process_window_ops (arg, nargs); |
3522 | break; |
3102 | break; |
3523 | #endif |
3103 | #endif |
3524 | |
3104 | |
… | |
… | |
3531 | break; |
3111 | break; |
3532 | } |
3112 | } |
3533 | } |
3113 | } |
3534 | /*}}} */ |
3114 | /*}}} */ |
3535 | |
3115 | |
3536 | #if ENABLE_FRILLS |
3116 | #if !ENABLE_MINIMAL |
3537 | /* ARGSUSED */ |
3117 | /* ARGSUSED */ |
3538 | void |
3118 | void |
3539 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3119 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3540 | { |
3120 | { |
3541 | int x, y; |
3121 | int x, y; |
3542 | XWindowAttributes wattr; |
3122 | XWindowAttributes wattr; |
3543 | Window wdummy; |
3123 | Window wdummy; |
3544 | dDisp; |
3124 | |
|
|
3125 | dLocal (Display *, dpy); |
3545 | |
3126 | |
3546 | if (nargs == 0) |
3127 | if (nargs == 0) |
3547 | return; |
3128 | return; |
3548 | |
3129 | |
3549 | switch (args[0]) |
3130 | switch (args[0]) |
3550 | { |
3131 | { |
3551 | /* |
3132 | /* |
3552 | * commands |
3133 | * commands |
3553 | */ |
3134 | */ |
3554 | case 1: /* deiconify window */ |
3135 | case 1: /* deiconify window */ |
3555 | XMapWindow (disp, parent[0]); |
3136 | XMapWindow (dpy, parent[0]); |
3556 | break; |
3137 | break; |
3557 | case 2: /* iconify window */ |
3138 | case 2: /* iconify window */ |
3558 | XIconifyWindow (disp, parent[0], display->screen); |
3139 | XIconifyWindow (dpy, parent[0], display->screen); |
3559 | break; |
3140 | break; |
3560 | case 3: /* set position (pixels) */ |
3141 | case 3: /* set position (pixels) */ |
3561 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3142 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3562 | break; |
3143 | break; |
3563 | case 4: /* set size (pixels) */ |
3144 | case 4: /* set size (pixels) */ |
3564 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3145 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3565 | break; |
3146 | break; |
3566 | case 5: /* raise window */ |
3147 | case 5: /* raise window */ |
3567 | XRaiseWindow (disp, parent[0]); |
3148 | XRaiseWindow (dpy, parent[0]); |
3568 | break; |
3149 | break; |
3569 | case 6: /* lower window */ |
3150 | case 6: /* lower window */ |
3570 | XLowerWindow (disp, parent[0]); |
3151 | XLowerWindow (dpy, parent[0]); |
3571 | break; |
3152 | break; |
3572 | case 7: /* refresh window */ |
3153 | case 7: /* refresh window */ |
3573 | scr_touch (true); |
3154 | scr_touch (true); |
3574 | break; |
3155 | break; |
3575 | case 8: /* set size (chars) */ |
3156 | case 8: /* set size (chars) */ |
… | |
… | |
3582 | if (args[0] >= 24) /* set height (chars) */ |
3163 | if (args[0] >= 24) /* set height (chars) */ |
3583 | set_widthheight ((unsigned int)width, |
3164 | set_widthheight ((unsigned int)width, |
3584 | (unsigned int) (args[1] * fheight)); |
3165 | (unsigned int) (args[1] * fheight)); |
3585 | break; |
3166 | break; |
3586 | |
3167 | |
3587 | |
|
|
3588 | /* |
3168 | /* |
3589 | * reports - some output format copied from XTerm |
3169 | * reports - some output format copied from XTerm |
3590 | */ |
3170 | */ |
3591 | case 11: /* report window state */ |
3171 | case 11: /* report window state */ |
3592 | XGetWindowAttributes (disp, parent[0], &wattr); |
3172 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3593 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3173 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3594 | break; |
3174 | break; |
3595 | case 13: /* report window position */ |
3175 | case 13: /* report window position */ |
3596 | XGetWindowAttributes (disp, parent[0], &wattr); |
3176 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3597 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3177 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3598 | -wattr.border_width, -wattr.border_width, |
3178 | -wattr.border_width, -wattr.border_width, |
3599 | &x, &y, &wdummy); |
3179 | &x, &y, &wdummy); |
3600 | tt_printf ("\033[3;%d;%dt", x, y); |
3180 | tt_printf ("\033[3;%d;%dt", x, y); |
3601 | break; |
3181 | break; |
3602 | case 14: /* report window size (pixels) */ |
3182 | case 14: /* report window size (pixels) */ |
3603 | XGetWindowAttributes (disp, parent[0], &wattr); |
3183 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3604 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3184 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3605 | break; |
3185 | break; |
3606 | case 18: /* report text area size (chars) */ |
3186 | case 18: /* report text area size (chars) */ |
3607 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3187 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3608 | break; |
3188 | break; |
… | |
… | |
3610 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3190 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3611 | break; |
3191 | break; |
3612 | case 20: /* report icon label */ |
3192 | case 20: /* report icon label */ |
3613 | { |
3193 | { |
3614 | char *s; |
3194 | char *s; |
3615 | XGetIconName (disp, parent[0], &s); |
3195 | XGetIconName (dpy, parent[0], &s); |
3616 | 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 */ |
3617 | XFree (s); |
3197 | XFree (s); |
3618 | } |
3198 | } |
3619 | break; |
3199 | break; |
3620 | case 21: /* report window title */ |
3200 | case 21: /* report window title */ |
3621 | { |
3201 | { |
3622 | char *s; |
3202 | char *s; |
3623 | XFetchName (disp, parent[0], &s); |
3203 | XFetchName (dpy, parent[0], &s); |
3624 | 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 */ |
3625 | XFree (s); |
3205 | XFree (s); |
3626 | } |
3206 | } |
3627 | break; |
3207 | break; |
3628 | } |
3208 | } |
3629 | } |
3209 | } |
… | |
… | |
3632 | /*----------------------------------------------------------------------*/ |
3212 | /*----------------------------------------------------------------------*/ |
3633 | /* |
3213 | /* |
3634 | * get input up until STRING TERMINATOR (or BEL) |
3214 | * get input up until STRING TERMINATOR (or BEL) |
3635 | * ends_how is terminator used. returned input must be free()'d |
3215 | * ends_how is terminator used. returned input must be free()'d |
3636 | */ |
3216 | */ |
3637 | unsigned char * |
3217 | char * |
3638 | rxvt_term::get_to_st (unicode_t &ends_how) |
3218 | rxvt_term::get_to_st (unicode_t &ends_how) |
3639 | { |
3219 | { |
3640 | unicode_t ch; |
3220 | unicode_t ch; |
3641 | bool seen_esc = false; |
3221 | bool seen_esc = false; |
3642 | unsigned int n = 0; |
3222 | unsigned int n = 0; |
… | |
… | |
3656 | seen_esc = true; |
3236 | seen_esc = true; |
3657 | continue; |
3237 | continue; |
3658 | } |
3238 | } |
3659 | else if (ch == C0_BEL || ch == CHAR_ST) |
3239 | else if (ch == C0_BEL || ch == CHAR_ST) |
3660 | break; |
3240 | break; |
|
|
3241 | else if (ch == C0_SYN) |
|
|
3242 | ch = cmd_get8 (); |
3661 | else if (ch < 0x20) |
3243 | else if (ch < 0x20) |
3662 | return NULL; /* other control character - exit */ |
3244 | return NULL; /* other control character - exit */ |
3663 | |
3245 | |
3664 | seen_esc = false; |
3246 | seen_esc = false; |
3665 | |
3247 | |
3666 | if (n >= STRING_MAX - 1) |
3248 | if (n >= STRING_MAX - 1) |
3667 | // stop at some sane length |
3249 | // stop at some sane length |
3668 | return NULL; |
3250 | return NULL; |
3669 | |
3251 | |
3670 | if (ch == C0_SYN) |
|
|
3671 | string[n++] = cmd_get8 (); |
|
|
3672 | else |
|
|
3673 | string[n++] = ch; |
3252 | string[n++] = ch; |
3674 | } |
3253 | } |
3675 | |
3254 | |
3676 | string[n++] = '\0'; |
3255 | string[n++] = '\0'; |
3677 | |
3256 | |
3678 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3257 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3679 | |
3258 | |
3680 | return (unsigned char *)rxvt_wcstombs (string); |
3259 | return rxvt_wcstombs (string); |
3681 | } |
3260 | } |
3682 | |
3261 | |
3683 | /*----------------------------------------------------------------------*/ |
3262 | /*----------------------------------------------------------------------*/ |
3684 | /* |
3263 | /* |
3685 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3264 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3686 | */ |
3265 | */ |
3687 | void |
3266 | void |
3688 | rxvt_term::process_dcs_seq () |
3267 | rxvt_term::process_dcs_seq () |
3689 | { |
3268 | { |
3690 | unsigned char *s; |
3269 | char *s; |
3691 | unicode_t eh; |
3270 | unicode_t eh; |
3692 | |
3271 | |
3693 | /* |
3272 | /* |
3694 | * Not handled yet |
3273 | * Not handled yet |
3695 | */ |
3274 | */ |
… | |
… | |
3714 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3293 | for (arg = 0; isdigit (ch); ch = cmd_getc ()) |
3715 | arg = arg * 10 + (ch - '0'); |
3294 | arg = arg * 10 + (ch - '0'); |
3716 | |
3295 | |
3717 | if (ch == ';') |
3296 | if (ch == ';') |
3718 | { |
3297 | { |
3719 | unsigned char *s = get_to_st (eh); |
3298 | char *s = get_to_st (eh); |
3720 | |
3299 | |
3721 | if (s) |
3300 | if (s) |
3722 | { |
3301 | { |
3723 | process_xterm_seq (arg, (char *)s, eh); |
3302 | process_xterm_seq (arg, s, eh); |
3724 | free (s); |
3303 | free (s); |
3725 | } |
3304 | } |
3726 | } |
3305 | } |
3727 | } |
3306 | } |
3728 | |
3307 | |
3729 | void |
3308 | void |
3730 | rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) |
3309 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3731 | { |
3310 | { |
3732 | if (str[0] == '?' && !str[1]) |
3311 | if (str[0] == '?' && !str[1]) |
3733 | { |
3312 | { |
3734 | unsigned short r, g, b; |
3313 | rgba c; |
3735 | 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 |
3736 | 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); |
3737 | } |
3322 | } |
3738 | else |
3323 | else |
3739 | set_window_color (color, str); |
3324 | set_window_color (color, str); |
3740 | } |
3325 | } |
3741 | |
3326 | |
3742 | /* |
3327 | /* |
3743 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3328 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3744 | */ |
3329 | */ |
3745 | void |
3330 | void |
3746 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3331 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3747 | { |
3332 | { |
3748 | int changed = 0; |
|
|
3749 | int color; |
3333 | int color; |
3750 | char *buf, *name; |
3334 | char *buf, *name; |
3751 | bool query = str[0] == '?' && !str[1]; |
3335 | bool query = str[0] == '?' && !str[1]; |
3752 | int saveop = op; |
3336 | int saveop = op; |
3753 | dDisp; |
3337 | |
|
|
3338 | dLocal (Display *, dpy); |
3754 | |
3339 | |
3755 | 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 | |
3756 | switch (op) |
3345 | switch (op) |
3757 | { |
3346 | { |
3758 | case XTerm_name: |
3347 | case XTerm_name: |
3759 | set_title (str); |
3348 | set_title (str); |
3760 | /* FALLTHROUGH */ |
3349 | /* FALLTHROUGH */ |
… | |
… | |
3774 | unsigned long bytes_after; |
3363 | unsigned long bytes_after; |
3775 | unsigned char *value = 0; |
3364 | unsigned char *value = 0; |
3776 | const char *str = ""; |
3365 | const char *str = ""; |
3777 | |
3366 | |
3778 | if (prop |
3367 | if (prop |
3779 | && XGetWindowProperty (disp, parent[0], |
3368 | && XGetWindowProperty (dpy, parent[0], |
3780 | prop, 0, 1<<16, 0, AnyPropertyType, |
3369 | prop, 0, 1<<16, 0, AnyPropertyType, |
3781 | &actual_type, &actual_format, |
3370 | &actual_type, &actual_format, |
3782 | &nitems, &bytes_after, &value) == Success |
3371 | &nitems, &bytes_after, &value) == Success |
3783 | && actual_type != None |
3372 | && actual_type != None |
3784 | && actual_format == 8) |
3373 | && actual_format == 8) |
3785 | str = (const char *)(value); |
3374 | str = (const char *)(value); |
3786 | |
3375 | |
3787 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3376 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3788 | |
3377 | |
3789 | XFree (value); |
3378 | XFree (value); |
3790 | } |
3379 | } |
3791 | else |
3380 | else |
3792 | { |
3381 | { |
… | |
… | |
3796 | { |
3385 | { |
3797 | *eq = 0; |
3386 | *eq = 0; |
3798 | set_utf8_property (display->atom (str), eq + 1); |
3387 | set_utf8_property (display->atom (str), eq + 1); |
3799 | } |
3388 | } |
3800 | else |
3389 | else |
3801 | XDeleteProperty (disp, parent[0], |
3390 | XDeleteProperty (dpy, parent[0], |
3802 | display->atom (str)); |
3391 | display->atom (str)); |
3803 | } |
3392 | } |
3804 | break; |
3393 | break; |
3805 | |
3394 | |
3806 | case XTerm_Color: |
3395 | case XTerm_Color: |
… | |
… | |
3808 | { |
3397 | { |
3809 | if ((name = strchr (buf, ';')) == NULL) |
3398 | if ((name = strchr (buf, ';')) == NULL) |
3810 | break; |
3399 | break; |
3811 | |
3400 | |
3812 | *name++ = '\0'; |
3401 | *name++ = '\0'; |
3813 | color = atoi (buf); |
3402 | color = atoi (buf) + minCOLOR; |
3814 | |
3403 | |
3815 | if (color < 0 || color >= TOTAL_COLORS) |
3404 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3816 | break; |
3405 | break; |
3817 | |
3406 | |
3818 | if ((buf = strchr (name, ';')) != NULL) |
3407 | if ((buf = strchr (name, ';')) != NULL) |
3819 | *buf++ = '\0'; |
3408 | *buf++ = '\0'; |
3820 | |
3409 | |
3821 | if (name[0] == '?' && !name[1]) |
3410 | process_color_seq (op, color, name, resp); |
3822 | { |
|
|
3823 | unsigned short r, g, b; |
|
|
3824 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
|
|
3825 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3826 | } |
|
|
3827 | else |
|
|
3828 | set_window_color (color + minCOLOR, name); |
|
|
3829 | } |
3411 | } |
3830 | break; |
3412 | break; |
3831 | case XTerm_Color00: |
3413 | case XTerm_Color00: |
3832 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3414 | process_color_seq (op, Color_fg, str, resp); |
3833 | break; |
3415 | break; |
3834 | case XTerm_Color01: |
3416 | case XTerm_Color01: |
3835 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3417 | process_color_seq (op, Color_bg, str, resp); |
3836 | break; |
3418 | break; |
3837 | #ifndef NO_CURSORCOLOR |
3419 | #ifndef NO_CURSORCOLOR |
3838 | case XTerm_Color_cursor: |
3420 | case XTerm_Color_cursor: |
3839 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3421 | process_color_seq (op, Color_cursor, str, resp); |
3840 | break; |
3422 | break; |
3841 | #endif |
3423 | #endif |
3842 | case XTerm_Color_pointer_fg: |
3424 | case XTerm_Color_pointer_fg: |
3843 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3425 | process_color_seq (op, Color_pointer_fg, str, resp); |
3844 | break; |
3426 | break; |
3845 | case XTerm_Color_pointer_bg: |
3427 | case XTerm_Color_pointer_bg: |
3846 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3428 | process_color_seq (op, Color_pointer_bg, str, resp); |
3847 | break; |
3429 | break; |
3848 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3430 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3849 | case XTerm_Color_BD: |
|
|
3850 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3851 | break; |
|
|
3852 | case XTerm_Color_UL: |
|
|
3853 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3854 | break; |
|
|
3855 | case XTerm_Color_RV: |
3431 | case XTerm_Color_RV: |
3856 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3432 | process_color_seq (op, Color_RV, str, resp); |
|
|
3433 | break; |
|
|
3434 | case Rxvt_Color_BD: |
|
|
3435 | case URxvt_Color_BD: |
|
|
3436 | process_color_seq (op, Color_BD, str, resp); |
|
|
3437 | break; |
|
|
3438 | case Rxvt_Color_UL: |
|
|
3439 | case URxvt_Color_UL: |
|
|
3440 | process_color_seq (op, Color_UL, str, resp); |
3857 | break; |
3441 | break; |
3858 | case URxvt_Color_IT: |
3442 | case URxvt_Color_IT: |
3859 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3443 | process_color_seq (op, Color_IT, str, resp); |
3860 | break; |
3444 | break; |
3861 | #endif |
3445 | #endif |
3862 | #if TRANSPARENT && TINTING |
3446 | #if TRANSPARENT && TINTING |
3863 | case URxvt_Color_tint: |
3447 | case URxvt_Color_tint: |
3864 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3448 | process_color_seq (op, Color_tint, str, resp); |
|
|
3449 | |
3865 | check_our_parents (); |
3450 | check_our_parents (); |
|
|
3451 | |
3866 | if (am_transparent) |
3452 | if (am_transparent) |
3867 | want_full_refresh = want_refresh = 1; |
3453 | want_full_refresh = want_refresh = 1; |
3868 | break; |
|
|
3869 | #endif |
|
|
3870 | |
3454 | |
|
|
3455 | break; |
|
|
3456 | #endif |
|
|
3457 | |
3871 | case XTerm_Pixmap: |
3458 | case Rxvt_Pixmap: |
|
|
3459 | { |
3872 | if (*str != ';') |
3460 | if (*str != ';') |
3873 | { |
3461 | { |
3874 | #if XPM_BACKGROUND |
3462 | #if XPM_BACKGROUND |
3875 | scale_pixmap (""); /* reset to default scaling */ |
3463 | scale_pixmap (""); /* reset to default scaling */ |
3876 | set_bgPixmap (str); /* change pixmap */ |
3464 | set_bgPixmap (str); /* change pixmap */ |
3877 | #endif |
|
|
3878 | scr_touch (true); |
3465 | scr_touch (true); |
|
|
3466 | #endif |
3879 | } |
3467 | } |
|
|
3468 | |
|
|
3469 | int changed = 0; |
|
|
3470 | |
3880 | while ((str = strchr (str, ';')) != NULL) |
3471 | while ((str = strchr (str, ';')) != NULL) |
3881 | { |
3472 | { |
3882 | str++; |
3473 | str++; |
3883 | #if XPM_BACKGROUND |
3474 | #if XPM_BACKGROUND |
3884 | changed += scale_pixmap (str); |
3475 | changed += scale_pixmap (str); |
3885 | #endif |
3476 | #endif |
3886 | } |
3477 | } |
3887 | |
3478 | |
3888 | if (changed) |
3479 | if (changed) |
3889 | { |
3480 | { |
3890 | #ifdef XPM_BACKGROUND |
3481 | #ifdef XPM_BACKGROUND |
3891 | resize_pixmap (); |
3482 | resize_pixmap (); |
3892 | #endif |
|
|
3893 | scr_touch (true); |
3483 | scr_touch (true); |
|
|
3484 | #endif |
3894 | } |
3485 | } |
|
|
3486 | #if TRANSPARENT && defined(HAVE_AFTERIMAGE) |
|
|
3487 | if (option (Opt_transparent)) |
|
|
3488 | check_our_parents (); |
|
|
3489 | #endif |
|
|
3490 | } |
3895 | break; |
3491 | break; |
3896 | |
3492 | |
3897 | case XTerm_restoreFG: |
3493 | case Rxvt_restoreFG: |
3898 | set_window_color (Color_fg, str); |
3494 | set_window_color (Color_fg, str); |
3899 | break; |
3495 | break; |
3900 | case XTerm_restoreBG: |
3496 | case Rxvt_restoreBG: |
3901 | set_window_color (Color_bg, str); |
3497 | set_window_color (Color_bg, str); |
3902 | break; |
3498 | break; |
3903 | |
3499 | |
3904 | case XTerm_logfile: |
3500 | case XTerm_logfile: |
3905 | // TODO, when secure mode? |
3501 | // TODO, when secure mode? |
3906 | break; |
3502 | break; |
3907 | |
3503 | |
3908 | #ifdef MENUBAR |
|
|
3909 | case URxvt_Menu: |
|
|
3910 | if (OPTION (Opt_insecure)) |
|
|
3911 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3912 | break; |
|
|
3913 | #endif |
|
|
3914 | #if 0 |
3504 | #if 0 |
3915 | case XTerm_dumpscreen: /* no error notices */ |
3505 | case Rxvt_dumpscreen: /* no error notices */ |
3916 | { |
3506 | { |
3917 | int fd; |
3507 | int fd; |
3918 | 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) |
3919 | { |
3509 | { |
3920 | scr_dump (fd); |
3510 | scr_dump (fd); |
… | |
… | |
3931 | case URxvt_italicFont: |
3521 | case URxvt_italicFont: |
3932 | case URxvt_boldItalicFont: |
3522 | case URxvt_boldItalicFont: |
3933 | #endif |
3523 | #endif |
3934 | if (query) |
3524 | if (query) |
3935 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3525 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3936 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3526 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3937 | ? fontset[op - URxvt_font]->fontdesc : "", |
3527 | ? fontset[op - URxvt_font]->fontdesc : "", |
3938 | resp); |
3528 | resp); |
3939 | else |
3529 | else |
3940 | { |
3530 | { |
3941 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3531 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3944 | allocated.push_back ((void *)res); |
3534 | allocated.push_back ((void *)res); |
3945 | set_fonts (); |
3535 | set_fonts (); |
3946 | } |
3536 | } |
3947 | break; |
3537 | break; |
3948 | |
3538 | |
3949 | #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 |
3950 | case URxvt_locale: |
3548 | case URxvt_locale: |
3951 | if (query) |
3549 | if (query) |
3952 | 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); |
3953 | else |
3551 | else |
3954 | { |
3552 | { |
3955 | set_locale (str); |
3553 | set_locale (str); |
3956 | pty.set_utf8_mode (enc_utf8); |
3554 | pty->set_utf8_mode (enc_utf8); |
3957 | init_xlocale (); |
3555 | init_xlocale (); |
3958 | } |
3556 | } |
3959 | break; |
3557 | break; |
3960 | |
3558 | |
3961 | case URxvt_view_up: |
3559 | case URxvt_view_up: |
3962 | case URxvt_view_down: |
3560 | case URxvt_view_down: |
|
|
3561 | { |
3963 | int lines = atoi (str); |
3562 | int lines = atoi (str); |
3964 | |
3563 | |
3965 | if (lines) |
3564 | if (lines) |
3966 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3565 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3967 | else |
3566 | else |
3968 | { |
|
|
3969 | scr_erase_savelines (); |
3567 | scr_erase_savelines (); |
3970 | } |
3568 | } |
3971 | |
3569 | |
|
|
3570 | break; |
|
|
3571 | #endif |
|
|
3572 | |
|
|
3573 | #if ENABLE_PERL |
|
|
3574 | case URxvt_perl: |
|
|
3575 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
|
|
3576 | ; // no responses yet |
3972 | break; |
3577 | break; |
3973 | #endif |
3578 | #endif |
3974 | } |
3579 | } |
3975 | } |
3580 | } |
3976 | /*----------------------------------------------------------------------*/ |
3581 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4007 | return state; |
3612 | return state; |
4008 | } |
3613 | } |
4009 | |
3614 | |
4010 | /* we're not using priv _yet_ */ |
3615 | /* we're not using priv _yet_ */ |
4011 | void |
3616 | void |
4012 | 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) |
4013 | { |
3618 | { |
4014 | unsigned int i, j; |
3619 | unsigned int i, j; |
4015 | int state; |
3620 | int state; |
4016 | |
3621 | |
4017 | static const struct |
3622 | static const struct |
… | |
… | |
4028 | { 5, PrivMode_rVideo }, |
3633 | { 5, PrivMode_rVideo }, |
4029 | { 6, PrivMode_relOrigin }, |
3634 | { 6, PrivMode_relOrigin }, |
4030 | { 7, PrivMode_Autowrap }, |
3635 | { 7, PrivMode_Autowrap }, |
4031 | // 8, bi-directional support mode |
3636 | // 8, bi-directional support mode |
4032 | { 9, PrivMode_MouseX10 }, |
3637 | { 9, PrivMode_MouseX10 }, |
4033 | #ifdef menuBar_esc |
|
|
4034 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4035 | #endif |
|
|
4036 | // 18, 19 printing-related |
3638 | // 18, 19 printing-related |
4037 | { 25, PrivMode_VisibleCursor }, |
3639 | { 25, PrivMode_VisibleCursor }, |
4038 | #ifdef scrollBar_esc |
3640 | #ifdef scrollBar_esc |
4039 | { scrollBar_esc, PrivMode_scrollBar }, |
3641 | { scrollBar_esc, PrivMode_scrollBar }, |
4040 | #endif |
3642 | #endif |
… | |
… | |
4087 | /* extra handling for values with state unkept */ |
3689 | /* extra handling for values with state unkept */ |
4088 | switch (arg[i]) |
3690 | switch (arg[i]) |
4089 | { |
3691 | { |
4090 | #if ENABLE_STYLES |
3692 | #if ENABLE_STYLES |
4091 | case 1021: |
3693 | case 1021: |
4092 | if (mode) |
3694 | set_option (Opt_intensityStyles, mode); |
4093 | SET_OPTION (Opt_intensityStyles); |
|
|
4094 | else |
|
|
4095 | CLR_OPTION (Opt_intensityStyles); |
|
|
4096 | |
3695 | |
4097 | scr_touch (true); |
3696 | scr_touch (true); |
4098 | break; |
3697 | break; |
4099 | #endif |
3698 | #endif |
4100 | case 1048: /* alternative cursor save */ |
3699 | case 1048: /* alternative cursor save */ |
4101 | case 1049: |
3700 | case 1049: |
4102 | if (OPTION (Opt_secondaryScreen)) |
3701 | if (option (Opt_secondaryScreen)) |
4103 | if (mode == 0) |
3702 | if (mode == 0) |
4104 | scr_cursor (RESTORE); |
3703 | scr_cursor (RESTORE); |
4105 | else if (mode == 1) |
3704 | else if (mode == 1) |
4106 | scr_cursor (SAVE); |
3705 | scr_cursor (SAVE); |
4107 | break; |
3706 | break; |
… | |
… | |
4122 | case 3: /* 80/132 */ |
3721 | case 3: /* 80/132 */ |
4123 | if (priv_modes & PrivMode_132OK) |
3722 | if (priv_modes & PrivMode_132OK) |
4124 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
3723 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
4125 | break; |
3724 | break; |
4126 | case 4: /* smooth scrolling */ |
3725 | case 4: /* smooth scrolling */ |
4127 | if (!state) |
3726 | set_option (Opt_jumpScroll, !state); |
4128 | SET_OPTION (Opt_jumpScroll); |
|
|
4129 | else |
|
|
4130 | CLR_OPTION (Opt_jumpScroll); |
|
|
4131 | break; |
3727 | break; |
4132 | case 5: /* reverse video */ |
3728 | case 5: /* reverse video */ |
4133 | scr_rvideo_mode (state); |
3729 | scr_rvideo_mode (state); |
4134 | break; |
3730 | break; |
4135 | case 6: /* relative/absolute origins */ |
3731 | case 6: /* relative/absolute origins */ |
… | |
… | |
4141 | /* 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 */ |
4142 | case 9: /* X10 mouse reporting */ |
3738 | case 9: /* X10 mouse reporting */ |
4143 | if (state) /* orthogonal */ |
3739 | if (state) /* orthogonal */ |
4144 | priv_modes &= ~PrivMode_MouseX11; |
3740 | priv_modes &= ~PrivMode_MouseX11; |
4145 | break; |
3741 | break; |
4146 | #ifdef menuBar_esc |
|
|
4147 | case menuBar_esc: |
|
|
4148 | #ifdef MENUBAR |
|
|
4149 | map_menuBar (state); |
|
|
4150 | #endif |
|
|
4151 | break; |
|
|
4152 | #endif |
|
|
4153 | #ifdef scrollBar_esc |
3742 | #ifdef scrollBar_esc |
4154 | case scrollBar_esc: |
3743 | case scrollBar_esc: |
4155 | if (scrollbar_mapping (state)) |
3744 | if (scrollbar_mapping (state)) |
4156 | { |
3745 | { |
4157 | resize_all_windows (0, 0, 0); |
3746 | resize_all_windows (0, 0, 0); |
… | |
… | |
4176 | #if 0 |
3765 | #if 0 |
4177 | case 1001: |
3766 | case 1001: |
4178 | break; /* X11 mouse highlighting */ |
3767 | break; /* X11 mouse highlighting */ |
4179 | #endif |
3768 | #endif |
4180 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3769 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4181 | if (!state) |
3770 | set_option (Opt_scrollTtyOutput, !state); |
4182 | SET_OPTION (Opt_scrollTtyOutput); |
|
|
4183 | else |
|
|
4184 | CLR_OPTION (Opt_scrollTtyOutput); |
|
|
4185 | break; |
3771 | break; |
4186 | case 1011: /* scroll to bottom on key press */ |
3772 | case 1011: /* scroll to bottom on key press */ |
4187 | if (state) |
3773 | set_option (Opt_scrollTtyKeypress, state); |
4188 | SET_OPTION (Opt_scrollTtyKeypress); |
|
|
4189 | else |
|
|
4190 | CLR_OPTION (Opt_scrollTtyKeypress); |
|
|
4191 | break; |
3774 | break; |
4192 | case 1047: /* secondary screen w/ clearing last */ |
3775 | case 1047: /* secondary screen w/ clearing last */ |
4193 | if (OPTION (Opt_secondaryScreen)) |
3776 | if (option (Opt_secondaryScreen)) |
4194 | if (current_screen != PRIMARY) |
3777 | if (current_screen != PRIMARY) |
4195 | scr_erase_screen (2); |
3778 | scr_erase_screen (2); |
4196 | scr_change_screen (state); |
3779 | scr_change_screen (state); |
4197 | break; |
3780 | break; |
4198 | case 1049: /* secondary screen w/ clearing first */ |
3781 | case 1049: /* secondary screen w/ clearing first */ |
4199 | scr_change_screen (state); |
3782 | scr_change_screen (state); |
4200 | if (OPTION (Opt_secondaryScreen)) |
3783 | if (option (Opt_secondaryScreen)) |
4201 | if (current_screen != PRIMARY) |
3784 | if (current_screen != PRIMARY) |
4202 | scr_erase_screen (2); |
3785 | scr_erase_screen (2); |
4203 | break; |
3786 | break; |
4204 | default: |
3787 | default: |
4205 | break; |
3788 | break; |
… | |
… | |
4333 | scr_color (Color_bg, Color_bg); |
3916 | scr_color (Color_bg, Color_bg); |
4334 | break; |
3917 | break; |
4335 | |
3918 | |
4336 | //case 50: // not variable spacing |
3919 | //case 50: // not variable spacing |
4337 | |
3920 | |
4338 | #ifndef NO_BRIGHTCOLOR |
3921 | #if !ENABLE_MINIMAL |
4339 | case 90: |
3922 | case 90: |
4340 | case 91: /* set bright fg color */ |
3923 | case 91: /* set bright fg color */ |
4341 | case 92: |
3924 | case 92: |
4342 | case 93: |
3925 | case 93: |
4343 | case 94: |
3926 | case 94: |
… | |
… | |
4388 | */ |
3971 | */ |
4389 | void |
3972 | void |
4390 | rxvt_term::tt_printf (const char *fmt,...) |
3973 | rxvt_term::tt_printf (const char *fmt,...) |
4391 | { |
3974 | { |
4392 | va_list arg_ptr; |
3975 | va_list arg_ptr; |
4393 | unsigned char buf[256]; |
3976 | char buf[256]; |
4394 | |
3977 | |
4395 | va_start (arg_ptr, fmt); |
3978 | va_start (arg_ptr, fmt); |
4396 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
3979 | vsnprintf ((char *)buf, 256, fmt, arg_ptr); |
4397 | va_end (arg_ptr); |
3980 | va_end (arg_ptr); |
4398 | tt_write (buf, strlen (buf)); |
3981 | tt_write (buf, strlen (buf)); |
… | |
… | |
4403 | * or generated by us in response to a query ESC sequence. |
3986 | * or generated by us in response to a query ESC sequence. |
4404 | */ |
3987 | */ |
4405 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
3988 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4406 | |
3989 | |
4407 | void |
3990 | void |
4408 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
3991 | rxvt_term::tt_write (const char *data, unsigned int len) |
4409 | { |
3992 | { |
|
|
3993 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
|
|
3994 | return; |
|
|
3995 | |
|
|
3996 | if (pty->pty < 0) |
|
|
3997 | return; |
|
|
3998 | |
4410 | if (v_buflen == 0) |
3999 | if (v_buflen == 0) |
4411 | { |
4000 | { |
4412 | 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)); |
4413 | |
4002 | |
4414 | if ((unsigned int)written == len) |
4003 | if ((unsigned int)written == len) |
4415 | return; |
4004 | return; |
4416 | |
4005 | |
4417 | data += written; |
4006 | data += written; |
4418 | len -= written; |
4007 | len -= written; |
4419 | } |
4008 | } |
4420 | |
4009 | |
4421 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
4010 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4422 | |
4011 | |
4423 | memcpy (v_buffer + v_buflen, data, len); |
4012 | memcpy (v_buffer + v_buflen, data, len); |
4424 | v_buflen += len; |
4013 | v_buflen += len; |
4425 | |
4014 | |
4426 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4015 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
4427 | } |
4016 | } |
4428 | |
4017 | |
4429 | void rxvt_term::pty_write () |
4018 | void rxvt_term::pty_write () |
4430 | { |
4019 | { |
4431 | 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)); |
4432 | |
4021 | |
4433 | if (written > 0) |
4022 | if (written > 0) |
4434 | { |
4023 | { |
4435 | v_buflen -= written; |
4024 | v_buflen -= written; |
4436 | |
4025 | |