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, |
… | |
… | |
299 | |
297 | |
300 | return -1; |
298 | return -1; |
301 | } |
299 | } |
302 | #endif |
300 | #endif |
303 | |
301 | |
304 | /*{{{ Convert the keypress event into a string */ |
|
|
305 | void |
302 | void |
306 | rxvt_term::lookup_key (XKeyEvent &ev) |
303 | rxvt_term::key_press (XKeyEvent &ev) |
307 | { |
304 | { |
308 | int ctrl, meta, shft, len; |
305 | int ctrl, meta, shft, len; |
309 | unsigned int newlen; |
306 | unsigned int newlen; |
310 | KeySym keysym; |
307 | KeySym keysym; |
311 | int valid_keysym; |
308 | int valid_keysym; |
312 | char kbuf[KBUFSZ]; |
309 | char kbuf[KBUFSZ]; |
|
|
310 | |
|
|
311 | #if ISO_14755 |
|
|
312 | if (iso14755buf & ISO_14755_52) |
|
|
313 | return; |
|
|
314 | #endif |
313 | |
315 | |
314 | /* |
316 | /* |
315 | * 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 |
316 | * escape sequence to toggle the Keypad. |
318 | * escape sequence to toggle the Keypad. |
317 | * |
319 | * |
… | |
… | |
497 | # if ISO_14755 |
499 | # if ISO_14755 |
498 | iso14755_51 (0); |
500 | iso14755_51 (0); |
499 | # endif |
501 | # endif |
500 | return; |
502 | return; |
501 | } |
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 | } |
502 | else if ((hv = hex_keyval (ev)) >= 0) |
512 | else if ((hv = hex_keyval (ev)) >= 0) |
503 | { |
513 | { |
504 | iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) |
514 | iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) |
505 | | hv | ISO_14755_51; |
515 | | hv | ISO_14755_51; |
506 | # if ISO_14755 |
516 | # if ISO_14755 |
… | |
… | |
508 | # endif |
518 | # endif |
509 | return; |
519 | return; |
510 | } |
520 | } |
511 | else |
521 | else |
512 | { |
522 | { |
513 | # if ENABLE_OVERLAY |
523 | # if ISO_14755 |
514 | scr_overlay_off (); |
524 | scr_overlay_off (); |
515 | # endif |
525 | # endif |
516 | iso14755buf = 0; |
526 | iso14755buf = 0; |
517 | } |
527 | } |
518 | } |
528 | } |
519 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
529 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
520 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
530 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
521 | if (!(iso14755buf & ISO_14755_STARTED)) |
531 | if (!(iso14755buf & ISO_14755_STARTED)) |
522 | { |
532 | { |
523 | iso14755buf |= ISO_14755_STARTED; |
533 | iso14755buf |= ISO_14755_STARTED; |
524 | # if ENABLE_OVERLAY |
534 | # if ISO_14755 |
525 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
535 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
526 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
536 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
527 | # endif |
537 | # endif |
528 | } |
538 | } |
529 | #endif |
539 | #endif |
530 | |
540 | |
531 | #ifdef PRINTPIPE |
541 | #ifdef PRINTPIPE |
532 | if (keysym == XK_Print) |
542 | if (keysym == XK_Print) |
533 | { |
543 | { |
534 | scr_printscreen (ctrl | shft); |
544 | scr_printscreen (ctrl | shft); |
535 | return; |
545 | return; |
… | |
… | |
537 | #endif |
547 | #endif |
538 | |
548 | |
539 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
549 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
540 | { |
550 | { |
541 | { |
551 | { |
|
|
552 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
542 | newlen = 1; |
553 | newlen = 1; |
|
|
554 | #ifdef XK_KP_Home |
|
|
555 | static const KeySym keypadtrans[] = { |
|
|
556 | XK_KP_7, // XK_KP_Home |
|
|
557 | XK_KP_4, // XK_KP_Left |
|
|
558 | XK_KP_8, // XK_KP_Up |
|
|
559 | XK_KP_6, // XK_KP_Right |
|
|
560 | XK_KP_2, // XK_KP_Down |
|
|
561 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
562 | XK_KP_9, // XK_KP_Prior |
|
|
563 | XK_KP_3, // XK_KP_Next |
|
|
564 | #else |
|
|
565 | XK_Prior, |
|
|
566 | XK_Next, |
|
|
567 | #endif |
|
|
568 | XK_KP_1, // XK_KP_End |
|
|
569 | XK_KP_5, // XK_KP_Begin |
|
|
570 | }; |
|
|
571 | |
|
|
572 | if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin)) |
|
|
573 | { |
|
|
574 | unsigned int index = keysym - XK_KP_Home; |
|
|
575 | keysym = kp ? keypadtrans[index] : XK_Home + index; |
|
|
576 | } |
|
|
577 | else if (keysym == XK_KP_Insert) |
|
|
578 | keysym = kp ? XK_KP_0 : XK_Insert; |
|
|
579 | #ifndef NO_DELETE_KEY |
|
|
580 | else if (keysym == XK_KP_Delete) |
|
|
581 | keysym = kp ? XK_KP_Decimal : XK_Delete; |
|
|
582 | #endif |
|
|
583 | #endif |
543 | switch (keysym) |
584 | switch (keysym) |
544 | { |
585 | { |
545 | #ifndef NO_BACKSPACE_KEY |
586 | #ifndef NO_BACKSPACE_KEY |
546 | case XK_BackSpace: |
587 | case XK_BackSpace: |
547 | if (priv_modes & PrivMode_HaveBackSpace) |
588 | if (priv_modes & PrivMode_HaveBackSpace) |
… | |
… | |
549 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
590 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
550 | ^ !!ctrl) ? '\b' : '\177'; |
591 | ^ !!ctrl) ? '\b' : '\177'; |
551 | kbuf[1] = '\0'; |
592 | kbuf[1] = '\0'; |
552 | } |
593 | } |
553 | else |
594 | else |
554 | strcpy (kbuf, key_backspace); |
595 | strcpy (kbuf, rs[Rs_backspace_key]); |
555 | break; |
596 | break; |
556 | #endif |
597 | #endif |
557 | #ifndef NO_DELETE_KEY |
598 | #ifndef NO_DELETE_KEY |
558 | # ifdef XK_KP_Prior |
|
|
559 | case XK_KP_Delete: |
|
|
560 | /* allow shift to override */ |
|
|
561 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
562 | { |
|
|
563 | strcpy (kbuf, "\033On"); |
|
|
564 | break; |
|
|
565 | } |
|
|
566 | /* FALLTHROUGH */ |
|
|
567 | # endif |
|
|
568 | case XK_Delete: |
599 | case XK_Delete: |
569 | strcpy (kbuf, key_delete); |
600 | strcpy (kbuf, rs[Rs_delete_key]); |
570 | break; |
601 | break; |
571 | #endif |
602 | #endif |
572 | case XK_Tab: |
603 | case XK_Tab: |
573 | if (shft) |
604 | if (shft) |
574 | strcpy (kbuf, "\033[Z"); |
605 | strcpy (kbuf, "\033[Z"); |
… | |
… | |
584 | #endif |
615 | #endif |
585 | newlen = 0; |
616 | newlen = 0; |
586 | } |
617 | } |
587 | break; |
618 | break; |
588 | |
619 | |
589 | #ifdef XK_KP_Left |
|
|
590 | case XK_KP_Up: /* \033Ox or standard */ |
|
|
591 | case XK_KP_Down: /* \033Or or standard */ |
|
|
592 | case XK_KP_Right: /* \033Ov or standard */ |
|
|
593 | case XK_KP_Left: /* \033Ot or standard */ |
|
|
594 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
595 | { |
|
|
596 | strcpy (kbuf, "\033OZ"); |
|
|
597 | kbuf[2] = "txvr"[keysym - XK_KP_Left]; |
|
|
598 | break; |
|
|
599 | } |
|
|
600 | else |
|
|
601 | /* translate to std. cursor key */ |
|
|
602 | keysym = XK_Left + (keysym - XK_KP_Left); |
|
|
603 | /* FALLTHROUGH */ |
|
|
604 | #endif |
|
|
605 | case XK_Up: /* "\033[A" */ |
620 | case XK_Up: /* "\033[A" */ |
606 | case XK_Down: /* "\033[B" */ |
621 | case XK_Down: /* "\033[B" */ |
607 | case XK_Right: /* "\033[C" */ |
622 | case XK_Right: /* "\033[C" */ |
608 | case XK_Left: /* "\033[D" */ |
623 | case XK_Left: /* "\033[D" */ |
609 | strcpy (kbuf, "\033[Z"); |
624 | strcpy (kbuf, "\033[Z"); |
… | |
… | |
619 | else if (priv_modes & PrivMode_aplCUR) |
634 | else if (priv_modes & PrivMode_aplCUR) |
620 | kbuf[1] = 'O'; |
635 | kbuf[1] = 'O'; |
621 | break; |
636 | break; |
622 | |
637 | |
623 | #ifndef UNSHIFTED_SCROLLKEYS |
638 | #ifndef UNSHIFTED_SCROLLKEYS |
624 | # ifdef XK_KP_Prior |
|
|
625 | case XK_KP_Prior: |
|
|
626 | /* allow shift to override */ |
|
|
627 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
628 | { |
|
|
629 | strcpy (kbuf, "\033Oy"); |
|
|
630 | break; |
|
|
631 | } |
|
|
632 | /* FALLTHROUGH */ |
|
|
633 | # endif |
|
|
634 | case XK_Prior: |
639 | case XK_Prior: |
635 | strcpy (kbuf, "\033[5~"); |
640 | strcpy (kbuf, "\033[5~"); |
636 | break; |
641 | break; |
637 | # ifdef XK_KP_Next |
|
|
638 | case XK_KP_Next: |
|
|
639 | /* allow shift to override */ |
|
|
640 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
641 | { |
|
|
642 | strcpy (kbuf, "\033Os"); |
|
|
643 | break; |
|
|
644 | } |
|
|
645 | /* FALLTHROUGH */ |
|
|
646 | # endif |
|
|
647 | case XK_Next: |
642 | case XK_Next: |
648 | strcpy (kbuf, "\033[6~"); |
643 | strcpy (kbuf, "\033[6~"); |
649 | break; |
644 | break; |
650 | #endif |
645 | #endif |
651 | case XK_KP_Enter: |
646 | case XK_KP_Enter: |
652 | /* allow shift to override */ |
647 | /* allow shift to override */ |
653 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
648 | if (kp) |
654 | { |
649 | { |
655 | strcpy (kbuf, "\033OM"); |
650 | strcpy (kbuf, "\033OM"); |
656 | break; |
651 | break; |
657 | } |
652 | } |
658 | |
653 | |
… | |
… | |
670 | kbuf[0] = '\015'; |
665 | kbuf[0] = '\015'; |
671 | kbuf[1] = '\0'; |
666 | kbuf[1] = '\0'; |
672 | } |
667 | } |
673 | break; |
668 | break; |
674 | |
669 | |
675 | #ifdef XK_KP_Begin |
|
|
676 | case XK_KP_Begin: |
|
|
677 | strcpy (kbuf, "\033Ou"); |
|
|
678 | break; |
|
|
679 | |
|
|
680 | #endif |
|
|
681 | case XK_KP_F1: /* "\033OP" */ |
670 | case XK_KP_F1: /* "\033OP" */ |
682 | case XK_KP_F2: /* "\033OQ" */ |
671 | case XK_KP_F2: /* "\033OQ" */ |
683 | case XK_KP_F3: /* "\033OR" */ |
672 | case XK_KP_F3: /* "\033OR" */ |
684 | case XK_KP_F4: /* "\033OS" */ |
673 | case XK_KP_F4: /* "\033OS" */ |
685 | strcpy (kbuf, "\033OP"); |
674 | strcpy (kbuf, "\033OP"); |
… | |
… | |
701 | case XK_KP_6: /* "\033Ov" : "6" */ |
690 | case XK_KP_6: /* "\033Ov" : "6" */ |
702 | case XK_KP_7: /* "\033Ow" : "7" */ |
691 | case XK_KP_7: /* "\033Ow" : "7" */ |
703 | case XK_KP_8: /* "\033Ox" : "8" */ |
692 | case XK_KP_8: /* "\033Ox" : "8" */ |
704 | case XK_KP_9: /* "\033Oy" : "9" */ |
693 | case XK_KP_9: /* "\033Oy" : "9" */ |
705 | /* allow shift to override */ |
694 | /* allow shift to override */ |
706 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
695 | if (kp) |
707 | { |
696 | { |
708 | strcpy (kbuf, "\033Oj"); |
697 | strcpy (kbuf, "\033Oj"); |
709 | kbuf[2] += (keysym - XK_KP_Multiply); |
698 | kbuf[2] += (keysym - XK_KP_Multiply); |
710 | } |
699 | } |
711 | else |
700 | else |
… | |
… | |
717 | |
706 | |
718 | case XK_Find: |
707 | case XK_Find: |
719 | strcpy (kbuf, "\033[1~"); |
708 | strcpy (kbuf, "\033[1~"); |
720 | break; |
709 | break; |
721 | |
710 | |
722 | #ifdef XK_KP_End |
|
|
723 | case XK_KP_Insert: |
|
|
724 | /* allow shift to override */ |
|
|
725 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
726 | { |
|
|
727 | strcpy (kbuf, "\033Op"); |
|
|
728 | break; |
|
|
729 | } |
|
|
730 | /* FALLTHROUGH */ |
|
|
731 | #endif |
|
|
732 | case XK_Insert: |
711 | case XK_Insert: |
733 | strcpy (kbuf, "\033[2~"); |
712 | strcpy (kbuf, "\033[2~"); |
734 | break; |
713 | break; |
735 | #ifdef DXK_Remove /* support for DEC remove like key */ |
714 | #ifdef DXK_Remove /* support for DEC remove like key */ |
736 | case DXK_Remove: |
715 | case DXK_Remove: |
… | |
… | |
740 | strcpy (kbuf, "\033[3~"); |
719 | strcpy (kbuf, "\033[3~"); |
741 | break; |
720 | break; |
742 | case XK_Select: |
721 | case XK_Select: |
743 | strcpy (kbuf, "\033[4~"); |
722 | strcpy (kbuf, "\033[4~"); |
744 | break; |
723 | break; |
745 | #ifdef XK_KP_End |
|
|
746 | case XK_KP_End: |
|
|
747 | /* allow shift to override */ |
|
|
748 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
749 | { |
|
|
750 | strcpy (kbuf, "\033Oq"); |
|
|
751 | break; |
|
|
752 | } |
|
|
753 | /* FALLTHROUGH */ |
|
|
754 | #endif |
|
|
755 | case XK_End: |
724 | case XK_End: |
756 | strcpy (kbuf, KS_END); |
725 | strcpy (kbuf, KS_END); |
757 | break; |
726 | break; |
758 | #ifdef XK_KP_Home |
|
|
759 | case XK_KP_Home: |
|
|
760 | /* allow shift to override */ |
|
|
761 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
762 | { |
|
|
763 | strcpy (kbuf, "\033Ow"); |
|
|
764 | break; |
|
|
765 | } |
|
|
766 | /* FALLTHROUGH */ |
|
|
767 | #endif |
|
|
768 | case XK_Home: |
727 | case XK_Home: |
769 | strcpy (kbuf, KS_HOME); |
728 | strcpy (kbuf, KS_HOME); |
770 | break; |
729 | break; |
771 | |
730 | |
772 | #define FKEY(n, fkey) \ |
731 | #define FKEY(n, fkey) \ |
… | |
… | |
874 | return; |
833 | return; |
875 | |
834 | |
876 | if (len <= 0) |
835 | if (len <= 0) |
877 | return; /* not mapped */ |
836 | return; /* not mapped */ |
878 | |
837 | |
879 | if (OPTION (Opt_scrollTtyKeypress)) |
838 | if (option (Opt_scrollTtyKeypress)) |
880 | if (view_start) |
839 | if (view_start) |
881 | { |
840 | { |
882 | view_start = 0; |
841 | view_start = 0; |
883 | want_refresh = 1; |
842 | want_refresh = 1; |
884 | } |
843 | } |
… | |
… | |
908 | tt_write (&ch, 1); |
867 | tt_write (&ch, 1); |
909 | } |
868 | } |
910 | |
869 | |
911 | tt_write (kbuf, (unsigned int)len); |
870 | tt_write (kbuf, (unsigned int)len); |
912 | } |
871 | } |
913 | /*}}} */ |
872 | |
|
|
873 | void |
|
|
874 | rxvt_term::key_release (XKeyEvent &ev) |
|
|
875 | { |
|
|
876 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
877 | KeySym keysym; |
|
|
878 | |
|
|
879 | keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
880 | #endif |
|
|
881 | |
|
|
882 | #if ENABLE_FRILLS || ISO_14755 |
|
|
883 | // ISO 14755 support |
|
|
884 | if (iso14755buf) |
|
|
885 | if (iso14755buf & ISO_14755_52) |
|
|
886 | { |
|
|
887 | # if ISO_14755 |
|
|
888 | scr_overlay_off (); |
|
|
889 | # endif |
|
|
890 | # if ISO_14755 |
|
|
891 | // iso14755 part 5.2 handling: release time |
|
|
892 | // first: controls |
|
|
893 | if ((ev.state & ControlMask) |
|
|
894 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
895 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
896 | { |
|
|
897 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
898 | commit_iso14755 (); |
|
|
899 | |
|
|
900 | return; |
|
|
901 | } |
|
|
902 | |
|
|
903 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
904 | if (i[0] == keysym) |
|
|
905 | { |
|
|
906 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
907 | commit_iso14755 (); |
|
|
908 | |
|
|
909 | return; |
|
|
910 | } |
|
|
911 | |
|
|
912 | scr_bell (); |
|
|
913 | # endif |
|
|
914 | iso14755buf = 0; |
|
|
915 | |
|
|
916 | return; |
|
|
917 | } |
|
|
918 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
919 | { |
|
|
920 | # if ISO_14755 |
|
|
921 | scr_overlay_off (); |
|
|
922 | # endif |
|
|
923 | if (iso14755buf & ISO_14755_51) |
|
|
924 | commit_iso14755 (); |
|
|
925 | #if ISO_14755 |
|
|
926 | else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) |
|
|
927 | { |
|
|
928 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
929 | |
|
|
930 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
931 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
932 | } |
|
|
933 | # endif |
|
|
934 | else |
|
|
935 | iso14755buf = 0; |
|
|
936 | } |
|
|
937 | #endif |
|
|
938 | |
|
|
939 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
940 | return; |
|
|
941 | |
|
|
942 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
943 | if (!(ev.state & ControlMask)) |
|
|
944 | slip_wheel_ev.stop (); |
|
|
945 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
946 | mouse_slip_wheel_speed = 0; |
|
|
947 | #endif |
|
|
948 | } |
914 | |
949 | |
915 | #if defined (KEYSYM_RESOURCE) |
950 | #if defined (KEYSYM_RESOURCE) |
916 | unsigned int |
951 | unsigned int |
917 | rxvt_term::cmd_write (const char *str, unsigned int count) |
952 | rxvt_term::cmd_write (const char *str, unsigned int count) |
918 | { |
953 | { |
… | |
… | |
948 | void |
983 | void |
949 | rxvt_term::flush () |
984 | rxvt_term::flush () |
950 | { |
985 | { |
951 | flush_ev.stop (); |
986 | flush_ev.stop (); |
952 | |
987 | |
953 | #ifdef TRANSPARENT |
988 | #ifdef HAVE_BG_PIXMAP |
954 | if (want_full_refresh) |
989 | if (bgPixmap.check_clearChanged ()) |
955 | { |
990 | { |
956 | want_full_refresh = 0; |
991 | // scr_clear (true); This needs to be researched further! |
957 | scr_clear (); |
|
|
958 | scr_touch (false); |
992 | scr_touch (false); |
959 | } |
993 | } |
960 | #endif |
994 | #endif |
961 | |
995 | |
962 | if (want_refresh) |
996 | if (want_refresh) |
… | |
… | |
1008 | |
1042 | |
1009 | display->flush (); |
1043 | display->flush (); |
1010 | } |
1044 | } |
1011 | |
1045 | |
1012 | void |
1046 | void |
1013 | rxvt_term::check_cb (check_watcher &w) |
1047 | rxvt_term::prepare_cb (ev::prepare &w, int revents) |
1014 | { |
1048 | { |
1015 | make_current (); |
1049 | make_current (); |
1016 | |
1050 | |
1017 | display->flush (); |
1051 | display->flush (); |
1018 | |
1052 | |
1019 | if (want_refresh && !flush_ev.active) |
1053 | if (want_refresh && !flush_ev.active) |
1020 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1054 | flush_ev.start (1. / 60.); // refresh at max. 60 hz normally |
1021 | } |
1055 | } |
1022 | |
1056 | |
1023 | void |
1057 | void |
1024 | rxvt_term::flush_cb (time_watcher &w) |
1058 | rxvt_term::flush_cb (ev::timer &w, int revents) |
1025 | { |
1059 | { |
1026 | make_current (); |
1060 | make_current (); |
1027 | |
1061 | |
1028 | refresh_limit = 1; |
|
|
1029 | refresh_count = 0; |
1062 | refresh_count = 0; |
1030 | flush (); |
1063 | flush (); |
1031 | } |
1064 | } |
1032 | |
1065 | |
1033 | #ifdef CURSOR_BLINK |
1066 | #ifdef CURSOR_BLINK |
1034 | void |
1067 | void |
1035 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1068 | rxvt_term::cursor_blink_cb (ev::timer &w, int revents) |
1036 | { |
1069 | { |
1037 | hidden_cursor = !hidden_cursor; |
1070 | hidden_cursor = !hidden_cursor; |
1038 | want_refresh = 1; |
1071 | want_refresh = 1; |
1039 | |
|
|
1040 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
|
|
1041 | } |
1072 | } |
1042 | #endif |
1073 | #endif |
1043 | |
1074 | |
1044 | #ifdef TEXT_BLINK |
1075 | #ifdef TEXT_BLINK |
1045 | void |
1076 | void |
1046 | rxvt_term::text_blink_cb (time_watcher &w) |
1077 | rxvt_term::text_blink_cb (ev::timer &w, int revents) |
1047 | { |
1078 | { |
1048 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1079 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1049 | { |
1080 | { |
1050 | hidden_text = !hidden_text; |
1081 | hidden_text = !hidden_text; |
1051 | want_refresh = 1; |
1082 | want_refresh = 1; |
1052 | w.start (w.at + TEXT_BLINK_INTERVAL); |
|
|
1053 | } |
1083 | } |
1054 | } |
1084 | } |
1055 | #endif |
1085 | #endif |
1056 | |
1086 | |
1057 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1087 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1058 | void |
1088 | void |
1059 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1089 | rxvt_term::cont_scroll_cb (ev::timer &w, int revents) |
1060 | { |
1090 | { |
1061 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1091 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1062 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1092 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1063 | { |
|
|
1064 | want_refresh = 1; |
1093 | want_refresh = 1; |
1065 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1094 | else |
1066 | } |
1095 | w.stop (); |
1067 | } |
1096 | } |
1068 | #endif |
1097 | #endif |
1069 | |
1098 | |
1070 | #ifdef SELECTION_SCROLLING |
1099 | #ifdef SELECTION_SCROLLING |
1071 | void |
1100 | void |
1072 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1101 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1073 | { |
1102 | { |
1074 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1103 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1075 | { |
1104 | { |
1076 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1105 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1077 | want_refresh = 1; |
1106 | want_refresh = 1; |
1078 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
|
|
1079 | } |
1107 | } |
|
|
1108 | else |
|
|
1109 | w.stop (); |
1080 | } |
1110 | } |
1081 | #endif |
1111 | #endif |
1082 | |
1112 | |
1083 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1113 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1084 | void |
1114 | void |
1085 | rxvt_term::slip_wheel_cb (time_watcher &w) |
1115 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1086 | { |
1116 | { |
1087 | if (mouse_slip_wheel_speed == 0 |
1117 | if (mouse_slip_wheel_speed == 0 |
1088 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1118 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1089 | : scr_page (UP, mouse_slip_wheel_speed)) |
1119 | : scr_page (UP, mouse_slip_wheel_speed)) |
1090 | { |
1120 | { |
1091 | if (view_start == top_row || view_start == 0) |
1121 | if (view_start == top_row || view_start == 0) |
1092 | mouse_slip_wheel_speed = 0; |
1122 | mouse_slip_wheel_speed = 0; |
1093 | |
1123 | |
1094 | want_refresh = 1; |
1124 | want_refresh = 1; |
1095 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
|
|
1096 | } |
1125 | } |
|
|
1126 | else |
|
|
1127 | w.stop (); |
1097 | } |
1128 | } |
1098 | #endif |
1129 | #endif |
1099 | |
1130 | |
1100 | #if HAVE_SCHED_YIELD |
1131 | #if LINUX_YIELD_HACK |
1101 | static struct event_handler |
1132 | static struct event_handler |
1102 | { |
1133 | { |
1103 | check_watcher cw_yield; |
1134 | ev::prepare yield_ev; |
1104 | |
1135 | |
1105 | void yield (check_watcher &w) |
1136 | void yield_cb (ev::prepare &w, int revents) |
1106 | { |
1137 | { |
1107 | sched_yield (); |
1138 | // this should really be sched_yield(), but the linux guys thought |
|
|
1139 | // that giving a process calling sched_yield () less cpu time than |
|
|
1140 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1141 | // allowed by the sus... as is returning ENOSYS. |
|
|
1142 | |
|
|
1143 | struct timespec ts = { 0, 0 }; |
|
|
1144 | nanosleep (&ts, 0); |
|
|
1145 | |
1108 | w.stop (); |
1146 | w.stop (); |
1109 | } |
1147 | } |
1110 | |
1148 | |
1111 | event_handler () |
1149 | event_handler () |
1112 | : cw_yield (this, &event_handler::yield) |
1150 | : yield_ev (this, &event_handler::yield_cb) |
1113 | { |
1151 | { |
1114 | } |
1152 | } |
1115 | } event_handler; |
1153 | } event_handler; |
1116 | #endif |
1154 | #endif |
1117 | |
1155 | |
… | |
… | |
1137 | cmdbuf_endp += r; |
1175 | cmdbuf_endp += r; |
1138 | return true; |
1176 | return true; |
1139 | } |
1177 | } |
1140 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1178 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1141 | { |
1179 | { |
1142 | #if HAVE_SCHED_YIELD |
1180 | #if LINUX_YIELD_HACK |
1143 | if (display->is_local) |
1181 | if (display->is_local) |
1144 | event_handler.cw_yield.start (); |
1182 | event_handler.yield_ev.start (); |
1145 | #endif |
1183 | #endif |
1146 | } |
1184 | } |
1147 | else |
1185 | else |
1148 | { |
1186 | { |
1149 | pty_ev.stop (); |
1187 | pty_ev.stop (); |
1150 | |
1188 | |
1151 | if (!OPTION (Opt_hold)) |
1189 | if (!option (Opt_hold)) |
1152 | destroy (); |
1190 | destroy (); |
1153 | } |
1191 | } |
1154 | |
1192 | |
1155 | return false; |
1193 | return false; |
1156 | } |
1194 | } |
1157 | |
1195 | |
1158 | void |
1196 | void |
1159 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1197 | rxvt_term::pty_cb (ev::io &w, int revents) |
1160 | { |
1198 | { |
1161 | make_current (); |
1199 | make_current (); |
1162 | |
1200 | |
1163 | if (revents & EVENT_READ) |
1201 | if (revents & ev::READ) |
1164 | // loop, but don't allow a single term to monopolize us |
1202 | // loop, but don't allow a single term to monopolize us |
1165 | while (pty_fill ()) |
1203 | while (pty_fill ()) |
1166 | if (cmd_parse ()) |
1204 | if (cmd_parse ()) |
1167 | break; |
1205 | break; |
1168 | |
1206 | |
1169 | if (revents & EVENT_WRITE) |
1207 | if (revents & ev::WRITE) |
1170 | pty_write (); |
1208 | pty_write (); |
1171 | } |
1209 | } |
1172 | |
1210 | |
1173 | void |
1211 | void |
1174 | rxvt_term::pointer_unblank () |
1212 | rxvt_term::pointer_unblank () |
1175 | { |
1213 | { |
1176 | XDefineCursor (xdisp, vt, TermWin_cursor); |
1214 | XDefineCursor (dpy, vt, TermWin_cursor); |
1177 | recolour_cursor (); |
1215 | recolour_cursor (); |
1178 | |
1216 | |
1179 | #ifdef POINTER_BLANK |
1217 | #ifdef POINTER_BLANK |
1180 | hidden_pointer = 0; |
1218 | hidden_pointer = 0; |
1181 | |
1219 | |
1182 | if (OPTION (Opt_pointerBlank)) |
1220 | if (option (Opt_pointerBlank)) |
1183 | pointer_ev.start (NOW + pointerBlankDelay); |
1221 | pointer_ev.start (pointerBlankDelay); |
1184 | #endif |
1222 | #endif |
1185 | } |
1223 | } |
1186 | |
1224 | |
1187 | #ifdef POINTER_BLANK |
1225 | #ifdef POINTER_BLANK |
1188 | void |
1226 | void |
1189 | rxvt_term::pointer_blank () |
1227 | rxvt_term::pointer_blank () |
1190 | { |
1228 | { |
1191 | if (!OPTION (Opt_pointerBlank)) |
1229 | if (!option (Opt_pointerBlank)) |
1192 | return; |
1230 | return; |
1193 | |
1231 | |
1194 | XDefineCursor (xdisp, vt, display->blank_cursor); |
1232 | XDefineCursor (dpy, vt, display->blank_cursor); |
1195 | XFlush (xdisp); |
1233 | XFlush (dpy); |
1196 | |
1234 | |
1197 | hidden_pointer = 1; |
1235 | hidden_pointer = 1; |
1198 | } |
1236 | } |
1199 | |
1237 | |
1200 | void |
1238 | void |
1201 | rxvt_term::pointer_cb (time_watcher &w) |
1239 | rxvt_term::pointer_cb (ev::timer &w, int revents) |
1202 | { |
1240 | { |
1203 | make_current (); |
1241 | make_current (); |
1204 | |
1242 | |
1205 | pointer_blank (); |
1243 | pointer_blank (); |
1206 | } |
1244 | } |
… | |
… | |
1209 | void |
1247 | void |
1210 | rxvt_term::mouse_report (XButtonEvent &ev) |
1248 | rxvt_term::mouse_report (XButtonEvent &ev) |
1211 | { |
1249 | { |
1212 | int button_number, key_state = 0; |
1250 | int button_number, key_state = 0; |
1213 | int x, y; |
1251 | int x, y; |
|
|
1252 | int code = 32; |
1214 | |
1253 | |
1215 | x = ev.x; |
1254 | x = Pixel2Col (ev.x); |
1216 | y = ev.y; |
1255 | y = Pixel2Row (ev.y); |
1217 | pixel_position (&x, &y); |
1256 | if (ev.type == MotionNotify) { |
|
|
1257 | if (x == mouse_row && y == mouse_col) |
|
|
1258 | return; |
|
|
1259 | mouse_row = x; |
|
|
1260 | mouse_col = y; |
|
|
1261 | code += 32; |
|
|
1262 | } |
1218 | |
1263 | |
1219 | if (MEvent.button == AnyButton) |
1264 | if (MEvent.button == AnyButton) |
1220 | button_number = 3; |
1265 | button_number = 3; |
1221 | else |
1266 | else |
1222 | { |
1267 | { |
… | |
… | |
1268 | x + 1, |
1313 | x + 1, |
1269 | y + 1); |
1314 | y + 1); |
1270 | #endif |
1315 | #endif |
1271 | |
1316 | |
1272 | tt_printf ("\033[M%c%c%c", |
1317 | tt_printf ("\033[M%c%c%c", |
1273 | (32 + button_number + key_state), |
1318 | (code + button_number + key_state), |
1274 | (32 + x + 1), |
1319 | (32 + x + 1), |
1275 | (32 + y + 1)); |
1320 | (32 + y + 1)); |
1276 | } |
1321 | } |
1277 | |
1322 | |
1278 | /*{{{ process an X event */ |
1323 | /*{{{ process an X event */ |
1279 | void |
1324 | void |
1280 | rxvt_term::x_cb (XEvent &ev) |
1325 | rxvt_term::x_cb (XEvent &ev) |
1281 | { |
1326 | { |
1282 | make_current (); |
1327 | make_current (); |
1283 | |
1328 | |
1284 | dLocal (Display *, xdisp); |
1329 | dLocal (Display *, dpy); |
1285 | |
1330 | |
1286 | if (ev.xany.window == vt |
1331 | if (ev.xany.window == vt |
1287 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1332 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1288 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1333 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1289 | return; |
1334 | return; |
… | |
… | |
1294 | unsigned int unused_mask; |
1339 | unsigned int unused_mask; |
1295 | |
1340 | |
1296 | switch (ev.type) |
1341 | switch (ev.type) |
1297 | { |
1342 | { |
1298 | case KeyPress: |
1343 | case KeyPress: |
1299 | #if ISO_14755 |
1344 | key_press (ev.xkey); |
1300 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1301 | #endif |
|
|
1302 | lookup_key (ev.xkey); |
|
|
1303 | |
|
|
1304 | break; |
1345 | break; |
1305 | |
1346 | |
1306 | case KeyRelease: |
1347 | case KeyRelease: |
1307 | { |
1348 | key_release (ev.xkey); |
1308 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
1309 | KeySym keysym; |
|
|
1310 | |
|
|
1311 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1312 | #endif |
|
|
1313 | |
|
|
1314 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1315 | // ISO 14755 support |
|
|
1316 | if (iso14755buf) |
|
|
1317 | if (iso14755buf & ISO_14755_52) |
|
|
1318 | { |
|
|
1319 | # if ENABLE_OVERLAY |
|
|
1320 | scr_overlay_off (); |
|
|
1321 | # endif |
|
|
1322 | # if ISO_14755 |
|
|
1323 | // iso14755 part 5.2 handling: release time |
|
|
1324 | // first: controls |
|
|
1325 | if ((ev.xkey.state & ControlMask) |
|
|
1326 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
1327 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
1328 | { |
|
|
1329 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
1330 | commit_iso14755 (); |
|
|
1331 | goto skip_switch; |
|
|
1332 | } |
|
|
1333 | |
|
|
1334 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1335 | if (i[0] == keysym) |
|
|
1336 | { |
|
|
1337 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1338 | commit_iso14755 (); |
|
|
1339 | goto skip_switch; |
|
|
1340 | } |
|
|
1341 | |
|
|
1342 | scr_bell (); |
|
|
1343 | # endif |
|
|
1344 | iso14755buf = 0; |
|
|
1345 | break; |
|
|
1346 | } |
|
|
1347 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1348 | { |
|
|
1349 | # if ENABLE_OVERLAY |
|
|
1350 | scr_overlay_off (); |
|
|
1351 | # endif |
|
|
1352 | if (iso14755buf & ISO_14755_51) |
|
|
1353 | commit_iso14755 (); |
|
|
1354 | #if ISO_14755 |
|
|
1355 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1356 | { |
|
|
1357 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1358 | |
|
|
1359 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1360 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1361 | } |
|
|
1362 | # endif |
|
|
1363 | else |
|
|
1364 | iso14755buf = 0; |
|
|
1365 | } |
|
|
1366 | #endif |
|
|
1367 | |
|
|
1368 | if (ev.xany.window == vt |
|
|
1369 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1370 | break; |
|
|
1371 | |
|
|
1372 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1373 | if (!(ev.xkey.state & ControlMask)) |
|
|
1374 | slip_wheel_ev.stop (); |
|
|
1375 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
1376 | mouse_slip_wheel_speed = 0; |
|
|
1377 | #endif |
|
|
1378 | break; |
1349 | break; |
1379 | } |
|
|
1380 | |
1350 | |
1381 | case ButtonPress: |
1351 | case ButtonPress: |
1382 | button_press (ev.xbutton); |
1352 | button_press (ev.xbutton); |
1383 | break; |
1353 | break; |
1384 | |
1354 | |
… | |
… | |
1399 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1369 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1400 | destroy (); |
1370 | destroy (); |
1401 | } |
1371 | } |
1402 | #if ENABLE_EWMH |
1372 | #if ENABLE_EWMH |
1403 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1373 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1404 | XSendEvent (xdisp, ev.xclient.window = display->root, |
1374 | XSendEvent (dpy, ev.xclient.window = display->root, |
1405 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1375 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1406 | &ev); |
1376 | &ev); |
1407 | #endif |
1377 | #endif |
1408 | } |
1378 | } |
1409 | } |
1379 | } |
… | |
… | |
1415 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
1385 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
1416 | focus_out (); |
1386 | focus_out (); |
1417 | } |
1387 | } |
1418 | #endif |
1388 | #endif |
1419 | } |
1389 | } |
1420 | break; |
|
|
1421 | |
|
|
1422 | case MappingNotify: |
|
|
1423 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1424 | break; |
1390 | break; |
1425 | |
1391 | |
1426 | /* |
1392 | /* |
1427 | * XXX: this is not the _current_ arrangement |
1393 | * XXX: this is not the _current_ arrangement |
1428 | * Here's my conclusion: |
1394 | * Here's my conclusion: |
… | |
… | |
1447 | break; |
1413 | break; |
1448 | } |
1414 | } |
1449 | break; |
1415 | break; |
1450 | |
1416 | |
1451 | case FocusIn: |
1417 | case FocusIn: |
|
|
1418 | if (ev.xfocus.detail != NotifyInferior |
|
|
1419 | && ev.xfocus.detail != NotifyPointer |
|
|
1420 | && ev.xfocus.mode != NotifyGrab) |
1452 | focus_in (); |
1421 | focus_in (); |
1453 | break; |
1422 | break; |
1454 | |
1423 | |
1455 | case FocusOut: |
1424 | case FocusOut: |
|
|
1425 | if (ev.xfocus.detail != NotifyInferior |
|
|
1426 | && ev.xfocus.detail != NotifyPointer |
|
|
1427 | && ev.xfocus.mode != NotifyGrab) |
1456 | focus_out (); |
1428 | focus_out (); |
1457 | break; |
1429 | break; |
1458 | |
1430 | |
1459 | case ConfigureNotify: |
1431 | case ConfigureNotify: |
|
|
1432 | /* fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", |
|
|
1433 | ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, |
|
|
1434 | szHint.width, szHint.height); */ |
1460 | if (ev.xconfigure.window == parent[0]) |
1435 | if (ev.xconfigure.window == parent[0]) |
1461 | { |
1436 | { |
1462 | while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1437 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1463 | ; |
1438 | ; |
1464 | |
1439 | |
1465 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1440 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1466 | { |
1441 | { |
1467 | seen_resize = 1; |
1442 | seen_resize = 1; |
1468 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1443 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1469 | } |
1444 | } |
1470 | |
1445 | else |
|
|
1446 | { |
|
|
1447 | #ifdef HAVE_BG_PIXMAP |
|
|
1448 | if (bgPixmap.window_position_sensitive ()) |
|
|
1449 | update_background (); |
|
|
1450 | #endif |
|
|
1451 | } |
1471 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1452 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1472 | |
|
|
1473 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
|
|
1474 | if (OPTION (Opt_transparent)) |
|
|
1475 | check_our_parents (); |
|
|
1476 | #endif |
|
|
1477 | } |
1453 | } |
1478 | break; |
1454 | break; |
1479 | |
1455 | |
1480 | case PropertyNotify: |
1456 | case PropertyNotify: |
1481 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1457 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
… | |
… | |
1499 | break; |
1475 | break; |
1500 | |
1476 | |
1501 | case MapNotify: |
1477 | case MapNotify: |
1502 | mapped = 1; |
1478 | mapped = 1; |
1503 | #ifdef TEXT_BLINK |
1479 | #ifdef TEXT_BLINK |
1504 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
1480 | text_blink_ev.start (TEXT_BLINK_INTERVAL); |
1505 | #endif |
1481 | #endif |
1506 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1482 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1507 | break; |
1483 | break; |
1508 | |
1484 | |
1509 | case UnmapNotify: |
1485 | case UnmapNotify: |
… | |
… | |
1511 | #ifdef TEXT_BLINK |
1487 | #ifdef TEXT_BLINK |
1512 | text_blink_ev.stop (); |
1488 | text_blink_ev.stop (); |
1513 | #endif |
1489 | #endif |
1514 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1490 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1515 | break; |
1491 | break; |
1516 | |
|
|
1517 | #ifdef TRANSPARENT |
|
|
1518 | case ReparentNotify: |
|
|
1519 | rootwin_cb (ev); |
|
|
1520 | break; |
|
|
1521 | #endif /* TRANSPARENT */ |
|
|
1522 | |
1492 | |
1523 | case GraphicsExpose: |
1493 | case GraphicsExpose: |
1524 | case Expose: |
1494 | case Expose: |
1525 | if (ev.xany.window == vt) |
1495 | if (ev.xany.window == vt) |
1526 | { |
1496 | { |
1527 | do |
1497 | do |
|
|
1498 | { |
1528 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1499 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1529 | ev.xexpose.width, ev.xexpose.height, False); |
1500 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1501 | } |
1530 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); |
1502 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1531 | |
1503 | |
1532 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1504 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1533 | |
1505 | |
1534 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) |
1506 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
|
|
1507 | { |
1535 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1508 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1536 | ev.xexpose.width, ev.xexpose.height, False); |
1509 | ev.xexpose.width, ev.xexpose.height, False); |
1537 | |
1510 | } |
1538 | want_refresh = 1; |
1511 | want_refresh = 1; |
1539 | } |
1512 | } |
1540 | else |
1513 | else |
1541 | { |
1514 | { |
1542 | XEvent unused_event; |
1515 | XEvent unused_event; |
1543 | |
1516 | |
1544 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) |
1517 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1545 | ; |
1518 | ; |
1546 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) |
1519 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1547 | ; |
1520 | ; |
1548 | |
1521 | |
1549 | if (isScrollbarWindow (ev.xany.window)) |
1522 | if (isScrollbarWindow (ev.xany.window)) |
1550 | { |
1523 | { |
1551 | scrollBar.setIdle (); |
1524 | scrollBar.setIdle (); |
1552 | scrollbar_show (0); |
1525 | scrollbar_show (0); |
1553 | } |
1526 | } |
1554 | |
|
|
1555 | #ifdef TRANSPARENT |
|
|
1556 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1557 | XClearWindow (xdisp, ev.xany.window); |
|
|
1558 | #endif |
|
|
1559 | } |
1527 | } |
1560 | break; |
1528 | break; |
1561 | |
1529 | |
1562 | case MotionNotify: |
1530 | case MotionNotify: |
1563 | #ifdef POINTER_BLANK |
1531 | #ifdef POINTER_BLANK |
1564 | if (hidden_pointer) |
1532 | if (hidden_pointer) |
1565 | pointer_unblank (); |
1533 | pointer_unblank (); |
1566 | #endif |
1534 | #endif |
|
|
1535 | if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) |
|
|
1536 | || priv_modes & PrivMode_MouseAnyEvent) |
|
|
1537 | mouse_report (ev.xbutton); |
1567 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1538 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1568 | break; |
1539 | break; |
1569 | |
1540 | |
1570 | if (ev.xany.window == vt) |
1541 | if (ev.xany.window == vt) |
1571 | { |
1542 | { |
1572 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1543 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1573 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1544 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1574 | ; // nop |
1545 | ; // nop |
1575 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1546 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1576 | { |
1547 | { |
1577 | while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) |
1548 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1578 | ; |
1549 | ; |
1579 | |
1550 | |
1580 | XQueryPointer (xdisp, vt, |
1551 | XQueryPointer (dpy, vt, |
1581 | &unused_root, &unused_child, |
1552 | &unused_root, &unused_child, |
1582 | &unused_root_x, &unused_root_y, |
1553 | &unused_root_x, &unused_root_y, |
1583 | &ev.xbutton.x, &ev.xbutton.y, |
1554 | &ev.xbutton.x, &ev.xbutton.y, |
1584 | &ev.xbutton.state); |
1555 | &ev.xbutton.state); |
1585 | #ifdef MOUSE_THRESHOLD |
1556 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1606 | |
1577 | |
1607 | /* don't clobber the current delay if we are |
1578 | /* don't clobber the current delay if we are |
1608 | * already in the middle of scrolling. |
1579 | * already in the middle of scrolling. |
1609 | */ |
1580 | */ |
1610 | if (!sel_scroll_ev.active) |
1581 | if (!sel_scroll_ev.active) |
1611 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1582 | sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1612 | |
1583 | |
1613 | /* save the event params so we can highlight |
1584 | /* save the event params so we can highlight |
1614 | * the selection in the pending-scroll loop |
1585 | * the selection in the pending-scroll loop |
1615 | */ |
1586 | */ |
1616 | selection_save_x = ev.xbutton.x; |
1587 | selection_save_x = ev.xbutton.x; |
… | |
… | |
1649 | #endif |
1620 | #endif |
1650 | } |
1621 | } |
1651 | } |
1622 | } |
1652 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1623 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1653 | { |
1624 | { |
1654 | while (XCheckTypedWindowEvent (xdisp, scrollBar.win, |
1625 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1655 | MotionNotify, &ev)) |
1626 | MotionNotify, &ev)) |
1656 | ; |
1627 | ; |
1657 | |
1628 | |
1658 | XQueryPointer (xdisp, scrollBar.win, |
1629 | XQueryPointer (dpy, scrollBar.win, |
1659 | &unused_root, &unused_child, |
1630 | &unused_root, &unused_child, |
1660 | &unused_root_x, &unused_root_y, |
1631 | &unused_root_x, &unused_root_y, |
1661 | &ev.xbutton.x, &ev.xbutton.y, |
1632 | &ev.xbutton.x, &ev.xbutton.y, |
1662 | &unused_mask); |
1633 | &unused_mask); |
1663 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1634 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1664 | scrollbar_size ()); |
1635 | scrollbar_size ()); |
1665 | want_refresh = 1; |
1636 | want_refresh = 1; |
1666 | refresh_limit = 0; |
|
|
1667 | scrollbar_show (1); |
1637 | scrollbar_show (1); |
1668 | } |
1638 | } |
1669 | break; |
1639 | break; |
1670 | } |
1640 | } |
1671 | |
1641 | |
1672 | skip_switch: ; |
|
|
1673 | |
|
|
1674 | #if defined(CURSOR_BLINK) |
1642 | #if defined(CURSOR_BLINK) |
1675 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1643 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
1676 | { |
1644 | { |
1677 | if (hidden_cursor) |
1645 | if (hidden_cursor) |
1678 | { |
1646 | { |
1679 | hidden_cursor = 0; |
1647 | hidden_cursor = 0; |
1680 | want_refresh = 1; |
1648 | want_refresh = 1; |
1681 | } |
1649 | } |
1682 | |
1650 | |
1683 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1651 | cursor_blink_ev.again (); |
1684 | } |
1652 | } |
1685 | #endif |
1653 | #endif |
1686 | |
1654 | |
1687 | #if defined(POINTER_BLANK) |
1655 | #if defined(POINTER_BLANK) |
1688 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1656 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
1689 | { |
1657 | { |
1690 | if (ev.type == MotionNotify |
1658 | if (ev.type == MotionNotify |
1691 | || ev.type == ButtonPress |
1659 | || ev.type == ButtonPress |
1692 | || ev.type == ButtonRelease) |
1660 | || ev.type == ButtonRelease) |
1693 | if (hidden_pointer) |
1661 | if (hidden_pointer) |
… | |
… | |
1705 | if (!focus) |
1673 | if (!focus) |
1706 | { |
1674 | { |
1707 | focus = 1; |
1675 | focus = 1; |
1708 | want_refresh = 1; |
1676 | want_refresh = 1; |
1709 | |
1677 | |
1710 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1678 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1711 | |
1679 | |
1712 | #if USE_XIM |
1680 | #if USE_XIM |
1713 | if (Input_Context != NULL) |
1681 | if (Input_Context != NULL) |
1714 | { |
1682 | { |
1715 | IMSetStatusPosition (); |
1683 | IMSetPosition (); |
1716 | XSetICFocus (Input_Context); |
1684 | XSetICFocus (Input_Context); |
1717 | } |
1685 | } |
1718 | #endif |
1686 | #endif |
1719 | #if CURSOR_BLINK |
1687 | #if CURSOR_BLINK |
1720 | if (OPTION (Opt_cursorBlink)) |
1688 | if (option (Opt_cursorBlink)) |
1721 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1689 | cursor_blink_ev.start (CURSOR_BLINK_INTERVAL, CURSOR_BLINK_INTERVAL); |
1722 | #endif |
1690 | #endif |
1723 | #if OFF_FOCUS_FADING |
1691 | #if OFF_FOCUS_FADING |
1724 | if (rs[Rs_fade]) |
1692 | if (rs[Rs_fade]) |
1725 | { |
1693 | { |
1726 | pix_colors = pix_colors_focused; |
1694 | pix_colors = pix_colors_focused; |
1727 | scr_recolour (); |
1695 | scr_recolour (); |
1728 | } |
1696 | } |
1729 | #endif |
1697 | #endif |
|
|
1698 | #if ENABLE_FRILLS |
|
|
1699 | if (option (Opt_urgentOnBell)) |
|
|
1700 | { |
|
|
1701 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1702 | { |
|
|
1703 | h->flags &= ~XUrgencyHint; |
|
|
1704 | XSetWMHints (dpy, parent[0], h); |
|
|
1705 | } |
|
|
1706 | } |
|
|
1707 | #endif |
1730 | } |
1708 | } |
1731 | } |
1709 | } |
1732 | |
1710 | |
1733 | void |
1711 | void |
1734 | rxvt_term::focus_out () |
1712 | rxvt_term::focus_out () |
… | |
… | |
1742 | |
1720 | |
1743 | #if ENABLE_FRILLS || ISO_14755 |
1721 | #if ENABLE_FRILLS || ISO_14755 |
1744 | if (iso14755buf) |
1722 | if (iso14755buf) |
1745 | { |
1723 | { |
1746 | iso14755buf = 0; |
1724 | iso14755buf = 0; |
1747 | # if ENABLE_OVERLAY |
1725 | # if ISO_14755 |
1748 | scr_overlay_off (); |
1726 | scr_overlay_off (); |
1749 | # endif |
1727 | # endif |
1750 | } |
1728 | } |
1751 | #endif |
1729 | #endif |
1752 | #if USE_XIM |
1730 | #if USE_XIM |
1753 | if (Input_Context != NULL) |
1731 | if (Input_Context != NULL) |
1754 | XUnsetICFocus (Input_Context); |
1732 | XUnsetICFocus (Input_Context); |
1755 | #endif |
1733 | #endif |
1756 | #if CURSOR_BLINK |
1734 | #if CURSOR_BLINK |
1757 | if (OPTION (Opt_cursorBlink)) |
1735 | if (option (Opt_cursorBlink)) |
1758 | cursor_blink_ev.stop (); |
1736 | cursor_blink_ev.stop (); |
|
|
1737 | |
1759 | hidden_cursor = 0; |
1738 | hidden_cursor = 0; |
1760 | #endif |
1739 | #endif |
1761 | #if OFF_FOCUS_FADING |
1740 | #if OFF_FOCUS_FADING |
1762 | if (rs[Rs_fade]) |
1741 | if (rs[Rs_fade]) |
1763 | { |
1742 | { |
… | |
… | |
1766 | } |
1745 | } |
1767 | #endif |
1746 | #endif |
1768 | } |
1747 | } |
1769 | } |
1748 | } |
1770 | |
1749 | |
1771 | #if TRANSPARENT |
1750 | void |
|
|
1751 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1752 | { |
|
|
1753 | #if OFF_FOCUS_FADING |
|
|
1754 | if (rs[Rs_fade]) |
|
|
1755 | { |
|
|
1756 | rgba c; |
|
|
1757 | pix_colors [Color_fade].get (c); |
|
|
1758 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1759 | } |
|
|
1760 | #endif |
|
|
1761 | } |
|
|
1762 | |
|
|
1763 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
1772 | void |
1764 | void |
1773 | rxvt_term::rootwin_cb (XEvent &ev) |
1765 | rxvt_term::rootwin_cb (XEvent &ev) |
1774 | { |
1766 | { |
1775 | make_current (); |
1767 | make_current (); |
1776 | |
1768 | |
|
|
1769 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1770 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1771 | return; |
|
|
1772 | |
|
|
1773 | # if ENABLE_TRANSPARENCY |
1777 | switch (ev.type) |
1774 | switch (ev.type) |
1778 | { |
1775 | { |
1779 | case PropertyNotify: |
1776 | case PropertyNotify: |
1780 | /* |
1777 | /* |
1781 | * if user used some Esetroot compatible prog to set the root bg, |
1778 | * if user used some Esetroot compatible prog to set the root bg, |
1782 | * use the property to determine the pixmap. We use it later on. |
1779 | * use the property to determine the pixmap. We use it later on. |
1783 | */ |
1780 | */ |
1784 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1781 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1785 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1782 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1786 | return; |
1783 | { |
1787 | |
1784 | bgPixmap.set_root_pixmap (); |
1788 | /* FALLTHROUGH */ |
1785 | update_background (); |
1789 | case ReparentNotify: |
1786 | } |
1790 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
|
|
1791 | want_refresh = want_full_refresh = 1; |
|
|
1792 | break; |
1787 | break; |
1793 | } |
1788 | } |
|
|
1789 | # endif |
1794 | } |
1790 | } |
1795 | #endif |
1791 | #endif |
1796 | |
1792 | |
1797 | void |
1793 | void |
1798 | rxvt_term::button_press (XButtonEvent &ev) |
1794 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1979 | upordown = 1; /* down */ |
1975 | upordown = 1; /* down */ |
1980 | } |
1976 | } |
1981 | if (upordown) |
1977 | if (upordown) |
1982 | { |
1978 | { |
1983 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1979 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1984 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1980 | cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1985 | #endif |
1981 | #endif |
1986 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1982 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1987 | { |
1983 | { |
1988 | if (upordown < 0) |
1984 | if (upordown < 0) |
1989 | scrollBar.setUp (); |
1985 | scrollBar.setUp (); |
… | |
… | |
2126 | selection_make (ev.time); |
2122 | selection_make (ev.time); |
2127 | break; |
2123 | break; |
2128 | |
2124 | |
2129 | case Button2: |
2125 | case Button2: |
2130 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2126 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2131 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2127 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2132 | break; |
2128 | break; |
2133 | |
2129 | |
2134 | #ifdef MOUSE_WHEEL |
2130 | #ifdef MOUSE_WHEEL |
2135 | case Button4: |
2131 | case Button4: |
2136 | case Button5: |
2132 | case Button5: |
… | |
… | |
2140 | |
2136 | |
2141 | v = ev.button == Button4 ? UP : DN; |
2137 | v = ev.button == Button4 ? UP : DN; |
2142 | |
2138 | |
2143 | if (ev.state & ShiftMask) |
2139 | if (ev.state & ShiftMask) |
2144 | i = 1; |
2140 | i = 1; |
2145 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2141 | else if (option (Opt_mouseWheelScrollPage)) |
2146 | i = nrow - 1; |
2142 | i = nrow - 1; |
2147 | else |
2143 | else |
2148 | i = 5; |
2144 | i = 5; |
2149 | |
2145 | |
2150 | # ifdef MOUSE_SLIP_WHEELING |
2146 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2152 | { |
2148 | { |
2153 | mouse_slip_wheel_speed += v ? -1 : 1; |
2149 | mouse_slip_wheel_speed += v ? -1 : 1; |
2154 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2150 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2155 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2151 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2156 | |
2152 | |
2157 | if (slip_wheel_ev.at < NOW) |
2153 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2158 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
|
|
2159 | |
|
|
2160 | slip_wheel_ev.start (); |
|
|
2161 | } |
2154 | } |
2162 | else |
2155 | else |
2163 | { |
2156 | { |
2164 | # endif |
2157 | # endif |
2165 | scr_page (v, i); |
2158 | scr_page (v, i); |
… | |
… | |
2171 | break; |
2164 | break; |
2172 | #endif |
2165 | #endif |
2173 | } |
2166 | } |
2174 | } |
2167 | } |
2175 | } |
2168 | } |
2176 | |
|
|
2177 | #ifdef TRANSPARENT |
|
|
2178 | #if TINTING |
|
|
2179 | /* taken from aterm-0.4.2 */ |
|
|
2180 | |
|
|
2181 | typedef uint32_t RUINT32T; |
|
|
2182 | |
|
|
2183 | void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2184 | { |
|
|
2185 | int sh_r, sh_g, sh_b; |
|
|
2186 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2187 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2188 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2189 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2190 | int i; |
|
|
2191 | |
|
|
2192 | Visual *visual = term->visual; |
|
|
2193 | |
|
|
2194 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2195 | |
|
|
2196 | /* for convenience */ |
|
|
2197 | mask_r = visual->red_mask; |
|
|
2198 | mask_g = visual->green_mask; |
|
|
2199 | mask_b = visual->blue_mask; |
|
|
2200 | |
|
|
2201 | /* boring lookup table pre-initialization */ |
|
|
2202 | switch (srcImage->bits_per_pixel) { |
|
|
2203 | case 15: |
|
|
2204 | if ((mask_r != 0x7c00) || |
|
|
2205 | (mask_g != 0x03e0) || |
|
|
2206 | (mask_b != 0x001f)) |
|
|
2207 | return; |
|
|
2208 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2209 | lookup_r = lookup; |
|
|
2210 | lookup_g = lookup+32; |
|
|
2211 | lookup_b = lookup+32+32; |
|
|
2212 | sh_r = 10; |
|
|
2213 | sh_g = 5; |
|
|
2214 | sh_b = 0; |
|
|
2215 | break; |
|
|
2216 | case 16: |
|
|
2217 | if ((mask_r != 0xf800) || |
|
|
2218 | (mask_g != 0x07e0) || |
|
|
2219 | (mask_b != 0x001f)) |
|
|
2220 | return; |
|
|
2221 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2222 | lookup_r = lookup; |
|
|
2223 | lookup_g = lookup+32; |
|
|
2224 | lookup_b = lookup+32+64; |
|
|
2225 | sh_r = 11; |
|
|
2226 | sh_g = 5; |
|
|
2227 | sh_b = 0; |
|
|
2228 | break; |
|
|
2229 | case 24: |
|
|
2230 | if ((mask_r != 0xff0000) || |
|
|
2231 | (mask_g != 0x00ff00) || |
|
|
2232 | (mask_b != 0x0000ff)) |
|
|
2233 | return; |
|
|
2234 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2235 | lookup_r = lookup; |
|
|
2236 | lookup_g = lookup+256; |
|
|
2237 | lookup_b = lookup+256+256; |
|
|
2238 | sh_r = 16; |
|
|
2239 | sh_g = 8; |
|
|
2240 | sh_b = 0; |
|
|
2241 | break; |
|
|
2242 | case 32: |
|
|
2243 | if ((mask_r != 0xff0000) || |
|
|
2244 | (mask_g != 0x00ff00) || |
|
|
2245 | (mask_b != 0x0000ff)) |
|
|
2246 | return; |
|
|
2247 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2248 | lookup_r = lookup; |
|
|
2249 | lookup_g = lookup+256; |
|
|
2250 | lookup_b = lookup+256+256; |
|
|
2251 | sh_r = 16; |
|
|
2252 | sh_g = 8; |
|
|
2253 | sh_b = 0; |
|
|
2254 | break; |
|
|
2255 | default: |
|
|
2256 | return; /* we do not support this color depth */ |
|
|
2257 | } |
|
|
2258 | |
|
|
2259 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2260 | if (shade < 0) { |
|
|
2261 | shade = -shade; |
|
|
2262 | if (shade < 0) shade = 0; |
|
|
2263 | if (shade > 100) shade = 100; |
|
|
2264 | |
|
|
2265 | lower_lim_r = 65535-rm; |
|
|
2266 | lower_lim_g = 65535-gm; |
|
|
2267 | lower_lim_b = 65535-bm; |
|
|
2268 | |
|
|
2269 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2270 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2271 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2272 | |
|
|
2273 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2274 | } else { |
|
|
2275 | if (shade < 0) shade = 0; |
|
|
2276 | if (shade > 100) shade = 100; |
|
|
2277 | |
|
|
2278 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2279 | |
|
|
2280 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2281 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2282 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2283 | } |
|
|
2284 | |
|
|
2285 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2286 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2287 | { |
|
|
2288 | unsigned int tmp; |
|
|
2289 | |
|
|
2290 | tmp = lower_lim_r; |
|
|
2291 | lower_lim_r = lower_lim_b; |
|
|
2292 | lower_lim_b = tmp; |
|
|
2293 | |
|
|
2294 | tmp = upper_lim_r; |
|
|
2295 | upper_lim_r = upper_lim_b; |
|
|
2296 | upper_lim_b = tmp; |
|
|
2297 | } |
|
|
2298 | |
|
|
2299 | /* fill our lookup tables */ |
|
|
2300 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2301 | { |
|
|
2302 | RUINT32T tmp; |
|
|
2303 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2304 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2305 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2306 | } |
|
|
2307 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2308 | { |
|
|
2309 | RUINT32T tmp; |
|
|
2310 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2311 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2312 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2313 | } |
|
|
2314 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2315 | { |
|
|
2316 | RUINT32T tmp; |
|
|
2317 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2318 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2319 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2320 | } |
|
|
2321 | |
|
|
2322 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2323 | switch (srcImage->bits_per_pixel) |
|
|
2324 | { |
|
|
2325 | case 15: |
|
|
2326 | { |
|
|
2327 | unsigned short *p1, *pf, *p, *pl; |
|
|
2328 | p1 = (unsigned short *) srcImage->data; |
|
|
2329 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2330 | while (p1 < pf) |
|
|
2331 | { |
|
|
2332 | p = p1; |
|
|
2333 | pl = p1 + srcImage->width; |
|
|
2334 | for (; p < pl; p++) |
|
|
2335 | { |
|
|
2336 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2337 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2338 | lookup_b[(*p & 0x001f)]; |
|
|
2339 | } |
|
|
2340 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2341 | } |
|
|
2342 | break; |
|
|
2343 | } |
|
|
2344 | case 16: |
|
|
2345 | { |
|
|
2346 | unsigned short *p1, *pf, *p, *pl; |
|
|
2347 | p1 = (unsigned short *) srcImage->data; |
|
|
2348 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2349 | while (p1 < pf) |
|
|
2350 | { |
|
|
2351 | p = p1; |
|
|
2352 | pl = p1 + srcImage->width; |
|
|
2353 | for (; p < pl; p++) |
|
|
2354 | { |
|
|
2355 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2356 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2357 | lookup_b[(*p & 0x001f)]; |
|
|
2358 | } |
|
|
2359 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2360 | } |
|
|
2361 | break; |
|
|
2362 | } |
|
|
2363 | case 24: |
|
|
2364 | { |
|
|
2365 | unsigned char *p1, *pf, *p, *pl; |
|
|
2366 | p1 = (unsigned char *) srcImage->data; |
|
|
2367 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2368 | while (p1 < pf) |
|
|
2369 | { |
|
|
2370 | p = p1; |
|
|
2371 | pl = p1 + srcImage->width * 3; |
|
|
2372 | for (; p < pl; p += 3) |
|
|
2373 | { |
|
|
2374 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2375 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2376 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2377 | } |
|
|
2378 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2379 | } |
|
|
2380 | break; |
|
|
2381 | } |
|
|
2382 | case 32: |
|
|
2383 | { |
|
|
2384 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2385 | p1 = (RUINT32T *) srcImage->data; |
|
|
2386 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2387 | |
|
|
2388 | while (p1 < pf) |
|
|
2389 | { |
|
|
2390 | p = p1; |
|
|
2391 | pl = p1 + srcImage->width; |
|
|
2392 | for (; p < pl; p++) |
|
|
2393 | { |
|
|
2394 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2395 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2396 | lookup_b[(*p & 0x0000ff)] | |
|
|
2397 | (*p & ~0xffffff); |
|
|
2398 | } |
|
|
2399 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2400 | } |
|
|
2401 | break; |
|
|
2402 | } |
|
|
2403 | } |
|
|
2404 | |
|
|
2405 | free (lookup); |
|
|
2406 | } |
|
|
2407 | #endif |
|
|
2408 | |
|
|
2409 | /* |
|
|
2410 | * Check our parents are still who we think they are. |
|
|
2411 | * Do transparency updates if required |
|
|
2412 | */ |
|
|
2413 | int |
|
|
2414 | rxvt_term::check_our_parents () |
|
|
2415 | { |
|
|
2416 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2417 | unsigned long nitems, bytes_after; |
|
|
2418 | Atom atype; |
|
|
2419 | unsigned char *prop = NULL; |
|
|
2420 | Window root, oldp, *list; |
|
|
2421 | Pixmap rootpixmap = None; |
|
|
2422 | XWindowAttributes wattr, wrootattr; |
|
|
2423 | |
|
|
2424 | pchanged = 0; |
|
|
2425 | |
|
|
2426 | if (!OPTION (Opt_transparent)) |
|
|
2427 | return pchanged; /* Don't try any more */ |
|
|
2428 | |
|
|
2429 | XGetWindowAttributes (xdisp, display->root, &wrootattr); |
|
|
2430 | rootdepth = wrootattr.depth; |
|
|
2431 | |
|
|
2432 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
|
|
2433 | |
|
|
2434 | if (rootdepth != wattr.depth) |
|
|
2435 | { |
|
|
2436 | if (am_transparent) |
|
|
2437 | { |
|
|
2438 | pchanged = 1; |
|
|
2439 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
|
|
2440 | am_transparent = am_pixmap_trans = 0; |
|
|
2441 | } |
|
|
2442 | |
|
|
2443 | return pchanged; /* Don't try any more */ |
|
|
2444 | } |
|
|
2445 | |
|
|
2446 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2447 | XSync (xdisp, False); |
|
|
2448 | |
|
|
2449 | /* |
|
|
2450 | * Make the frame window set by the window manager have |
|
|
2451 | * the root background. Some window managers put multiple nested frame |
|
|
2452 | * windows for each client, so we have to take care about that. |
|
|
2453 | */ |
|
|
2454 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2455 | && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2456 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2457 | &nitems, &bytes_after, &prop) == Success); |
|
|
2458 | |
|
|
2459 | if (!i || prop == NULL) |
|
|
2460 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2461 | && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2462 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2463 | &nitems, &bytes_after, &prop) == Success); |
|
|
2464 | |
|
|
2465 | if (!i || prop == NULL |
|
|
2466 | #if TINTING |
|
|
2467 | || !rs[Rs_color + Color_tint] |
|
|
2468 | #endif |
|
|
2469 | ) |
|
|
2470 | have_pixmap = 0; |
|
|
2471 | else |
|
|
2472 | { |
|
|
2473 | have_pixmap = 1; |
|
|
2474 | rootpixmap = *(Pixmap *)prop; |
|
|
2475 | XFree (prop); |
|
|
2476 | } |
|
|
2477 | |
|
|
2478 | if (have_pixmap) |
|
|
2479 | { |
|
|
2480 | /* |
|
|
2481 | * Copy display->root pixmap transparency |
|
|
2482 | */ |
|
|
2483 | int sx, sy, nx, ny; |
|
|
2484 | unsigned int nw, nh; |
|
|
2485 | Window cr; |
|
|
2486 | XImage *image; |
|
|
2487 | GC gc; |
|
|
2488 | XGCValues gcvalue; |
|
|
2489 | |
|
|
2490 | XTranslateCoordinates (xdisp, parent[0], display->root, |
|
|
2491 | 0, 0, &sx, &sy, &cr); |
|
|
2492 | nw = (unsigned int)szHint.width; |
|
|
2493 | nh = (unsigned int)szHint.height; |
|
|
2494 | nx = ny = 0; |
|
|
2495 | |
|
|
2496 | if (sx < 0) |
|
|
2497 | { |
|
|
2498 | nw += sx; |
|
|
2499 | nx = -sx; |
|
|
2500 | sx = 0; |
|
|
2501 | } |
|
|
2502 | |
|
|
2503 | if (sy < 0) |
|
|
2504 | { |
|
|
2505 | nh += sy; |
|
|
2506 | ny = -sy; |
|
|
2507 | sy = 0; |
|
|
2508 | } |
|
|
2509 | |
|
|
2510 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2511 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2512 | |
|
|
2513 | XSync (xdisp, False); |
|
|
2514 | allowedxerror = -1; |
|
|
2515 | image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2516 | |
|
|
2517 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2518 | /* XXX: may need a delay here? */ |
|
|
2519 | allowedxerror = 0; |
|
|
2520 | |
|
|
2521 | if (image == NULL) |
|
|
2522 | { |
|
|
2523 | if (am_transparent && am_pixmap_trans) |
|
|
2524 | { |
|
|
2525 | pchanged = 1; |
|
|
2526 | if (pixmap != None) |
|
|
2527 | { |
|
|
2528 | XFreePixmap (xdisp, pixmap); |
|
|
2529 | pixmap = None; |
|
|
2530 | } |
|
|
2531 | } |
|
|
2532 | |
|
|
2533 | am_pixmap_trans = 0; |
|
|
2534 | } |
|
|
2535 | else |
|
|
2536 | { |
|
|
2537 | if (pixmap != None) |
|
|
2538 | XFreePixmap (xdisp, pixmap); |
|
|
2539 | |
|
|
2540 | #if TINTING |
|
|
2541 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2542 | { |
|
|
2543 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2544 | |
|
|
2545 | rxvt_rgba c; |
|
|
2546 | pix_colors_focused [Color_tint].get (this, c); |
|
|
2547 | |
|
|
2548 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
|
|
2549 | } |
|
|
2550 | #endif |
|
|
2551 | |
|
|
2552 | pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); |
|
|
2553 | gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); |
|
|
2554 | XPutImage (xdisp, pixmap, gc, image, 0, 0, |
|
|
2555 | nx, ny, image->width, image->height); |
|
|
2556 | XFreeGC (xdisp, gc); |
|
|
2557 | XDestroyImage (image); |
|
|
2558 | XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); |
|
|
2559 | XClearWindow (xdisp, parent[0]); |
|
|
2560 | |
|
|
2561 | if (!am_transparent || !am_pixmap_trans) |
|
|
2562 | pchanged = 1; |
|
|
2563 | |
|
|
2564 | am_transparent = am_pixmap_trans = 1; |
|
|
2565 | } |
|
|
2566 | } |
|
|
2567 | |
|
|
2568 | if (am_pixmap_trans) |
|
|
2569 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
|
|
2570 | else |
|
|
2571 | { |
|
|
2572 | unsigned int n; |
|
|
2573 | /* |
|
|
2574 | * InheritPixmap transparency |
|
|
2575 | */ |
|
|
2576 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2577 | { |
|
|
2578 | oldp = parent[i]; |
|
|
2579 | XQueryTree (xdisp, parent[i - 1], &root, |
|
|
2580 | &parent[i], &list, &n); |
|
|
2581 | XFree (list); |
|
|
2582 | |
|
|
2583 | if (parent[i] == display->root) |
|
|
2584 | { |
|
|
2585 | if (oldp != None) |
|
|
2586 | pchanged = 1; |
|
|
2587 | |
|
|
2588 | break; |
|
|
2589 | } |
|
|
2590 | |
|
|
2591 | if (oldp != parent[i]) |
|
|
2592 | pchanged = 1; |
|
|
2593 | } |
|
|
2594 | |
|
|
2595 | n = 0; |
|
|
2596 | |
|
|
2597 | if (pchanged) |
|
|
2598 | { |
|
|
2599 | for (; n < (unsigned int)i; n++) |
|
|
2600 | { |
|
|
2601 | XGetWindowAttributes (xdisp, parent[n], &wattr); |
|
|
2602 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2603 | { |
|
|
2604 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2605 | break; |
|
|
2606 | } |
|
|
2607 | } |
|
|
2608 | } |
|
|
2609 | |
|
|
2610 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2611 | { |
|
|
2612 | XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); |
|
|
2613 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
|
|
2614 | am_transparent = 0; |
|
|
2615 | /* XXX: also turn off Opt_transparent? */ |
|
|
2616 | } |
|
|
2617 | else |
|
|
2618 | { |
|
|
2619 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2620 | { |
|
|
2621 | XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); |
|
|
2622 | XClearWindow (xdisp, parent[n]); |
|
|
2623 | } |
|
|
2624 | |
|
|
2625 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
|
|
2626 | am_transparent = 1; |
|
|
2627 | } |
|
|
2628 | |
|
|
2629 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2630 | parent[i] = None; |
|
|
2631 | } |
|
|
2632 | |
|
|
2633 | if (scrollBar.win) |
|
|
2634 | { |
|
|
2635 | XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); |
|
|
2636 | scrollBar.setIdle (); |
|
|
2637 | scrollbar_show (0); |
|
|
2638 | } |
|
|
2639 | |
|
|
2640 | if (am_transparent) |
|
|
2641 | { |
|
|
2642 | want_refresh = want_full_refresh = 1; |
|
|
2643 | if (am_pixmap_trans) |
|
|
2644 | flush (); |
|
|
2645 | } |
|
|
2646 | |
|
|
2647 | return pchanged; |
|
|
2648 | } |
|
|
2649 | #endif |
|
|
2650 | |
2169 | |
2651 | /*}}} */ |
2170 | /*}}} */ |
2652 | |
2171 | |
2653 | bool |
2172 | bool |
2654 | rxvt_term::cmd_parse () |
2173 | rxvt_term::cmd_parse () |
… | |
… | |
2703 | if (ch == C0_LF) |
2222 | if (ch == C0_LF) |
2704 | nlines++; |
2223 | nlines++; |
2705 | |
2224 | |
2706 | refresh_count++; |
2225 | refresh_count++; |
2707 | |
2226 | |
2708 | if (!OPTION (Opt_jumpScroll) |
2227 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2709 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2710 | { |
2228 | { |
2711 | refreshnow = true; |
|
|
2712 | refresh_count = 0; |
2229 | refresh_count = 0; |
|
|
2230 | |
|
|
2231 | if (!option (Opt_skipScroll) || ev::ev_time () > ev::now () + 1. / 60.) |
|
|
2232 | { |
|
|
2233 | refreshnow = true; |
2713 | ch = NOCHAR; |
2234 | ch = NOCHAR; |
2714 | break; |
2235 | break; |
|
|
2236 | } |
2715 | } |
2237 | } |
2716 | |
2238 | |
2717 | // scr_add_lines only works for nlines <= nrow - 1. |
2239 | // scr_add_lines only works for nlines <= nrow - 1. |
2718 | if (nlines >= nrow - 1) |
2240 | if (nlines >= nrow - 1) |
2719 | { |
2241 | { |
… | |
… | |
2747 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2269 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2748 | scr_add_lines (buf, str - buf, nlines); |
2270 | scr_add_lines (buf, str - buf, nlines); |
2749 | |
2271 | |
2750 | /* |
2272 | /* |
2751 | * If there have been a lot of new lines, then update the screen |
2273 | * If there have been a lot of new lines, then update the screen |
2752 | * What the heck I'll cheat and only refresh less than every page-full. |
2274 | * What the heck we'll cheat and only refresh less than every page-full. |
2753 | * the number of pages between refreshes is refresh_limit, which |
2275 | * if skipScroll is enabled. |
2754 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2755 | */ |
2276 | */ |
2756 | if (refreshnow) |
2277 | if (refreshnow) |
2757 | { |
2278 | { |
2758 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2759 | refresh_limit++; |
|
|
2760 | else |
|
|
2761 | { |
|
|
2762 | flag = true; |
2279 | flag = true; |
2763 | scr_refresh (); |
2280 | scr_refresh (); |
2764 | want_refresh = 1; |
2281 | want_refresh = 1; |
2765 | } |
|
|
2766 | } |
2282 | } |
2767 | |
2283 | |
2768 | } |
2284 | } |
2769 | else |
2285 | else |
2770 | { |
2286 | { |
… | |
… | |
2919 | { |
2435 | { |
2920 | if ((buf[len++] = cmd_getc ()) == 'i') |
2436 | if ((buf[len++] = cmd_getc ()) == 'i') |
2921 | break; /* done = 1 */ |
2437 | break; /* done = 1 */ |
2922 | } |
2438 | } |
2923 | } |
2439 | } |
2924 | |
2440 | |
2925 | for (i = 0; i < len; i++) |
2441 | for (i = 0; i < len; i++) |
2926 | if (putc (buf[i], fd) == EOF) |
2442 | if (putc (buf[i], fd) == EOF) |
2927 | { |
2443 | { |
2928 | done = 1; |
2444 | done = 1; |
2929 | break; |
2445 | break; |
… | |
… | |
2991 | process_dcs_seq (); |
2507 | process_dcs_seq (); |
2992 | break; |
2508 | break; |
2993 | case 0x9b: /* CSI */ |
2509 | case 0x9b: /* CSI */ |
2994 | process_csi_seq (); |
2510 | process_csi_seq (); |
2995 | break; |
2511 | break; |
2996 | case 0x9d: /* CSI */ |
2512 | case 0x9d: /* OSC */ |
2997 | process_osc_seq (); |
2513 | process_osc_seq (); |
2998 | break; |
2514 | break; |
2999 | #endif |
2515 | #endif |
3000 | } |
2516 | } |
3001 | } |
2517 | } |
… | |
… | |
3227 | rxvt_term::process_csi_seq () |
2743 | rxvt_term::process_csi_seq () |
3228 | { |
2744 | { |
3229 | unicode_t ch, priv, i; |
2745 | unicode_t ch, priv, i; |
3230 | unsigned int nargs, p; |
2746 | unsigned int nargs, p; |
3231 | int n, ndef; |
2747 | int n, ndef; |
3232 | int arg[ESC_ARGS]; |
2748 | int arg[ESC_ARGS] = { }; |
3233 | |
2749 | |
3234 | for (nargs = ESC_ARGS; nargs > 0;) |
2750 | nargs = 0; |
3235 | arg[--nargs] = 0; |
|
|
3236 | |
2751 | |
3237 | priv = 0; |
2752 | priv = 0; |
3238 | ch = cmd_getc (); |
2753 | ch = cmd_getc (); |
3239 | if (ch >= '<' && ch <= '?') |
2754 | if (ch >= '<' && ch <= '?') |
3240 | { /* '<' '=' '>' '?' */ |
2755 | { /* '<' '=' '>' '?' */ |
… | |
… | |
3284 | switch (priv) |
2799 | switch (priv) |
3285 | { |
2800 | { |
3286 | case '>': |
2801 | case '>': |
3287 | if (ch == CSI_DA) /* secondary device attributes */ |
2802 | if (ch == CSI_DA) /* secondary device attributes */ |
3288 | { |
2803 | { |
3289 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
2804 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
3290 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
2805 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
3291 | // |
2806 | // |
3292 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
2807 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
3293 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
2808 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later |
3294 | // that we do not support xterm mouse reporting (should be 95 when we do). |
2809 | // versions. |
3295 | // |
2810 | // |
3296 | tt_printf ("\033[>%d;94;0c", 'U'); |
2811 | tt_printf ("\033[>%d;95;0c", 'U'); |
3297 | } |
2812 | } |
3298 | break; |
2813 | break; |
3299 | case '?': |
2814 | case '?': |
3300 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2815 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3301 | process_terminal_mode (ch, priv, nargs, arg); |
2816 | process_terminal_mode (ch, priv, nargs, arg); |
… | |
… | |
3428 | break; |
2943 | break; |
3429 | case 6: /* CPR requested */ |
2944 | case 6: /* CPR requested */ |
3430 | scr_report_position (); |
2945 | scr_report_position (); |
3431 | break; |
2946 | break; |
3432 | case 7: /* unofficial extension */ |
2947 | case 7: /* unofficial extension */ |
3433 | if (OPTION (Opt_insecure)) |
2948 | if (option (Opt_insecure)) |
3434 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
2949 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3435 | break; |
2950 | break; |
3436 | case 8: /* unofficial extension */ |
2951 | case 8: /* unofficial extension */ |
3437 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2952 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3438 | break; |
2953 | break; |
… | |
… | |
3531 | { |
3046 | { |
3532 | int x, y; |
3047 | int x, y; |
3533 | XWindowAttributes wattr; |
3048 | XWindowAttributes wattr; |
3534 | Window wdummy; |
3049 | Window wdummy; |
3535 | |
3050 | |
3536 | dLocal (Display *, xdisp); |
3051 | dLocal (Display *, dpy); |
3537 | |
3052 | |
3538 | if (nargs == 0) |
3053 | if (nargs == 0) |
3539 | return; |
3054 | return; |
3540 | |
3055 | |
3541 | switch (args[0]) |
3056 | switch (args[0]) |
3542 | { |
3057 | { |
3543 | /* |
3058 | /* |
3544 | * commands |
3059 | * commands |
3545 | */ |
3060 | */ |
3546 | case 1: /* deiconify window */ |
3061 | case 1: /* deiconify window */ |
3547 | XMapWindow (xdisp, parent[0]); |
3062 | XMapWindow (dpy, parent[0]); |
3548 | break; |
3063 | break; |
3549 | case 2: /* iconify window */ |
3064 | case 2: /* iconify window */ |
3550 | XIconifyWindow (xdisp, parent[0], display->screen); |
3065 | XIconifyWindow (dpy, parent[0], display->screen); |
3551 | break; |
3066 | break; |
3552 | case 3: /* set position (pixels) */ |
3067 | case 3: /* set position (pixels) */ |
3553 | XMoveWindow (xdisp, parent[0], args[1], args[2]); |
3068 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3554 | break; |
3069 | break; |
3555 | case 4: /* set size (pixels) */ |
3070 | case 4: /* set size (pixels) */ |
3556 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3071 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3557 | break; |
3072 | break; |
3558 | case 5: /* raise window */ |
3073 | case 5: /* raise window */ |
3559 | XRaiseWindow (xdisp, parent[0]); |
3074 | XRaiseWindow (dpy, parent[0]); |
3560 | break; |
3075 | break; |
3561 | case 6: /* lower window */ |
3076 | case 6: /* lower window */ |
3562 | XLowerWindow (xdisp, parent[0]); |
3077 | XLowerWindow (dpy, parent[0]); |
3563 | break; |
3078 | break; |
3564 | case 7: /* refresh window */ |
3079 | case 7: /* refresh window */ |
3565 | scr_touch (true); |
3080 | scr_touch (true); |
3566 | break; |
3081 | break; |
3567 | case 8: /* set size (chars) */ |
3082 | case 8: /* set size (chars) */ |
… | |
… | |
3574 | if (args[0] >= 24) /* set height (chars) */ |
3089 | if (args[0] >= 24) /* set height (chars) */ |
3575 | set_widthheight ((unsigned int)width, |
3090 | set_widthheight ((unsigned int)width, |
3576 | (unsigned int) (args[1] * fheight)); |
3091 | (unsigned int) (args[1] * fheight)); |
3577 | break; |
3092 | break; |
3578 | |
3093 | |
3579 | |
|
|
3580 | /* |
3094 | /* |
3581 | * reports - some output format copied from XTerm |
3095 | * reports - some output format copied from XTerm |
3582 | */ |
3096 | */ |
3583 | case 11: /* report window state */ |
3097 | case 11: /* report window state */ |
3584 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3098 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3585 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3099 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3586 | break; |
3100 | break; |
3587 | case 13: /* report window position */ |
3101 | case 13: /* report window position */ |
3588 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3102 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3589 | XTranslateCoordinates (xdisp, parent[0], wattr.root, |
3103 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3590 | -wattr.border_width, -wattr.border_width, |
3104 | -wattr.border_width, -wattr.border_width, |
3591 | &x, &y, &wdummy); |
3105 | &x, &y, &wdummy); |
3592 | tt_printf ("\033[3;%d;%dt", x, y); |
3106 | tt_printf ("\033[3;%d;%dt", x, y); |
3593 | break; |
3107 | break; |
3594 | case 14: /* report window size (pixels) */ |
3108 | case 14: /* report window size (pixels) */ |
3595 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3109 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3596 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3110 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3597 | break; |
3111 | break; |
3598 | case 18: /* report text area size (chars) */ |
3112 | case 18: /* report text area size (chars) */ |
3599 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3113 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3600 | break; |
3114 | break; |
… | |
… | |
3602 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3116 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3603 | break; |
3117 | break; |
3604 | case 20: /* report icon label */ |
3118 | case 20: /* report icon label */ |
3605 | { |
3119 | { |
3606 | char *s; |
3120 | char *s; |
3607 | XGetIconName (xdisp, parent[0], &s); |
3121 | XGetIconName (dpy, parent[0], &s); |
3608 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3122 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3609 | XFree (s); |
3123 | XFree (s); |
3610 | } |
3124 | } |
3611 | break; |
3125 | break; |
3612 | case 21: /* report window title */ |
3126 | case 21: /* report window title */ |
3613 | { |
3127 | { |
3614 | char *s; |
3128 | char *s; |
3615 | XFetchName (xdisp, parent[0], &s); |
3129 | XFetchName (dpy, parent[0], &s); |
3616 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3130 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3617 | XFree (s); |
3131 | XFree (s); |
3618 | } |
3132 | } |
3619 | break; |
3133 | break; |
3620 | } |
3134 | } |
3621 | } |
3135 | } |
… | |
… | |
3648 | seen_esc = true; |
3162 | seen_esc = true; |
3649 | continue; |
3163 | continue; |
3650 | } |
3164 | } |
3651 | else if (ch == C0_BEL || ch == CHAR_ST) |
3165 | else if (ch == C0_BEL || ch == CHAR_ST) |
3652 | break; |
3166 | break; |
|
|
3167 | else if (ch == C0_SYN) |
|
|
3168 | ch = cmd_get8 (); |
3653 | else if (ch < 0x20) |
3169 | else if (ch < 0x20) |
3654 | return NULL; /* other control character - exit */ |
3170 | return NULL; /* other control character - exit */ |
3655 | |
3171 | |
3656 | seen_esc = false; |
3172 | seen_esc = false; |
3657 | |
3173 | |
3658 | if (n >= STRING_MAX - 1) |
3174 | if (n >= STRING_MAX - 1) |
3659 | // stop at some sane length |
3175 | // stop at some sane length |
3660 | return NULL; |
3176 | return NULL; |
3661 | |
3177 | |
3662 | if (ch == C0_SYN) |
|
|
3663 | string[n++] = cmd_get8 (); |
|
|
3664 | else |
|
|
3665 | string[n++] = ch; |
3178 | string[n++] = ch; |
3666 | } |
3179 | } |
3667 | |
3180 | |
3668 | string[n++] = '\0'; |
3181 | string[n++] = '\0'; |
3669 | |
3182 | |
3670 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3183 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
… | |
… | |
3721 | void |
3234 | void |
3722 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3235 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3723 | { |
3236 | { |
3724 | if (str[0] == '?' && !str[1]) |
3237 | if (str[0] == '?' && !str[1]) |
3725 | { |
3238 | { |
3726 | rxvt_rgba c; |
3239 | rgba c; |
3727 | pix_colors_focused[color].get (this, c); |
3240 | pix_colors_focused[color].get (c); |
3728 | |
3241 | |
3729 | #if XFT |
3242 | #if XFT |
3730 | if (c.a != rxvt_rgba::MAX_CC) |
3243 | if (c.a != rgba::MAX_CC) |
3731 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
3244 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
3732 | else |
3245 | else |
3733 | #endif |
3246 | #endif |
3734 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3247 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3735 | } |
3248 | } |
… | |
… | |
3746 | int color; |
3259 | int color; |
3747 | char *buf, *name; |
3260 | char *buf, *name; |
3748 | bool query = str[0] == '?' && !str[1]; |
3261 | bool query = str[0] == '?' && !str[1]; |
3749 | int saveop = op; |
3262 | int saveop = op; |
3750 | |
3263 | |
3751 | dLocal (Display *, xdisp); |
3264 | dLocal (Display *, dpy); |
3752 | |
3265 | |
3753 | assert (str != NULL); |
3266 | assert (str != NULL); |
|
|
3267 | |
|
|
3268 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3269 | return; |
|
|
3270 | |
3754 | switch (op) |
3271 | switch (op) |
3755 | { |
3272 | { |
3756 | case XTerm_name: |
3273 | case XTerm_name: |
3757 | set_title (str); |
3274 | set_title (str); |
3758 | /* FALLTHROUGH */ |
3275 | /* FALLTHROUGH */ |
… | |
… | |
3772 | unsigned long bytes_after; |
3289 | unsigned long bytes_after; |
3773 | unsigned char *value = 0; |
3290 | unsigned char *value = 0; |
3774 | const char *str = ""; |
3291 | const char *str = ""; |
3775 | |
3292 | |
3776 | if (prop |
3293 | if (prop |
3777 | && XGetWindowProperty (xdisp, parent[0], |
3294 | && XGetWindowProperty (dpy, parent[0], |
3778 | prop, 0, 1<<16, 0, AnyPropertyType, |
3295 | prop, 0, 1<<16, 0, AnyPropertyType, |
3779 | &actual_type, &actual_format, |
3296 | &actual_type, &actual_format, |
3780 | &nitems, &bytes_after, &value) == Success |
3297 | &nitems, &bytes_after, &value) == Success |
3781 | && actual_type != None |
3298 | && actual_type != None |
3782 | && actual_format == 8) |
3299 | && actual_format == 8) |
… | |
… | |
3794 | { |
3311 | { |
3795 | *eq = 0; |
3312 | *eq = 0; |
3796 | set_utf8_property (display->atom (str), eq + 1); |
3313 | set_utf8_property (display->atom (str), eq + 1); |
3797 | } |
3314 | } |
3798 | else |
3315 | else |
3799 | XDeleteProperty (xdisp, parent[0], |
3316 | XDeleteProperty (dpy, parent[0], |
3800 | display->atom (str)); |
3317 | display->atom (str)); |
3801 | } |
3318 | } |
3802 | break; |
3319 | break; |
3803 | |
3320 | |
3804 | case XTerm_Color: |
3321 | case XTerm_Color: |
… | |
… | |
3850 | break; |
3367 | break; |
3851 | case URxvt_Color_IT: |
3368 | case URxvt_Color_IT: |
3852 | process_color_seq (op, Color_IT, str, resp); |
3369 | process_color_seq (op, Color_IT, str, resp); |
3853 | break; |
3370 | break; |
3854 | #endif |
3371 | #endif |
3855 | #if TRANSPARENT && TINTING |
3372 | #if ENABLE_TRANSPARENCY |
3856 | case URxvt_Color_tint: |
3373 | case URxvt_Color_tint: |
3857 | process_color_seq (op, Color_tint, str, resp); |
3374 | process_color_seq (op, Color_tint, str, resp); |
3858 | check_our_parents (); |
3375 | { |
3859 | if (am_transparent) |
3376 | bool changed = false; |
3860 | want_full_refresh = want_refresh = 1; |
3377 | if (ISSET_PIXCOLOR (Color_tint)) |
3861 | break; |
3378 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
3862 | #endif |
3379 | else |
|
|
3380 | changed = bgPixmap.unset_tint (); |
|
|
3381 | if (changed) |
|
|
3382 | update_background (); |
|
|
3383 | } |
3863 | |
3384 | |
|
|
3385 | break; |
|
|
3386 | #endif |
|
|
3387 | |
|
|
3388 | #if BG_IMAGE_FROM_FILE |
3864 | case Rxvt_Pixmap: |
3389 | case Rxvt_Pixmap: |
3865 | { |
3390 | if (!strcmp (str, "?")) |
3866 | if (*str != ';') |
|
|
3867 | { |
3391 | { |
3868 | #if XPM_BACKGROUND |
3392 | char str[256]; |
3869 | scale_pixmap (""); /* reset to default scaling */ |
3393 | |
3870 | set_bgPixmap (str); /* change pixmap */ |
3394 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
3871 | scr_touch (true); |
3395 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
3872 | #endif |
3396 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
|
|
3397 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3873 | } |
3398 | } |
3874 | |
3399 | else |
|
|
3400 | { |
3875 | int changed = 0; |
3401 | int changed = 0; |
3876 | |
3402 | |
3877 | while ((str = strchr (str, ';')) != NULL) |
3403 | if (*str != ';') |
3878 | { |
3404 | { |
|
|
3405 | /* reset to default scaling :*/ |
|
|
3406 | bgPixmap.unset_geometry (); |
|
|
3407 | if (bgPixmap.set_file (str)) /* change pixmap */ |
|
|
3408 | changed++; |
|
|
3409 | str = strchr (str, ';'); |
|
|
3410 | if (str == NULL) |
|
|
3411 | bgPixmap.set_defaultGeometry (); |
|
|
3412 | } |
|
|
3413 | while (str) |
|
|
3414 | { |
3879 | str++; |
3415 | str++; |
3880 | #if XPM_BACKGROUND |
3416 | if (bgPixmap.set_geometry (str)) |
3881 | changed += scale_pixmap (str); |
3417 | changed++; |
3882 | #endif |
3418 | str = strchr (str, ';'); |
3883 | } |
3419 | } |
3884 | |
|
|
3885 | if (changed) |
3420 | if (changed) |
3886 | { |
3421 | update_background (); |
3887 | #ifdef XPM_BACKGROUND |
|
|
3888 | resize_pixmap (); |
|
|
3889 | scr_touch (true); |
|
|
3890 | #endif |
|
|
3891 | } |
3422 | } |
3892 | } |
|
|
3893 | break; |
3423 | break; |
|
|
3424 | #endif |
3894 | |
3425 | |
3895 | case Rxvt_restoreFG: |
3426 | case Rxvt_restoreFG: |
3896 | set_window_color (Color_fg, str); |
3427 | set_window_color (Color_fg, str); |
3897 | break; |
3428 | break; |
3898 | case Rxvt_restoreBG: |
3429 | case Rxvt_restoreBG: |
… | |
… | |
3923 | case URxvt_italicFont: |
3454 | case URxvt_italicFont: |
3924 | case URxvt_boldItalicFont: |
3455 | case URxvt_boldItalicFont: |
3925 | #endif |
3456 | #endif |
3926 | if (query) |
3457 | if (query) |
3927 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3458 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3928 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3459 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3929 | ? fontset[op - URxvt_font]->fontdesc : "", |
3460 | ? fontset[op - URxvt_font]->fontdesc : "", |
3930 | resp); |
3461 | resp); |
3931 | else |
3462 | else |
3932 | { |
3463 | { |
3933 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3464 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3947 | break; |
3478 | break; |
3948 | |
3479 | |
3949 | #if !ENABLE_MINIMAL |
3480 | #if !ENABLE_MINIMAL |
3950 | case URxvt_locale: |
3481 | case URxvt_locale: |
3951 | if (query) |
3482 | if (query) |
3952 | tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); |
3483 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
3953 | else |
3484 | else |
3954 | { |
3485 | { |
3955 | set_locale (str); |
3486 | set_locale (str); |
3956 | pty->set_utf8_mode (enc_utf8); |
3487 | pty->set_utf8_mode (enc_utf8); |
3957 | init_xlocale (); |
3488 | init_xlocale (); |
… | |
… | |
3972 | break; |
3503 | break; |
3973 | #endif |
3504 | #endif |
3974 | |
3505 | |
3975 | #if ENABLE_PERL |
3506 | #if ENABLE_PERL |
3976 | case URxvt_perl: |
3507 | case URxvt_perl: |
3977 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3508 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
3978 | ; // no responses yet |
3509 | ; // no responses yet |
3979 | break; |
3510 | break; |
3980 | #endif |
3511 | #endif |
3981 | } |
3512 | } |
3982 | } |
3513 | } |
… | |
… | |
4020 | { |
3551 | { |
4021 | unsigned int i, j; |
3552 | unsigned int i, j; |
4022 | int state; |
3553 | int state; |
4023 | |
3554 | |
4024 | static const struct |
3555 | static const struct |
4025 | { |
3556 | { |
4026 | const int argval; |
3557 | const int argval; |
4027 | const unsigned long bit; |
3558 | const unsigned long bit; |
4028 | } |
|
|
4029 | |
|
|
4030 | argtopriv[] = { |
3559 | } argtopriv[] = { |
4031 | { 1, PrivMode_aplCUR }, |
3560 | { 1, PrivMode_aplCUR }, |
4032 | { 2, PrivMode_vt52 }, |
3561 | { 2, PrivMode_vt52 }, |
4033 | { 3, PrivMode_132 }, |
3562 | { 3, PrivMode_132 }, |
4034 | { 4, PrivMode_smoothScroll }, |
3563 | { 4, PrivMode_smoothScroll }, |
4035 | { 5, PrivMode_rVideo }, |
3564 | { 5, PrivMode_rVideo }, |
… | |
… | |
4052 | #ifndef NO_BACKSPACE_KEY |
3581 | #ifndef NO_BACKSPACE_KEY |
4053 | { 67, PrivMode_BackSpace }, |
3582 | { 67, PrivMode_BackSpace }, |
4054 | #endif |
3583 | #endif |
4055 | { 1000, PrivMode_MouseX11 }, |
3584 | { 1000, PrivMode_MouseX11 }, |
4056 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
3585 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
4057 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
3586 | { 1002, PrivMode_MouseBtnEvent }, |
4058 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
3587 | { 1003, PrivMode_MouseAnyEvent }, |
4059 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3588 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
4060 | { 1011, PrivMode_Keypress }, // rxvt extension |
3589 | { 1011, PrivMode_Keypress }, // rxvt extension |
4061 | // 1035 enable modifiers for alt, numlock NYI |
3590 | // 1035 enable modifiers for alt, numlock NYI |
4062 | // 1036 send ESC for meta keys NYI |
3591 | // 1036 send ESC for meta keys NYI |
4063 | // 1037 send DEL for keypad delete NYI |
3592 | // 1037 send DEL for keypad delete NYI |
… | |
… | |
4098 | scr_touch (true); |
3627 | scr_touch (true); |
4099 | break; |
3628 | break; |
4100 | #endif |
3629 | #endif |
4101 | case 1048: /* alternative cursor save */ |
3630 | case 1048: /* alternative cursor save */ |
4102 | case 1049: |
3631 | case 1049: |
4103 | if (OPTION (Opt_secondaryScreen)) |
3632 | if (option (Opt_secondaryScreen)) |
4104 | if (mode == 0) |
3633 | if (mode == 0) |
4105 | scr_cursor (RESTORE); |
3634 | scr_cursor (RESTORE); |
4106 | else if (mode == 1) |
3635 | else if (mode == 1) |
4107 | scr_cursor (SAVE); |
3636 | scr_cursor (SAVE); |
4108 | break; |
3637 | break; |
… | |
… | |
4137 | scr_autowrap (state); |
3666 | scr_autowrap (state); |
4138 | break; |
3667 | break; |
4139 | /* case 8: - auto repeat, can't do on a per window basis */ |
3668 | /* case 8: - auto repeat, can't do on a per window basis */ |
4140 | case 9: /* X10 mouse reporting */ |
3669 | case 9: /* X10 mouse reporting */ |
4141 | if (state) /* orthogonal */ |
3670 | if (state) /* orthogonal */ |
4142 | priv_modes &= ~PrivMode_MouseX11; |
3671 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4143 | break; |
3672 | break; |
4144 | #ifdef scrollBar_esc |
3673 | #ifdef scrollBar_esc |
4145 | case scrollBar_esc: |
3674 | case scrollBar_esc: |
4146 | if (scrollbar_mapping (state)) |
3675 | if (scrollbar_mapping (state)) |
4147 | { |
3676 | { |
… | |
… | |
4160 | break; |
3689 | break; |
4161 | /* case 66: - application key pad */ |
3690 | /* case 66: - application key pad */ |
4162 | /* case 67: - backspace key */ |
3691 | /* case 67: - backspace key */ |
4163 | case 1000: /* X11 mouse reporting */ |
3692 | case 1000: /* X11 mouse reporting */ |
4164 | if (state) /* orthogonal */ |
3693 | if (state) /* orthogonal */ |
4165 | priv_modes &= ~PrivMode_MouseX10; |
3694 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4166 | break; |
3695 | break; |
4167 | #if 0 |
3696 | #if 0 |
4168 | case 1001: |
3697 | case 1001: |
4169 | break; /* X11 mouse highlighting */ |
3698 | break; /* X11 mouse highlighting */ |
4170 | #endif |
3699 | #endif |
|
|
3700 | case 1002: |
|
|
3701 | case 1003: |
|
|
3702 | if (state) { |
|
|
3703 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
|
|
3704 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3705 | vt_emask_mouse = PointerMotionMask; |
|
|
3706 | } else |
|
|
3707 | vt_emask_mouse = NoEventMask; |
|
|
3708 | vt_select_input (); |
|
|
3709 | break; |
4171 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3710 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4172 | set_option (Opt_scrollTtyOutput, !state); |
3711 | set_option (Opt_scrollTtyOutput, !state); |
4173 | break; |
3712 | break; |
4174 | case 1011: /* scroll to bottom on key press */ |
3713 | case 1011: /* scroll to bottom on key press */ |
4175 | set_option (Opt_scrollTtyKeypress, state); |
3714 | set_option (Opt_scrollTtyKeypress, state); |
4176 | break; |
3715 | break; |
4177 | case 1047: /* secondary screen w/ clearing last */ |
3716 | case 1047: /* secondary screen w/ clearing last */ |
4178 | if (OPTION (Opt_secondaryScreen)) |
3717 | if (option (Opt_secondaryScreen)) |
4179 | if (current_screen != PRIMARY) |
3718 | if (current_screen != PRIMARY) |
4180 | scr_erase_screen (2); |
3719 | scr_erase_screen (2); |
4181 | scr_change_screen (state); |
3720 | scr_change_screen (state); |
4182 | break; |
3721 | break; |
4183 | case 1049: /* secondary screen w/ clearing first */ |
3722 | case 1049: /* secondary screen w/ clearing first */ |
4184 | scr_change_screen (state); |
3723 | scr_change_screen (state); |
4185 | if (OPTION (Opt_secondaryScreen)) |
3724 | if (option (Opt_secondaryScreen)) |
4186 | if (current_screen != PRIMARY) |
3725 | if (current_screen != PRIMARY) |
4187 | scr_erase_screen (2); |
3726 | scr_erase_screen (2); |
4188 | break; |
3727 | break; |
4189 | default: |
3728 | default: |
4190 | break; |
3729 | break; |
… | |
… | |
4412 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
3951 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4413 | |
3952 | |
4414 | memcpy (v_buffer + v_buflen, data, len); |
3953 | memcpy (v_buffer + v_buflen, data, len); |
4415 | v_buflen += len; |
3954 | v_buflen += len; |
4416 | |
3955 | |
4417 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
3956 | pty_ev.set (ev::READ | ev::WRITE); |
4418 | } |
3957 | } |
4419 | |
3958 | |
4420 | void rxvt_term::pty_write () |
3959 | void rxvt_term::pty_write () |
4421 | { |
3960 | { |
4422 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
3961 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
… | |
… | |
4427 | |
3966 | |
4428 | if (v_buflen == 0) |
3967 | if (v_buflen == 0) |
4429 | { |
3968 | { |
4430 | free (v_buffer); |
3969 | free (v_buffer); |
4431 | v_buffer = 0; |
3970 | v_buffer = 0; |
4432 | v_buflen = 0; |
|
|
4433 | |
3971 | |
4434 | pty_ev.set (EVENT_READ); |
3972 | pty_ev.set (ev::READ); |
4435 | return; |
3973 | return; |
4436 | } |
3974 | } |
4437 | |
3975 | |
4438 | memmove (v_buffer, v_buffer + written, v_buflen); |
3976 | memmove (v_buffer, v_buffer + written, v_buflen); |
4439 | } |
3977 | } |
4440 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
3978 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4441 | pty_ev.set (EVENT_READ); |
3979 | pty_ev.set (ev::READ); |
4442 | } |
3980 | } |
4443 | |
3981 | |
4444 | /*----------------------- end-of-file (C source) -----------------------*/ |
3982 | /*----------------------- end-of-file (C source) -----------------------*/ |
4445 | |
3983 | |