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.97 by root, Mon Jul 26 18:01:19 2004 UTC vs.
Revision 1.120 by root, Tue Aug 10 22:36:30 2004 UTC

306 newlen = 0; 306 newlen = 0;
307 } 307 }
308 break; 308 break;
309 309
310#ifdef XK_KP_Left 310#ifdef XK_KP_Left
311 case XK_KP_Up: /* \033Ox or standard */ 311 case XK_KP_Up: /* \033Ox or standard */
312 case XK_KP_Down: /* \033Or or standard */ 312 case XK_KP_Down: /* \033Or or standard */
313 case XK_KP_Right: /* \033Ov or standard */ 313 case XK_KP_Right: /* \033Ov or standard */
314 case XK_KP_Left: /* \033Ot or standard */ 314 case XK_KP_Left: /* \033Ot or standard */
315 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 315 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
316 { 316 {
661 if (want_full_refresh) 661 if (want_full_refresh)
662 { 662 {
663 want_full_refresh = 0; 663 want_full_refresh = 0;
664 scr_clear (); 664 scr_clear ();
665 scr_touch (false); 665 scr_touch (false);
666 want_refresh = 1;
667 } 666 }
668#endif 667#endif
669 668
670 if (want_refresh) 669 if (want_refresh)
671 { 670 {
675 IMSendSpot (); 674 IMSendSpot ();
676#endif 675#endif
677 } 676 }
678 677
679 display->flush (); 678 display->flush ();
679
680 flush_ev.stop ();
680} 681}
681 682
682void 683void
683rxvt_term::check_cb (check_watcher &w) 684rxvt_term::check_cb (check_watcher &w)
684{ 685{
685 SET_R (this); 686 SET_R (this);
686 SET_LOCALE (locale); 687 SET_LOCALE (locale);
687 688
689 display->flush ();
690
691 if (want_refresh && !flush_ev.active)
692 flush_ev.start (NOW + 0.01);
693}
694
695void
696rxvt_term::flush_cb (time_watcher &w)
697{
698 SET_R (this);
699 SET_LOCALE (locale);
700
701 refresh_limit = 1;
702 refresh_count = 0;
688 flush (); 703 flush ();
689} 704}
690 705
691#ifdef CURSOR_BLINK 706#ifdef CURSOR_BLINK
692void 707void
796 while (pty_fill ()) 811 while (pty_fill ())
797 if (cmd_parse ()) 812 if (cmd_parse ())
798 break; 813 break;
799} 814}
800 815
801#ifdef POINTER_BLANK
802void 816void
803rxvt_term::pointer_unblank () 817rxvt_term::pointer_unblank ()
804{ 818{
805 XDefineCursor (display->display, TermWin.vt, TermWin_cursor); 819 XDefineCursor (display->display, TermWin.vt, TermWin_cursor);
806 recolour_cursor (); 820 recolour_cursor ();
807 821
822#ifdef POINTER_BLANK
808 hidden_pointer = 0; 823 hidden_pointer = 0;
809 824
810 if (Options & Opt_pointerBlank) 825 if (Options & Opt_pointerBlank)
811 pointer_ev.start (NOW + pointerBlankDelay); 826 pointer_ev.start (NOW + pointerBlankDelay);
827#endif
812} 828}
813 829
830#ifdef POINTER_BLANK
814void 831void
815rxvt_term::pointer_blank () 832rxvt_term::pointer_blank ()
816{ 833{
817 if (! (Options & Opt_pointerBlank)) 834 if (! (Options & Opt_pointerBlank))
818 return; 835 return;
1072 } 1089 }
1073#endif /* OFFIX_DND */ 1090#endif /* OFFIX_DND */
1074 break; 1091 break;
1075 1092
1076 case MappingNotify: 1093 case MappingNotify:
1077 XRefreshKeyboardMapping (& (ev.xmapping)); 1094 XRefreshKeyboardMapping (&ev.xmapping);
1078 break; 1095 break;
1079 1096
1080 /* 1097 /*
1081 * XXX: this is not the _current_ arrangement 1098 * XXX: this is not the _current_ arrangement
1082 * Here's my conclusion: 1099 * Here's my conclusion:
1113#endif 1130#endif
1114#ifdef CURSOR_BLINK 1131#ifdef CURSOR_BLINK
1115 if (Options & Opt_cursorBlink) 1132 if (Options & Opt_cursorBlink)
1116 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1133 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1117#endif 1134#endif
1135#ifdef OFF_FOCUS_FADING
1136 if (rs[Rs_fade])
1137 {
1138 PixColors = PixColorsFocused;
1139 set_colorfgbg ();
1140 scr_clear ();
1141 scr_touch (true);
1142 }
1143#endif
1118 1144
1119 } 1145 }
1120 break; 1146 break;
1121 1147
1122 case FocusOut: 1148 case FocusOut:
1131#ifdef CURSOR_BLINK 1157#ifdef CURSOR_BLINK
1132 if (Options & Opt_cursorBlink) 1158 if (Options & Opt_cursorBlink)
1133 cursor_blink_ev.stop (); 1159 cursor_blink_ev.stop ();
1134 hidden_cursor = 0; 1160 hidden_cursor = 0;
1135#endif 1161#endif
1162#ifdef OFF_FOCUS_FADING
1163 if (rs[Rs_fade])
1164 {
1165 PixColors = PixColorsUnFocused;
1166 set_colorfgbg ();
1167 scr_clear ();
1168 scr_touch (true);
1169 }
1170#endif
1136 1171
1137 } 1172 }
1138 break; 1173 break;
1139 1174
1140 case ConfigureNotify: 1175 case ConfigureNotify:
1149 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); 1184 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
1150 } 1185 }
1151 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); 1186 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev));
1152 1187
1153 if (szHint.width != width || szHint.height != height) 1188 if (szHint.width != width || szHint.height != height)
1154 {
1155 D_SIZE ((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height));
1156 resize_all_windows (width, height, 1); 1189 resize_all_windows (width, height, 1);
1157 } 1190
1158#ifdef DEBUG_SIZE
1159 else
1160 {
1161 D_SIZE ((stderr, "Size: Not resizing"));
1162 }
1163#endif
1164#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1191#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1165 if (Options & Opt_transparent) 1192 if (Options & Opt_transparent)
1166 { 1193 {
1167 check_our_parents (); 1194 check_our_parents ();
1168 if (am_transparent) 1195 if (am_transparent)
1169 want_full_refresh = 1; 1196 want_refresh = want_full_refresh = 1;
1170 } 1197 }
1171#endif 1198#endif
1172 } 1199 }
1173 break; 1200 break;
1174 1201
1208 1235
1209 case GraphicsExpose: 1236 case GraphicsExpose:
1210 case Expose: 1237 case Expose:
1211 if (ev.xany.window == TermWin.vt) 1238 if (ev.xany.window == TermWin.vt)
1212 { 1239 {
1213#ifdef NO_SLOW_LINK_SUPPORT 1240 do
1214 scr_expose (ev.xexpose.x, ev.xexpose.y, 1241 scr_expose (ev.xexpose.x, ev.xexpose.y,
1215 ev.xexpose.width, ev.xexpose.height, False); 1242 ev.xexpose.width, ev.xexpose.height, False);
1216#else 1243 while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev));
1217 // I don't understand this, so I changed it :) 1244
1245 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1246
1247 while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev))
1218 scr_expose (ev.xexpose.x, ev.xexpose.y, 1248 scr_expose (ev.xexpose.x, ev.xexpose.y,
1219 ev.xexpose.width, ev.xexpose.height, False); 1249 ev.xexpose.width, ev.xexpose.height, False);
1220 //scr_expose (ev.xexpose.x, 0, 1250
1221 // ev.xexpose.width, TermWin.height, False); 1251 scr_refresh (refresh_type);
1222#endif
1223 want_refresh = 1;
1224 } 1252 }
1225 else 1253 else
1226 { 1254 {
1227 XEvent unused_event; 1255 XEvent unused_event;
1228 1256
1237 scrollbar_show (0); 1265 scrollbar_show (0);
1238 } 1266 }
1239#ifdef MENUBAR 1267#ifdef MENUBAR
1240 if (menubar_visible () && isMenuBarWindow (ev.xany.window)) 1268 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1241 menubar_expose (); 1269 menubar_expose ();
1270#endif
1271
1272#ifdef TRANSPARENT
1273 if (am_transparent && ev.xany.window == TermWin.parent[0])
1274 XClearWindow (display->display, ev.xany.window);
1242#endif 1275#endif
1243 } 1276 }
1244 break; 1277 break;
1245 1278
1246 case MotionNotify: 1279 case MotionNotify:
1379 } 1412 }
1380 1413
1381 /* FALLTHROUGH */ 1414 /* FALLTHROUGH */
1382 case ReparentNotify: 1415 case ReparentNotify:
1383 if ((Options & Opt_transparent) && check_our_parents () && am_transparent) 1416 if ((Options & Opt_transparent) && check_our_parents () && am_transparent)
1384 want_full_refresh = 1; 1417 want_refresh = want_full_refresh = 1;
1385 break; 1418 break;
1386#endif 1419#endif
1387 } 1420 }
1388} 1421}
1389 1422
1571 break; 1604 break;
1572 case R_SB_ALIGN_BOTTOM: 1605 case R_SB_ALIGN_BOTTOM:
1573 csrO = scrollBar.bot - scrollBar.top; 1606 csrO = scrollBar.bot - scrollBar.top;
1574 break; 1607 break;
1575 } 1608 }
1609
1576 if (scrollBar.style == R_SB_XTERM 1610 if (scrollBar.style == R_SB_XTERM
1577 || scrollbar_above_slider (ev.y) 1611 || scrollbar_above_slider (ev.y)
1578 || scrollbar_below_slider (ev.y)) 1612 || scrollbar_below_slider (ev.y))
1579 scr_move_to ( scrollbar_position (ev.y) - csrO, 1613 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ());
1580 scrollbar_size ()); 1614
1581 scrollBar.setMotion (); 1615 scrollBar.setMotion ();
1582 break; 1616 break;
1583 1617
1584 case Button1: 1618 case Button1:
1585 if (scrollbar_align == R_SB_ALIGN_CENTRE) 1619 if (scrollbar_align == R_SB_ALIGN_CENTRE)
1609 scr_page ((ev.button == Button1 ? DN : UP), 1643 scr_page ((ev.button == Button1 ? DN : UP),
1610 (TermWin.nrow 1644 (TermWin.nrow
1611 * scrollbar_position (ev.y) 1645 * scrollbar_position (ev.y)
1612 / scrollbar_size ())); 1646 / scrollbar_size ()));
1613 } 1647 }
1648
1614 break; 1649 break;
1615 } 1650 }
1616 } 1651 }
1617 return; 1652 return;
1618 } 1653 }
1708 1743
1709# ifdef MOUSE_SLIP_WHEELING 1744# ifdef MOUSE_SLIP_WHEELING
1710 if (ev.state & ControlMask) 1745 if (ev.state & ControlMask)
1711 { 1746 {
1712 mouse_slip_wheel_speed += v ? -1 : 1; 1747 mouse_slip_wheel_speed += v ? -1 : 1;
1748 if (mouse_slip_wheel_speed < -TermWin.nrow) mouse_slip_wheel_speed = -TermWin.nrow;
1749 if (mouse_slip_wheel_speed > +TermWin.nrow) mouse_slip_wheel_speed = +TermWin.nrow;
1750
1751 if (slip_wheel_ev.at < NOW)
1713 slip_wheel_ev.start (NOW + SCROLLBAR_CONTINUOUS_DELAY); 1752 slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY;
1753
1754 slip_wheel_ev.start ();
1714 } 1755 }
1756 else
1757 {
1715# endif 1758# endif
1716# ifdef JUMP_MOUSE_WHEEL 1759# ifdef JUMP_MOUSE_WHEEL
1717 scr_page (v, i);
1718 scr_refresh (SMOOTH_REFRESH);
1719 scrollbar_show (1);
1720# else
1721 while (i--)
1722 {
1723 scr_page (v, 1); 1760 scr_page (v, i);
1724 scr_refresh (SMOOTH_REFRESH); 1761 scr_refresh (SMOOTH_REFRESH);
1725 scrollbar_show (1); 1762 scrollbar_show (1);
1763# else
1764 while (i--)
1765 {
1766 scr_page (v, 1);
1767 scr_refresh (SMOOTH_REFRESH);
1768 scrollbar_show (1);
1769 }
1770# endif
1771# ifdef MOUSE_SLIP_WHEELING
1726 } 1772 }
1727# endif 1773#endif
1728
1729 } 1774 }
1730 break; 1775 break;
1731#endif 1776#endif
1732
1733 } 1777 }
1734 } 1778 }
1735#ifdef MENUBAR 1779#ifdef MENUBAR
1736 else if (isMenuBarWindow (ev.window)) 1780 else if (isMenuBarWindow (ev.window))
1737 menubar_control (ev); 1781 menubar_control (ev);
1738#endif 1782#endif
1739} 1783}
1740 1784
1741#ifdef TRANSPARENT 1785#ifdef TRANSPARENT
1742#if TINTING 1786#if TINTING
1743/* shading taken from eterm-0.9.2 */ 1787/* taken from aterm-0.4.2 */
1744/* RGB 15 */
1745 1788
1746static void 1789typedef uint32_t RUINT32T;
1747shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1748{
1749 unsigned char *ptr;
1750 int x, y;
1751 1790
1752 ptr = (unsigned char *)data + (w * sizeof(uint16_t)); 1791void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm)
1753 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { 1792{
1754 /* No saturation */ 1793 int sh_r, sh_g, sh_b;
1755 for (y = h; --y >= 0;) { 1794 RUINT32T mask_r, mask_g, mask_b;
1756 for (x = -w; x < 0; x++) { 1795 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
1757 int r, g, b; 1796 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
1797 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
1798 int i;
1758 1799
1759 b = ((uint16_t *) ptr)[x]; 1800 Visual* visual = display->visual;
1760 r = (b & 0x7c00) * rm; 1801
1761 g = (b & 0x3e0) * gm; 1802 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
1762 b = (b & 0x1f) * bm; 1803
1763 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) 1804 /* for convenience */
1764 | ((g >> 8) & 0x3e0) 1805 mask_r = visual->red_mask;
1765 | ((b >> 8) & 0x1f); 1806 mask_g = visual->green_mask;
1766 } 1807 mask_b = visual->blue_mask;
1767 ptr += bpl; 1808
1768 } 1809 /* boring lookup table pre-initialization */
1810 switch (srcImage->bits_per_pixel) {
1811 case 15:
1812 if ((mask_r != 0x7c00) ||
1813 (mask_g != 0x03e0) ||
1814 (mask_b != 0x001f))
1815 return;
1816 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32));
1817 lookup_r = lookup;
1818 lookup_g = lookup+32;
1819 lookup_b = lookup+32+32;
1820 sh_r = 10;
1821 sh_g = 5;
1822 sh_b = 0;
1823 break;
1824 case 16:
1825 if ((mask_r != 0xf800) ||
1826 (mask_g != 0x07e0) ||
1827 (mask_b != 0x001f))
1828 return;
1829 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32));
1830 lookup_r = lookup;
1831 lookup_g = lookup+32;
1832 lookup_b = lookup+32+64;
1833 sh_r = 11;
1834 sh_g = 5;
1835 sh_b = 0;
1836 break;
1837 case 24:
1838 if ((mask_r != 0xff0000) ||
1839 (mask_g != 0x00ff00) ||
1840 (mask_b != 0x0000ff))
1841 return;
1842 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
1843 lookup_r = lookup;
1844 lookup_g = lookup+256;
1845 lookup_b = lookup+256+256;
1846 sh_r = 16;
1847 sh_g = 8;
1848 sh_b = 0;
1849 break;
1850 case 32:
1851 if ((mask_r != 0xff0000) ||
1852 (mask_g != 0x00ff00) ||
1853 (mask_b != 0x0000ff))
1854 return;
1855 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
1856 lookup_r = lookup;
1857 lookup_g = lookup+256;
1858 lookup_b = lookup+256+256;
1859 sh_r = 16;
1860 sh_g = 8;
1861 sh_b = 0;
1862 break;
1863 default:
1864 return; /* we do not support this color depth */
1865 }
1866
1867 /* prepare limits for color transformation (each channel is handled separately) */
1868 if (shade < 0) {
1869 shade = -shade;
1870 if (shade < 0) shade = 0;
1871 if (shade > 100) shade = 100;
1872
1873 lower_lim_r = 65535-rm;
1874 lower_lim_g = 65535-gm;
1875 lower_lim_b = 65535-bm;
1876
1877 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100);
1878 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
1879 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
1880
1881 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1769 } else { 1882 } else {
1770 for (y = h; --y >= 0;) { 1883 if (shade < 0) shade = 0;
1771 for (x = -w; x < 0; x++) { 1884 if (shade > 100) shade = 100;
1772 int r, g, b;
1773 1885
1774 b = ((uint16_t *) ptr)[x]; 1886 lower_lim_r = lower_lim_g = lower_lim_b = 0;
1775 r = (b & 0x7c00) * rm; 1887
1776 g = (b & 0x3e0) * gm; 1888 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
1777 b = (b & 0x1f) * bm; 1889 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);
1778 r |= (!(r >> 15) - 1); 1890 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100);
1779 g |= (!(g >> 10) - 1); 1891 }
1780 b |= (!(b >> 5) - 1); 1892
1781 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) 1893 /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */
1782 | ((g >> 8) & 0x3e0) 1894 if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 ))
1783 | ((b >> 8) & 0x1f); 1895 {
1784 } 1896 unsigned int tmp;
1785 ptr += bpl; 1897
1898 tmp = lower_lim_r;
1899 lower_lim_r = lower_lim_b;
1900 lower_lim_b = tmp;
1901
1902 tmp = upper_lim_r;
1903 upper_lim_r = upper_lim_b;
1904 upper_lim_b = tmp;
1905 }
1906
1907 /* fill our lookup tables */
1908 for (i = 0; i <= mask_r>>sh_r; i++)
1909 {
1910 RUINT32T tmp;
1911 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r));
1912 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r);
1913 lookup_r[i] = (tmp/65535)<<sh_r;
1914 }
1915 for (i = 0; i <= mask_g>>sh_g; i++)
1916 {
1917 RUINT32T tmp;
1918 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g));
1919 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g);
1920 lookup_g[i] = (tmp/65535)<<sh_g;
1921 }
1922 for (i = 0; i <= mask_b>>sh_b; i++)
1923 {
1924 RUINT32T tmp;
1925 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b));
1926 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b);
1927 lookup_b[i] = (tmp/65535)<<sh_b;
1928 }
1929
1930 /* apply table to input image (replacing colors by newly calculated ones) */
1931 switch (srcImage->bits_per_pixel)
1932 {
1933 case 15:
1934 {
1935 unsigned short *p1, *pf, *p, *pl;
1936 p1 = (unsigned short *) srcImage->data;
1937 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1938 while (p1 < pf)
1939 {
1940 p = p1;
1941 pl = p1 + srcImage->width;
1942 for (; p < pl; p++)
1786 } 1943 {
1944 *p = lookup_r[(*p & 0x7c00)>>10] |
1945 lookup_g[(*p & 0x03e0)>> 5] |
1946 lookup_b[(*p & 0x001f)];
1947 }
1948 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
1787 } 1949 }
1788} 1950 break;
1789 1951 }
1790/* RGB 16 */ 1952 case 16:
1791static void 1953 {
1792shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm) 1954 unsigned short *p1, *pf, *p, *pl;
1793{ 1955 p1 = (unsigned short *) srcImage->data;
1794 unsigned char *ptr; 1956 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1795 int x, y; 1957 while (p1 < pf)
1796 1958 {
1797 ptr = (unsigned char *)data + (w * sizeof(uint16_t)); 1959 p = p1;
1798 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { 1960 pl = p1 + srcImage->width;
1799 /* No saturation */ 1961 for (; p < pl; p++)
1800 for (y = h; --y >= 0;) {
1801 for (x = -w; x < 0; x++) {
1802 int r, g, b;
1803
1804 b = ((uint16_t *) ptr)[x];
1805 r = (b & 0xf800) * rm;
1806 g = (b & 0x7e0) * gm;
1807 b = (b & 0x1f) * bm;
1808 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1809 | ((g >> 8) & 0x7e0)
1810 | ((b >> 8) & 0x1f);
1811 }
1812 ptr += bpl;
1813 } 1962 {
1814 } else { 1963 *p = lookup_r[(*p & 0xf800)>>11] |
1815 for (y = h; --y >= 0;) { 1964 lookup_g[(*p & 0x07e0)>> 5] |
1816 for (x = -w; x < 0; x++) { 1965 lookup_b[(*p & 0x001f)];
1817 int r, g, b;
1818
1819 b = ((uint16_t *) ptr)[x];
1820 r = (b & 0xf800) * rm;
1821 g = (b & 0x7e0) * gm;
1822 b = (b & 0x1f) * bm;
1823 r |= (!(r >> 16) - 1);
1824 g |= (!(g >> 11) - 1);
1825 b |= (!(b >> 5) - 1);
1826 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1827 | ((g >> 8) & 0x7e0)
1828 | ((b >> 8) & 0x1f);
1829 } 1966 }
1830 ptr += bpl; 1967 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
1968 }
1969 break;
1970 }
1971 case 24:
1972 {
1973 unsigned char *p1, *pf, *p, *pl;
1974 p1 = (unsigned char *) srcImage->data;
1975 pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1976 while (p1 < pf)
1977 {
1978 p = p1;
1979 pl = p1 + srcImage->width * 3;
1980 for (; p < pl; p += 3)
1831 } 1981 {
1982 p[0] = lookup_r[(p[0] & 0xff0000)>>16];
1983 p[1] = lookup_r[(p[1] & 0x00ff00)>> 8];
1984 p[2] = lookup_r[(p[2] & 0x0000ff)];
1985 }
1986 p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line);
1832 } 1987 }
1833} 1988 break;
1989 }
1990 case 32:
1991 {
1992 RUINT32T *p1, *pf, *p, *pl;
1993 p1 = (RUINT32T *) srcImage->data;
1994 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1834 1995
1835/* RGB 24 */ 1996 while (p1 < pf)
1836static void 1997 {
1837shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm) 1998 p = p1;
1838{ 1999 pl = p1 + srcImage->width;
1839 unsigned char *ptr; 2000 for (; p < pl; p++)
1840 int x, y;
1841
1842 ptr = (unsigned char *)data + (w * 3);
1843 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1844 /* No saturation */
1845 for (y = h; --y >= 0;) {
1846 for (x = -(w * 3); x < 0; x += 3) {
1847 int r, g, b;
1848
1849 if (byteorder.big_endian()) {
1850 r = (ptr[x + 0] * rm) >> 8;
1851 g = (ptr[x + 1] * gm) >> 8;
1852 b = (ptr[x + 2] * bm) >> 8;
1853 ptr[x + 0] = r;
1854 ptr[x + 1] = g;
1855 ptr[x + 2] = b;
1856 } else {
1857 r = (ptr[x + 2] * rm) >> 8;
1858 g = (ptr[x + 1] * gm) >> 8;
1859 b = (ptr[x + 0] * bm) >> 8;
1860 ptr[x + 2] = r;
1861 ptr[x + 1] = g;
1862 ptr[x + 0] = b;
1863 }
1864 }
1865 ptr += bpl;
1866 } 2001 {
1867 } else { 2002 *p = lookup_r[(*p & 0xff0000)>>16] |
1868 for (y = h; --y >= 0;) { 2003 lookup_g[(*p & 0x00ff00)>> 8] |
1869 for (x = -(w * 3); x < 0; x += 3) { 2004 lookup_b[(*p & 0x0000ff)] |
1870 int r, g, b; 2005 (*p & ~0xffffff);
1871
1872 if (byteorder.big_endian()) {
1873 r = (ptr[x + 0] * rm) >> 8;
1874 g = (ptr[x + 1] * gm) >> 8;
1875 b = (ptr[x + 2] * bm) >> 8;
1876
1877 r |= (!(r >> 8) - 1);
1878 g |= (!(g >> 8) - 1);
1879 b |= (!(b >> 8) - 1);
1880
1881 ptr[x + 0] = r;
1882 ptr[x + 1] = g;
1883 ptr[x + 2] = b;
1884 } else {
1885 r = (ptr[x + 2] * rm) >> 8;
1886 g = (ptr[x + 1] * gm) >> 8;
1887 b = (ptr[x + 0] * bm) >> 8;
1888
1889 r |= (!(r >> 8) - 1);
1890 g |= (!(g >> 8) - 1);
1891 b |= (!(b >> 8) - 1);
1892
1893 ptr[x + 2] = r;
1894 ptr[x + 1] = g;
1895 ptr[x + 0] = b;
1896 }
1897 } 2006 }
1898 ptr += bpl; 2007 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line);
1899 } 2008 }
2009 break;
2010 }
1900 } 2011 }
1901}
1902 2012
1903/* RGB 32 */ 2013 free (lookup);
1904static void
1905shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1906{
1907 unsigned char *ptr;
1908 int x, y;
1909
1910 ptr = (unsigned char *)data + (w * 4);
1911 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1912 /* No saturation */
1913 for (y = h; --y >= 0;) {
1914 if (byteorder.big_endian()) {
1915 for (x = -(w * 4); x < 0; x += 4) {
1916 int r, g, b;
1917
1918 r = (ptr[x + 1] * rm) >> 8;
1919 g = (ptr[x + 2] * gm) >> 8;
1920 b = (ptr[x + 3] * bm) >> 8;
1921 ptr[x + 1] = r;
1922 ptr[x + 2] = g;
1923 ptr[x + 3] = b;
1924 }
1925 } else {
1926 for (x = -(w * 4); x < 0; x += 4) {
1927 int r, g, b;
1928
1929 r = (ptr[x + 2] * rm) >> 8;
1930 g = (ptr[x + 1] * gm) >> 8;
1931 b = (ptr[x + 0] * bm) >> 8;
1932 ptr[x + 2] = r;
1933 ptr[x + 1] = g;
1934 ptr[x + 0] = b;
1935 }
1936 }
1937 ptr += bpl;
1938 }
1939 } else {
1940 for (y = h; --y >= 0;) {
1941 for (x = -(w * 4); x < 0; x += 4) {
1942 int r, g, b;
1943
1944 if (byteorder.big_endian()) {
1945 r = (ptr[x + 1] * rm) >> 8;
1946 g = (ptr[x + 2] * gm) >> 8;
1947 b = (ptr[x + 3] * bm) >> 8;
1948
1949 r |= (!(r >> 8) - 1);
1950 g |= (!(g >> 8) - 1);
1951 b |= (!(b >> 8) - 1);
1952
1953 ptr[x + 1] = r;
1954 ptr[x + 2] = g;
1955 ptr[x + 3] = b;
1956 } else {
1957 r = (ptr[x + 2] * rm) >> 8;
1958 g = (ptr[x + 1] * gm) >> 8;
1959 b = (ptr[x + 0] * bm) >> 8;
1960
1961 r |= (!(r >> 8) - 1);
1962 g |= (!(g >> 8) - 1);
1963 b |= (!(b >> 8) - 1);
1964
1965 ptr[x + 2] = r;
1966 ptr[x + 1] = g;
1967 ptr[x + 0] = b;
1968 }
1969 }
1970 ptr += bpl;
1971 }
1972 }
1973} 2014}
1974
1975#endif 2015#endif
1976 2016
1977/* 2017/*
1978 * Check our parents are still who we think they are. 2018 * Check our parents are still who we think they are.
1979 * Do transparency updates if required 2019 * Do transparency updates if required
2002 if (rootdepth != wattr.depth) 2042 if (rootdepth != wattr.depth)
2003 { 2043 {
2004 if (am_transparent) 2044 if (am_transparent)
2005 { 2045 {
2006 pchanged = 1; 2046 pchanged = 1;
2007 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); 2047 XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]);
2008 am_transparent = am_pixmap_trans = 0; 2048 am_transparent = am_pixmap_trans = 0;
2009 } 2049 }
2010 2050
2011 return pchanged; /* Don't try any more */ 2051 return pchanged; /* Don't try any more */
2012 } 2052 }
2028 i = (xa[XA_XSETROOTID] 2068 i = (xa[XA_XSETROOTID]
2029 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], 2069 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID],
2030 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2070 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2031 &nitems, &bytes_after, &prop) == Success); 2071 &nitems, &bytes_after, &prop) == Success);
2032 2072
2033 if (!i || prop == NULL) 2073 if (!i || prop == NULL
2074#if TINTING
2075 || !rs[Rs_color + Color_tint]
2076#endif
2077 )
2034 have_pixmap = 0; 2078 have_pixmap = 0;
2035 else 2079 else
2036 { 2080 {
2037 have_pixmap = 1; 2081 have_pixmap = 1;
2038 rootpixmap = *(Pixmap *)prop; 2082 rootpixmap = *(Pixmap *)prop;
2100 XFreePixmap (display->display, TermWin.pixmap); 2144 XFreePixmap (display->display, TermWin.pixmap);
2101 2145
2102#if TINTING 2146#if TINTING
2103 if (ISSET_PIXCOLOR (Color_tint)) 2147 if (ISSET_PIXCOLOR (Color_tint))
2104 { 2148 {
2105 unsigned short shade, rm, gm, bm; 2149 unsigned short rm, gm, bm;
2150 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2106 2151
2107 PixColors[Color_tint].get (display, rm, gm, bm); 2152 PixColorsFocused[Color_tint].get (display, rm, gm, bm);
2108 2153
2109 rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but... 2154 ShadeXImage (display, image, shade, rm, gm, bm);
2110
2111 /* Determine bitshift and bitmask values */
2112 switch (image->bits_per_pixel)
2113 {
2114 case 15: shade_ximage_15 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2115 case 16: shade_ximage_16 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2116 case 24: shade_ximage_24 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2117 case 32: shade_ximage_32 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2118 }
2119 } 2155 }
2120#endif 2156#endif
2121 2157
2122 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 2158 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt,
2123 szHint.width, szHint.height, image->depth); 2159 szHint.width, szHint.height, image->depth);
2124 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); 2160 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue);
2125 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, 2161 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0,
2126 nx, ny, image->width, image->height); 2162 nx, ny, image->width, image->height);
2127 XFreeGC (display->display, gc); 2163 XFreeGC (display->display, gc);
2128 XDestroyImage (image); 2164 XDestroyImage (image);
2129 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2165 XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap);
2130 TermWin.pixmap); 2166 XClearWindow (display->display, TermWin.parent[0]);
2131 2167
2132 if (!am_transparent || !am_pixmap_trans) 2168 if (!am_transparent || !am_pixmap_trans)
2133 pchanged = 1; 2169 pchanged = 1;
2134 2170
2135 am_transparent = am_pixmap_trans = 1; 2171 am_transparent = am_pixmap_trans = 1;
2180 } 2216 }
2181 2217
2182 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) 2218 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
2183 { 2219 {
2184 D_X ((stderr, "InheritPixmap Turning off")); 2220 D_X ((stderr, "InheritPixmap Turning off"));
2185 XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]); 2221 XSetWindowBackground (display->display, TermWin.parent[0], PixColorsFocused[Color_fg]);
2186 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); 2222 XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]);
2187 am_transparent = 0; 2223 am_transparent = 0;
2188 /* XXX: also turn off Opt_transparent? */ 2224 /* XXX: also turn off Opt_transparent? */
2189 } 2225 }
2190 else 2226 else
2191 { 2227 {
2194 * needed for fvwm2.2.2 (and before?) */ 2230 * needed for fvwm2.2.2 (and before?) */
2195 sleep (1); 2231 sleep (1);
2196#endif 2232#endif
2197 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); 2233 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
2198 for (n = 0; n < (unsigned int)i; n++) 2234 for (n = 0; n < (unsigned int)i; n++)
2235 {
2199 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); 2236 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative);
2237 XClearWindow (display->display, TermWin.parent[n]);
2238 }
2200 2239
2201 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); 2240 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
2202 am_transparent = 1; 2241 am_transparent = 1;
2203 } 2242 }
2204 2243
2205 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2244 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2206 TermWin.parent[i] = None; 2245 TermWin.parent[i] = None;
2246 }
2247
2248 // this is experimental
2249 if (scrollBar.win)
2250 {
2251 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
2252 XClearWindow (display->display, scrollBar.win);
2253 scrollBar.setIdle ();
2254 scrollbar_show (0);
2207 } 2255 }
2208 2256
2209 return pchanged; 2257 return pchanged;
2210} 2258}
2211#endif 2259#endif
2236 unicode_t buf[UBUFSIZ]; 2284 unicode_t buf[UBUFSIZ];
2237 bool refreshnow = false; 2285 bool refreshnow = false;
2238 int nlines = 0; 2286 int nlines = 0;
2239 unicode_t *str = buf; 2287 unicode_t *str = buf;
2240 2288
2241 *str++ = ch;
2242
2243 for (;;) 2289 for (;;)
2244 { 2290 {
2245 seq_begin = cmdbuf_ptr;
2246 ch = next_char ();
2247
2248 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2291 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))
2249 break; 2292 break;
2250 2293
2251 *str++ = ch; 2294 *str++ = ch;
2252 2295
2253 if (ch == C0_LF) 2296 if (ch == C0_LF)
2254 { 2297 {
2255 nlines++; 2298 nlines++;
2256 refresh_count++; 2299 refresh_count++;
2257 2300
2258 if (! (Options & Opt_jumpScroll) 2301 if (!(Options & Opt_jumpScroll)
2259 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) 2302 || (refresh_count >= refresh_limit * (TermWin.nrow - 1)))
2260 { 2303 {
2261 refreshnow = true; 2304 refreshnow = true;
2262 flag = true;
2263 ch = NOCHAR; 2305 ch = NOCHAR;
2264 break; 2306 break;
2265 } 2307 }
2266 2308
2267 // scr_add_lines only works for nlines < TermWin.nrow - 1. 2309 // scr_add_lines only works for nlines <= TermWin.nrow - 1.
2268 if (nlines >= TermWin.nrow - 1) 2310 if (nlines >= TermWin.nrow - 1)
2269 { 2311 {
2270 scr_add_lines (buf, nlines, str - buf); 2312 scr_add_lines (buf, nlines, str - buf);
2271 nlines = 0; 2313 nlines = 0;
2272 str = buf; 2314 str = buf;
2276 if (str >= buf + UBUFSIZ) 2318 if (str >= buf + UBUFSIZ)
2277 { 2319 {
2278 ch = NOCHAR; 2320 ch = NOCHAR;
2279 break; 2321 break;
2280 } 2322 }
2323
2324 seq_begin = cmdbuf_ptr;
2325 ch = next_char ();
2281 } 2326 }
2282 2327
2283 scr_add_lines (buf, nlines, str - buf); 2328 scr_add_lines (buf, nlines, str - buf);
2284 2329
2285 /* 2330 /*
2286 * If there have been a lot of new lines, then update the screen 2331 * If there have been a lot of new lines, then update the screen
2287 * What the heck I'll cheat and only refresh less than every page-full. 2332 * What the heck I'll cheat and only refresh less than every page-full.
2288 * the number of pages between refreshes is refresh_limit, which 2333 * the number of pages between refreshes is refresh_limit, which
2289 * is incremented here because we must be doing flat-out scrolling. 2334 * is incremented here because we must be doing flat-out scrolling.
2290 *
2291 * refreshing should be correct for small scrolls, because of the
2292 * time-out
2293 */ 2335 */
2294 if (refreshnow) 2336 if (refreshnow)
2295 { 2337 {
2296 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2338 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2297 refresh_limit++; 2339 refresh_limit++;
2298 else 2340 else
2341 {
2342 flag = true;
2299 scr_refresh (refresh_type); 2343 scr_refresh (refresh_type);
2344 }
2300 } 2345 }
2301 2346
2302 } 2347 }
2303 else 2348 else
2304 { 2349 {
3252 if (str[0] == '?' && !str[1]) 3297 if (str[0] == '?' && !str[1])
3253 { 3298 {
3254 if (Options & Opt_insecure) 3299 if (Options & Opt_insecure)
3255 { 3300 {
3256 unsigned short r, g, b; 3301 unsigned short r, g, b;
3257 PixColors[color].get (display, r, g, b); 3302 PixColorsFocused[color].get (display, r, g, b);
3258 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); 3303 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp);
3259 } 3304 }
3260 } 3305 }
3261 else 3306 else
3262 set_window_color (color, str); 3307 set_window_color (color, str);
3367 if (name[0] == '?' && !name[1]) 3412 if (name[0] == '?' && !name[1])
3368 { 3413 {
3369 if (Options & Opt_insecure) 3414 if (Options & Opt_insecure)
3370 { 3415 {
3371 unsigned short r, g, b; 3416 unsigned short r, g, b;
3372 PixColors[color + minCOLOR].get (display, r, g, b); 3417 PixColorsFocused[color + minCOLOR].get (display, r, g, b);
3373 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3418 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3374 } 3419 }
3375 } 3420 }
3376 else 3421 else
3377 set_window_color (color + minCOLOR, name); 3422 set_window_color (color + minCOLOR, name);
3750 rendset = 0, rendstyle = ~RS_None; 3795 rendset = 0, rendstyle = ~RS_None;
3751 break; 3796 break;
3752 case 1: 3797 case 1:
3753 rendset = 1, rendstyle = RS_Bold; 3798 rendset = 1, rendstyle = RS_Bold;
3754 break; 3799 break;
3800 //case 2: // faint or second colour
3755 case 4: 3801 case 4:
3756 rendset = 1, rendstyle = RS_Uline; 3802 rendset = 1, rendstyle = RS_Uline;
3757 break; 3803 break;
3758 case 5: 3804 case 5: // slowly blinking
3805 case 6: // rapidly blinking
3759 rendset = 1, rendstyle = RS_Blink; 3806 rendset = 1, rendstyle = RS_Blink;
3760 break; 3807 break;
3761 //case 6: // scoansi light background 3808 //case 6: // scoansi light background
3762 case 7: 3809 case 7:
3763 rendset = 1, rendstyle = RS_RVid; 3810 rendset = 1, rendstyle = RS_RVid;
3764 break; 3811 break;
3765 case 8: 3812 case 8:
3766 // invisible. NYI 3813 // invisible. NYI
3767 break; 3814 break;
3815 //case 9: // crossed out
3768 //case 10: // scoansi acs off 3816 //case 10: // scoansi acs off, primary font
3769 //case 11: // scoansi acs on 3817 //case 11: // scoansi acs on, first alt font
3770 //case 12: // scoansi acs on, |0x80 3818 //case 12: // scoansi acs on, |0x80, second alt font
3771 case 21: // disable bold, blink and invis (some terminals use this) 3819 //...
3820 //case 19: // ninth alt font
3821 //case 20: // gothic
3822 case 21: // disable bold, faint
3772 rendset = 0, rendstyle = RS_Bold | RS_Blink; 3823 rendset = 0, rendstyle = RS_Bold;
3773 break; 3824 break;
3774 case 22: 3825 case 22:
3775 rendset = 0, rendstyle = RS_Bold; 3826 rendset = 0, rendstyle = RS_Bold;
3776 break; 3827 break;
3828 //case 23: disable italic
3777 case 24: 3829 case 24:
3778 rendset = 0, rendstyle = RS_Uline; 3830 rendset = 0, rendstyle = RS_Uline;
3779 break; 3831 break;
3780 case 25: 3832 case 25:
3781 rendset = 0, rendstyle = RS_Blink; 3833 rendset = 0, rendstyle = RS_Blink;
3782 break; 3834 break;
3783 case 27: 3835 case 27:
3784 rendset = 0, rendstyle = RS_RVid; 3836 rendset = 0, rendstyle = RS_RVid;
3785 break; 3837 break;
3786 case 28:
3787 // visible. NYI 3838 //case 28: // visible. NYI
3788 break; 3839 //case 29: // not crossed-out
3789 } 3840 }
3790 3841
3791 if (rendset != -1) 3842 if (rendset != -1)
3792 { 3843 {
3793 scr_rendition (rendset, rendstyle); 3844 scr_rendition (rendset, rendstyle);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines