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.323 by ayin, Mon May 28 18:38:03 2007 UTC vs.
Revision 1.361 by ayin, Wed Oct 31 09:55:23 2007 UTC

95 XK_Shift_L, 0x21e7, 95 XK_Shift_L, 0x21e7,
96 XK_Shift_R, 0x21e7, 96 XK_Shift_R, 0x21e7,
97 97
98 XK_Shift_Lock, 0x21eb, 98 XK_Shift_Lock, 0x21eb,
99 XK_ISO_Lock, 0x21eb, 99 XK_ISO_Lock, 0x21eb,
100 XK_ISO_Lock, 0x21eb,
101 XK_Caps_Lock, 0x21ec, 100 XK_Caps_Lock, 0x21ec,
102 XK_Num_Lock, 0x21ed, 101 XK_Num_Lock, 0x21ed,
103 XK_ISO_Level3_Shift, 0x21ee, 102 XK_ISO_Level3_Shift, 0x21ee,
104 XK_ISO_Level3_Lock, 0x21ef, 103 XK_ISO_Level3_Lock, 0x21ef,
105 XK_ISO_Group_Lock, 0x21f0, 104 XK_ISO_Group_Lock, 0x21f0,
519# endif 518# endif
520 return; 519 return;
521 } 520 }
522 else 521 else
523 { 522 {
524# if ENABLE_OVERLAY 523# if ISO_14755
525 scr_overlay_off (); 524 scr_overlay_off ();
526# endif 525# endif
527 iso14755buf = 0; 526 iso14755buf = 0;
528 } 527 }
529 } 528 }
530 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) 529 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
531 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) 530 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))
532 if (!(iso14755buf & ISO_14755_STARTED)) 531 if (!(iso14755buf & ISO_14755_STARTED))
533 { 532 {
534 iso14755buf |= ISO_14755_STARTED; 533 iso14755buf |= ISO_14755_STARTED;
535# if ENABLE_OVERLAY 534# if ISO_14755
536 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); 535 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1);
537 scr_overlay_set (0, 0, "ISO 14755 mode"); 536 scr_overlay_set (0, 0, "ISO 14755 mode");
538# endif 537# endif
539 } 538 }
540#endif 539#endif
541 540
542#ifdef PRINTPIPE 541#ifdef PRINTPIPE
543 if (keysym == XK_Print) 542 if (keysym == XK_Print)
544 { 543 {
545 scr_printscreen (ctrl | shft); 544 scr_printscreen (ctrl | shft);
546 return; 545 return;
548#endif 547#endif
549 548
550 if (keysym >= 0xFF00 && keysym <= 0xFFFF) 549 if (keysym >= 0xFF00 && keysym <= 0xFFFF)
551 { 550 {
552 { 551 {
552 bool kp = priv_modes & PrivMode_aplKP ? !shft : shft;
553 newlen = 1; 553 newlen = 1;
554 switch (keysym) 554 switch (keysym)
555 { 555 {
556#ifndef NO_BACKSPACE_KEY 556#ifndef NO_BACKSPACE_KEY
557 case XK_BackSpace: 557 case XK_BackSpace:
560 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) 560 kbuf[0] = (!! (priv_modes & PrivMode_BackSpace)
561 ^ !!ctrl) ? '\b' : '\177'; 561 ^ !!ctrl) ? '\b' : '\177';
562 kbuf[1] = '\0'; 562 kbuf[1] = '\0';
563 } 563 }
564 else 564 else
565 strcpy (kbuf, key_backspace); 565 strcpy (kbuf, rs[Rs_backspace_key]);
566 break; 566 break;
567#endif 567#endif
568#ifndef NO_DELETE_KEY 568#ifndef NO_DELETE_KEY
569# ifdef XK_KP_Prior 569# ifdef XK_KP_Delete
570 case XK_KP_Delete: 570 case XK_KP_Delete:
571 /* allow shift to override */ 571 /* allow shift to override */
572 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 572 if (kp)
573 { 573 {
574 strcpy (kbuf, "\033On"); 574 strcpy (kbuf, "\033On");
575 break; 575 break;
576 } 576 }
577 /* FALLTHROUGH */ 577 /* FALLTHROUGH */
578# endif 578# endif
579 case XK_Delete: 579 case XK_Delete:
580 strcpy (kbuf, key_delete); 580 strcpy (kbuf, rs[Rs_delete_key]);
581 break; 581 break;
582#endif 582#endif
583 case XK_Tab: 583 case XK_Tab:
584 if (shft) 584 if (shft)
585 strcpy (kbuf, "\033[Z"); 585 strcpy (kbuf, "\033[Z");
600#ifdef XK_KP_Left 600#ifdef XK_KP_Left
601 case XK_KP_Up: /* \033Ox or standard */ 601 case XK_KP_Up: /* \033Ox or standard */
602 case XK_KP_Down: /* \033Or or standard */ 602 case XK_KP_Down: /* \033Or or standard */
603 case XK_KP_Right: /* \033Ov or standard */ 603 case XK_KP_Right: /* \033Ov or standard */
604 case XK_KP_Left: /* \033Ot or standard */ 604 case XK_KP_Left: /* \033Ot or standard */
605 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 605 if (kp)
606 { 606 {
607 strcpy (kbuf, "\033OZ"); 607 strcpy (kbuf, "\033OZ");
608 kbuf[2] = "txvr"[keysym - XK_KP_Left]; 608 kbuf[2] = "txvr"[keysym - XK_KP_Left];
609 break; 609 break;
610 } 610 }
633 633
634#ifndef UNSHIFTED_SCROLLKEYS 634#ifndef UNSHIFTED_SCROLLKEYS
635# ifdef XK_KP_Prior 635# ifdef XK_KP_Prior
636 case XK_KP_Prior: 636 case XK_KP_Prior:
637 /* allow shift to override */ 637 /* allow shift to override */
638 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 638 if (kp)
639 { 639 {
640 strcpy (kbuf, "\033Oy"); 640 strcpy (kbuf, "\033Oy");
641 break; 641 break;
642 } 642 }
643 /* FALLTHROUGH */ 643 /* FALLTHROUGH */
646 strcpy (kbuf, "\033[5~"); 646 strcpy (kbuf, "\033[5~");
647 break; 647 break;
648# ifdef XK_KP_Next 648# ifdef XK_KP_Next
649 case XK_KP_Next: 649 case XK_KP_Next:
650 /* allow shift to override */ 650 /* allow shift to override */
651 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 651 if (kp)
652 { 652 {
653 strcpy (kbuf, "\033Os"); 653 strcpy (kbuf, "\033Os");
654 break; 654 break;
655 } 655 }
656 /* FALLTHROUGH */ 656 /* FALLTHROUGH */
659 strcpy (kbuf, "\033[6~"); 659 strcpy (kbuf, "\033[6~");
660 break; 660 break;
661#endif 661#endif
662 case XK_KP_Enter: 662 case XK_KP_Enter:
663 /* allow shift to override */ 663 /* allow shift to override */
664 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 664 if (kp)
665 { 665 {
666 strcpy (kbuf, "\033OM"); 666 strcpy (kbuf, "\033OM");
667 break; 667 break;
668 } 668 }
669 669
712 case XK_KP_6: /* "\033Ov" : "6" */ 712 case XK_KP_6: /* "\033Ov" : "6" */
713 case XK_KP_7: /* "\033Ow" : "7" */ 713 case XK_KP_7: /* "\033Ow" : "7" */
714 case XK_KP_8: /* "\033Ox" : "8" */ 714 case XK_KP_8: /* "\033Ox" : "8" */
715 case XK_KP_9: /* "\033Oy" : "9" */ 715 case XK_KP_9: /* "\033Oy" : "9" */
716 /* allow shift to override */ 716 /* allow shift to override */
717 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 717 if (kp)
718 { 718 {
719 strcpy (kbuf, "\033Oj"); 719 strcpy (kbuf, "\033Oj");
720 kbuf[2] += (keysym - XK_KP_Multiply); 720 kbuf[2] += (keysym - XK_KP_Multiply);
721 } 721 }
722 else 722 else
728 728
729 case XK_Find: 729 case XK_Find:
730 strcpy (kbuf, "\033[1~"); 730 strcpy (kbuf, "\033[1~");
731 break; 731 break;
732 732
733#ifdef XK_KP_End 733#ifdef XK_KP_Insert
734 case XK_KP_Insert: 734 case XK_KP_Insert:
735 /* allow shift to override */ 735 /* allow shift to override */
736 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 736 if (kp)
737 { 737 {
738 strcpy (kbuf, "\033Op"); 738 strcpy (kbuf, "\033Op");
739 break; 739 break;
740 } 740 }
741 /* FALLTHROUGH */ 741 /* FALLTHROUGH */
754 strcpy (kbuf, "\033[4~"); 754 strcpy (kbuf, "\033[4~");
755 break; 755 break;
756#ifdef XK_KP_End 756#ifdef XK_KP_End
757 case XK_KP_End: 757 case XK_KP_End:
758 /* allow shift to override */ 758 /* allow shift to override */
759 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 759 if (kp)
760 { 760 {
761 strcpy (kbuf, "\033Oq"); 761 strcpy (kbuf, "\033Oq");
762 break; 762 break;
763 } 763 }
764 /* FALLTHROUGH */ 764 /* FALLTHROUGH */
767 strcpy (kbuf, KS_END); 767 strcpy (kbuf, KS_END);
768 break; 768 break;
769#ifdef XK_KP_Home 769#ifdef XK_KP_Home
770 case XK_KP_Home: 770 case XK_KP_Home:
771 /* allow shift to override */ 771 /* allow shift to override */
772 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 772 if (kp)
773 { 773 {
774 strcpy (kbuf, "\033Ow"); 774 strcpy (kbuf, "\033Ow");
775 break; 775 break;
776 } 776 }
777 /* FALLTHROUGH */ 777 /* FALLTHROUGH */
934#if ENABLE_FRILLS || ISO_14755 934#if ENABLE_FRILLS || ISO_14755
935 // ISO 14755 support 935 // ISO 14755 support
936 if (iso14755buf) 936 if (iso14755buf)
937 if (iso14755buf & ISO_14755_52) 937 if (iso14755buf & ISO_14755_52)
938 { 938 {
939# if ENABLE_OVERLAY 939# if ISO_14755
940 scr_overlay_off (); 940 scr_overlay_off ();
941# endif 941# endif
942# if ISO_14755 942# if ISO_14755
943 // iso14755 part 5.2 handling: release time 943 // iso14755 part 5.2 handling: release time
944 // first: controls 944 // first: controls
967 967
968 return; 968 return;
969 } 969 }
970 else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) 970 else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask))
971 { 971 {
972# if ENABLE_OVERLAY 972# if ISO_14755
973 scr_overlay_off (); 973 scr_overlay_off ();
974# endif 974# endif
975 if (iso14755buf & ISO_14755_51) 975 if (iso14755buf & ISO_14755_51)
976 commit_iso14755 (); 976 commit_iso14755 ();
977#if ISO_14755 977#if ISO_14755
978 else if (iso14755buf & ISO_14755_STARTED) 978 else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED)
979 { 979 {
980 iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair 980 iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair
981 981
982 scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); 982 scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1);
983 scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); 983 scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE");
1035void 1035void
1036rxvt_term::flush () 1036rxvt_term::flush ()
1037{ 1037{
1038 flush_ev.stop (); 1038 flush_ev.stop ();
1039 1039
1040#ifdef TRANSPARENT 1040#ifdef HAVE_BG_PIXMAP
1041 if (want_full_refresh) 1041 if (bgPixmap.check_clearChanged ())
1042 { 1042 {
1043 want_full_refresh = 0; 1043// scr_clear (true); This needs to be researched further!
1044 scr_clear ();
1045 scr_touch (false); 1044 scr_touch (false);
1046 } 1045 }
1047#endif 1046#endif
1048 1047
1049 if (want_refresh) 1048 if (want_refresh)
1110void 1109void
1111rxvt_term::flush_cb (time_watcher &w) 1110rxvt_term::flush_cb (time_watcher &w)
1112{ 1111{
1113 make_current (); 1112 make_current ();
1114 1113
1115 refresh_limit = 1;
1116 refresh_count = 0; 1114 refresh_count = 0;
1117 flush (); 1115 flush ();
1118} 1116}
1119 1117
1120#ifdef CURSOR_BLINK 1118#ifdef CURSOR_BLINK
1186 1184
1187#if LINUX_YIELD_HACK 1185#if LINUX_YIELD_HACK
1188static struct event_handler 1186static struct event_handler
1189{ 1187{
1190 check_watcher yield_ev; 1188 check_watcher yield_ev;
1191 1189
1192 void yield_cb (check_watcher &w) 1190 void yield_cb (check_watcher &w)
1193 { 1191 {
1194 // this should really be sched_yield(), but the linux guys thought 1192 // this should really be sched_yield(), but the linux guys thought
1195 // that giving a process calling sched_yield () less cpu time than 1193 // that giving a process calling sched_yield () less cpu time than
1196 // ones with high nice levels is a useful thing to do. It surely is is 1194 // ones with high nice levels is a useful thing to do. It surely is is
1243 pty_ev.stop (); 1241 pty_ev.stop ();
1244 1242
1245 if (!option (Opt_hold)) 1243 if (!option (Opt_hold))
1246 destroy (); 1244 destroy ();
1247 } 1245 }
1248 1246
1249 return false; 1247 return false;
1250} 1248}
1251 1249
1252void 1250void
1253rxvt_term::pty_cb (io_watcher &w, short revents) 1251rxvt_term::pty_cb (io_watcher &w, short revents)
1303void 1301void
1304rxvt_term::mouse_report (XButtonEvent &ev) 1302rxvt_term::mouse_report (XButtonEvent &ev)
1305{ 1303{
1306 int button_number, key_state = 0; 1304 int button_number, key_state = 0;
1307 int x, y; 1305 int x, y;
1306 int code = 32;
1308 1307
1309 x = ev.x; 1308 x = Pixel2Col (ev.x);
1310 y = ev.y; 1309 y = Pixel2Row (ev.y);
1311 pixel_position (&x, &y); 1310 if (ev.type == MotionNotify) {
1311 if (x == mouse_row && y == mouse_col)
1312 return;
1313 mouse_row = x;
1314 mouse_col = y;
1315 code += 32;
1316 }
1312 1317
1313 if (MEvent.button == AnyButton) 1318 if (MEvent.button == AnyButton)
1314 button_number = 3; 1319 button_number = 3;
1315 else 1320 else
1316 { 1321 {
1362 x + 1, 1367 x + 1,
1363 y + 1); 1368 y + 1);
1364#endif 1369#endif
1365 1370
1366 tt_printf ("\033[M%c%c%c", 1371 tt_printf ("\033[M%c%c%c",
1367 (32 + button_number + key_state), 1372 (code + button_number + key_state),
1368 (32 + x + 1), 1373 (32 + x + 1),
1369 (32 + y + 1)); 1374 (32 + y + 1));
1370} 1375}
1371 1376
1372/*{{{ process an X event */ 1377/*{{{ process an X event */
1434 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) 1439 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1435 focus_out (); 1440 focus_out ();
1436 } 1441 }
1437#endif 1442#endif
1438 } 1443 }
1439 break;
1440
1441 case MappingNotify:
1442 XRefreshKeyboardMapping (&ev.xmapping);
1443 break; 1444 break;
1444 1445
1445 /* 1446 /*
1446 * XXX: this is not the _current_ arrangement 1447 * XXX: this is not the _current_ arrangement
1447 * Here's my conclusion: 1448 * Here's my conclusion:
1480 && ev.xfocus.mode != NotifyGrab) 1481 && ev.xfocus.mode != NotifyGrab)
1481 focus_out (); 1482 focus_out ();
1482 break; 1483 break;
1483 1484
1484 case ConfigureNotify: 1485 case ConfigureNotify:
1486 /* fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n",
1487 ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y,
1488 szHint.width, szHint.height); */
1485 if (ev.xconfigure.window == parent[0]) 1489 if (ev.xconfigure.window == parent[0])
1486 { 1490 {
1487 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) 1491 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1488 ; 1492 ;
1489 1493
1490 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1494 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1491 { 1495 {
1492 seen_resize = 1; 1496 seen_resize = 1;
1493 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1497 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1494 } 1498 }
1495 1499 else
1500 {
1501#ifdef HAVE_BG_PIXMAP
1502 if (bgPixmap.window_position_sensitive ())
1503 update_background ();
1504#endif
1505 }
1496 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1506 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1497
1498#ifdef TRANSPARENT
1499 if (option (Opt_transparent))
1500 check_our_parents ();
1501#endif
1502 } 1507 }
1503 break; 1508 break;
1504 1509
1505 case PropertyNotify: 1510 case PropertyNotify:
1506 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) 1511 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END)))
1537 text_blink_ev.stop (); 1542 text_blink_ev.stop ();
1538#endif 1543#endif
1539 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1544 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1540 break; 1545 break;
1541 1546
1542#ifdef TRANSPARENT
1543 case ReparentNotify:
1544 rootwin_cb (ev);
1545 break;
1546#endif /* TRANSPARENT */
1547
1548 case GraphicsExpose: 1547 case GraphicsExpose:
1549 case Expose: 1548 case Expose:
1550 if (ev.xany.window == vt) 1549 if (ev.xany.window == vt)
1551 { 1550 {
1552 do 1551 do
1552 {
1553 scr_expose (ev.xexpose.x, ev.xexpose.y, 1553 scr_expose (ev.xexpose.x, ev.xexpose.y,
1554 ev.xexpose.width, ev.xexpose.height, False); 1554 ev.xexpose.width, ev.xexpose.height, False);
1555 }
1555 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); 1556 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev));
1556 1557
1557 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; 1558 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1558 1559
1559 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) 1560 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1561 {
1560 scr_expose (ev.xexpose.x, ev.xexpose.y, 1562 scr_expose (ev.xexpose.x, ev.xexpose.y,
1561 ev.xexpose.width, ev.xexpose.height, False); 1563 ev.xexpose.width, ev.xexpose.height, False);
1562 1564 }
1563 want_refresh = 1; 1565 want_refresh = 1;
1564 } 1566 }
1565 else 1567 else
1566 { 1568 {
1567 XEvent unused_event; 1569 XEvent unused_event;
1574 if (isScrollbarWindow (ev.xany.window)) 1576 if (isScrollbarWindow (ev.xany.window))
1575 { 1577 {
1576 scrollBar.setIdle (); 1578 scrollBar.setIdle ();
1577 scrollbar_show (0); 1579 scrollbar_show (0);
1578 } 1580 }
1579
1580#ifdef TRANSPARENT
1581 if (am_transparent && ev.xany.window == parent[0])
1582 XClearWindow (dpy, ev.xany.window);
1583#endif
1584 } 1581 }
1585 break; 1582 break;
1586 1583
1587 case MotionNotify: 1584 case MotionNotify:
1588#ifdef POINTER_BLANK 1585#ifdef POINTER_BLANK
1589 if (hidden_pointer) 1586 if (hidden_pointer)
1590 pointer_unblank (); 1587 pointer_unblank ();
1591#endif 1588#endif
1589 if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask))
1590 || priv_modes & PrivMode_MouseAnyEvent)
1591 mouse_report (ev.xbutton);
1592 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1592 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1593 break; 1593 break;
1594 1594
1595 if (ev.xany.window == vt) 1595 if (ev.xany.window == vt)
1596 { 1596 {
1686 &ev.xbutton.x, &ev.xbutton.y, 1686 &ev.xbutton.x, &ev.xbutton.y,
1687 &unused_mask); 1687 &unused_mask);
1688 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1688 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1689 scrollbar_size ()); 1689 scrollbar_size ());
1690 want_refresh = 1; 1690 want_refresh = 1;
1691 refresh_limit = 0;
1692 scrollbar_show (1); 1691 scrollbar_show (1);
1693 } 1692 }
1694 break; 1693 break;
1695 } 1694 }
1696 1695
1751 } 1750 }
1752#endif 1751#endif
1753#if ENABLE_FRILLS 1752#if ENABLE_FRILLS
1754 if (option (Opt_urgentOnBell)) 1753 if (option (Opt_urgentOnBell))
1755 { 1754 {
1756 XWMHints *h;
1757
1758 h = XGetWMHints(dpy, parent[0]); 1755 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1759 if (h != NULL)
1760 { 1756 {
1761 h->flags &= ~XUrgencyHint; 1757 h->flags &= ~XUrgencyHint;
1762 XSetWMHints(dpy, parent[0], h); 1758 XSetWMHints (dpy, parent[0], h);
1763 } 1759 }
1764 } 1760 }
1765#endif 1761#endif
1766 } 1762 }
1767} 1763}
1778 1774
1779#if ENABLE_FRILLS || ISO_14755 1775#if ENABLE_FRILLS || ISO_14755
1780 if (iso14755buf) 1776 if (iso14755buf)
1781 { 1777 {
1782 iso14755buf = 0; 1778 iso14755buf = 0;
1783# if ENABLE_OVERLAY 1779# if ISO_14755
1784 scr_overlay_off (); 1780 scr_overlay_off ();
1785# endif 1781# endif
1786 } 1782 }
1787#endif 1783#endif
1788#if USE_XIM 1784#if USE_XIM
1815 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); 1811 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c);
1816 } 1812 }
1817#endif 1813#endif
1818} 1814}
1819 1815
1820#if TRANSPARENT || ENABLE_PERL 1816#if ENABLE_TRANSPARENCY || ENABLE_PERL
1821void 1817void
1822rxvt_term::rootwin_cb (XEvent &ev) 1818rxvt_term::rootwin_cb (XEvent &ev)
1823{ 1819{
1824 make_current (); 1820 make_current ();
1825 1821
1826 if (SHOULD_INVOKE (HOOK_ROOT_EVENT) 1822 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1827 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) 1823 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END)))
1828 return; 1824 return;
1829 1825
1830# if TRANSPARENT 1826# if ENABLE_TRANSPARENCY
1831 switch (ev.type) 1827 switch (ev.type)
1832 { 1828 {
1833 case PropertyNotify: 1829 case PropertyNotify:
1834 /* 1830 /*
1835 * if user used some Esetroot compatible prog to set the root bg, 1831 * if user used some Esetroot compatible prog to set the root bg,
1836 * use the property to determine the pixmap. We use it later on. 1832 * use the property to determine the pixmap. We use it later on.
1837 */ 1833 */
1838 if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] 1834 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1839 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1835 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1840 return; 1836 {
1841 1837 bgPixmap.set_root_pixmap ();
1842 /* FALLTHROUGH */ 1838 update_background ();
1843 case ReparentNotify: 1839 }
1844 if (option (Opt_transparent) && check_our_parents () && am_transparent)
1845 want_refresh = want_full_refresh = 1;
1846 break; 1840 break;
1847 } 1841 }
1848# endif 1842# endif
1849} 1843}
1850#endif 1844#endif
2227#endif 2221#endif
2228 } 2222 }
2229 } 2223 }
2230} 2224}
2231 2225
2232#ifdef TRANSPARENT
2233#if TINTING
2234/* taken from aterm-0.4.2 */
2235
2236typedef uint32_t RUINT32T;
2237
2238void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm)
2239{
2240 int sh_r, sh_g, sh_b;
2241 RUINT32T mask_r, mask_g, mask_b;
2242 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
2243 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
2244 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
2245 int i;
2246
2247 Visual *visual = term->visual;
2248
2249 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
2250
2251 /* for convenience */
2252 mask_r = visual->red_mask;
2253 mask_g = visual->green_mask;
2254 mask_b = visual->blue_mask;
2255
2256 /* boring lookup table pre-initialization */
2257 switch (srcImage->bits_per_pixel) {
2258 case 15:
2259 if ((mask_r != 0x7c00) ||
2260 (mask_g != 0x03e0) ||
2261 (mask_b != 0x001f))
2262 return;
2263 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32));
2264 lookup_r = lookup;
2265 lookup_g = lookup+32;
2266 lookup_b = lookup+32+32;
2267 sh_r = 10;
2268 sh_g = 5;
2269 sh_b = 0;
2270 break;
2271 case 16:
2272 if ((mask_r != 0xf800) ||
2273 (mask_g != 0x07e0) ||
2274 (mask_b != 0x001f))
2275 return;
2276 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32));
2277 lookup_r = lookup;
2278 lookup_g = lookup+32;
2279 lookup_b = lookup+32+64;
2280 sh_r = 11;
2281 sh_g = 5;
2282 sh_b = 0;
2283 break;
2284 case 24:
2285 if ((mask_r != 0xff0000) ||
2286 (mask_g != 0x00ff00) ||
2287 (mask_b != 0x0000ff))
2288 return;
2289 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2290 lookup_r = lookup;
2291 lookup_g = lookup+256;
2292 lookup_b = lookup+256+256;
2293 sh_r = 16;
2294 sh_g = 8;
2295 sh_b = 0;
2296 break;
2297 case 32:
2298 if ((mask_r != 0xff0000) ||
2299 (mask_g != 0x00ff00) ||
2300 (mask_b != 0x0000ff))
2301 return;
2302 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2303 lookup_r = lookup;
2304 lookup_g = lookup+256;
2305 lookup_b = lookup+256+256;
2306 sh_r = 16;
2307 sh_g = 8;
2308 sh_b = 0;
2309 break;
2310 default:
2311 return; /* we do not support this color depth */
2312 }
2313
2314 /* prepare limits for color transformation (each channel is handled separately) */
2315 if (shade < 0) {
2316 shade = -shade;
2317 if (shade < 0) shade = 0;
2318 if (shade > 100) shade = 100;
2319
2320 lower_lim_r = 65535-rm;
2321 lower_lim_g = 65535-gm;
2322 lower_lim_b = 65535-bm;
2323
2324 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100);
2325 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
2326 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
2327
2328 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
2329 } else {
2330 if (shade < 0) shade = 0;
2331 if (shade > 100) shade = 100;
2332
2333 lower_lim_r = lower_lim_g = lower_lim_b = 0;
2334
2335 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
2336 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);
2337 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100);
2338 }
2339
2340 /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */
2341 if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 ))
2342 {
2343 unsigned int tmp;
2344
2345 tmp = lower_lim_r;
2346 lower_lim_r = lower_lim_b;
2347 lower_lim_b = tmp;
2348
2349 tmp = upper_lim_r;
2350 upper_lim_r = upper_lim_b;
2351 upper_lim_b = tmp;
2352 }
2353
2354 /* fill our lookup tables */
2355 for (i = 0; i <= mask_r>>sh_r; i++)
2356 {
2357 RUINT32T tmp;
2358 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r));
2359 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r);
2360 lookup_r[i] = (tmp/65535)<<sh_r;
2361 }
2362 for (i = 0; i <= mask_g>>sh_g; i++)
2363 {
2364 RUINT32T tmp;
2365 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g));
2366 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g);
2367 lookup_g[i] = (tmp/65535)<<sh_g;
2368 }
2369 for (i = 0; i <= mask_b>>sh_b; i++)
2370 {
2371 RUINT32T tmp;
2372 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b));
2373 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b);
2374 lookup_b[i] = (tmp/65535)<<sh_b;
2375 }
2376
2377 /* apply table to input image (replacing colors by newly calculated ones) */
2378 switch (srcImage->bits_per_pixel)
2379 {
2380 case 15:
2381 {
2382 unsigned short *p1, *pf, *p, *pl;
2383 p1 = (unsigned short *) srcImage->data;
2384 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2385 while (p1 < pf)
2386 {
2387 p = p1;
2388 pl = p1 + srcImage->width;
2389 for (; p < pl; p++)
2390 {
2391 *p = lookup_r[(*p & 0x7c00)>>10] |
2392 lookup_g[(*p & 0x03e0)>> 5] |
2393 lookup_b[(*p & 0x001f)];
2394 }
2395 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2396 }
2397 break;
2398 }
2399 case 16:
2400 {
2401 unsigned short *p1, *pf, *p, *pl;
2402 p1 = (unsigned short *) srcImage->data;
2403 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2404 while (p1 < pf)
2405 {
2406 p = p1;
2407 pl = p1 + srcImage->width;
2408 for (; p < pl; p++)
2409 {
2410 *p = lookup_r[(*p & 0xf800)>>11] |
2411 lookup_g[(*p & 0x07e0)>> 5] |
2412 lookup_b[(*p & 0x001f)];
2413 }
2414 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2415 }
2416 break;
2417 }
2418 case 24:
2419 {
2420 unsigned char *p1, *pf, *p, *pl;
2421 p1 = (unsigned char *) srcImage->data;
2422 pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2423 while (p1 < pf)
2424 {
2425 p = p1;
2426 pl = p1 + srcImage->width * 3;
2427 for (; p < pl; p += 3)
2428 {
2429 p[0] = lookup_r[(p[0] & 0xff0000)>>16];
2430 p[1] = lookup_r[(p[1] & 0x00ff00)>> 8];
2431 p[2] = lookup_r[(p[2] & 0x0000ff)];
2432 }
2433 p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line);
2434 }
2435 break;
2436 }
2437 case 32:
2438 {
2439 RUINT32T *p1, *pf, *p, *pl;
2440 p1 = (RUINT32T *) srcImage->data;
2441 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2442
2443 while (p1 < pf)
2444 {
2445 p = p1;
2446 pl = p1 + srcImage->width;
2447 for (; p < pl; p++)
2448 {
2449 *p = lookup_r[(*p & 0xff0000)>>16] |
2450 lookup_g[(*p & 0x00ff00)>> 8] |
2451 lookup_b[(*p & 0x0000ff)] |
2452 (*p & ~0xffffff);
2453 }
2454 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line);
2455 }
2456 break;
2457 }
2458 }
2459
2460 free (lookup);
2461}
2462#endif
2463
2464/*
2465 * Check our parents are still who we think they are.
2466 * Do transparency updates if required
2467 */
2468int
2469rxvt_term::check_our_parents ()
2470{
2471 int i, pchanged, aformat, have_pixmap, rootdepth;
2472 unsigned long nitems, bytes_after;
2473 Atom atype;
2474 unsigned char *prop = NULL;
2475 Window root, oldp, *list;
2476 Pixmap rootpixmap = None;
2477 XWindowAttributes wattr, wrootattr;
2478
2479 pchanged = 0;
2480
2481 if (!option (Opt_transparent))
2482 return pchanged; /* Don't try any more */
2483
2484 XGetWindowAttributes (dpy, display->root, &wrootattr);
2485 rootdepth = wrootattr.depth;
2486
2487 XGetWindowAttributes (dpy, parent[0], &wattr);
2488
2489 if (rootdepth != wattr.depth)
2490 {
2491 if (am_transparent)
2492 {
2493 pchanged = 1;
2494 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2495 am_transparent = am_pixmap_trans = 0;
2496 }
2497
2498 return pchanged; /* Don't try any more */
2499 }
2500
2501 /* Get all X ops out of the queue so that our information is up-to-date. */
2502 XSync (dpy, False);
2503
2504 /*
2505 * Make the frame window set by the window manager have
2506 * the root background. Some window managers put multiple nested frame
2507 * windows for each client, so we have to take care about that.
2508 */
2509 i = (xa[XA_XROOTPMAP_ID]
2510 && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID],
2511 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2512 &nitems, &bytes_after, &prop) == Success);
2513
2514 if (!i || prop == NULL)
2515 i = (xa[XA_ESETROOT_PMAP_ID]
2516 && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID],
2517 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2518 &nitems, &bytes_after, &prop) == Success);
2519
2520 if (!i || prop == NULL
2521#if TINTING
2522 || !ISSET_PIXCOLOR (Color_tint)
2523#endif
2524 )
2525 have_pixmap = 0;
2526 else
2527 {
2528 have_pixmap = 1;
2529 rootpixmap = *(Pixmap *)prop;
2530 XFree (prop);
2531 }
2532
2533 if (have_pixmap)
2534 {
2535 /*
2536 * Copy display->root pixmap transparency
2537 */
2538 int sx, sy, nx, ny;
2539 unsigned int nw, nh;
2540 Window cr;
2541 XImage *image;
2542 GC gc;
2543 XGCValues gcvalue;
2544
2545 XTranslateCoordinates (dpy, parent[0], display->root,
2546 0, 0, &sx, &sy, &cr);
2547 nw = (unsigned int)szHint.width;
2548 nh = (unsigned int)szHint.height;
2549 nx = ny = 0;
2550
2551 if (sx < 0)
2552 {
2553 nw += sx;
2554 nx = -sx;
2555 sx = 0;
2556 }
2557
2558 if (sy < 0)
2559 {
2560 nh += sy;
2561 ny = -sy;
2562 sy = 0;
2563 }
2564
2565 min_it (nw, (unsigned int) (wrootattr.width - sx));
2566 min_it (nh, (unsigned int) (wrootattr.height - sy));
2567
2568 XSync (dpy, False);
2569 allowedxerror = -1;
2570 image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2571
2572 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2573 /* XXX: may need a delay here? */
2574 allowedxerror = 0;
2575
2576 if (image == NULL)
2577 {
2578 if (am_transparent && am_pixmap_trans)
2579 {
2580 pchanged = 1;
2581 if (pixmap != None)
2582 {
2583 XFreePixmap (dpy, pixmap);
2584 pixmap = None;
2585 }
2586 }
2587
2588 am_pixmap_trans = 0;
2589 }
2590 else
2591 {
2592 if (pixmap != None)
2593 XFreePixmap (dpy, pixmap);
2594
2595#if TINTING
2596 if (ISSET_PIXCOLOR (Color_tint))
2597 {
2598 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2599
2600 rgba c;
2601 pix_colors_focused [Color_tint].get (c);
2602
2603 ShadeXImage (this, image, shade, c.r, c.g, c.b);
2604 }
2605#endif
2606
2607 pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth);
2608 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
2609 XPutImage (dpy, pixmap, gc, image, 0, 0,
2610 nx, ny, image->width, image->height);
2611 XFreeGC (dpy, gc);
2612 XDestroyImage (image);
2613 XSetWindowBackgroundPixmap (dpy, parent[0], pixmap);
2614 XClearWindow (dpy, parent[0]);
2615
2616 if (!am_transparent || !am_pixmap_trans)
2617 pchanged = 1;
2618
2619 am_transparent = am_pixmap_trans = 1;
2620 }
2621 }
2622
2623 if (am_pixmap_trans)
2624 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2625 else
2626 {
2627 unsigned int n;
2628 /*
2629 * InheritPixmap transparency
2630 */
2631 for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2632 {
2633 oldp = parent[i];
2634 XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n);
2635 XFree (list);
2636
2637 if (parent[i] == display->root)
2638 {
2639 if (oldp != None)
2640 pchanged = 1;
2641
2642 break;
2643 }
2644
2645 if (oldp != parent[i])
2646 pchanged = 1;
2647 }
2648
2649 n = 0;
2650
2651 if (pchanged)
2652 for (; n < (unsigned int)i; n++)
2653 {
2654 XGetWindowAttributes (dpy, parent[n], &wattr);
2655
2656 if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
2657 {
2658 n = (int) (sizeof (parent) / sizeof (Window)) + 1;
2659 break;
2660 }
2661 }
2662
2663 if (n > (sizeof (parent) / sizeof (parent[0])))
2664 {
2665 XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]);
2666 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2667 am_transparent = 0;
2668 /* XXX: also turn off Opt_transparent? */
2669 }
2670 else
2671 {
2672 for (n = 0; n < (unsigned int)i; n++)
2673 {
2674 XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative);
2675 XClearWindow (dpy, parent[n]);
2676 }
2677
2678 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2679 am_transparent = 1;
2680 }
2681
2682 for (; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2683 parent[i] = None;
2684 }
2685
2686 if (scrollBar.win)
2687 {
2688 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2689 scrollBar.setIdle ();
2690 scrollbar_show (0);
2691 }
2692
2693 if (am_transparent)
2694 {
2695 want_refresh = want_full_refresh = 1;
2696 if (am_pixmap_trans)
2697 flush ();
2698 }
2699
2700 return pchanged;
2701}
2702#endif
2703
2704/*}}} */ 2226/*}}} */
2705 2227
2706bool 2228bool
2707rxvt_term::cmd_parse () 2229rxvt_term::cmd_parse ()
2708{ 2230{
2756 if (ch == C0_LF) 2278 if (ch == C0_LF)
2757 nlines++; 2279 nlines++;
2758 2280
2759 refresh_count++; 2281 refresh_count++;
2760 2282
2761 if (!option (Opt_jumpScroll) 2283 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2762 || (refresh_count >= refresh_limit * (nrow - 1)))
2763 { 2284 {
2764 refreshnow = true;
2765 refresh_count = 0; 2285 refresh_count = 0;
2286
2287 if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.)
2288 {
2289 refreshnow = true;
2766 ch = NOCHAR; 2290 ch = NOCHAR;
2767 break; 2291 break;
2292 }
2768 } 2293 }
2769 2294
2770 // scr_add_lines only works for nlines <= nrow - 1. 2295 // scr_add_lines only works for nlines <= nrow - 1.
2771 if (nlines >= nrow - 1) 2296 if (nlines >= nrow - 1)
2772 { 2297 {
2800 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) 2325 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2801 scr_add_lines (buf, str - buf, nlines); 2326 scr_add_lines (buf, str - buf, nlines);
2802 2327
2803 /* 2328 /*
2804 * If there have been a lot of new lines, then update the screen 2329 * If there have been a lot of new lines, then update the screen
2805 * What the heck I'll cheat and only refresh less than every page-full. 2330 * What the heck we'll cheat and only refresh less than every page-full.
2806 * the number of pages between refreshes is refresh_limit, which 2331 * if skipScroll is enabled.
2807 * is incremented here because we must be doing flat-out scrolling.
2808 */ 2332 */
2809 if (refreshnow) 2333 if (refreshnow)
2810 { 2334 {
2811 if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2812 refresh_limit++;
2813 else
2814 {
2815 flag = true; 2335 flag = true;
2816 //TODO: due to popular request, implement "skipscroll" option here
2817 scr_refresh (); 2336 scr_refresh ();
2818 want_refresh = 1; 2337 want_refresh = 1;
2819 }
2820 } 2338 }
2821 2339
2822 } 2340 }
2823 else 2341 else
2824 { 2342 {
2973 { 2491 {
2974 if ((buf[len++] = cmd_getc ()) == 'i') 2492 if ((buf[len++] = cmd_getc ()) == 'i')
2975 break; /* done = 1 */ 2493 break; /* done = 1 */
2976 } 2494 }
2977 } 2495 }
2978 2496
2979 for (i = 0; i < len; i++) 2497 for (i = 0; i < len; i++)
2980 if (putc (buf[i], fd) == EOF) 2498 if (putc (buf[i], fd) == EOF)
2981 { 2499 {
2982 done = 1; 2500 done = 1;
2983 break; 2501 break;
3045 process_dcs_seq (); 2563 process_dcs_seq ();
3046 break; 2564 break;
3047 case 0x9b: /* CSI */ 2565 case 0x9b: /* CSI */
3048 process_csi_seq (); 2566 process_csi_seq ();
3049 break; 2567 break;
3050 case 0x9d: /* CSI */ 2568 case 0x9d: /* OSC */
3051 process_osc_seq (); 2569 process_osc_seq ();
3052 break; 2570 break;
3053#endif 2571#endif
3054 } 2572 }
3055} 2573}
3281rxvt_term::process_csi_seq () 2799rxvt_term::process_csi_seq ()
3282{ 2800{
3283 unicode_t ch, priv, i; 2801 unicode_t ch, priv, i;
3284 unsigned int nargs, p; 2802 unsigned int nargs, p;
3285 int n, ndef; 2803 int n, ndef;
3286 int arg[ESC_ARGS]; 2804 int arg[ESC_ARGS] = { };
3287 2805
3288 for (nargs = ESC_ARGS; nargs > 0;) 2806 nargs = 0;
3289 arg[--nargs] = 0;
3290 2807
3291 priv = 0; 2808 priv = 0;
3292 ch = cmd_getc (); 2809 ch = cmd_getc ();
3293 if (ch >= '<' && ch <= '?') 2810 if (ch >= '<' && ch <= '?')
3294 { /* '<' '=' '>' '?' */ 2811 { /* '<' '=' '>' '?' */
3338 switch (priv) 2855 switch (priv)
3339 { 2856 {
3340 case '>': 2857 case '>':
3341 if (ch == CSI_DA) /* secondary device attributes */ 2858 if (ch == CSI_DA) /* secondary device attributes */
3342 { 2859 {
3343 // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, 2860 // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt,
3344 // 'U' for rxvt-unicode != 7.[34] (where it was broken). 2861 // 'U' for rxvt-unicode != 7.[34] (where it was broken).
3345 // 2862 //
3346 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt 2863 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt
3347 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify 2864 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later
3348 // that we do not support xterm mouse reporting (should be 95 when we do). 2865 // versions.
3349 // 2866 //
3350 tt_printf ("\033[>%d;94;0c", 'U'); 2867 tt_printf ("\033[>%d;95;0c", 'U');
3351 } 2868 }
3352 break; 2869 break;
3353 case '?': 2870 case '?':
3354 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2871 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
3355 process_terminal_mode (ch, priv, nargs, arg); 2872 process_terminal_mode (ch, priv, nargs, arg);
3801 int saveop = op; 3318 int saveop = op;
3802 3319
3803 dLocal (Display *, dpy); 3320 dLocal (Display *, dpy);
3804 3321
3805 assert (str != NULL); 3322 assert (str != NULL);
3806 3323
3807 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) 3324 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END)))
3808 return; 3325 return;
3809 3326
3810 switch (op) 3327 switch (op)
3811 { 3328 {
3906 break; 3423 break;
3907 case URxvt_Color_IT: 3424 case URxvt_Color_IT:
3908 process_color_seq (op, Color_IT, str, resp); 3425 process_color_seq (op, Color_IT, str, resp);
3909 break; 3426 break;
3910#endif 3427#endif
3911#if TRANSPARENT && TINTING 3428#if ENABLE_TRANSPARENCY
3912 case URxvt_Color_tint: 3429 case URxvt_Color_tint:
3913 process_color_seq (op, Color_tint, str, resp); 3430 process_color_seq (op, Color_tint, str, resp);
3431 {
3432 bool changed = false;
3433 if (ISSET_PIXCOLOR (Color_tint))
3434 changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]);
3435 else
3436 changed = bgPixmap.unset_tint ();
3437 if (changed)
3438 update_background ();
3439 }
3914 3440
3915 check_our_parents ();
3916
3917 if (am_transparent)
3918 want_full_refresh = want_refresh = 1;
3919
3920 break; 3441 break;
3921#endif 3442#endif
3922 3443
3444#if BG_IMAGE_FROM_FILE
3923 case Rxvt_Pixmap: 3445 case Rxvt_Pixmap:
3924 { 3446 if (!strcmp (str, "?"))
3925 if (*str != ';')
3926 { 3447 {
3927#if XPM_BACKGROUND 3448 char str[256];
3928 scale_pixmap (""); /* reset to default scaling */ 3449
3929 set_bgPixmap (str); /* change pixmap */ 3450 sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */
3930 scr_touch (true); 3451 min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767),
3931#endif 3452 min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767));
3453 process_xterm_seq (XTerm_title, str, CHAR_ST);
3932 } 3454 }
3933 3455 else
3456 {
3934 int changed = 0; 3457 int changed = 0;
3935 3458
3936 while ((str = strchr (str, ';')) != NULL) 3459 if (*str != ';')
3937 { 3460 {
3461 /* reset to default scaling :*/
3462 bgPixmap.unset_geometry ();
3463 if (bgPixmap.set_file (str)) /* change pixmap */
3464 changed++;
3465 str = strchr (str, ';');
3466 if (str == NULL)
3467 bgPixmap.set_defaultGeometry ();
3468 }
3469 while (str)
3470 {
3938 str++; 3471 str++;
3939#if XPM_BACKGROUND 3472 if (bgPixmap.set_geometry (str))
3940 changed += scale_pixmap (str); 3473 changed++;
3941#endif 3474 str = strchr (str, ';');
3942 } 3475 }
3943
3944 if (changed) 3476 if (changed)
3945 { 3477 update_background ();
3946#ifdef XPM_BACKGROUND
3947 resize_pixmap ();
3948 scr_touch (true);
3949#endif
3950 } 3478 }
3951 }
3952 break; 3479 break;
3480#endif
3953 3481
3954 case Rxvt_restoreFG: 3482 case Rxvt_restoreFG:
3955 set_window_color (Color_fg, str); 3483 set_window_color (Color_fg, str);
3956 break; 3484 break;
3957 case Rxvt_restoreBG: 3485 case Rxvt_restoreBG:
4079{ 3607{
4080 unsigned int i, j; 3608 unsigned int i, j;
4081 int state; 3609 int state;
4082 3610
4083 static const struct 3611 static const struct
4084 { 3612 {
4085 const int argval; 3613 const int argval;
4086 const unsigned long bit; 3614 const unsigned long bit;
4087 }
4088
4089 argtopriv[] = { 3615 } argtopriv[] = {
4090 { 1, PrivMode_aplCUR }, 3616 { 1, PrivMode_aplCUR },
4091 { 2, PrivMode_vt52 }, 3617 { 2, PrivMode_vt52 },
4092 { 3, PrivMode_132 }, 3618 { 3, PrivMode_132 },
4093 { 4, PrivMode_smoothScroll }, 3619 { 4, PrivMode_smoothScroll },
4094 { 5, PrivMode_rVideo }, 3620 { 5, PrivMode_rVideo },
4111#ifndef NO_BACKSPACE_KEY 3637#ifndef NO_BACKSPACE_KEY
4112 { 67, PrivMode_BackSpace }, 3638 { 67, PrivMode_BackSpace },
4113#endif 3639#endif
4114 { 1000, PrivMode_MouseX11 }, 3640 { 1000, PrivMode_MouseX11 },
4115 // 1001 Use Hilite Mouse Tracking. NYI, TODO 3641 // 1001 Use Hilite Mouse Tracking. NYI, TODO
4116 // 1002 Use Cell Motion Mouse Tracking. NYI, TODO 3642 { 1002, PrivMode_MouseBtnEvent },
4117 // 1003 Use All Motion Mouse Tracking. NYI, TODO 3643 { 1003, PrivMode_MouseAnyEvent },
4118 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3644 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
4119 { 1011, PrivMode_Keypress }, // rxvt extension 3645 { 1011, PrivMode_Keypress }, // rxvt extension
4120 // 1035 enable modifiers for alt, numlock NYI 3646 // 1035 enable modifiers for alt, numlock NYI
4121 // 1036 send ESC for meta keys NYI 3647 // 1036 send ESC for meta keys NYI
4122 // 1037 send DEL for keypad delete NYI 3648 // 1037 send DEL for keypad delete NYI
4196 scr_autowrap (state); 3722 scr_autowrap (state);
4197 break; 3723 break;
4198 /* case 8: - auto repeat, can't do on a per window basis */ 3724 /* case 8: - auto repeat, can't do on a per window basis */
4199 case 9: /* X10 mouse reporting */ 3725 case 9: /* X10 mouse reporting */
4200 if (state) /* orthogonal */ 3726 if (state) /* orthogonal */
4201 priv_modes &= ~PrivMode_MouseX11; 3727 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
4202 break; 3728 break;
4203#ifdef scrollBar_esc 3729#ifdef scrollBar_esc
4204 case scrollBar_esc: 3730 case scrollBar_esc:
4205 if (scrollbar_mapping (state)) 3731 if (scrollbar_mapping (state))
4206 { 3732 {
4219 break; 3745 break;
4220 /* case 66: - application key pad */ 3746 /* case 66: - application key pad */
4221 /* case 67: - backspace key */ 3747 /* case 67: - backspace key */
4222 case 1000: /* X11 mouse reporting */ 3748 case 1000: /* X11 mouse reporting */
4223 if (state) /* orthogonal */ 3749 if (state) /* orthogonal */
4224 priv_modes &= ~PrivMode_MouseX10; 3750 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
4225 break; 3751 break;
4226#if 0 3752#if 0
4227 case 1001: 3753 case 1001:
4228 break; /* X11 mouse highlighting */ 3754 break; /* X11 mouse highlighting */
4229#endif 3755#endif
3756 case 1002:
3757 case 1003:
3758 if (state) {
3759 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11);
3760 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3761 vt_emask_mouse = PointerMotionMask;
3762 } else
3763 vt_emask_mouse = NoEventMask;
3764 vt_select_input ();
3765 break;
4230 case 1010: /* scroll to bottom on TTY output inhibit */ 3766 case 1010: /* scroll to bottom on TTY output inhibit */
4231 set_option (Opt_scrollTtyOutput, !state); 3767 set_option (Opt_scrollTtyOutput, !state);
4232 break; 3768 break;
4233 case 1011: /* scroll to bottom on key press */ 3769 case 1011: /* scroll to bottom on key press */
4234 set_option (Opt_scrollTtyKeypress, state); 3770 set_option (Opt_scrollTtyKeypress, state);
4486 4022
4487 if (v_buflen == 0) 4023 if (v_buflen == 0)
4488 { 4024 {
4489 free (v_buffer); 4025 free (v_buffer);
4490 v_buffer = 0; 4026 v_buffer = 0;
4491 v_buflen = 0;
4492 4027
4493 pty_ev.set (EVENT_READ); 4028 pty_ev.set (EVENT_READ);
4494 return; 4029 return;
4495 } 4030 }
4496 4031

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines