1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: command.C |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com> |
31 | * |
31 | * |
32 | * This program is free software; you can redistribute it and/or modify |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
33 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
35 | * (at your option) any later version. |
… | |
… | |
49 | #include "rxvt.h" |
49 | #include "rxvt.h" |
50 | #include "rxvtperl.h" |
50 | #include "rxvtperl.h" |
51 | #include "version.h" |
51 | #include "version.h" |
52 | #include "command.h" |
52 | #include "command.h" |
53 | |
53 | |
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #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> |
64 | |
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
|
|
63 | |
65 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
66 | |
65 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
|
|
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
67 | |
72 | #if ENABLE_FRILLS || ISO_14755 |
68 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
69 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
70 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
71 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
99 | XK_Shift_L, 0x21e7, |
95 | XK_Shift_L, 0x21e7, |
100 | XK_Shift_R, 0x21e7, |
96 | XK_Shift_R, 0x21e7, |
101 | |
97 | |
102 | XK_Shift_Lock, 0x21eb, |
98 | XK_Shift_Lock, 0x21eb, |
103 | XK_ISO_Lock, 0x21eb, |
99 | XK_ISO_Lock, 0x21eb, |
104 | XK_ISO_Lock, 0x21eb, |
|
|
105 | XK_Caps_Lock, 0x21ec, |
100 | XK_Caps_Lock, 0x21ec, |
106 | XK_Num_Lock, 0x21ed, |
101 | XK_Num_Lock, 0x21ed, |
107 | XK_ISO_Level3_Shift, 0x21ee, |
102 | XK_ISO_Level3_Shift, 0x21ee, |
108 | XK_ISO_Level3_Lock, 0x21ef, |
103 | XK_ISO_Level3_Lock, 0x21ef, |
109 | XK_ISO_Group_Lock, 0x21f0, |
104 | XK_ISO_Group_Lock, 0x21f0, |
… | |
… | |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
142 | || !IN_RANGE_EXC (y, 0, nrow)) |
148 | return; |
143 | return; |
149 | |
144 | |
150 | for (;;) |
145 | for (;;) |
151 | { |
146 | { |
152 | const line_t &l = ROW(y - view_start); |
147 | const line_t &l = ROW(y + view_start); |
153 | |
148 | |
154 | text_t t = l.t[x]; |
149 | text_t t = l.t[x]; |
155 | |
150 | |
156 | if (t != NOCHAR || !x) |
151 | if (t != NOCHAR || !x) |
157 | { |
152 | { |
… | |
… | |
230 | # if !UNICODE3 |
225 | # if !UNICODE3 |
231 | if (ch >= 0x10000) |
226 | if (ch >= 0x10000) |
232 | ch = 0xfffd; |
227 | ch = 0xfffd; |
233 | # endif |
228 | # endif |
234 | scr_overlay_set (11, y, ch, r); |
229 | scr_overlay_set (11, y, ch, r); |
|
|
230 | |
|
|
231 | if (WCWIDTH (ch) >= 2) |
235 | scr_overlay_set (12, y, NOCHAR, r); |
232 | scr_overlay_set (12, y, NOCHAR, r); |
236 | } |
233 | } |
237 | |
234 | |
|
|
235 | // { |
|
|
236 | // char buf[4+4+3+1]; |
|
|
237 | // snprintf (buf, sizeof (buf), "(%.4d|%.4d)", x, y); |
|
|
238 | // scr_overlay_set (0, 0, buf); |
|
|
239 | // } |
238 | scr_overlay_set (0, len , attr); |
240 | scr_overlay_set (0, len , attr); |
239 | scr_overlay_set (0, len + 1, fname); |
241 | scr_overlay_set (0, len + 1, fname); |
240 | |
242 | |
241 | free (fname); |
243 | free (fname); |
242 | |
244 | |
… | |
… | |
295 | |
297 | |
296 | return -1; |
298 | return -1; |
297 | } |
299 | } |
298 | #endif |
300 | #endif |
299 | |
301 | |
300 | /*{{{ Convert the keypress event into a string */ |
|
|
301 | void |
302 | void |
302 | rxvt_term::lookup_key (XKeyEvent &ev) |
303 | rxvt_term::key_press (XKeyEvent &ev) |
303 | { |
304 | { |
304 | int ctrl, meta, shft, len; |
305 | int ctrl, meta, shft, len; |
305 | unsigned int newlen; |
306 | unsigned int newlen; |
306 | KeySym keysym; |
307 | KeySym keysym; |
307 | #ifdef DEBUG_CMD |
|
|
308 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
309 | #endif |
|
|
310 | int valid_keysym; |
308 | int valid_keysym; |
311 | char kbuf[KBUFSZ]; |
309 | char kbuf[KBUFSZ]; |
|
|
310 | |
|
|
311 | #if ISO_14755 |
|
|
312 | if (iso14755buf & ISO_14755_52) |
|
|
313 | return; |
|
|
314 | #endif |
312 | |
315 | |
313 | /* |
316 | /* |
314 | * 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 |
315 | * escape sequence to toggle the Keypad. |
318 | * escape sequence to toggle the Keypad. |
316 | * |
319 | * |
… | |
… | |
443 | scr_move_to (0, 1); |
446 | scr_move_to (0, 1); |
444 | return; |
447 | return; |
445 | } |
448 | } |
446 | else if (keysym == XK_End) |
449 | else if (keysym == XK_End) |
447 | { |
450 | { |
448 | scr_move_to (1, 0); |
451 | scr_move_to (1, 1); |
449 | return; |
452 | return; |
450 | } |
453 | } |
451 | } |
454 | } |
452 | #endif |
455 | #endif |
453 | } |
456 | } |
… | |
… | |
464 | { |
467 | { |
465 | switch (keysym) |
468 | switch (keysym) |
466 | { |
469 | { |
467 | /* normal XTerm key bindings */ |
470 | /* normal XTerm key bindings */ |
468 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
471 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
469 | selection_request (ev.time, 0, 0); |
472 | selection_request (ev.time); |
470 | return; |
473 | return; |
471 | #if TODO |
474 | #if TODO |
472 | /* rxvt extras */ |
475 | /* rxvt extras */ |
473 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
476 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
474 | change_font (FONT_UP); |
477 | change_font (FONT_UP); |
… | |
… | |
493 | { |
496 | { |
494 | commit_iso14755 (); |
497 | commit_iso14755 (); |
495 | iso14755buf = ISO_14755_51; |
498 | iso14755buf = ISO_14755_51; |
496 | # if ISO_14755 |
499 | # if ISO_14755 |
497 | iso14755_51 (0); |
500 | iso14755_51 (0); |
|
|
501 | # endif |
|
|
502 | return; |
|
|
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); |
498 | # endif |
509 | # endif |
499 | return; |
510 | return; |
500 | } |
511 | } |
501 | else if ((hv = hex_keyval (ev)) >= 0) |
512 | else if ((hv = hex_keyval (ev)) >= 0) |
502 | { |
513 | { |
… | |
… | |
507 | # endif |
518 | # endif |
508 | return; |
519 | return; |
509 | } |
520 | } |
510 | else |
521 | else |
511 | { |
522 | { |
512 | # if ENABLE_OVERLAY |
523 | # if ISO_14755 |
513 | scr_overlay_off (); |
524 | scr_overlay_off (); |
514 | # endif |
525 | # endif |
515 | iso14755buf = 0; |
526 | iso14755buf = 0; |
516 | } |
527 | } |
517 | } |
528 | } |
518 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
529 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
519 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
530 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
520 | if (!(iso14755buf & ISO_14755_STARTED)) |
531 | if (!(iso14755buf & ISO_14755_STARTED)) |
521 | { |
532 | { |
522 | iso14755buf |= ISO_14755_STARTED; |
533 | iso14755buf |= ISO_14755_STARTED; |
523 | # if ENABLE_OVERLAY |
534 | # if ISO_14755 |
524 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
535 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
525 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
536 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
526 | # endif |
537 | # endif |
527 | } |
538 | } |
528 | #endif |
539 | #endif |
529 | |
540 | |
530 | #ifdef PRINTPIPE |
541 | #ifdef PRINTPIPE |
531 | if (keysym == XK_Print) |
542 | if (keysym == XK_Print) |
532 | { |
543 | { |
533 | scr_printscreen (ctrl | shft); |
544 | scr_printscreen (ctrl | shft); |
534 | return; |
545 | return; |
… | |
… | |
536 | #endif |
547 | #endif |
537 | |
548 | |
538 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
549 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
539 | { |
550 | { |
540 | { |
551 | { |
|
|
552 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
541 | 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 |
542 | switch (keysym) |
584 | switch (keysym) |
543 | { |
585 | { |
544 | #ifndef NO_BACKSPACE_KEY |
586 | #ifndef NO_BACKSPACE_KEY |
545 | case XK_BackSpace: |
587 | case XK_BackSpace: |
546 | if (priv_modes & PrivMode_HaveBackSpace) |
588 | if (priv_modes & PrivMode_HaveBackSpace) |
… | |
… | |
548 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
590 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
549 | ^ !!ctrl) ? '\b' : '\177'; |
591 | ^ !!ctrl) ? '\b' : '\177'; |
550 | kbuf[1] = '\0'; |
592 | kbuf[1] = '\0'; |
551 | } |
593 | } |
552 | else |
594 | else |
553 | strcpy (kbuf, key_backspace); |
595 | strcpy (kbuf, rs[Rs_backspace_key]); |
554 | break; |
596 | break; |
555 | #endif |
597 | #endif |
556 | #ifndef NO_DELETE_KEY |
598 | #ifndef NO_DELETE_KEY |
557 | # ifdef XK_KP_Prior |
|
|
558 | case XK_KP_Delete: |
|
|
559 | /* allow shift to override */ |
|
|
560 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
561 | { |
|
|
562 | strcpy (kbuf, "\033On"); |
|
|
563 | break; |
|
|
564 | } |
|
|
565 | /* FALLTHROUGH */ |
|
|
566 | # endif |
|
|
567 | case XK_Delete: |
599 | case XK_Delete: |
568 | strcpy (kbuf, key_delete); |
600 | strcpy (kbuf, rs[Rs_delete_key]); |
569 | break; |
601 | break; |
570 | #endif |
602 | #endif |
571 | case XK_Tab: |
603 | case XK_Tab: |
572 | if (shft) |
604 | if (shft) |
573 | strcpy (kbuf, "\033[Z"); |
605 | strcpy (kbuf, "\033[Z"); |
… | |
… | |
583 | #endif |
615 | #endif |
584 | newlen = 0; |
616 | newlen = 0; |
585 | } |
617 | } |
586 | break; |
618 | break; |
587 | |
619 | |
588 | #ifdef XK_KP_Left |
|
|
589 | case XK_KP_Up: /* \033Ox or standard */ |
|
|
590 | case XK_KP_Down: /* \033Or or standard */ |
|
|
591 | case XK_KP_Right: /* \033Ov or standard */ |
|
|
592 | case XK_KP_Left: /* \033Ot or standard */ |
|
|
593 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
594 | { |
|
|
595 | strcpy (kbuf, "\033OZ"); |
|
|
596 | kbuf[2] = "txvr"[keysym - XK_KP_Left]; |
|
|
597 | break; |
|
|
598 | } |
|
|
599 | else |
|
|
600 | /* translate to std. cursor key */ |
|
|
601 | keysym = XK_Left + (keysym - XK_KP_Left); |
|
|
602 | /* FALLTHROUGH */ |
|
|
603 | #endif |
|
|
604 | case XK_Up: /* "\033[A" */ |
620 | case XK_Up: /* "\033[A" */ |
605 | case XK_Down: /* "\033[B" */ |
621 | case XK_Down: /* "\033[B" */ |
606 | case XK_Right: /* "\033[C" */ |
622 | case XK_Right: /* "\033[C" */ |
607 | case XK_Left: /* "\033[D" */ |
623 | case XK_Left: /* "\033[D" */ |
608 | strcpy (kbuf, "\033[Z"); |
624 | strcpy (kbuf, "\033[Z"); |
… | |
… | |
618 | else if (priv_modes & PrivMode_aplCUR) |
634 | else if (priv_modes & PrivMode_aplCUR) |
619 | kbuf[1] = 'O'; |
635 | kbuf[1] = 'O'; |
620 | break; |
636 | break; |
621 | |
637 | |
622 | #ifndef UNSHIFTED_SCROLLKEYS |
638 | #ifndef UNSHIFTED_SCROLLKEYS |
623 | # ifdef XK_KP_Prior |
|
|
624 | case XK_KP_Prior: |
|
|
625 | /* allow shift to override */ |
|
|
626 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
627 | { |
|
|
628 | strcpy (kbuf, "\033Oy"); |
|
|
629 | break; |
|
|
630 | } |
|
|
631 | /* FALLTHROUGH */ |
|
|
632 | # endif |
|
|
633 | case XK_Prior: |
639 | case XK_Prior: |
634 | strcpy (kbuf, "\033[5~"); |
640 | strcpy (kbuf, "\033[5~"); |
635 | break; |
641 | break; |
636 | # ifdef XK_KP_Next |
|
|
637 | case XK_KP_Next: |
|
|
638 | /* allow shift to override */ |
|
|
639 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
640 | { |
|
|
641 | strcpy (kbuf, "\033Os"); |
|
|
642 | break; |
|
|
643 | } |
|
|
644 | /* FALLTHROUGH */ |
|
|
645 | # endif |
|
|
646 | case XK_Next: |
642 | case XK_Next: |
647 | strcpy (kbuf, "\033[6~"); |
643 | strcpy (kbuf, "\033[6~"); |
648 | break; |
644 | break; |
649 | #endif |
645 | #endif |
650 | case XK_KP_Enter: |
646 | case XK_KP_Enter: |
651 | /* allow shift to override */ |
647 | /* allow shift to override */ |
652 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
648 | if (kp) |
653 | { |
649 | { |
654 | strcpy (kbuf, "\033OM"); |
650 | strcpy (kbuf, "\033OM"); |
655 | break; |
651 | break; |
656 | } |
652 | } |
657 | |
653 | |
… | |
… | |
669 | kbuf[0] = '\015'; |
665 | kbuf[0] = '\015'; |
670 | kbuf[1] = '\0'; |
666 | kbuf[1] = '\0'; |
671 | } |
667 | } |
672 | break; |
668 | break; |
673 | |
669 | |
674 | #ifdef XK_KP_Begin |
|
|
675 | case XK_KP_Begin: |
|
|
676 | strcpy (kbuf, "\033Ou"); |
|
|
677 | break; |
|
|
678 | |
|
|
679 | #endif |
|
|
680 | case XK_KP_F1: /* "\033OP" */ |
670 | case XK_KP_F1: /* "\033OP" */ |
681 | case XK_KP_F2: /* "\033OQ" */ |
671 | case XK_KP_F2: /* "\033OQ" */ |
682 | case XK_KP_F3: /* "\033OR" */ |
672 | case XK_KP_F3: /* "\033OR" */ |
683 | case XK_KP_F4: /* "\033OS" */ |
673 | case XK_KP_F4: /* "\033OS" */ |
684 | strcpy (kbuf, "\033OP"); |
674 | strcpy (kbuf, "\033OP"); |
… | |
… | |
700 | case XK_KP_6: /* "\033Ov" : "6" */ |
690 | case XK_KP_6: /* "\033Ov" : "6" */ |
701 | case XK_KP_7: /* "\033Ow" : "7" */ |
691 | case XK_KP_7: /* "\033Ow" : "7" */ |
702 | case XK_KP_8: /* "\033Ox" : "8" */ |
692 | case XK_KP_8: /* "\033Ox" : "8" */ |
703 | case XK_KP_9: /* "\033Oy" : "9" */ |
693 | case XK_KP_9: /* "\033Oy" : "9" */ |
704 | /* allow shift to override */ |
694 | /* allow shift to override */ |
705 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
695 | if (kp) |
706 | { |
696 | { |
707 | strcpy (kbuf, "\033Oj"); |
697 | strcpy (kbuf, "\033Oj"); |
708 | kbuf[2] += (keysym - XK_KP_Multiply); |
698 | kbuf[2] += (keysym - XK_KP_Multiply); |
709 | } |
699 | } |
710 | else |
700 | else |
… | |
… | |
716 | |
706 | |
717 | case XK_Find: |
707 | case XK_Find: |
718 | strcpy (kbuf, "\033[1~"); |
708 | strcpy (kbuf, "\033[1~"); |
719 | break; |
709 | break; |
720 | |
710 | |
721 | #ifdef XK_KP_End |
|
|
722 | case XK_KP_Insert: |
|
|
723 | /* allow shift to override */ |
|
|
724 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
725 | { |
|
|
726 | strcpy (kbuf, "\033Op"); |
|
|
727 | break; |
|
|
728 | } |
|
|
729 | /* FALLTHROUGH */ |
|
|
730 | #endif |
|
|
731 | case XK_Insert: |
711 | case XK_Insert: |
732 | strcpy (kbuf, "\033[2~"); |
712 | strcpy (kbuf, "\033[2~"); |
733 | break; |
713 | break; |
734 | #ifdef DXK_Remove /* support for DEC remove like key */ |
714 | #ifdef DXK_Remove /* support for DEC remove like key */ |
735 | case DXK_Remove: |
715 | case DXK_Remove: |
… | |
… | |
739 | strcpy (kbuf, "\033[3~"); |
719 | strcpy (kbuf, "\033[3~"); |
740 | break; |
720 | break; |
741 | case XK_Select: |
721 | case XK_Select: |
742 | strcpy (kbuf, "\033[4~"); |
722 | strcpy (kbuf, "\033[4~"); |
743 | break; |
723 | break; |
744 | #ifdef XK_KP_End |
|
|
745 | case XK_KP_End: |
|
|
746 | /* allow shift to override */ |
|
|
747 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
748 | { |
|
|
749 | strcpy (kbuf, "\033Oq"); |
|
|
750 | break; |
|
|
751 | } |
|
|
752 | /* FALLTHROUGH */ |
|
|
753 | #endif |
|
|
754 | case XK_End: |
724 | case XK_End: |
755 | strcpy (kbuf, KS_END); |
725 | strcpy (kbuf, KS_END); |
756 | break; |
726 | break; |
757 | #ifdef XK_KP_Home |
|
|
758 | case XK_KP_Home: |
|
|
759 | /* allow shift to override */ |
|
|
760 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
761 | { |
|
|
762 | strcpy (kbuf, "\033Ow"); |
|
|
763 | break; |
|
|
764 | } |
|
|
765 | /* FALLTHROUGH */ |
|
|
766 | #endif |
|
|
767 | case XK_Home: |
727 | case XK_Home: |
768 | strcpy (kbuf, KS_HOME); |
728 | strcpy (kbuf, KS_HOME); |
769 | break; |
729 | break; |
770 | |
730 | |
771 | #define FKEY(n, fkey) \ |
731 | #define FKEY(n, fkey) \ |
… | |
… | |
873 | return; |
833 | return; |
874 | |
834 | |
875 | if (len <= 0) |
835 | if (len <= 0) |
876 | return; /* not mapped */ |
836 | return; /* not mapped */ |
877 | |
837 | |
878 | if (OPTION (Opt_scrollTtyKeypress)) |
838 | if (option (Opt_scrollTtyKeypress)) |
879 | if (view_start) |
839 | if (view_start) |
880 | { |
840 | { |
881 | view_start = 0; |
841 | view_start = 0; |
882 | want_refresh = 1; |
842 | want_refresh = 1; |
883 | } |
843 | } |
… | |
… | |
905 | { |
865 | { |
906 | const char ch = C0_ESC; |
866 | const char ch = C0_ESC; |
907 | tt_write (&ch, 1); |
867 | tt_write (&ch, 1); |
908 | } |
868 | } |
909 | |
869 | |
910 | #if defined(DEBUG_CMD) |
|
|
911 | /* Display keyboard buffer contents */ |
|
|
912 | unsigned char *p; |
|
|
913 | int i; |
|
|
914 | |
|
|
915 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
916 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
917 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
918 | fprintf (stderr, "'\n"); |
|
|
919 | #endif /* DEBUG_CMD */ |
|
|
920 | tt_write (kbuf, (unsigned int)len); |
870 | tt_write (kbuf, (unsigned int)len); |
921 | } |
871 | } |
922 | /*}}} */ |
|
|
923 | |
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 | } |
|
|
949 | |
924 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
950 | #if defined (KEYSYM_RESOURCE) |
925 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
|
|
926 | /* attempt to `write' count to the input buffer */ |
|
|
927 | unsigned int |
951 | unsigned int |
928 | rxvt_term::cmd_write (const char *str, unsigned int count) |
952 | rxvt_term::cmd_write (const char *str, unsigned int count) |
929 | { |
953 | { |
930 | unsigned int n, s; |
954 | unsigned int n, s; |
931 | |
955 | |
… | |
… | |
959 | void |
983 | void |
960 | rxvt_term::flush () |
984 | rxvt_term::flush () |
961 | { |
985 | { |
962 | flush_ev.stop (); |
986 | flush_ev.stop (); |
963 | |
987 | |
964 | #ifdef TRANSPARENT |
988 | #ifdef HAVE_BG_PIXMAP |
965 | if (want_full_refresh) |
989 | if (bgPixmap.check_clearChanged ()) |
966 | { |
990 | { |
967 | want_full_refresh = 0; |
991 | // scr_clear (true); This needs to be researched further! |
968 | scr_clear (); |
|
|
969 | scr_touch (false); |
992 | scr_touch (false); |
970 | } |
993 | } |
971 | #endif |
994 | #endif |
972 | |
995 | |
973 | if (want_refresh) |
996 | if (want_refresh) |
974 | { |
997 | { |
975 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
998 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
976 | { |
999 | { |
977 | int row = -view_start; |
1000 | int row = view_start; |
978 | int end_row = row + nrow; |
1001 | int end_row = row + nrow; |
979 | |
1002 | |
980 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
1003 | while (row > top_row && ROW (row - 1).is_longer ()) |
981 | --row; |
1004 | --row; |
982 | |
1005 | |
983 | do |
1006 | do |
984 | { |
1007 | { |
985 | int start_row = row; |
1008 | int start_row = row; |
… | |
… | |
987 | |
1010 | |
988 | do |
1011 | do |
989 | { |
1012 | { |
990 | l = &ROW (row++); |
1013 | l = &ROW (row++); |
991 | |
1014 | |
992 | if (l->f & LINE_FILTERED) |
1015 | if (!(l->f & LINE_FILTERED)) |
993 | row++; |
|
|
994 | else |
|
|
995 | { |
1016 | { |
996 | // line not filtered, mark it as filtered |
1017 | // line not filtered, mark it as filtered |
997 | l->f |= LINE_FILTERED; |
1018 | l->f |= LINE_FILTERED; |
998 | while (l->is_longer ()) |
1019 | while (l->is_longer ()) |
999 | { |
1020 | { |
1000 | l = &ROW (++row); |
1021 | l = &ROW (row++); |
1001 | l->f |= LINE_FILTERED; |
1022 | l->f |= LINE_FILTERED; |
1002 | } |
1023 | } |
1003 | |
1024 | |
1004 | // and filter it |
1025 | // and filter it |
1005 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
1026 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
… | |
… | |
1007 | break; |
1028 | break; |
1008 | } |
1029 | } |
1009 | } |
1030 | } |
1010 | while (l->is_longer () && row < end_row); |
1031 | while (l->is_longer () && row < end_row); |
1011 | } |
1032 | } |
1012 | while (++row < end_row); |
1033 | while (row < end_row); |
1013 | } |
1034 | } |
1014 | |
1035 | |
1015 | scr_refresh (refresh_type); |
1036 | scr_refresh (); |
1016 | scrollbar_show (1); |
1037 | scrollbar_show (1); |
1017 | #ifdef USE_XIM |
1038 | #ifdef USE_XIM |
1018 | IMSendSpot (); |
1039 | IMSendSpot (); |
1019 | #endif |
1040 | #endif |
1020 | } |
1041 | } |
1021 | |
1042 | |
1022 | display->flush (); |
1043 | display->flush (); |
1023 | } |
1044 | } |
1024 | |
1045 | |
|
|
1046 | /* checks wether a refresh is requested and starts the refresh timer */ |
1025 | void |
1047 | void |
1026 | rxvt_term::check_cb (check_watcher &w) |
1048 | rxvt_term::refresh_check () |
1027 | { |
1049 | { |
1028 | SET_R (this); |
|
|
1029 | SET_LOCALE (locale); |
|
|
1030 | |
|
|
1031 | display->flush (); |
|
|
1032 | |
|
|
1033 | if (want_refresh && !flush_ev.active) |
1050 | if (want_refresh && !flush_ev.is_active ()) |
1034 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1051 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
1035 | } |
1052 | } |
1036 | |
1053 | |
1037 | void |
1054 | void |
1038 | rxvt_term::flush_cb (time_watcher &w) |
1055 | rxvt_term::flush_cb (ev::timer &w, int revents) |
1039 | { |
1056 | { |
1040 | SET_R (this); |
1057 | make_current (); |
1041 | SET_LOCALE (locale); |
|
|
1042 | |
1058 | |
1043 | refresh_limit = 1; |
|
|
1044 | refresh_count = 0; |
1059 | refresh_count = 0; |
1045 | flush (); |
1060 | flush (); |
1046 | } |
1061 | } |
1047 | |
1062 | |
1048 | #ifdef CURSOR_BLINK |
1063 | #ifdef CURSOR_BLINK |
1049 | void |
1064 | void |
1050 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1065 | rxvt_term::cursor_blink_cb (ev::timer &w, int revents) |
1051 | { |
1066 | { |
1052 | hidden_cursor = !hidden_cursor; |
1067 | hidden_cursor = !hidden_cursor; |
1053 | want_refresh = 1; |
1068 | want_refresh = 1; |
1054 | |
1069 | refresh_check (); |
1055 | w.start (w.at + BLINK_INTERVAL); |
|
|
1056 | } |
1070 | } |
1057 | #endif |
1071 | #endif |
1058 | |
1072 | |
1059 | #ifdef TEXT_BLINK |
1073 | #ifdef TEXT_BLINK |
1060 | void |
1074 | void |
1061 | rxvt_term::text_blink_cb (time_watcher &w) |
1075 | rxvt_term::text_blink_cb (ev::timer &w, int revents) |
1062 | { |
1076 | { |
1063 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1077 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1064 | { |
1078 | { |
1065 | hidden_text = !hidden_text; |
1079 | hidden_text = !hidden_text; |
1066 | want_refresh = 1; |
1080 | want_refresh = 1; |
1067 | w.start (w.at + TEXT_BLINK_INTERVAL); |
1081 | refresh_check (); |
1068 | } |
1082 | } |
|
|
1083 | else |
|
|
1084 | w.stop (); |
1069 | } |
1085 | } |
1070 | #endif |
1086 | #endif |
1071 | |
1087 | |
1072 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1088 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1073 | void |
1089 | void |
1074 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1090 | rxvt_term::cont_scroll_cb (ev::timer &w, int revents) |
1075 | { |
1091 | { |
1076 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1092 | if ((scrollbar_isUp () || scrollbar_isDn ()) |
1077 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1093 | && scr_page (scrollbar_isUp () ? UP : DN, 1)) |
1078 | { |
1094 | { |
1079 | refresh_type |= SMOOTH_REFRESH; |
|
|
1080 | want_refresh = 1; |
1095 | want_refresh = 1; |
1081 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1096 | refresh_check (); |
1082 | } |
1097 | } |
|
|
1098 | else |
|
|
1099 | w.stop (); |
1083 | } |
1100 | } |
1084 | #endif |
1101 | #endif |
1085 | |
1102 | |
1086 | #ifdef SELECTION_SCROLLING |
1103 | #ifdef SELECTION_SCROLLING |
1087 | void |
1104 | void |
1088 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1105 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1089 | { |
1106 | { |
1090 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1107 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1091 | { |
1108 | { |
1092 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1109 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1093 | refresh_type |= SMOOTH_REFRESH; |
|
|
1094 | want_refresh = 1; |
1110 | want_refresh = 1; |
1095 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1111 | refresh_check (); |
1096 | } |
1112 | } |
|
|
1113 | else |
|
|
1114 | w.stop (); |
1097 | } |
1115 | } |
1098 | #endif |
1116 | #endif |
1099 | |
1117 | |
1100 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1118 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1101 | void |
1119 | void |
1102 | rxvt_term::slip_wheel_cb (time_watcher &w) |
1120 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1103 | { |
1121 | { |
1104 | if (mouse_slip_wheel_speed == 0 |
1122 | if (scr_changeview (view_start - mouse_slip_wheel_speed)) |
1105 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
|
|
1106 | : scr_page (UP, mouse_slip_wheel_speed)) |
|
|
1107 | { |
1123 | { |
1108 | if (view_start == nsaved || |
|
|
1109 | view_start == 0) |
|
|
1110 | mouse_slip_wheel_speed = 0; |
|
|
1111 | |
|
|
1112 | refresh_type |= SMOOTH_REFRESH; |
|
|
1113 | want_refresh = 1; |
1124 | want_refresh = 1; |
1114 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1125 | refresh_check (); |
|
|
1126 | } |
|
|
1127 | |
|
|
1128 | if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0) |
1115 | } |
1129 | { |
|
|
1130 | mouse_slip_wheel_speed = 0; |
|
|
1131 | w.stop (); |
|
|
1132 | } |
1116 | } |
1133 | } |
1117 | #endif |
1134 | #endif |
1118 | |
1135 | |
1119 | #if HAVE_SCHED_YIELD |
1136 | #if LINUX_YIELD_HACK |
1120 | static struct event_handler |
1137 | static struct event_handler |
1121 | { |
1138 | { |
1122 | check_watcher cw_yield; |
1139 | ev::prepare yield_ev; |
1123 | |
1140 | |
1124 | void yield (check_watcher &w) |
1141 | void yield_cb (ev::prepare &w, int revents) |
1125 | { |
1142 | { |
1126 | sched_yield (); |
1143 | // this should really be sched_yield(), but the linux guys thought |
|
|
1144 | // that giving a process calling sched_yield () less cpu time than |
|
|
1145 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1146 | // allowed by the sus... as is returning ENOSYS. |
|
|
1147 | |
|
|
1148 | struct timespec ts = { 0, 0 }; |
|
|
1149 | nanosleep (&ts, 0); |
|
|
1150 | |
1127 | w.stop (); |
1151 | w.stop (); |
1128 | } |
1152 | } |
1129 | |
1153 | |
1130 | event_handler () |
1154 | event_handler () |
1131 | : cw_yield (this, &event_handler::yield) |
1155 | : yield_ev (this, &event_handler::yield_cb) |
1132 | { |
1156 | { |
1133 | } |
1157 | } |
1134 | } event_handler; |
1158 | } event_handler; |
1135 | #endif |
1159 | #endif |
1136 | |
1160 | |
… | |
… | |
1147 | |
1171 | |
1148 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1172 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
1149 | cmdbuf_ptr = cmdbuf_base; |
1173 | cmdbuf_ptr = cmdbuf_base; |
1150 | cmdbuf_endp = cmdbuf_ptr + n; |
1174 | cmdbuf_endp = cmdbuf_ptr + n; |
1151 | |
1175 | |
1152 | ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); |
1176 | ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); |
1153 | |
1177 | |
1154 | if (r > 0) |
1178 | if (r > 0) |
1155 | { |
1179 | { |
1156 | cmdbuf_endp += r; |
1180 | cmdbuf_endp += r; |
1157 | return true; |
1181 | return true; |
1158 | } |
1182 | } |
1159 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1183 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1160 | { |
1184 | { |
1161 | #if HAVE_SCHED_YIELD |
1185 | #if LINUX_YIELD_HACK |
1162 | if (display->is_local) |
1186 | if (display->is_local) |
1163 | event_handler.cw_yield.start (); |
1187 | event_handler.yield_ev.start (); |
1164 | #endif |
1188 | #endif |
1165 | } |
1189 | } |
1166 | else |
1190 | else |
1167 | { |
1191 | { |
1168 | pty_ev.stop (); |
1192 | pty_ev.stop (); |
1169 | |
1193 | |
1170 | if (!OPTION (Opt_hold)) |
1194 | if (!option (Opt_hold)) |
1171 | destroy (); |
1195 | destroy (); |
1172 | } |
1196 | } |
1173 | |
1197 | |
1174 | return false; |
1198 | return false; |
1175 | } |
1199 | } |
1176 | |
1200 | |
1177 | void |
1201 | void |
1178 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1202 | rxvt_term::pty_cb (ev::io &w, int revents) |
1179 | { |
1203 | { |
1180 | SET_R (this); |
1204 | make_current (); |
1181 | SET_LOCALE (locale); |
|
|
1182 | |
1205 | |
1183 | if (revents & EVENT_READ) |
1206 | if (revents & ev::READ) |
1184 | // loop, but don't allow a single term to monopolize us |
1207 | // loop, but don't allow a single term to monopolize us |
1185 | while (pty_fill ()) |
1208 | while (pty_fill ()) |
1186 | if (cmd_parse ()) |
1209 | if (cmd_parse ()) |
1187 | break; |
1210 | break; |
1188 | |
1211 | |
1189 | if (revents & EVENT_WRITE) |
1212 | if (revents & ev::WRITE) |
1190 | pty_write (); |
1213 | pty_write (); |
1191 | } |
1214 | } |
1192 | |
1215 | |
1193 | void |
1216 | void |
1194 | rxvt_term::pointer_unblank () |
1217 | rxvt_term::pointer_unblank () |
1195 | { |
1218 | { |
1196 | XDefineCursor (display->display, vt, TermWin_cursor); |
1219 | XDefineCursor (dpy, vt, TermWin_cursor); |
1197 | recolour_cursor (); |
1220 | recolour_cursor (); |
1198 | |
1221 | |
1199 | #ifdef POINTER_BLANK |
1222 | #ifdef POINTER_BLANK |
1200 | hidden_pointer = 0; |
1223 | hidden_pointer = 0; |
1201 | |
1224 | |
1202 | if (OPTION (Opt_pointerBlank)) |
1225 | if (option (Opt_pointerBlank)) |
1203 | pointer_ev.start (NOW + pointerBlankDelay); |
1226 | pointer_ev.start (pointerBlankDelay); |
1204 | #endif |
1227 | #endif |
1205 | } |
1228 | } |
1206 | |
1229 | |
1207 | #ifdef POINTER_BLANK |
1230 | #ifdef POINTER_BLANK |
1208 | void |
1231 | void |
1209 | rxvt_term::pointer_blank () |
1232 | rxvt_term::pointer_blank () |
1210 | { |
1233 | { |
1211 | if (!OPTION (Opt_pointerBlank)) |
1234 | if (!option (Opt_pointerBlank)) |
1212 | return; |
1235 | return; |
1213 | |
1236 | |
1214 | XDefineCursor (display->display, vt, display->blank_cursor); |
1237 | XDefineCursor (dpy, vt, display->blank_cursor); |
1215 | XFlush (display->display); |
1238 | XFlush (dpy); |
1216 | |
1239 | |
1217 | hidden_pointer = 1; |
1240 | hidden_pointer = 1; |
1218 | } |
1241 | } |
1219 | |
1242 | |
1220 | void |
1243 | void |
1221 | rxvt_term::pointer_cb (time_watcher &w) |
1244 | rxvt_term::pointer_cb (ev::timer &w, int revents) |
1222 | { |
1245 | { |
1223 | SET_R (this); |
1246 | make_current (); |
1224 | SET_LOCALE (locale); |
|
|
1225 | |
1247 | |
1226 | pointer_blank (); |
1248 | pointer_blank (); |
1227 | } |
1249 | } |
1228 | #endif |
1250 | #endif |
1229 | |
1251 | |
1230 | void |
1252 | void |
1231 | rxvt_term::mouse_report (XButtonEvent &ev) |
1253 | rxvt_term::mouse_report (XButtonEvent &ev) |
1232 | { |
1254 | { |
1233 | int button_number, key_state = 0; |
1255 | int button_number, key_state = 0; |
1234 | int x, y; |
1256 | int x, y; |
|
|
1257 | int code = 32; |
1235 | |
1258 | |
1236 | x = ev.x; |
1259 | x = Pixel2Col (ev.x); |
1237 | y = ev.y; |
1260 | y = Pixel2Row (ev.y); |
1238 | pixel_position (&x, &y); |
1261 | if (ev.type == MotionNotify) |
|
|
1262 | { |
|
|
1263 | if (x == mouse_row && y == mouse_col) |
|
|
1264 | return; |
|
|
1265 | mouse_row = x; |
|
|
1266 | mouse_col = y; |
|
|
1267 | code += 32; |
|
|
1268 | } |
1239 | |
1269 | |
1240 | if (MEvent.button == AnyButton) |
1270 | if (MEvent.button == AnyButton) |
1241 | button_number = 3; |
1271 | button_number = 3; |
1242 | else |
1272 | else |
1243 | { |
1273 | { |
… | |
… | |
1289 | x + 1, |
1319 | x + 1, |
1290 | y + 1); |
1320 | y + 1); |
1291 | #endif |
1321 | #endif |
1292 | |
1322 | |
1293 | tt_printf ("\033[M%c%c%c", |
1323 | tt_printf ("\033[M%c%c%c", |
1294 | (32 + button_number + key_state), |
1324 | (code + button_number + key_state), |
1295 | (32 + x + 1), |
1325 | (32 + x + 1), |
1296 | (32 + y + 1)); |
1326 | (32 + y + 1)); |
1297 | } |
1327 | } |
1298 | |
|
|
1299 | #ifdef USING_W11LIB |
|
|
1300 | void |
|
|
1301 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1302 | { |
|
|
1303 | rxvt_t *r = rxvt_get_r (); |
|
|
1304 | |
|
|
1305 | x_cb (*ev); |
|
|
1306 | } |
|
|
1307 | #endif |
|
|
1308 | |
1328 | |
1309 | /*{{{ process an X event */ |
1329 | /*{{{ process an X event */ |
1310 | void |
1330 | void |
1311 | rxvt_term::x_cb (XEvent &ev) |
1331 | rxvt_term::x_cb (XEvent &ev) |
1312 | { |
1332 | { |
1313 | dDisp; |
1333 | make_current (); |
1314 | |
1334 | |
1315 | SET_R (this); |
1335 | dLocal (Display *, dpy); |
1316 | SET_LOCALE (locale); |
|
|
1317 | |
1336 | |
|
|
1337 | if (ev.xany.window == vt |
|
|
1338 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1339 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1340 | return; |
|
|
1341 | |
|
|
1342 | // for XQueryPointer |
1318 | Window unused_root, unused_child; |
1343 | Window unused_root, unused_child; |
1319 | int unused_root_x, unused_root_y; |
1344 | int unused_root_x, unused_root_y; |
1320 | unsigned int unused_mask; |
1345 | unsigned int unused_mask; |
1321 | |
1346 | |
1322 | switch (ev.type) |
1347 | switch (ev.type) |
1323 | { |
1348 | { |
1324 | case KeyPress: |
1349 | case KeyPress: |
1325 | #if ISO_14755 |
1350 | key_press (ev.xkey); |
1326 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1327 | #endif |
|
|
1328 | lookup_key (ev.xkey); |
|
|
1329 | |
|
|
1330 | break; |
1351 | break; |
1331 | |
1352 | |
1332 | case KeyRelease: |
1353 | case KeyRelease: |
1333 | { |
1354 | key_release (ev.xkey); |
1334 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
1335 | KeySym keysym; |
|
|
1336 | |
|
|
1337 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1338 | #endif |
|
|
1339 | |
|
|
1340 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1341 | // ISO 14755 support |
|
|
1342 | if (iso14755buf) |
|
|
1343 | if (iso14755buf & ISO_14755_52) |
|
|
1344 | { |
|
|
1345 | # if ENABLE_OVERLAY |
|
|
1346 | scr_overlay_off (); |
|
|
1347 | # endif |
|
|
1348 | # if ISO_14755 |
|
|
1349 | // iso14755 part 5.2 handling: release time |
|
|
1350 | // first: controls |
|
|
1351 | if ((ev.xkey.state & ControlMask) |
|
|
1352 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
1353 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
1354 | { |
|
|
1355 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
1356 | commit_iso14755 (); |
|
|
1357 | goto skip_switch; |
|
|
1358 | } |
|
|
1359 | |
|
|
1360 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1361 | if (i[0] == keysym) |
|
|
1362 | { |
|
|
1363 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1364 | commit_iso14755 (); |
|
|
1365 | goto skip_switch; |
|
|
1366 | } |
|
|
1367 | |
|
|
1368 | scr_bell (); |
|
|
1369 | # endif |
|
|
1370 | iso14755buf = 0; |
|
|
1371 | break; |
|
|
1372 | } |
|
|
1373 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1374 | { |
|
|
1375 | # if ENABLE_OVERLAY |
|
|
1376 | scr_overlay_off (); |
|
|
1377 | # endif |
|
|
1378 | if (iso14755buf & ISO_14755_51) |
|
|
1379 | commit_iso14755 (); |
|
|
1380 | #if ISO_14755 |
|
|
1381 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1382 | { |
|
|
1383 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1384 | |
|
|
1385 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1386 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1387 | } |
|
|
1388 | # endif |
|
|
1389 | else |
|
|
1390 | iso14755buf = 0; |
|
|
1391 | } |
|
|
1392 | #endif |
|
|
1393 | |
|
|
1394 | if (ev.xany.window == vt |
|
|
1395 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1396 | break; |
|
|
1397 | |
|
|
1398 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1399 | if (!(ev.xkey.state & ControlMask)) |
|
|
1400 | slip_wheel_ev.stop (); |
|
|
1401 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
1402 | mouse_slip_wheel_speed = 0; |
|
|
1403 | #endif |
|
|
1404 | break; |
1355 | break; |
1405 | } |
|
|
1406 | |
1356 | |
1407 | case ButtonPress: |
1357 | case ButtonPress: |
1408 | button_press (ev.xbutton); |
1358 | button_press (ev.xbutton); |
1409 | break; |
1359 | break; |
1410 | |
1360 | |
… | |
… | |
1412 | button_release (ev.xbutton); |
1362 | button_release (ev.xbutton); |
1413 | break; |
1363 | break; |
1414 | |
1364 | |
1415 | case ClientMessage: |
1365 | case ClientMessage: |
1416 | if (ev.xclient.format == 32 |
1366 | if (ev.xclient.format == 32 |
1417 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1367 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1418 | { |
1368 | { |
|
|
1369 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1370 | { |
|
|
1371 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1372 | { |
1419 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1373 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1374 | { |
|
|
1375 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1420 | destroy (); |
1376 | destroy (); |
|
|
1377 | } |
1421 | #if ENABLE_EWMH |
1378 | #if ENABLE_EWMH |
1422 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1379 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1423 | XSendEvent (disp, ev.xclient.window = display->root, |
1380 | XSendEvent (dpy, ev.xclient.window = display->root, |
1424 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1381 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1425 | &ev); |
1382 | &ev); |
|
|
1383 | #endif |
|
|
1384 | } |
|
|
1385 | } |
|
|
1386 | #if ENABLE_XEMBED |
|
|
1387 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1388 | { |
|
|
1389 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1390 | focus_in (); |
|
|
1391 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1392 | focus_out (); |
|
|
1393 | } |
1426 | #endif |
1394 | #endif |
1427 | } |
1395 | } |
1428 | #if ENABLE_XEMBED |
|
|
1429 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1430 | { |
|
|
1431 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1432 | focus_in (); |
|
|
1433 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1434 | focus_out (); |
|
|
1435 | } |
|
|
1436 | #endif |
|
|
1437 | #ifdef OFFIX_DND |
|
|
1438 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1439 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1440 | && (ev.xclient.data.l[0] == DndFile |
|
|
1441 | || ev.xclient.data.l[0] == DndDir |
|
|
1442 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1443 | { |
|
|
1444 | /* Get Dnd data */ |
|
|
1445 | Atom ActualType; |
|
|
1446 | int ActualFormat; |
|
|
1447 | unsigned char *data; |
|
|
1448 | unsigned long Size, RemainingBytes; |
|
|
1449 | |
|
|
1450 | XGetWindowProperty (disp, display->root, |
|
|
1451 | xa[XA_DNDSELECTION], |
|
|
1452 | 0L, 1000000L, |
|
|
1453 | False, AnyPropertyType, |
|
|
1454 | &ActualType, &ActualFormat, |
|
|
1455 | &Size, &RemainingBytes, |
|
|
1456 | &data); |
|
|
1457 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1458 | XFree (data); |
|
|
1459 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1460 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1461 | } |
|
|
1462 | #endif /* OFFIX_DND */ |
|
|
1463 | break; |
|
|
1464 | |
|
|
1465 | case MappingNotify: |
|
|
1466 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1467 | break; |
1396 | break; |
1468 | |
1397 | |
1469 | /* |
1398 | /* |
1470 | * XXX: this is not the _current_ arrangement |
1399 | * XXX: this is not the _current_ arrangement |
1471 | * Here's my conclusion: |
1400 | * Here's my conclusion: |
… | |
… | |
1490 | break; |
1419 | break; |
1491 | } |
1420 | } |
1492 | break; |
1421 | break; |
1493 | |
1422 | |
1494 | case FocusIn: |
1423 | case FocusIn: |
|
|
1424 | if (ev.xfocus.detail != NotifyInferior |
|
|
1425 | && ev.xfocus.detail != NotifyPointer |
|
|
1426 | && ev.xfocus.mode != NotifyGrab) |
1495 | focus_in (); |
1427 | focus_in (); |
1496 | break; |
1428 | break; |
1497 | |
1429 | |
1498 | case FocusOut: |
1430 | case FocusOut: |
|
|
1431 | if (ev.xfocus.detail != NotifyInferior |
|
|
1432 | && ev.xfocus.detail != NotifyPointer |
|
|
1433 | && ev.xfocus.mode != NotifyGrab) |
1499 | focus_out (); |
1434 | focus_out (); |
1500 | break; |
1435 | break; |
1501 | |
1436 | |
1502 | case ConfigureNotify: |
1437 | case ConfigureNotify: |
|
|
1438 | /* fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", |
|
|
1439 | ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, |
|
|
1440 | szHint.width, szHint.height); */ |
1503 | if (ev.xconfigure.window == parent[0]) |
1441 | if (ev.xconfigure.window == parent[0]) |
1504 | { |
1442 | { |
1505 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1443 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1506 | ; |
1444 | ; |
1507 | |
1445 | |
1508 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1446 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1509 | { |
1447 | { |
1510 | seen_resize = 1; |
1448 | seen_resize = 1; |
1511 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1449 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1512 | } |
1450 | } |
1513 | |
1451 | else |
1514 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1452 | { |
1515 | if (OPTION (Opt_transparent)) |
1453 | #ifdef HAVE_BG_PIXMAP |
1516 | check_our_parents (); |
1454 | if (bgPixmap.window_position_sensitive ()) |
|
|
1455 | update_background (); |
1517 | #endif |
1456 | #endif |
|
|
1457 | } |
|
|
1458 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1518 | } |
1459 | } |
1519 | break; |
1460 | break; |
1520 | |
1461 | |
1521 | case PropertyNotify: |
1462 | case PropertyNotify: |
|
|
1463 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1522 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1464 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1523 | && ev.xproperty.state == PropertyNewValue) |
1465 | && ev.xproperty.state == PropertyNewValue) |
1524 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1466 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1525 | |
1467 | |
1526 | break; |
1468 | break; |
1527 | |
1469 | |
1528 | case SelectionClear: |
1470 | case SelectionClear: |
1529 | selection_clear (); |
1471 | selection_clear (); |
… | |
… | |
1539 | break; |
1481 | break; |
1540 | |
1482 | |
1541 | case MapNotify: |
1483 | case MapNotify: |
1542 | mapped = 1; |
1484 | mapped = 1; |
1543 | #ifdef TEXT_BLINK |
1485 | #ifdef TEXT_BLINK |
1544 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
1486 | text_blink_ev.start (); |
1545 | #endif |
1487 | #endif |
1546 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1488 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1547 | break; |
1489 | break; |
1548 | |
1490 | |
1549 | case UnmapNotify: |
1491 | case UnmapNotify: |
… | |
… | |
1551 | #ifdef TEXT_BLINK |
1493 | #ifdef TEXT_BLINK |
1552 | text_blink_ev.stop (); |
1494 | text_blink_ev.stop (); |
1553 | #endif |
1495 | #endif |
1554 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1496 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1555 | break; |
1497 | break; |
1556 | |
|
|
1557 | #ifdef TRANSPARENT |
|
|
1558 | case ReparentNotify: |
|
|
1559 | rootwin_cb (ev); |
|
|
1560 | break; |
|
|
1561 | #endif /* TRANSPARENT */ |
|
|
1562 | |
1498 | |
1563 | case GraphicsExpose: |
1499 | case GraphicsExpose: |
1564 | case Expose: |
1500 | case Expose: |
1565 | if (ev.xany.window == vt) |
1501 | if (ev.xany.window == vt) |
1566 | { |
1502 | { |
1567 | do |
1503 | do |
|
|
1504 | { |
1568 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1505 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1569 | ev.xexpose.width, ev.xexpose.height, False); |
1506 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1507 | } |
1570 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); |
1508 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1571 | |
1509 | |
1572 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1510 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1573 | |
1511 | |
1574 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1512 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
|
|
1513 | { |
1575 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1514 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1576 | ev.xexpose.width, ev.xexpose.height, False); |
1515 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1516 | } |
1577 | |
1517 | |
1578 | scr_refresh (refresh_type); |
1518 | want_refresh = 1; |
1579 | } |
1519 | } |
1580 | else |
1520 | else |
1581 | { |
1521 | { |
1582 | XEvent unused_event; |
1522 | XEvent unused_event; |
1583 | |
1523 | |
1584 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1524 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1585 | ; |
1525 | ; |
1586 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1526 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1587 | ; |
1527 | ; |
1588 | |
1528 | |
1589 | if (isScrollbarWindow (ev.xany.window)) |
1529 | if (isScrollbarWindow (ev.xany.window)) |
1590 | { |
1530 | { |
1591 | scrollBar.setIdle (); |
1531 | scrollBar.setIdle (); |
1592 | scrollbar_show (0); |
1532 | scrollbar_show (0); |
1593 | } |
1533 | } |
1594 | #ifdef MENUBAR |
|
|
1595 | if (menubar_visible () && isMenuBarWindow (ev.xany.window)) |
|
|
1596 | menubar_expose (); |
|
|
1597 | #endif |
|
|
1598 | |
|
|
1599 | #ifdef TRANSPARENT |
|
|
1600 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1601 | XClearWindow (disp, ev.xany.window); |
|
|
1602 | #endif |
|
|
1603 | } |
1534 | } |
1604 | break; |
1535 | break; |
1605 | |
1536 | |
1606 | case MotionNotify: |
1537 | case MotionNotify: |
1607 | #ifdef POINTER_BLANK |
1538 | #ifdef POINTER_BLANK |
1608 | if (hidden_pointer) |
1539 | if (hidden_pointer) |
1609 | pointer_unblank (); |
1540 | pointer_unblank (); |
1610 | #endif |
1541 | #endif |
1611 | #if MENUBAR |
1542 | if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) |
1612 | if (isMenuBarWindow (ev.xany.window)) |
1543 | || priv_modes & PrivMode_MouseAnyEvent) |
1613 | { |
|
|
1614 | menubar_control (ev.xbutton); |
1544 | mouse_report (ev.xbutton); |
1615 | break; |
|
|
1616 | } |
|
|
1617 | #endif |
|
|
1618 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1545 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1619 | break; |
1546 | break; |
1620 | |
1547 | |
1621 | if (ev.xany.window == vt) |
1548 | if (ev.xany.window == vt) |
1622 | { |
1549 | { |
|
|
1550 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1623 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1551 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1624 | ; // nop |
1552 | ; // nop |
1625 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1553 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1626 | { |
1554 | { |
1627 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1555 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1628 | ; |
1556 | ; |
1629 | |
1557 | |
1630 | XQueryPointer (disp, vt, |
1558 | XQueryPointer (dpy, vt, |
1631 | &unused_root, &unused_child, |
1559 | &unused_root, &unused_child, |
1632 | &unused_root_x, &unused_root_y, |
1560 | &unused_root_x, &unused_root_y, |
1633 | &ev.xbutton.x, &ev.xbutton.y, |
1561 | &ev.xbutton.x, &ev.xbutton.y, |
1634 | &ev.xbutton.state); |
1562 | &ev.xbutton.state); |
1635 | #ifdef MOUSE_THRESHOLD |
1563 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1655 | int dist; |
1583 | int dist; |
1656 | |
1584 | |
1657 | /* don't clobber the current delay if we are |
1585 | /* don't clobber the current delay if we are |
1658 | * already in the middle of scrolling. |
1586 | * already in the middle of scrolling. |
1659 | */ |
1587 | */ |
1660 | if (!sel_scroll_ev.active) |
1588 | if (!sel_scroll_ev.is_active ()) |
1661 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1589 | sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1662 | |
1590 | |
1663 | /* save the event params so we can highlight |
1591 | /* save the event params so we can highlight |
1664 | * the selection in the pending-scroll loop |
1592 | * the selection in the pending-scroll loop |
1665 | */ |
1593 | */ |
1666 | selection_save_x = ev.xbutton.x; |
1594 | selection_save_x = ev.xbutton.x; |
… | |
… | |
1688 | else |
1616 | else |
1689 | { |
1617 | { |
1690 | /* we are within the text window, so we |
1618 | /* we are within the text window, so we |
1691 | * shouldn't be scrolling |
1619 | * shouldn't be scrolling |
1692 | */ |
1620 | */ |
1693 | if (sel_scroll_ev.active) |
|
|
1694 | sel_scroll_ev.stop(); |
1621 | sel_scroll_ev.stop(); |
1695 | } |
1622 | } |
1696 | #endif |
1623 | #endif |
1697 | #ifdef MOUSE_THRESHOLD |
1624 | #ifdef MOUSE_THRESHOLD |
1698 | } |
1625 | } |
1699 | #endif |
1626 | #endif |
1700 | } |
1627 | } |
1701 | } |
1628 | } |
1702 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1629 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1703 | { |
1630 | { |
1704 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1631 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1705 | MotionNotify, &ev)) |
1632 | MotionNotify, &ev)) |
1706 | ; |
1633 | ; |
1707 | |
1634 | |
1708 | XQueryPointer (disp, scrollBar.win, |
1635 | XQueryPointer (dpy, scrollBar.win, |
1709 | &unused_root, &unused_child, |
1636 | &unused_root, &unused_child, |
1710 | &unused_root_x, &unused_root_y, |
1637 | &unused_root_x, &unused_root_y, |
1711 | &ev.xbutton.x, &ev.xbutton.y, |
1638 | &ev.xbutton.x, &ev.xbutton.y, |
1712 | &unused_mask); |
1639 | &unused_mask); |
1713 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1640 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1714 | scrollbar_size ()); |
1641 | scrollbar_size ()); |
1715 | scr_refresh (refresh_type); |
|
|
1716 | refresh_limit = 0; |
1642 | want_refresh = 1; |
1717 | scrollbar_show (1); |
1643 | scrollbar_show (1); |
1718 | } |
1644 | } |
1719 | break; |
1645 | break; |
1720 | } |
1646 | } |
1721 | |
1647 | |
1722 | skip_switch: ; |
|
|
1723 | |
|
|
1724 | #if defined(CURSOR_BLINK) |
1648 | #if defined(CURSOR_BLINK) |
1725 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1649 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
1726 | { |
1650 | { |
1727 | if (hidden_cursor) |
1651 | if (hidden_cursor) |
1728 | { |
1652 | { |
1729 | hidden_cursor = 0; |
1653 | hidden_cursor = 0; |
1730 | want_refresh = 1; |
1654 | want_refresh = 1; |
1731 | } |
1655 | } |
1732 | |
1656 | |
1733 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1657 | cursor_blink_ev.again (); |
1734 | } |
1658 | } |
1735 | #endif |
1659 | #endif |
1736 | |
1660 | |
1737 | #if defined(POINTER_BLANK) |
1661 | #if defined(POINTER_BLANK) |
1738 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1662 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
1739 | { |
1663 | { |
1740 | if (ev.type == MotionNotify |
1664 | if (ev.type == MotionNotify |
1741 | || ev.type == ButtonPress |
1665 | || ev.type == ButtonPress |
1742 | || ev.type == ButtonRelease) |
1666 | || ev.type == ButtonRelease) |
1743 | if (hidden_pointer) |
1667 | if (hidden_pointer) |
… | |
… | |
1745 | |
1669 | |
1746 | if (ev.type == KeyPress && hidden_pointer == 0) |
1670 | if (ev.type == KeyPress && hidden_pointer == 0) |
1747 | pointer_blank (); |
1671 | pointer_blank (); |
1748 | } |
1672 | } |
1749 | #endif |
1673 | #endif |
|
|
1674 | |
|
|
1675 | refresh_check (); |
1750 | } |
1676 | } |
1751 | |
1677 | |
1752 | void |
1678 | void |
1753 | rxvt_term::focus_in () |
1679 | rxvt_term::focus_in () |
1754 | { |
1680 | { |
1755 | if (!focus) |
1681 | if (!focus) |
1756 | { |
1682 | { |
1757 | focus = 1; |
1683 | focus = 1; |
1758 | want_refresh = 1; |
1684 | want_refresh = 1; |
1759 | |
1685 | |
1760 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1686 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1761 | |
1687 | |
1762 | #if USE_XIM |
1688 | #if USE_XIM |
1763 | if (Input_Context != NULL) |
1689 | if (Input_Context != NULL) |
1764 | { |
1690 | { |
1765 | IMSetStatusPosition (); |
1691 | IMSetPosition (); |
1766 | XSetICFocus (Input_Context); |
1692 | XSetICFocus (Input_Context); |
1767 | } |
1693 | } |
1768 | #endif |
1694 | #endif |
1769 | #if CURSOR_BLINK |
1695 | #if CURSOR_BLINK |
1770 | if (OPTION (Opt_cursorBlink)) |
1696 | if (option (Opt_cursorBlink)) |
1771 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1697 | cursor_blink_ev.again (); |
1772 | #endif |
1698 | #endif |
1773 | #if OFF_FOCUS_FADING |
1699 | #if OFF_FOCUS_FADING |
1774 | if (rs[Rs_fade]) |
1700 | if (rs[Rs_fade]) |
1775 | { |
1701 | { |
1776 | pix_colors = pix_colors_focused; |
1702 | pix_colors = pix_colors_focused; |
1777 | scr_recolour (); |
1703 | scr_recolour (); |
1778 | } |
1704 | } |
1779 | #endif |
1705 | #endif |
|
|
1706 | #if ENABLE_FRILLS |
|
|
1707 | if (option (Opt_urgentOnBell)) |
|
|
1708 | { |
|
|
1709 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1710 | { |
|
|
1711 | h->flags &= ~XUrgencyHint; |
|
|
1712 | XSetWMHints (dpy, parent[0], h); |
|
|
1713 | } |
|
|
1714 | } |
|
|
1715 | #endif |
1780 | } |
1716 | } |
1781 | } |
1717 | } |
1782 | |
1718 | |
1783 | void |
1719 | void |
1784 | rxvt_term::focus_out () |
1720 | rxvt_term::focus_out () |
… | |
… | |
1792 | |
1728 | |
1793 | #if ENABLE_FRILLS || ISO_14755 |
1729 | #if ENABLE_FRILLS || ISO_14755 |
1794 | if (iso14755buf) |
1730 | if (iso14755buf) |
1795 | { |
1731 | { |
1796 | iso14755buf = 0; |
1732 | iso14755buf = 0; |
1797 | # if ENABLE_OVERLAY |
1733 | # if ISO_14755 |
1798 | scr_overlay_off (); |
1734 | scr_overlay_off (); |
1799 | # endif |
1735 | # endif |
1800 | } |
1736 | } |
1801 | #endif |
1737 | #endif |
1802 | #if USE_XIM |
1738 | #if USE_XIM |
1803 | if (Input_Context != NULL) |
1739 | if (Input_Context != NULL) |
1804 | XUnsetICFocus (Input_Context); |
1740 | XUnsetICFocus (Input_Context); |
1805 | #endif |
1741 | #endif |
1806 | #if CURSOR_BLINK |
1742 | #if CURSOR_BLINK |
1807 | if (OPTION (Opt_cursorBlink)) |
1743 | if (option (Opt_cursorBlink)) |
1808 | cursor_blink_ev.stop (); |
1744 | cursor_blink_ev.stop (); |
|
|
1745 | |
1809 | hidden_cursor = 0; |
1746 | hidden_cursor = 0; |
1810 | #endif |
1747 | #endif |
1811 | #if OFF_FOCUS_FADING |
1748 | #if OFF_FOCUS_FADING |
1812 | if (rs[Rs_fade]) |
1749 | if (rs[Rs_fade]) |
1813 | { |
1750 | { |
… | |
… | |
1816 | } |
1753 | } |
1817 | #endif |
1754 | #endif |
1818 | } |
1755 | } |
1819 | } |
1756 | } |
1820 | |
1757 | |
1821 | #if TRANSPARENT |
1758 | void |
|
|
1759 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1760 | { |
|
|
1761 | #if OFF_FOCUS_FADING |
|
|
1762 | if (rs[Rs_fade]) |
|
|
1763 | { |
|
|
1764 | rgba c; |
|
|
1765 | pix_colors [Color_fade].get (c); |
|
|
1766 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1767 | } |
|
|
1768 | #endif |
|
|
1769 | } |
|
|
1770 | |
|
|
1771 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
1822 | void |
1772 | void |
1823 | rxvt_term::rootwin_cb (XEvent &ev) |
1773 | rxvt_term::rootwin_cb (XEvent &ev) |
1824 | { |
1774 | { |
1825 | SET_R (this); |
1775 | make_current (); |
1826 | SET_LOCALE (locale); |
|
|
1827 | |
1776 | |
|
|
1777 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1778 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1779 | return; |
|
|
1780 | |
|
|
1781 | # if ENABLE_TRANSPARENCY |
1828 | switch (ev.type) |
1782 | switch (ev.type) |
1829 | { |
1783 | { |
1830 | case PropertyNotify: |
1784 | case PropertyNotify: |
1831 | /* |
1785 | /* |
1832 | * if user used some Esetroot compatible prog to set the root bg, |
1786 | * if user used some Esetroot compatible prog to set the root bg, |
1833 | * use the property to determine the pixmap. We use it later on. |
1787 | * use the property to determine the pixmap. We use it later on. |
1834 | */ |
1788 | */ |
1835 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1789 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1836 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1790 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1837 | return; |
1791 | { |
1838 | |
1792 | bgPixmap.set_root_pixmap (); |
1839 | /* FALLTHROUGH */ |
1793 | update_background (); |
1840 | case ReparentNotify: |
1794 | } |
1841 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
|
|
1842 | want_refresh = want_full_refresh = 1; |
|
|
1843 | break; |
1795 | break; |
1844 | } |
1796 | } |
|
|
1797 | # endif |
|
|
1798 | |
|
|
1799 | refresh_check (); |
1845 | } |
1800 | } |
1846 | #endif |
1801 | #endif |
1847 | |
1802 | |
1848 | void |
1803 | void |
1849 | rxvt_term::button_press (XButtonEvent &ev) |
1804 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1858 | /* |
1813 | /* |
1859 | * VT window processing of button press |
1814 | * VT window processing of button press |
1860 | */ |
1815 | */ |
1861 | if (ev.window == vt) |
1816 | if (ev.window == vt) |
1862 | { |
1817 | { |
|
|
1818 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1819 | return; |
|
|
1820 | |
1863 | #if ISO_14755 |
1821 | #if ISO_14755 |
1864 | // 5.4 |
1822 | // 5.4 |
1865 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1823 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1866 | { |
1824 | { |
1867 | iso14755_54 (ev.x, ev.y); |
1825 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1901 | mouse_report (ev); |
1859 | mouse_report (ev); |
1902 | } |
1860 | } |
1903 | #else |
1861 | #else |
1904 | MEvent.button = ev.button; |
1862 | MEvent.button = ev.button; |
1905 | mouse_report (ev); |
1863 | mouse_report (ev); |
1906 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1864 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1907 | |
1865 | |
1908 | } |
1866 | } |
1909 | else |
1867 | else |
1910 | { |
1868 | { |
1911 | if (ev.button != MEvent.button) |
1869 | if (ev.button != MEvent.button) |
1912 | MEvent.clicks = 0; |
1870 | MEvent.clicks = 0; |
1913 | |
1871 | |
1914 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1915 | switch (ev.button) |
1872 | switch (ev.button) |
1916 | { |
1873 | { |
1917 | case Button1: |
1874 | case Button1: |
1918 | /* allow meta + click to select rectangular areas */ |
1875 | /* allow meta + click to select rectangular areas */ |
1919 | /* should be done in screen.C */ |
1876 | /* should be done in screen.C */ |
1920 | #if ENABLE_FRILLS |
1877 | #if ENABLE_FRILLS |
1921 | selection.rect = !!(ev.state & ModMetaMask); |
1878 | selection.rect = !!(ev.state & ModMetaMask); |
1922 | #else |
1879 | #else |
1923 | selection.rect = false; |
1880 | selection.rect = false; |
1924 | #endif |
1881 | #endif |
1925 | |
1882 | |
1926 | /* allow shift+left click to extend selection */ |
1883 | /* allow shift+left click to extend selection */ |
1927 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1884 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1928 | { |
1885 | { |
1929 | if (MEvent.button == Button1 && clickintime) |
1886 | if (MEvent.button == Button1 && clickintime) |
1930 | selection_rotate (ev.x, ev.y); |
1887 | selection_rotate (ev.x, ev.y); |
1931 | else |
1888 | else |
1932 | selection_extend (ev.x, ev.y, 1); |
1889 | selection_extend (ev.x, ev.y, 1); |
1933 | } |
1890 | } |
1934 | else |
1891 | else |
1935 | { |
1892 | { |
1936 | if (MEvent.button == Button1 && clickintime) |
1893 | if (MEvent.button == Button1 && clickintime) |
1937 | MEvent.clicks++; |
1894 | MEvent.clicks++; |
1938 | else |
1895 | else |
1939 | MEvent.clicks = 1; |
1896 | MEvent.clicks = 1; |
1940 | |
1897 | |
1941 | selection_click (MEvent.clicks, ev.x, ev.y); |
1898 | selection_click (MEvent.clicks, ev.x, ev.y); |
1942 | } |
1899 | } |
1943 | |
1900 | |
1944 | MEvent.button = Button1; |
1901 | MEvent.button = Button1; |
1945 | break; |
1902 | break; |
1946 | |
1903 | |
1947 | case Button3: |
1904 | case Button3: |
1948 | if (MEvent.button == Button3 && clickintime) |
1905 | if (MEvent.button == Button3 && clickintime) |
1949 | selection_rotate (ev.x, ev.y); |
1906 | selection_rotate (ev.x, ev.y); |
1950 | else |
1907 | else |
1951 | selection_extend (ev.x, ev.y, 1); |
1908 | selection_extend (ev.x, ev.y, 1); |
1952 | |
1909 | |
1953 | MEvent.button = Button3; |
1910 | MEvent.button = Button3; |
1954 | break; |
1911 | break; |
1955 | } |
1912 | } |
1956 | } |
1913 | } |
1957 | |
1914 | |
1958 | MEvent.time = ev.time; |
1915 | MEvent.time = ev.time; |
1959 | return; |
1916 | return; |
1960 | } |
1917 | } |
1961 | |
1918 | |
… | |
… | |
2006 | tt_printf ("\033[5~"); |
1963 | tt_printf ("\033[5~"); |
2007 | break; |
1964 | break; |
2008 | } |
1965 | } |
2009 | } |
1966 | } |
2010 | else |
1967 | else |
2011 | #endif /* NO_SCROLLBAR_REPORT */ |
1968 | #endif /* NO_SCROLLBAR_REPORT */ |
2012 | |
1969 | |
2013 | { |
1970 | { |
2014 | char upordown = 0; |
1971 | char upordown = 0; |
2015 | |
1972 | |
2016 | if (scrollBar.style == R_SB_NEXT) |
1973 | if (scrollBar.style == R_SB_NEXT) |
2017 | { |
1974 | { |
2018 | if (scrollbarnext_upButton (ev.y)) |
1975 | if (scrollbarnext_upButton (ev.y)) |
2019 | upordown = -1; /* up */ |
1976 | upordown = -1; /* up */ |
… | |
… | |
2025 | if (scrollbarrxvt_upButton (ev.y)) |
1982 | if (scrollbarrxvt_upButton (ev.y)) |
2026 | upordown = -1; /* up */ |
1983 | upordown = -1; /* up */ |
2027 | else if (scrollbarrxvt_dnButton (ev.y)) |
1984 | else if (scrollbarrxvt_dnButton (ev.y)) |
2028 | upordown = 1; /* down */ |
1985 | upordown = 1; /* down */ |
2029 | } |
1986 | } |
|
|
1987 | |
2030 | if (upordown) |
1988 | if (upordown) |
2031 | { |
1989 | { |
2032 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1990 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
1991 | if (!cont_scroll_ev.is_active ()) |
2033 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1992 | cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2034 | #endif |
1993 | #endif |
2035 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1994 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
2036 | { |
1995 | { |
2037 | if (upordown < 0) |
1996 | if (upordown < 0) |
2038 | scrollBar.setUp (); |
1997 | scrollBar.setUp (); |
… | |
… | |
2100 | } |
2059 | } |
2101 | } |
2060 | } |
2102 | |
2061 | |
2103 | return; |
2062 | return; |
2104 | } |
2063 | } |
2105 | |
|
|
2106 | #if MENUBAR |
|
|
2107 | /* |
|
|
2108 | * Menubar window processing of button press |
|
|
2109 | */ |
|
|
2110 | if (isMenuBarWindow (ev.window)) |
|
|
2111 | menubar_control (ev); |
|
|
2112 | #endif |
|
|
2113 | } |
2064 | } |
2114 | |
2065 | |
2115 | void |
2066 | void |
2116 | rxvt_term::button_release (XButtonEvent &ev) |
2067 | rxvt_term::button_release (XButtonEvent &ev) |
2117 | { |
2068 | { |
… | |
… | |
2123 | |
2074 | |
2124 | if (scrollbar_isUpDn ()) |
2075 | if (scrollbar_isUpDn ()) |
2125 | { |
2076 | { |
2126 | scrollBar.setIdle (); |
2077 | scrollBar.setIdle (); |
2127 | scrollbar_show (0); |
2078 | scrollbar_show (0); |
2128 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
2129 | refresh_type &= ~SMOOTH_REFRESH; |
|
|
2130 | #endif |
|
|
2131 | } |
2079 | } |
2132 | |
2080 | |
2133 | #ifdef SELECTION_SCROLLING |
2081 | #ifdef SELECTION_SCROLLING |
2134 | if (sel_scroll_ev.active) |
|
|
2135 | sel_scroll_ev.stop(); |
2082 | sel_scroll_ev.stop(); |
2136 | #endif |
2083 | #endif |
2137 | |
2084 | |
2138 | if (ev.window == vt) |
2085 | if (ev.window == vt) |
2139 | { |
2086 | { |
|
|
2087 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2088 | return; |
|
|
2089 | |
2140 | #if ISO_14755 |
2090 | #if ISO_14755 |
2141 | // 5.4 |
2091 | // 5.4 |
2142 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2092 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2143 | return; |
2093 | return; |
2144 | #endif |
2094 | #endif |
|
|
2095 | |
2145 | if (reportmode) |
2096 | if (reportmode) |
2146 | { |
2097 | { |
2147 | /* mouse report from vt window */ |
2098 | /* mouse report from vt window */ |
2148 | /* don't report release of wheel "buttons" */ |
2099 | /* don't report release of wheel "buttons" */ |
2149 | if (ev.button >= 4) |
2100 | if (ev.button >= 4) |
… | |
… | |
2160 | mouse_report (ev); |
2111 | mouse_report (ev); |
2161 | } |
2112 | } |
2162 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2113 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2163 | MEvent.button = AnyButton; |
2114 | MEvent.button = AnyButton; |
2164 | mouse_report (ev); |
2115 | mouse_report (ev); |
2165 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2116 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2166 | return; |
2117 | return; |
2167 | } |
2118 | } |
2168 | |
2119 | |
2169 | /* |
2120 | /* |
2170 | * dumb hack to compensate for the failure of click-and-drag |
2121 | * dumb hack to compensate for the failure of click-and-drag |
… | |
… | |
2173 | if (priv_modes & PrivMode_mouse_report |
2124 | if (priv_modes & PrivMode_mouse_report |
2174 | && bypass_keystate |
2125 | && bypass_keystate |
2175 | && ev.button == Button1 && MEvent.clicks <= 1) |
2126 | && ev.button == Button1 && MEvent.clicks <= 1) |
2176 | selection_extend (ev.x, ev.y, 0); |
2127 | selection_extend (ev.x, ev.y, 0); |
2177 | |
2128 | |
2178 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2179 | return; |
|
|
2180 | |
|
|
2181 | switch (ev.button) |
2129 | switch (ev.button) |
2182 | { |
2130 | { |
2183 | case Button1: |
2131 | case Button1: |
2184 | case Button3: |
2132 | case Button3: |
2185 | selection_make (ev.time); |
2133 | selection_make (ev.time); |
2186 | break; |
2134 | break; |
|
|
2135 | |
2187 | case Button2: |
2136 | case Button2: |
2188 | selection_request (ev.time, ev.x, ev.y); |
2137 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
|
|
2138 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2189 | break; |
2139 | break; |
|
|
2140 | |
2190 | #ifdef MOUSE_WHEEL |
2141 | #ifdef MOUSE_WHEEL |
2191 | case Button4: |
2142 | case Button4: |
2192 | case Button5: |
2143 | case Button5: |
2193 | { |
2144 | { |
2194 | int i; |
2145 | int i; |
… | |
… | |
2196 | |
2147 | |
2197 | v = ev.button == Button4 ? UP : DN; |
2148 | v = ev.button == Button4 ? UP : DN; |
2198 | |
2149 | |
2199 | if (ev.state & ShiftMask) |
2150 | if (ev.state & ShiftMask) |
2200 | i = 1; |
2151 | i = 1; |
2201 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2152 | else if (option (Opt_mouseWheelScrollPage)) |
2202 | i = nrow - 1; |
2153 | i = nrow - 1; |
2203 | else |
2154 | else |
2204 | i = 5; |
2155 | i = 5; |
2205 | |
2156 | |
2206 | # ifdef MOUSE_SLIP_WHEELING |
2157 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2208 | { |
2159 | { |
2209 | mouse_slip_wheel_speed += v ? -1 : 1; |
2160 | mouse_slip_wheel_speed += v ? -1 : 1; |
2210 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2161 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2211 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2162 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2212 | |
2163 | |
2213 | if (slip_wheel_ev.at < NOW) |
2164 | if (!slip_wheel_ev.is_active ()) |
2214 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
2165 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2215 | |
|
|
2216 | slip_wheel_ev.start (); |
|
|
2217 | } |
2166 | } |
2218 | else |
2167 | else |
2219 | { |
2168 | { |
2220 | # endif |
2169 | # endif |
2221 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2222 | scr_page (v, i); |
2170 | scr_page (v, i); |
2223 | scr_refresh (SMOOTH_REFRESH); |
|
|
2224 | scrollbar_show (1); |
2171 | scrollbar_show (1); |
2225 | # else |
|
|
2226 | while (i--) |
|
|
2227 | { |
|
|
2228 | scr_page (v, 1); |
|
|
2229 | scr_refresh (SMOOTH_REFRESH); |
|
|
2230 | scrollbar_show (1); |
|
|
2231 | } |
|
|
2232 | # endif |
|
|
2233 | # ifdef MOUSE_SLIP_WHEELING |
2172 | # ifdef MOUSE_SLIP_WHEELING |
2234 | } |
2173 | } |
2235 | #endif |
2174 | # endif |
2236 | } |
2175 | } |
2237 | break; |
2176 | break; |
2238 | #endif |
2177 | #endif |
2239 | } |
2178 | } |
2240 | } |
2179 | } |
2241 | #ifdef MENUBAR |
|
|
2242 | else if (isMenuBarWindow (ev.window)) |
|
|
2243 | menubar_control (ev); |
|
|
2244 | #endif |
|
|
2245 | } |
2180 | } |
2246 | |
|
|
2247 | #ifdef TRANSPARENT |
|
|
2248 | #if TINTING |
|
|
2249 | /* taken from aterm-0.4.2 */ |
|
|
2250 | |
|
|
2251 | typedef uint32_t RUINT32T; |
|
|
2252 | |
|
|
2253 | void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2254 | { |
|
|
2255 | int sh_r, sh_g, sh_b; |
|
|
2256 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2257 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2258 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2259 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2260 | int i; |
|
|
2261 | |
|
|
2262 | Visual *visual = display->visual; |
|
|
2263 | |
|
|
2264 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2265 | |
|
|
2266 | /* for convenience */ |
|
|
2267 | mask_r = visual->red_mask; |
|
|
2268 | mask_g = visual->green_mask; |
|
|
2269 | mask_b = visual->blue_mask; |
|
|
2270 | |
|
|
2271 | /* boring lookup table pre-initialization */ |
|
|
2272 | switch (srcImage->bits_per_pixel) { |
|
|
2273 | case 15: |
|
|
2274 | if ((mask_r != 0x7c00) || |
|
|
2275 | (mask_g != 0x03e0) || |
|
|
2276 | (mask_b != 0x001f)) |
|
|
2277 | return; |
|
|
2278 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2279 | lookup_r = lookup; |
|
|
2280 | lookup_g = lookup+32; |
|
|
2281 | lookup_b = lookup+32+32; |
|
|
2282 | sh_r = 10; |
|
|
2283 | sh_g = 5; |
|
|
2284 | sh_b = 0; |
|
|
2285 | break; |
|
|
2286 | case 16: |
|
|
2287 | if ((mask_r != 0xf800) || |
|
|
2288 | (mask_g != 0x07e0) || |
|
|
2289 | (mask_b != 0x001f)) |
|
|
2290 | return; |
|
|
2291 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2292 | lookup_r = lookup; |
|
|
2293 | lookup_g = lookup+32; |
|
|
2294 | lookup_b = lookup+32+64; |
|
|
2295 | sh_r = 11; |
|
|
2296 | sh_g = 5; |
|
|
2297 | sh_b = 0; |
|
|
2298 | break; |
|
|
2299 | case 24: |
|
|
2300 | if ((mask_r != 0xff0000) || |
|
|
2301 | (mask_g != 0x00ff00) || |
|
|
2302 | (mask_b != 0x0000ff)) |
|
|
2303 | return; |
|
|
2304 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2305 | lookup_r = lookup; |
|
|
2306 | lookup_g = lookup+256; |
|
|
2307 | lookup_b = lookup+256+256; |
|
|
2308 | sh_r = 16; |
|
|
2309 | sh_g = 8; |
|
|
2310 | sh_b = 0; |
|
|
2311 | break; |
|
|
2312 | case 32: |
|
|
2313 | if ((mask_r != 0xff0000) || |
|
|
2314 | (mask_g != 0x00ff00) || |
|
|
2315 | (mask_b != 0x0000ff)) |
|
|
2316 | return; |
|
|
2317 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2318 | lookup_r = lookup; |
|
|
2319 | lookup_g = lookup+256; |
|
|
2320 | lookup_b = lookup+256+256; |
|
|
2321 | sh_r = 16; |
|
|
2322 | sh_g = 8; |
|
|
2323 | sh_b = 0; |
|
|
2324 | break; |
|
|
2325 | default: |
|
|
2326 | return; /* we do not support this color depth */ |
|
|
2327 | } |
|
|
2328 | |
|
|
2329 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2330 | if (shade < 0) { |
|
|
2331 | shade = -shade; |
|
|
2332 | if (shade < 0) shade = 0; |
|
|
2333 | if (shade > 100) shade = 100; |
|
|
2334 | |
|
|
2335 | lower_lim_r = 65535-rm; |
|
|
2336 | lower_lim_g = 65535-gm; |
|
|
2337 | lower_lim_b = 65535-bm; |
|
|
2338 | |
|
|
2339 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2340 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2341 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2342 | |
|
|
2343 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2344 | } else { |
|
|
2345 | if (shade < 0) shade = 0; |
|
|
2346 | if (shade > 100) shade = 100; |
|
|
2347 | |
|
|
2348 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2349 | |
|
|
2350 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2351 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2352 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2353 | } |
|
|
2354 | |
|
|
2355 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2356 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2357 | { |
|
|
2358 | unsigned int tmp; |
|
|
2359 | |
|
|
2360 | tmp = lower_lim_r; |
|
|
2361 | lower_lim_r = lower_lim_b; |
|
|
2362 | lower_lim_b = tmp; |
|
|
2363 | |
|
|
2364 | tmp = upper_lim_r; |
|
|
2365 | upper_lim_r = upper_lim_b; |
|
|
2366 | upper_lim_b = tmp; |
|
|
2367 | } |
|
|
2368 | |
|
|
2369 | /* fill our lookup tables */ |
|
|
2370 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2371 | { |
|
|
2372 | RUINT32T tmp; |
|
|
2373 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2374 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2375 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2376 | } |
|
|
2377 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2378 | { |
|
|
2379 | RUINT32T tmp; |
|
|
2380 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2381 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2382 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2383 | } |
|
|
2384 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2385 | { |
|
|
2386 | RUINT32T tmp; |
|
|
2387 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2388 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2389 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2390 | } |
|
|
2391 | |
|
|
2392 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2393 | switch (srcImage->bits_per_pixel) |
|
|
2394 | { |
|
|
2395 | case 15: |
|
|
2396 | { |
|
|
2397 | unsigned short *p1, *pf, *p, *pl; |
|
|
2398 | p1 = (unsigned short *) srcImage->data; |
|
|
2399 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2400 | while (p1 < pf) |
|
|
2401 | { |
|
|
2402 | p = p1; |
|
|
2403 | pl = p1 + srcImage->width; |
|
|
2404 | for (; p < pl; p++) |
|
|
2405 | { |
|
|
2406 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2407 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2408 | lookup_b[(*p & 0x001f)]; |
|
|
2409 | } |
|
|
2410 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2411 | } |
|
|
2412 | break; |
|
|
2413 | } |
|
|
2414 | case 16: |
|
|
2415 | { |
|
|
2416 | unsigned short *p1, *pf, *p, *pl; |
|
|
2417 | p1 = (unsigned short *) srcImage->data; |
|
|
2418 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2419 | while (p1 < pf) |
|
|
2420 | { |
|
|
2421 | p = p1; |
|
|
2422 | pl = p1 + srcImage->width; |
|
|
2423 | for (; p < pl; p++) |
|
|
2424 | { |
|
|
2425 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2426 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2427 | lookup_b[(*p & 0x001f)]; |
|
|
2428 | } |
|
|
2429 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2430 | } |
|
|
2431 | break; |
|
|
2432 | } |
|
|
2433 | case 24: |
|
|
2434 | { |
|
|
2435 | unsigned char *p1, *pf, *p, *pl; |
|
|
2436 | p1 = (unsigned char *) srcImage->data; |
|
|
2437 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2438 | while (p1 < pf) |
|
|
2439 | { |
|
|
2440 | p = p1; |
|
|
2441 | pl = p1 + srcImage->width * 3; |
|
|
2442 | for (; p < pl; p += 3) |
|
|
2443 | { |
|
|
2444 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2445 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2446 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2447 | } |
|
|
2448 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2449 | } |
|
|
2450 | break; |
|
|
2451 | } |
|
|
2452 | case 32: |
|
|
2453 | { |
|
|
2454 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2455 | p1 = (RUINT32T *) srcImage->data; |
|
|
2456 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2457 | |
|
|
2458 | while (p1 < pf) |
|
|
2459 | { |
|
|
2460 | p = p1; |
|
|
2461 | pl = p1 + srcImage->width; |
|
|
2462 | for (; p < pl; p++) |
|
|
2463 | { |
|
|
2464 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2465 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2466 | lookup_b[(*p & 0x0000ff)] | |
|
|
2467 | (*p & ~0xffffff); |
|
|
2468 | } |
|
|
2469 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2470 | } |
|
|
2471 | break; |
|
|
2472 | } |
|
|
2473 | } |
|
|
2474 | |
|
|
2475 | free (lookup); |
|
|
2476 | } |
|
|
2477 | #endif |
|
|
2478 | |
|
|
2479 | /* |
|
|
2480 | * Check our parents are still who we think they are. |
|
|
2481 | * Do transparency updates if required |
|
|
2482 | */ |
|
|
2483 | int |
|
|
2484 | rxvt_term::check_our_parents () |
|
|
2485 | { |
|
|
2486 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2487 | unsigned long nitems, bytes_after; |
|
|
2488 | Atom atype; |
|
|
2489 | unsigned char *prop = NULL; |
|
|
2490 | Window root, oldp, *list; |
|
|
2491 | Pixmap rootpixmap = None; |
|
|
2492 | XWindowAttributes wattr, wrootattr; |
|
|
2493 | dDisp; |
|
|
2494 | |
|
|
2495 | pchanged = 0; |
|
|
2496 | |
|
|
2497 | if (!OPTION (Opt_transparent)) |
|
|
2498 | return pchanged; /* Don't try any more */ |
|
|
2499 | |
|
|
2500 | XGetWindowAttributes (disp, display->root, &wrootattr); |
|
|
2501 | rootdepth = wrootattr.depth; |
|
|
2502 | |
|
|
2503 | XGetWindowAttributes (disp, parent[0], &wattr); |
|
|
2504 | |
|
|
2505 | if (rootdepth != wattr.depth) |
|
|
2506 | { |
|
|
2507 | if (am_transparent) |
|
|
2508 | { |
|
|
2509 | pchanged = 1; |
|
|
2510 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2511 | am_transparent = am_pixmap_trans = 0; |
|
|
2512 | } |
|
|
2513 | |
|
|
2514 | return pchanged; /* Don't try any more */ |
|
|
2515 | } |
|
|
2516 | |
|
|
2517 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2518 | XSync (disp, False); |
|
|
2519 | |
|
|
2520 | /* |
|
|
2521 | * Make the frame window set by the window manager have |
|
|
2522 | * the root background. Some window managers put multiple nested frame |
|
|
2523 | * windows for each client, so we have to take care about that. |
|
|
2524 | */ |
|
|
2525 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2526 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2527 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2528 | &nitems, &bytes_after, &prop) == Success); |
|
|
2529 | |
|
|
2530 | if (!i || prop == NULL) |
|
|
2531 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2532 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2533 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2534 | &nitems, &bytes_after, &prop) == Success); |
|
|
2535 | |
|
|
2536 | if (!i || prop == NULL |
|
|
2537 | #if TINTING |
|
|
2538 | || !rs[Rs_color + Color_tint] |
|
|
2539 | #endif |
|
|
2540 | ) |
|
|
2541 | have_pixmap = 0; |
|
|
2542 | else |
|
|
2543 | { |
|
|
2544 | have_pixmap = 1; |
|
|
2545 | rootpixmap = *(Pixmap *)prop; |
|
|
2546 | XFree (prop); |
|
|
2547 | } |
|
|
2548 | |
|
|
2549 | if (have_pixmap) |
|
|
2550 | { |
|
|
2551 | /* |
|
|
2552 | * Copy display->root pixmap transparency |
|
|
2553 | */ |
|
|
2554 | int sx, sy, nx, ny; |
|
|
2555 | unsigned int nw, nh; |
|
|
2556 | Window cr; |
|
|
2557 | XImage *image; |
|
|
2558 | GC gc; |
|
|
2559 | XGCValues gcvalue; |
|
|
2560 | |
|
|
2561 | XTranslateCoordinates (disp, parent[0], display->root, |
|
|
2562 | 0, 0, &sx, &sy, &cr); |
|
|
2563 | nw = (unsigned int)szHint.width; |
|
|
2564 | nh = (unsigned int)szHint.height; |
|
|
2565 | nx = ny = 0; |
|
|
2566 | |
|
|
2567 | if (sx < 0) |
|
|
2568 | { |
|
|
2569 | nw += sx; |
|
|
2570 | nx = -sx; |
|
|
2571 | sx = 0; |
|
|
2572 | } |
|
|
2573 | |
|
|
2574 | if (sy < 0) |
|
|
2575 | { |
|
|
2576 | nh += sy; |
|
|
2577 | ny = -sy; |
|
|
2578 | sy = 0; |
|
|
2579 | } |
|
|
2580 | |
|
|
2581 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2582 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2583 | |
|
|
2584 | XSync (disp, False); |
|
|
2585 | allowedxerror = -1; |
|
|
2586 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2587 | |
|
|
2588 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2589 | /* XXX: may need a delay here? */ |
|
|
2590 | allowedxerror = 0; |
|
|
2591 | |
|
|
2592 | if (image == NULL) |
|
|
2593 | { |
|
|
2594 | if (am_transparent && am_pixmap_trans) |
|
|
2595 | { |
|
|
2596 | pchanged = 1; |
|
|
2597 | if (pixmap != None) |
|
|
2598 | { |
|
|
2599 | XFreePixmap (disp, pixmap); |
|
|
2600 | pixmap = None; |
|
|
2601 | } |
|
|
2602 | } |
|
|
2603 | |
|
|
2604 | am_pixmap_trans = 0; |
|
|
2605 | } |
|
|
2606 | else |
|
|
2607 | { |
|
|
2608 | if (pixmap != None) |
|
|
2609 | XFreePixmap (disp, pixmap); |
|
|
2610 | |
|
|
2611 | #if TINTING |
|
|
2612 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2613 | { |
|
|
2614 | unsigned short rm, gm, bm; |
|
|
2615 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2616 | |
|
|
2617 | pix_colors_focused[Color_tint].get (display, rm, gm, bm); |
|
|
2618 | |
|
|
2619 | ShadeXImage (display, image, shade, rm, gm, bm); |
|
|
2620 | } |
|
|
2621 | #endif |
|
|
2622 | |
|
|
2623 | pixmap = XCreatePixmap (disp, vt, |
|
|
2624 | szHint.width, szHint.height, image->depth); |
|
|
2625 | gc = XCreateGC (disp, vt, 0UL, &gcvalue); |
|
|
2626 | XPutImage (disp, pixmap, gc, image, 0, 0, |
|
|
2627 | nx, ny, image->width, image->height); |
|
|
2628 | XFreeGC (disp, gc); |
|
|
2629 | XDestroyImage (image); |
|
|
2630 | XSetWindowBackgroundPixmap (disp, parent[0], pixmap); |
|
|
2631 | XClearWindow (disp, parent[0]); |
|
|
2632 | |
|
|
2633 | if (!am_transparent || !am_pixmap_trans) |
|
|
2634 | pchanged = 1; |
|
|
2635 | |
|
|
2636 | am_transparent = am_pixmap_trans = 1; |
|
|
2637 | } |
|
|
2638 | } |
|
|
2639 | |
|
|
2640 | if (am_pixmap_trans) |
|
|
2641 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2642 | else |
|
|
2643 | { |
|
|
2644 | unsigned int n; |
|
|
2645 | /* |
|
|
2646 | * InheritPixmap transparency |
|
|
2647 | */ |
|
|
2648 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2649 | { |
|
|
2650 | oldp = parent[i]; |
|
|
2651 | XQueryTree (disp, parent[i - 1], &root, |
|
|
2652 | &parent[i], &list, &n); |
|
|
2653 | XFree (list); |
|
|
2654 | |
|
|
2655 | if (parent[i] == display->root) |
|
|
2656 | { |
|
|
2657 | if (oldp != None) |
|
|
2658 | pchanged = 1; |
|
|
2659 | |
|
|
2660 | break; |
|
|
2661 | } |
|
|
2662 | |
|
|
2663 | if (oldp != parent[i]) |
|
|
2664 | pchanged = 1; |
|
|
2665 | } |
|
|
2666 | |
|
|
2667 | n = 0; |
|
|
2668 | |
|
|
2669 | if (pchanged) |
|
|
2670 | { |
|
|
2671 | for (; n < (unsigned int)i; n++) |
|
|
2672 | { |
|
|
2673 | XGetWindowAttributes (disp, parent[n], &wattr); |
|
|
2674 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2675 | { |
|
|
2676 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2677 | break; |
|
|
2678 | } |
|
|
2679 | } |
|
|
2680 | } |
|
|
2681 | |
|
|
2682 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2683 | { |
|
|
2684 | XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); |
|
|
2685 | XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); |
|
|
2686 | am_transparent = 0; |
|
|
2687 | /* XXX: also turn off Opt_transparent? */ |
|
|
2688 | } |
|
|
2689 | else |
|
|
2690 | { |
|
|
2691 | #if WAIT_FOR_WM |
|
|
2692 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2693 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2694 | sleep (1); |
|
|
2695 | #endif |
|
|
2696 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2697 | { |
|
|
2698 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
|
|
2699 | XClearWindow (disp, parent[n]); |
|
|
2700 | } |
|
|
2701 | |
|
|
2702 | XSetWindowBackgroundPixmap (disp, vt, ParentRelative); |
|
|
2703 | am_transparent = 1; |
|
|
2704 | } |
|
|
2705 | |
|
|
2706 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2707 | parent[i] = None; |
|
|
2708 | } |
|
|
2709 | |
|
|
2710 | if (scrollBar.win) |
|
|
2711 | { |
|
|
2712 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
|
|
2713 | scrollBar.setIdle (); |
|
|
2714 | scrollbar_show (0); |
|
|
2715 | } |
|
|
2716 | |
|
|
2717 | if (am_transparent) |
|
|
2718 | { |
|
|
2719 | want_refresh = want_full_refresh = 1; |
|
|
2720 | if (am_pixmap_trans) |
|
|
2721 | flush (); |
|
|
2722 | } |
|
|
2723 | |
|
|
2724 | return pchanged; |
|
|
2725 | } |
|
|
2726 | #endif |
|
|
2727 | |
2181 | |
2728 | /*}}} */ |
2182 | /*}}} */ |
2729 | |
2183 | |
2730 | bool |
2184 | bool |
2731 | rxvt_term::cmd_parse () |
2185 | rxvt_term::cmd_parse () |
… | |
… | |
2780 | if (ch == C0_LF) |
2234 | if (ch == C0_LF) |
2781 | nlines++; |
2235 | nlines++; |
2782 | |
2236 | |
2783 | refresh_count++; |
2237 | refresh_count++; |
2784 | |
2238 | |
2785 | if (!OPTION (Opt_jumpScroll) |
2239 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2786 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2787 | { |
2240 | { |
2788 | refreshnow = true; |
|
|
2789 | refresh_count = 0; |
2241 | refresh_count = 0; |
|
|
2242 | |
|
|
2243 | if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.) |
|
|
2244 | { |
|
|
2245 | refreshnow = true; |
2790 | ch = NOCHAR; |
2246 | ch = NOCHAR; |
2791 | break; |
2247 | break; |
|
|
2248 | } |
2792 | } |
2249 | } |
2793 | |
2250 | |
2794 | // scr_add_lines only works for nlines <= nrow - 1. |
2251 | // scr_add_lines only works for nlines <= nrow - 1. |
2795 | if (nlines >= nrow - 1) |
2252 | if (nlines >= nrow - 1) |
2796 | { |
2253 | { |
|
|
2254 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2797 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2255 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2798 | scr_add_lines (buf, str - buf, nlines); |
2256 | scr_add_lines (buf, str - buf, nlines); |
2799 | |
2257 | |
2800 | nlines = 0; |
2258 | nlines = 0; |
2801 | str = buf; |
2259 | str = buf; |
2802 | eol = str + min (ncol, UBUFSIZ); |
2260 | eol = str + min (ncol, UBUFSIZ); |
… | |
… | |
2817 | |
2275 | |
2818 | seq_begin = cmdbuf_ptr; |
2276 | seq_begin = cmdbuf_ptr; |
2819 | ch = next_char (); |
2277 | ch = next_char (); |
2820 | } |
2278 | } |
2821 | |
2279 | |
|
|
2280 | if (!(SHOULD_INVOKE (HOOK_ADD_LINES) |
2822 | if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) |
2281 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2823 | scr_add_lines (buf, str - buf, nlines); |
2282 | scr_add_lines (buf, str - buf, nlines); |
2824 | |
2283 | |
2825 | /* |
2284 | /* |
2826 | * If there have been a lot of new lines, then update the screen |
2285 | * If there have been a lot of new lines, then update the screen |
2827 | * What the heck I'll cheat and only refresh less than every page-full. |
2286 | * What the heck we'll cheat and only refresh less than every page-full. |
2828 | * the number of pages between refreshes is refresh_limit, which |
2287 | * if skipScroll is enabled. |
2829 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2830 | */ |
2288 | */ |
2831 | if (refreshnow) |
2289 | if (refreshnow) |
2832 | { |
2290 | { |
2833 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2834 | refresh_limit++; |
|
|
2835 | else |
|
|
2836 | { |
|
|
2837 | flag = true; |
2291 | flag = true; |
2838 | scr_refresh (refresh_type); |
2292 | scr_refresh (); |
2839 | flush_ev.stop (); |
2293 | want_refresh = 1; |
2840 | } |
|
|
2841 | } |
2294 | } |
2842 | |
2295 | |
2843 | } |
2296 | } |
2844 | else |
2297 | else |
2845 | { |
2298 | { |
… | |
… | |
2856 | |
2309 | |
2857 | ch = NOCHAR; |
2310 | ch = NOCHAR; |
2858 | } |
2311 | } |
2859 | } |
2312 | } |
2860 | |
2313 | |
|
|
2314 | refresh_check (); |
|
|
2315 | |
2861 | return flag; |
2316 | return flag; |
2862 | } |
2317 | } |
2863 | |
2318 | |
2864 | // read the next character |
2319 | // read the next character |
2865 | wchar_t |
2320 | wchar_t |
2866 | rxvt_term::next_char () |
2321 | rxvt_term::next_char () NOTHROW |
2867 | { |
2322 | { |
2868 | while (cmdbuf_ptr < cmdbuf_endp) |
2323 | while (cmdbuf_ptr < cmdbuf_endp) |
2869 | { |
2324 | { |
2870 | // assume 7-bit to be ascii ALWAYS |
2325 | // assume 7-bit to be ascii ALWAYS |
2871 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2326 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2892 | return NOCHAR; |
2347 | return NOCHAR; |
2893 | } |
2348 | } |
2894 | |
2349 | |
2895 | // read the next octet |
2350 | // read the next octet |
2896 | uint32_t |
2351 | uint32_t |
2897 | rxvt_term::next_octet () |
2352 | rxvt_term::next_octet () NOTHROW |
2898 | { |
2353 | { |
2899 | return cmdbuf_ptr < cmdbuf_endp |
2354 | return cmdbuf_ptr < cmdbuf_endp |
2900 | ? (unsigned char)*cmdbuf_ptr++ |
2355 | ? (unsigned char)*cmdbuf_ptr++ |
2901 | : NOCHAR; |
2356 | : NOCHAR; |
2902 | } |
2357 | } |
|
|
2358 | |
|
|
2359 | static class out_of_input out_of_input; |
2903 | |
2360 | |
2904 | /* rxvt_cmd_getc () - Return next input character */ |
2361 | /* rxvt_cmd_getc () - Return next input character */ |
2905 | /* |
2362 | /* |
2906 | * Return the next input character after first passing any keyboard input |
2363 | * Return the next input character after first passing any keyboard input |
2907 | * to the command. |
2364 | * to the command. |
2908 | */ |
2365 | */ |
2909 | wchar_t |
2366 | wchar_t |
2910 | rxvt_term::cmd_getc () |
2367 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2911 | { |
2368 | { |
2912 | wchar_t c = next_char (); |
2369 | wchar_t c = next_char (); |
2913 | |
2370 | |
2914 | if (c == NOCHAR) |
2371 | if (c == NOCHAR) |
2915 | throw out_of_input; |
2372 | throw out_of_input; |
2916 | |
2373 | |
2917 | return c; |
2374 | return c; |
2918 | } |
2375 | } |
2919 | |
2376 | |
2920 | uint32_t |
2377 | uint32_t |
2921 | rxvt_term::cmd_get8 () |
2378 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2922 | { |
2379 | { |
2923 | uint32_t c = next_octet (); |
2380 | uint32_t c = next_octet (); |
2924 | |
2381 | |
2925 | if (c == NOCHAR) |
2382 | if (c == NOCHAR) |
2926 | throw out_of_input; |
2383 | throw out_of_input; |
… | |
… | |
2992 | { |
2449 | { |
2993 | if ((buf[len++] = cmd_getc ()) == 'i') |
2450 | if ((buf[len++] = cmd_getc ()) == 'i') |
2994 | break; /* done = 1 */ |
2451 | break; /* done = 1 */ |
2995 | } |
2452 | } |
2996 | } |
2453 | } |
2997 | |
2454 | |
2998 | for (i = 0; i < len; i++) |
2455 | for (i = 0; i < len; i++) |
2999 | if (putc (buf[i], fd) == EOF) |
2456 | if (putc (buf[i], fd) == EOF) |
3000 | { |
2457 | { |
3001 | done = 1; |
2458 | done = 1; |
3002 | break; |
2459 | break; |
… | |
… | |
3004 | } |
2461 | } |
3005 | } |
2462 | } |
3006 | |
2463 | |
3007 | pclose_printer (fd); |
2464 | pclose_printer (fd); |
3008 | } |
2465 | } |
3009 | #endif /* PRINTPIPE */ |
2466 | #endif /* PRINTPIPE */ |
3010 | /*}}} */ |
2467 | /*}}} */ |
3011 | |
2468 | |
3012 | /* *INDENT-OFF* */ |
2469 | /* *INDENT-OFF* */ |
3013 | enum { |
2470 | enum { |
3014 | C1_40 = 0x40, |
2471 | C1_40 = 0x40, |
… | |
… | |
3064 | process_dcs_seq (); |
2521 | process_dcs_seq (); |
3065 | break; |
2522 | break; |
3066 | case 0x9b: /* CSI */ |
2523 | case 0x9b: /* CSI */ |
3067 | process_csi_seq (); |
2524 | process_csi_seq (); |
3068 | break; |
2525 | break; |
3069 | case 0x9d: /* CSI */ |
2526 | case 0x9d: /* OSC */ |
3070 | process_osc_seq (); |
2527 | process_osc_seq (); |
3071 | break; |
2528 | break; |
3072 | #endif |
2529 | #endif |
3073 | } |
2530 | } |
3074 | } |
2531 | } |
… | |
… | |
3164 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
2621 | scr_charset_set (2, (unsigned int)cmd_getc ()); |
3165 | break; |
2622 | break; |
3166 | case '+': |
2623 | case '+': |
3167 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
2624 | scr_charset_set (3, (unsigned int)cmd_getc ()); |
3168 | break; |
2625 | break; |
3169 | #if ENABLE_FRILLS |
2626 | #if !ENABLE_MINIMAL |
3170 | case '6': |
2627 | case '6': |
3171 | scr_backindex (); |
2628 | scr_backindex (); |
3172 | break; |
2629 | break; |
3173 | #endif |
2630 | #endif |
3174 | case '7': |
2631 | case '7': |
3175 | scr_cursor (SAVE); |
2632 | scr_cursor (SAVE); |
3176 | break; |
2633 | break; |
3177 | case '8': |
2634 | case '8': |
3178 | scr_cursor (RESTORE); |
2635 | scr_cursor (RESTORE); |
3179 | break; |
2636 | break; |
3180 | #if ENABLE_FRILLS |
2637 | #if !ENABLE_MINIMAL |
3181 | case '9': |
2638 | case '9': |
3182 | scr_forwardindex (); |
2639 | scr_forwardindex (); |
3183 | break; |
2640 | break; |
3184 | #endif |
2641 | #endif |
3185 | case '=': |
2642 | case '=': |
… | |
… | |
3300 | rxvt_term::process_csi_seq () |
2757 | rxvt_term::process_csi_seq () |
3301 | { |
2758 | { |
3302 | unicode_t ch, priv, i; |
2759 | unicode_t ch, priv, i; |
3303 | unsigned int nargs, p; |
2760 | unsigned int nargs, p; |
3304 | int n, ndef; |
2761 | int n, ndef; |
3305 | int arg[ESC_ARGS]; |
2762 | int arg[ESC_ARGS] = { }; |
3306 | |
2763 | |
3307 | for (nargs = ESC_ARGS; nargs > 0;) |
2764 | nargs = 0; |
3308 | arg[--nargs] = 0; |
|
|
3309 | |
2765 | |
3310 | priv = 0; |
2766 | priv = 0; |
3311 | ch = cmd_getc (); |
2767 | ch = cmd_getc (); |
3312 | if (ch >= '<' && ch <= '?') |
2768 | if (ch >= '<' && ch <= '?') |
|
|
2769 | { |
3313 | { /* '<' '=' '>' '?' */ |
2770 | /* '<' '=' '>' '?' */ |
3314 | priv = ch; |
2771 | priv = ch; |
3315 | ch = cmd_getc (); |
2772 | ch = cmd_getc (); |
3316 | } |
2773 | } |
3317 | |
2774 | |
3318 | /* read any numerical arguments */ |
2775 | /* read any numerical arguments */ |
… | |
… | |
3347 | ndef = get_byte_array_bit (csi_defaults, i); |
2804 | ndef = get_byte_array_bit (csi_defaults, i); |
3348 | for (p = 0; p < nargs; p++) |
2805 | for (p = 0; p < nargs; p++) |
3349 | if (arg[p] == -1) |
2806 | if (arg[p] == -1) |
3350 | arg[p] = ndef; |
2807 | arg[p] = ndef; |
3351 | |
2808 | |
3352 | #ifdef DEBUG_CMD |
|
|
3353 | fprintf (stderr, "CSI "); |
|
|
3354 | for (p = 0; p < nargs; p++) |
|
|
3355 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3356 | fprintf (stderr, "%c\n", ch); |
|
|
3357 | #endif |
|
|
3358 | |
|
|
3359 | /* |
2809 | /* |
3360 | * private mode handling |
2810 | * private mode handling |
3361 | */ |
2811 | */ |
3362 | if (priv) |
2812 | if (priv) |
3363 | { |
2813 | { |
3364 | switch (priv) |
2814 | switch (priv) |
3365 | { |
2815 | { |
3366 | case '>': |
2816 | case '>': |
3367 | if (ch == CSI_DA) /* secondary device attributes */ |
2817 | if (ch == CSI_DA) /* secondary device attributes */ |
3368 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
2818 | { |
|
|
2819 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
|
|
2820 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
|
|
2821 | // |
|
|
2822 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
2823 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later |
|
|
2824 | // versions. |
|
|
2825 | // |
|
|
2826 | tt_printf ("\033[>%d;95;0c", 'U'); |
|
|
2827 | } |
3369 | break; |
2828 | break; |
3370 | case '?': |
2829 | case '?': |
3371 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2830 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3372 | process_terminal_mode (ch, priv, nargs, arg); |
2831 | process_terminal_mode (ch, priv, nargs, arg); |
3373 | break; |
2832 | break; |
… | |
… | |
3499 | break; |
2958 | break; |
3500 | case 6: /* CPR requested */ |
2959 | case 6: /* CPR requested */ |
3501 | scr_report_position (); |
2960 | scr_report_position (); |
3502 | break; |
2961 | break; |
3503 | case 7: /* unofficial extension */ |
2962 | case 7: /* unofficial extension */ |
3504 | if (OPTION (Opt_insecure)) |
2963 | if (option (Opt_insecure)) |
3505 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
2964 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3506 | break; |
2965 | break; |
3507 | case 8: /* unofficial extension */ |
2966 | case 8: /* unofficial extension */ |
3508 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2967 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3509 | break; |
2968 | break; |
… | |
… | |
3576 | break; |
3035 | break; |
3577 | case CSI_75: |
3036 | case CSI_75: |
3578 | scr_cursor (RESTORE); |
3037 | scr_cursor (RESTORE); |
3579 | break; |
3038 | break; |
3580 | |
3039 | |
3581 | #if ENABLE_FRILLS |
3040 | #if !ENABLE_MINIMAL |
3582 | case CSI_74: |
3041 | case CSI_74: |
3583 | process_window_ops (arg, nargs); |
3042 | process_window_ops (arg, nargs); |
3584 | break; |
3043 | break; |
3585 | #endif |
3044 | #endif |
3586 | |
3045 | |
… | |
… | |
3593 | break; |
3052 | break; |
3594 | } |
3053 | } |
3595 | } |
3054 | } |
3596 | /*}}} */ |
3055 | /*}}} */ |
3597 | |
3056 | |
3598 | #if ENABLE_FRILLS |
3057 | #if !ENABLE_MINIMAL |
3599 | /* ARGSUSED */ |
3058 | /* ARGSUSED */ |
3600 | void |
3059 | void |
3601 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3060 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3602 | { |
3061 | { |
3603 | int x, y; |
3062 | int x, y; |
3604 | XWindowAttributes wattr; |
3063 | XWindowAttributes wattr; |
3605 | Window wdummy; |
3064 | Window wdummy; |
3606 | dDisp; |
3065 | |
|
|
3066 | dLocal (Display *, dpy); |
3607 | |
3067 | |
3608 | if (nargs == 0) |
3068 | if (nargs == 0) |
3609 | return; |
3069 | return; |
3610 | |
3070 | |
3611 | switch (args[0]) |
3071 | switch (args[0]) |
3612 | { |
3072 | { |
3613 | /* |
3073 | /* |
3614 | * commands |
3074 | * commands |
3615 | */ |
3075 | */ |
3616 | case 1: /* deiconify window */ |
3076 | case 1: /* deiconify window */ |
3617 | XMapWindow (disp, parent[0]); |
3077 | XMapWindow (dpy, parent[0]); |
3618 | break; |
3078 | break; |
3619 | case 2: /* iconify window */ |
3079 | case 2: /* iconify window */ |
3620 | XIconifyWindow (disp, parent[0], display->screen); |
3080 | XIconifyWindow (dpy, parent[0], display->screen); |
3621 | break; |
3081 | break; |
3622 | case 3: /* set position (pixels) */ |
3082 | case 3: /* set position (pixels) */ |
3623 | XMoveWindow (disp, parent[0], args[1], args[2]); |
3083 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3624 | break; |
3084 | break; |
3625 | case 4: /* set size (pixels) */ |
3085 | case 4: /* set size (pixels) */ |
3626 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3086 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3627 | break; |
3087 | break; |
3628 | case 5: /* raise window */ |
3088 | case 5: /* raise window */ |
3629 | XRaiseWindow (disp, parent[0]); |
3089 | XRaiseWindow (dpy, parent[0]); |
3630 | break; |
3090 | break; |
3631 | case 6: /* lower window */ |
3091 | case 6: /* lower window */ |
3632 | XLowerWindow (disp, parent[0]); |
3092 | XLowerWindow (dpy, parent[0]); |
3633 | break; |
3093 | break; |
3634 | case 7: /* refresh window */ |
3094 | case 7: /* refresh window */ |
3635 | scr_touch (true); |
3095 | scr_touch (true); |
3636 | break; |
3096 | break; |
3637 | case 8: /* set size (chars) */ |
3097 | case 8: /* set size (chars) */ |
… | |
… | |
3644 | if (args[0] >= 24) /* set height (chars) */ |
3104 | if (args[0] >= 24) /* set height (chars) */ |
3645 | set_widthheight ((unsigned int)width, |
3105 | set_widthheight ((unsigned int)width, |
3646 | (unsigned int) (args[1] * fheight)); |
3106 | (unsigned int) (args[1] * fheight)); |
3647 | break; |
3107 | break; |
3648 | |
3108 | |
3649 | |
|
|
3650 | /* |
3109 | /* |
3651 | * reports - some output format copied from XTerm |
3110 | * reports - some output format copied from XTerm |
3652 | */ |
3111 | */ |
3653 | case 11: /* report window state */ |
3112 | case 11: /* report window state */ |
3654 | XGetWindowAttributes (disp, parent[0], &wattr); |
3113 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3655 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3114 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3656 | break; |
3115 | break; |
3657 | case 13: /* report window position */ |
3116 | case 13: /* report window position */ |
3658 | XGetWindowAttributes (disp, parent[0], &wattr); |
3117 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3659 | XTranslateCoordinates (disp, parent[0], wattr.root, |
3118 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3660 | -wattr.border_width, -wattr.border_width, |
3119 | -wattr.border_width, -wattr.border_width, |
3661 | &x, &y, &wdummy); |
3120 | &x, &y, &wdummy); |
3662 | tt_printf ("\033[3;%d;%dt", x, y); |
3121 | tt_printf ("\033[3;%d;%dt", x, y); |
3663 | break; |
3122 | break; |
3664 | case 14: /* report window size (pixels) */ |
3123 | case 14: /* report window size (pixels) */ |
3665 | XGetWindowAttributes (disp, parent[0], &wattr); |
3124 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3666 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3125 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3667 | break; |
3126 | break; |
3668 | case 18: /* report text area size (chars) */ |
3127 | case 18: /* report text area size (chars) */ |
3669 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3128 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3670 | break; |
3129 | break; |
… | |
… | |
3672 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3131 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3673 | break; |
3132 | break; |
3674 | case 20: /* report icon label */ |
3133 | case 20: /* report icon label */ |
3675 | { |
3134 | { |
3676 | char *s; |
3135 | char *s; |
3677 | XGetIconName (disp, parent[0], &s); |
3136 | XGetIconName (dpy, parent[0], &s); |
3678 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3137 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3679 | XFree (s); |
3138 | XFree (s); |
3680 | } |
3139 | } |
3681 | break; |
3140 | break; |
3682 | case 21: /* report window title */ |
3141 | case 21: /* report window title */ |
3683 | { |
3142 | { |
3684 | char *s; |
3143 | char *s; |
3685 | XFetchName (disp, parent[0], &s); |
3144 | XFetchName (dpy, parent[0], &s); |
3686 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3145 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3687 | XFree (s); |
3146 | XFree (s); |
3688 | } |
3147 | } |
3689 | break; |
3148 | break; |
3690 | } |
3149 | } |
3691 | } |
3150 | } |
… | |
… | |
3718 | seen_esc = true; |
3177 | seen_esc = true; |
3719 | continue; |
3178 | continue; |
3720 | } |
3179 | } |
3721 | else if (ch == C0_BEL || ch == CHAR_ST) |
3180 | else if (ch == C0_BEL || ch == CHAR_ST) |
3722 | break; |
3181 | break; |
|
|
3182 | else if (ch == C0_SYN) |
|
|
3183 | ch = cmd_get8 (); |
3723 | else if (ch < 0x20) |
3184 | else if (ch < 0x20) |
3724 | return NULL; /* other control character - exit */ |
3185 | return NULL; /* other control character - exit */ |
3725 | |
3186 | |
3726 | seen_esc = false; |
3187 | seen_esc = false; |
3727 | |
3188 | |
3728 | if (n >= STRING_MAX - 1) |
3189 | if (n >= STRING_MAX - 1) |
3729 | // stop at some sane length |
3190 | // stop at some sane length |
3730 | return NULL; |
3191 | return NULL; |
3731 | |
3192 | |
3732 | if (ch == C0_SYN) |
|
|
3733 | string[n++] = cmd_get8 (); |
|
|
3734 | else |
|
|
3735 | string[n++] = ch; |
3193 | string[n++] = ch; |
3736 | } |
3194 | } |
3737 | |
3195 | |
3738 | string[n++] = '\0'; |
3196 | string[n++] = '\0'; |
3739 | |
3197 | |
3740 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3198 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
… | |
… | |
3791 | void |
3249 | void |
3792 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3250 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3793 | { |
3251 | { |
3794 | if (str[0] == '?' && !str[1]) |
3252 | if (str[0] == '?' && !str[1]) |
3795 | { |
3253 | { |
3796 | unsigned short r, g, b; |
3254 | rgba c; |
3797 | pix_colors_focused[color].get (display, r, g, b); |
3255 | pix_colors_focused[color].get (c); |
|
|
3256 | |
|
|
3257 | #if XFT |
|
|
3258 | if (c.a != rgba::MAX_CC) |
|
|
3259 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
|
|
3260 | else |
|
|
3261 | #endif |
3798 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); |
3262 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3799 | } |
3263 | } |
3800 | else |
3264 | else |
3801 | set_window_color (color, str); |
3265 | set_window_color (color, str); |
3802 | } |
3266 | } |
3803 | |
3267 | |
… | |
… | |
3805 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3269 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3806 | */ |
3270 | */ |
3807 | void |
3271 | void |
3808 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3272 | rxvt_term::process_xterm_seq (int op, const char *str, char resp) |
3809 | { |
3273 | { |
3810 | int changed = 0; |
|
|
3811 | int color; |
3274 | int color; |
3812 | char *buf, *name; |
3275 | char *buf, *name; |
3813 | bool query = str[0] == '?' && !str[1]; |
3276 | bool query = str[0] == '?' && !str[1]; |
3814 | int saveop = op; |
3277 | int saveop = op; |
3815 | dDisp; |
3278 | |
|
|
3279 | dLocal (Display *, dpy); |
3816 | |
3280 | |
3817 | assert (str != NULL); |
3281 | assert (str != NULL); |
|
|
3282 | |
|
|
3283 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3284 | return; |
|
|
3285 | |
3818 | switch (op) |
3286 | switch (op) |
3819 | { |
3287 | { |
3820 | case XTerm_name: |
3288 | case XTerm_name: |
3821 | set_title (str); |
3289 | set_title (str); |
3822 | /* FALLTHROUGH */ |
3290 | /* FALLTHROUGH */ |
… | |
… | |
3836 | unsigned long bytes_after; |
3304 | unsigned long bytes_after; |
3837 | unsigned char *value = 0; |
3305 | unsigned char *value = 0; |
3838 | const char *str = ""; |
3306 | const char *str = ""; |
3839 | |
3307 | |
3840 | if (prop |
3308 | if (prop |
3841 | && XGetWindowProperty (disp, parent[0], |
3309 | && XGetWindowProperty (dpy, parent[0], |
3842 | prop, 0, 1<<16, 0, AnyPropertyType, |
3310 | prop, 0, 1<<16, 0, AnyPropertyType, |
3843 | &actual_type, &actual_format, |
3311 | &actual_type, &actual_format, |
3844 | &nitems, &bytes_after, &value) == Success |
3312 | &nitems, &bytes_after, &value) == Success |
3845 | && actual_type != None |
3313 | && actual_type != None |
3846 | && actual_format == 8) |
3314 | && actual_format == 8) |
3847 | str = (const char *)(value); |
3315 | str = (const char *)(value); |
3848 | |
3316 | |
3849 | tt_printf ("\033]%d;%s%c", XTerm_property, str, resp); |
3317 | tt_printf ("\033]%d;%s%c", op, str, resp); |
3850 | |
3318 | |
3851 | XFree (value); |
3319 | XFree (value); |
3852 | } |
3320 | } |
3853 | else |
3321 | else |
3854 | { |
3322 | { |
… | |
… | |
3858 | { |
3326 | { |
3859 | *eq = 0; |
3327 | *eq = 0; |
3860 | set_utf8_property (display->atom (str), eq + 1); |
3328 | set_utf8_property (display->atom (str), eq + 1); |
3861 | } |
3329 | } |
3862 | else |
3330 | else |
3863 | XDeleteProperty (disp, parent[0], |
3331 | XDeleteProperty (dpy, parent[0], |
3864 | display->atom (str)); |
3332 | display->atom (str)); |
3865 | } |
3333 | } |
3866 | break; |
3334 | break; |
3867 | |
3335 | |
3868 | case XTerm_Color: |
3336 | case XTerm_Color: |
… | |
… | |
3870 | { |
3338 | { |
3871 | if ((name = strchr (buf, ';')) == NULL) |
3339 | if ((name = strchr (buf, ';')) == NULL) |
3872 | break; |
3340 | break; |
3873 | |
3341 | |
3874 | *name++ = '\0'; |
3342 | *name++ = '\0'; |
3875 | color = atoi (buf); |
3343 | color = atoi (buf) + minCOLOR; |
3876 | |
3344 | |
3877 | if (color < 0 || color >= TOTAL_COLORS) |
3345 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3878 | break; |
3346 | break; |
3879 | |
3347 | |
3880 | if ((buf = strchr (name, ';')) != NULL) |
3348 | if ((buf = strchr (name, ';')) != NULL) |
3881 | *buf++ = '\0'; |
3349 | *buf++ = '\0'; |
3882 | |
3350 | |
3883 | if (name[0] == '?' && !name[1]) |
3351 | process_color_seq (op, color, name, resp); |
3884 | { |
|
|
3885 | unsigned short r, g, b; |
|
|
3886 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
|
|
3887 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
|
|
3888 | } |
|
|
3889 | else |
|
|
3890 | set_window_color (color + minCOLOR, name); |
|
|
3891 | } |
3352 | } |
3892 | break; |
3353 | break; |
3893 | case XTerm_Color00: |
3354 | case XTerm_Color00: |
3894 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3355 | process_color_seq (op, Color_fg, str, resp); |
3895 | break; |
3356 | break; |
3896 | case XTerm_Color01: |
3357 | case XTerm_Color01: |
3897 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3358 | process_color_seq (op, Color_bg, str, resp); |
3898 | break; |
3359 | break; |
3899 | #ifndef NO_CURSORCOLOR |
3360 | #ifndef NO_CURSORCOLOR |
3900 | case XTerm_Color_cursor: |
3361 | case XTerm_Color_cursor: |
3901 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3362 | process_color_seq (op, Color_cursor, str, resp); |
3902 | break; |
3363 | break; |
3903 | #endif |
3364 | #endif |
3904 | case XTerm_Color_pointer_fg: |
3365 | case XTerm_Color_pointer_fg: |
3905 | process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp); |
3366 | process_color_seq (op, Color_pointer_fg, str, resp); |
3906 | break; |
3367 | break; |
3907 | case XTerm_Color_pointer_bg: |
3368 | case XTerm_Color_pointer_bg: |
3908 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3369 | process_color_seq (op, Color_pointer_bg, str, resp); |
3909 | break; |
3370 | break; |
3910 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3371 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3911 | case XTerm_Color_BD: |
|
|
3912 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3913 | break; |
|
|
3914 | case XTerm_Color_UL: |
|
|
3915 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3916 | break; |
|
|
3917 | case XTerm_Color_RV: |
3372 | case XTerm_Color_RV: |
3918 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3373 | process_color_seq (op, Color_RV, str, resp); |
|
|
3374 | break; |
|
|
3375 | case Rxvt_Color_BD: |
|
|
3376 | case URxvt_Color_BD: |
|
|
3377 | process_color_seq (op, Color_BD, str, resp); |
|
|
3378 | break; |
|
|
3379 | case Rxvt_Color_UL: |
|
|
3380 | case URxvt_Color_UL: |
|
|
3381 | process_color_seq (op, Color_UL, str, resp); |
3919 | break; |
3382 | break; |
3920 | case URxvt_Color_IT: |
3383 | case URxvt_Color_IT: |
3921 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3384 | process_color_seq (op, Color_IT, str, resp); |
3922 | break; |
3385 | break; |
3923 | #endif |
3386 | #endif |
3924 | #if TRANSPARENT && TINTING |
3387 | #if ENABLE_TRANSPARENCY |
3925 | case URxvt_Color_tint: |
3388 | case URxvt_Color_tint: |
3926 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3389 | process_color_seq (op, Color_tint, str, resp); |
3927 | check_our_parents (); |
3390 | { |
3928 | if (am_transparent) |
3391 | bool changed = false; |
3929 | want_full_refresh = want_refresh = 1; |
3392 | if (ISSET_PIXCOLOR (Color_tint)) |
3930 | break; |
3393 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
3931 | #endif |
3394 | else |
|
|
3395 | changed = bgPixmap.unset_tint (); |
|
|
3396 | if (changed) |
|
|
3397 | update_background (); |
|
|
3398 | } |
3932 | |
3399 | |
|
|
3400 | break; |
|
|
3401 | #endif |
|
|
3402 | |
|
|
3403 | #if BG_IMAGE_FROM_FILE |
3933 | case XTerm_Pixmap: |
3404 | case Rxvt_Pixmap: |
3934 | if (*str != ';') |
3405 | if (!strcmp (str, "?")) |
3935 | { |
3406 | { |
3936 | #if XPM_BACKGROUND |
3407 | char str[256]; |
3937 | scale_pixmap (""); /* reset to default scaling */ |
3408 | |
3938 | set_bgPixmap (str); /* change pixmap */ |
3409 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
3939 | #endif |
3410 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
3940 | scr_touch (true); |
3411 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
|
|
3412 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3941 | } |
3413 | } |
3942 | while ((str = strchr (str, ';')) != NULL) |
3414 | else |
3943 | { |
3415 | { |
|
|
3416 | int changed = 0; |
|
|
3417 | |
|
|
3418 | if (*str != ';') |
|
|
3419 | { |
|
|
3420 | /* reset to default scaling :*/ |
|
|
3421 | bgPixmap.unset_geometry (); |
|
|
3422 | if (bgPixmap.set_file (str)) /* change pixmap */ |
|
|
3423 | changed++; |
|
|
3424 | str = strchr (str, ';'); |
|
|
3425 | if (str == NULL) |
|
|
3426 | bgPixmap.set_defaultGeometry (); |
|
|
3427 | } |
|
|
3428 | while (str) |
|
|
3429 | { |
3944 | str++; |
3430 | str++; |
3945 | #if XPM_BACKGROUND |
3431 | if (bgPixmap.set_geometry (str)) |
3946 | changed += scale_pixmap (str); |
3432 | changed++; |
3947 | #endif |
3433 | str = strchr (str, ';'); |
|
|
3434 | } |
|
|
3435 | if (changed) |
|
|
3436 | update_background (); |
3948 | } |
3437 | } |
3949 | |
|
|
3950 | if (changed) |
|
|
3951 | { |
|
|
3952 | #ifdef XPM_BACKGROUND |
|
|
3953 | resize_pixmap (); |
|
|
3954 | #endif |
|
|
3955 | scr_touch (true); |
|
|
3956 | } |
|
|
3957 | break; |
3438 | break; |
|
|
3439 | #endif |
3958 | |
3440 | |
3959 | case XTerm_restoreFG: |
3441 | case Rxvt_restoreFG: |
3960 | set_window_color (Color_fg, str); |
3442 | set_window_color (Color_fg, str); |
3961 | break; |
3443 | break; |
3962 | case XTerm_restoreBG: |
3444 | case Rxvt_restoreBG: |
3963 | set_window_color (Color_bg, str); |
3445 | set_window_color (Color_bg, str); |
3964 | break; |
3446 | break; |
3965 | |
3447 | |
3966 | case XTerm_logfile: |
3448 | case XTerm_logfile: |
3967 | // TODO, when secure mode? |
3449 | // TODO, when secure mode? |
3968 | break; |
3450 | break; |
3969 | |
3451 | |
3970 | #ifdef MENUBAR |
|
|
3971 | case URxvt_Menu: |
|
|
3972 | if (OPTION (Opt_insecure)) |
|
|
3973 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3974 | break; |
|
|
3975 | #endif |
|
|
3976 | #if 0 |
3452 | #if 0 |
3977 | case XTerm_dumpscreen: /* no error notices */ |
3453 | case Rxvt_dumpscreen: /* no error notices */ |
3978 | { |
3454 | { |
3979 | int fd; |
3455 | int fd; |
3980 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3456 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3981 | { |
3457 | { |
3982 | scr_dump (fd); |
3458 | scr_dump (fd); |
… | |
… | |
3993 | case URxvt_italicFont: |
3469 | case URxvt_italicFont: |
3994 | case URxvt_boldItalicFont: |
3470 | case URxvt_boldItalicFont: |
3995 | #endif |
3471 | #endif |
3996 | if (query) |
3472 | if (query) |
3997 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3473 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3998 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3474 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3999 | ? fontset[op - URxvt_font]->fontdesc : "", |
3475 | ? fontset[op - URxvt_font]->fontdesc : "", |
4000 | resp); |
3476 | resp); |
4001 | else |
3477 | else |
4002 | { |
3478 | { |
4003 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3479 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
4006 | allocated.push_back ((void *)res); |
3482 | allocated.push_back ((void *)res); |
4007 | set_fonts (); |
3483 | set_fonts (); |
4008 | } |
3484 | } |
4009 | break; |
3485 | break; |
4010 | |
3486 | |
4011 | #if ENABLE_FRILLS |
3487 | case URxvt_version: |
|
|
3488 | if (query) |
|
|
3489 | tt_printf ("\33]%d;rxvt-unicode;%-.20s;%c;%c%c", |
|
|
3490 | op, |
|
|
3491 | rs[Rs_name], VERSION[0], VERSION[2], |
|
|
3492 | resp); |
|
|
3493 | break; |
|
|
3494 | |
|
|
3495 | #if !ENABLE_MINIMAL |
4012 | case URxvt_locale: |
3496 | case URxvt_locale: |
4013 | if (query) |
3497 | if (query) |
4014 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); |
3498 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
4015 | else |
3499 | else |
4016 | { |
3500 | { |
4017 | set_locale (str); |
3501 | set_locale (str); |
4018 | pty.set_utf8_mode (enc_utf8); |
3502 | pty->set_utf8_mode (enc_utf8); |
4019 | init_xlocale (); |
3503 | init_xlocale (); |
4020 | } |
3504 | } |
4021 | break; |
3505 | break; |
4022 | |
3506 | |
4023 | case URxvt_view_up: |
3507 | case URxvt_view_up: |
… | |
… | |
4034 | break; |
3518 | break; |
4035 | #endif |
3519 | #endif |
4036 | |
3520 | |
4037 | #if ENABLE_PERL |
3521 | #if ENABLE_PERL |
4038 | case URxvt_perl: |
3522 | case URxvt_perl: |
4039 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3523 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
4040 | ; // no responses yet |
3524 | ; // no responses yet |
4041 | break; |
3525 | break; |
4042 | #endif |
3526 | #endif |
4043 | } |
3527 | } |
4044 | } |
3528 | } |
… | |
… | |
4076 | return state; |
3560 | return state; |
4077 | } |
3561 | } |
4078 | |
3562 | |
4079 | /* we're not using priv _yet_ */ |
3563 | /* we're not using priv _yet_ */ |
4080 | void |
3564 | void |
4081 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
3565 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4082 | { |
3566 | { |
4083 | unsigned int i, j; |
3567 | unsigned int i, j; |
4084 | int state; |
3568 | int state; |
4085 | |
3569 | |
4086 | static const struct |
3570 | static const struct |
4087 | { |
3571 | { |
4088 | const int argval; |
3572 | const int argval; |
4089 | const unsigned long bit; |
3573 | const unsigned long bit; |
4090 | } |
|
|
4091 | |
|
|
4092 | argtopriv[] = { |
3574 | } argtopriv[] = { |
4093 | { 1, PrivMode_aplCUR }, |
3575 | { 1, PrivMode_aplCUR }, |
4094 | { 2, PrivMode_vt52 }, |
3576 | { 2, PrivMode_vt52 }, |
4095 | { 3, PrivMode_132 }, |
3577 | { 3, PrivMode_132 }, |
4096 | { 4, PrivMode_smoothScroll }, |
3578 | { 4, PrivMode_smoothScroll }, |
4097 | { 5, PrivMode_rVideo }, |
3579 | { 5, PrivMode_rVideo }, |
4098 | { 6, PrivMode_relOrigin }, |
3580 | { 6, PrivMode_relOrigin }, |
4099 | { 7, PrivMode_Autowrap }, |
3581 | { 7, PrivMode_Autowrap }, |
4100 | // 8, bi-directional support mode |
3582 | // 8, bi-directional support mode |
4101 | { 9, PrivMode_MouseX10 }, |
3583 | { 9, PrivMode_MouseX10 }, |
4102 | #ifdef menuBar_esc |
|
|
4103 | { menuBar_esc, PrivMode_menuBar }, |
|
|
4104 | #endif |
|
|
4105 | // 18, 19 printing-related |
3584 | // 18, 19 printing-related |
4106 | { 25, PrivMode_VisibleCursor }, |
3585 | { 25, PrivMode_VisibleCursor }, |
4107 | #ifdef scrollBar_esc |
3586 | #ifdef scrollBar_esc |
4108 | { scrollBar_esc, PrivMode_scrollBar }, |
3587 | { scrollBar_esc, PrivMode_scrollBar }, |
4109 | #endif |
3588 | #endif |
… | |
… | |
4116 | { 66, PrivMode_aplKP }, |
3595 | { 66, PrivMode_aplKP }, |
4117 | #ifndef NO_BACKSPACE_KEY |
3596 | #ifndef NO_BACKSPACE_KEY |
4118 | { 67, PrivMode_BackSpace }, |
3597 | { 67, PrivMode_BackSpace }, |
4119 | #endif |
3598 | #endif |
4120 | { 1000, PrivMode_MouseX11 }, |
3599 | { 1000, PrivMode_MouseX11 }, |
4121 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
3600 | { 1002, PrivMode_MouseBtnEvent }, |
4122 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
3601 | { 1003, PrivMode_MouseAnyEvent }, |
4123 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
|
|
4124 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3602 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
4125 | { 1011, PrivMode_Keypress }, // rxvt extension |
3603 | { 1011, PrivMode_Keypress }, // rxvt extension |
4126 | // 1035 enable modifiers for alt, numlock NYI |
3604 | // 1035 enable modifiers for alt, numlock NYI |
4127 | // 1036 send ESC for meta keys NYI |
3605 | // 1036 send ESC for meta keys NYI |
4128 | // 1037 send DEL for keypad delete NYI |
3606 | // 1037 send DEL for keypad delete NYI |
… | |
… | |
4163 | scr_touch (true); |
3641 | scr_touch (true); |
4164 | break; |
3642 | break; |
4165 | #endif |
3643 | #endif |
4166 | case 1048: /* alternative cursor save */ |
3644 | case 1048: /* alternative cursor save */ |
4167 | case 1049: |
3645 | case 1049: |
4168 | if (OPTION (Opt_secondaryScreen)) |
3646 | if (option (Opt_secondaryScreen)) |
4169 | if (mode == 0) |
3647 | if (mode == 0) |
4170 | scr_cursor (RESTORE); |
3648 | scr_cursor (RESTORE); |
4171 | else if (mode == 1) |
3649 | else if (mode == 1) |
4172 | scr_cursor (SAVE); |
3650 | scr_cursor (SAVE); |
4173 | break; |
3651 | break; |
… | |
… | |
4202 | scr_autowrap (state); |
3680 | scr_autowrap (state); |
4203 | break; |
3681 | break; |
4204 | /* case 8: - auto repeat, can't do on a per window basis */ |
3682 | /* case 8: - auto repeat, can't do on a per window basis */ |
4205 | case 9: /* X10 mouse reporting */ |
3683 | case 9: /* X10 mouse reporting */ |
4206 | if (state) /* orthogonal */ |
3684 | if (state) /* orthogonal */ |
4207 | priv_modes &= ~PrivMode_MouseX11; |
3685 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4208 | break; |
3686 | break; |
4209 | #ifdef menuBar_esc |
|
|
4210 | case menuBar_esc: |
|
|
4211 | #ifdef MENUBAR |
|
|
4212 | map_menuBar (state); |
|
|
4213 | #endif |
|
|
4214 | break; |
|
|
4215 | #endif |
|
|
4216 | #ifdef scrollBar_esc |
3687 | #ifdef scrollBar_esc |
4217 | case scrollBar_esc: |
3688 | case scrollBar_esc: |
4218 | if (scrollbar_mapping (state)) |
3689 | if (scrollbar_mapping (state)) |
4219 | { |
3690 | { |
4220 | resize_all_windows (0, 0, 0); |
3691 | resize_all_windows (0, 0, 0); |
… | |
… | |
4232 | break; |
3703 | break; |
4233 | /* case 66: - application key pad */ |
3704 | /* case 66: - application key pad */ |
4234 | /* case 67: - backspace key */ |
3705 | /* case 67: - backspace key */ |
4235 | case 1000: /* X11 mouse reporting */ |
3706 | case 1000: /* X11 mouse reporting */ |
4236 | if (state) /* orthogonal */ |
3707 | if (state) /* orthogonal */ |
4237 | priv_modes &= ~PrivMode_MouseX10; |
3708 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4238 | break; |
3709 | break; |
4239 | #if 0 |
|
|
4240 | case 1001: |
3710 | case 1002: |
4241 | break; /* X11 mouse highlighting */ |
3711 | case 1003: |
4242 | #endif |
3712 | if (state) |
|
|
3713 | { |
|
|
3714 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
|
|
3715 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3716 | vt_emask_mouse = PointerMotionMask; |
|
|
3717 | } |
|
|
3718 | else |
|
|
3719 | vt_emask_mouse = NoEventMask; |
|
|
3720 | vt_select_input (); |
|
|
3721 | break; |
4243 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3722 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4244 | set_option (Opt_scrollTtyOutput, !state); |
3723 | set_option (Opt_scrollTtyOutput, !state); |
4245 | break; |
3724 | break; |
4246 | case 1011: /* scroll to bottom on key press */ |
3725 | case 1011: /* scroll to bottom on key press */ |
4247 | set_option (Opt_scrollTtyKeypress, state); |
3726 | set_option (Opt_scrollTtyKeypress, state); |
4248 | break; |
3727 | break; |
4249 | case 1047: /* secondary screen w/ clearing last */ |
3728 | case 1047: /* secondary screen w/ clearing last */ |
4250 | if (OPTION (Opt_secondaryScreen)) |
3729 | if (option (Opt_secondaryScreen)) |
4251 | if (current_screen != PRIMARY) |
3730 | if (current_screen != PRIMARY) |
4252 | scr_erase_screen (2); |
3731 | scr_erase_screen (2); |
4253 | scr_change_screen (state); |
3732 | scr_change_screen (state); |
4254 | break; |
3733 | break; |
4255 | case 1049: /* secondary screen w/ clearing first */ |
3734 | case 1049: /* secondary screen w/ clearing first */ |
4256 | scr_change_screen (state); |
3735 | scr_change_screen (state); |
4257 | if (OPTION (Opt_secondaryScreen)) |
3736 | if (option (Opt_secondaryScreen)) |
4258 | if (current_screen != PRIMARY) |
3737 | if (current_screen != PRIMARY) |
4259 | scr_erase_screen (2); |
3738 | scr_erase_screen (2); |
4260 | break; |
3739 | break; |
4261 | default: |
3740 | default: |
4262 | break; |
3741 | break; |
… | |
… | |
4390 | scr_color (Color_bg, Color_bg); |
3869 | scr_color (Color_bg, Color_bg); |
4391 | break; |
3870 | break; |
4392 | |
3871 | |
4393 | //case 50: // not variable spacing |
3872 | //case 50: // not variable spacing |
4394 | |
3873 | |
4395 | #if ENABLE_FRILLS |
3874 | #if !ENABLE_MINIMAL |
4396 | case 90: |
3875 | case 90: |
4397 | case 91: /* set bright fg color */ |
3876 | case 91: /* set bright fg color */ |
4398 | case 92: |
3877 | case 92: |
4399 | case 93: |
3878 | case 93: |
4400 | case 94: |
3879 | case 94: |
… | |
… | |
4424 | rxvt_term::process_graphics () |
3903 | rxvt_term::process_graphics () |
4425 | { |
3904 | { |
4426 | unicode_t ch, cmd = cmd_getc (); |
3905 | unicode_t ch, cmd = cmd_getc (); |
4427 | |
3906 | |
4428 | if (cmd == 'Q') |
3907 | if (cmd == 'Q') |
|
|
3908 | { |
4429 | { /* query graphics */ |
3909 | /* query graphics */ |
4430 | tt_printf ("\033G0\012"); /* no graphics */ |
3910 | tt_printf ("\033G0\012"); /* no graphics */ |
4431 | return; |
3911 | return; |
4432 | } |
3912 | } |
4433 | /* swallow other graphics sequences until terminating ':' */ |
3913 | /* swallow other graphics sequences until terminating ':' */ |
4434 | do |
3914 | do |
… | |
… | |
4465 | rxvt_term::tt_write (const char *data, unsigned int len) |
3945 | rxvt_term::tt_write (const char *data, unsigned int len) |
4466 | { |
3946 | { |
4467 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
3947 | if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) |
4468 | return; |
3948 | return; |
4469 | |
3949 | |
4470 | if (pty.pty < 0) |
3950 | if (pty->pty < 0) |
4471 | return; |
3951 | return; |
4472 | |
3952 | |
4473 | if (v_buflen == 0) |
3953 | if (v_buflen == 0) |
4474 | { |
3954 | { |
4475 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
3955 | ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); |
4476 | |
3956 | |
4477 | if ((unsigned int)written == len) |
3957 | if ((unsigned int)written == len) |
4478 | return; |
3958 | return; |
4479 | |
3959 | |
4480 | data += written; |
3960 | data += written; |
… | |
… | |
4484 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
3964 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4485 | |
3965 | |
4486 | memcpy (v_buffer + v_buflen, data, len); |
3966 | memcpy (v_buffer + v_buflen, data, len); |
4487 | v_buflen += len; |
3967 | v_buflen += len; |
4488 | |
3968 | |
4489 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
3969 | pty_ev.set (ev::READ | ev::WRITE); |
4490 | } |
3970 | } |
4491 | |
3971 | |
4492 | void rxvt_term::pty_write () |
3972 | void rxvt_term::pty_write () |
4493 | { |
3973 | { |
4494 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
3974 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
4495 | |
3975 | |
4496 | if (written > 0) |
3976 | if (written > 0) |
4497 | { |
3977 | { |
4498 | v_buflen -= written; |
3978 | v_buflen -= written; |
4499 | |
3979 | |
4500 | if (v_buflen == 0) |
3980 | if (v_buflen == 0) |
4501 | { |
3981 | { |
4502 | free (v_buffer); |
3982 | free (v_buffer); |
4503 | v_buffer = 0; |
3983 | v_buffer = 0; |
4504 | v_buflen = 0; |
|
|
4505 | |
3984 | |
4506 | pty_ev.set (EVENT_READ); |
3985 | pty_ev.set (ev::READ); |
4507 | return; |
3986 | return; |
4508 | } |
3987 | } |
4509 | |
3988 | |
4510 | memmove (v_buffer, v_buffer + written, v_buflen); |
3989 | memmove (v_buffer, v_buffer + written, v_buflen); |
4511 | } |
3990 | } |
4512 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
3991 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4513 | pty_ev.set (EVENT_READ); |
3992 | pty_ev.set (ev::READ); |
4514 | } |
3993 | } |
4515 | |
3994 | |
4516 | /*----------------------- end-of-file (C source) -----------------------*/ |
3995 | /*----------------------- end-of-file (C source) -----------------------*/ |
4517 | |
3996 | |