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.327 by ayin, Mon Jun 11 13:33:34 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
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#ifdef XPM_BACKGROUND
1495 if (!option(Opt_transparent) && bgPixmap.auto_resize)
1496 {
1497 resize_pixmap ();
1498 scr_touch (true);
1499 }
1500#endif
1501 } 1498 }
1502 1499 else
1500 {
1501#ifdef HAVE_BG_PIXMAP
1502 if (bgPixmap.window_position_sensitive ())
1503 update_background ();
1504#endif
1505 }
1503 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1506 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1504
1505#ifdef TRANSPARENT
1506 if (option (Opt_transparent))
1507 check_our_parents ();
1508#endif
1509 } 1507 }
1510 break; 1508 break;
1511 1509
1512 case PropertyNotify: 1510 case PropertyNotify:
1513 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)))
1544 text_blink_ev.stop (); 1542 text_blink_ev.stop ();
1545#endif 1543#endif
1546 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1544 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1547 break; 1545 break;
1548 1546
1549#ifdef TRANSPARENT
1550 case ReparentNotify:
1551 rootwin_cb (ev);
1552 break;
1553#endif /* TRANSPARENT */
1554
1555 case GraphicsExpose: 1547 case GraphicsExpose:
1556 case Expose: 1548 case Expose:
1557 if (ev.xany.window == vt) 1549 if (ev.xany.window == vt)
1558 { 1550 {
1559 do 1551 do
1552 {
1560 scr_expose (ev.xexpose.x, ev.xexpose.y, 1553 scr_expose (ev.xexpose.x, ev.xexpose.y,
1561 ev.xexpose.width, ev.xexpose.height, False); 1554 ev.xexpose.width, ev.xexpose.height, False);
1555 }
1562 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); 1556 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev));
1563 1557
1564 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; 1558 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1565 1559
1566 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) 1560 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1561 {
1567 scr_expose (ev.xexpose.x, ev.xexpose.y, 1562 scr_expose (ev.xexpose.x, ev.xexpose.y,
1568 ev.xexpose.width, ev.xexpose.height, False); 1563 ev.xexpose.width, ev.xexpose.height, False);
1569 1564 }
1570 want_refresh = 1; 1565 want_refresh = 1;
1571 } 1566 }
1572 else 1567 else
1573 { 1568 {
1574 XEvent unused_event; 1569 XEvent unused_event;
1581 if (isScrollbarWindow (ev.xany.window)) 1576 if (isScrollbarWindow (ev.xany.window))
1582 { 1577 {
1583 scrollBar.setIdle (); 1578 scrollBar.setIdle ();
1584 scrollbar_show (0); 1579 scrollbar_show (0);
1585 } 1580 }
1586
1587#ifdef TRANSPARENT
1588 if (am_transparent && ev.xany.window == parent[0])
1589 XClearWindow (dpy, ev.xany.window);
1590#endif
1591 } 1581 }
1592 break; 1582 break;
1593 1583
1594 case MotionNotify: 1584 case MotionNotify:
1595#ifdef POINTER_BLANK 1585#ifdef POINTER_BLANK
1596 if (hidden_pointer) 1586 if (hidden_pointer)
1597 pointer_unblank (); 1587 pointer_unblank ();
1598#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);
1599 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1592 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1600 break; 1593 break;
1601 1594
1602 if (ev.xany.window == vt) 1595 if (ev.xany.window == vt)
1603 { 1596 {
1693 &ev.xbutton.x, &ev.xbutton.y, 1686 &ev.xbutton.x, &ev.xbutton.y,
1694 &unused_mask); 1687 &unused_mask);
1695 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1688 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1696 scrollbar_size ()); 1689 scrollbar_size ());
1697 want_refresh = 1; 1690 want_refresh = 1;
1698 refresh_limit = 0;
1699 scrollbar_show (1); 1691 scrollbar_show (1);
1700 } 1692 }
1701 break; 1693 break;
1702 } 1694 }
1703 1695
1758 } 1750 }
1759#endif 1751#endif
1760#if ENABLE_FRILLS 1752#if ENABLE_FRILLS
1761 if (option (Opt_urgentOnBell)) 1753 if (option (Opt_urgentOnBell))
1762 { 1754 {
1763 XWMHints *h;
1764
1765 h = XGetWMHints(dpy, parent[0]); 1755 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1766 if (h != NULL)
1767 { 1756 {
1768 h->flags &= ~XUrgencyHint; 1757 h->flags &= ~XUrgencyHint;
1769 XSetWMHints(dpy, parent[0], h); 1758 XSetWMHints (dpy, parent[0], h);
1770 } 1759 }
1771 } 1760 }
1772#endif 1761#endif
1773 } 1762 }
1774} 1763}
1785 1774
1786#if ENABLE_FRILLS || ISO_14755 1775#if ENABLE_FRILLS || ISO_14755
1787 if (iso14755buf) 1776 if (iso14755buf)
1788 { 1777 {
1789 iso14755buf = 0; 1778 iso14755buf = 0;
1790# if ENABLE_OVERLAY 1779# if ISO_14755
1791 scr_overlay_off (); 1780 scr_overlay_off ();
1792# endif 1781# endif
1793 } 1782 }
1794#endif 1783#endif
1795#if USE_XIM 1784#if USE_XIM
1822 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);
1823 } 1812 }
1824#endif 1813#endif
1825} 1814}
1826 1815
1827#if TRANSPARENT || ENABLE_PERL 1816#if ENABLE_TRANSPARENCY || ENABLE_PERL
1828void 1817void
1829rxvt_term::rootwin_cb (XEvent &ev) 1818rxvt_term::rootwin_cb (XEvent &ev)
1830{ 1819{
1831 make_current (); 1820 make_current ();
1832 1821
1833 if (SHOULD_INVOKE (HOOK_ROOT_EVENT) 1822 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1834 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) 1823 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END)))
1835 return; 1824 return;
1836 1825
1837# if TRANSPARENT 1826# if ENABLE_TRANSPARENCY
1838 switch (ev.type) 1827 switch (ev.type)
1839 { 1828 {
1840 case PropertyNotify: 1829 case PropertyNotify:
1841 /* 1830 /*
1842 * 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,
1843 * 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.
1844 */ 1833 */
1845 if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] 1834 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1846 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1835 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1847 return; 1836 {
1848 1837 bgPixmap.set_root_pixmap ();
1849 /* FALLTHROUGH */ 1838 update_background ();
1850 case ReparentNotify: 1839 }
1851 if (option (Opt_transparent))
1852 check_our_parents ();
1853 break; 1840 break;
1854 } 1841 }
1855# endif 1842# endif
1856} 1843}
1857#endif 1844#endif
2234#endif 2221#endif
2235 } 2222 }
2236 } 2223 }
2237} 2224}
2238 2225
2239#ifdef TRANSPARENT
2240#if TINTING && !defined(HAVE_AFTERIMAGE)
2241/* taken from aterm-0.4.2 */
2242
2243typedef uint32_t RUINT32T;
2244
2245void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm)
2246{
2247 int sh_r, sh_g, sh_b;
2248 RUINT32T mask_r, mask_g, mask_b;
2249 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
2250 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
2251 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
2252 int i;
2253
2254 Visual *visual = term->visual;
2255
2256 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
2257
2258 /* for convenience */
2259 mask_r = visual->red_mask;
2260 mask_g = visual->green_mask;
2261 mask_b = visual->blue_mask;
2262
2263 /* boring lookup table pre-initialization */
2264 switch (srcImage->bits_per_pixel) {
2265 case 15:
2266 if ((mask_r != 0x7c00) ||
2267 (mask_g != 0x03e0) ||
2268 (mask_b != 0x001f))
2269 return;
2270 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32));
2271 lookup_r = lookup;
2272 lookup_g = lookup+32;
2273 lookup_b = lookup+32+32;
2274 sh_r = 10;
2275 sh_g = 5;
2276 sh_b = 0;
2277 break;
2278 case 16:
2279 if ((mask_r != 0xf800) ||
2280 (mask_g != 0x07e0) ||
2281 (mask_b != 0x001f))
2282 return;
2283 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32));
2284 lookup_r = lookup;
2285 lookup_g = lookup+32;
2286 lookup_b = lookup+32+64;
2287 sh_r = 11;
2288 sh_g = 5;
2289 sh_b = 0;
2290 break;
2291 case 24:
2292 if ((mask_r != 0xff0000) ||
2293 (mask_g != 0x00ff00) ||
2294 (mask_b != 0x0000ff))
2295 return;
2296 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2297 lookup_r = lookup;
2298 lookup_g = lookup+256;
2299 lookup_b = lookup+256+256;
2300 sh_r = 16;
2301 sh_g = 8;
2302 sh_b = 0;
2303 break;
2304 case 32:
2305 if ((mask_r != 0xff0000) ||
2306 (mask_g != 0x00ff00) ||
2307 (mask_b != 0x0000ff))
2308 return;
2309 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2310 lookup_r = lookup;
2311 lookup_g = lookup+256;
2312 lookup_b = lookup+256+256;
2313 sh_r = 16;
2314 sh_g = 8;
2315 sh_b = 0;
2316 break;
2317 default:
2318 return; /* we do not support this color depth */
2319 }
2320
2321 /* prepare limits for color transformation (each channel is handled separately) */
2322 if (shade < 0) {
2323 shade = -shade;
2324 if (shade < 0) shade = 0;
2325 if (shade > 100) shade = 100;
2326
2327 lower_lim_r = 65535-rm;
2328 lower_lim_g = 65535-gm;
2329 lower_lim_b = 65535-bm;
2330
2331 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100);
2332 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
2333 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
2334
2335 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
2336 } else {
2337 if (shade < 0) shade = 0;
2338 if (shade > 100) shade = 100;
2339
2340 lower_lim_r = lower_lim_g = lower_lim_b = 0;
2341
2342 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
2343 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);
2344 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100);
2345 }
2346
2347 /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */
2348 if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 ))
2349 {
2350 unsigned int tmp;
2351
2352 tmp = lower_lim_r;
2353 lower_lim_r = lower_lim_b;
2354 lower_lim_b = tmp;
2355
2356 tmp = upper_lim_r;
2357 upper_lim_r = upper_lim_b;
2358 upper_lim_b = tmp;
2359 }
2360
2361 /* fill our lookup tables */
2362 for (i = 0; i <= mask_r>>sh_r; i++)
2363 {
2364 RUINT32T tmp;
2365 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r));
2366 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r);
2367 lookup_r[i] = (tmp/65535)<<sh_r;
2368 }
2369 for (i = 0; i <= mask_g>>sh_g; i++)
2370 {
2371 RUINT32T tmp;
2372 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g));
2373 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g);
2374 lookup_g[i] = (tmp/65535)<<sh_g;
2375 }
2376 for (i = 0; i <= mask_b>>sh_b; i++)
2377 {
2378 RUINT32T tmp;
2379 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b));
2380 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b);
2381 lookup_b[i] = (tmp/65535)<<sh_b;
2382 }
2383
2384 /* apply table to input image (replacing colors by newly calculated ones) */
2385 switch (srcImage->bits_per_pixel)
2386 {
2387 case 15:
2388 {
2389 unsigned short *p1, *pf, *p, *pl;
2390 p1 = (unsigned short *) srcImage->data;
2391 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2392 while (p1 < pf)
2393 {
2394 p = p1;
2395 pl = p1 + srcImage->width;
2396 for (; p < pl; p++)
2397 {
2398 *p = lookup_r[(*p & 0x7c00)>>10] |
2399 lookup_g[(*p & 0x03e0)>> 5] |
2400 lookup_b[(*p & 0x001f)];
2401 }
2402 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2403 }
2404 break;
2405 }
2406 case 16:
2407 {
2408 unsigned short *p1, *pf, *p, *pl;
2409 p1 = (unsigned short *) srcImage->data;
2410 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2411 while (p1 < pf)
2412 {
2413 p = p1;
2414 pl = p1 + srcImage->width;
2415 for (; p < pl; p++)
2416 {
2417 *p = lookup_r[(*p & 0xf800)>>11] |
2418 lookup_g[(*p & 0x07e0)>> 5] |
2419 lookup_b[(*p & 0x001f)];
2420 }
2421 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2422 }
2423 break;
2424 }
2425 case 24:
2426 {
2427 unsigned char *p1, *pf, *p, *pl;
2428 p1 = (unsigned char *) srcImage->data;
2429 pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2430 while (p1 < pf)
2431 {
2432 p = p1;
2433 pl = p1 + srcImage->width * 3;
2434 for (; p < pl; p += 3)
2435 {
2436 p[0] = lookup_r[(p[0] & 0xff0000)>>16];
2437 p[1] = lookup_r[(p[1] & 0x00ff00)>> 8];
2438 p[2] = lookup_r[(p[2] & 0x0000ff)];
2439 }
2440 p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line);
2441 }
2442 break;
2443 }
2444 case 32:
2445 {
2446 RUINT32T *p1, *pf, *p, *pl;
2447 p1 = (RUINT32T *) srcImage->data;
2448 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2449
2450 while (p1 < pf)
2451 {
2452 p = p1;
2453 pl = p1 + srcImage->width;
2454 for (; p < pl; p++)
2455 {
2456 *p = lookup_r[(*p & 0xff0000)>>16] |
2457 lookup_g[(*p & 0x00ff00)>> 8] |
2458 lookup_b[(*p & 0x0000ff)] |
2459 (*p & ~0xffffff);
2460 }
2461 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line);
2462 }
2463 break;
2464 }
2465 }
2466
2467 free (lookup);
2468}
2469#endif
2470
2471/*
2472 * Check our parents are still who we think they are.
2473 * Do transparency updates if required
2474 */
2475int
2476rxvt_term::check_our_parents ()
2477{
2478 check_our_parents_ev.stop ();
2479 check_our_parents_ev.start (NOW + .1);
2480 return 0;
2481}
2482
2483void
2484rxvt_term::check_our_parents_cb (time_watcher &w)
2485{
2486 int i, pchanged, aformat, have_pixmap, rootdepth;
2487 unsigned long nitems, bytes_after;
2488 Atom atype;
2489 unsigned char *prop = NULL;
2490 Window root, oldp, *list;
2491 Pixmap rootpixmap = None;
2492 XWindowAttributes wattr, wrootattr;
2493 int sx, sy;
2494 Window cr;
2495
2496 pchanged = 0;
2497
2498 if (!option (Opt_transparent))
2499 return /*pchanged*/; /* Don't try any more */
2500
2501 XGetWindowAttributes (dpy, display->root, &wrootattr);
2502 rootdepth = wrootattr.depth;
2503
2504 XGetWindowAttributes (dpy, parent[0], &wattr);
2505
2506 if (rootdepth != wattr.depth)
2507 {
2508 if (am_transparent)
2509 {
2510 pchanged = 1;
2511 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2512 am_transparent = am_pixmap_trans = 0;
2513 }
2514
2515 return /*pchanged*/; /* Don't try any more */
2516 }
2517
2518 /* Get all X ops out of the queue so that our information is up-to-date. */
2519 XSync (dpy, False);
2520
2521 XTranslateCoordinates (dpy, parent[0], display->root,
2522 0, 0, &sx, &sy, &cr);
2523
2524 /* check if we are outside of the visible part of the virtual screen : */
2525 if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0
2526 || sx >= wrootattr.width || sy >= wrootattr.height )
2527 return /* 0 */ ;
2528 /*
2529 * Make the frame window set by the window manager have
2530 * the root background. Some window managers put multiple nested frame
2531 * windows for each client, so we have to take care about that.
2532 */
2533 i = (xa[XA_XROOTPMAP_ID]
2534 && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID],
2535 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2536 &nitems, &bytes_after, &prop) == Success);
2537
2538 if (!i || prop == NULL)
2539 i = (xa[XA_ESETROOT_PMAP_ID]
2540 && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID],
2541 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2542 &nitems, &bytes_after, &prop) == Success);
2543
2544 if (!i || prop == NULL
2545#if TINTING
2546 || (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL
2547#ifdef HAVE_AFTERIMAGE
2548 && original_asim == NULL && rs[Rs_blurradius] == NULL
2549#endif
2550 )
2551#endif
2552 )
2553 have_pixmap = 0;
2554 else
2555 {
2556 have_pixmap = 1;
2557 rootpixmap = *(Pixmap *)prop;
2558 XFree (prop);
2559 }
2560
2561 if (have_pixmap)
2562 {
2563 Bool success = False ;
2564 GC gc;
2565 XGCValues gcvalue;
2566#ifdef HAVE_AFTERIMAGE
2567 {
2568 Pixmap tmp_pmap = None ;
2569 ShadingInfo shade;
2570 ARGB32 tint ;
2571 unsigned int pmap_w = 0, pmap_h = 0;
2572
2573 if (get_drawable_size( rootpixmap, &pmap_w, &pmap_h ))
2574 {
2575 int root_x = 0, root_y = 0;
2576
2577 shade.shading = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2578 if (ISSET_PIXCOLOR (Color_tint))
2579 {
2580 rgba c;
2581 pix_colors_focused [Color_tint].get (c);
2582 shade.tintColor.red = c.r;
2583 shade.tintColor.green = c.g;
2584 shade.tintColor.blue = c.b;
2585 }
2586 else
2587 shade.tintColor.red = shade.tintColor.green = shade.tintColor.blue = 0xFFFF;
2588 tint = shading2tint32( &shade );
2589 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
2590 if (GetWinPosition (parent[0], &root_x, &root_y) )
2591 {
2592 ASImageLayer *layers = create_image_layers( 2 );
2593 ASImage *merged_im = NULL;
2594 int back_x, back_y, back_w, back_h;
2595 /* merge_layers does good job at tiling background appropriately,
2596 so all we need is to cut out smallest possible piece : */
2597#define MAKE_ROOTPMAP_GEOM(xy,wh,widthheight) \
2598 do{ while( root_##xy < 0 ) root_##xy += (int)wrootattr.widthheight; \
2599 back_##xy = root_##xy % pmap_##wh; /* that gives us left side of the closest tile : */ \
2600 if( pmap_##wh >= back_##xy + szHint.widthheight ) \
2601 back_##wh = szHint.widthheight;/* background is large - limit it by our size */ \
2602 else \
2603 { /* small background - need the whole of it for successfull tiling :*/ \
2604 back_##xy = 0; \
2605 back_##wh = pmap_##wh; \
2606 }}while(0)
2607
2608 MAKE_ROOTPMAP_GEOM(x,w,width);
2609 MAKE_ROOTPMAP_GEOM(y,h,height);
2610
2611 layers[0].im = pixmap2asimage (display->asv, rootpixmap, back_x, back_y, back_w, back_h, AllPlanes, ASA_ASImage, 100);
2612 layers[0].clip_x = (back_w == pmap_w)?root_x:0;
2613 layers[0].clip_y = (back_h == pmap_h)?root_y:0;
2614 layers[0].clip_width = szHint.width;
2615 layers[0].clip_height = szHint.height;
2616 layers[0].tint = tint;
2617 if (rs[Rs_blurradius] && layers[0].im)
2618 {
2619 double r = atof(rs[Rs_blurradius]);
2620 ASImage* tmp = blur_asimage_gauss(display->asv, layers[0].im, r, r, 0xFFFFFFFF, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT );
2621 if( tmp )
2622 {
2623 destroy_asimage( &layers[0].im );
2624 layers[0].im = tmp;
2625 }
2626 }
2627 if (original_asim != NULL)
2628 {
2629 int fore_w, fore_h;
2630 layers[1].im = original_asim;
2631 if( bgPixmap.auto_resize )
2632 {
2633 fore_w = szHint.width;
2634 fore_h = szHint.height;
2635 }
2636 else
2637 {
2638 fore_w = bgPixmap.w;
2639 fore_h = bgPixmap.h;
2640 }
2641 if (fore_w != original_asim->width
2642 || fore_h != original_asim->height)
2643 {
2644 layers[1].im = scale_asimage( display->asv,
2645 original_asim,
2646 fore_w, fore_h,
2647 ASA_ASImage, 100,
2648 ASIMAGE_QUALITY_DEFAULT );
2649 }
2650
2651 layers[1].clip_width = szHint.width;
2652 layers[1].clip_height = szHint.height;
2653
2654 if (rs[Rs_blendtype])
2655 {
2656 layers[1].merge_scanlines = blend_scanlines_name2func(rs[Rs_blendtype]);
2657 if( layers[1].merge_scanlines == NULL )
2658 layers[1].merge_scanlines = alphablend_scanlines;
2659 }
2660 }
2661 merged_im = merge_layers( display->asv, layers, layers[1].im?2:1,
2662 szHint.width, szHint.height,
2663 ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT );
2664 if (layers[1].im != original_asim)
2665 destroy_asimage( &(layers[1].im) );
2666 destroy_asimage( &(layers[0].im) );
2667 if (merged_im != NULL)
2668 {
2669 tmp_pmap = asimage2pixmap( display->asv, DefaultRootWindow(dpy), merged_im, gc, True );
2670 destroy_asimage( &merged_im );
2671 }
2672 free( layers );
2673 }
2674 }
2675 if (tmp_pmap != None)
2676 {
2677 success = True;
2678 if (pixmap != None)
2679 XFreePixmap (dpy, pixmap);
2680 pixmap = tmp_pmap;
2681 }
2682 }
2683#else /* HAVE_AFTERIMAGE */
2684 {
2685 /*
2686 * Copy display->root pixmap transparency
2687 */
2688 int nx, ny;
2689 unsigned int nw, nh;
2690 XImage *image;
2691
2692 nw = (unsigned int)szHint.width;
2693 nh = (unsigned int)szHint.height;
2694 nx = ny = 0;
2695
2696 if (sx < 0)
2697 {
2698 nw += sx;
2699 nx = -sx;
2700 sx = 0;
2701 }
2702
2703 if (sy < 0)
2704 {
2705 nh += sy;
2706 ny = -sy;
2707 sy = 0;
2708 }
2709
2710 min_it (nw, (unsigned int) (wrootattr.width - sx));
2711 min_it (nh, (unsigned int) (wrootattr.height - sy));
2712
2713 XSync (dpy, False);
2714 allowedxerror = -1;
2715 image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2716
2717 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2718 /* XXX: may need a delay here? */
2719 allowedxerror = 0;
2720 if (image != NULL)
2721 {
2722 if (pixmap != None)
2723 XFreePixmap (dpy, pixmap);
2724
2725#if TINTING
2726 if (ISSET_PIXCOLOR (Color_tint))
2727 {
2728 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2729
2730 rgba c;
2731 pix_colors_focused [Color_tint].get (c);
2732 ShadeXImage (this, image, shade, c.r, c.g, c.b);
2733 }
2734#endif
2735
2736 pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth);
2737 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
2738 XPutImage (dpy, pixmap, gc, image, 0, 0,
2739 nx, ny, image->width, image->height);
2740 XDestroyImage (image);
2741 success = True ;
2742 }
2743 }
2744#endif /* HAVE_AFTERIMAGE */
2745 if (gc != NULL)
2746 XFreeGC (dpy, gc);
2747
2748 if (!success)
2749 {
2750 if (am_transparent && am_pixmap_trans)
2751 {
2752 pchanged = 1;
2753 if (pixmap != None)
2754 {
2755 XFreePixmap (dpy, pixmap);
2756 pixmap = None;
2757 }
2758 }
2759
2760 am_pixmap_trans = 0;
2761 }
2762 else
2763 {
2764 XSetWindowBackgroundPixmap (dpy, parent[0], pixmap);
2765 XClearWindow (dpy, parent[0]);
2766
2767 if (!am_transparent || !am_pixmap_trans)
2768 pchanged = 1;
2769
2770 am_transparent = am_pixmap_trans = 1;
2771 }
2772 }
2773
2774 if (am_pixmap_trans)
2775 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2776 else
2777 {
2778 unsigned int n;
2779 /*
2780 * InheritPixmap transparency
2781 */
2782 for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2783 {
2784 oldp = parent[i];
2785 XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n);
2786 XFree (list);
2787
2788 if (parent[i] == display->root)
2789 {
2790 if (oldp != None)
2791 pchanged = 1;
2792
2793 break;
2794 }
2795
2796 if (oldp != parent[i])
2797 pchanged = 1;
2798 }
2799
2800 n = 0;
2801
2802 if (pchanged)
2803 for (; n < (unsigned int)i; n++)
2804 {
2805 XGetWindowAttributes (dpy, parent[n], &wattr);
2806
2807 if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
2808 {
2809 n = (int) (sizeof (parent) / sizeof (Window)) + 1;
2810 break;
2811 }
2812 }
2813
2814 if (n > (sizeof (parent) / sizeof (parent[0])))
2815 {
2816 XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]);
2817 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2818 am_transparent = 0;
2819 /* XXX: also turn off Opt_transparent? */
2820 }
2821 else
2822 {
2823 for (n = 0; n < (unsigned int)i; n++)
2824 {
2825 XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative);
2826 XClearWindow (dpy, parent[n]);
2827 }
2828
2829 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2830 am_transparent = 1;
2831 }
2832
2833 for (; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2834 parent[i] = None;
2835 }
2836
2837 if (scrollBar.win)
2838 {
2839 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2840 scrollBar.setIdle ();
2841 scrollbar_show (0);
2842 }
2843
2844 if (am_transparent)
2845 {
2846 want_refresh = want_full_refresh = 1;
2847 if (am_pixmap_trans)
2848 flush ();
2849 }
2850
2851// return pchanged;
2852}
2853#endif
2854
2855/*}}} */ 2226/*}}} */
2856 2227
2857bool 2228bool
2858rxvt_term::cmd_parse () 2229rxvt_term::cmd_parse ()
2859{ 2230{
2907 if (ch == C0_LF) 2278 if (ch == C0_LF)
2908 nlines++; 2279 nlines++;
2909 2280
2910 refresh_count++; 2281 refresh_count++;
2911 2282
2912 if (!option (Opt_jumpScroll) 2283 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2913 || (refresh_count >= refresh_limit * (nrow - 1)))
2914 { 2284 {
2915 refreshnow = true;
2916 refresh_count = 0; 2285 refresh_count = 0;
2286
2287 if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.)
2288 {
2289 refreshnow = true;
2917 ch = NOCHAR; 2290 ch = NOCHAR;
2918 break; 2291 break;
2292 }
2919 } 2293 }
2920 2294
2921 // scr_add_lines only works for nlines <= nrow - 1. 2295 // scr_add_lines only works for nlines <= nrow - 1.
2922 if (nlines >= nrow - 1) 2296 if (nlines >= nrow - 1)
2923 { 2297 {
2951 && 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))))
2952 scr_add_lines (buf, str - buf, nlines); 2326 scr_add_lines (buf, str - buf, nlines);
2953 2327
2954 /* 2328 /*
2955 * 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
2956 * 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.
2957 * the number of pages between refreshes is refresh_limit, which 2331 * if skipScroll is enabled.
2958 * is incremented here because we must be doing flat-out scrolling.
2959 */ 2332 */
2960 if (refreshnow) 2333 if (refreshnow)
2961 { 2334 {
2962 if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2963 refresh_limit++;
2964 else
2965 {
2966 flag = true; 2335 flag = true;
2967 //TODO: due to popular request, implement "skipscroll" option here
2968 scr_refresh (); 2336 scr_refresh ();
2969 want_refresh = 1; 2337 want_refresh = 1;
2970 }
2971 } 2338 }
2972 2339
2973 } 2340 }
2974 else 2341 else
2975 { 2342 {
3124 { 2491 {
3125 if ((buf[len++] = cmd_getc ()) == 'i') 2492 if ((buf[len++] = cmd_getc ()) == 'i')
3126 break; /* done = 1 */ 2493 break; /* done = 1 */
3127 } 2494 }
3128 } 2495 }
3129 2496
3130 for (i = 0; i < len; i++) 2497 for (i = 0; i < len; i++)
3131 if (putc (buf[i], fd) == EOF) 2498 if (putc (buf[i], fd) == EOF)
3132 { 2499 {
3133 done = 1; 2500 done = 1;
3134 break; 2501 break;
3196 process_dcs_seq (); 2563 process_dcs_seq ();
3197 break; 2564 break;
3198 case 0x9b: /* CSI */ 2565 case 0x9b: /* CSI */
3199 process_csi_seq (); 2566 process_csi_seq ();
3200 break; 2567 break;
3201 case 0x9d: /* CSI */ 2568 case 0x9d: /* OSC */
3202 process_osc_seq (); 2569 process_osc_seq ();
3203 break; 2570 break;
3204#endif 2571#endif
3205 } 2572 }
3206} 2573}
3432rxvt_term::process_csi_seq () 2799rxvt_term::process_csi_seq ()
3433{ 2800{
3434 unicode_t ch, priv, i; 2801 unicode_t ch, priv, i;
3435 unsigned int nargs, p; 2802 unsigned int nargs, p;
3436 int n, ndef; 2803 int n, ndef;
3437 int arg[ESC_ARGS]; 2804 int arg[ESC_ARGS] = { };
3438 2805
3439 for (nargs = ESC_ARGS; nargs > 0;) 2806 nargs = 0;
3440 arg[--nargs] = 0;
3441 2807
3442 priv = 0; 2808 priv = 0;
3443 ch = cmd_getc (); 2809 ch = cmd_getc ();
3444 if (ch >= '<' && ch <= '?') 2810 if (ch >= '<' && ch <= '?')
3445 { /* '<' '=' '>' '?' */ 2811 { /* '<' '=' '>' '?' */
3489 switch (priv) 2855 switch (priv)
3490 { 2856 {
3491 case '>': 2857 case '>':
3492 if (ch == CSI_DA) /* secondary device attributes */ 2858 if (ch == CSI_DA) /* secondary device attributes */
3493 { 2859 {
3494 // 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,
3495 // 'U' for rxvt-unicode != 7.[34] (where it was broken). 2861 // 'U' for rxvt-unicode != 7.[34] (where it was broken).
3496 // 2862 //
3497 // 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
3498 // 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
3499 // that we do not support xterm mouse reporting (should be 95 when we do). 2865 // versions.
3500 // 2866 //
3501 tt_printf ("\033[>%d;94;0c", 'U'); 2867 tt_printf ("\033[>%d;95;0c", 'U');
3502 } 2868 }
3503 break; 2869 break;
3504 case '?': 2870 case '?':
3505 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2871 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
3506 process_terminal_mode (ch, priv, nargs, arg); 2872 process_terminal_mode (ch, priv, nargs, arg);
3952 int saveop = op; 3318 int saveop = op;
3953 3319
3954 dLocal (Display *, dpy); 3320 dLocal (Display *, dpy);
3955 3321
3956 assert (str != NULL); 3322 assert (str != NULL);
3957 3323
3958 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)))
3959 return; 3325 return;
3960 3326
3961 switch (op) 3327 switch (op)
3962 { 3328 {
4057 break; 3423 break;
4058 case URxvt_Color_IT: 3424 case URxvt_Color_IT:
4059 process_color_seq (op, Color_IT, str, resp); 3425 process_color_seq (op, Color_IT, str, resp);
4060 break; 3426 break;
4061#endif 3427#endif
4062#if TRANSPARENT && TINTING 3428#if ENABLE_TRANSPARENCY
4063 case URxvt_Color_tint: 3429 case URxvt_Color_tint:
4064 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 }
4065 3440
4066 check_our_parents ();
4067
4068 if (am_transparent)
4069 want_full_refresh = want_refresh = 1;
4070
4071 break; 3441 break;
4072#endif 3442#endif
4073 3443
3444#if BG_IMAGE_FROM_FILE
4074 case Rxvt_Pixmap: 3445 case Rxvt_Pixmap:
4075 { 3446 if (!strcmp (str, "?"))
4076 if (*str != ';')
4077 { 3447 {
4078#if XPM_BACKGROUND 3448 char str[256];
4079 scale_pixmap (""); /* reset to default scaling */ 3449
4080 set_bgPixmap (str); /* change pixmap */ 3450 sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */
4081 scr_touch (true); 3451 min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767),
4082#endif 3452 min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767));
3453 process_xterm_seq (XTerm_title, str, CHAR_ST);
4083 } 3454 }
4084 3455 else
3456 {
4085 int changed = 0; 3457 int changed = 0;
4086 3458
4087 while ((str = strchr (str, ';')) != NULL) 3459 if (*str != ';')
4088 { 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 {
4089 str++; 3471 str++;
4090#if XPM_BACKGROUND 3472 if (bgPixmap.set_geometry (str))
4091 changed += scale_pixmap (str); 3473 changed++;
4092#endif 3474 str = strchr (str, ';');
4093 } 3475 }
4094
4095 if (changed) 3476 if (changed)
4096 { 3477 update_background ();
4097#ifdef XPM_BACKGROUND
4098 resize_pixmap ();
4099 scr_touch (true);
4100#endif
4101 } 3478 }
4102#if TRANSPARENT && defined(HAVE_AFTERIMAGE) 3479 break;
4103 if (option(Opt_transparent))
4104 check_our_parents ();
4105#endif 3480#endif
4106
4107 }
4108 break;
4109 3481
4110 case Rxvt_restoreFG: 3482 case Rxvt_restoreFG:
4111 set_window_color (Color_fg, str); 3483 set_window_color (Color_fg, str);
4112 break; 3484 break;
4113 case Rxvt_restoreBG: 3485 case Rxvt_restoreBG:
4235{ 3607{
4236 unsigned int i, j; 3608 unsigned int i, j;
4237 int state; 3609 int state;
4238 3610
4239 static const struct 3611 static const struct
4240 { 3612 {
4241 const int argval; 3613 const int argval;
4242 const unsigned long bit; 3614 const unsigned long bit;
4243 }
4244
4245 argtopriv[] = { 3615 } argtopriv[] = {
4246 { 1, PrivMode_aplCUR }, 3616 { 1, PrivMode_aplCUR },
4247 { 2, PrivMode_vt52 }, 3617 { 2, PrivMode_vt52 },
4248 { 3, PrivMode_132 }, 3618 { 3, PrivMode_132 },
4249 { 4, PrivMode_smoothScroll }, 3619 { 4, PrivMode_smoothScroll },
4250 { 5, PrivMode_rVideo }, 3620 { 5, PrivMode_rVideo },
4267#ifndef NO_BACKSPACE_KEY 3637#ifndef NO_BACKSPACE_KEY
4268 { 67, PrivMode_BackSpace }, 3638 { 67, PrivMode_BackSpace },
4269#endif 3639#endif
4270 { 1000, PrivMode_MouseX11 }, 3640 { 1000, PrivMode_MouseX11 },
4271 // 1001 Use Hilite Mouse Tracking. NYI, TODO 3641 // 1001 Use Hilite Mouse Tracking. NYI, TODO
4272 // 1002 Use Cell Motion Mouse Tracking. NYI, TODO 3642 { 1002, PrivMode_MouseBtnEvent },
4273 // 1003 Use All Motion Mouse Tracking. NYI, TODO 3643 { 1003, PrivMode_MouseAnyEvent },
4274 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3644 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
4275 { 1011, PrivMode_Keypress }, // rxvt extension 3645 { 1011, PrivMode_Keypress }, // rxvt extension
4276 // 1035 enable modifiers for alt, numlock NYI 3646 // 1035 enable modifiers for alt, numlock NYI
4277 // 1036 send ESC for meta keys NYI 3647 // 1036 send ESC for meta keys NYI
4278 // 1037 send DEL for keypad delete NYI 3648 // 1037 send DEL for keypad delete NYI
4352 scr_autowrap (state); 3722 scr_autowrap (state);
4353 break; 3723 break;
4354 /* 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 */
4355 case 9: /* X10 mouse reporting */ 3725 case 9: /* X10 mouse reporting */
4356 if (state) /* orthogonal */ 3726 if (state) /* orthogonal */
4357 priv_modes &= ~PrivMode_MouseX11; 3727 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
4358 break; 3728 break;
4359#ifdef scrollBar_esc 3729#ifdef scrollBar_esc
4360 case scrollBar_esc: 3730 case scrollBar_esc:
4361 if (scrollbar_mapping (state)) 3731 if (scrollbar_mapping (state))
4362 { 3732 {
4375 break; 3745 break;
4376 /* case 66: - application key pad */ 3746 /* case 66: - application key pad */
4377 /* case 67: - backspace key */ 3747 /* case 67: - backspace key */
4378 case 1000: /* X11 mouse reporting */ 3748 case 1000: /* X11 mouse reporting */
4379 if (state) /* orthogonal */ 3749 if (state) /* orthogonal */
4380 priv_modes &= ~PrivMode_MouseX10; 3750 priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
4381 break; 3751 break;
4382#if 0 3752#if 0
4383 case 1001: 3753 case 1001:
4384 break; /* X11 mouse highlighting */ 3754 break; /* X11 mouse highlighting */
4385#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;
4386 case 1010: /* scroll to bottom on TTY output inhibit */ 3766 case 1010: /* scroll to bottom on TTY output inhibit */
4387 set_option (Opt_scrollTtyOutput, !state); 3767 set_option (Opt_scrollTtyOutput, !state);
4388 break; 3768 break;
4389 case 1011: /* scroll to bottom on key press */ 3769 case 1011: /* scroll to bottom on key press */
4390 set_option (Opt_scrollTtyKeypress, state); 3770 set_option (Opt_scrollTtyKeypress, state);
4642 4022
4643 if (v_buflen == 0) 4023 if (v_buflen == 0)
4644 { 4024 {
4645 free (v_buffer); 4025 free (v_buffer);
4646 v_buffer = 0; 4026 v_buffer = 0;
4647 v_buflen = 0;
4648 4027
4649 pty_ev.set (EVENT_READ); 4028 pty_ev.set (EVENT_READ);
4650 return; 4029 return;
4651 } 4030 }
4652 4031

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines