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

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.299 by root, Tue Jan 31 19:11:43 2006 UTC vs.
Revision 1.427 by root, Wed Nov 5 15:44:04 2008 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*----------------------------------------------------------------------*
2 * File: command.C 2 * File: command.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
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 * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it>
31 * 32 *
32 * This program is free software; you can redistribute it and/or modify 33 * 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 34 * 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 35 * the Free Software Foundation; either version 2 of the License, or
35 * (at your option) any later version. 36 * (at your option) any later version.
49#include "rxvt.h" 50#include "rxvt.h"
50#include "rxvtperl.h" 51#include "rxvtperl.h"
51#include "version.h" 52#include "version.h"
52#include "command.h" 53#include "command.h"
53 54
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 55#ifdef KEYSYM_RESOURCE
60# include "keyboard.h" 56# include "keyboard.h"
61#endif 57#endif
62 58
63#include <csignal> 59#include <csignal>
60
61#if LINUX_YIELD_HACK
62# include <ctime>
63#endif
64 64
65/*----------------------------------------------------------------------*/ 65/*----------------------------------------------------------------------*/
66 66
67#define IS_CONTROL(ch) !((ch) & 0xffffff60UL) 67#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
68 68
96 XK_Shift_L, 0x21e7, 96 XK_Shift_L, 0x21e7,
97 XK_Shift_R, 0x21e7, 97 XK_Shift_R, 0x21e7,
98 98
99 XK_Shift_Lock, 0x21eb, 99 XK_Shift_Lock, 0x21eb,
100 XK_ISO_Lock, 0x21eb, 100 XK_ISO_Lock, 0x21eb,
101 XK_ISO_Lock, 0x21eb,
102 XK_Caps_Lock, 0x21ec, 101 XK_Caps_Lock, 0x21ec,
103 XK_Num_Lock, 0x21ed, 102 XK_Num_Lock, 0x21ed,
104 XK_ISO_Level3_Shift, 0x21ee, 103 XK_ISO_Level3_Shift, 0x21ee,
105 XK_ISO_Level3_Lock, 0x21ef, 104 XK_ISO_Level3_Lock, 0x21ef,
106 XK_ISO_Group_Lock, 0x21f0, 105 XK_ISO_Group_Lock, 0x21f0,
200 r & RS_Uline ? " uline" : "", 199 r & RS_Uline ? " uline" : "",
201 r & RS_Careful ? " careful" : ""); 200 r & RS_Careful ? " careful" : "");
202 201
203 int width = wcswidth (fname, wcslen (fname)); 202 int width = wcswidth (fname, wcslen (fname));
204 203
205 max_it (width, 8+5); // for char + hey 204 max_it (width, 8+5); // for char + hex
206 max_it (width, strlen (attr)); 205 max_it (width, strlen (attr));
207 206
208 if (y >= 0) 207 if (y >= 0)
209 { 208 {
210 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; 209 y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1;
222 ch = *chr++; 221 ch = *chr++;
223 222
224 sprintf (buf, "%8x", ch); 223 sprintf (buf, "%8x", ch);
225 scr_overlay_set (0, y, buf); 224 scr_overlay_set (0, y, buf);
226 scr_overlay_set (9, y, '='); 225 scr_overlay_set (9, y, '=');
227# if !UNICODE3 226# if !UNICODE_3
228 if (ch >= 0x10000) 227 if (ch >= 0x10000)
229 ch = 0xfffd; 228 ch = 0xfffd;
230# endif 229# endif
231 scr_overlay_set (11, y, ch, r); 230 scr_overlay_set (11, y, ch, r);
232 231
280 } 279 }
281 280
282 iso14755buf = 0; 281 iso14755buf = 0;
283} 282}
284 283
285int 284static int
286rxvt_term::hex_keyval (XKeyEvent &ev) 285hex_keyval (XKeyEvent &ev)
287{ 286{
288 // check wether this event corresponds to a hex digit 287 // check wether this event corresponds to a hex digit
289 // if the modifiers had not been pressed. 288 // if the modifiers had not been pressed.
290 for (int index = 0; index < 8; index++) 289 for (int index = 0; index < 8; index++)
291 { 290 {
299 298
300 return -1; 299 return -1;
301} 300}
302#endif 301#endif
303 302
304/*{{{ Convert the keypress event into a string */ 303static inline KeySym
304translate_keypad (KeySym keysym, bool kp)
305{
306#ifdef XK_KP_Home
307 static const KeySym keypadtrans[] = {
308 XK_KP_7, // XK_KP_Home
309 XK_KP_4, // XK_KP_Left
310 XK_KP_8, // XK_KP_Up
311 XK_KP_6, // XK_KP_Right
312 XK_KP_2, // XK_KP_Down
313# ifndef UNSHIFTED_SCROLLKEYS
314 XK_KP_9, // XK_KP_Prior
315 XK_KP_3, // XK_KP_Next
316# else
317 XK_Prior,
318 XK_Next,
319# endif
320 XK_KP_1, // XK_KP_End
321 XK_KP_5, // XK_KP_Begin
322 };
323
324 if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin))
325 {
326 unsigned int index = keysym - XK_KP_Home;
327 keysym = kp ? keypadtrans[index] : XK_Home + index;
328 }
329 else if (keysym == XK_KP_Insert)
330 keysym = kp ? XK_KP_0 : XK_Insert;
331# ifndef NO_DELETE_KEY
332 else if (keysym == XK_KP_Delete)
333 keysym = kp ? XK_KP_Decimal : XK_Delete;
334# endif
335#endif
336 return keysym;
337}
338
339static inline int
340map_function_key (KeySym keysym)
341{
342 int param = 0;
343
344 if (IN_RANGE_INC (keysym, XK_F1, XK_F35))
345 {
346 param = 11 + keysym - XK_F1;
347 if (keysym >= XK_F17)
348 param += 4;
349 else if (keysym >= XK_F15)
350 param += 3;
351 else if (keysym >= XK_F11)
352 param += 2;
353 else if (keysym >= XK_F6)
354 param += 1;
355 }
356 else
357 switch (keysym)
358 {
359 case XK_Find:
360 param = 1;
361 break;
362 case XK_Insert:
363 param = 2;
364 break;
365#ifdef DXK_Remove
366 case DXK_Remove:
367#endif
368 case XK_Execute:
369 param = 3;
370 break;
371 case XK_Select:
372 param = 4;
373 break;
374#ifndef UNSHIFTED_SCROLLKEYS
375 case XK_Prior:
376 param = 5;
377 break;
378 case XK_Next:
379 param = 6;
380 break;
381 case XK_Home:
382 param = 7;
383 break;
384 case XK_End:
385 param = 8;
386 break;
387#endif
388 case XK_Help:
389 param = 28;
390 break;
391 case XK_Menu:
392 param = 29;
393 break;
394 }
395 return param;
396}
397
305void 398void
306rxvt_term::lookup_key (XKeyEvent &ev) 399rxvt_term::key_press (XKeyEvent &ev)
307{ 400{
308 int ctrl, meta, shft, len; 401 int ctrl, meta, shft, len;
309 unsigned int newlen;
310 KeySym keysym; 402 KeySym keysym;
311 int valid_keysym; 403 int valid_keysym;
312 char kbuf[KBUFSZ]; 404 char kbuf[KBUFSZ];
405
406#if ISO_14755
407 if (iso14755buf & ISO_14755_52)
408 return;
409#endif
313 410
314 /* 411 /*
315 * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an 412 * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an
316 * escape sequence to toggle the Keypad. 413 * escape sequence to toggle the Keypad.
317 * 414 *
322 meta = ev.state & ModMetaMask; 419 meta = ev.state & ModMetaMask;
323 420
324 if (numlock_state || (ev.state & ModNumLockMask)) 421 if (numlock_state || (ev.state & ModNumLockMask))
325 { 422 {
326 numlock_state = (ev.state & ModNumLockMask); 423 numlock_state = (ev.state & ModNumLockMask);
327 PrivMode ((!numlock_state), PrivMode_aplKP); 424 set_privmode (PrivMode_aplKP, !numlock_state);
328 } 425 }
329 426
330 kbuf[0] = 0; 427 kbuf[0] = 0;
331 428
332#ifdef USE_XIM 429#ifdef USE_XIM
497# if ISO_14755 594# if ISO_14755
498 iso14755_51 (0); 595 iso14755_51 (0);
499# endif 596# endif
500 return; 597 return;
501 } 598 }
599 else if (keysym == XK_BackSpace)
600 {
601 iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51;
602# if ISO_14755
603 iso14755_51 (iso14755buf & ISO_14755_MASK);
604# endif
605 return;
606 }
502 else if ((hv = hex_keyval (ev)) >= 0) 607 else if ((hv = hex_keyval (ev)) >= 0)
503 { 608 {
504 iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) 609 iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK)
505 | hv | ISO_14755_51; 610 | hv | ISO_14755_51;
506# if ISO_14755 611# if ISO_14755
508# endif 613# endif
509 return; 614 return;
510 } 615 }
511 else 616 else
512 { 617 {
513# if ENABLE_OVERLAY 618# if ISO_14755
514 scr_overlay_off (); 619 scr_overlay_off ();
515# endif 620# endif
516 iso14755buf = 0; 621 iso14755buf = 0;
517 } 622 }
518 } 623 }
519 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) 624 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
520 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) 625 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))
521 if (!(iso14755buf & ISO_14755_STARTED)) 626 if (!(iso14755buf & ISO_14755_STARTED))
522 { 627 {
523 iso14755buf |= ISO_14755_STARTED; 628 iso14755buf |= ISO_14755_STARTED;
524# if ENABLE_OVERLAY 629# if ISO_14755
525 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); 630 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1);
526 scr_overlay_set (0, 0, "ISO 14755 mode"); 631 scr_overlay_set (0, 0, "ISO 14755 mode");
527# endif 632# endif
528 } 633 }
529#endif 634#endif
530 635
531#ifdef PRINTPIPE 636#ifdef PRINTPIPE
532 if (keysym == XK_Print) 637 if (keysym == XK_Print)
533 { 638 {
534 scr_printscreen (ctrl | shft); 639 scr_printscreen (ctrl | shft);
535 return; 640 return;
536 } 641 }
537#endif 642#endif
538 643
539 if (keysym >= 0xFF00 && keysym <= 0xFFFF) 644 if (keysym >= 0xFF00 && keysym <= 0xFFFF)
540 { 645 {
646 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft;
647 unsigned int newlen = 1;
648
649 switch (translate_keypad (keysym, kp))
541 { 650 {
651#ifndef NO_BACKSPACE_KEY
652 case XK_BackSpace:
653 if (priv_modes & PrivMode_HaveBackSpace)
654 {
655 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace)
656 ^ !!ctrl) ? '\b' : '\177';
657 kbuf[1] = '\0';
658 }
659 else
660 strcpy (kbuf, rs[Rs_backspace_key]);
661 break;
662#endif
663#ifndef NO_DELETE_KEY
664 case XK_Delete:
665 strcpy (kbuf, rs[Rs_delete_key]);
666 break;
667#endif
668 case XK_Tab:
669 if (shft)
670 strcpy (kbuf, "\033[Z");
671 else
672 {
673#ifdef CTRL_TAB_MAKES_META
674 if (ctrl)
675 meta = 1;
676#endif
677#ifdef MOD4_TAB_MAKES_META
678 if (ev.state & Mod4Mask)
679 meta = 1;
680#endif
542 newlen = 1; 681 newlen = 0;
543 switch (keysym) 682 }
683 break;
684
685 case XK_Up: /* "\033[A" */
686 case XK_Down: /* "\033[B" */
687 case XK_Right: /* "\033[C" */
688 case XK_Left: /* "\033[D" */
689 strcpy (kbuf, "\033[Z");
690 kbuf[2] = "DACB"[keysym - XK_Left];
691 /* do Shift first */
692 if (shft)
693 kbuf[2] = "dacb"[keysym - XK_Left];
694 else if (ctrl)
695 {
696 kbuf[1] = 'O';
697 kbuf[2] = "dacb"[keysym - XK_Left];
698 }
699 else if (priv_modes & PrivMode_aplCUR)
700 kbuf[1] = 'O';
701 break;
702
703 case XK_KP_Enter:
704 /* allow shift to override */
705 if (kp)
706 {
707 strcpy (kbuf, "\033OM");
708 break;
709 }
710
711 /* FALLTHROUGH */
712
713 case XK_Return:
714 if (priv_modes & PrivMode_LFNL)
715 {
716 kbuf[0] = '\015';
717 kbuf[1] = '\012';
718 kbuf[2] = '\0';
719 }
720 else
721 {
722 kbuf[0] = '\015';
723 kbuf[1] = '\0';
724 }
725 break;
726
727 case XK_KP_F1: /* "\033OP" */
728 case XK_KP_F2: /* "\033OQ" */
729 case XK_KP_F3: /* "\033OR" */
730 case XK_KP_F4: /* "\033OS" */
731 strcpy (kbuf, "\033OP");
732 kbuf[2] += (keysym - XK_KP_F1);
733 break;
734
735 case XK_KP_Multiply: /* "\033Oj" : "*" */
736 case XK_KP_Add: /* "\033Ok" : "+" */
737 case XK_KP_Separator: /* "\033Ol" : "," */
738 case XK_KP_Subtract: /* "\033Om" : "-" */
739 case XK_KP_Decimal: /* "\033On" : "." */
740 case XK_KP_Divide: /* "\033Oo" : "/" */
741 case XK_KP_0: /* "\033Op" : "0" */
742 case XK_KP_1: /* "\033Oq" : "1" */
743 case XK_KP_2: /* "\033Or" : "2" */
744 case XK_KP_3: /* "\033Os" : "3" */
745 case XK_KP_4: /* "\033Ot" : "4" */
746 case XK_KP_5: /* "\033Ou" : "5" */
747 case XK_KP_6: /* "\033Ov" : "6" */
748 case XK_KP_7: /* "\033Ow" : "7" */
749 case XK_KP_8: /* "\033Ox" : "8" */
750 case XK_KP_9: /* "\033Oy" : "9" */
751 /* allow shift to override */
752 if (kp)
753 {
754 strcpy (kbuf, "\033Oj");
755 kbuf[2] += (keysym - XK_KP_Multiply);
756 }
757 else
758 {
759 kbuf[0] = ('*' + (keysym - XK_KP_Multiply));
760 kbuf[1] = '\0';
761 }
762 break;
763
764 default:
544 { 765 {
545#ifndef NO_BACKSPACE_KEY 766 int param = map_function_key (keysym);
546 case XK_BackSpace: 767 if (param > 0)
547 if (priv_modes & PrivMode_HaveBackSpace) 768 sprintf (kbuf,"\033[%d~", param);
548 {
549 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace)
550 ^ !!ctrl) ? '\b' : '\177';
551 kbuf[1] = '\0';
552 }
553 else 769 else
554 strcpy (kbuf, key_backspace);
555 break;
556#endif
557#ifndef NO_DELETE_KEY
558# ifdef XK_KP_Prior
559 case XK_KP_Delete:
560 /* allow shift to override */
561 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
562 {
563 strcpy (kbuf, "\033On");
564 break;
565 }
566 /* FALLTHROUGH */
567# endif
568 case XK_Delete:
569 strcpy (kbuf, key_delete);
570 break;
571#endif
572 case XK_Tab:
573 if (shft)
574 strcpy (kbuf, "\033[Z");
575 else
576 {
577#ifdef CTRL_TAB_MAKES_META
578 if (ctrl)
579 meta = 1;
580#endif
581#ifdef MOD4_TAB_MAKES_META
582 if (ev.state & Mod4Mask)
583 meta = 1;
584#endif
585 newlen = 0;
586 }
587 break;
588
589#ifdef XK_KP_Left
590 case XK_KP_Up: /* \033Ox or standard */
591 case XK_KP_Down: /* \033Or or standard */
592 case XK_KP_Right: /* \033Ov or standard */
593 case XK_KP_Left: /* \033Ot or standard */
594 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
595 {
596 strcpy (kbuf, "\033OZ");
597 kbuf[2] = "txvr"[keysym - XK_KP_Left];
598 break;
599 }
600 else
601 /* translate to std. cursor key */
602 keysym = XK_Left + (keysym - XK_KP_Left);
603 /* FALLTHROUGH */
604#endif
605 case XK_Up: /* "\033[A" */
606 case XK_Down: /* "\033[B" */
607 case XK_Right: /* "\033[C" */
608 case XK_Left: /* "\033[D" */
609 strcpy (kbuf, "\033[Z");
610 kbuf[2] = "DACB"[keysym - XK_Left];
611 /* do Shift first */
612 if (shft)
613 kbuf[2] = "dacb"[keysym - XK_Left];
614 else if (ctrl)
615 {
616 kbuf[1] = 'O';
617 kbuf[2] = "dacb"[keysym - XK_Left];
618 }
619 else if (priv_modes & PrivMode_aplCUR)
620 kbuf[1] = 'O';
621 break;
622
623#ifndef UNSHIFTED_SCROLLKEYS
624# ifdef XK_KP_Prior
625 case XK_KP_Prior:
626 /* allow shift to override */
627 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
628 {
629 strcpy (kbuf, "\033Oy");
630 break;
631 }
632 /* FALLTHROUGH */
633# endif
634 case XK_Prior:
635 strcpy (kbuf, "\033[5~");
636 break;
637# ifdef XK_KP_Next
638 case XK_KP_Next:
639 /* allow shift to override */
640 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
641 {
642 strcpy (kbuf, "\033Os");
643 break;
644 }
645 /* FALLTHROUGH */
646# endif
647 case XK_Next:
648 strcpy (kbuf, "\033[6~");
649 break;
650#endif
651 case XK_KP_Enter:
652 /* allow shift to override */
653 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
654 {
655 strcpy (kbuf, "\033OM");
656 break;
657 }
658
659 /* FALLTHROUGH */
660
661 case XK_Return:
662 if (priv_modes & PrivMode_LFNL)
663 {
664 kbuf[0] = '\015';
665 kbuf[1] = '\012';
666 kbuf[2] = '\0';
667 }
668 else
669 {
670 kbuf[0] = '\015';
671 kbuf[1] = '\0';
672 }
673 break;
674
675#ifdef XK_KP_Begin
676 case XK_KP_Begin:
677 strcpy (kbuf, "\033Ou");
678 break;
679
680#endif
681 case XK_KP_F1: /* "\033OP" */
682 case XK_KP_F2: /* "\033OQ" */
683 case XK_KP_F3: /* "\033OR" */
684 case XK_KP_F4: /* "\033OS" */
685 strcpy (kbuf, "\033OP");
686 kbuf[2] += (keysym - XK_KP_F1);
687 break;
688
689 case XK_KP_Multiply: /* "\033Oj" : "*" */
690 case XK_KP_Add: /* "\033Ok" : "+" */
691 case XK_KP_Separator: /* "\033Ol" : "," */
692 case XK_KP_Subtract: /* "\033Om" : "-" */
693 case XK_KP_Decimal: /* "\033On" : "." */
694 case XK_KP_Divide: /* "\033Oo" : "/" */
695 case XK_KP_0: /* "\033Op" : "0" */
696 case XK_KP_1: /* "\033Oq" : "1" */
697 case XK_KP_2: /* "\033Or" : "2" */
698 case XK_KP_3: /* "\033Os" : "3" */
699 case XK_KP_4: /* "\033Ot" : "4" */
700 case XK_KP_5: /* "\033Ou" : "5" */
701 case XK_KP_6: /* "\033Ov" : "6" */
702 case XK_KP_7: /* "\033Ow" : "7" */
703 case XK_KP_8: /* "\033Ox" : "8" */
704 case XK_KP_9: /* "\033Oy" : "9" */
705 /* allow shift to override */
706 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
707 {
708 strcpy (kbuf, "\033Oj");
709 kbuf[2] += (keysym - XK_KP_Multiply);
710 }
711 else
712 {
713 kbuf[0] = ('*' + (keysym - XK_KP_Multiply));
714 kbuf[1] = '\0';
715 }
716 break;
717
718 case XK_Find:
719 strcpy (kbuf, "\033[1~");
720 break;
721
722#ifdef XK_KP_End
723 case XK_KP_Insert:
724 /* allow shift to override */
725 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
726 {
727 strcpy (kbuf, "\033Op");
728 break;
729 }
730 /* FALLTHROUGH */
731#endif
732 case XK_Insert:
733 strcpy (kbuf, "\033[2~");
734 break;
735#ifdef DXK_Remove /* support for DEC remove like key */
736 case DXK_Remove:
737 /* FALLTHROUGH */
738#endif
739 case XK_Execute:
740 strcpy (kbuf, "\033[3~");
741 break;
742 case XK_Select:
743 strcpy (kbuf, "\033[4~");
744 break;
745#ifdef XK_KP_End
746 case XK_KP_End:
747 /* allow shift to override */
748 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
749 {
750 strcpy (kbuf, "\033Oq");
751 break;
752 }
753 /* FALLTHROUGH */
754#endif
755 case XK_End:
756 strcpy (kbuf, KS_END);
757 break;
758#ifdef XK_KP_Home
759 case XK_KP_Home:
760 /* allow shift to override */
761 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
762 {
763 strcpy (kbuf, "\033Ow");
764 break;
765 }
766 /* FALLTHROUGH */
767#endif
768 case XK_Home:
769 strcpy (kbuf, KS_HOME);
770 break;
771
772#define FKEY(n, fkey) \
773 sprintf ((char *)kbuf,"\033[%2d~", (int) ((n) + (keysym - fkey)))
774
775 case XK_F1: /* "\033[11~" */
776 case XK_F2: /* "\033[12~" */
777 case XK_F3: /* "\033[13~" */
778 case XK_F4: /* "\033[14~" */
779 case XK_F5: /* "\033[15~" */
780 FKEY (11, XK_F1);
781 break;
782 case XK_F6: /* "\033[17~" */
783 case XK_F7: /* "\033[18~" */
784 case XK_F8: /* "\033[19~" */
785 case XK_F9: /* "\033[20~" */
786 case XK_F10: /* "\033[21~" */
787 FKEY (17, XK_F6);
788 break;
789 case XK_F11: /* "\033[23~" */
790 case XK_F12: /* "\033[24~" */
791 case XK_F13: /* "\033[25~" */
792 case XK_F14: /* "\033[26~" */
793 FKEY (23, XK_F11);
794 break;
795 case XK_F15: /* "\033[28~" */
796 case XK_F16: /* "\033[29~" */
797 FKEY (28, XK_F15);
798 break;
799 case XK_Help: /* "\033[28~" */
800 FKEY (28, XK_Help);
801 break;
802 case XK_Menu: /* "\033[29~" */
803 FKEY (29, XK_Menu);
804 break;
805 case XK_F17: /* "\033[31~" */
806 case XK_F18: /* "\033[32~" */
807 case XK_F19: /* "\033[33~" */
808 case XK_F20: /* "\033[34~" */
809 case XK_F21: /* "\033[35~" */
810 case XK_F22: /* "\033[36~" */
811 case XK_F23: /* "\033[37~" */
812 case XK_F24: /* "\033[38~" */
813 case XK_F25: /* "\033[39~" */
814 case XK_F26: /* "\033[40~" */
815 case XK_F27: /* "\033[41~" */
816 case XK_F28: /* "\033[42~" */
817 case XK_F29: /* "\033[43~" */
818 case XK_F30: /* "\033[44~" */
819 case XK_F31: /* "\033[45~" */
820 case XK_F32: /* "\033[46~" */
821 case XK_F33: /* "\033[47~" */
822 case XK_F34: /* "\033[48~" */
823 case XK_F35: /* "\033[49~" */
824 FKEY (31, XK_F17);
825 break;
826#undef FKEY
827 default:
828 newlen = 0; 770 newlen = 0;
829 break;
830 } 771 }
831 772 break;
832 if (newlen)
833 len = strlen (kbuf);
834 } 773 }
774
775 if (newlen)
776 len = strlen (kbuf);
835 777
836 /* 778 /*
837 * Pass meta for all function keys, if 'meta' option set 779 * Pass meta for all function keys, if 'meta' option set
838 */ 780 */
839#ifdef META8_OPTION 781#ifdef META8_OPTION
874 return; 816 return;
875 817
876 if (len <= 0) 818 if (len <= 0)
877 return; /* not mapped */ 819 return; /* not mapped */
878 820
879 if (OPTION (Opt_scrollTtyKeypress)) 821 if (option (Opt_scrollTtyKeypress))
880 if (view_start) 822 if (view_start)
881 { 823 {
882 view_start = 0; 824 view_start = 0;
883 want_refresh = 1; 825 want_refresh = 1;
884 } 826 }
908 tt_write (&ch, 1); 850 tt_write (&ch, 1);
909 } 851 }
910 852
911 tt_write (kbuf, (unsigned int)len); 853 tt_write (kbuf, (unsigned int)len);
912} 854}
913/*}}} */ 855
856void
857rxvt_term::key_release (XKeyEvent &ev)
858{
859#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
860 KeySym keysym;
861
862 keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
863#endif
864
865#if ENABLE_FRILLS || ISO_14755
866 // ISO 14755 support
867 if (iso14755buf)
868 if (iso14755buf & ISO_14755_52)
869 {
870# if ISO_14755
871 scr_overlay_off ();
872# endif
873# if ISO_14755
874 // iso14755 part 5.2 handling: release time
875 // first: controls
876 if ((ev.state & ControlMask)
877 && ((keysym >= 0x40 && keysym <= 0x5f)
878 || (keysym >= 0x61 && keysym <= 0x7f)))
879 {
880 iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f);
881 commit_iso14755 ();
882
883 return;
884 }
885
886 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
887 if (i[0] == keysym)
888 {
889 iso14755buf = ISO_14755_51 | i[1];
890 commit_iso14755 ();
891
892 return;
893 }
894
895 scr_bell ();
896# endif
897 iso14755buf = 0;
898
899 return;
900 }
901 else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask))
902 {
903# if ISO_14755
904 scr_overlay_off ();
905# endif
906 if (iso14755buf & ISO_14755_51)
907 commit_iso14755 ();
908#if ISO_14755
909 else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED)
910 {
911 iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair
912
913 scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1);
914 scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE");
915 }
916# endif
917 else
918 iso14755buf = 0;
919 }
920#endif
921
922 if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END)))
923 return;
924
925#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
926 if (!(ev.state & ControlMask))
927 slip_wheel_ev.stop ();
928 else if (keysym == XK_Control_L || keysym == XK_Control_R)
929 mouse_slip_wheel_speed = 0;
930#endif
931}
914 932
915#if defined (KEYSYM_RESOURCE) 933#if defined (KEYSYM_RESOURCE)
916unsigned int 934unsigned int
917rxvt_term::cmd_write (const char *str, unsigned int count) 935rxvt_term::cmd_write (const char *str, unsigned int count)
918{ 936{
948void 966void
949rxvt_term::flush () 967rxvt_term::flush ()
950{ 968{
951 flush_ev.stop (); 969 flush_ev.stop ();
952 970
953#ifdef TRANSPARENT 971#ifdef HAVE_BG_PIXMAP
954 if (want_full_refresh) 972 if (bgPixmap.check_clearChanged ())
955 { 973 {
956 want_full_refresh = 0; 974// scr_clear (true); This needs to be researched further!
957 scr_clear ();
958 scr_touch (false); 975 scr_touch (false);
959 } 976 }
960#endif 977#endif
961 978
962 if (want_refresh) 979 if (want_refresh)
998 } 1015 }
999 while (row < end_row); 1016 while (row < end_row);
1000 } 1017 }
1001 1018
1002 scr_refresh (); 1019 scr_refresh ();
1003 scrollbar_show (1); 1020 scrollBar.show (1);
1004#ifdef USE_XIM 1021#ifdef USE_XIM
1005 IMSendSpot (); 1022 IMSendSpot ();
1006#endif 1023#endif
1007 } 1024 }
1008 1025
1009 display->flush (); 1026 display->flush ();
1010} 1027}
1011 1028
1029/* checks wether a refresh is requested and starts the refresh timer */
1012void 1030void
1013rxvt_term::check_cb (check_watcher &w) 1031rxvt_term::refresh_check ()
1032{
1033 if (want_refresh && !flush_ev.is_active ())
1034 flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally
1035
1036 display->flush ();
1037}
1038
1039void
1040rxvt_term::flush_cb (ev::timer &w, int revents)
1014{ 1041{
1015 make_current (); 1042 make_current ();
1016 1043
1017 display->flush ();
1018
1019 if (want_refresh && !flush_ev.active)
1020 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally
1021}
1022
1023void
1024rxvt_term::flush_cb (time_watcher &w)
1025{
1026 make_current ();
1027
1028 refresh_limit = 1;
1029 refresh_count = 0; 1044 refresh_count = 0;
1030 flush (); 1045 flush ();
1031} 1046}
1032 1047
1033#ifdef CURSOR_BLINK 1048#ifdef CURSOR_BLINK
1034void 1049void
1035rxvt_term::cursor_blink_cb (time_watcher &w) 1050rxvt_term::cursor_blink_cb (ev::timer &w, int revents)
1036{ 1051{
1037 hidden_cursor = !hidden_cursor; 1052 hidden_cursor = !hidden_cursor;
1038 want_refresh = 1; 1053 want_refresh = 1;
1039 1054 refresh_check ();
1040 w.start (w.at + CURSOR_BLINK_INTERVAL);
1041} 1055}
1042#endif 1056#endif
1043 1057
1044#ifdef TEXT_BLINK 1058#ifdef TEXT_BLINK
1045void 1059void
1046rxvt_term::text_blink_cb (time_watcher &w) 1060rxvt_term::text_blink_cb (ev::timer &w, int revents)
1047{ 1061{
1048 if (scr_refresh_rend (RS_Blink, RS_Blink)) 1062 if (scr_refresh_rend (RS_Blink, RS_Blink))
1049 { 1063 {
1050 hidden_text = !hidden_text; 1064 hidden_text = !hidden_text;
1051 want_refresh = 1; 1065 want_refresh = 1;
1052 w.start (w.at + TEXT_BLINK_INTERVAL); 1066 refresh_check ();
1053 } 1067 }
1068 else
1069 w.stop ();
1054} 1070}
1055#endif 1071#endif
1056 1072
1057#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1073#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1058void 1074void
1059rxvt_term::cont_scroll_cb (time_watcher &w) 1075rxvt_term::cont_scroll_cb (ev::timer &w, int revents)
1060{ 1076{
1061 if ((scrollbar_isUp() || scrollbar_isDn()) && 1077 if ((scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN)
1062 scr_page (scrollbar_isUp() ? UP : DN, 1)) 1078 && scr_page (scrollBar.state == STATE_UP ? UP : DN, 1))
1063 { 1079 {
1064 want_refresh = 1; 1080 want_refresh = 1;
1065 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1081 refresh_check ();
1066 } 1082 }
1083 else
1084 w.stop ();
1067} 1085}
1068#endif 1086#endif
1069 1087
1070#ifdef SELECTION_SCROLLING 1088#ifdef SELECTION_SCROLLING
1071void 1089void
1072rxvt_term::sel_scroll_cb (time_watcher &w) 1090rxvt_term::sel_scroll_cb (ev::timer &w, int revents)
1073{ 1091{
1074 if (scr_page (scroll_selection_dir, scroll_selection_lines)) 1092 if (scr_page (scroll_selection_dir, scroll_selection_lines))
1075 { 1093 {
1076 selection_extend (selection_save_x, selection_save_y, selection_save_state); 1094 selection_extend (selection_save_x, selection_save_y, selection_save_state);
1077 want_refresh = 1; 1095 want_refresh = 1;
1078 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1096 refresh_check ();
1079 } 1097 }
1098 else
1099 w.stop ();
1080} 1100}
1081#endif 1101#endif
1082 1102
1083#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1103#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1084void 1104void
1085rxvt_term::slip_wheel_cb (time_watcher &w) 1105rxvt_term::slip_wheel_cb (ev::timer &w, int revents)
1086{ 1106{
1087 if (mouse_slip_wheel_speed == 0 1107 if (scr_changeview (view_start - mouse_slip_wheel_speed))
1088 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
1089 : scr_page (UP, mouse_slip_wheel_speed))
1090 { 1108 {
1091 if (view_start == top_row || view_start == 0)
1092 mouse_slip_wheel_speed = 0;
1093
1094 want_refresh = 1; 1109 want_refresh = 1;
1095 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1110 refresh_check ();
1111 }
1112
1113 if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0)
1096 } 1114 {
1115 mouse_slip_wheel_speed = 0;
1116 w.stop ();
1117 }
1097} 1118}
1098#endif 1119#endif
1099 1120
1100#if HAVE_SCHED_YIELD 1121#if LINUX_YIELD_HACK
1101static struct event_handler 1122static struct event_handler
1102{ 1123{
1103 check_watcher cw_yield; 1124 ev::prepare yield_ev;
1104 1125
1105 void yield (check_watcher &w) 1126 void yield_cb (ev::prepare &w, int revents)
1106 { 1127 {
1107 sched_yield (); 1128 // this should really be sched_yield(), but the linux guys thought
1129 // that giving a process calling sched_yield () less cpu time than
1130 // ones with high nice levels is a useful thing to do. It surely is is
1131 // allowed by the sus... as is returning ENOSYS.
1132 // since the linux guys additionally thought that breaking the only
1133 // known workaroudn against their unusable sched_yield hack is cool,
1134 // we just nanosleep a bit and hope for the best.
1135
1136 struct timespec ts = { 0, 1000 };
1137 nanosleep (&ts, 0);
1138
1108 w.stop (); 1139 w.stop ();
1109 } 1140 }
1110 1141
1111 event_handler () 1142 event_handler ()
1112 : cw_yield (this, &event_handler::yield) 1143 : yield_ev (this, &event_handler::yield_cb)
1113 { 1144 {
1114 } 1145 }
1115} event_handler; 1146} event_handler;
1116#endif 1147#endif
1117 1148
1137 cmdbuf_endp += r; 1168 cmdbuf_endp += r;
1138 return true; 1169 return true;
1139 } 1170 }
1140 else if (r < 0 && (errno == EAGAIN || errno == EINTR)) 1171 else if (r < 0 && (errno == EAGAIN || errno == EINTR))
1141 { 1172 {
1142#if HAVE_SCHED_YIELD 1173#if LINUX_YIELD_HACK
1143 if (display->is_local) 1174 if (display->is_local)
1144 event_handler.cw_yield.start (); 1175 event_handler.yield_ev.start ();
1145#endif 1176#endif
1146 } 1177 }
1147 else 1178 else
1148 { 1179 {
1149 pty_ev.stop (); 1180 pty_ev.stop ();
1150 1181
1151 if (!OPTION (Opt_hold)) 1182 if (!option (Opt_hold))
1152 destroy (); 1183 destroy ();
1153 } 1184 }
1154 1185
1155 return false; 1186 return false;
1156} 1187}
1157 1188
1158void 1189void
1159rxvt_term::pty_cb (io_watcher &w, short revents) 1190rxvt_term::pty_cb (ev::io &w, int revents)
1160{ 1191{
1161 make_current (); 1192 make_current ();
1162 1193
1163 if (revents & EVENT_READ) 1194 if (revents & ev::READ)
1164 // loop, but don't allow a single term to monopolize us 1195 // loop, but don't allow a single term to monopolize us
1165 while (pty_fill ()) 1196 for (int i = CBUFCNT; i-- && pty_fill (); )
1166 if (cmd_parse ()) 1197 cmd_parse ();
1167 break;
1168 1198
1169 if (revents & EVENT_WRITE) 1199 if (revents & ev::WRITE)
1170 pty_write (); 1200 pty_write ();
1201
1202 refresh_check ();
1171} 1203}
1172 1204
1173void 1205void
1174rxvt_term::pointer_unblank () 1206rxvt_term::pointer_unblank ()
1175{ 1207{
1176 XDefineCursor (xdisp, vt, TermWin_cursor); 1208 XDefineCursor (dpy, vt, TermWin_cursor);
1177 recolour_cursor (); 1209 recolour_cursor ();
1178 1210
1179#ifdef POINTER_BLANK 1211#ifdef POINTER_BLANK
1180 hidden_pointer = 0; 1212 hidden_pointer = 0;
1181 1213
1182 if (OPTION (Opt_pointerBlank)) 1214 if (option (Opt_pointerBlank))
1183 pointer_ev.start (NOW + pointerBlankDelay); 1215 pointer_ev.start (pointerBlankDelay);
1184#endif 1216#endif
1185} 1217}
1186 1218
1187#ifdef POINTER_BLANK 1219#ifdef POINTER_BLANK
1188void 1220void
1189rxvt_term::pointer_blank () 1221rxvt_term::pointer_blank ()
1190{ 1222{
1191 if (!OPTION (Opt_pointerBlank)) 1223 if (!option (Opt_pointerBlank))
1192 return; 1224 return;
1193 1225
1194 XDefineCursor (xdisp, vt, display->blank_cursor); 1226 XDefineCursor (dpy, vt, display->blank_cursor);
1195 XFlush (xdisp); 1227 XFlush (dpy);
1196 1228
1197 hidden_pointer = 1; 1229 hidden_pointer = 1;
1198} 1230}
1199 1231
1200void 1232void
1201rxvt_term::pointer_cb (time_watcher &w) 1233rxvt_term::pointer_cb (ev::timer &w, int revents)
1202{ 1234{
1203 make_current (); 1235 make_current ();
1204 1236
1205 pointer_blank (); 1237 pointer_blank ();
1206} 1238}
1209void 1241void
1210rxvt_term::mouse_report (XButtonEvent &ev) 1242rxvt_term::mouse_report (XButtonEvent &ev)
1211{ 1243{
1212 int button_number, key_state = 0; 1244 int button_number, key_state = 0;
1213 int x, y; 1245 int x, y;
1246 int code = 32;
1214 1247
1215 x = ev.x; 1248 x = Pixel2Col (ev.x);
1216 y = ev.y; 1249 y = Pixel2Row (ev.y);
1217 pixel_position (&x, &y); 1250 if (ev.type == MotionNotify)
1251 {
1252 if (x == mouse_row && y == mouse_col)
1253 return;
1254 mouse_row = x;
1255 mouse_col = y;
1256 code += 32;
1257 }
1218 1258
1219 if (MEvent.button == AnyButton) 1259 if (MEvent.button == AnyButton)
1220 button_number = 3; 1260 button_number = 3;
1221 else 1261 else
1222 { 1262 {
1268 x + 1, 1308 x + 1,
1269 y + 1); 1309 y + 1);
1270#endif 1310#endif
1271 1311
1272 tt_printf ("\033[M%c%c%c", 1312 tt_printf ("\033[M%c%c%c",
1273 (32 + button_number + key_state), 1313 (code + button_number + key_state),
1274 (32 + x + 1), 1314 (32 + x + 1),
1275 (32 + y + 1)); 1315 (32 + y + 1));
1276} 1316}
1277 1317
1278/*{{{ process an X event */ 1318/*{{{ process an X event */
1279void 1319void
1280rxvt_term::x_cb (XEvent &ev) 1320rxvt_term::x_cb (XEvent &ev)
1281{ 1321{
1282 make_current (); 1322 make_current ();
1283 1323
1284 dLocal (Display *, xdisp); 1324 dLocal (Display *, dpy);
1285 1325
1286 if (ev.xany.window == vt 1326 if (ev.xany.window == vt
1287 && SHOULD_INVOKE (HOOK_X_EVENT) 1327 && SHOULD_INVOKE (HOOK_X_EVENT)
1288 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) 1328 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END)))
1289 return; 1329 return;
1294 unsigned int unused_mask; 1334 unsigned int unused_mask;
1295 1335
1296 switch (ev.type) 1336 switch (ev.type)
1297 { 1337 {
1298 case KeyPress: 1338 case KeyPress:
1299#if ISO_14755 1339 key_press (ev.xkey);
1300 if (!(iso14755buf & ISO_14755_52))
1301#endif
1302 lookup_key (ev.xkey);
1303
1304 break; 1340 break;
1305 1341
1306 case KeyRelease: 1342 case KeyRelease:
1307 { 1343 key_release (ev.xkey);
1308#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL
1309 KeySym keysym;
1310
1311 keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1312#endif
1313
1314#if ENABLE_FRILLS || ISO_14755
1315 // ISO 14755 support
1316 if (iso14755buf)
1317 if (iso14755buf & ISO_14755_52)
1318 {
1319# if ENABLE_OVERLAY
1320 scr_overlay_off ();
1321# endif
1322# if ISO_14755
1323 // iso14755 part 5.2 handling: release time
1324 // first: controls
1325 if ((ev.xkey.state & ControlMask)
1326 && ((keysym >= 0x40 && keysym <= 0x5f)
1327 || (keysym >= 0x61 && keysym <= 0x7f)))
1328 {
1329 iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f);
1330 commit_iso14755 ();
1331 goto skip_switch;
1332 }
1333
1334 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1335 if (i[0] == keysym)
1336 {
1337 iso14755buf = ISO_14755_51 | i[1];
1338 commit_iso14755 ();
1339 goto skip_switch;
1340 }
1341
1342 scr_bell ();
1343# endif
1344 iso14755buf = 0;
1345 break;
1346 }
1347 else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask))
1348 {
1349# if ENABLE_OVERLAY
1350 scr_overlay_off ();
1351# endif
1352 if (iso14755buf & ISO_14755_51)
1353 commit_iso14755 ();
1354#if ISO_14755
1355 else if (iso14755buf & ISO_14755_STARTED)
1356 {
1357 iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair
1358
1359 scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1);
1360 scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE");
1361 }
1362# endif
1363 else
1364 iso14755buf = 0;
1365 }
1366#endif
1367
1368 if (ev.xany.window == vt
1369 && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END)))
1370 break;
1371
1372#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1373 if (!(ev.xkey.state & ControlMask))
1374 slip_wheel_ev.stop ();
1375 else if (keysym == XK_Control_L || keysym == XK_Control_R)
1376 mouse_slip_wheel_speed = 0;
1377#endif
1378 break; 1344 break;
1379 }
1380 1345
1381 case ButtonPress: 1346 case ButtonPress:
1382 button_press (ev.xbutton); 1347 button_press (ev.xbutton);
1383 break; 1348 break;
1384 1349
1399 if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) 1364 if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END)))
1400 destroy (); 1365 destroy ();
1401 } 1366 }
1402#if ENABLE_EWMH 1367#if ENABLE_EWMH
1403 else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) 1368 else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING])
1404 XSendEvent (xdisp, ev.xclient.window = display->root, 1369 XSendEvent (dpy, ev.xclient.window = display->root,
1405 False, SubstructureRedirectMask | SubstructureNotifyMask, 1370 False, SubstructureRedirectMask | SubstructureNotifyMask,
1406 &ev); 1371 &ev);
1407#endif 1372#endif
1408 } 1373 }
1409 } 1374 }
1415 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) 1380 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1416 focus_out (); 1381 focus_out ();
1417 } 1382 }
1418#endif 1383#endif
1419 } 1384 }
1420 break;
1421
1422 case MappingNotify:
1423 XRefreshKeyboardMapping (&ev.xmapping);
1424 break; 1385 break;
1425 1386
1426 /* 1387 /*
1427 * XXX: this is not the _current_ arrangement 1388 * XXX: this is not the _current_ arrangement
1428 * Here's my conclusion: 1389 * Here's my conclusion:
1447 break; 1408 break;
1448 } 1409 }
1449 break; 1410 break;
1450 1411
1451 case FocusIn: 1412 case FocusIn:
1413 if (ev.xfocus.detail != NotifyInferior
1414 && ev.xfocus.detail != NotifyPointer
1415 && ev.xfocus.mode != NotifyGrab)
1452 focus_in (); 1416 focus_in ();
1453 break; 1417 break;
1454 1418
1455 case FocusOut: 1419 case FocusOut:
1420 if (ev.xfocus.detail != NotifyInferior
1421 && ev.xfocus.detail != NotifyPointer
1422 && ev.xfocus.mode != NotifyGrab)
1456 focus_out (); 1423 focus_out ();
1457 break; 1424 break;
1458 1425
1459 case ConfigureNotify: 1426 case ConfigureNotify:
1427 /*fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n",
1428 ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y,
1429 szHint.width, szHint.height);*/
1460 if (ev.xconfigure.window == parent[0]) 1430 if (ev.xconfigure.window == parent[0])
1461 { 1431 {
1462 while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) 1432 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1463 ; 1433 ;
1464 1434
1465 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1435 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1466 { 1436 {
1467 seen_resize = 1; 1437 seen_resize = 1;
1468 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1438 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1469 } 1439 }
1440 else
1441 {
1442#ifdef HAVE_BG_PIXMAP
1443 if (bgPixmap.window_position_sensitive ())
1444 {
1445 if (mapped)
1446 update_background ();
1447 else
1448 bgPixmap.invalidate ();
1449 }
1450#endif
1451 }
1470 1452
1471 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1453 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1472
1473#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1474 if (OPTION (Opt_transparent))
1475 check_our_parents ();
1476#endif
1477 } 1454 }
1478 break; 1455 break;
1479 1456
1480 case PropertyNotify: 1457 case PropertyNotify:
1481 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) 1458 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END)))
1497 case SelectionRequest: 1474 case SelectionRequest:
1498 selection_send (ev.xselectionrequest); 1475 selection_send (ev.xselectionrequest);
1499 break; 1476 break;
1500 1477
1501 case MapNotify: 1478 case MapNotify:
1479#ifdef HAVE_BG_PIXMAP
1480 /* This is needed spcifically to fix the case of no window manager or a
1481 * non-reparenting window manager. In those cases we never get first
1482 * ConfigureNotify. Also that speeds startup under normal WM, by taking
1483 * care of multiplicity of ConfigureNotify events arriwing while WM does
1484 * reparenting.
1485 * We should not render background immidiately, as there could be several
1486 * ConfigureNotify's to follow. Lets take care of all of them in one scoop
1487 * by scheduling background redraw as soon as we can, but giving a short
1488 * bit of time for ConfigureNotifies to arrive.
1489 * We should render background PRIOR to drawing any text, but AFTER all
1490 * of ConfigureNotifys for the best results.
1491 */
1492 if (bgPixmap.flags & bgPixmap_t::isInvalid)
1493 update_background_ev.start (0.025);
1494#endif
1502 mapped = 1; 1495 mapped = 1;
1503#ifdef TEXT_BLINK 1496#ifdef TEXT_BLINK
1504 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); 1497 text_blink_ev.start ();
1505#endif 1498#endif
1506 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1499 HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1507 break; 1500 break;
1508 1501
1509 case UnmapNotify: 1502 case UnmapNotify:
1511#ifdef TEXT_BLINK 1504#ifdef TEXT_BLINK
1512 text_blink_ev.stop (); 1505 text_blink_ev.stop ();
1513#endif 1506#endif
1514 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1507 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1515 break; 1508 break;
1516
1517#ifdef TRANSPARENT
1518 case ReparentNotify:
1519 rootwin_cb (ev);
1520 break;
1521#endif /* TRANSPARENT */
1522 1509
1523 case GraphicsExpose: 1510 case GraphicsExpose:
1524 case Expose: 1511 case Expose:
1525 if (ev.xany.window == vt) 1512 if (ev.xany.window == vt)
1526 { 1513 {
1527 do 1514 do
1515 {
1528 scr_expose (ev.xexpose.x, ev.xexpose.y, 1516 scr_expose (ev.xexpose.x, ev.xexpose.y,
1529 ev.xexpose.width, ev.xexpose.height, False); 1517 ev.xexpose.width, ev.xexpose.height, False);
1518 }
1530 while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); 1519 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev));
1531 1520
1532 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; 1521 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1533 1522
1534 while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) 1523 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1524 {
1535 scr_expose (ev.xexpose.x, ev.xexpose.y, 1525 scr_expose (ev.xexpose.x, ev.xexpose.y,
1536 ev.xexpose.width, ev.xexpose.height, False); 1526 ev.xexpose.width, ev.xexpose.height, False);
1527 }
1537 1528
1538 want_refresh = 1; 1529 want_refresh = 1;
1539 } 1530 }
1540 else 1531 else
1541 { 1532 {
1542 XEvent unused_event; 1533 XEvent unused_event;
1543 1534
1544 while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) 1535 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event))
1545 ; 1536 ;
1546 while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) 1537 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1547 ; 1538 ;
1548 1539
1549 if (isScrollbarWindow (ev.xany.window)) 1540 if (scrollBar.state && ev.xany.window == scrollBar.win)
1550 { 1541 {
1551 scrollBar.setIdle (); 1542 scrollBar.state = STATE_IDLE;
1552 scrollbar_show (0); 1543 scrollBar.show (0);
1553 } 1544 }
1554
1555#ifdef TRANSPARENT
1556 if (am_transparent && ev.xany.window == parent[0])
1557 XClearWindow (xdisp, ev.xany.window);
1558#endif
1559 } 1545 }
1560 break; 1546 break;
1561 1547
1562 case MotionNotify: 1548 case MotionNotify:
1563#ifdef POINTER_BLANK 1549#ifdef POINTER_BLANK
1564 if (hidden_pointer) 1550 if (hidden_pointer)
1565 pointer_unblank (); 1551 pointer_unblank ();
1566#endif 1552#endif
1553 if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask))
1554 || priv_modes & PrivMode_MouseAnyEvent)
1555 mouse_report (ev.xbutton);
1567 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1556 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1568 break; 1557 break;
1569 1558
1570 if (ev.xany.window == vt) 1559 if (ev.xany.window == vt)
1571 { 1560 {
1572 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) 1561 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1573 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1562 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1574 ; // nop 1563 ; // nop
1575 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1564 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1576 { 1565 {
1577 while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) 1566 while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev))
1578 ; 1567 ;
1579 1568
1580 XQueryPointer (xdisp, vt, 1569 XQueryPointer (dpy, vt,
1581 &unused_root, &unused_child, 1570 &unused_root, &unused_child,
1582 &unused_root_x, &unused_root_y, 1571 &unused_root_x, &unused_root_y,
1583 &ev.xbutton.x, &ev.xbutton.y, 1572 &ev.xbutton.x, &ev.xbutton.y,
1584 &ev.xbutton.state); 1573 &ev.xbutton.state);
1585#ifdef MOUSE_THRESHOLD 1574#ifdef MOUSE_THRESHOLD
1605 int dist; 1594 int dist;
1606 1595
1607 /* don't clobber the current delay if we are 1596 /* don't clobber the current delay if we are
1608 * already in the middle of scrolling. 1597 * already in the middle of scrolling.
1609 */ 1598 */
1610 if (!sel_scroll_ev.active) 1599 if (!sel_scroll_ev.is_active ())
1611 sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); 1600 sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
1612 1601
1613 /* save the event params so we can highlight 1602 /* save the event params so we can highlight
1614 * the selection in the pending-scroll loop 1603 * the selection in the pending-scroll loop
1615 */ 1604 */
1616 selection_save_x = ev.xbutton.x; 1605 selection_save_x = ev.xbutton.x;
1638 else 1627 else
1639 { 1628 {
1640 /* we are within the text window, so we 1629 /* we are within the text window, so we
1641 * shouldn't be scrolling 1630 * shouldn't be scrolling
1642 */ 1631 */
1643 if (sel_scroll_ev.active)
1644 sel_scroll_ev.stop(); 1632 sel_scroll_ev.stop();
1645 } 1633 }
1646#endif 1634#endif
1647#ifdef MOUSE_THRESHOLD 1635#ifdef MOUSE_THRESHOLD
1648 } 1636 }
1649#endif 1637#endif
1650 } 1638 }
1651 } 1639 }
1652 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1640 else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win)
1653 { 1641 {
1654 while (XCheckTypedWindowEvent (xdisp, scrollBar.win, 1642 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1655 MotionNotify, &ev)) 1643 MotionNotify, &ev))
1656 ; 1644 ;
1657 1645
1658 XQueryPointer (xdisp, scrollBar.win, 1646 XQueryPointer (dpy, scrollBar.win,
1659 &unused_root, &unused_child, 1647 &unused_root, &unused_child,
1660 &unused_root_x, &unused_root_y, 1648 &unused_root_x, &unused_root_y,
1661 &ev.xbutton.x, &ev.xbutton.y, 1649 &ev.xbutton.x, &ev.xbutton.y,
1662 &unused_mask); 1650 &unused_mask);
1663 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1651 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1664 scrollbar_size ()); 1652 scrollBar.size ());
1665 want_refresh = 1; 1653 want_refresh = 1;
1666 refresh_limit = 0;
1667 scrollbar_show (1); 1654 scrollBar.show (1);
1668 } 1655 }
1669 break; 1656 break;
1670 } 1657 }
1671 1658
1672skip_switch: ;
1673
1674#if defined(CURSOR_BLINK) 1659#if defined(CURSOR_BLINK)
1675 if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) 1660 if (option (Opt_cursorBlink) && ev.type == KeyPress)
1676 { 1661 {
1677 if (hidden_cursor) 1662 if (hidden_cursor)
1678 { 1663 {
1679 hidden_cursor = 0; 1664 hidden_cursor = 0;
1680 want_refresh = 1; 1665 want_refresh = 1;
1681 } 1666 }
1682 1667
1683 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1668 cursor_blink_ev.again ();
1684 } 1669 }
1685#endif 1670#endif
1686 1671
1687#if defined(POINTER_BLANK) 1672#if defined(POINTER_BLANK)
1688 if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) 1673 if (option (Opt_pointerBlank) && pointerBlankDelay > 0)
1689 { 1674 {
1690 if (ev.type == MotionNotify 1675 if (ev.type == MotionNotify
1691 || ev.type == ButtonPress 1676 || ev.type == ButtonPress
1692 || ev.type == ButtonRelease) 1677 || ev.type == ButtonRelease)
1693 if (hidden_pointer) 1678 if (hidden_pointer)
1695 1680
1696 if (ev.type == KeyPress && hidden_pointer == 0) 1681 if (ev.type == KeyPress && hidden_pointer == 0)
1697 pointer_blank (); 1682 pointer_blank ();
1698 } 1683 }
1699#endif 1684#endif
1685
1686 refresh_check ();
1687}
1688
1689void
1690rxvt_term::set_urgency (bool enable)
1691{
1692 if (enable == urgency_hint)
1693 return;
1694
1695 if (XWMHints *h = XGetWMHints (dpy, parent[0]))
1696 {
1697 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0);
1698 XSetWMHints (dpy, parent[0], h);
1699 urgency_hint = enable;
1700 }
1700} 1701}
1701 1702
1702void 1703void
1703rxvt_term::focus_in () 1704rxvt_term::focus_in ()
1704{ 1705{
1705 if (!focus) 1706 if (!focus)
1706 { 1707 {
1707 focus = 1; 1708 focus = 1;
1708 want_refresh = 1; 1709 want_refresh = 1;
1709 1710
1710 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1711
1712#if USE_XIM 1711#if USE_XIM
1713 if (Input_Context != NULL) 1712 if (Input_Context != NULL)
1714 { 1713 {
1715 IMSetStatusPosition (); 1714 IMSetPosition ();
1716 XSetICFocus (Input_Context); 1715 XSetICFocus (Input_Context);
1717 } 1716 }
1718#endif 1717#endif
1719#if CURSOR_BLINK 1718#if CURSOR_BLINK
1720 if (OPTION (Opt_cursorBlink)) 1719 if (option (Opt_cursorBlink))
1721 cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); 1720 cursor_blink_ev.again ();
1722#endif 1721#endif
1723#if OFF_FOCUS_FADING 1722#if OFF_FOCUS_FADING
1724 if (rs[Rs_fade]) 1723 if (rs[Rs_fade])
1725 { 1724 {
1726 pix_colors = pix_colors_focused; 1725 pix_colors = pix_colors_focused;
1727 scr_recolour (); 1726 scr_recolour ();
1728 } 1727 }
1729#endif 1728#endif
1729#if ENABLE_FRILLS
1730 if (option (Opt_urgentOnBell))
1731 set_urgency (0);
1732#endif
1733
1734 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1730 } 1735 }
1731} 1736}
1732 1737
1733void 1738void
1734rxvt_term::focus_out () 1739rxvt_term::focus_out ()
1736 if (focus) 1741 if (focus)
1737 { 1742 {
1738 focus = 0; 1743 focus = 0;
1739 want_refresh = 1; 1744 want_refresh = 1;
1740 1745
1741 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1746#if ENABLE_FRILLS
1742 1747 if (option (Opt_urgentOnBell))
1748 set_urgency (0);
1749#endif
1743#if ENABLE_FRILLS || ISO_14755 1750#if ENABLE_FRILLS || ISO_14755
1744 if (iso14755buf) 1751 if (iso14755buf)
1745 { 1752 {
1746 iso14755buf = 0; 1753 iso14755buf = 0;
1747# if ENABLE_OVERLAY 1754# if ISO_14755
1748 scr_overlay_off (); 1755 scr_overlay_off ();
1749# endif 1756# endif
1750 } 1757 }
1751#endif 1758#endif
1752#if USE_XIM 1759#if USE_XIM
1753 if (Input_Context != NULL) 1760 if (Input_Context != NULL)
1754 XUnsetICFocus (Input_Context); 1761 XUnsetICFocus (Input_Context);
1755#endif 1762#endif
1756#if CURSOR_BLINK 1763#if CURSOR_BLINK
1757 if (OPTION (Opt_cursorBlink)) 1764 if (option (Opt_cursorBlink))
1758 cursor_blink_ev.stop (); 1765 cursor_blink_ev.stop ();
1766
1759 hidden_cursor = 0; 1767 hidden_cursor = 0;
1760#endif 1768#endif
1761#if OFF_FOCUS_FADING 1769#if OFF_FOCUS_FADING
1762 if (rs[Rs_fade]) 1770 if (rs[Rs_fade])
1763 { 1771 {
1764 pix_colors = pix_colors_unfocused; 1772 pix_colors = pix_colors_unfocused;
1765 scr_recolour (); 1773 scr_recolour ();
1766 } 1774 }
1767#endif 1775#endif
1776
1777 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1778 }
1779}
1780
1781void
1782rxvt_term::update_fade_color (unsigned int idx)
1783{
1784#if OFF_FOCUS_FADING
1785 if (rs[Rs_fade])
1768 } 1786 {
1787 rgba c;
1788 pix_colors [Color_fade].get (c);
1789 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c);
1790 }
1791#endif
1769} 1792}
1770 1793
1771#if TRANSPARENT 1794#if ENABLE_TRANSPARENCY || ENABLE_PERL
1772void 1795void
1773rxvt_term::rootwin_cb (XEvent &ev) 1796rxvt_term::rootwin_cb (XEvent &ev)
1774{ 1797{
1775 make_current (); 1798 make_current ();
1776 1799
1800 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1801 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END)))
1802 return;
1803
1804# if ENABLE_TRANSPARENCY
1777 switch (ev.type) 1805 switch (ev.type)
1778 { 1806 {
1779 case PropertyNotify: 1807 case PropertyNotify:
1780 /* 1808 /*
1781 * if user used some Esetroot compatible prog to set the root bg, 1809 * if user used some Esetroot compatible prog to set the root bg,
1782 * use the property to determine the pixmap. We use it later on. 1810 * use the property to determine the pixmap. We use it later on.
1783 */ 1811 */
1784 if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] 1812 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1785 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1813 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1786 return; 1814 {
1815 bgPixmap.set_root_pixmap ();
1816 update_background ();
1817 }
1787 1818
1788 /* FALLTHROUGH */
1789 case ReparentNotify:
1790 if (OPTION (Opt_transparent) && check_our_parents () && am_transparent)
1791 want_refresh = want_full_refresh = 1;
1792 break; 1819 break;
1793 } 1820 }
1821# endif
1822
1823 refresh_check ();
1794} 1824}
1795#endif 1825#endif
1796 1826
1797void 1827void
1798rxvt_term::button_press (XButtonEvent &ev) 1828rxvt_term::button_press (XButtonEvent &ev)
1853 mouse_report (ev); 1883 mouse_report (ev);
1854 } 1884 }
1855#else 1885#else
1856 MEvent.button = ev.button; 1886 MEvent.button = ev.button;
1857 mouse_report (ev); 1887 mouse_report (ev);
1858#endif /* MOUSE_REPORT_DOUBLECLICK */ 1888#endif /* MOUSE_REPORT_DOUBLECLICK */
1859 1889
1860 } 1890 }
1861 else 1891 else
1862 { 1892 {
1863 if (ev.button != MEvent.button) 1893 if (ev.button != MEvent.button)
1911 } 1941 }
1912 1942
1913 /* 1943 /*
1914 * Scrollbar window processing of button press 1944 * Scrollbar window processing of button press
1915 */ 1945 */
1916 if (isScrollbarWindow (ev.window)) 1946 if (scrollBar.state && ev.window == scrollBar.win)
1917 { 1947 {
1918 scrollBar.setIdle (); 1948 page_dirn direction = NO_DIR;
1949
1950 if (scrollBar.upButton (ev.y))
1951 direction = UP; /* up */
1952 else if (scrollBar.dnButton (ev.y))
1953 direction = DN; /* down */
1954
1955 scrollBar.state = STATE_IDLE;
1919 /* 1956 /*
1920 * Rxvt-style scrollbar: 1957 * Rxvt-style scrollbar:
1921 * move up if mouse is above slider 1958 * move up if mouse is above slider
1922 * move dn if mouse is below slider 1959 * move dn if mouse is below slider
1923 * 1960 *
1932 /* 1969 /*
1933 * Mouse report disabled scrollbar: 1970 * Mouse report disabled scrollbar:
1934 * arrow buttons - send up/down 1971 * arrow buttons - send up/down
1935 * click on scrollbar - send pageup/down 1972 * click on scrollbar - send pageup/down
1936 */ 1973 */
1937 if ((scrollBar.style == R_SB_NEXT 1974 if (direction == UP)
1938 && scrollbarnext_upButton (ev.y))
1939 || (scrollBar.style == R_SB_RXVT
1940 && scrollbarrxvt_upButton (ev.y)))
1941 tt_printf ("\033[A"); 1975 tt_printf ("\033[A");
1942 else if ((scrollBar.style == R_SB_NEXT 1976 else if (direction == DN)
1943 && scrollbarnext_dnButton (ev.y))
1944 || (scrollBar.style == R_SB_RXVT
1945 && scrollbarrxvt_dnButton (ev.y)))
1946 tt_printf ("\033[B"); 1977 tt_printf ("\033[B");
1947 else 1978 else
1948 switch (ev.button) 1979 switch (ev.button)
1949 { 1980 {
1950 case Button2: 1981 case Button2:
1957 tt_printf ("\033[5~"); 1988 tt_printf ("\033[5~");
1958 break; 1989 break;
1959 } 1990 }
1960 } 1991 }
1961 else 1992 else
1962#endif /* NO_SCROLLBAR_REPORT */ 1993#endif /* NO_SCROLLBAR_REPORT */
1963
1964 {
1965 char upordown = 0;
1966
1967 if (scrollBar.style == R_SB_NEXT)
1968 { 1994 {
1969 if (scrollbarnext_upButton (ev.y)) 1995 if (direction != NO_DIR)
1970 upordown = -1; /* up */
1971 else if (scrollbarnext_dnButton (ev.y))
1972 upordown = 1; /* down */
1973 }
1974 else if (scrollBar.style == R_SB_RXVT)
1975 {
1976 if (scrollbarrxvt_upButton (ev.y))
1977 upordown = -1; /* up */
1978 else if (scrollbarrxvt_dnButton (ev.y))
1979 upordown = 1; /* down */
1980 }
1981 if (upordown)
1982 { 1996 {
1983#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING 1997#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
1998 if (!cont_scroll_ev.is_active ())
1984 cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); 1999 cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
1985#endif 2000#endif
1986 if (scr_page (upordown < 0 ? UP : DN, 1)) 2001 if (scr_page (direction, 1))
1987 { 2002 {
1988 if (upordown < 0) 2003 if (direction == UP)
1989 scrollBar.setUp (); 2004 scrollBar.state = STATE_UP;
1990 else 2005 else
1991 scrollBar.setDn (); 2006 scrollBar.state = STATE_DOWN;
1992 } 2007 }
1993 } 2008 }
1994 else 2009 else
1995 switch (ev.button) 2010 switch (ev.button)
1996 { 2011 {
1997 case Button2: 2012 case Button2:
1998 switch (scrollbar_align) 2013 switch (scrollBar.align)
1999 { 2014 {
2000 case R_SB_ALIGN_TOP: 2015 case R_SB_ALIGN_TOP:
2001 csrO = 0; 2016 csrO = 0;
2002 break; 2017 break;
2003 case R_SB_ALIGN_CENTRE: 2018 case R_SB_ALIGN_CENTRE:
2009 } 2024 }
2010 2025
2011 if (scrollBar.style == R_SB_XTERM 2026 if (scrollBar.style == R_SB_XTERM
2012 || scrollbar_above_slider (ev.y) 2027 || scrollbar_above_slider (ev.y)
2013 || scrollbar_below_slider (ev.y)) 2028 || scrollbar_below_slider (ev.y))
2014 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); 2029 scr_move_to (scrollbar_position (ev.y) - csrO, scrollBar.size ());
2015 2030
2016 scrollBar.setMotion (); 2031 scrollBar.state = STATE_MOTION;
2017 break; 2032 break;
2018 2033
2019 case Button1: 2034 case Button1:
2020 if (scrollbar_align == R_SB_ALIGN_CENTRE) 2035 if (scrollBar.align == R_SB_ALIGN_CENTRE)
2021 csrO = ev.y - scrollBar.top; 2036 csrO = ev.y - scrollBar.top;
2022 /* FALLTHROUGH */ 2037 /* FALLTHROUGH */
2023 2038
2024 case Button3: 2039 case Button3:
2025 if (scrollBar.style != R_SB_XTERM) 2040 if (scrollBar.style != R_SB_XTERM)
2035 scr_page (DN, nrow - 1); 2050 scr_page (DN, nrow - 1);
2036# else 2051# else
2037 scr_page (DN, nrow / 4); 2052 scr_page (DN, nrow / 4);
2038# endif 2053# endif
2039 else 2054 else
2040 scrollBar.setMotion (); 2055 scrollBar.state = STATE_MOTION;
2041 } 2056 }
2042 else 2057 else
2043 { 2058 {
2044 scr_page ((ev.button == Button1 ? DN : UP), 2059 scr_page ((ev.button == Button1 ? DN : UP),
2045 (nrow 2060 (nrow
2046 * scrollbar_position (ev.y) 2061 * scrollbar_position (ev.y)
2047 / scrollbar_size ())); 2062 / scrollBar.size ()));
2048 } 2063 }
2049 2064
2050 break; 2065 break;
2051 } 2066 }
2052 } 2067 }
2062 2077
2063 csrO = 0; /* reset csr Offset */ 2078 csrO = 0; /* reset csr Offset */
2064 if (!bypass_keystate) 2079 if (!bypass_keystate)
2065 reportmode = !! (priv_modes & PrivMode_mouse_report); 2080 reportmode = !! (priv_modes & PrivMode_mouse_report);
2066 2081
2067 if (scrollbar_isUpDn ()) 2082 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN)
2068 { 2083 {
2069 scrollBar.setIdle (); 2084 scrollBar.state = STATE_IDLE;
2070 scrollbar_show (0); 2085 scrollBar.show (0);
2071 } 2086 }
2072 2087
2073#ifdef SELECTION_SCROLLING 2088#ifdef SELECTION_SCROLLING
2074 if (sel_scroll_ev.active)
2075 sel_scroll_ev.stop(); 2089 sel_scroll_ev.stop();
2076#endif 2090#endif
2077 2091
2078 if (ev.window == vt) 2092 if (ev.window == vt)
2079 { 2093 {
2080 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) 2094 if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END)))
2104 mouse_report (ev); 2118 mouse_report (ev);
2105 } 2119 }
2106#else /* MOUSE_REPORT_DOUBLECLICK */ 2120#else /* MOUSE_REPORT_DOUBLECLICK */
2107 MEvent.button = AnyButton; 2121 MEvent.button = AnyButton;
2108 mouse_report (ev); 2122 mouse_report (ev);
2109#endif /* MOUSE_REPORT_DOUBLECLICK */ 2123#endif /* MOUSE_REPORT_DOUBLECLICK */
2110 return; 2124 return;
2111 } 2125 }
2112 2126
2113 /* 2127 /*
2114 * dumb hack to compensate for the failure of click-and-drag 2128 * dumb hack to compensate for the failure of click-and-drag
2126 selection_make (ev.time); 2140 selection_make (ev.time);
2127 break; 2141 break;
2128 2142
2129 case Button2: 2143 case Button2:
2130 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? 2144 if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window?
2131 selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); 2145 selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary);
2132 break; 2146 break;
2133 2147
2134#ifdef MOUSE_WHEEL 2148#ifdef MOUSE_WHEEL
2135 case Button4: 2149 case Button4:
2136 case Button5: 2150 case Button5:
2140 2154
2141 v = ev.button == Button4 ? UP : DN; 2155 v = ev.button == Button4 ? UP : DN;
2142 2156
2143 if (ev.state & ShiftMask) 2157 if (ev.state & ShiftMask)
2144 i = 1; 2158 i = 1;
2145 else if (OPTION (Opt_mouseWheelScrollPage)) 2159 else if (option (Opt_mouseWheelScrollPage))
2146 i = nrow - 1; 2160 i = nrow - 1;
2147 else 2161 else
2148 i = 5; 2162 i = 5;
2149 2163
2150# ifdef MOUSE_SLIP_WHEELING 2164# ifdef MOUSE_SLIP_WHEELING
2152 { 2166 {
2153 mouse_slip_wheel_speed += v ? -1 : 1; 2167 mouse_slip_wheel_speed += v ? -1 : 1;
2154 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; 2168 if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow;
2155 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; 2169 if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow;
2156 2170
2157 if (slip_wheel_ev.at < NOW) 2171 if (!slip_wheel_ev.is_active ())
2158 slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; 2172 slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY);
2159
2160 slip_wheel_ev.start ();
2161 } 2173 }
2162 else 2174 else
2175# endif
2163 { 2176 {
2164# endif
2165 scr_page (v, i); 2177 scr_page (v, i);
2166 scrollbar_show (1); 2178 scrollBar.show (1);
2167# ifdef MOUSE_SLIP_WHEELING
2168 } 2179 }
2169# endif
2170 } 2180 }
2171 break; 2181 break;
2172#endif 2182#endif
2173 } 2183 }
2174 } 2184 }
2175} 2185}
2176 2186
2177#ifdef TRANSPARENT
2178#if TINTING
2179/* taken from aterm-0.4.2 */
2180
2181typedef uint32_t RUINT32T;
2182
2183void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm)
2184{
2185 int sh_r, sh_g, sh_b;
2186 RUINT32T mask_r, mask_g, mask_b;
2187 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
2188 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
2189 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
2190 int i;
2191
2192 Visual *visual = term->visual;
2193
2194 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
2195
2196 /* for convenience */
2197 mask_r = visual->red_mask;
2198 mask_g = visual->green_mask;
2199 mask_b = visual->blue_mask;
2200
2201 /* boring lookup table pre-initialization */
2202 switch (srcImage->bits_per_pixel) {
2203 case 15:
2204 if ((mask_r != 0x7c00) ||
2205 (mask_g != 0x03e0) ||
2206 (mask_b != 0x001f))
2207 return;
2208 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32));
2209 lookup_r = lookup;
2210 lookup_g = lookup+32;
2211 lookup_b = lookup+32+32;
2212 sh_r = 10;
2213 sh_g = 5;
2214 sh_b = 0;
2215 break;
2216 case 16:
2217 if ((mask_r != 0xf800) ||
2218 (mask_g != 0x07e0) ||
2219 (mask_b != 0x001f))
2220 return;
2221 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32));
2222 lookup_r = lookup;
2223 lookup_g = lookup+32;
2224 lookup_b = lookup+32+64;
2225 sh_r = 11;
2226 sh_g = 5;
2227 sh_b = 0;
2228 break;
2229 case 24:
2230 if ((mask_r != 0xff0000) ||
2231 (mask_g != 0x00ff00) ||
2232 (mask_b != 0x0000ff))
2233 return;
2234 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2235 lookup_r = lookup;
2236 lookup_g = lookup+256;
2237 lookup_b = lookup+256+256;
2238 sh_r = 16;
2239 sh_g = 8;
2240 sh_b = 0;
2241 break;
2242 case 32:
2243 if ((mask_r != 0xff0000) ||
2244 (mask_g != 0x00ff00) ||
2245 (mask_b != 0x0000ff))
2246 return;
2247 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2248 lookup_r = lookup;
2249 lookup_g = lookup+256;
2250 lookup_b = lookup+256+256;
2251 sh_r = 16;
2252 sh_g = 8;
2253 sh_b = 0;
2254 break;
2255 default:
2256 return; /* we do not support this color depth */
2257 }
2258
2259 /* prepare limits for color transformation (each channel is handled separately) */
2260 if (shade < 0) {
2261 shade = -shade;
2262 if (shade < 0) shade = 0;
2263 if (shade > 100) shade = 100;
2264
2265 lower_lim_r = 65535-rm;
2266 lower_lim_g = 65535-gm;
2267 lower_lim_b = 65535-bm;
2268
2269 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100);
2270 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
2271 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
2272
2273 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
2274 } else {
2275 if (shade < 0) shade = 0;
2276 if (shade > 100) shade = 100;
2277
2278 lower_lim_r = lower_lim_g = lower_lim_b = 0;
2279
2280 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
2281 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);
2282 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100);
2283 }
2284
2285 /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */
2286 if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 ))
2287 {
2288 unsigned int tmp;
2289
2290 tmp = lower_lim_r;
2291 lower_lim_r = lower_lim_b;
2292 lower_lim_b = tmp;
2293
2294 tmp = upper_lim_r;
2295 upper_lim_r = upper_lim_b;
2296 upper_lim_b = tmp;
2297 }
2298
2299 /* fill our lookup tables */
2300 for (i = 0; i <= mask_r>>sh_r; i++)
2301 {
2302 RUINT32T tmp;
2303 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r));
2304 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r);
2305 lookup_r[i] = (tmp/65535)<<sh_r;
2306 }
2307 for (i = 0; i <= mask_g>>sh_g; i++)
2308 {
2309 RUINT32T tmp;
2310 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g));
2311 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g);
2312 lookup_g[i] = (tmp/65535)<<sh_g;
2313 }
2314 for (i = 0; i <= mask_b>>sh_b; i++)
2315 {
2316 RUINT32T tmp;
2317 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b));
2318 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b);
2319 lookup_b[i] = (tmp/65535)<<sh_b;
2320 }
2321
2322 /* apply table to input image (replacing colors by newly calculated ones) */
2323 switch (srcImage->bits_per_pixel)
2324 {
2325 case 15:
2326 {
2327 unsigned short *p1, *pf, *p, *pl;
2328 p1 = (unsigned short *) srcImage->data;
2329 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2330 while (p1 < pf)
2331 {
2332 p = p1;
2333 pl = p1 + srcImage->width;
2334 for (; p < pl; p++)
2335 {
2336 *p = lookup_r[(*p & 0x7c00)>>10] |
2337 lookup_g[(*p & 0x03e0)>> 5] |
2338 lookup_b[(*p & 0x001f)];
2339 }
2340 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2341 }
2342 break;
2343 }
2344 case 16:
2345 {
2346 unsigned short *p1, *pf, *p, *pl;
2347 p1 = (unsigned short *) srcImage->data;
2348 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2349 while (p1 < pf)
2350 {
2351 p = p1;
2352 pl = p1 + srcImage->width;
2353 for (; p < pl; p++)
2354 {
2355 *p = lookup_r[(*p & 0xf800)>>11] |
2356 lookup_g[(*p & 0x07e0)>> 5] |
2357 lookup_b[(*p & 0x001f)];
2358 }
2359 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2360 }
2361 break;
2362 }
2363 case 24:
2364 {
2365 unsigned char *p1, *pf, *p, *pl;
2366 p1 = (unsigned char *) srcImage->data;
2367 pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2368 while (p1 < pf)
2369 {
2370 p = p1;
2371 pl = p1 + srcImage->width * 3;
2372 for (; p < pl; p += 3)
2373 {
2374 p[0] = lookup_r[(p[0] & 0xff0000)>>16];
2375 p[1] = lookup_r[(p[1] & 0x00ff00)>> 8];
2376 p[2] = lookup_r[(p[2] & 0x0000ff)];
2377 }
2378 p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line);
2379 }
2380 break;
2381 }
2382 case 32:
2383 {
2384 RUINT32T *p1, *pf, *p, *pl;
2385 p1 = (RUINT32T *) srcImage->data;
2386 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2387
2388 while (p1 < pf)
2389 {
2390 p = p1;
2391 pl = p1 + srcImage->width;
2392 for (; p < pl; p++)
2393 {
2394 *p = lookup_r[(*p & 0xff0000)>>16] |
2395 lookup_g[(*p & 0x00ff00)>> 8] |
2396 lookup_b[(*p & 0x0000ff)] |
2397 (*p & ~0xffffff);
2398 }
2399 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line);
2400 }
2401 break;
2402 }
2403 }
2404
2405 free (lookup);
2406}
2407#endif
2408
2409/*
2410 * Check our parents are still who we think they are.
2411 * Do transparency updates if required
2412 */
2413int
2414rxvt_term::check_our_parents ()
2415{
2416 int i, pchanged, aformat, have_pixmap, rootdepth;
2417 unsigned long nitems, bytes_after;
2418 Atom atype;
2419 unsigned char *prop = NULL;
2420 Window root, oldp, *list;
2421 Pixmap rootpixmap = None;
2422 XWindowAttributes wattr, wrootattr;
2423
2424 pchanged = 0;
2425
2426 if (!OPTION (Opt_transparent))
2427 return pchanged; /* Don't try any more */
2428
2429 XGetWindowAttributes (xdisp, display->root, &wrootattr);
2430 rootdepth = wrootattr.depth;
2431
2432 XGetWindowAttributes (xdisp, parent[0], &wattr);
2433
2434 if (rootdepth != wattr.depth)
2435 {
2436 if (am_transparent)
2437 {
2438 pchanged = 1;
2439 XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]);
2440 am_transparent = am_pixmap_trans = 0;
2441 }
2442
2443 return pchanged; /* Don't try any more */
2444 }
2445
2446 /* Get all X ops out of the queue so that our information is up-to-date. */
2447 XSync (xdisp, False);
2448
2449 /*
2450 * Make the frame window set by the window manager have
2451 * the root background. Some window managers put multiple nested frame
2452 * windows for each client, so we have to take care about that.
2453 */
2454 i = (xa[XA_XROOTPMAP_ID]
2455 && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID],
2456 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2457 &nitems, &bytes_after, &prop) == Success);
2458
2459 if (!i || prop == NULL)
2460 i = (xa[XA_ESETROOT_PMAP_ID]
2461 && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID],
2462 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2463 &nitems, &bytes_after, &prop) == Success);
2464
2465 if (!i || prop == NULL
2466#if TINTING
2467 || !ISSET_PIXCOLOR (Color_tint)
2468#endif
2469 )
2470 have_pixmap = 0;
2471 else
2472 {
2473 have_pixmap = 1;
2474 rootpixmap = *(Pixmap *)prop;
2475 XFree (prop);
2476 }
2477
2478 if (have_pixmap)
2479 {
2480 /*
2481 * Copy display->root pixmap transparency
2482 */
2483 int sx, sy, nx, ny;
2484 unsigned int nw, nh;
2485 Window cr;
2486 XImage *image;
2487 GC gc;
2488 XGCValues gcvalue;
2489
2490 XTranslateCoordinates (xdisp, parent[0], display->root,
2491 0, 0, &sx, &sy, &cr);
2492 nw = (unsigned int)szHint.width;
2493 nh = (unsigned int)szHint.height;
2494 nx = ny = 0;
2495
2496 if (sx < 0)
2497 {
2498 nw += sx;
2499 nx = -sx;
2500 sx = 0;
2501 }
2502
2503 if (sy < 0)
2504 {
2505 nh += sy;
2506 ny = -sy;
2507 sy = 0;
2508 }
2509
2510 min_it (nw, (unsigned int) (wrootattr.width - sx));
2511 min_it (nh, (unsigned int) (wrootattr.height - sy));
2512
2513 XSync (xdisp, False);
2514 allowedxerror = -1;
2515 image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2516
2517 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2518 /* XXX: may need a delay here? */
2519 allowedxerror = 0;
2520
2521 if (image == NULL)
2522 {
2523 if (am_transparent && am_pixmap_trans)
2524 {
2525 pchanged = 1;
2526 if (pixmap != None)
2527 {
2528 XFreePixmap (xdisp, pixmap);
2529 pixmap = None;
2530 }
2531 }
2532
2533 am_pixmap_trans = 0;
2534 }
2535 else
2536 {
2537 if (pixmap != None)
2538 XFreePixmap (xdisp, pixmap);
2539
2540#if TINTING
2541 if (ISSET_PIXCOLOR (Color_tint))
2542 {
2543 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2544
2545 rgba c;
2546 pix_colors_focused [Color_tint].get (this, c);
2547
2548 ShadeXImage (this, image, shade, c.r, c.g, c.b);
2549 }
2550#endif
2551
2552 pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth);
2553 gc = XCreateGC (xdisp, vt, 0UL, &gcvalue);
2554 XPutImage (xdisp, pixmap, gc, image, 0, 0,
2555 nx, ny, image->width, image->height);
2556 XFreeGC (xdisp, gc);
2557 XDestroyImage (image);
2558 XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap);
2559 XClearWindow (xdisp, parent[0]);
2560
2561 if (!am_transparent || !am_pixmap_trans)
2562 pchanged = 1;
2563
2564 am_transparent = am_pixmap_trans = 1;
2565 }
2566 }
2567
2568 if (am_pixmap_trans)
2569 XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative);
2570 else
2571 {
2572 unsigned int n;
2573 /*
2574 * InheritPixmap transparency
2575 */
2576 for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2577 {
2578 oldp = parent[i];
2579 XQueryTree (xdisp, parent[i - 1], &root, &parent[i], &list, &n);
2580 XFree (list);
2581
2582 if (parent[i] == display->root)
2583 {
2584 if (oldp != None)
2585 pchanged = 1;
2586
2587 break;
2588 }
2589
2590 if (oldp != parent[i])
2591 pchanged = 1;
2592 }
2593
2594 n = 0;
2595
2596 if (pchanged)
2597 for (; n < (unsigned int)i; n++)
2598 {
2599 XGetWindowAttributes (xdisp, parent[n], &wattr);
2600
2601 if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
2602 {
2603 n = (int) (sizeof (parent) / sizeof (Window)) + 1;
2604 break;
2605 }
2606 }
2607
2608 if (n > (sizeof (parent) / sizeof (parent[0])))
2609 {
2610 XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]);
2611 XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]);
2612 am_transparent = 0;
2613 /* XXX: also turn off Opt_transparent? */
2614 }
2615 else
2616 {
2617 for (n = 0; n < (unsigned int)i; n++)
2618 {
2619 XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative);
2620 XClearWindow (xdisp, parent[n]);
2621 }
2622
2623 XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative);
2624 am_transparent = 1;
2625 }
2626
2627 for (; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2628 parent[i] = None;
2629 }
2630
2631 if (scrollBar.win)
2632 {
2633 XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative);
2634 scrollBar.setIdle ();
2635 scrollbar_show (0);
2636 }
2637
2638 if (am_transparent)
2639 {
2640 want_refresh = want_full_refresh = 1;
2641 if (am_pixmap_trans)
2642 flush ();
2643 }
2644
2645 return pchanged;
2646}
2647#endif
2648
2649/*}}} */ 2187/*}}} */
2650 2188
2651bool 2189void
2652rxvt_term::cmd_parse () 2190rxvt_term::cmd_parse ()
2653{ 2191{
2654 bool flag = false;
2655 wchar_t ch = NOCHAR; 2192 wchar_t ch = NOCHAR;
2656 char *seq_begin; // remember start of esc-sequence here 2193 char *seq_begin; // remember start of esc-sequence here
2657 2194
2658 for (;;) 2195 for (;;)
2659 { 2196 {
2660 if (ch == NOCHAR) 2197 if (expect_false (ch == NOCHAR))
2661 { 2198 {
2662 seq_begin = cmdbuf_ptr; 2199 seq_begin = cmdbuf_ptr;
2663 ch = next_char (); 2200 ch = next_char ();
2664 2201
2665 if (ch == NOCHAR) 2202 if (ch == NOCHAR)
2666 break; 2203 break;
2667 } 2204 }
2668 2205
2669 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) 2206 if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
2670 { 2207 {
2671 if (!seen_input) 2208 if (expect_false (!seen_input))
2672 { 2209 {
2673 seen_input = 1; 2210 seen_input = 1;
2674 // many badly-written programs (e.g. jed) contain a race condition: 2211 // many badly-written programs (e.g. jed) contain a race condition:
2675 // they first read the screensize and then install a SIGWINCH handler. 2212 // they first read the screensize and then install a SIGWINCH handler.
2676 // some window managers resize the window early, and these programs 2213 // some window managers resize the window early, and these programs
2689 wchar_t *str = buf; 2226 wchar_t *str = buf;
2690 wchar_t *eol = str + min (ncol, UBUFSIZ); 2227 wchar_t *eol = str + min (ncol, UBUFSIZ);
2691 2228
2692 for (;;) 2229 for (;;)
2693 { 2230 {
2694 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2231 if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)))
2695 break; 2232 break;
2696 2233
2697 *str++ = ch; 2234 *str++ = ch;
2698 2235
2699 if (ch == C0_LF || str >= eol) 2236 if (expect_false (ch == C0_LF || str >= eol))
2700 { 2237 {
2701 if (ch == C0_LF) 2238 if (ch == C0_LF)
2702 nlines++; 2239 nlines++;
2703 2240
2704 refresh_count++; 2241 refresh_count++;
2705 2242
2706 if (!OPTION (Opt_jumpScroll) 2243 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2707 || (refresh_count >= refresh_limit * (nrow - 1)))
2708 { 2244 {
2709 refreshnow = true;
2710 refresh_count = 0; 2245 refresh_count = 0;
2246
2247 if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.)
2248 {
2249 refreshnow = true;
2711 ch = NOCHAR; 2250 ch = NOCHAR;
2712 break; 2251 break;
2252 }
2713 } 2253 }
2714 2254
2715 // scr_add_lines only works for nlines <= nrow - 1. 2255 // scr_add_lines only works for nlines <= nrow - 1.
2716 if (nlines >= nrow - 1) 2256 if (nlines >= nrow - 1)
2717 { 2257 {
2745 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) 2285 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2746 scr_add_lines (buf, str - buf, nlines); 2286 scr_add_lines (buf, str - buf, nlines);
2747 2287
2748 /* 2288 /*
2749 * If there have been a lot of new lines, then update the screen 2289 * If there have been a lot of new lines, then update the screen
2750 * What the heck I'll cheat and only refresh less than every page-full. 2290 * What the heck we'll cheat and only refresh less than every page-full.
2751 * the number of pages between refreshes is refresh_limit, which 2291 * if skipScroll is enabled.
2752 * is incremented here because we must be doing flat-out scrolling.
2753 */ 2292 */
2754 if (refreshnow) 2293 if (refreshnow)
2755 { 2294 {
2756 if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2757 refresh_limit++;
2758 else
2759 {
2760 flag = true;
2761 scr_refresh (); 2295 scr_refresh ();
2762 want_refresh = 1; 2296 want_refresh = 1;
2763 }
2764 } 2297 }
2765
2766 } 2298 }
2767 else 2299 else
2768 { 2300 {
2769 try 2301 try
2770 { 2302 {
2778 } 2310 }
2779 2311
2780 ch = NOCHAR; 2312 ch = NOCHAR;
2781 } 2313 }
2782 } 2314 }
2783
2784 return flag;
2785} 2315}
2786 2316
2787// read the next character 2317// read the next character
2788wchar_t 2318wchar_t
2789rxvt_term::next_char () NOTHROW 2319rxvt_term::next_char () NOTHROW
2790{ 2320{
2791 while (cmdbuf_ptr < cmdbuf_endp) 2321 while (cmdbuf_ptr < cmdbuf_endp)
2792 { 2322 {
2793 // assume 7-bit to be ascii ALWAYS 2323 // assume 7-bit to be ascii ALWAYS
2794 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) 2324 if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b))
2795 return *cmdbuf_ptr++; 2325 return *cmdbuf_ptr++;
2796 2326
2797 wchar_t wc; 2327 wchar_t wc;
2798 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); 2328 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
2799 2329
2803 cmdbuf_ptr = cmdbuf_endp; 2333 cmdbuf_ptr = cmdbuf_endp;
2804 break; 2334 break;
2805 } 2335 }
2806 2336
2807 if (len == (size_t)-1) 2337 if (len == (size_t)-1)
2338 {
2339 mbrtowc (0, 0, 0, mbstate); // reset now undefined conversion state
2808 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2340 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2341 }
2809 2342
2810 // assume wchar == unicode 2343 // assume wchar == unicode
2811 cmdbuf_ptr += len; 2344 cmdbuf_ptr += len;
2812 return wc & UNICODE_MASK; 2345 return wc & UNICODE_MASK;
2813 } 2346 }
2857/*----------------------------------------------------------------------*/ 2390/*----------------------------------------------------------------------*/
2858#ifdef PRINTPIPE 2391#ifdef PRINTPIPE
2859FILE * 2392FILE *
2860rxvt_term::popen_printer () 2393rxvt_term::popen_printer ()
2861{ 2394{
2862 FILE *stream = popen (rs[Rs_print_pipe], "w"); 2395 FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w");
2863 2396
2864 if (stream == NULL) 2397 if (stream == NULL)
2865 rxvt_warn ("can't open printer pipe, not printing.\n"); 2398 rxvt_warn ("can't open printer pipe, not printing.\n");
2866 2399
2867 return stream; 2400 return stream;
2878 * simulate attached vt100 printer 2411 * simulate attached vt100 printer
2879 */ 2412 */
2880void 2413void
2881rxvt_term::process_print_pipe () 2414rxvt_term::process_print_pipe ()
2882{ 2415{
2883 int done; 2416 FILE *fd = popen_printer ();
2884 FILE *fd;
2885 2417
2886 if ((fd = popen_printer ()) == NULL) 2418 if (!fd)
2887 return; 2419 return;
2888 2420
2889 /* 2421 /*
2890 * Send all input to the printer until either ESC[4i or ESC[?4i 2422 * Send all input to the printer until either ESC[4i or ESC[?4i
2891 * is received. 2423 * is received.
2892 */ 2424 */
2893 for (done = 0; !done;) 2425 for (int done = 0; !done; )
2894 { 2426 {
2895 unsigned char buf[8]; 2427 unsigned char buf[8];
2896 unicode_t ch; 2428 unicode_t ch;
2897 unsigned int i, len; 2429 unsigned int i, len;
2898 2430
2917 { 2449 {
2918 if ((buf[len++] = cmd_getc ()) == 'i') 2450 if ((buf[len++] = cmd_getc ()) == 'i')
2919 break; /* done = 1 */ 2451 break; /* done = 1 */
2920 } 2452 }
2921 } 2453 }
2922 2454
2923 for (i = 0; i < len; i++) 2455 for (i = 0; i < len; i++)
2924 if (putc (buf[i], fd) == EOF) 2456 if (putc (buf[i], fd) == EOF)
2925 { 2457 {
2926 done = 1; 2458 done = 1;
2927 break; 2459 break;
2929 } 2461 }
2930 } 2462 }
2931 2463
2932 pclose_printer (fd); 2464 pclose_printer (fd);
2933} 2465}
2934#endif /* PRINTPIPE */ 2466#endif /* PRINTPIPE */
2935/*}}} */ 2467/*}}} */
2936 2468
2937/* *INDENT-OFF* */ 2469/* *INDENT-OFF* */
2938enum { 2470enum {
2939 C1_40 = 0x40, 2471 C1_40 = 0x40,
2989 process_dcs_seq (); 2521 process_dcs_seq ();
2990 break; 2522 break;
2991 case 0x9b: /* CSI */ 2523 case 0x9b: /* CSI */
2992 process_csi_seq (); 2524 process_csi_seq ();
2993 break; 2525 break;
2994 case 0x9d: /* CSI */ 2526 case 0x9d: /* OSC */
2995 process_osc_seq (); 2527 process_osc_seq ();
2996 break; 2528 break;
2997#endif 2529#endif
2998 } 2530 }
2999} 2531}
3043 break; 2575 break;
3044 case 'Z': /* identify the terminal type */ 2576 case 'Z': /* identify the terminal type */
3045 tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ 2577 tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */
3046 break; 2578 break;
3047 case '<': /* turn off VT52 mode */ 2579 case '<': /* turn off VT52 mode */
3048 PrivMode (0, PrivMode_vt52); 2580 set_privmode (PrivMode_vt52, 0);
3049 break; 2581 break;
3050 case 'F': /* use special graphics character set */ 2582 case 'F': /* use special graphics character set */
3051 case 'G': /* use regular character set */ 2583 case 'G': /* use regular character set */
3052 /* unimplemented */ 2584 /* unimplemented */
3053 break; 2585 break;
3107 scr_forwardindex (); 2639 scr_forwardindex ();
3108 break; 2640 break;
3109#endif 2641#endif
3110 case '=': 2642 case '=':
3111 case '>': 2643 case '>':
3112 PrivMode ((ch == '='), PrivMode_aplKP); 2644 set_privmode (PrivMode_aplKP, ch == '=');
3113 break; 2645 break;
3114 2646
3115 case C1_40: 2647 case C1_40:
3116 cmd_getc (); 2648 cmd_getc ();
3117 break; 2649 break;
3156 /* 8.3.110: SINGLE CHARACTER INTRODUCER */ 2688 /* 8.3.110: SINGLE CHARACTER INTRODUCER */
3157 case C1_SCI: /* ESC Z */ 2689 case C1_SCI: /* ESC Z */
3158 tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); 2690 tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1);
3159 break; /* steal obsolete ESC [ c */ 2691 break; /* steal obsolete ESC [ c */
3160 2692
3161 /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ 2693 /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */
3162 case C1_CSI: /* ESC [ */ 2694 case C1_CSI: /* ESC [ */
3163 process_csi_seq (); 2695 process_csi_seq ();
3164 break; 2696 break;
3165 2697
3166 /* 8.3.90: OPERATING SYSTEM COMMAND */ 2698 /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */
3167 case C1_OSC: /* ESC ] */ 2699 case C1_OSC: /* ESC ] */
3168 process_osc_seq (); 2700 process_osc_seq ();
3169 break; 2701 break;
3170 2702
3171 /* 8.3.106: RESET TO INITIAL STATE */ 2703 /* 8.3.106: RESET TO INITIAL STATE (RIS) */
3172 case 'c': 2704 case 'c':
3173 mbstate.reset (); 2705 mbstate.reset ();
3174 scr_poweron (); 2706 scr_poweron ();
3175 scrollbar_show (1); 2707 scrollBar.show (1);
3176 break; 2708 break;
3177 2709
3178 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ 2710 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */
3179 case 'n': 2711 case 'n':
3180 scr_charset_choose (2); 2712 scr_charset_choose (2);
3225rxvt_term::process_csi_seq () 2757rxvt_term::process_csi_seq ()
3226{ 2758{
3227 unicode_t ch, priv, i; 2759 unicode_t ch, priv, i;
3228 unsigned int nargs, p; 2760 unsigned int nargs, p;
3229 int n, ndef; 2761 int n, ndef;
3230 int arg[ESC_ARGS]; 2762 int arg[ESC_ARGS] = { };
3231 2763
3232 for (nargs = ESC_ARGS; nargs > 0;) 2764 nargs = 0;
3233 arg[--nargs] = 0;
3234 2765
3235 priv = 0; 2766 priv = 0;
3236 ch = cmd_getc (); 2767 ch = cmd_getc ();
3237 if (ch >= '<' && ch <= '?') 2768 if ((ch >= '<' && ch <= '?') || ch == '!')
2769 {
3238 { /* '<' '=' '>' '?' */ 2770 /* '<' '=' '>' '?' '!' */
3239 priv = ch; 2771 priv = ch;
3240 ch = cmd_getc (); 2772 ch = cmd_getc ();
3241 } 2773 }
3242 2774
3243 /* read any numerical arguments */ 2775 /* read any numerical arguments */
3282 switch (priv) 2814 switch (priv)
3283 { 2815 {
3284 case '>': 2816 case '>':
3285 if (ch == CSI_DA) /* secondary device attributes */ 2817 if (ch == CSI_DA) /* secondary device attributes */
3286 { 2818 {
3287 // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, 2819 // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt,
3288 // 'U' for rxvt-unicode != 7.[34] (where it was broken). 2820 // 'U' for rxvt-unicode != 7.[34] (where it was broken).
3289 // 2821 //
3290 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt 2822 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt
3291 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify 2823 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later
3292 // that we do not support xterm mouse reporting (should be 95 when we do). 2824 // versions.
3293 // 2825 //
3294 tt_printf ("\033[>%d;94;0c", 'U'); 2826 tt_printf ("\033[>%d;95;0c", 'U');
3295 } 2827 }
3296 break; 2828 break;
2829
3297 case '?': 2830 case '?':
3298 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2831 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
3299 process_terminal_mode (ch, priv, nargs, arg); 2832 process_terminal_mode (ch, priv, nargs, arg);
3300 break; 2833 break;
2834
2835 case '!':
2836 if (ch == CSI_70)
2837 {
2838 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */
2839 scr_soft_reset ();
2840
2841 static const int pm_h[] = { 7, 25 };
2842 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1049 };
2843
2844 process_terminal_mode ('h', 0, sizeof (pm_h) / sizeof (pm_h[0]), pm_h);
2845 process_terminal_mode ('l', 0, sizeof (pm_l) / sizeof (pm_l[0]), pm_l);
3301 } 2846 }
2847 break;
2848 }
2849
3302 return; 2850 return;
3303 } 2851 }
3304 2852
3305 switch (ch) 2853 switch (ch)
3306 { 2854 {
3426 break; 2974 break;
3427 case 6: /* CPR requested */ 2975 case 6: /* CPR requested */
3428 scr_report_position (); 2976 scr_report_position ();
3429 break; 2977 break;
3430 case 7: /* unofficial extension */ 2978 case 7: /* unofficial extension */
3431 if (OPTION (Opt_insecure)) 2979 if (option (Opt_insecure))
3432 tt_printf ("%-.250s\012", rs[Rs_display_name]); 2980 tt_printf ("%-.250s\012", rs[Rs_display_name]);
3433 break; 2981 break;
3434 case 8: /* unofficial extension */ 2982 case 8: /* unofficial extension */
3435 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); 2983 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
3436 break; 2984 break;
3529{ 3077{
3530 int x, y; 3078 int x, y;
3531 XWindowAttributes wattr; 3079 XWindowAttributes wattr;
3532 Window wdummy; 3080 Window wdummy;
3533 3081
3534 dLocal (Display *, xdisp); 3082 dLocal (Display *, dpy);
3535 3083
3536 if (nargs == 0) 3084 if (nargs == 0)
3537 return; 3085 return;
3538 3086
3539 switch (args[0]) 3087 switch (args[0])
3540 { 3088 {
3541 /* 3089 /*
3542 * commands 3090 * commands
3543 */ 3091 */
3544 case 1: /* deiconify window */ 3092 case 1: /* deiconify window */
3545 XMapWindow (xdisp, parent[0]); 3093 XMapWindow (dpy, parent[0]);
3546 break; 3094 break;
3547 case 2: /* iconify window */ 3095 case 2: /* iconify window */
3548 XIconifyWindow (xdisp, parent[0], display->screen); 3096 XIconifyWindow (dpy, parent[0], display->screen);
3549 break; 3097 break;
3550 case 3: /* set position (pixels) */ 3098 case 3: /* set position (pixels) */
3551 XMoveWindow (xdisp, parent[0], args[1], args[2]); 3099 XMoveWindow (dpy, parent[0], args[1], args[2]);
3552 break; 3100 break;
3553 case 4: /* set size (pixels) */ 3101 case 4: /* set size (pixels) */
3554 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); 3102 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
3555 break; 3103 break;
3556 case 5: /* raise window */ 3104 case 5: /* raise window */
3557 XRaiseWindow (xdisp, parent[0]); 3105 XRaiseWindow (dpy, parent[0]);
3558 break; 3106 break;
3559 case 6: /* lower window */ 3107 case 6: /* lower window */
3560 XLowerWindow (xdisp, parent[0]); 3108 XLowerWindow (dpy, parent[0]);
3561 break; 3109 break;
3562 case 7: /* refresh window */ 3110 case 7: /* refresh window */
3563 scr_touch (true); 3111 scr_touch (true);
3564 break; 3112 break;
3565 case 8: /* set size (chars) */ 3113 case 8: /* set size (chars) */
3576 3124
3577 /* 3125 /*
3578 * reports - some output format copied from XTerm 3126 * reports - some output format copied from XTerm
3579 */ 3127 */
3580 case 11: /* report window state */ 3128 case 11: /* report window state */
3581 XGetWindowAttributes (xdisp, parent[0], &wattr); 3129 XGetWindowAttributes (dpy, parent[0], &wattr);
3582 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 3130 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
3583 break; 3131 break;
3584 case 13: /* report window position */ 3132 case 13: /* report window position */
3585 XGetWindowAttributes (xdisp, parent[0], &wattr); 3133 XGetWindowAttributes (dpy, parent[0], &wattr);
3586 XTranslateCoordinates (xdisp, parent[0], wattr.root, 3134 XTranslateCoordinates (dpy, parent[0], wattr.root,
3587 -wattr.border_width, -wattr.border_width, 3135 -wattr.border_width, -wattr.border_width,
3588 &x, &y, &wdummy); 3136 &x, &y, &wdummy);
3589 tt_printf ("\033[3;%d;%dt", x, y); 3137 tt_printf ("\033[3;%d;%dt", x, y);
3590 break; 3138 break;
3591 case 14: /* report window size (pixels) */ 3139 case 14: /* report window size (pixels) */
3592 XGetWindowAttributes (xdisp, parent[0], &wattr); 3140 XGetWindowAttributes (dpy, parent[0], &wattr);
3593 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 3141 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
3594 break; 3142 break;
3595 case 18: /* report text area size (chars) */ 3143 case 18: /* report text area size (chars) */
3596 tt_printf ("\033[8;%d;%dt", nrow, ncol); 3144 tt_printf ("\033[8;%d;%dt", nrow, ncol);
3597 break; 3145 break;
3599 tt_printf ("\033[9;%d;%dt", nrow, ncol); 3147 tt_printf ("\033[9;%d;%dt", nrow, ncol);
3600 break; 3148 break;
3601 case 20: /* report icon label */ 3149 case 20: /* report icon label */
3602 { 3150 {
3603 char *s; 3151 char *s;
3604 XGetIconName (xdisp, parent[0], &s); 3152 XGetIconName (dpy, parent[0], &s);
3605 tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ 3153 tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */
3606 XFree (s); 3154 XFree (s);
3607 } 3155 }
3608 break; 3156 break;
3609 case 21: /* report window title */ 3157 case 21: /* report window title */
3610 { 3158 {
3611 char *s; 3159 char *s;
3612 XFetchName (xdisp, parent[0], &s); 3160 XFetchName (dpy, parent[0], &s);
3613 tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ 3161 tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */
3614 XFree (s); 3162 XFree (s);
3615 } 3163 }
3616 break; 3164 break;
3617 } 3165 }
3618} 3166}
3645 seen_esc = true; 3193 seen_esc = true;
3646 continue; 3194 continue;
3647 } 3195 }
3648 else if (ch == C0_BEL || ch == CHAR_ST) 3196 else if (ch == C0_BEL || ch == CHAR_ST)
3649 break; 3197 break;
3198 else if (ch == C0_SYN)
3199 ch = cmd_get8 ();
3650 else if (ch < 0x20) 3200 else if (ch < 0x20)
3651 return NULL; /* other control character - exit */ 3201 return NULL; /* other control character - exit */
3652 3202
3653 seen_esc = false; 3203 seen_esc = false;
3654 3204
3655 if (n >= STRING_MAX - 1) 3205 if (n >= STRING_MAX - 1)
3656 // stop at some sane length 3206 // stop at some sane length
3657 return NULL; 3207 return NULL;
3658 3208
3659 if (ch == C0_SYN)
3660 string[n++] = cmd_get8 ();
3661 else
3662 string[n++] = ch; 3209 string[n++] = ch;
3663 } 3210 }
3664 3211
3665 string[n++] = '\0'; 3212 string[n++] = '\0';
3666 3213
3667 ends_how = (ch == 0x5c ? C0_ESC : ch); 3214 ends_how = (ch == 0x5c ? C0_ESC : ch);
3719rxvt_term::process_color_seq (int report, int color, const char *str, char resp) 3266rxvt_term::process_color_seq (int report, int color, const char *str, char resp)
3720{ 3267{
3721 if (str[0] == '?' && !str[1]) 3268 if (str[0] == '?' && !str[1])
3722 { 3269 {
3723 rgba c; 3270 rgba c;
3724 pix_colors_focused[color].get (this, c); 3271 pix_colors_focused[color].get (c);
3725 3272
3726#if XFT 3273#if XFT
3727 if (c.a != rgba::MAX_CC) 3274 if (c.a != rgba::MAX_CC)
3728 tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); 3275 tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp);
3729 else 3276 else
3743 int color; 3290 int color;
3744 char *buf, *name; 3291 char *buf, *name;
3745 bool query = str[0] == '?' && !str[1]; 3292 bool query = str[0] == '?' && !str[1];
3746 int saveop = op; 3293 int saveop = op;
3747 3294
3748 dLocal (Display *, xdisp); 3295 dLocal (Display *, dpy);
3749 3296
3750 assert (str != NULL); 3297 assert (str != NULL);
3298
3299 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END)))
3300 return;
3301
3751 switch (op) 3302 switch (op)
3752 { 3303 {
3753 case XTerm_name: 3304 case XTerm_name:
3754 set_title (str); 3305 set_title (str);
3755 /* FALLTHROUGH */ 3306 /* FALLTHROUGH */
3769 unsigned long bytes_after; 3320 unsigned long bytes_after;
3770 unsigned char *value = 0; 3321 unsigned char *value = 0;
3771 const char *str = ""; 3322 const char *str = "";
3772 3323
3773 if (prop 3324 if (prop
3774 && XGetWindowProperty (xdisp, parent[0], 3325 && XGetWindowProperty (dpy, parent[0],
3775 prop, 0, 1<<16, 0, AnyPropertyType, 3326 prop, 0, 1<<16, 0, AnyPropertyType,
3776 &actual_type, &actual_format, 3327 &actual_type, &actual_format,
3777 &nitems, &bytes_after, &value) == Success 3328 &nitems, &bytes_after, &value) == Success
3778 && actual_type != None 3329 && actual_type != None
3779 && actual_format == 8) 3330 && actual_format == 8)
3791 { 3342 {
3792 *eq = 0; 3343 *eq = 0;
3793 set_utf8_property (display->atom (str), eq + 1); 3344 set_utf8_property (display->atom (str), eq + 1);
3794 } 3345 }
3795 else 3346 else
3796 XDeleteProperty (xdisp, parent[0], 3347 XDeleteProperty (dpy, parent[0],
3797 display->atom (str)); 3348 display->atom (str));
3798 } 3349 }
3799 break; 3350 break;
3800 3351
3801 case XTerm_Color: 3352 case XTerm_Color:
3814 *buf++ = '\0'; 3365 *buf++ = '\0';
3815 3366
3816 process_color_seq (op, color, name, resp); 3367 process_color_seq (op, color, name, resp);
3817 } 3368 }
3818 break; 3369 break;
3370 case Rxvt_restoreFG:
3819 case XTerm_Color00: 3371 case XTerm_Color00:
3820 process_color_seq (op, Color_fg, str, resp); 3372 process_color_seq (op, Color_fg, str, resp);
3821 break; 3373 break;
3374 case Rxvt_restoreBG:
3822 case XTerm_Color01: 3375 case XTerm_Color01:
3823 process_color_seq (op, Color_bg, str, resp); 3376 process_color_seq (op, Color_bg, str, resp);
3824 break; 3377 break;
3825#ifndef NO_CURSORCOLOR 3378#ifndef NO_CURSORCOLOR
3826 case XTerm_Color_cursor: 3379 case XTerm_Color_cursor:
3847 break; 3400 break;
3848 case URxvt_Color_IT: 3401 case URxvt_Color_IT:
3849 process_color_seq (op, Color_IT, str, resp); 3402 process_color_seq (op, Color_IT, str, resp);
3850 break; 3403 break;
3851#endif 3404#endif
3852#if TRANSPARENT && TINTING 3405 case URxvt_Color_border:
3406 process_color_seq (op, Color_border, str, resp);
3407 break;
3408#if ENABLE_TRANSPARENCY
3853 case URxvt_Color_tint: 3409 case URxvt_Color_tint:
3854 process_color_seq (op, Color_tint, str, resp); 3410 process_color_seq (op, Color_tint, str, resp);
3411 {
3412 bool changed = false;
3855 3413
3856 check_our_parents (); 3414 if (ISSET_PIXCOLOR (Color_tint))
3415 changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]);
3416 else
3417 changed = bgPixmap.unset_tint ();
3857 3418
3858 if (am_transparent) 3419 if (changed)
3859 want_full_refresh = want_refresh = 1; 3420 update_background ();
3421 }
3860 3422
3861 break; 3423 break;
3862#endif 3424#endif
3863 3425
3426#if BG_IMAGE_FROM_FILE
3864 case Rxvt_Pixmap: 3427 case Rxvt_Pixmap:
3865 { 3428 if (!strcmp (str, "?"))
3866 if (*str != ';')
3867 { 3429 {
3868#if XPM_BACKGROUND 3430 char str[256];
3869 scale_pixmap (""); /* reset to default scaling */ 3431
3870 set_bgPixmap (str); /* change pixmap */ 3432 sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */
3871 scr_touch (true); 3433 min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767),
3872#endif 3434 min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767));
3435 process_xterm_seq (XTerm_title, str, CHAR_ST);
3873 } 3436 }
3874 3437 else
3438 {
3875 int changed = 0; 3439 int changed = 0;
3876 3440
3877 while ((str = strchr (str, ';')) != NULL) 3441 if (*str != ';')
3878 { 3442 {
3443 /* reset to default scaling :*/
3444 bgPixmap.unset_geometry ();
3445 if (bgPixmap.set_file (str)) /* change pixmap */
3446 changed++;
3447 str = strchr (str, ';');
3448 if (str == NULL)
3449 bgPixmap.set_defaultGeometry ();
3450 }
3451
3452 while (str)
3453 {
3879 str++; 3454 str++;
3880#if XPM_BACKGROUND 3455 if (bgPixmap.set_geometry (str))
3881 changed += scale_pixmap (str); 3456 changed++;
3882#endif 3457 str = strchr (str, ';');
3883 } 3458 }
3884 3459
3885 if (changed) 3460 if (changed)
3886 { 3461 update_background ();
3887#ifdef XPM_BACKGROUND
3888 resize_pixmap ();
3889 scr_touch (true);
3890#endif
3891 } 3462 }
3892 }
3893 break; 3463 break;
3894 3464#endif
3895 case Rxvt_restoreFG:
3896 set_window_color (Color_fg, str);
3897 break;
3898 case Rxvt_restoreBG:
3899 set_window_color (Color_bg, str);
3900 break;
3901 3465
3902 case XTerm_logfile: 3466 case XTerm_logfile:
3903 // TODO, when secure mode? 3467 // TODO, when secure mode?
3904 break; 3468 break;
3905 3469
3923 case URxvt_italicFont: 3487 case URxvt_italicFont:
3924 case URxvt_boldItalicFont: 3488 case URxvt_boldItalicFont:
3925#endif 3489#endif
3926 if (query) 3490 if (query)
3927 tt_printf ("\33]%d;%-.250s%c", saveop, 3491 tt_printf ("\33]%d;%-.250s%c", saveop,
3928 OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc 3492 option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc
3929 ? fontset[op - URxvt_font]->fontdesc : "", 3493 ? fontset[op - URxvt_font]->fontdesc : "",
3930 resp); 3494 resp);
3931 else 3495 else
3932 { 3496 {
3933 const char *&res = rs[Rs_font + (op - URxvt_font)]; 3497 const char *&res = rs[Rs_font + (op - URxvt_font)];
3947 break; 3511 break;
3948 3512
3949#if !ENABLE_MINIMAL 3513#if !ENABLE_MINIMAL
3950 case URxvt_locale: 3514 case URxvt_locale:
3951 if (query) 3515 if (query)
3952 tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); 3516 tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp);
3953 else 3517 else
3954 { 3518 {
3955 set_locale (str); 3519 set_locale (str);
3956 pty->set_utf8_mode (enc_utf8); 3520 pty->set_utf8_mode (enc_utf8);
3957 init_xlocale (); 3521 init_xlocale ();
3972 break; 3536 break;
3973#endif 3537#endif
3974 3538
3975#if ENABLE_PERL 3539#if ENABLE_PERL
3976 case URxvt_perl: 3540 case URxvt_perl:
3977 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) 3541 HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END));
3978 ; // no responses yet
3979 break; 3542 break;
3980#endif 3543#endif
3981 } 3544 }
3982} 3545}
3983/*----------------------------------------------------------------------*/ 3546/*----------------------------------------------------------------------*/
4006 { 3569 {
4007 if (mode == 'r') 3570 if (mode == 'r')
4008 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ 3571 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */
4009 else 3572 else
4010 state = (mode == 't') ? ! (priv_modes & bit) : mode; 3573 state = (mode == 't') ? ! (priv_modes & bit) : mode;
4011 PrivMode (state, bit); 3574 set_privmode (bit, state);
4012 } 3575 }
4013 3576
4014 return state; 3577 return state;
4015} 3578}
4016 3579
4020{ 3583{
4021 unsigned int i, j; 3584 unsigned int i, j;
4022 int state; 3585 int state;
4023 3586
4024 static const struct 3587 static const struct
4025 { 3588 {
4026 const int argval; 3589 const int argval;
4027 const unsigned long bit; 3590 const unsigned long bit;
4028 }
4029
4030 argtopriv[] = { 3591 } argtopriv[] = {
4031 { 1, PrivMode_aplCUR }, 3592 { 1, PrivMode_aplCUR }, // DECCKM
4032 { 2, PrivMode_vt52 }, 3593 { 2, PrivMode_vt52 },
4033 { 3, PrivMode_132 }, 3594 { 3, PrivMode_132 }, // DECCOLM
4034 { 4, PrivMode_smoothScroll }, 3595 { 4, PrivMode_smoothScroll }, // DECSCLM
4035 { 5, PrivMode_rVideo }, 3596 { 5, PrivMode_rVideo }, // DECSCNM
4036 { 6, PrivMode_relOrigin }, 3597 { 6, PrivMode_relOrigin }, // DECOM
4037 { 7, PrivMode_Autowrap }, 3598 { 7, PrivMode_Autowrap }, // DECAWM
4038 // 8, bi-directional support mode 3599 // 8, auto-repeat keys // DECARM
4039 { 9, PrivMode_MouseX10 }, 3600 { 9, PrivMode_MouseX10 },
4040 // 18, 19 printing-related 3601 // 18 end FF to printer after print screen
3602 // 19 Print screen prints full screen/scorll region
4041 { 25, PrivMode_VisibleCursor }, 3603 { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis
4042#ifdef scrollBar_esc 3604#ifdef scrollBar_esc
4043 { scrollBar_esc, PrivMode_scrollBar }, 3605 { scrollBar_esc, PrivMode_scrollBar },
4044#endif 3606#endif
4045 { 35, PrivMode_ShiftKeys }, // rxvt extension 3607 { 35, PrivMode_ShiftKeys }, // rxvt extension
3608 // 38, tektronix mode // DECTEK
4046 { 40, PrivMode_132OK }, 3609 { 40, PrivMode_132OK },
4047 // 41 xterm more fixes NYI 3610 // 41 xterm more fixes NYI
4048 // 45 margin bell NYI 3611 // 45 margin bell NYI
4049 // 46 start logging 3612 // 46 start logging
4050 { 47, PrivMode_Screen }, 3613 { 47, PrivMode_Screen },
4051 { 66, PrivMode_aplKP }, 3614 { 66, PrivMode_aplKP }, // DECPAM/DECPNM
4052#ifndef NO_BACKSPACE_KEY 3615#ifndef NO_BACKSPACE_KEY
4053 { 67, PrivMode_BackSpace }, 3616 { 67, PrivMode_BackSpace }, // DECBKM
4054#endif 3617#endif
4055 { 1000, PrivMode_MouseX11 }, 3618 { 1000, PrivMode_MouseX11 },
4056 // 1001 Use Hilite Mouse Tracking. NYI, TODO 3619 { 1002, PrivMode_MouseBtnEvent },
4057 // 1002 Use Cell Motion Mouse Tracking. NYI, TODO 3620 { 1003, PrivMode_MouseAnyEvent },
4058 // 1003 Use All Motion Mouse Tracking. NYI, TODO
4059 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3621 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
4060 { 1011, PrivMode_Keypress }, // rxvt extension 3622 { 1011, PrivMode_Keypress }, // rxvt extension
4061 // 1035 enable modifiers for alt, numlock NYI 3623 // 1035 enable modifiers for alt, numlock NYI
4062 // 1036 send ESC for meta keys NYI 3624 // 1036 send ESC for meta keys NYI
4063 // 1037 send DEL for keypad delete NYI 3625 // 1037 send DEL for keypad delete NYI
4064 { 1047, PrivMode_Screen }, 3626 { 1047, PrivMode_Screen },
4065 // 1048 save and restore cursor 3627 // 1048 save and restore cursor
4066 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ 3628 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
4067 // 1051, 1052, 1060, 1061 keyboard emulation NYI 3629 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3630 { 2004, PrivMode_BracketPaste },
4068 }; 3631 };
4069 3632
4070 if (nargs == 0) 3633 if (nargs == 0)
4071 return; 3634 return;
4072 3635
4098 scr_touch (true); 3661 scr_touch (true);
4099 break; 3662 break;
4100#endif 3663#endif
4101 case 1048: /* alternative cursor save */ 3664 case 1048: /* alternative cursor save */
4102 case 1049: 3665 case 1049:
4103 if (OPTION (Opt_secondaryScreen)) 3666 if (option (Opt_secondaryScreen))
4104 if (mode == 0) 3667 if (mode == 0)
4105 scr_cursor (RESTORE); 3668 scr_cursor (RESTORE);
4106 else if (mode == 1) 3669 else if (mode == 1)
4107 scr_cursor (SAVE); 3670 scr_cursor (SAVE);
4108 break; 3671 break;
4116 case 2: /* VT52 mode */ 3679 case 2: /* VT52 mode */
4117 /* oddball mode. should be set regardless of set/reset 3680 /* oddball mode. should be set regardless of set/reset
4118 * parameter. Return from VT52 mode with an ESC < from 3681 * parameter. Return from VT52 mode with an ESC < from
4119 * within VT52 mode 3682 * within VT52 mode
4120 */ 3683 */
4121 PrivMode (1, PrivMode_vt52); 3684 set_privmode (PrivMode_vt52, 1);
4122 break; 3685 break;
4123 case 3: /* 80/132 */ 3686 case 3: /* 80/132 */
4124 if (priv_modes & PrivMode_132OK) 3687 if (priv_modes & PrivMode_132OK)
4125 set_widthheight (((state ? 132 : 80) * fwidth), height); 3688 set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight);
4126 break; 3689 break;
4127 case 4: /* smooth scrolling */ 3690 case 4: /* smooth scrolling */
4128 set_option (Opt_jumpScroll, !state); 3691 set_option (Opt_jumpScroll, !state);
4129 break; 3692 break;
4130 case 5: /* reverse video */ 3693 case 5: /* reverse video */
4137 scr_autowrap (state); 3700 scr_autowrap (state);
4138 break; 3701 break;
4139 /* case 8: - auto repeat, can't do on a per window basis */ 3702 /* case 8: - auto repeat, can't do on a per window basis */
4140 case 9: /* X10 mouse reporting */ 3703 case 9: /* X10 mouse reporting */
4141 if (state) /* orthogonal */ 3704 if (state) /* orthogonal */
4142 priv_modes &= ~PrivMode_MouseX11; 3705 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
4143 break; 3706 break;
4144#ifdef scrollBar_esc 3707#ifdef scrollBar_esc
4145 case scrollBar_esc: 3708 case scrollBar_esc:
4146 if (scrollbar_mapping (state)) 3709 if (scrollBar.map (state))
4147 { 3710 {
4148 resize_all_windows (0, 0, 0); 3711 resize_all_windows (0, 0, 0);
4149 scr_touch (true); 3712 scr_touch (true);
4150 } 3713 }
4151 break; 3714 break;
4160 break; 3723 break;
4161 /* case 66: - application key pad */ 3724 /* case 66: - application key pad */
4162 /* case 67: - backspace key */ 3725 /* case 67: - backspace key */
4163 case 1000: /* X11 mouse reporting */ 3726 case 1000: /* X11 mouse reporting */
4164 if (state) /* orthogonal */ 3727 if (state) /* orthogonal */
4165 priv_modes &= ~PrivMode_MouseX10; 3728 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
4166 break; 3729 break;
4167#if 0
4168 case 1001: 3730 case 1002:
4169 break; /* X11 mouse highlighting */ 3731 case 1003:
4170#endif 3732 if (state)
3733 {
3734 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
3735 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3736 vt_emask_mouse = PointerMotionMask;
3737 }
3738 else
3739 vt_emask_mouse = NoEventMask;
3740
3741 vt_select_input ();
3742 break;
4171 case 1010: /* scroll to bottom on TTY output inhibit */ 3743 case 1010: /* scroll to bottom on TTY output inhibit */
4172 set_option (Opt_scrollTtyOutput, !state); 3744 set_option (Opt_scrollTtyOutput, !state);
4173 break; 3745 break;
4174 case 1011: /* scroll to bottom on key press */ 3746 case 1011: /* scroll to bottom on key press */
4175 set_option (Opt_scrollTtyKeypress, state); 3747 set_option (Opt_scrollTtyKeypress, state);
4176 break; 3748 break;
4177 case 1047: /* secondary screen w/ clearing last */ 3749 case 1047: /* secondary screen w/ clearing last */
4178 if (OPTION (Opt_secondaryScreen)) 3750 if (option (Opt_secondaryScreen))
4179 if (current_screen != PRIMARY) 3751 if (current_screen != PRIMARY)
4180 scr_erase_screen (2); 3752 scr_erase_screen (2);
3753
4181 scr_change_screen (state); 3754 scr_change_screen (state);
4182 break; 3755 break;
4183 case 1049: /* secondary screen w/ clearing first */ 3756 case 1049: /* secondary screen w/ clearing first */
4184 scr_change_screen (state); 3757 scr_change_screen (state);
4185 if (OPTION (Opt_secondaryScreen)) 3758 if (option (Opt_secondaryScreen))
4186 if (current_screen != PRIMARY) 3759 if (current_screen != PRIMARY)
4187 scr_erase_screen (2); 3760 scr_erase_screen (2);
4188 break; 3761 break;
4189 default: 3762 default:
4190 break; 3763 break;
4352rxvt_term::process_graphics () 3925rxvt_term::process_graphics ()
4353{ 3926{
4354 unicode_t ch, cmd = cmd_getc (); 3927 unicode_t ch, cmd = cmd_getc ();
4355 3928
4356 if (cmd == 'Q') 3929 if (cmd == 'Q')
3930 {
4357 { /* query graphics */ 3931 /* query graphics */
4358 tt_printf ("\033G0\012"); /* no graphics */ 3932 tt_printf ("\033G0\012"); /* no graphics */
4359 return; 3933 return;
4360 } 3934 }
4361 /* swallow other graphics sequences until terminating ':' */ 3935 /* swallow other graphics sequences until terminating ':' */
4362 do 3936 do
4412 v_buffer = (char *)realloc (v_buffer, v_buflen + len); 3986 v_buffer = (char *)realloc (v_buffer, v_buflen + len);
4413 3987
4414 memcpy (v_buffer + v_buflen, data, len); 3988 memcpy (v_buffer + v_buflen, data, len);
4415 v_buflen += len; 3989 v_buflen += len;
4416 3990
4417 pty_ev.set (EVENT_READ | EVENT_WRITE); 3991 pty_ev.set (ev::READ | ev::WRITE);
4418} 3992}
4419 3993
4420void rxvt_term::pty_write () 3994void rxvt_term::pty_write ()
4421{ 3995{
4422 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); 3996 int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE));
4427 4001
4428 if (v_buflen == 0) 4002 if (v_buflen == 0)
4429 { 4003 {
4430 free (v_buffer); 4004 free (v_buffer);
4431 v_buffer = 0; 4005 v_buffer = 0;
4432 v_buflen = 0;
4433 4006
4434 pty_ev.set (EVENT_READ); 4007 pty_ev.set (ev::READ);
4435 return; 4008 return;
4436 } 4009 }
4437 4010
4438 memmove (v_buffer, v_buffer + written, v_buflen); 4011 memmove (v_buffer, v_buffer + written, v_buflen);
4439 } 4012 }
4440 else if (written != -1 || (errno != EAGAIN && errno != EINTR)) 4013 else if (written != -1 || (errno != EAGAIN && errno != EINTR))
4441 pty_ev.set (EVENT_READ); 4014 pty_ev.set (ev::READ);
4442} 4015}
4443 4016
4444/*----------------------- end-of-file (C source) -----------------------*/ 4017/*----------------------- end-of-file (C source) -----------------------*/
4445 4018

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines