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