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.321 by root, Tue May 1 21:30:01 2007 UTC vs.
Revision 1.348 by sasha, Thu Aug 16 21:26:20 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,
500# if ISO_14755 499# if ISO_14755
501 iso14755_51 (0); 500 iso14755_51 (0);
502# endif 501# endif
503 return; 502 return;
504 } 503 }
504 else if (keysym == XK_BackSpace)
505 {
506 iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51;
507# if ISO_14755
508 iso14755_51 (iso14755buf & ISO_14755_MASK);
509# endif
510 return;
511 }
505 else if ((hv = hex_keyval (ev)) >= 0) 512 else if ((hv = hex_keyval (ev)) >= 0)
506 { 513 {
507 iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) 514 iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK)
508 | hv | ISO_14755_51; 515 | hv | ISO_14755_51;
509# if ISO_14755 516# if ISO_14755
511# endif 518# endif
512 return; 519 return;
513 } 520 }
514 else 521 else
515 { 522 {
516# if ENABLE_OVERLAY 523# if ISO_14755
517 scr_overlay_off (); 524 scr_overlay_off ();
518# endif 525# endif
519 iso14755buf = 0; 526 iso14755buf = 0;
520 } 527 }
521 } 528 }
522 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) 529 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
523 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) 530 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))
524 if (!(iso14755buf & ISO_14755_STARTED)) 531 if (!(iso14755buf & ISO_14755_STARTED))
525 { 532 {
526 iso14755buf |= ISO_14755_STARTED; 533 iso14755buf |= ISO_14755_STARTED;
527# if ENABLE_OVERLAY 534# if ISO_14755
528 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); 535 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1);
529 scr_overlay_set (0, 0, "ISO 14755 mode"); 536 scr_overlay_set (0, 0, "ISO 14755 mode");
530# endif 537# endif
531 } 538 }
532#endif 539#endif
533 540
534#ifdef PRINTPIPE 541#ifdef PRINTPIPE
535 if (keysym == XK_Print) 542 if (keysym == XK_Print)
536 { 543 {
537 scr_printscreen (ctrl | shft); 544 scr_printscreen (ctrl | shft);
538 return; 545 return;
720 727
721 case XK_Find: 728 case XK_Find:
722 strcpy (kbuf, "\033[1~"); 729 strcpy (kbuf, "\033[1~");
723 break; 730 break;
724 731
725#ifdef XK_KP_End 732#ifdef XK_KP_Insert
726 case XK_KP_Insert: 733 case XK_KP_Insert:
727 /* allow shift to override */ 734 /* allow shift to override */
728 if ((priv_modes & PrivMode_aplKP) ? !shft : shft) 735 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
729 { 736 {
730 strcpy (kbuf, "\033Op"); 737 strcpy (kbuf, "\033Op");
926#if ENABLE_FRILLS || ISO_14755 933#if ENABLE_FRILLS || ISO_14755
927 // ISO 14755 support 934 // ISO 14755 support
928 if (iso14755buf) 935 if (iso14755buf)
929 if (iso14755buf & ISO_14755_52) 936 if (iso14755buf & ISO_14755_52)
930 { 937 {
931# if ENABLE_OVERLAY 938# if ISO_14755
932 scr_overlay_off (); 939 scr_overlay_off ();
933# endif 940# endif
934# if ISO_14755 941# if ISO_14755
935 // iso14755 part 5.2 handling: release time 942 // iso14755 part 5.2 handling: release time
936 // first: controls 943 // first: controls
959 966
960 return; 967 return;
961 } 968 }
962 else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) 969 else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask))
963 { 970 {
964# if ENABLE_OVERLAY 971# if ISO_14755
965 scr_overlay_off (); 972 scr_overlay_off ();
966# endif 973# endif
967 if (iso14755buf & ISO_14755_51) 974 if (iso14755buf & ISO_14755_51)
968 commit_iso14755 (); 975 commit_iso14755 ();
969#if ISO_14755 976#if ISO_14755
970 else if (iso14755buf & ISO_14755_STARTED) 977 else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED)
971 { 978 {
972 iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair 979 iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair
973 980
974 scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); 981 scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1);
975 scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); 982 scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE");
1027void 1034void
1028rxvt_term::flush () 1035rxvt_term::flush ()
1029{ 1036{
1030 flush_ev.stop (); 1037 flush_ev.stop ();
1031 1038
1032#ifdef TRANSPARENT 1039#ifdef ENABLE_TRANSPARENCY
1033 if (want_full_refresh) 1040 if (want_full_refresh)
1034 { 1041 {
1035 want_full_refresh = 0; 1042 want_full_refresh = 0;
1036 scr_clear (); 1043 scr_clear ();
1037 scr_touch (false); 1044 scr_touch (false);
1102void 1109void
1103rxvt_term::flush_cb (time_watcher &w) 1110rxvt_term::flush_cb (time_watcher &w)
1104{ 1111{
1105 make_current (); 1112 make_current ();
1106 1113
1107 refresh_limit = 1;
1108 refresh_count = 0; 1114 refresh_count = 0;
1109 flush (); 1115 flush ();
1110} 1116}
1111 1117
1112#ifdef CURSOR_BLINK 1118#ifdef CURSOR_BLINK
1178 1184
1179#if LINUX_YIELD_HACK 1185#if LINUX_YIELD_HACK
1180static struct event_handler 1186static struct event_handler
1181{ 1187{
1182 check_watcher yield_ev; 1188 check_watcher yield_ev;
1183 1189
1184 void yield_cb (check_watcher &w) 1190 void yield_cb (check_watcher &w)
1185 { 1191 {
1186 // this should really be sched_yield(), but the linux guys thought 1192 // this should really be sched_yield(), but the linux guys thought
1187 // that giving a process calling sched_yield () less cpu time than 1193 // that giving a process calling sched_yield () less cpu time than
1188 // 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
1235 pty_ev.stop (); 1241 pty_ev.stop ();
1236 1242
1237 if (!option (Opt_hold)) 1243 if (!option (Opt_hold))
1238 destroy (); 1244 destroy ();
1239 } 1245 }
1240 1246
1241 return false; 1247 return false;
1242} 1248}
1243 1249
1244void 1250void
1245rxvt_term::pty_cb (io_watcher &w, short revents) 1251rxvt_term::pty_cb (io_watcher &w, short revents)
1426 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) 1432 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1427 focus_out (); 1433 focus_out ();
1428 } 1434 }
1429#endif 1435#endif
1430 } 1436 }
1431 break;
1432
1433 case MappingNotify:
1434 XRefreshKeyboardMapping (&ev.xmapping);
1435 break; 1437 break;
1436 1438
1437 /* 1439 /*
1438 * XXX: this is not the _current_ arrangement 1440 * XXX: this is not the _current_ arrangement
1439 * Here's my conclusion: 1441 * Here's my conclusion:
1472 && ev.xfocus.mode != NotifyGrab) 1474 && ev.xfocus.mode != NotifyGrab)
1473 focus_out (); 1475 focus_out ();
1474 break; 1476 break;
1475 1477
1476 case ConfigureNotify: 1478 case ConfigureNotify:
1479/* fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n",
1480 ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y,
1481 szHint.width, szHint.height);*/
1477 if (ev.xconfigure.window == parent[0]) 1482 if (ev.xconfigure.window == parent[0])
1478 { 1483 {
1479 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) 1484 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1480 ; 1485 ;
1481 1486
1482 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1487 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1483 { 1488 {
1484 seen_resize = 1; 1489 seen_resize = 1;
1485 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1490 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1486 } 1491 }
1487 1492 else
1493 {
1494#ifdef ENABLE_TRANSPARENCY
1495 if (option (Opt_transparent))
1496 update_background ();
1497#endif
1498 }
1488 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1499 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1489
1490#ifdef TRANSPARENT
1491 if (option (Opt_transparent))
1492 check_our_parents ();
1493#endif
1494 } 1500 }
1495 break; 1501 break;
1496 1502
1497 case PropertyNotify: 1503 case PropertyNotify:
1498 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) 1504 if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END)))
1529 text_blink_ev.stop (); 1535 text_blink_ev.stop ();
1530#endif 1536#endif
1531 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); 1537 HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END));
1532 break; 1538 break;
1533 1539
1534#ifdef TRANSPARENT 1540#ifdef ENABLE_TRANSPARENCY
1535 case ReparentNotify: 1541 case ReparentNotify:
1536 rootwin_cb (ev); 1542 rootwin_cb (ev);
1537 break; 1543 break;
1538#endif /* TRANSPARENT */ 1544#endif /* ENABLE_TRANSPARENCY */
1539 1545
1540 case GraphicsExpose: 1546 case GraphicsExpose:
1541 case Expose: 1547 case Expose:
1542 if (ev.xany.window == vt) 1548 if (ev.xany.window == vt)
1543 { 1549 {
1566 if (isScrollbarWindow (ev.xany.window)) 1572 if (isScrollbarWindow (ev.xany.window))
1567 { 1573 {
1568 scrollBar.setIdle (); 1574 scrollBar.setIdle ();
1569 scrollbar_show (0); 1575 scrollbar_show (0);
1570 } 1576 }
1571
1572#ifdef TRANSPARENT
1573 if (am_transparent && ev.xany.window == parent[0])
1574 XClearWindow (dpy, ev.xany.window);
1575#endif
1576 } 1577 }
1577 break; 1578 break;
1578 1579
1579 case MotionNotify: 1580 case MotionNotify:
1580#ifdef POINTER_BLANK 1581#ifdef POINTER_BLANK
1678 &ev.xbutton.x, &ev.xbutton.y, 1679 &ev.xbutton.x, &ev.xbutton.y,
1679 &unused_mask); 1680 &unused_mask);
1680 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1681 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1681 scrollbar_size ()); 1682 scrollbar_size ());
1682 want_refresh = 1; 1683 want_refresh = 1;
1683 refresh_limit = 0;
1684 scrollbar_show (1); 1684 scrollbar_show (1);
1685 } 1685 }
1686 break; 1686 break;
1687 } 1687 }
1688 1688
1740 { 1740 {
1741 pix_colors = pix_colors_focused; 1741 pix_colors = pix_colors_focused;
1742 scr_recolour (); 1742 scr_recolour ();
1743 } 1743 }
1744#endif 1744#endif
1745#if ENABLE_FRILLS
1746 if (option (Opt_urgentOnBell))
1747 {
1748 XWMHints *h;
1749
1750 h = XGetWMHints(dpy, parent[0]);
1751 if (h != NULL)
1752 {
1753 h->flags &= ~XUrgencyHint;
1754 XSetWMHints(dpy, parent[0], h);
1755 }
1756 }
1757#endif
1745 } 1758 }
1746} 1759}
1747 1760
1748void 1761void
1749rxvt_term::focus_out () 1762rxvt_term::focus_out ()
1757 1770
1758#if ENABLE_FRILLS || ISO_14755 1771#if ENABLE_FRILLS || ISO_14755
1759 if (iso14755buf) 1772 if (iso14755buf)
1760 { 1773 {
1761 iso14755buf = 0; 1774 iso14755buf = 0;
1762# if ENABLE_OVERLAY 1775# if ISO_14755
1763 scr_overlay_off (); 1776 scr_overlay_off ();
1764# endif 1777# endif
1765 } 1778 }
1766#endif 1779#endif
1767#if USE_XIM 1780#if USE_XIM
1794 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); 1807 pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c);
1795 } 1808 }
1796#endif 1809#endif
1797} 1810}
1798 1811
1799#if TRANSPARENT || ENABLE_PERL 1812#if ENABLE_TRANSPARENCY || ENABLE_PERL
1800void 1813void
1801rxvt_term::rootwin_cb (XEvent &ev) 1814rxvt_term::rootwin_cb (XEvent &ev)
1802{ 1815{
1803 make_current (); 1816 make_current ();
1804 1817
1805 if (SHOULD_INVOKE (HOOK_ROOT_EVENT) 1818 if (SHOULD_INVOKE (HOOK_ROOT_EVENT)
1806 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) 1819 && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END)))
1807 return; 1820 return;
1808 1821
1809# if TRANSPARENT 1822# if ENABLE_TRANSPARENCY
1810 switch (ev.type) 1823 switch (ev.type)
1811 { 1824 {
1812 case PropertyNotify: 1825 case PropertyNotify:
1813 /* 1826 /*
1814 * if user used some Esetroot compatible prog to set the root bg, 1827 * if user used some Esetroot compatible prog to set the root bg,
1815 * use the property to determine the pixmap. We use it later on. 1828 * use the property to determine the pixmap. We use it later on.
1816 */ 1829 */
1817 if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] 1830 if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID]
1818 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1831 || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID])
1819 return; 1832 {
1820 1833 bgPixmap.set_root_pixmap ();
1821 /* FALLTHROUGH */ 1834 update_background ();
1822 case ReparentNotify: 1835 }
1823 if (option (Opt_transparent) && check_our_parents () && am_transparent)
1824 want_refresh = want_full_refresh = 1;
1825 break; 1836 break;
1826 } 1837 }
1827# endif 1838# endif
1828} 1839}
1829#endif 1840#endif
2206#endif 2217#endif
2207 } 2218 }
2208 } 2219 }
2209} 2220}
2210 2221
2211#ifdef TRANSPARENT
2212#if TINTING
2213/* taken from aterm-0.4.2 */
2214
2215typedef uint32_t RUINT32T;
2216
2217void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm)
2218{
2219 int sh_r, sh_g, sh_b;
2220 RUINT32T mask_r, mask_g, mask_b;
2221 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
2222 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
2223 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
2224 int i;
2225
2226 Visual *visual = term->visual;
2227
2228 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
2229
2230 /* for convenience */
2231 mask_r = visual->red_mask;
2232 mask_g = visual->green_mask;
2233 mask_b = visual->blue_mask;
2234
2235 /* boring lookup table pre-initialization */
2236 switch (srcImage->bits_per_pixel) {
2237 case 15:
2238 if ((mask_r != 0x7c00) ||
2239 (mask_g != 0x03e0) ||
2240 (mask_b != 0x001f))
2241 return;
2242 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32));
2243 lookup_r = lookup;
2244 lookup_g = lookup+32;
2245 lookup_b = lookup+32+32;
2246 sh_r = 10;
2247 sh_g = 5;
2248 sh_b = 0;
2249 break;
2250 case 16:
2251 if ((mask_r != 0xf800) ||
2252 (mask_g != 0x07e0) ||
2253 (mask_b != 0x001f))
2254 return;
2255 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32));
2256 lookup_r = lookup;
2257 lookup_g = lookup+32;
2258 lookup_b = lookup+32+64;
2259 sh_r = 11;
2260 sh_g = 5;
2261 sh_b = 0;
2262 break;
2263 case 24:
2264 if ((mask_r != 0xff0000) ||
2265 (mask_g != 0x00ff00) ||
2266 (mask_b != 0x0000ff))
2267 return;
2268 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2269 lookup_r = lookup;
2270 lookup_g = lookup+256;
2271 lookup_b = lookup+256+256;
2272 sh_r = 16;
2273 sh_g = 8;
2274 sh_b = 0;
2275 break;
2276 case 32:
2277 if ((mask_r != 0xff0000) ||
2278 (mask_g != 0x00ff00) ||
2279 (mask_b != 0x0000ff))
2280 return;
2281 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2282 lookup_r = lookup;
2283 lookup_g = lookup+256;
2284 lookup_b = lookup+256+256;
2285 sh_r = 16;
2286 sh_g = 8;
2287 sh_b = 0;
2288 break;
2289 default:
2290 return; /* we do not support this color depth */
2291 }
2292
2293 /* prepare limits for color transformation (each channel is handled separately) */
2294 if (shade < 0) {
2295 shade = -shade;
2296 if (shade < 0) shade = 0;
2297 if (shade > 100) shade = 100;
2298
2299 lower_lim_r = 65535-rm;
2300 lower_lim_g = 65535-gm;
2301 lower_lim_b = 65535-bm;
2302
2303 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100);
2304 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
2305 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
2306
2307 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
2308 } else {
2309 if (shade < 0) shade = 0;
2310 if (shade > 100) shade = 100;
2311
2312 lower_lim_r = lower_lim_g = lower_lim_b = 0;
2313
2314 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
2315 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);
2316 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100);
2317 }
2318
2319 /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */
2320 if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 ))
2321 {
2322 unsigned int tmp;
2323
2324 tmp = lower_lim_r;
2325 lower_lim_r = lower_lim_b;
2326 lower_lim_b = tmp;
2327
2328 tmp = upper_lim_r;
2329 upper_lim_r = upper_lim_b;
2330 upper_lim_b = tmp;
2331 }
2332
2333 /* fill our lookup tables */
2334 for (i = 0; i <= mask_r>>sh_r; i++)
2335 {
2336 RUINT32T tmp;
2337 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r));
2338 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r);
2339 lookup_r[i] = (tmp/65535)<<sh_r;
2340 }
2341 for (i = 0; i <= mask_g>>sh_g; i++)
2342 {
2343 RUINT32T tmp;
2344 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g));
2345 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g);
2346 lookup_g[i] = (tmp/65535)<<sh_g;
2347 }
2348 for (i = 0; i <= mask_b>>sh_b; i++)
2349 {
2350 RUINT32T tmp;
2351 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b));
2352 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b);
2353 lookup_b[i] = (tmp/65535)<<sh_b;
2354 }
2355
2356 /* apply table to input image (replacing colors by newly calculated ones) */
2357 switch (srcImage->bits_per_pixel)
2358 {
2359 case 15:
2360 {
2361 unsigned short *p1, *pf, *p, *pl;
2362 p1 = (unsigned short *) srcImage->data;
2363 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2364 while (p1 < pf)
2365 {
2366 p = p1;
2367 pl = p1 + srcImage->width;
2368 for (; p < pl; p++)
2369 {
2370 *p = lookup_r[(*p & 0x7c00)>>10] |
2371 lookup_g[(*p & 0x03e0)>> 5] |
2372 lookup_b[(*p & 0x001f)];
2373 }
2374 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2375 }
2376 break;
2377 }
2378 case 16:
2379 {
2380 unsigned short *p1, *pf, *p, *pl;
2381 p1 = (unsigned short *) srcImage->data;
2382 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2383 while (p1 < pf)
2384 {
2385 p = p1;
2386 pl = p1 + srcImage->width;
2387 for (; p < pl; p++)
2388 {
2389 *p = lookup_r[(*p & 0xf800)>>11] |
2390 lookup_g[(*p & 0x07e0)>> 5] |
2391 lookup_b[(*p & 0x001f)];
2392 }
2393 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2394 }
2395 break;
2396 }
2397 case 24:
2398 {
2399 unsigned char *p1, *pf, *p, *pl;
2400 p1 = (unsigned char *) srcImage->data;
2401 pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2402 while (p1 < pf)
2403 {
2404 p = p1;
2405 pl = p1 + srcImage->width * 3;
2406 for (; p < pl; p += 3)
2407 {
2408 p[0] = lookup_r[(p[0] & 0xff0000)>>16];
2409 p[1] = lookup_r[(p[1] & 0x00ff00)>> 8];
2410 p[2] = lookup_r[(p[2] & 0x0000ff)];
2411 }
2412 p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line);
2413 }
2414 break;
2415 }
2416 case 32:
2417 {
2418 RUINT32T *p1, *pf, *p, *pl;
2419 p1 = (RUINT32T *) srcImage->data;
2420 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2421
2422 while (p1 < pf)
2423 {
2424 p = p1;
2425 pl = p1 + srcImage->width;
2426 for (; p < pl; p++)
2427 {
2428 *p = lookup_r[(*p & 0xff0000)>>16] |
2429 lookup_g[(*p & 0x00ff00)>> 8] |
2430 lookup_b[(*p & 0x0000ff)] |
2431 (*p & ~0xffffff);
2432 }
2433 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line);
2434 }
2435 break;
2436 }
2437 }
2438
2439 free (lookup);
2440}
2441#endif
2442
2443/*
2444 * Check our parents are still who we think they are.
2445 * Do transparency updates if required
2446 */
2447int
2448rxvt_term::check_our_parents ()
2449{
2450 int i, pchanged, aformat, have_pixmap, rootdepth;
2451 unsigned long nitems, bytes_after;
2452 Atom atype;
2453 unsigned char *prop = NULL;
2454 Window root, oldp, *list;
2455 Pixmap rootpixmap = None;
2456 XWindowAttributes wattr, wrootattr;
2457
2458 pchanged = 0;
2459
2460 if (!option (Opt_transparent))
2461 return pchanged; /* Don't try any more */
2462
2463 XGetWindowAttributes (dpy, display->root, &wrootattr);
2464 rootdepth = wrootattr.depth;
2465
2466 XGetWindowAttributes (dpy, parent[0], &wattr);
2467
2468 if (rootdepth != wattr.depth)
2469 {
2470 if (am_transparent)
2471 {
2472 pchanged = 1;
2473 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2474 am_transparent = am_pixmap_trans = 0;
2475 }
2476
2477 return pchanged; /* Don't try any more */
2478 }
2479
2480 /* Get all X ops out of the queue so that our information is up-to-date. */
2481 XSync (dpy, False);
2482
2483 /*
2484 * Make the frame window set by the window manager have
2485 * the root background. Some window managers put multiple nested frame
2486 * windows for each client, so we have to take care about that.
2487 */
2488 i = (xa[XA_XROOTPMAP_ID]
2489 && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID],
2490 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2491 &nitems, &bytes_after, &prop) == Success);
2492
2493 if (!i || prop == NULL)
2494 i = (xa[XA_ESETROOT_PMAP_ID]
2495 && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID],
2496 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2497 &nitems, &bytes_after, &prop) == Success);
2498
2499 if (!i || prop == NULL
2500#if TINTING
2501 || !ISSET_PIXCOLOR (Color_tint)
2502#endif
2503 )
2504 have_pixmap = 0;
2505 else
2506 {
2507 have_pixmap = 1;
2508 rootpixmap = *(Pixmap *)prop;
2509 XFree (prop);
2510 }
2511
2512 if (have_pixmap)
2513 {
2514 /*
2515 * Copy display->root pixmap transparency
2516 */
2517 int sx, sy, nx, ny;
2518 unsigned int nw, nh;
2519 Window cr;
2520 XImage *image;
2521 GC gc;
2522 XGCValues gcvalue;
2523
2524 XTranslateCoordinates (dpy, parent[0], display->root,
2525 0, 0, &sx, &sy, &cr);
2526 nw = (unsigned int)szHint.width;
2527 nh = (unsigned int)szHint.height;
2528 nx = ny = 0;
2529
2530 if (sx < 0)
2531 {
2532 nw += sx;
2533 nx = -sx;
2534 sx = 0;
2535 }
2536
2537 if (sy < 0)
2538 {
2539 nh += sy;
2540 ny = -sy;
2541 sy = 0;
2542 }
2543
2544 min_it (nw, (unsigned int) (wrootattr.width - sx));
2545 min_it (nh, (unsigned int) (wrootattr.height - sy));
2546
2547 XSync (dpy, False);
2548 allowedxerror = -1;
2549 image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2550
2551 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2552 /* XXX: may need a delay here? */
2553 allowedxerror = 0;
2554
2555 if (image == NULL)
2556 {
2557 if (am_transparent && am_pixmap_trans)
2558 {
2559 pchanged = 1;
2560 if (pixmap != None)
2561 {
2562 XFreePixmap (dpy, pixmap);
2563 pixmap = None;
2564 }
2565 }
2566
2567 am_pixmap_trans = 0;
2568 }
2569 else
2570 {
2571 if (pixmap != None)
2572 XFreePixmap (dpy, pixmap);
2573
2574#if TINTING
2575 if (ISSET_PIXCOLOR (Color_tint))
2576 {
2577 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2578
2579 rgba c;
2580 pix_colors_focused [Color_tint].get (c);
2581
2582 ShadeXImage (this, image, shade, c.r, c.g, c.b);
2583 }
2584#endif
2585
2586 pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth);
2587 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
2588 XPutImage (dpy, pixmap, gc, image, 0, 0,
2589 nx, ny, image->width, image->height);
2590 XFreeGC (dpy, gc);
2591 XDestroyImage (image);
2592 XSetWindowBackgroundPixmap (dpy, parent[0], pixmap);
2593 XClearWindow (dpy, parent[0]);
2594
2595 if (!am_transparent || !am_pixmap_trans)
2596 pchanged = 1;
2597
2598 am_transparent = am_pixmap_trans = 1;
2599 }
2600 }
2601
2602 if (am_pixmap_trans)
2603 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2604 else
2605 {
2606 unsigned int n;
2607 /*
2608 * InheritPixmap transparency
2609 */
2610 for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2611 {
2612 oldp = parent[i];
2613 XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n);
2614 XFree (list);
2615
2616 if (parent[i] == display->root)
2617 {
2618 if (oldp != None)
2619 pchanged = 1;
2620
2621 break;
2622 }
2623
2624 if (oldp != parent[i])
2625 pchanged = 1;
2626 }
2627
2628 n = 0;
2629
2630 if (pchanged)
2631 for (; n < (unsigned int)i; n++)
2632 {
2633 XGetWindowAttributes (dpy, parent[n], &wattr);
2634
2635 if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
2636 {
2637 n = (int) (sizeof (parent) / sizeof (Window)) + 1;
2638 break;
2639 }
2640 }
2641
2642 if (n > (sizeof (parent) / sizeof (parent[0])))
2643 {
2644 XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]);
2645 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2646 am_transparent = 0;
2647 /* XXX: also turn off Opt_transparent? */
2648 }
2649 else
2650 {
2651 for (n = 0; n < (unsigned int)i; n++)
2652 {
2653 XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative);
2654 XClearWindow (dpy, parent[n]);
2655 }
2656
2657 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2658 am_transparent = 1;
2659 }
2660
2661 for (; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2662 parent[i] = None;
2663 }
2664
2665 if (scrollBar.win)
2666 {
2667 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2668 scrollBar.setIdle ();
2669 scrollbar_show (0);
2670 }
2671
2672 if (am_transparent)
2673 {
2674 want_refresh = want_full_refresh = 1;
2675 if (am_pixmap_trans)
2676 flush ();
2677 }
2678
2679 return pchanged;
2680}
2681#endif
2682
2683/*}}} */ 2222/*}}} */
2684 2223
2685bool 2224bool
2686rxvt_term::cmd_parse () 2225rxvt_term::cmd_parse ()
2687{ 2226{
2735 if (ch == C0_LF) 2274 if (ch == C0_LF)
2736 nlines++; 2275 nlines++;
2737 2276
2738 refresh_count++; 2277 refresh_count++;
2739 2278
2740 if (!option (Opt_jumpScroll) 2279 if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1)
2741 || (refresh_count >= refresh_limit * (nrow - 1)))
2742 { 2280 {
2743 refreshnow = true;
2744 refresh_count = 0; 2281 refresh_count = 0;
2282
2283 if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.)
2284 {
2285 refreshnow = true;
2745 ch = NOCHAR; 2286 ch = NOCHAR;
2746 break; 2287 break;
2288 }
2747 } 2289 }
2748 2290
2749 // scr_add_lines only works for nlines <= nrow - 1. 2291 // scr_add_lines only works for nlines <= nrow - 1.
2750 if (nlines >= nrow - 1) 2292 if (nlines >= nrow - 1)
2751 { 2293 {
2779 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) 2321 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2780 scr_add_lines (buf, str - buf, nlines); 2322 scr_add_lines (buf, str - buf, nlines);
2781 2323
2782 /* 2324 /*
2783 * If there have been a lot of new lines, then update the screen 2325 * If there have been a lot of new lines, then update the screen
2784 * What the heck I'll cheat and only refresh less than every page-full. 2326 * What the heck we'll cheat and only refresh less than every page-full.
2785 * the number of pages between refreshes is refresh_limit, which 2327 * if skipScroll is enabled.
2786 * is incremented here because we must be doing flat-out scrolling.
2787 */ 2328 */
2788 if (refreshnow) 2329 if (refreshnow)
2789 { 2330 {
2790 if (option (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2791 refresh_limit++;
2792 else
2793 {
2794 flag = true; 2331 flag = true;
2795 //TODO: due to popular request, implement "skipscroll" option here
2796 scr_refresh (); 2332 scr_refresh ();
2797 want_refresh = 1; 2333 want_refresh = 1;
2798 }
2799 } 2334 }
2800 2335
2801 } 2336 }
2802 else 2337 else
2803 { 2338 {
2952 { 2487 {
2953 if ((buf[len++] = cmd_getc ()) == 'i') 2488 if ((buf[len++] = cmd_getc ()) == 'i')
2954 break; /* done = 1 */ 2489 break; /* done = 1 */
2955 } 2490 }
2956 } 2491 }
2957 2492
2958 for (i = 0; i < len; i++) 2493 for (i = 0; i < len; i++)
2959 if (putc (buf[i], fd) == EOF) 2494 if (putc (buf[i], fd) == EOF)
2960 { 2495 {
2961 done = 1; 2496 done = 1;
2962 break; 2497 break;
3024 process_dcs_seq (); 2559 process_dcs_seq ();
3025 break; 2560 break;
3026 case 0x9b: /* CSI */ 2561 case 0x9b: /* CSI */
3027 process_csi_seq (); 2562 process_csi_seq ();
3028 break; 2563 break;
3029 case 0x9d: /* CSI */ 2564 case 0x9d: /* OSC */
3030 process_osc_seq (); 2565 process_osc_seq ();
3031 break; 2566 break;
3032#endif 2567#endif
3033 } 2568 }
3034} 2569}
3262 unicode_t ch, priv, i; 2797 unicode_t ch, priv, i;
3263 unsigned int nargs, p; 2798 unsigned int nargs, p;
3264 int n, ndef; 2799 int n, ndef;
3265 int arg[ESC_ARGS]; 2800 int arg[ESC_ARGS];
3266 2801
3267 for (nargs = ESC_ARGS; nargs > 0;) 2802 memset (arg, 0, sizeof (arg));
3268 arg[--nargs] = 0; 2803 nargs = 0;
3269 2804
3270 priv = 0; 2805 priv = 0;
3271 ch = cmd_getc (); 2806 ch = cmd_getc ();
3272 if (ch >= '<' && ch <= '?') 2807 if (ch >= '<' && ch <= '?')
3273 { /* '<' '=' '>' '?' */ 2808 { /* '<' '=' '>' '?' */
3317 switch (priv) 2852 switch (priv)
3318 { 2853 {
3319 case '>': 2854 case '>':
3320 if (ch == CSI_DA) /* secondary device attributes */ 2855 if (ch == CSI_DA) /* secondary device attributes */
3321 { 2856 {
3322 // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, 2857 // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt,
3323 // 'U' for rxvt-unicode != 7.[34] (where it was broken). 2858 // 'U' for rxvt-unicode != 7.[34] (where it was broken).
3324 // 2859 //
3325 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt 2860 // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt
3326 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify 2861 // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify
3327 // that we do not support xterm mouse reporting (should be 95 when we do). 2862 // that we do not support xterm mouse reporting (should be 95 when we do).
3780 int saveop = op; 3315 int saveop = op;
3781 3316
3782 dLocal (Display *, dpy); 3317 dLocal (Display *, dpy);
3783 3318
3784 assert (str != NULL); 3319 assert (str != NULL);
3785 3320
3786 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) 3321 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END)))
3787 return; 3322 return;
3788 3323
3789 switch (op) 3324 switch (op)
3790 { 3325 {
3885 break; 3420 break;
3886 case URxvt_Color_IT: 3421 case URxvt_Color_IT:
3887 process_color_seq (op, Color_IT, str, resp); 3422 process_color_seq (op, Color_IT, str, resp);
3888 break; 3423 break;
3889#endif 3424#endif
3890#if TRANSPARENT && TINTING 3425#if ENABLE_TRANSPARENCY
3891 case URxvt_Color_tint: 3426 case URxvt_Color_tint:
3892 process_color_seq (op, Color_tint, str, resp); 3427 process_color_seq (op, Color_tint, str, resp);
3428 {
3429 bool changed = false;
3430 if (ISSET_PIXCOLOR (Color_tint))
3431 changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]);
3432 else
3433 changed = bgPixmap.unset_tint ();
3434 if (changed)
3435 update_background ();
3436 }
3893 3437
3894 check_our_parents ();
3895
3896 if (am_transparent)
3897 want_full_refresh = want_refresh = 1;
3898
3899 break; 3438 break;
3900#endif 3439#endif
3901 3440
3441#if XPM_BACKGROUND
3902 case Rxvt_Pixmap: 3442 case Rxvt_Pixmap:
3903 { 3443 if (!strcmp (str, "?"))
3904 if (*str != ';')
3905 { 3444 {
3906#if XPM_BACKGROUND 3445 char str[256];
3907 scale_pixmap (""); /* reset to default scaling */ 3446
3908 set_bgPixmap (str); /* change pixmap */ 3447 sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */
3909 scr_touch (true); 3448 min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767),
3910#endif 3449 min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767));
3450 process_xterm_seq (XTerm_title, str, CHAR_ST);
3911 } 3451 }
3912 3452 else
3453 {
3913 int changed = 0; 3454 int changed = 0;
3914 3455
3915 while ((str = strchr (str, ';')) != NULL) 3456 if (*str != ';')
3916 { 3457 {
3458 /* reset to default scaling :*/
3459 bgPixmap.unset_geometry ();
3460 if (bgPixmap.set_file (str)) /* change pixmap */
3461 changed++;
3462 str = strchr (str, ';');
3463 if (str == NULL)
3464 bgPixmap.set_defaultGeometry ();
3465 }
3466 while (str)
3467 {
3917 str++; 3468 str++;
3918#if XPM_BACKGROUND 3469 if (bgPixmap.set_geometry (str))
3919 changed += scale_pixmap (str); 3470 changed++;
3920#endif 3471 str = strchr (str, ';');
3921 } 3472 }
3922
3923 if (changed) 3473 if (changed)
3924 { 3474 update_background ();
3925#ifdef XPM_BACKGROUND
3926 resize_pixmap ();
3927 scr_touch (true);
3928#endif
3929 } 3475 }
3930 }
3931 break; 3476 break;
3477#endif
3932 3478
3933 case Rxvt_restoreFG: 3479 case Rxvt_restoreFG:
3934 set_window_color (Color_fg, str); 3480 set_window_color (Color_fg, str);
3935 break; 3481 break;
3936 case Rxvt_restoreBG: 3482 case Rxvt_restoreBG:
4058{ 3604{
4059 unsigned int i, j; 3605 unsigned int i, j;
4060 int state; 3606 int state;
4061 3607
4062 static const struct 3608 static const struct
4063 { 3609 {
4064 const int argval; 3610 const int argval;
4065 const unsigned long bit; 3611 const unsigned long bit;
4066 }
4067
4068 argtopriv[] = { 3612 } argtopriv[] = {
4069 { 1, PrivMode_aplCUR }, 3613 { 1, PrivMode_aplCUR },
4070 { 2, PrivMode_vt52 }, 3614 { 2, PrivMode_vt52 },
4071 { 3, PrivMode_132 }, 3615 { 3, PrivMode_132 },
4072 { 4, PrivMode_smoothScroll }, 3616 { 4, PrivMode_smoothScroll },
4073 { 5, PrivMode_rVideo }, 3617 { 5, PrivMode_rVideo },

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines