ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.277 by root, Fri Jan 20 12:16:28 2006 UTC vs.
Revision 1.362 by ayin, Sat Nov 10 16:04:49 2007 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*----------------------------------------------------------------------*
2 * File: command.C 2 * File: command.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
49#include "rxvt.h" 49#include "rxvt.h"
50#include "rxvtperl.h" 50#include "rxvtperl.h"
51#include "version.h" 51#include "version.h"
52#include "command.h" 52#include "command.h"
53 53
54#if HAVE_SCHED_YIELD
55#undef HAVE_SCHED_YIELD // disabled for the time being
56//# include <sched.h>
57#endif
58
59#ifdef KEYSYM_RESOURCE 54#ifdef KEYSYM_RESOURCE
60# include "keyboard.h" 55# include "keyboard.h"
61#endif 56#endif
62 57
63#include <csignal> 58#include <csignal>
59
60#if LINUX_YIELD_HACK
61# include <ctime>
62#endif
64 63
65/*----------------------------------------------------------------------*/ 64/*----------------------------------------------------------------------*/
66 65
67#define IS_CONTROL(ch) !((ch) & 0xffffff60UL) 66#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
68 67
96 XK_Shift_L, 0x21e7, 95 XK_Shift_L, 0x21e7,
97 XK_Shift_R, 0x21e7, 96 XK_Shift_R, 0x21e7,
98 97
99 XK_Shift_Lock, 0x21eb, 98 XK_Shift_Lock, 0x21eb,
100 XK_ISO_Lock, 0x21eb, 99 XK_ISO_Lock, 0x21eb,
101 XK_ISO_Lock, 0x21eb,
102 XK_Caps_Lock, 0x21ec, 100 XK_Caps_Lock, 0x21ec,
103 XK_Num_Lock, 0x21ed, 101 XK_Num_Lock, 0x21ed,
104 XK_ISO_Level3_Shift, 0x21ee, 102 XK_ISO_Level3_Shift, 0x21ee,
105 XK_ISO_Level3_Lock, 0x21ef, 103 XK_ISO_Level3_Lock, 0x21ef,
106 XK_ISO_Group_Lock, 0x21f0, 104 XK_ISO_Group_Lock, 0x21f0,
227# if !UNICODE3 225# if !UNICODE3
228 if (ch >= 0x10000) 226 if (ch >= 0x10000)
229 ch = 0xfffd; 227 ch = 0xfffd;
230# endif 228# endif
231 scr_overlay_set (11, y, ch, r); 229 scr_overlay_set (11, y, ch, r);
230
231 if (WCWIDTH (ch) >= 2)
232 scr_overlay_set (12, y, NOCHAR, r); 232 scr_overlay_set (12, y, NOCHAR, r);
233 } 233 }
234 234
235// {
236// char buf[4+4+3+1];
237// snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y);
238// scr_overlay_set (0, 0, buf);
239// }
235 scr_overlay_set (0, len , attr); 240 scr_overlay_set (0, len , attr);
236 scr_overlay_set (0, len + 1, fname); 241 scr_overlay_set (0, len + 1, fname);
237 242
238 free (fname); 243 free (fname);
239 244
292 297
293 return -1; 298 return -1;
294} 299}
295#endif 300#endif
296 301
297/*{{{ Convert the keypress event into a string */
298void 302void
299rxvt_term::lookup_key (XKeyEvent &ev) 303rxvt_term::key_press (XKeyEvent &ev)
300{ 304{
301 int ctrl, meta, shft, len; 305 int ctrl, meta, shft, len;
302 unsigned int newlen; 306 unsigned int newlen;
303 KeySym keysym; 307 KeySym keysym;
304#ifdef DEBUG_CMD
305 static int debug_key = 1; /* accessible by a debugger only */
306#endif
307 int valid_keysym; 308 int valid_keysym;
308 char kbuf[KBUFSZ]; 309 char kbuf[KBUFSZ];
310
311#if ISO_14755
312 if (iso14755buf & ISO_14755_52)
313 return;
314#endif
309 315
310 /* 316 /*
311 * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an 317 * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an
312 * escape sequence to toggle the Keypad. 318 * escape sequence to toggle the Keypad.
313 * 319 *
493# if ISO_14755 499# if ISO_14755
494 iso14755_51 (0); 500 iso14755_51 (0);
495# endif 501# endif
496 return; 502 return;
497 } 503 }
504 else if (keysym == XK_BackSpace)
505 {
506 iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51;
507# if ISO_14755
508 iso14755_51 (iso14755buf & ISO_14755_MASK);
509# endif
510 return;
511 }
498 else if ((hv = hex_keyval (ev)) >= 0) 512 else if ((hv = hex_keyval (ev)) >= 0)
499 { 513 {
500 iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) 514 iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK)
501 | hv | ISO_14755_51; 515 | hv | ISO_14755_51;
502# if ISO_14755 516# if ISO_14755
504# endif 518# endif
505 return; 519 return;
506 } 520 }
507 else 521 else
508 { 522 {
509# if ENABLE_OVERLAY 523# if ISO_14755
510 scr_overlay_off (); 524 scr_overlay_off ();
511# endif 525# endif
512 iso14755buf = 0; 526 iso14755buf = 0;
513 } 527 }
514 } 528 }
515 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) 529 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
516 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) 530 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))
517 if (!(iso14755buf & ISO_14755_STARTED)) 531 if (!(iso14755buf & ISO_14755_STARTED))
518 { 532 {
519 iso14755buf |= ISO_14755_STARTED; 533 iso14755buf |= ISO_14755_STARTED;
520# if ENABLE_OVERLAY 534# if ISO_14755
521 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); 535 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1);
522 scr_overlay_set (0, 0, "ISO 14755 mode"); 536 scr_overlay_set (0, 0, "ISO 14755 mode");
523# endif 537# endif
524 } 538 }
525#endif 539#endif
526 540
527#ifdef PRINTPIPE 541#ifdef PRINTPIPE
528 if (keysym == XK_Print) 542 if (keysym == XK_Print)
529 { 543 {
530 scr_printscreen (ctrl | shft); 544 scr_printscreen (ctrl | shft);
531 return; 545 return;
533#endif 547#endif
534 548
535 if (keysym >= 0xFF00 && keysym <= 0xFFFF) 549 if (keysym >= 0xFF00 && keysym <= 0xFFFF)
536 { 550 {
537 { 551 {
552 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft;
538 newlen = 1; 553 newlen = 1;
539 switch (keysym) 554 switch (keysym)
540 { 555 {
541#ifndef NO_BACKSPACE_KEY 556#ifndef NO_BACKSPACE_KEY
542 case XK_BackSpace: 557 case XK_BackSpace:
545 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) 560 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace)
546 ^ !!ctrl) ? '\b' : '\177'; 561 ^ !!ctrl) ? '\b' : '\177';
547 kbuf[1] = '\0'; 562 kbuf[1] = '\0';
548 } 563 }
549 else 564 else
550 strcpy (kbuf, key_backspace); 565 strcpy (kbuf, rs[Rs_backspace_key]);
551 break; 566 break;
552#endif 567#endif
553#ifndef NO_DELETE_KEY 568#ifndef NO_DELETE_KEY
554# ifdef XK_KP_Prior 569# ifdef XK_KP_Delete
555 case XK_KP_Delete: 570 case XK_KP_Delete:
556 /* allow shift to override */ 571 /* allow shift to override */
557 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 572 if (kp)
558 { 573 {
559 strcpy (kbuf, "\033On"); 574 strcpy (kbuf, "\033On");
560 break; 575 break;
561 } 576 }
562 /* FALLTHROUGH */ 577 /* FALLTHROUGH */
563# endif 578# endif
564 case XK_Delete: 579 case XK_Delete:
565 strcpy (kbuf, key_delete); 580 strcpy (kbuf, rs[Rs_delete_key]);
566 break; 581 break;
567#endif 582#endif
568 case XK_Tab: 583 case XK_Tab:
569 if (shft) 584 if (shft)
570 strcpy (kbuf, "\033[Z"); 585 strcpy (kbuf, "\033[Z");
581 newlen = 0; 596 newlen = 0;
582 } 597 }
583 break; 598 break;
584 599
585#ifdef XK_KP_Left 600#ifdef XK_KP_Left
601 case XK_KP_Left: /* \033Ot or standard */
586 case XK_KP_Up: /* \033Ox or standard */ 602 case XK_KP_Up: /* \033Ox or standard */
603 case XK_KP_Right: /* \033Ov or standard */
587 case XK_KP_Down: /* \033Or or standard */ 604 case XK_KP_Down: /* \033Or or standard */
588 case XK_KP_Right: /* \033Ov or standard */ 605 if (kp)
589 case XK_KP_Left: /* \033Ot or standard */
590 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
591 { 606 {
592 strcpy (kbuf, "\033OZ"); 607 strcpy (kbuf, "\033OZ");
593 kbuf[2] = "txvr"[keysym - XK_KP_Left]; 608 kbuf[2] = "txvr"[keysym - XK_KP_Left];
594 break; 609 break;
595 } 610 }
618 633
619#ifndef UNSHIFTED_SCROLLKEYS 634#ifndef UNSHIFTED_SCROLLKEYS
620# ifdef XK_KP_Prior 635# ifdef XK_KP_Prior
621 case XK_KP_Prior: 636 case XK_KP_Prior:
622 /* allow shift to override */ 637 /* allow shift to override */
623 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 638 if (kp)
624 { 639 {
625 strcpy (kbuf, "\033Oy"); 640 strcpy (kbuf, "\033Oy");
626 break; 641 break;
627 } 642 }
628 /* FALLTHROUGH */ 643 /* FALLTHROUGH */
631 strcpy (kbuf, "\033[5~"); 646 strcpy (kbuf, "\033[5~");
632 break; 647 break;
633# ifdef XK_KP_Next 648# ifdef XK_KP_Next
634 case XK_KP_Next: 649 case XK_KP_Next:
635 /* allow shift to override */ 650 /* allow shift to override */
636 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 651 if (kp)
637 { 652 {
638 strcpy (kbuf, "\033Os"); 653 strcpy (kbuf, "\033Os");
639 break; 654 break;
640 } 655 }
641 /* FALLTHROUGH */ 656 /* FALLTHROUGH */
644 strcpy (kbuf, "\033[6~"); 659 strcpy (kbuf, "\033[6~");
645 break; 660 break;
646#endif 661#endif
647 case XK_KP_Enter: 662 case XK_KP_Enter:
648 /* allow shift to override */ 663 /* allow shift to override */
649 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 664 if (kp)
650 { 665 {
651 strcpy (kbuf, "\033OM"); 666 strcpy (kbuf, "\033OM");
652 break; 667 break;
653 } 668 }
654 669
697 case XK_KP_6: /* "\033Ov" : "6" */ 712 case XK_KP_6: /* "\033Ov" : "6" */
698 case XK_KP_7: /* "\033Ow" : "7" */ 713 case XK_KP_7: /* "\033Ow" : "7" */
699 case XK_KP_8: /* "\033Ox" : "8" */ 714 case XK_KP_8: /* "\033Ox" : "8" */
700 case XK_KP_9: /* "\033Oy" : "9" */ 715 case XK_KP_9: /* "\033Oy" : "9" */
701 /* allow shift to override */ 716 /* allow shift to override */
702 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 717 if (kp)
703 { 718 {
704 strcpy (kbuf, "\033Oj"); 719 strcpy (kbuf, "\033Oj");
705 kbuf[2] += (keysym - XK_KP_Multiply); 720 kbuf[2] += (keysym - XK_KP_Multiply);
706 } 721 }
707 else 722 else
713 728
714 case XK_Find: 729 case XK_Find:
715 strcpy (kbuf, "\033[1~"); 730 strcpy (kbuf, "\033[1~");
716 break; 731 break;
717 732
718#ifdef XK_KP_End 733#ifdef XK_KP_Insert
719 case XK_KP_Insert: 734 case XK_KP_Insert:
720 /* allow shift to override */ 735 /* allow shift to override */
721 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 736 if (kp)
722 { 737 {
723 strcpy (kbuf, "\033Op"); 738 strcpy (kbuf, "\033Op");
724 break; 739 break;
725 } 740 }
726 /* FALLTHROUGH */ 741 /* FALLTHROUGH */
739 strcpy (kbuf, "\033[4~"); 754 strcpy (kbuf, "\033[4~");
740 break; 755 break;
741#ifdef XK_KP_End 756#ifdef XK_KP_End
742 case XK_KP_End: 757 case XK_KP_End:
743 /* allow shift to override */ 758 /* allow shift to override */
744 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 759 if (kp)
745 { 760 {
746 strcpy (kbuf, "\033Oq"); 761 strcpy (kbuf, "\033Oq");
747 break; 762 break;
748 } 763 }
749 /* FALLTHROUGH */ 764 /* FALLTHROUGH */
752 strcpy (kbuf, KS_END); 767 strcpy (kbuf, KS_END);
753 break; 768 break;
754#ifdef XK_KP_Home 769#ifdef XK_KP_Home
755 case XK_KP_Home: 770 case XK_KP_Home:
756 /* allow shift to override */ 771 /* allow shift to override */
757 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 772 if (kp)
758 { 773 {
759 strcpy (kbuf, "\033Ow"); 774 strcpy (kbuf, "\033Ow");
760 break; 775 break;
761 } 776 }
762 /* FALLTHROUGH */ 777 /* FALLTHROUGH */
870 return; 885 return;
871 886
872 if (len <= 0) 887 if (len <= 0)
873 return; /* not mapped */ 888 return; /* not mapped */
874 889
875 if (OPTION (Opt_scrollTtyKeypress)) 890 if (option (Opt_scrollTtyKeypress))
876 if (view_start) 891 if (view_start)
877 { 892 {
878 view_start = 0; 893 view_start = 0;
879 want_refresh = 1; 894 want_refresh = 1;
880 } 895 }
902 { 917 {
903 const char ch = C0_ESC; 918 const char ch = C0_ESC;
904 tt_write (&ch, 1); 919 tt_write (&ch, 1);
905 } 920 }
906 921
907#if defined(DEBUG_CMD)
908 /* Display keyboard buffer contents */
909 unsigned char *p;
910 int i;
911
912 fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len);
913 for (i = 0, p = kbuf; i < len; i++, p++)
914 fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p);
915 fprintf (stderr, "'\n");
916#endif /* DEBUG_CMD */
917 tt_write (kbuf, (unsigned int)len); 922 tt_write (kbuf, (unsigned int)len);
918} 923}
919/*}}} */ 924
925void
926rxvt_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 ISO_14755
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 ISO_14755
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}
920 1001
921#if defined (KEYSYM_RESOURCE) 1002#if defined (KEYSYM_RESOURCE)
922unsigned int 1003unsigned int
923rxvt_term::cmd_write (const char *str, unsigned int count) 1004rxvt_term::cmd_write (const char *str, unsigned int count)
924{ 1005{
954void 1035void
955rxvt_term::flush () 1036rxvt_term::flush ()
956{ 1037{
957 flush_ev.stop (); 1038 flush_ev.stop ();
958 1039
959#ifdef TRANSPARENT 1040#ifdef HAVE_BG_PIXMAP
960 if (want_full_refresh) 1041 if (bgPixmap.check_clearChanged ())
961 { 1042 {
962 want_full_refresh = 0; 1043// scr_clear (true); This needs to be researched further!
963 scr_clear ();
964 scr_touch (false); 1044 scr_touch (false);
965 } 1045 }
966#endif 1046#endif
967 1047
968 if (want_refresh) 1048 if (want_refresh)
1029void 1109void
1030rxvt_term::flush_cb (time_watcher &w) 1110rxvt_term::flush_cb (time_watcher &w)
1031{ 1111{
1032 make_current (); 1112 make_current ();
1033 1113
1034 refresh_limit = 1;
1035 refresh_count = 0; 1114 refresh_count = 0;
1036 flush (); 1115 flush ();
1037} 1116}
1038 1117
1039#ifdef CURSOR_BLINK 1118#ifdef CURSOR_BLINK
1101 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1180 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1102 } 1181 }
1103} 1182}
1104#endif 1183#endif
1105 1184
1106#if HAVE_SCHED_YIELD 1185#if LINUX_YIELD_HACK
1107static struct event_handler 1186static struct event_handler
1108{ 1187{
1109 check_watcher cw_yield; 1188 check_watcher yield_ev;
1110 1189
1111 void yield (check_watcher &w) 1190 void yield_cb (check_watcher &w)
1112 { 1191 {
1113 sched_yield (); 1192 // this should really be sched_yield(), but the linux guys thought
1193 // that giving a process calling sched_yield () less cpu time than
1194 // ones with high nice levels is a useful thing to do. It surely is is
1195 // allowed by the sus... as is returning ENOSYS.
1196
1197 struct timespec ts = { 0, 0 };
1198 nanosleep (&ts, 0);
1199
1114 w.stop (); 1200 w.stop ();
1115 } 1201 }
1116 1202
1117 event_handler () 1203 event_handler ()
1118 : cw_yield (this, &event_handler::yield) 1204 : yield_ev (this, &event_handler::yield_cb)
1119 { 1205 {
1120 } 1206 }
1121} event_handler; 1207} event_handler;
1122#endif 1208#endif
1123 1209
1143 cmdbuf_endp += r; 1229 cmdbuf_endp += r;
1144 return true; 1230 return true;
1145 } 1231 }
1146 else if (r < 0 && (errno == EAGAIN || errno == EINTR)) 1232 else if (r < 0 && (errno == EAGAIN || errno == EINTR))
1147 { 1233 {
1148#if HAVE_SCHED_YIELD 1234#if LINUX_YIELD_HACK
1149 if (display->is_local) 1235 if (display->is_local)
1150 event_handler.cw_yield.start (); 1236 event_handler.yield_ev.start ();
1151#endif 1237#endif
1152 } 1238 }
1153 else 1239 else
1154 { 1240 {
1155 pty_ev.stop (); 1241 pty_ev.stop ();
1156 1242
1157 if (!OPTION (Opt_hold)) 1243 if (!option (Opt_hold))
1158 destroy (); 1244 destroy ();
1159 } 1245 }
1160 1246
1161 return false; 1247 return false;
1162} 1248}
1163 1249
1164void 1250void
1165rxvt_term::pty_cb (io_watcher &w, short revents) 1251rxvt_term::pty_cb (io_watcher &w, short revents)
1177} 1263}
1178 1264
1179void 1265void
1180rxvt_term::pointer_unblank () 1266rxvt_term::pointer_unblank ()
1181{ 1267{
1182 XDefineCursor (display->display, vt, TermWin_cursor); 1268 XDefineCursor (dpy, vt, TermWin_cursor);
1183 recolour_cursor (); 1269 recolour_cursor ();
1184 1270
1185#ifdef POINTER_BLANK 1271#ifdef POINTER_BLANK
1186 hidden_pointer = 0; 1272 hidden_pointer = 0;
1187 1273
1188 if (OPTION (Opt_pointerBlank)) 1274 if (option (Opt_pointerBlank))
1189 pointer_ev.start (NOW + pointerBlankDelay); 1275 pointer_ev.start (NOW + pointerBlankDelay);
1190#endif 1276#endif
1191} 1277}
1192 1278
1193#ifdef POINTER_BLANK 1279#ifdef POINTER_BLANK
1194void 1280void
1195rxvt_term::pointer_blank () 1281rxvt_term::pointer_blank ()
1196{ 1282{
1197 if (!OPTION (Opt_pointerBlank)) 1283 if (!option (Opt_pointerBlank))
1198 return; 1284 return;
1199 1285
1200 XDefineCursor (display->display, vt, display->blank_cursor); 1286 XDefineCursor (dpy, vt, display->blank_cursor);
1201 XFlush (display->display); 1287 XFlush (dpy);
1202 1288
1203 hidden_pointer = 1; 1289 hidden_pointer = 1;
1204} 1290}
1205 1291
1206void 1292void
1215void 1301void
1216rxvt_term::mouse_report (XButtonEvent &ev) 1302rxvt_term::mouse_report (XButtonEvent &ev)
1217{ 1303{
1218 int button_number, key_state = 0; 1304 int button_number, key_state = 0;
1219 int x, y; 1305 int x, y;
1306 int code = 32;
1220 1307
1221 x = ev.x; 1308 x = Pixel2Col (ev.x);
1222 y = ev.y; 1309 y = Pixel2Row (ev.y);
1223 pixel_position (&x, &y); 1310 if (ev.type == MotionNotify) {
1311 if (x == mouse_row && y == mouse_col)
1312 return;
1313 mouse_row = x;
1314 mouse_col = y;
1315 code += 32;
1316 }
1224 1317
1225 if (MEvent.button == AnyButton) 1318 if (MEvent.button == AnyButton)
1226 button_number = 3; 1319 button_number = 3;
1227 else 1320 else
1228 { 1321 {
1274 x + 1, 1367 x + 1,
1275 y + 1); 1368 y + 1);
1276#endif 1369#endif
1277 1370
1278 tt_printf ("\033[M%c%c%c", 1371 tt_printf ("\033[M%c%c%c",
1279 (32 + button_number + key_state), 1372 (code + button_number + key_state),
1280 (32 + x + 1), 1373 (32 + x + 1),
1281 (32 + y + 1)); 1374 (32 + y + 1));
1282} 1375}
1283
1284#ifdef USING_W11LIB
1285void
1286rxvt_W11_process_x_event (XEvent *ev)
1287{
1288 rxvt_t *r = rxvt_get_r ();
1289
1290 x_cb (*ev);
1291}
1292#endif
1293 1376
1294/*{{{ process an X event */ 1377/*{{{ process an X event */
1295void 1378void
1296rxvt_term::x_cb (XEvent &ev) 1379rxvt_term::x_cb (XEvent &ev)
1297{ 1380{
1298 make_current (); 1381 make_current ();
1299 1382
1300 dDisp; 1383 dLocal (Display *, dpy);
1301 1384
1302 if (ev.xany.window == vt 1385 if (ev.xany.window == vt
1303 && SHOULD_INVOKE (HOOK_X_EVENT) 1386 && SHOULD_INVOKE (HOOK_X_EVENT)
1304 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) 1387 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END)))
1305 return; 1388 return;
1310 unsigned int unused_mask; 1393 unsigned int unused_mask;
1311 1394
1312 switch (ev.type) 1395 switch (ev.type)
1313 { 1396 {
1314 case KeyPress: 1397 case KeyPress:
1315#if ISO_14755 1398 key_press (ev.xkey);
1316 if (!(iso14755buf & ISO_14755_52))
1317#endif
1318 lookup_key (ev.xkey);
1319
1320 break; 1399 break;
1321 1400
1322 case KeyRelease: 1401 case KeyRelease:
1323 { 1402 key_release (ev.xkey);
1324#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
1325 KeySym keysym;
1326
1327 keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1328#endif
1329
1330#if ENABLE_FRILLS || ISO_14755
1331 // ISO 14755 support
1332 if (iso14755buf)
1333 if (iso14755buf & ISO_14755_52)
1334 {
1335# if ENABLE_OVERLAY
1336 scr_overlay_off ();
1337# endif
1338# if ISO_14755
1339 // iso14755 part 5.2 handling: release time
1340 // first: controls
1341 if ((ev.xkey.state & ControlMask)
1342 && ((keysym >= 0x40 && keysym <= 0x5f)
1343 || (keysym >= 0x61 && keysym <= 0x7f)))
1344 {
1345 iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f);
1346 commit_iso14755 ();
1347 goto skip_switch;
1348 }
1349
1350 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1351 if (i[0] == keysym)
1352 {
1353 iso14755buf = ISO_14755_51 | i[1];
1354 commit_iso14755 ();
1355 goto skip_switch;
1356 }
1357
1358 scr_bell ();
1359# endif
1360 iso14755buf = 0;
1361 break;
1362 }
1363 else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask))
1364 {
1365# if ENABLE_OVERLAY
1366 scr_overlay_off ();
1367# endif
1368 if (iso14755buf & ISO_14755_51)
1369 commit_iso14755 ();
1370#if ISO_14755
1371 else if (iso14755buf & ISO_14755_STARTED)
1372 {
1373 iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair
1374
1375 scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1);
1376 scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE");
1377 }
1378# endif
1379 else
1380 iso14755buf = 0;
1381 }
1382#endif
1383
1384 if (ev.xany.window == vt
1385 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END)))
1386 break;
1387
1388#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1389 if (!(ev.xkey.state & ControlMask))
1390 slip_wheel_ev.stop ();
1391 else if (keysym == XK_Control_L || keysym == XK_Control_R)
1392 mouse_slip_wheel_speed = 0;
1393#endif
1394 break; 1403 break;
1395 }
1396 1404
1397 case ButtonPress: 1405 case ButtonPress:
1398 button_press (ev.xbutton); 1406 button_press (ev.xbutton);
1399 break; 1407 break;
1400 1408
1415 if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) 1423 if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END)))
1416 destroy (); 1424 destroy ();
1417 } 1425 }
1418#if ENABLE_EWMH 1426#if ENABLE_EWMH
1419 else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) 1427 else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING])
1420 XSendEvent (disp, ev.xclient.window = display->root, 1428 XSendEvent (dpy, ev.xclient.window = display->root,
1421 False, SubstructureRedirectMask | SubstructureNotifyMask, 1429 False, SubstructureRedirectMask | SubstructureNotifyMask,
1422 &ev); 1430 &ev);
1423#endif 1431#endif
1424 } 1432 }
1425 } 1433 }
1431 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) 1439 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1432 focus_out (); 1440 focus_out ();
1433 } 1441 }
1434#endif 1442#endif
1435 } 1443 }
1436 break;
1437
1438 case MappingNotify:
1439 XRefreshKeyboardMapping (&ev.xmapping);
1440 break; 1444 break;
1441 1445
1442 /* 1446 /*
1443 * XXX: this is not the _current_ arrangement 1447 * XXX: this is not the _current_ arrangement
1444 * Here's my conclusion: 1448 * Here's my conclusion:
1463 break; 1467 break;
1464 } 1468 }
1465 break; 1469 break;
1466 1470
1467 case FocusIn: 1471 case FocusIn:
1472 if (ev.xfocus.detail != NotifyInferior
1473 && ev.xfocus.detail != NotifyPointer
1474 && ev.xfocus.mode != NotifyGrab)
1468 focus_in (); 1475 focus_in ();
1469 break; 1476 break;
1470 1477
1471 case FocusOut: 1478 case FocusOut:
1479 if (ev.xfocus.detail != NotifyInferior
1480 && ev.xfocus.detail != NotifyPointer
1481 && ev.xfocus.mode != NotifyGrab)
1472 focus_out (); 1482 focus_out ();
1473 break; 1483 break;
1474 1484
1475 case ConfigureNotify: 1485 case ConfigureNotify:
1486 /* fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n",
1487 ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y,
1488 szHint.width, szHint.height); */
1476 if (ev.xconfigure.window == parent[0]) 1489 if (ev.xconfigure.window == parent[0])
1477 { 1490 {
1478 while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) 1491 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1479 ; 1492 ;
1480 1493
1481 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1494 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1482 { 1495 {
1483 seen_resize = 1; 1496 seen_resize = 1;
1484 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1497 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1485 } 1498 }
1486 1499 else
1500 {
1501#ifdef HAVE_BG_PIXMAP
1502 if (bgPixmap.window_position_sensitive ())
1503 update_background ();
1504#endif
1505 }
1487 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1506 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1488
1489#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1490 if (OPTION (Opt_transparent))
1491 check_our_parents ();
1492#endif
1493 } 1507 }
1494 break; 1508 break;
1495 1509
1496 case PropertyNotify: 1510 case PropertyNotify:
1511 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END)))
1497 if (ev.xproperty.atom == xa[XA_VT_SELECTION] 1512 if (ev.xproperty.atom == xa[XA_VT_SELECTION]
1498 && ev.xproperty.state == PropertyNewValue) 1513 && ev.xproperty.state == PropertyNewValue)
1499 selection_property (ev.xproperty.window, ev.xproperty.atom); 1514 selection_property (ev.xproperty.window, ev.xproperty.atom);
1500 1515
1501 break; 1516 break;
1502 1517
1503 case SelectionClear: 1518 case SelectionClear:
1504 selection_clear (); 1519 selection_clear ();
1526#ifdef TEXT_BLINK 1541#ifdef TEXT_BLINK
1527 text_blink_ev.stop (); 1542 text_blink_ev.stop ();
1528#endif 1543#endif
1529 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1544 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1530 break; 1545 break;
1531
1532#ifdef TRANSPARENT
1533 case ReparentNotify:
1534 rootwin_cb (ev);
1535 break;
1536#endif /* TRANSPARENT */
1537 1546
1538 case GraphicsExpose: 1547 case GraphicsExpose:
1539 case Expose: 1548 case Expose:
1540 if (ev.xany.window == vt) 1549 if (ev.xany.window == vt)
1541 { 1550 {
1542 do 1551 do
1552 {
1543 scr_expose (ev.xexpose.x, ev.xexpose.y, 1553 scr_expose (ev.xexpose.x, ev.xexpose.y,
1544 ev.xexpose.width, ev.xexpose.height, False); 1554 ev.xexpose.width, ev.xexpose.height, False);
1555 }
1545 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); 1556 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev));
1546 1557
1547 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; 1558 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1548 1559
1549 while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) 1560 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1561 {
1550 scr_expose (ev.xexpose.x, ev.xexpose.y, 1562 scr_expose (ev.xexpose.x, ev.xexpose.y,
1551 ev.xexpose.width, ev.xexpose.height, False); 1563 ev.xexpose.width, ev.xexpose.height, False);
1552 1564 }
1553 want_refresh = 1; 1565 want_refresh = 1;
1554 } 1566 }
1555 else 1567 else
1556 { 1568 {
1557 XEvent unused_event; 1569 XEvent unused_event;
1558 1570
1559 while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) 1571 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event))
1560 ; 1572 ;
1561 while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) 1573 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1562 ; 1574 ;
1563 1575
1564 if (isScrollbarWindow (ev.xany.window)) 1576 if (isScrollbarWindow (ev.xany.window))
1565 { 1577 {
1566 scrollBar.setIdle (); 1578 scrollBar.setIdle ();
1567 scrollbar_show (0); 1579 scrollbar_show (0);
1568 } 1580 }
1569
1570#ifdef TRANSPARENT
1571 if (am_transparent && ev.xany.window == parent[0])
1572 XClearWindow (disp, ev.xany.window);
1573#endif
1574 } 1581 }
1575 break; 1582 break;
1576 1583
1577 case MotionNotify: 1584 case MotionNotify:
1578#ifdef POINTER_BLANK 1585#ifdef POINTER_BLANK
1579 if (hidden_pointer) 1586 if (hidden_pointer)
1580 pointer_unblank (); 1587 pointer_unblank ();
1581#endif 1588#endif
1589 if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask))
1590 || priv_modes & PrivMode_MouseAnyEvent)
1591 mouse_report (ev.xbutton);
1582 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1592 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1583 break; 1593 break;
1584 1594
1585 if (ev.xany.window == vt) 1595 if (ev.xany.window == vt)
1586 { 1596 {
1587 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) 1597 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1588 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1598 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1589 ; // nop 1599 ; // nop
1590 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1600 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1591 { 1601 {
1592 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1602 while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev))
1593 ; 1603 ;
1594 1604
1595 XQueryPointer (disp, vt, 1605 XQueryPointer (dpy, vt,
1596 &unused_root, &unused_child, 1606 &unused_root, &unused_child,
1597 &unused_root_x, &unused_root_y, 1607 &unused_root_x, &unused_root_y,
1598 &ev.xbutton.x, &ev.xbutton.y, 1608 &ev.xbutton.x, &ev.xbutton.y,
1599 &ev.xbutton.state); 1609 &ev.xbutton.state);
1600#ifdef MOUSE_THRESHOLD 1610#ifdef MOUSE_THRESHOLD
1664#endif 1674#endif
1665 } 1675 }
1666 } 1676 }
1667 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1677 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ())
1668 { 1678 {
1669 while (XCheckTypedWindowEvent (disp, scrollBar.win, 1679 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1670 MotionNotify, &ev)) 1680 MotionNotify, &ev))
1671 ; 1681 ;
1672 1682
1673 XQueryPointer (disp, scrollBar.win, 1683 XQueryPointer (dpy, scrollBar.win,
1674 &unused_root, &unused_child, 1684 &unused_root, &unused_child,
1675 &unused_root_x, &unused_root_y, 1685 &unused_root_x, &unused_root_y,
1676 &ev.xbutton.x, &ev.xbutton.y, 1686 &ev.xbutton.x, &ev.xbutton.y,
1677 &unused_mask); 1687 &unused_mask);
1678 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1688 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1679 scrollbar_size ()); 1689 scrollbar_size ());
1680 want_refresh = 1; 1690 want_refresh = 1;
1681 refresh_limit = 0;
1682 scrollbar_show (1); 1691 scrollbar_show (1);
1683 } 1692 }
1684 break; 1693 break;
1685 } 1694 }
1686 1695
1687skip_switch: ;
1688
1689#if defined(CURSOR_BLINK) 1696#if defined(CURSOR_BLINK)
1690 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) 1697 if (option (Opt_cursorBlink) && ev.type == KeyPress)
1691 { 1698 {
1692 if (hidden_cursor) 1699 if (hidden_cursor)
1693 { 1700 {
1694 hidden_cursor = 0; 1701 hidden_cursor = 0;
1695 want_refresh = 1; 1702 want_refresh = 1;
1698 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1705 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1699 } 1706 }
1700#endif 1707#endif
1701 1708
1702#if defined(POINTER_BLANK) 1709#if defined(POINTER_BLANK)
1703 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) 1710 if (option (Opt_pointerBlank) && pointerBlankDelay > 0)
1704 { 1711 {
1705 if (ev.type == MotionNotify 1712 if (ev.type == MotionNotify
1706 || ev.type == ButtonPress 1713 || ev.type == ButtonPress
1707 || ev.type == ButtonRelease) 1714 || ev.type == ButtonRelease)
1708 if (hidden_pointer) 1715 if (hidden_pointer)
1720 if (!focus) 1727 if (!focus)
1721 { 1728 {
1722 focus = 1; 1729 focus = 1;
1723 want_refresh = 1; 1730 want_refresh = 1;
1724 1731
1725 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1732 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1726 1733
1727#if USE_XIM 1734#if USE_XIM
1728 if (Input_Context != NULL) 1735 if (Input_Context != NULL)
1729 { 1736 {
1730 IMSetStatusPosition (); 1737 IMSetPosition ();
1731 XSetICFocus (Input_Context); 1738 XSetICFocus (Input_Context);
1732 } 1739 }
1733#endif 1740#endif
1734#if CURSOR_BLINK 1741#if CURSOR_BLINK
1735 if (OPTION (Opt_cursorBlink)) 1742 if (option (Opt_cursorBlink))
1736 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1743 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL);
1737#endif 1744#endif
1738#if OFF_FOCUS_FADING 1745#if OFF_FOCUS_FADING
1739 if (rs[Rs_fade]) 1746 if (rs[Rs_fade])
1740 { 1747 {
1741 pix_colors = pix_colors_focused; 1748 pix_colors = pix_colors_focused;
1742 scr_recolour (); 1749 scr_recolour ();
1743 } 1750 }
1744#endif 1751#endif
1752#if ENABLE_FRILLS
1753 if (option (Opt_urgentOnBell))
1754 {
1755 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1756 {
1757 h->flags &= ~XUrgencyHint;
1758 XSetWMHints (dpy, parent[0], h);
1759 }
1760 }
1761#endif
1745 } 1762 }
1746} 1763}
1747 1764
1748void 1765void
1749rxvt_term::focus_out () 1766rxvt_term::focus_out ()
1757 1774
1758#if ENABLE_FRILLS || ISO_14755 1775#if ENABLE_FRILLS || ISO_14755
1759 if (iso14755buf) 1776 if (iso14755buf)
1760 { 1777 {
1761 iso14755buf = 0; 1778 iso14755buf = 0;
1762# if ENABLE_OVERLAY 1779# if ISO_14755
1763 scr_overlay_off (); 1780 scr_overlay_off ();
1764# endif 1781# endif
1765 } 1782 }
1766#endif 1783#endif
1767#if USE_XIM 1784#if USE_XIM
1768 if (Input_Context != NULL) 1785 if (Input_Context != NULL)
1769 XUnsetICFocus (Input_Context); 1786 XUnsetICFocus (Input_Context);
1770#endif 1787#endif
1771#if CURSOR_BLINK 1788#if CURSOR_BLINK
1772 if (OPTION (Opt_cursorBlink)) 1789 if (option (Opt_cursorBlink))
1773 cursor_blink_ev.stop (); 1790 cursor_blink_ev.stop ();
1774 hidden_cursor = 0; 1791 hidden_cursor = 0;
1775#endif 1792#endif
1776#if OFF_FOCUS_FADING 1793#if OFF_FOCUS_FADING
1777 if (rs[Rs_fade]) 1794 if (rs[Rs_fade])
1781 } 1798 }
1782#endif 1799#endif
1783 } 1800 }
1784} 1801}
1785 1802
1786#if TRANSPARENT 1803void
1804rxvt_term::update_fade_color (unsigned int idx)
1805{
1806#if OFF_FOCUS_FADING
1807 if (rs[Rs_fade])
1808 {
1809 rgba c;
1810 pix_colors [Color_fade].get (c);
1811 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c);
1812 }
1813#endif
1814}
1815
1816#if ENABLE_TRANSPARENCY || ENABLE_PERL
1787void 1817void
1788rxvt_term::rootwin_cb (XEvent &ev) 1818rxvt_term::rootwin_cb (XEvent &ev)
1789{ 1819{
1790 make_current (); 1820 make_current ();
1791 1821
1822 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1823 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END)))
1824 return;
1825
1826# if ENABLE_TRANSPARENCY
1792 switch (ev.type) 1827 switch (ev.type)
1793 { 1828 {
1794 case PropertyNotify: 1829 case PropertyNotify:
1795 /* 1830 /*
1796 * if user used some Esetroot compatible prog to set the root bg, 1831 * if user used some Esetroot compatible prog to set the root bg,
1797 * use the property to determine the pixmap. We use it later on. 1832 * use the property to determine the pixmap. We use it later on.
1798 */ 1833 */
1799 if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] 1834 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1800 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1835 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1801 return; 1836 {
1802 1837 bgPixmap.set_root_pixmap ();
1803 /* FALLTHROUGH */ 1838 update_background ();
1804 case ReparentNotify: 1839 }
1805 if (OPTION (Opt_transparent) && check_our_parents () && am_transparent)
1806 want_refresh = want_full_refresh = 1;
1807 break; 1840 break;
1808 } 1841 }
1842# endif
1809} 1843}
1810#endif 1844#endif
1811 1845
1812void 1846void
1813rxvt_term::button_press (XButtonEvent &ev) 1847rxvt_term::button_press (XButtonEvent &ev)
1822 /* 1856 /*
1823 * VT window processing of button press 1857 * VT window processing of button press
1824 */ 1858 */
1825 if (ev.window == vt) 1859 if (ev.window == vt)
1826 { 1860 {
1861 if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END)))
1862 return;
1863
1827#if ISO_14755 1864#if ISO_14755
1828 // 5.4 1865 // 5.4
1829 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) 1866 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54))
1830 { 1867 {
1831 iso14755_54 (ev.x, ev.y); 1868 iso14755_54 (ev.x, ev.y);
1873 else 1910 else
1874 { 1911 {
1875 if (ev.button != MEvent.button) 1912 if (ev.button != MEvent.button)
1876 MEvent.clicks = 0; 1913 MEvent.clicks = 0;
1877 1914
1878 if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END)))
1879 switch (ev.button) 1915 switch (ev.button)
1880 { 1916 {
1881 case Button1: 1917 case Button1:
1882 /* allow meta + click to select rectangular areas */ 1918 /* allow meta + click to select rectangular areas */
1883 /* should be done in screen.C */ 1919 /* should be done in screen.C */
1884#if ENABLE_FRILLS 1920#if ENABLE_FRILLS
1885 selection.rect = !!(ev.state & ModMetaMask); 1921 selection.rect = !!(ev.state & ModMetaMask);
1886#else 1922#else
1887 selection.rect = false; 1923 selection.rect = false;
1888#endif 1924#endif
1889 1925
1890 /* allow shift+left click to extend selection */ 1926 /* allow shift+left click to extend selection */
1891 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) 1927 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
1892 { 1928 {
1893 if (MEvent.button == Button1 && clickintime) 1929 if (MEvent.button == Button1 && clickintime)
1894 selection_rotate (ev.x, ev.y); 1930 selection_rotate (ev.x, ev.y);
1895 else 1931 else
1896 selection_extend (ev.x, ev.y, 1); 1932 selection_extend (ev.x, ev.y, 1);
1897 } 1933 }
1898 else 1934 else
1899 { 1935 {
1900 if (MEvent.button == Button1 && clickintime) 1936 if (MEvent.button == Button1 && clickintime)
1901 MEvent.clicks++; 1937 MEvent.clicks++;
1902 else 1938 else
1903 MEvent.clicks = 1; 1939 MEvent.clicks = 1;
1904 1940
1905 selection_click (MEvent.clicks, ev.x, ev.y); 1941 selection_click (MEvent.clicks, ev.x, ev.y);
1906 } 1942 }
1907 1943
1908 MEvent.button = Button1; 1944 MEvent.button = Button1;
1909 break; 1945 break;
1910 1946
1911 case Button3: 1947 case Button3:
1912 if (MEvent.button == Button3 && clickintime) 1948 if (MEvent.button == Button3 && clickintime)
1913 selection_rotate (ev.x, ev.y); 1949 selection_rotate (ev.x, ev.y);
1914 else 1950 else
1915 selection_extend (ev.x, ev.y, 1); 1951 selection_extend (ev.x, ev.y, 1);
1916 1952
1917 MEvent.button = Button3; 1953 MEvent.button = Button3;
1918 break; 1954 break;
1919 } 1955 }
1920 } 1956 }
1921 1957
1922 MEvent.time = ev.time; 1958 MEvent.time = ev.time;
1923 return; 1959 return;
1924 } 1960 }
1925 1961
2088 sel_scroll_ev.stop(); 2124 sel_scroll_ev.stop();
2089#endif 2125#endif
2090 2126
2091 if (ev.window == vt) 2127 if (ev.window == vt)
2092 { 2128 {
2129 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2130 return;
2131
2093#if ISO_14755 2132#if ISO_14755
2094 // 5.4 2133 // 5.4
2095 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) 2134 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54))
2096 return; 2135 return;
2097#endif 2136#endif
2137
2098 if (reportmode) 2138 if (reportmode)
2099 { 2139 {
2100 /* mouse report from vt window */ 2140 /* mouse report from vt window */
2101 /* don't report release of wheel "buttons" */ 2141 /* don't report release of wheel "buttons" */
2102 if (ev.button >= 4) 2142 if (ev.button >= 4)
2126 if (priv_modes & PrivMode_mouse_report 2166 if (priv_modes & PrivMode_mouse_report
2127 && bypass_keystate 2167 && bypass_keystate
2128 && ev.button == Button1 && MEvent.clicks <= 1) 2168 && ev.button == Button1 && MEvent.clicks <= 1)
2129 selection_extend (ev.x, ev.y, 0); 2169 selection_extend (ev.x, ev.y, 0);
2130 2170
2131 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2132 return;
2133
2134 switch (ev.button) 2171 switch (ev.button)
2135 { 2172 {
2136 case Button1: 2173 case Button1:
2137 case Button3: 2174 case Button3:
2138 selection_make (ev.time); 2175 selection_make (ev.time);
2139 break; 2176 break;
2140 2177
2141 case Button2: 2178 case Button2:
2142 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? 2179 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window?
2143 selection_request (ev.time, ev.state & ShiftMask ? Sel_Clipboard : Sel_Primary); 2180 selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary);
2144 break; 2181 break;
2145 2182
2146#ifdef MOUSE_WHEEL 2183#ifdef MOUSE_WHEEL
2147 case Button4: 2184 case Button4:
2148 case Button5: 2185 case Button5:
2152 2189
2153 v = ev.button == Button4 ? UP : DN; 2190 v = ev.button == Button4 ? UP : DN;
2154 2191
2155 if (ev.state & ShiftMask) 2192 if (ev.state & ShiftMask)
2156 i = 1; 2193 i = 1;
2157 else if (OPTION (Opt_mouseWheelScrollPage)) 2194 else if (option (Opt_mouseWheelScrollPage))
2158 i = nrow - 1; 2195 i = nrow - 1;
2159 else 2196 else
2160 i = 5; 2197 i = 5;
2161 2198
2162# ifdef MOUSE_SLIP_WHEELING 2199# ifdef MOUSE_SLIP_WHEELING
2183 break; 2220 break;
2184#endif 2221#endif
2185 } 2222 }
2186 } 2223 }
2187} 2224}
2188
2189#ifdef TRANSPARENT
2190#if TINTING
2191/* taken from aterm-0.4.2 */
2192
2193typedef uint32_t RUINT32T;
2194
2195void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm)
2196{
2197 int sh_r, sh_g, sh_b;
2198 RUINT32T mask_r, mask_g, mask_b;
2199 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
2200 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
2201 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
2202 int i;
2203
2204 Visual *visual = display->visual;
2205
2206 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
2207
2208 /* for convenience */
2209 mask_r = visual->red_mask;
2210 mask_g = visual->green_mask;
2211 mask_b = visual->blue_mask;
2212
2213 /* boring lookup table pre-initialization */
2214 switch (srcImage->bits_per_pixel) {
2215 case 15:
2216 if ((mask_r != 0x7c00) ||
2217 (mask_g != 0x03e0) ||
2218 (mask_b != 0x001f))
2219 return;
2220 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32));
2221 lookup_r = lookup;
2222 lookup_g = lookup+32;
2223 lookup_b = lookup+32+32;
2224 sh_r = 10;
2225 sh_g = 5;
2226 sh_b = 0;
2227 break;
2228 case 16:
2229 if ((mask_r != 0xf800) ||
2230 (mask_g != 0x07e0) ||
2231 (mask_b != 0x001f))
2232 return;
2233 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32));
2234 lookup_r = lookup;
2235 lookup_g = lookup+32;
2236 lookup_b = lookup+32+64;
2237 sh_r = 11;
2238 sh_g = 5;
2239 sh_b = 0;
2240 break;
2241 case 24:
2242 if ((mask_r != 0xff0000) ||
2243 (mask_g != 0x00ff00) ||
2244 (mask_b != 0x0000ff))
2245 return;
2246 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2247 lookup_r = lookup;
2248 lookup_g = lookup+256;
2249 lookup_b = lookup+256+256;
2250 sh_r = 16;
2251 sh_g = 8;
2252 sh_b = 0;
2253 break;
2254 case 32:
2255 if ((mask_r != 0xff0000) ||
2256 (mask_g != 0x00ff00) ||
2257 (mask_b != 0x0000ff))
2258 return;
2259 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2260 lookup_r = lookup;
2261 lookup_g = lookup+256;
2262 lookup_b = lookup+256+256;
2263 sh_r = 16;
2264 sh_g = 8;
2265 sh_b = 0;
2266 break;
2267 default:
2268 return; /* we do not support this color depth */
2269 }
2270
2271 /* prepare limits for color transformation (each channel is handled separately) */
2272 if (shade < 0) {
2273 shade = -shade;
2274 if (shade < 0) shade = 0;
2275 if (shade > 100) shade = 100;
2276
2277 lower_lim_r = 65535-rm;
2278 lower_lim_g = 65535-gm;
2279 lower_lim_b = 65535-bm;
2280
2281 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100);
2282 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
2283 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
2284
2285 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
2286 } else {
2287 if (shade < 0) shade = 0;
2288 if (shade > 100) shade = 100;
2289
2290 lower_lim_r = lower_lim_g = lower_lim_b = 0;
2291
2292 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
2293 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);
2294 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100);
2295 }
2296
2297 /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */
2298 if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 ))
2299 {
2300 unsigned int tmp;
2301
2302 tmp = lower_lim_r;
2303 lower_lim_r = lower_lim_b;
2304 lower_lim_b = tmp;
2305
2306 tmp = upper_lim_r;
2307 upper_lim_r = upper_lim_b;
2308 upper_lim_b = tmp;
2309 }
2310
2311 /* fill our lookup tables */
2312 for (i = 0; i <= mask_r>>sh_r; i++)
2313 {
2314 RUINT32T tmp;
2315 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r));
2316 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r);
2317 lookup_r[i] = (tmp/65535)<<sh_r;
2318 }
2319 for (i = 0; i <= mask_g>>sh_g; i++)
2320 {
2321 RUINT32T tmp;
2322 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g));
2323 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g);
2324 lookup_g[i] = (tmp/65535)<<sh_g;
2325 }
2326 for (i = 0; i <= mask_b>>sh_b; i++)
2327 {
2328 RUINT32T tmp;
2329 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b));
2330 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b);
2331 lookup_b[i] = (tmp/65535)<<sh_b;
2332 }
2333
2334 /* apply table to input image (replacing colors by newly calculated ones) */
2335 switch (srcImage->bits_per_pixel)
2336 {
2337 case 15:
2338 {
2339 unsigned short *p1, *pf, *p, *pl;
2340 p1 = (unsigned short *) srcImage->data;
2341 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2342 while (p1 < pf)
2343 {
2344 p = p1;
2345 pl = p1 + srcImage->width;
2346 for (; p < pl; p++)
2347 {
2348 *p = lookup_r[(*p & 0x7c00)>>10] |
2349 lookup_g[(*p & 0x03e0)>> 5] |
2350 lookup_b[(*p & 0x001f)];
2351 }
2352 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2353 }
2354 break;
2355 }
2356 case 16:
2357 {
2358 unsigned short *p1, *pf, *p, *pl;
2359 p1 = (unsigned short *) srcImage->data;
2360 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2361 while (p1 < pf)
2362 {
2363 p = p1;
2364 pl = p1 + srcImage->width;
2365 for (; p < pl; p++)
2366 {
2367 *p = lookup_r[(*p & 0xf800)>>11] |
2368 lookup_g[(*p & 0x07e0)>> 5] |
2369 lookup_b[(*p & 0x001f)];
2370 }
2371 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2372 }
2373 break;
2374 }
2375 case 24:
2376 {
2377 unsigned char *p1, *pf, *p, *pl;
2378 p1 = (unsigned char *) srcImage->data;
2379 pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2380 while (p1 < pf)
2381 {
2382 p = p1;
2383 pl = p1 + srcImage->width * 3;
2384 for (; p < pl; p += 3)
2385 {
2386 p[0] = lookup_r[(p[0] & 0xff0000)>>16];
2387 p[1] = lookup_r[(p[1] & 0x00ff00)>> 8];
2388 p[2] = lookup_r[(p[2] & 0x0000ff)];
2389 }
2390 p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line);
2391 }
2392 break;
2393 }
2394 case 32:
2395 {
2396 RUINT32T *p1, *pf, *p, *pl;
2397 p1 = (RUINT32T *) srcImage->data;
2398 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2399
2400 while (p1 < pf)
2401 {
2402 p = p1;
2403 pl = p1 + srcImage->width;
2404 for (; p < pl; p++)
2405 {
2406 *p = lookup_r[(*p & 0xff0000)>>16] |
2407 lookup_g[(*p & 0x00ff00)>> 8] |
2408 lookup_b[(*p & 0x0000ff)] |
2409 (*p & ~0xffffff);
2410 }
2411 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line);
2412 }
2413 break;
2414 }
2415 }
2416
2417 free (lookup);
2418}
2419#endif
2420
2421/*
2422 * Check our parents are still who we think they are.
2423 * Do transparency updates if required
2424 */
2425int
2426rxvt_term::check_our_parents ()
2427{
2428 int i, pchanged, aformat, have_pixmap, rootdepth;
2429 unsigned long nitems, bytes_after;
2430 Atom atype;
2431 unsigned char *prop = NULL;
2432 Window root, oldp, *list;
2433 Pixmap rootpixmap = None;
2434 XWindowAttributes wattr, wrootattr;
2435 dDisp;
2436
2437 pchanged = 0;
2438
2439 if (!OPTION (Opt_transparent))
2440 return pchanged; /* Don't try any more */
2441
2442 XGetWindowAttributes (disp, display->root, &wrootattr);
2443 rootdepth = wrootattr.depth;
2444
2445 XGetWindowAttributes (disp, parent[0], &wattr);
2446
2447 if (rootdepth != wattr.depth)
2448 {
2449 if (am_transparent)
2450 {
2451 pchanged = 1;
2452 XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]);
2453 am_transparent = am_pixmap_trans = 0;
2454 }
2455
2456 return pchanged; /* Don't try any more */
2457 }
2458
2459 /* Get all X ops out of the queue so that our information is up-to-date. */
2460 XSync (disp, False);
2461
2462 /*
2463 * Make the frame window set by the window manager have
2464 * the root background. Some window managers put multiple nested frame
2465 * windows for each client, so we have to take care about that.
2466 */
2467 i = (xa[XA_XROOTPMAP_ID]
2468 && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID],
2469 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2470 &nitems, &bytes_after, &prop) == Success);
2471
2472 if (!i || prop == NULL)
2473 i = (xa[XA_ESETROOT_PMAP_ID]
2474 && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID],
2475 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2476 &nitems, &bytes_after, &prop) == Success);
2477
2478 if (!i || prop == NULL
2479#if TINTING
2480 || !rs[Rs_color + Color_tint]
2481#endif
2482 )
2483 have_pixmap = 0;
2484 else
2485 {
2486 have_pixmap = 1;
2487 rootpixmap = *(Pixmap *)prop;
2488 XFree (prop);
2489 }
2490
2491 if (have_pixmap)
2492 {
2493 /*
2494 * Copy display->root pixmap transparency
2495 */
2496 int sx, sy, nx, ny;
2497 unsigned int nw, nh;
2498 Window cr;
2499 XImage *image;
2500 GC gc;
2501 XGCValues gcvalue;
2502
2503 XTranslateCoordinates (disp, parent[0], display->root,
2504 0, 0, &sx, &sy, &cr);
2505 nw = (unsigned int)szHint.width;
2506 nh = (unsigned int)szHint.height;
2507 nx = ny = 0;
2508
2509 if (sx < 0)
2510 {
2511 nw += sx;
2512 nx = -sx;
2513 sx = 0;
2514 }
2515
2516 if (sy < 0)
2517 {
2518 nh += sy;
2519 ny = -sy;
2520 sy = 0;
2521 }
2522
2523 min_it (nw, (unsigned int) (wrootattr.width - sx));
2524 min_it (nh, (unsigned int) (wrootattr.height - sy));
2525
2526 XSync (disp, False);
2527 allowedxerror = -1;
2528 image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2529
2530 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2531 /* XXX: may need a delay here? */
2532 allowedxerror = 0;
2533
2534 if (image == NULL)
2535 {
2536 if (am_transparent && am_pixmap_trans)
2537 {
2538 pchanged = 1;
2539 if (pixmap != None)
2540 {
2541 XFreePixmap (disp, pixmap);
2542 pixmap = None;
2543 }
2544 }
2545
2546 am_pixmap_trans = 0;
2547 }
2548 else
2549 {
2550 if (pixmap != None)
2551 XFreePixmap (disp, pixmap);
2552
2553#if TINTING
2554 if (ISSET_PIXCOLOR (Color_tint))
2555 {
2556 unsigned short rm, gm, bm;
2557 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2558
2559 pix_colors_focused[Color_tint].get (display, rm, gm, bm);
2560
2561 ShadeXImage (display, image, shade, rm, gm, bm);
2562 }
2563#endif
2564
2565 pixmap = XCreatePixmap (disp, vt,
2566 szHint.width, szHint.height, image->depth);
2567 gc = XCreateGC (disp, vt, 0UL, &gcvalue);
2568 XPutImage (disp, pixmap, gc, image, 0, 0,
2569 nx, ny, image->width, image->height);
2570 XFreeGC (disp, gc);
2571 XDestroyImage (image);
2572 XSetWindowBackgroundPixmap (disp, parent[0], pixmap);
2573 XClearWindow (disp, parent[0]);
2574
2575 if (!am_transparent || !am_pixmap_trans)
2576 pchanged = 1;
2577
2578 am_transparent = am_pixmap_trans = 1;
2579 }
2580 }
2581
2582 if (am_pixmap_trans)
2583 XSetWindowBackgroundPixmap (disp, vt, ParentRelative);
2584 else
2585 {
2586 unsigned int n;
2587 /*
2588 * InheritPixmap transparency
2589 */
2590 for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2591 {
2592 oldp = parent[i];
2593 XQueryTree (disp, parent[i - 1], &root,
2594 &parent[i], &list, &n);
2595 XFree (list);
2596
2597 if (parent[i] == display->root)
2598 {
2599 if (oldp != None)
2600 pchanged = 1;
2601
2602 break;
2603 }
2604
2605 if (oldp != parent[i])
2606 pchanged = 1;
2607 }
2608
2609 n = 0;
2610
2611 if (pchanged)
2612 {
2613 for (; n < (unsigned int)i; n++)
2614 {
2615 XGetWindowAttributes (disp, parent[n], &wattr);
2616 if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
2617 {
2618 n = (int) (sizeof (parent) / sizeof (Window)) + 1;
2619 break;
2620 }
2621 }
2622 }
2623
2624 if (n > (int) (sizeof (parent) / sizeof (parent[0])))
2625 {
2626 XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]);
2627 XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]);
2628 am_transparent = 0;
2629 /* XXX: also turn off Opt_transparent? */
2630 }
2631 else
2632 {
2633#if WAIT_FOR_WM
2634 /* wait (an arbitrary period) for the WM to do its thing
2635 * needed for fvwm2.2.2 (and before?) */
2636 sleep (1);
2637#endif
2638 for (n = 0; n < (unsigned int)i; n++)
2639 {
2640 XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative);
2641 XClearWindow (disp, parent[n]);
2642 }
2643
2644 XSetWindowBackgroundPixmap (disp, vt, ParentRelative);
2645 am_transparent = 1;
2646 }
2647
2648 for (; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2649 parent[i] = None;
2650 }
2651
2652 if (scrollBar.win)
2653 {
2654 XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative);
2655 scrollBar.setIdle ();
2656 scrollbar_show (0);
2657 }
2658
2659 if (am_transparent)
2660 {
2661 want_refresh = want_full_refresh = 1;
2662 if (am_pixmap_trans)
2663 flush ();
2664 }
2665
2666 return pchanged;
2667}
2668#endif
2669 2225
2670/*}}} */ 2226/*}}} */
2671 2227
2672bool 2228bool
2673rxvt_term::cmd_parse () 2229rxvt_term::cmd_parse ()
2722 if (ch == C0_LF) 2278 if (ch == C0_LF)
2723 nlines++; 2279 nlines++;
2724 2280
2725 refresh_count++; 2281 refresh_count++;
2726 2282
2727 if (!OPTION (Opt_jumpScroll) 2283 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2728 || (refresh_count >= refresh_limit * (nrow - 1)))
2729 { 2284 {
2730 refreshnow = true;
2731 refresh_count = 0; 2285 refresh_count = 0;
2286
2287 if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.)
2288 {
2289 refreshnow = true;
2732 ch = NOCHAR; 2290 ch = NOCHAR;
2733 break; 2291 break;
2292 }
2734 } 2293 }
2735 2294
2736 // scr_add_lines only works for nlines <= nrow - 1. 2295 // scr_add_lines only works for nlines <= nrow - 1.
2737 if (nlines >= nrow - 1) 2296 if (nlines >= nrow - 1)
2738 { 2297 {
2766 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) 2325 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2767 scr_add_lines (buf, str - buf, nlines); 2326 scr_add_lines (buf, str - buf, nlines);
2768 2327
2769 /* 2328 /*
2770 * If there have been a lot of new lines, then update the screen 2329 * If there have been a lot of new lines, then update the screen
2771 * What the heck I'll cheat and only refresh less than every page-full. 2330 * What the heck we'll cheat and only refresh less than every page-full.
2772 * the number of pages between refreshes is refresh_limit, which 2331 * if skipScroll is enabled.
2773 * is incremented here because we must be doing flat-out scrolling.
2774 */ 2332 */
2775 if (refreshnow) 2333 if (refreshnow)
2776 { 2334 {
2777 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2778 refresh_limit++;
2779 else
2780 {
2781 flag = true; 2335 flag = true;
2782 scr_refresh (); 2336 scr_refresh ();
2783 want_refresh = 1; 2337 want_refresh = 1;
2784 }
2785 } 2338 }
2786 2339
2787 } 2340 }
2788 else 2341 else
2789 { 2342 {
2938 { 2491 {
2939 if ((buf[len++] = cmd_getc ()) == 'i') 2492 if ((buf[len++] = cmd_getc ()) == 'i')
2940 break; /* done = 1 */ 2493 break; /* done = 1 */
2941 } 2494 }
2942 } 2495 }
2943 2496
2944 for (i = 0; i < len; i++) 2497 for (i = 0; i < len; i++)
2945 if (putc (buf[i], fd) == EOF) 2498 if (putc (buf[i], fd) == EOF)
2946 { 2499 {
2947 done = 1; 2500 done = 1;
2948 break; 2501 break;
3010 process_dcs_seq (); 2563 process_dcs_seq ();
3011 break; 2564 break;
3012 case 0x9b: /* CSI */ 2565 case 0x9b: /* CSI */
3013 process_csi_seq (); 2566 process_csi_seq ();
3014 break; 2567 break;
3015 case 0x9d: /* CSI */ 2568 case 0x9d: /* OSC */
3016 process_osc_seq (); 2569 process_osc_seq ();
3017 break; 2570 break;
3018#endif 2571#endif
3019 } 2572 }
3020} 2573}
3110 scr_charset_set (2, (unsigned int)cmd_getc ()); 2663 scr_charset_set (2, (unsigned int)cmd_getc ());
3111 break; 2664 break;
3112 case '+': 2665 case '+':
3113 scr_charset_set (3, (unsigned int)cmd_getc ()); 2666 scr_charset_set (3, (unsigned int)cmd_getc ());
3114 break; 2667 break;
3115#if ENABLE_FRILLS 2668#if !ENABLE_MINIMAL
3116 case '6': 2669 case '6':
3117 scr_backindex (); 2670 scr_backindex ();
3118 break; 2671 break;
3119#endif 2672#endif
3120 case '7': 2673 case '7':
3121 scr_cursor (SAVE); 2674 scr_cursor (SAVE);
3122 break; 2675 break;
3123 case '8': 2676 case '8':
3124 scr_cursor (RESTORE); 2677 scr_cursor (RESTORE);
3125 break; 2678 break;
3126#if ENABLE_FRILLS 2679#if !ENABLE_MINIMAL
3127 case '9': 2680 case '9':
3128 scr_forwardindex (); 2681 scr_forwardindex ();
3129 break; 2682 break;
3130#endif 2683#endif
3131 case '=': 2684 case '=':
3246rxvt_term::process_csi_seq () 2799rxvt_term::process_csi_seq ()
3247{ 2800{
3248 unicode_t ch, priv, i; 2801 unicode_t ch, priv, i;
3249 unsigned int nargs, p; 2802 unsigned int nargs, p;
3250 int n, ndef; 2803 int n, ndef;
3251 int arg[ESC_ARGS]; 2804 int arg[ESC_ARGS] = { };
3252 2805
3253 for (nargs = ESC_ARGS; nargs > 0;) 2806 nargs = 0;
3254 arg[--nargs] = 0;
3255 2807
3256 priv = 0; 2808 priv = 0;
3257 ch = cmd_getc (); 2809 ch = cmd_getc ();
3258 if (ch >= '<' && ch <= '?') 2810 if (ch >= '<' && ch <= '?')
3259 { /* '<' '=' '>' '?' */ 2811 { /* '<' '=' '>' '?' */
3293 ndef = get_byte_array_bit (csi_defaults, i); 2845 ndef = get_byte_array_bit (csi_defaults, i);
3294 for (p = 0; p < nargs; p++) 2846 for (p = 0; p < nargs; p++)
3295 if (arg[p] == -1) 2847 if (arg[p] == -1)
3296 arg[p] = ndef; 2848 arg[p] = ndef;
3297 2849
3298#ifdef DEBUG_CMD
3299 fprintf (stderr, "CSI ");
3300 for (p = 0; p < nargs; p++)
3301 fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : "");
3302 fprintf (stderr, "%c\n", ch);
3303#endif
3304
3305 /* 2850 /*
3306 * private mode handling 2851 * private mode handling
3307 */ 2852 */
3308 if (priv) 2853 if (priv)
3309 { 2854 {
3310 switch (priv) 2855 switch (priv)
3311 { 2856 {
3312 case '>': 2857 case '>':
3313 if (ch == CSI_DA) /* secondary device attributes */ 2858 if (ch == CSI_DA) /* secondary device attributes */
3314 tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); 2859 {
2860 // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt,
2861 // 'U' for rxvt-unicode != 7.[34] (where it was broken).
2862 //
2863 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt
2864 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later
2865 // versions.
2866 //
2867 tt_printf ("\033[>%d;95;0c", 'U');
2868 }
3315 break; 2869 break;
3316 case '?': 2870 case '?':
3317 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2871 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
3318 process_terminal_mode (ch, priv, nargs, arg); 2872 process_terminal_mode (ch, priv, nargs, arg);
3319 break; 2873 break;
3445 break; 2999 break;
3446 case 6: /* CPR requested */ 3000 case 6: /* CPR requested */
3447 scr_report_position (); 3001 scr_report_position ();
3448 break; 3002 break;
3449 case 7: /* unofficial extension */ 3003 case 7: /* unofficial extension */
3450 if (OPTION (Opt_insecure)) 3004 if (option (Opt_insecure))
3451 tt_printf ("%-.250s\012", rs[Rs_display_name]); 3005 tt_printf ("%-.250s\012", rs[Rs_display_name]);
3452 break; 3006 break;
3453 case 8: /* unofficial extension */ 3007 case 8: /* unofficial extension */
3454 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); 3008 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
3455 break; 3009 break;
3522 break; 3076 break;
3523 case CSI_75: 3077 case CSI_75:
3524 scr_cursor (RESTORE); 3078 scr_cursor (RESTORE);
3525 break; 3079 break;
3526 3080
3527#if ENABLE_FRILLS 3081#if !ENABLE_MINIMAL
3528 case CSI_74: 3082 case CSI_74:
3529 process_window_ops (arg, nargs); 3083 process_window_ops (arg, nargs);
3530 break; 3084 break;
3531#endif 3085#endif
3532 3086
3539 break; 3093 break;
3540 } 3094 }
3541} 3095}
3542/*}}} */ 3096/*}}} */
3543 3097
3544#if ENABLE_FRILLS 3098#if !ENABLE_MINIMAL
3545/* ARGSUSED */ 3099/* ARGSUSED */
3546void 3100void
3547rxvt_term::process_window_ops (const int *args, unsigned int nargs) 3101rxvt_term::process_window_ops (const int *args, unsigned int nargs)
3548{ 3102{
3549 int x, y; 3103 int x, y;
3550 XWindowAttributes wattr; 3104 XWindowAttributes wattr;
3551 Window wdummy; 3105 Window wdummy;
3552 dDisp; 3106
3107 dLocal (Display *, dpy);
3553 3108
3554 if (nargs == 0) 3109 if (nargs == 0)
3555 return; 3110 return;
3556 3111
3557 switch (args[0]) 3112 switch (args[0])
3558 { 3113 {
3559 /* 3114 /*
3560 * commands 3115 * commands
3561 */ 3116 */
3562 case 1: /* deiconify window */ 3117 case 1: /* deiconify window */
3563 XMapWindow (disp, parent[0]); 3118 XMapWindow (dpy, parent[0]);
3564 break; 3119 break;
3565 case 2: /* iconify window */ 3120 case 2: /* iconify window */
3566 XIconifyWindow (disp, parent[0], display->screen); 3121 XIconifyWindow (dpy, parent[0], display->screen);
3567 break; 3122 break;
3568 case 3: /* set position (pixels) */ 3123 case 3: /* set position (pixels) */
3569 XMoveWindow (disp, parent[0], args[1], args[2]); 3124 XMoveWindow (dpy, parent[0], args[1], args[2]);
3570 break; 3125 break;
3571 case 4: /* set size (pixels) */ 3126 case 4: /* set size (pixels) */
3572 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); 3127 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
3573 break; 3128 break;
3574 case 5: /* raise window */ 3129 case 5: /* raise window */
3575 XRaiseWindow (disp, parent[0]); 3130 XRaiseWindow (dpy, parent[0]);
3576 break; 3131 break;
3577 case 6: /* lower window */ 3132 case 6: /* lower window */
3578 XLowerWindow (disp, parent[0]); 3133 XLowerWindow (dpy, parent[0]);
3579 break; 3134 break;
3580 case 7: /* refresh window */ 3135 case 7: /* refresh window */
3581 scr_touch (true); 3136 scr_touch (true);
3582 break; 3137 break;
3583 case 8: /* set size (chars) */ 3138 case 8: /* set size (chars) */
3590 if (args[0] >= 24) /* set height (chars) */ 3145 if (args[0] >= 24) /* set height (chars) */
3591 set_widthheight ((unsigned int)width, 3146 set_widthheight ((unsigned int)width,
3592 (unsigned int) (args[1] * fheight)); 3147 (unsigned int) (args[1] * fheight));
3593 break; 3148 break;
3594 3149
3595
3596 /* 3150 /*
3597 * reports - some output format copied from XTerm 3151 * reports - some output format copied from XTerm
3598 */ 3152 */
3599 case 11: /* report window state */ 3153 case 11: /* report window state */
3600 XGetWindowAttributes (disp, parent[0], &wattr); 3154 XGetWindowAttributes (dpy, parent[0], &wattr);
3601 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 3155 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
3602 break; 3156 break;
3603 case 13: /* report window position */ 3157 case 13: /* report window position */
3604 XGetWindowAttributes (disp, parent[0], &wattr); 3158 XGetWindowAttributes (dpy, parent[0], &wattr);
3605 XTranslateCoordinates (disp, parent[0], wattr.root, 3159 XTranslateCoordinates (dpy, parent[0], wattr.root,
3606 -wattr.border_width, -wattr.border_width, 3160 -wattr.border_width, -wattr.border_width,
3607 &x, &y, &wdummy); 3161 &x, &y, &wdummy);
3608 tt_printf ("\033[3;%d;%dt", x, y); 3162 tt_printf ("\033[3;%d;%dt", x, y);
3609 break; 3163 break;
3610 case 14: /* report window size (pixels) */ 3164 case 14: /* report window size (pixels) */
3611 XGetWindowAttributes (disp, parent[0], &wattr); 3165 XGetWindowAttributes (dpy, parent[0], &wattr);
3612 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 3166 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
3613 break; 3167 break;
3614 case 18: /* report text area size (chars) */ 3168 case 18: /* report text area size (chars) */
3615 tt_printf ("\033[8;%d;%dt", nrow, ncol); 3169 tt_printf ("\033[8;%d;%dt", nrow, ncol);
3616 break; 3170 break;
3618 tt_printf ("\033[9;%d;%dt", nrow, ncol); 3172 tt_printf ("\033[9;%d;%dt", nrow, ncol);
3619 break; 3173 break;
3620 case 20: /* report icon label */ 3174 case 20: /* report icon label */
3621 { 3175 {
3622 char *s; 3176 char *s;
3623 XGetIconName (disp, parent[0], &s); 3177 XGetIconName (dpy, parent[0], &s);
3624 tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ 3178 tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */
3625 XFree (s); 3179 XFree (s);
3626 } 3180 }
3627 break; 3181 break;
3628 case 21: /* report window title */ 3182 case 21: /* report window title */
3629 { 3183 {
3630 char *s; 3184 char *s;
3631 XFetchName (disp, parent[0], &s); 3185 XFetchName (dpy, parent[0], &s);
3632 tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ 3186 tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */
3633 XFree (s); 3187 XFree (s);
3634 } 3188 }
3635 break; 3189 break;
3636 } 3190 }
3637} 3191}
3664 seen_esc = true; 3218 seen_esc = true;
3665 continue; 3219 continue;
3666 } 3220 }
3667 else if (ch == C0_BEL || ch == CHAR_ST) 3221 else if (ch == C0_BEL || ch == CHAR_ST)
3668 break; 3222 break;
3223 else if (ch == C0_SYN)
3224 ch = cmd_get8 ();
3669 else if (ch < 0x20) 3225 else if (ch < 0x20)
3670 return NULL; /* other control character - exit */ 3226 return NULL; /* other control character - exit */
3671 3227
3672 seen_esc = false; 3228 seen_esc = false;
3673 3229
3674 if (n >= STRING_MAX - 1) 3230 if (n >= STRING_MAX - 1)
3675 // stop at some sane length 3231 // stop at some sane length
3676 return NULL; 3232 return NULL;
3677 3233
3678 if (ch == C0_SYN)
3679 string[n++] = cmd_get8 ();
3680 else
3681 string[n++] = ch; 3234 string[n++] = ch;
3682 } 3235 }
3683 3236
3684 string[n++] = '\0'; 3237 string[n++] = '\0';
3685 3238
3686 ends_how = (ch == 0x5c ? C0_ESC : ch); 3239 ends_how = (ch == 0x5c ? C0_ESC : ch);
3737void 3290void
3738rxvt_term::process_color_seq (int report, int color, const char *str, char resp) 3291rxvt_term::process_color_seq (int report, int color, const char *str, char resp)
3739{ 3292{
3740 if (str[0] == '?' && !str[1]) 3293 if (str[0] == '?' && !str[1])
3741 { 3294 {
3742 unsigned short r, g, b; 3295 rgba c;
3743 pix_colors_focused[color].get (display, r, g, b); 3296 pix_colors_focused[color].get (c);
3297
3298#if XFT
3299 if (c.a != rgba::MAX_CC)
3300 tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp);
3301 else
3302#endif
3744 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); 3303 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp);
3745 } 3304 }
3746 else 3305 else
3747 set_window_color (color, str); 3306 set_window_color (color, str);
3748} 3307}
3749 3308
3755{ 3314{
3756 int color; 3315 int color;
3757 char *buf, *name; 3316 char *buf, *name;
3758 bool query = str[0] == '?' && !str[1]; 3317 bool query = str[0] == '?' && !str[1];
3759 int saveop = op; 3318 int saveop = op;
3760 dDisp; 3319
3320 dLocal (Display *, dpy);
3761 3321
3762 assert (str != NULL); 3322 assert (str != NULL);
3323
3324 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END)))
3325 return;
3326
3763 switch (op) 3327 switch (op)
3764 { 3328 {
3765 case XTerm_name: 3329 case XTerm_name:
3766 set_title (str); 3330 set_title (str);
3767 /* FALLTHROUGH */ 3331 /* FALLTHROUGH */
3781 unsigned long bytes_after; 3345 unsigned long bytes_after;
3782 unsigned char *value = 0; 3346 unsigned char *value = 0;
3783 const char *str = ""; 3347 const char *str = "";
3784 3348
3785 if (prop 3349 if (prop
3786 && XGetWindowProperty (disp, parent[0], 3350 && XGetWindowProperty (dpy, parent[0],
3787 prop, 0, 1<<16, 0, AnyPropertyType, 3351 prop, 0, 1<<16, 0, AnyPropertyType,
3788 &actual_type, &actual_format, 3352 &actual_type, &actual_format,
3789 &nitems, &bytes_after, &value) == Success 3353 &nitems, &bytes_after, &value) == Success
3790 && actual_type != None 3354 && actual_type != None
3791 && actual_format == 8) 3355 && actual_format == 8)
3792 str = (const char *)(value); 3356 str = (const char *)(value);
3793 3357
3794 tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); 3358 tt_printf ("\033]%d;%s%c", op, str, resp);
3795 3359
3796 XFree (value); 3360 XFree (value);
3797 } 3361 }
3798 else 3362 else
3799 { 3363 {
3803 { 3367 {
3804 *eq = 0; 3368 *eq = 0;
3805 set_utf8_property (display->atom (str), eq + 1); 3369 set_utf8_property (display->atom (str), eq + 1);
3806 } 3370 }
3807 else 3371 else
3808 XDeleteProperty (disp, parent[0], 3372 XDeleteProperty (dpy, parent[0],
3809 display->atom (str)); 3373 display->atom (str));
3810 } 3374 }
3811 break; 3375 break;
3812 3376
3813 case XTerm_Color: 3377 case XTerm_Color:
3823 break; 3387 break;
3824 3388
3825 if ((buf = strchr (name, ';')) != NULL) 3389 if ((buf = strchr (name, ';')) != NULL)
3826 *buf++ = '\0'; 3390 *buf++ = '\0';
3827 3391
3828 if (name[0] == '?' && !name[1]) 3392 process_color_seq (op, color, name, resp);
3829 {
3830 unsigned short r, g, b;
3831 pix_colors_focused[color].get (display, r, g, b);
3832 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3833 }
3834 else
3835 set_window_color (color, name);
3836 } 3393 }
3837 break; 3394 break;
3838 case XTerm_Color00: 3395 case XTerm_Color00:
3839 process_color_seq (XTerm_Color00, Color_fg, str, resp); 3396 process_color_seq (op, Color_fg, str, resp);
3840 break; 3397 break;
3841 case XTerm_Color01: 3398 case XTerm_Color01:
3842 process_color_seq (XTerm_Color01, Color_bg, str, resp); 3399 process_color_seq (op, Color_bg, str, resp);
3843 break; 3400 break;
3844#ifndef NO_CURSORCOLOR 3401#ifndef NO_CURSORCOLOR
3845 case XTerm_Color_cursor: 3402 case XTerm_Color_cursor:
3846 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); 3403 process_color_seq (op, Color_cursor, str, resp);
3847 break; 3404 break;
3848#endif 3405#endif
3849 case XTerm_Color_pointer_fg: 3406 case XTerm_Color_pointer_fg:
3850 process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); 3407 process_color_seq (op, Color_pointer_fg, str, resp);
3851 break; 3408 break;
3852 case XTerm_Color_pointer_bg: 3409 case XTerm_Color_pointer_bg:
3853 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); 3410 process_color_seq (op, Color_pointer_bg, str, resp);
3854 break; 3411 break;
3855#ifndef NO_BOLD_UNDERLINE_REVERSE 3412#ifndef NO_BOLD_UNDERLINE_REVERSE
3856 case XTerm_Color_RV: 3413 case XTerm_Color_RV:
3857 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3414 process_color_seq (op, Color_RV, str, resp);
3858 break; 3415 break;
3859 case Rxvt_Color_BD: 3416 case Rxvt_Color_BD:
3860 case URxvt_Color_BD: 3417 case URxvt_Color_BD:
3861 process_color_seq (op, Color_BD, str, resp); 3418 process_color_seq (op, Color_BD, str, resp);
3862 break; 3419 break;
3863 case Rxvt_Color_UL: 3420 case Rxvt_Color_UL:
3864 case URxvt_Color_UL: 3421 case URxvt_Color_UL:
3865 process_color_seq (op, Color_UL, str, resp); 3422 process_color_seq (op, Color_UL, str, resp);
3866 break; 3423 break;
3867 case URxvt_Color_IT: 3424 case URxvt_Color_IT:
3868 process_color_seq (URxvt_Color_IT, Color_IT, str, resp); 3425 process_color_seq (op, Color_IT, str, resp);
3869 break; 3426 break;
3870#endif 3427#endif
3871#if TRANSPARENT && TINTING 3428#if ENABLE_TRANSPARENCY
3872 case URxvt_Color_tint: 3429 case URxvt_Color_tint:
3873 process_color_seq (URxvt_Color_tint, Color_tint, str, resp); 3430 process_color_seq (op, Color_tint, str, resp);
3874 check_our_parents (); 3431 {
3875 if (am_transparent) 3432 bool changed = false;
3876 want_full_refresh = want_refresh = 1; 3433 if (ISSET_PIXCOLOR (Color_tint))
3877 break; 3434 changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]);
3878#endif 3435 else
3436 changed = bgPixmap.unset_tint ();
3437 if (changed)
3438 update_background ();
3439 }
3879 3440
3441 break;
3442#endif
3443
3444#if BG_IMAGE_FROM_FILE
3880 case Rxvt_Pixmap: 3445 case Rxvt_Pixmap:
3881 { 3446 if (!strcmp (str, "?"))
3882 if (*str != ';')
3883 { 3447 {
3884#if XPM_BACKGROUND 3448 char str[256];
3885 scale_pixmap (""); /* reset to default scaling */ 3449
3886 set_bgPixmap (str); /* change pixmap */ 3450 sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */
3887 scr_touch (true); 3451 min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767),
3888#endif 3452 min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767));
3453 process_xterm_seq (XTerm_title, str, CHAR_ST);
3889 } 3454 }
3890 3455 else
3456 {
3891 int changed = 0; 3457 int changed = 0;
3892 3458
3893 while ((str = strchr (str, ';')) != NULL) 3459 if (*str != ';')
3894 { 3460 {
3461 /* reset to default scaling :*/
3462 bgPixmap.unset_geometry ();
3463 if (bgPixmap.set_file (str)) /* change pixmap */
3464 changed++;
3465 str = strchr (str, ';');
3466 if (str == NULL)
3467 bgPixmap.set_defaultGeometry ();
3468 }
3469 while (str)
3470 {
3895 str++; 3471 str++;
3896#if XPM_BACKGROUND 3472 if (bgPixmap.set_geometry (str))
3897 changed += scale_pixmap (str); 3473 changed++;
3898#endif 3474 str = strchr (str, ';');
3899 } 3475 }
3900
3901 if (changed) 3476 if (changed)
3902 { 3477 update_background ();
3903#ifdef XPM_BACKGROUND
3904 resize_pixmap ();
3905 scr_touch (true);
3906#endif
3907 } 3478 }
3908 }
3909 break; 3479 break;
3480#endif
3910 3481
3911 case Rxvt_restoreFG: 3482 case Rxvt_restoreFG:
3912 set_window_color (Color_fg, str); 3483 set_window_color (Color_fg, str);
3913 break; 3484 break;
3914 case Rxvt_restoreBG: 3485 case Rxvt_restoreBG:
3939 case URxvt_italicFont: 3510 case URxvt_italicFont:
3940 case URxvt_boldItalicFont: 3511 case URxvt_boldItalicFont:
3941#endif 3512#endif
3942 if (query) 3513 if (query)
3943 tt_printf ("\33]%d;%-.250s%c", saveop, 3514 tt_printf ("\33]%d;%-.250s%c", saveop,
3944 OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc 3515 option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc
3945 ? fontset[op - URxvt_font]->fontdesc : "", 3516 ? fontset[op - URxvt_font]->fontdesc : "",
3946 resp); 3517 resp);
3947 else 3518 else
3948 { 3519 {
3949 const char *&res = rs[Rs_font + (op - URxvt_font)]; 3520 const char *&res = rs[Rs_font + (op - URxvt_font)];
3952 allocated.push_back ((void *)res); 3523 allocated.push_back ((void *)res);
3953 set_fonts (); 3524 set_fonts ();
3954 } 3525 }
3955 break; 3526 break;
3956 3527
3957#if ENABLE_FRILLS 3528 case URxvt_version:
3529 if (query)
3530 tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c",
3531 op,
3532 rs[Rs_name], VERSION[0], VERSION[2],
3533 resp);
3534 break;
3535
3536#if !ENABLE_MINIMAL
3958 case URxvt_locale: 3537 case URxvt_locale:
3959 if (query) 3538 if (query)
3960 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); 3539 tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp);
3961 else 3540 else
3962 { 3541 {
3963 set_locale (str); 3542 set_locale (str);
3964 pty->set_utf8_mode (enc_utf8); 3543 pty->set_utf8_mode (enc_utf8);
3965 init_xlocale (); 3544 init_xlocale ();
3980 break; 3559 break;
3981#endif 3560#endif
3982 3561
3983#if ENABLE_PERL 3562#if ENABLE_PERL
3984 case URxvt_perl: 3563 case URxvt_perl:
3985 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) 3564 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END)))
3986 ; // no responses yet 3565 ; // no responses yet
3987 break; 3566 break;
3988#endif 3567#endif
3989 } 3568 }
3990} 3569}
4028{ 3607{
4029 unsigned int i, j; 3608 unsigned int i, j;
4030 int state; 3609 int state;
4031 3610
4032 static const struct 3611 static const struct
4033 { 3612 {
4034 const int argval; 3613 const int argval;
4035 const unsigned long bit; 3614 const unsigned long bit;
4036 }
4037
4038 argtopriv[] = { 3615 } argtopriv[] = {
4039 { 1, PrivMode_aplCUR }, 3616 { 1, PrivMode_aplCUR },
4040 { 2, PrivMode_vt52 }, 3617 { 2, PrivMode_vt52 },
4041 { 3, PrivMode_132 }, 3618 { 3, PrivMode_132 },
4042 { 4, PrivMode_smoothScroll }, 3619 { 4, PrivMode_smoothScroll },
4043 { 5, PrivMode_rVideo }, 3620 { 5, PrivMode_rVideo },
4060#ifndef NO_BACKSPACE_KEY 3637#ifndef NO_BACKSPACE_KEY
4061 { 67, PrivMode_BackSpace }, 3638 { 67, PrivMode_BackSpace },
4062#endif 3639#endif
4063 { 1000, PrivMode_MouseX11 }, 3640 { 1000, PrivMode_MouseX11 },
4064 // 1001 Use Hilite Mouse Tracking. NYI, TODO 3641 // 1001 Use Hilite Mouse Tracking. NYI, TODO
4065 // 1002 Use Cell Motion Mouse Tracking. NYI, TODO 3642 { 1002, PrivMode_MouseBtnEvent },
4066 // 1003 Use All Motion Mouse Tracking. NYI, TODO 3643 { 1003, PrivMode_MouseAnyEvent },
4067 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3644 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
4068 { 1011, PrivMode_Keypress }, // rxvt extension 3645 { 1011, PrivMode_Keypress }, // rxvt extension
4069 // 1035 enable modifiers for alt, numlock NYI 3646 // 1035 enable modifiers for alt, numlock NYI
4070 // 1036 send ESC for meta keys NYI 3647 // 1036 send ESC for meta keys NYI
4071 // 1037 send DEL for keypad delete NYI 3648 // 1037 send DEL for keypad delete NYI
4106 scr_touch (true); 3683 scr_touch (true);
4107 break; 3684 break;
4108#endif 3685#endif
4109 case 1048: /* alternative cursor save */ 3686 case 1048: /* alternative cursor save */
4110 case 1049: 3687 case 1049:
4111 if (OPTION (Opt_secondaryScreen)) 3688 if (option (Opt_secondaryScreen))
4112 if (mode == 0) 3689 if (mode == 0)
4113 scr_cursor (RESTORE); 3690 scr_cursor (RESTORE);
4114 else if (mode == 1) 3691 else if (mode == 1)
4115 scr_cursor (SAVE); 3692 scr_cursor (SAVE);
4116 break; 3693 break;
4145 scr_autowrap (state); 3722 scr_autowrap (state);
4146 break; 3723 break;
4147 /* case 8: - auto repeat, can't do on a per window basis */ 3724 /* case 8: - auto repeat, can't do on a per window basis */
4148 case 9: /* X10 mouse reporting */ 3725 case 9: /* X10 mouse reporting */
4149 if (state) /* orthogonal */ 3726 if (state) /* orthogonal */
4150 priv_modes &= ~PrivMode_MouseX11; 3727 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
4151 break; 3728 break;
4152#ifdef scrollBar_esc 3729#ifdef scrollBar_esc
4153 case scrollBar_esc: 3730 case scrollBar_esc:
4154 if (scrollbar_mapping (state)) 3731 if (scrollbar_mapping (state))
4155 { 3732 {
4168 break; 3745 break;
4169 /* case 66: - application key pad */ 3746 /* case 66: - application key pad */
4170 /* case 67: - backspace key */ 3747 /* case 67: - backspace key */
4171 case 1000: /* X11 mouse reporting */ 3748 case 1000: /* X11 mouse reporting */
4172 if (state) /* orthogonal */ 3749 if (state) /* orthogonal */
4173 priv_modes &= ~PrivMode_MouseX10; 3750 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
4174 break; 3751 break;
4175#if 0 3752#if 0
4176 case 1001: 3753 case 1001:
4177 break; /* X11 mouse highlighting */ 3754 break; /* X11 mouse highlighting */
4178#endif 3755#endif
3756 case 1002:
3757 case 1003:
3758 if (state) {
3759 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
3760 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3761 vt_emask_mouse = PointerMotionMask;
3762 } else
3763 vt_emask_mouse = NoEventMask;
3764 vt_select_input ();
3765 break;
4179 case 1010: /* scroll to bottom on TTY output inhibit */ 3766 case 1010: /* scroll to bottom on TTY output inhibit */
4180 set_option (Opt_scrollTtyOutput, !state); 3767 set_option (Opt_scrollTtyOutput, !state);
4181 break; 3768 break;
4182 case 1011: /* scroll to bottom on key press */ 3769 case 1011: /* scroll to bottom on key press */
4183 set_option (Opt_scrollTtyKeypress, state); 3770 set_option (Opt_scrollTtyKeypress, state);
4184 break; 3771 break;
4185 case 1047: /* secondary screen w/ clearing last */ 3772 case 1047: /* secondary screen w/ clearing last */
4186 if (OPTION (Opt_secondaryScreen)) 3773 if (option (Opt_secondaryScreen))
4187 if (current_screen != PRIMARY) 3774 if (current_screen != PRIMARY)
4188 scr_erase_screen (2); 3775 scr_erase_screen (2);
4189 scr_change_screen (state); 3776 scr_change_screen (state);
4190 break; 3777 break;
4191 case 1049: /* secondary screen w/ clearing first */ 3778 case 1049: /* secondary screen w/ clearing first */
4192 scr_change_screen (state); 3779 scr_change_screen (state);
4193 if (OPTION (Opt_secondaryScreen)) 3780 if (option (Opt_secondaryScreen))
4194 if (current_screen != PRIMARY) 3781 if (current_screen != PRIMARY)
4195 scr_erase_screen (2); 3782 scr_erase_screen (2);
4196 break; 3783 break;
4197 default: 3784 default:
4198 break; 3785 break;
4326 scr_color (Color_bg, Color_bg); 3913 scr_color (Color_bg, Color_bg);
4327 break; 3914 break;
4328 3915
4329 //case 50: // not variable spacing 3916 //case 50: // not variable spacing
4330 3917
4331#if ENABLE_FRILLS 3918#if !ENABLE_MINIMAL
4332 case 90: 3919 case 90:
4333 case 91: /* set bright fg color */ 3920 case 91: /* set bright fg color */
4334 case 92: 3921 case 92:
4335 case 93: 3922 case 93:
4336 case 94: 3923 case 94:
4435 4022
4436 if (v_buflen == 0) 4023 if (v_buflen == 0)
4437 { 4024 {
4438 free (v_buffer); 4025 free (v_buffer);
4439 v_buffer = 0; 4026 v_buffer = 0;
4440 v_buflen = 0;
4441 4027
4442 pty_ev.set (EVENT_READ); 4028 pty_ev.set (EVENT_READ);
4443 return; 4029 return;
4444 } 4030 }
4445 4031

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines