… | |
… | |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "version.h" |
50 | #include "version.h" |
51 | #include "command.h" |
51 | #include "command.h" |
52 | |
52 | |
53 | #include <wchar.h> |
53 | #include <cwchar> |
|
|
54 | #include <csignal> |
54 | |
55 | |
55 | /*----------------------------------------------------------------------*/ |
56 | /*----------------------------------------------------------------------*/ |
56 | |
57 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
59 | |
… | |
… | |
417 | { |
418 | { |
418 | /* normal XTerm key bindings */ |
419 | /* normal XTerm key bindings */ |
419 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | selection_request (ev.time, 0, 0); |
421 | selection_request (ev.time, 0, 0); |
421 | return; |
422 | return; |
422 | #if TODO // TODO |
423 | #if TODO |
423 | /* rxvt extras */ |
424 | /* rxvt extras */ |
424 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | change_font (FONT_UP); |
426 | change_font (FONT_UP); |
426 | return; |
427 | return; |
427 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
428 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
487 | #endif |
488 | #endif |
488 | |
489 | |
489 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
490 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
490 | { |
491 | { |
491 | #ifdef KEYSYM_RESOURCE |
492 | #ifdef KEYSYM_RESOURCE |
492 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
493 | if (!(shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
493 | { |
494 | { |
494 | unsigned int l; |
495 | unsigned int l; |
495 | const unsigned char *kbuf0; |
496 | const unsigned char *kbuf0; |
496 | |
497 | |
497 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
498 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
… | |
… | |
784 | case XK_F35: /* "\033[49~" */ |
785 | case XK_F35: /* "\033[49~" */ |
785 | FKEY (31, XK_F17); |
786 | FKEY (31, XK_F17); |
786 | break; |
787 | break; |
787 | #undef FKEY |
788 | #undef FKEY |
788 | default: |
789 | default: |
789 | newlen = 0; |
790 | if (len == 0 |
790 | break; |
791 | && (keysym & 0xfff0) != 0xff70 |
|
|
792 | && (keysym & 0xfff0) != 0xffe0) |
|
|
793 | /* generate a keycode for every remaining keypress */ |
|
|
794 | sprintf ((char *)kbuf, "\033[%x;%xA", (unsigned char)ev.state, (unsigned short)keysym); |
791 | } |
795 | } |
|
|
796 | |
792 | if (newlen) |
797 | if (newlen) |
793 | len = strlen (kbuf); |
798 | len = strlen (kbuf); |
794 | } |
799 | } |
795 | |
800 | |
796 | /* |
801 | /* |
… | |
… | |
804 | } |
809 | } |
805 | else if (ctrl && keysym == XK_minus) |
810 | else if (ctrl && keysym == XK_minus) |
806 | { |
811 | { |
807 | len = 1; |
812 | len = 1; |
808 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
813 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
814 | } |
|
|
815 | else if (keysym == XK_ISO_Left_Tab) |
|
|
816 | { |
|
|
817 | strcpy (kbuf, "\033[Z"); |
|
|
818 | len = 3; |
|
|
819 | } |
|
|
820 | else if (len == 0 |
|
|
821 | && (keysym & 0xffe0) != 0xfe00 |
|
|
822 | && (keysym < 0xfe50 || keysym > 0xfe6f)) |
|
|
823 | { |
|
|
824 | /* generate a keycode for every remaining keypress */ |
|
|
825 | len = sprintf ((char *)kbuf, "\033[%x;%xA", (unsigned char)ev.state, (unsigned short)keysym); |
809 | } |
826 | } |
810 | else |
827 | else |
811 | { |
828 | { |
812 | #ifdef META8_OPTION |
829 | #ifdef META8_OPTION |
813 | /* set 8-bit on */ |
830 | /* set 8-bit on */ |
… | |
… | |
910 | #endif /* MENUBAR_MAX */ |
927 | #endif /* MENUBAR_MAX */ |
911 | |
928 | |
912 | void |
929 | void |
913 | rxvt_term::flush () |
930 | rxvt_term::flush () |
914 | { |
931 | { |
|
|
932 | flush_ev.stop (); |
|
|
933 | |
915 | #ifdef TRANSPARENT |
934 | #ifdef TRANSPARENT |
916 | if (want_full_refresh) |
935 | if (want_full_refresh) |
917 | { |
936 | { |
918 | want_full_refresh = 0; |
937 | want_full_refresh = 0; |
919 | scr_clear (); |
938 | scr_clear (); |
… | |
… | |
929 | IMSendSpot (); |
948 | IMSendSpot (); |
930 | #endif |
949 | #endif |
931 | } |
950 | } |
932 | |
951 | |
933 | display->flush (); |
952 | display->flush (); |
934 | |
|
|
935 | flush_ev.stop (); |
|
|
936 | } |
953 | } |
937 | |
954 | |
938 | void |
955 | void |
939 | rxvt_term::check_cb (check_watcher &w) |
956 | rxvt_term::check_cb (check_watcher &w) |
940 | { |
957 | { |
… | |
… | |
1057 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1074 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1058 | { |
1075 | { |
1059 | SET_R (this); |
1076 | SET_R (this); |
1060 | SET_LOCALE (locale); |
1077 | SET_LOCALE (locale); |
1061 | |
1078 | |
1062 | if (revents & EVENT_WRITE) |
|
|
1063 | tt_write (0, 0); |
|
|
1064 | else if (revents & EVENT_READ) |
1079 | if (revents & EVENT_READ) |
1065 | // loop, but don't allow a single term to monopolize us |
1080 | // loop, but don't allow a single term to monopolize us |
1066 | while (pty_fill ()) |
1081 | while (pty_fill ()) |
1067 | if (cmd_parse ()) |
1082 | if (cmd_parse ()) |
1068 | break; |
1083 | break; |
|
|
1084 | |
|
|
1085 | if (revents & EVENT_WRITE) |
|
|
1086 | pty_write (); |
1069 | } |
1087 | } |
1070 | |
1088 | |
1071 | void |
1089 | void |
1072 | rxvt_term::pointer_unblank () |
1090 | rxvt_term::pointer_unblank () |
1073 | { |
1091 | { |
… | |
… | |
1216 | if (ev.type == KeyPress && hidden_pointer == 0) |
1234 | if (ev.type == KeyPress && hidden_pointer == 0) |
1217 | pointer_blank (); |
1235 | pointer_blank (); |
1218 | } |
1236 | } |
1219 | #endif |
1237 | #endif |
1220 | |
1238 | |
1221 | #ifdef USE_XIM |
|
|
1222 | if (XFilterEvent (&ev, None)) |
|
|
1223 | return; |
|
|
1224 | #endif |
|
|
1225 | |
|
|
1226 | Window unused_root, unused_child; |
1239 | Window unused_root, unused_child; |
1227 | int unused_root_x, unused_root_y; |
1240 | int unused_root_x, unused_root_y; |
1228 | unsigned int unused_mask; |
1241 | unsigned int unused_mask; |
1229 | |
1242 | |
1230 | switch (ev.type) |
1243 | switch (ev.type) |
1231 | { |
1244 | { |
1232 | case KeyPress: |
1245 | case KeyPress: |
1233 | #if ISO_14755 |
1246 | #if ISO_14755 |
… | |
… | |
1338 | 0L, 1000000L, |
1351 | 0L, 1000000L, |
1339 | False, AnyPropertyType, |
1352 | False, AnyPropertyType, |
1340 | &ActualType, &ActualFormat, |
1353 | &ActualType, &ActualFormat, |
1341 | &Size, &RemainingBytes, |
1354 | &Size, &RemainingBytes, |
1342 | &data); |
1355 | &data); |
1343 | XChangeProperty (display->display, display->root, |
1356 | set_string_property (XA_CUT_BUFFER0, data); |
1344 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1345 | 8, PropModeReplace, |
|
|
1346 | data, strlen (data)); |
|
|
1347 | XFree (data); |
1357 | XFree (data); |
1348 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1358 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1349 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1359 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1350 | } |
1360 | } |
1351 | #endif /* OFFIX_DND */ |
1361 | #endif /* OFFIX_DND */ |
1352 | break; |
1362 | break; |
1353 | |
1363 | |
… | |
… | |
1457 | resize_all_windows (width, height, 1); |
1467 | resize_all_windows (width, height, 1); |
1458 | } |
1468 | } |
1459 | |
1469 | |
1460 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1470 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1461 | if (options & Opt_transparent) |
1471 | if (options & Opt_transparent) |
1462 | { |
|
|
1463 | check_our_parents (); |
1472 | check_our_parents (); |
1464 | if (am_transparent) |
|
|
1465 | want_refresh = want_full_refresh = 1; |
|
|
1466 | } |
|
|
1467 | #endif |
1473 | #endif |
1468 | } |
1474 | } |
1469 | break; |
1475 | break; |
1470 | |
1476 | |
1471 | case PropertyNotify: |
1477 | case PropertyNotify: |
… | |
… | |
1479 | selection_clear (); |
1485 | selection_clear (); |
1480 | break; |
1486 | break; |
1481 | |
1487 | |
1482 | case SelectionNotify: |
1488 | case SelectionNotify: |
1483 | if (selection_wait == Sel_normal) |
1489 | if (selection_wait == Sel_normal) |
1484 | selection_paste (ev.xselection.requestor, |
1490 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1485 | ev.xselection.property, True); |
|
|
1486 | break; |
1491 | break; |
1487 | |
1492 | |
1488 | case SelectionRequest: |
1493 | case SelectionRequest: |
1489 | selection_send (ev.xselectionrequest); |
1494 | selection_send (ev.xselectionrequest); |
1490 | break; |
1495 | break; |
… | |
… | |
1562 | { |
1567 | { |
1563 | menubar_control (ev.xbutton); |
1568 | menubar_control (ev.xbutton); |
1564 | break; |
1569 | break; |
1565 | } |
1570 | } |
1566 | #endif |
1571 | #endif |
1567 | if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1572 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1568 | break; |
1573 | break; |
1569 | |
1574 | |
1570 | if (ev.xany.window == TermWin.vt) |
1575 | if (ev.xany.window == TermWin.vt) |
1571 | { |
1576 | { |
1572 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1577 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
… | |
… | |
1575 | ; |
1580 | ; |
1576 | |
1581 | |
1577 | XQueryPointer (display->display, TermWin.vt, |
1582 | XQueryPointer (display->display, TermWin.vt, |
1578 | &unused_root, &unused_child, |
1583 | &unused_root, &unused_child, |
1579 | &unused_root_x, &unused_root_y, |
1584 | &unused_root_x, &unused_root_y, |
1580 | & (ev.xbutton.x), & (ev.xbutton.y), |
1585 | &ev.xbutton.x, &ev.xbutton.y, |
1581 | &unused_mask); |
1586 | &ev.xbutton.state); |
1582 | #ifdef MOUSE_THRESHOLD |
1587 | #ifdef MOUSE_THRESHOLD |
1583 | /* deal with a `jumpy' mouse */ |
1588 | /* deal with a `jumpy' mouse */ |
1584 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1589 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1585 | { |
1590 | { |
1586 | #endif |
1591 | #endif |
… | |
… | |
1591 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1596 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1592 | break; |
1597 | break; |
1593 | } |
1598 | } |
1594 | #endif |
1599 | #endif |
1595 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1600 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1596 | (ev.xbutton.state & Button3Mask) ? 2 : 0); |
1601 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1602 | |
1597 | #ifdef SELECTION_SCROLLING |
1603 | #ifdef SELECTION_SCROLLING |
1598 | if (ev.xbutton.y < TermWin.int_bwidth |
1604 | if (ev.xbutton.y < TermWin.int_bwidth |
1599 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1605 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1600 | { |
1606 | { |
1601 | int dist; |
1607 | int dist; |
… | |
… | |
1612 | selection_save_x = ev.xbutton.x; |
1618 | selection_save_x = ev.xbutton.x; |
1613 | selection_save_y = ev.xbutton.y; |
1619 | selection_save_y = ev.xbutton.y; |
1614 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1620 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1615 | |
1621 | |
1616 | /* calc number of lines to scroll */ |
1622 | /* calc number of lines to scroll */ |
1617 | if (ev.xbutton.y<TermWin.int_bwidth) |
1623 | if (ev.xbutton.y < TermWin.int_bwidth) |
1618 | { |
1624 | { |
1619 | scroll_selection_dir = UP; |
1625 | scroll_selection_dir = UP; |
1620 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1626 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1621 | } |
1627 | } |
1622 | else |
1628 | else |
… | |
… | |
1646 | } |
1652 | } |
1647 | } |
1653 | } |
1648 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1654 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1649 | { |
1655 | { |
1650 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1656 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1651 | MotionNotify, &ev)) ; |
1657 | MotionNotify, &ev)) |
|
|
1658 | ; |
|
|
1659 | |
1652 | XQueryPointer (display->display, scrollBar.win, |
1660 | XQueryPointer (display->display, scrollBar.win, |
1653 | &unused_root, &unused_child, |
1661 | &unused_root, &unused_child, |
1654 | &unused_root_x, &unused_root_y, |
1662 | &unused_root_x, &unused_root_y, |
1655 | & (ev.xbutton.x), & (ev.xbutton.y), |
1663 | &ev.xbutton.x, &ev.xbutton.y, |
1656 | &unused_mask); |
1664 | &unused_mask); |
1657 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1665 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1658 | scrollbar_size ()); |
1666 | scrollbar_size ()); |
1659 | scr_refresh (refresh_type); |
1667 | scr_refresh (refresh_type); |
1660 | refresh_limit = 0; |
1668 | refresh_limit = 0; |
… | |
… | |
1676 | case PropertyNotify: |
1684 | case PropertyNotify: |
1677 | /* |
1685 | /* |
1678 | * if user used some Esetroot compatible prog to set the root bg, |
1686 | * if user used some Esetroot compatible prog to set the root bg, |
1679 | * use the property to determine the pixmap. We use it later on. |
1687 | * use the property to determine the pixmap. We use it later on. |
1680 | */ |
1688 | */ |
1681 | if (xa[XA_XROOTPMAPID] == 0) |
|
|
1682 | xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); |
|
|
1683 | |
|
|
1684 | if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) |
1689 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1690 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1685 | return; |
1691 | return; |
1686 | |
1692 | |
1687 | /* FALLTHROUGH */ |
1693 | /* FALLTHROUGH */ |
1688 | case ReparentNotify: |
1694 | case ReparentNotify: |
1689 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1695 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
1715 | return; |
1721 | return; |
1716 | } |
1722 | } |
1717 | #endif |
1723 | #endif |
1718 | |
1724 | |
1719 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1725 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
|
|
1726 | |
1720 | if (reportmode) |
1727 | if (reportmode) |
1721 | { |
1728 | { |
1722 | /* mouse report from vt window */ |
1729 | /* mouse report from vt window */ |
1723 | /* save the xbutton state (for ButtonRelease) */ |
1730 | /* save the xbutton state (for ButtonRelease) */ |
1724 | MEvent.state = ev.state; |
1731 | MEvent.state = ev.state; |
… | |
… | |
1753 | } |
1760 | } |
1754 | else |
1761 | else |
1755 | { |
1762 | { |
1756 | if (ev.button != MEvent.button) |
1763 | if (ev.button != MEvent.button) |
1757 | MEvent.clicks = 0; |
1764 | MEvent.clicks = 0; |
|
|
1765 | |
1758 | switch (ev.button) |
1766 | switch (ev.button) |
1759 | { |
1767 | { |
1760 | case Button1: |
1768 | case Button1: |
|
|
1769 | /* allow meta + click to select rectangular areas */ |
|
|
1770 | /* should be done in screen.C */ |
|
|
1771 | #if ENABLE_FRILLS |
|
|
1772 | selection.rect = !! (ev.state & ModMetaMask); |
|
|
1773 | #else |
|
|
1774 | selection.rect = false; |
|
|
1775 | #endif |
|
|
1776 | |
1761 | /* allow shift+left click to extend selection */ |
1777 | /* allow shift+left click to extend selection */ |
1762 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1778 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1763 | { |
1779 | { |
1764 | if (MEvent.button == Button1 && clickintime) |
1780 | if (MEvent.button == Button1 && clickintime) |
1765 | selection_rotate (ev.x, ev.y); |
1781 | selection_rotate (ev.x, ev.y); |
… | |
… | |
2349 | /* |
2365 | /* |
2350 | * Make the frame window set by the window manager have |
2366 | * Make the frame window set by the window manager have |
2351 | * the root background. Some window managers put multiple nested frame |
2367 | * the root background. Some window managers put multiple nested frame |
2352 | * windows for each client, so we have to take care about that. |
2368 | * windows for each client, so we have to take care about that. |
2353 | */ |
2369 | */ |
2354 | i = (xa[XA_XROOTPMAPID] |
2370 | i = (xa[XA_XROOTPMAP_ID] |
2355 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2371 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], |
2356 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2372 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2357 | &nitems, &bytes_after, &prop) == Success); |
2373 | &nitems, &bytes_after, &prop) == Success); |
2358 | |
2374 | |
2359 | if (!i || prop == NULL) |
2375 | if (!i || prop == NULL) |
2360 | i = (xa[XA_XSETROOTID] |
2376 | i = (xa[XA_ESETROOT_PMAP_ID] |
2361 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2377 | && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], |
2362 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2378 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2363 | &nitems, &bytes_after, &prop) == Success); |
2379 | &nitems, &bytes_after, &prop) == Success); |
2364 | |
2380 | |
2365 | if (!i || prop == NULL |
2381 | if (!i || prop == NULL |
2366 | #if TINTING |
2382 | #if TINTING |
… | |
… | |
2407 | sy = 0; |
2423 | sy = 0; |
2408 | } |
2424 | } |
2409 | |
2425 | |
2410 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2426 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2411 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2427 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2428 | |
|
|
2429 | XSync (display->display, False); |
2412 | allowedxerror = -1; |
2430 | allowedxerror = -1; |
2413 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2431 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2414 | |
2432 | |
2415 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2433 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2416 | /* XXX: may need a delay here? */ |
2434 | /* XXX: may need a delay here? */ |
… | |
… | |
2462 | |
2480 | |
2463 | am_transparent = am_pixmap_trans = 1; |
2481 | am_transparent = am_pixmap_trans = 1; |
2464 | } |
2482 | } |
2465 | } |
2483 | } |
2466 | |
2484 | |
2467 | if (!am_pixmap_trans) |
2485 | if (am_pixmap_trans) |
|
|
2486 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
|
|
2487 | else |
2468 | { |
2488 | { |
2469 | unsigned int n; |
2489 | unsigned int n; |
2470 | /* |
2490 | /* |
2471 | * InheritPixmap transparency |
2491 | * InheritPixmap transparency |
2472 | */ |
2492 | */ |
… | |
… | |
2535 | if (scrollBar.win) |
2555 | if (scrollBar.win) |
2536 | { |
2556 | { |
2537 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2557 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2538 | scrollBar.setIdle (); |
2558 | scrollBar.setIdle (); |
2539 | scrollbar_show (0); |
2559 | scrollbar_show (0); |
|
|
2560 | } |
|
|
2561 | |
|
|
2562 | if (am_transparent) |
|
|
2563 | { |
|
|
2564 | want_refresh = want_full_refresh = 1; |
|
|
2565 | if (am_pixmap_trans) |
|
|
2566 | flush (); |
2540 | } |
2567 | } |
2541 | |
2568 | |
2542 | return pchanged; |
2569 | return pchanged; |
2543 | } |
2570 | } |
2544 | #endif |
2571 | #endif |
… | |
… | |
2696 | if (len == (size_t)-1) |
2723 | if (len == (size_t)-1) |
2697 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2724 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2698 | |
2725 | |
2699 | // assume wchar == unicode |
2726 | // assume wchar == unicode |
2700 | cmdbuf_ptr += len; |
2727 | cmdbuf_ptr += len; |
2701 | return wc; |
2728 | return wc & UNICODE_MASK; |
2702 | } |
2729 | } |
2703 | |
2730 | |
2704 | return NOCHAR; |
2731 | return NOCHAR; |
2705 | } |
2732 | } |
2706 | |
2733 | |
… | |
… | |
3504 | * ends_how is terminator used. returned input must be free()'d |
3531 | * ends_how is terminator used. returned input must be free()'d |
3505 | */ |
3532 | */ |
3506 | unsigned char * |
3533 | unsigned char * |
3507 | rxvt_term::get_to_st (unicode_t &ends_how) |
3534 | rxvt_term::get_to_st (unicode_t &ends_how) |
3508 | { |
3535 | { |
3509 | unicode_t seen_esc = 0, ch; |
3536 | unicode_t ch; |
|
|
3537 | bool seen_esc = false; |
3510 | unsigned int n = 0; |
3538 | unsigned int n = 0; |
3511 | unsigned char *s; |
|
|
3512 | unsigned char string[STRING_MAX]; |
3539 | wchar_t string[STRING_MAX]; |
3513 | |
3540 | |
3514 | while ((ch = cmd_getc ()) != NOCHAR) |
3541 | while ((ch = cmd_getc ()) != NOCHAR) |
3515 | { |
3542 | { |
3516 | if (seen_esc) |
3543 | if (seen_esc) |
3517 | { |
3544 | { |
… | |
… | |
3520 | else |
3547 | else |
3521 | return NULL; |
3548 | return NULL; |
3522 | } |
3549 | } |
3523 | else if (ch == C0_ESC) |
3550 | else if (ch == C0_ESC) |
3524 | { |
3551 | { |
3525 | seen_esc = 1; |
3552 | seen_esc = true; |
3526 | continue; |
3553 | continue; |
3527 | } |
3554 | } |
3528 | else if (ch == C0_BEL || ch == CHAR_ST) |
3555 | else if (ch == C0_BEL || ch == CHAR_ST) |
3529 | break; |
3556 | break; |
3530 | else if (ch < 0x20) |
3557 | else if (ch < 0x20) |
3531 | return NULL; /* other control character - exit */ |
3558 | return NULL; /* other control character - exit */ |
3532 | |
3559 | |
3533 | seen_esc = 0; |
3560 | seen_esc = false; |
3534 | |
3561 | |
3535 | if (n >= sizeof (string) - 1) |
3562 | if (n >= sizeof (string) - 1) |
3536 | // stop at some sane length |
3563 | // stop at some sane length |
3537 | return NULL; |
3564 | return NULL; |
3538 | |
3565 | |
… | |
… | |
3542 | string[n++] = ch; |
3569 | string[n++] = ch; |
3543 | } |
3570 | } |
3544 | |
3571 | |
3545 | string[n++] = '\0'; |
3572 | string[n++] = '\0'; |
3546 | |
3573 | |
3547 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3548 | return NULL; |
|
|
3549 | |
|
|
3550 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3574 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3551 | strncpy (s, string, n); |
3575 | |
3552 | return s; |
3576 | return (unsigned char *)rxvt_wcstombs (string); |
3553 | } |
3577 | } |
3554 | |
3578 | |
3555 | /*----------------------------------------------------------------------*/ |
3579 | /*----------------------------------------------------------------------*/ |
3556 | /* |
3580 | /* |
3557 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3581 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3658 | set_title (str); |
3682 | set_title (str); |
3659 | break; |
3683 | break; |
3660 | case XTerm_property: |
3684 | case XTerm_property: |
3661 | if (str[0] == '?') |
3685 | if (str[0] == '?') |
3662 | { |
3686 | { |
3663 | Atom prop = XInternAtom (display->display, str + 1, True); |
3687 | Atom prop = display->atom (str + 1); |
3664 | Atom actual_type; |
3688 | Atom actual_type; |
3665 | int actual_format; |
3689 | int actual_format; |
3666 | unsigned long nitems; |
3690 | unsigned long nitems; |
3667 | unsigned long bytes_after; |
3691 | unsigned long bytes_after; |
3668 | unsigned char *value = 0; |
3692 | unsigned char *value = 0; |
… | |
… | |
3686 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3710 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3687 | |
3711 | |
3688 | if (eq) |
3712 | if (eq) |
3689 | { |
3713 | { |
3690 | *eq = 0; |
3714 | *eq = 0; |
3691 | XChangeProperty (display->display, TermWin.parent[0], |
3715 | set_utf8_property (display->atom (str), eq + 1); |
3692 | display->atom (str), XA_STRING, 8, |
|
|
3693 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3694 | strlen (eq + 1)); |
|
|
3695 | } |
3716 | } |
3696 | else |
3717 | else |
3697 | XDeleteProperty (display->display, TermWin.parent[0], |
3718 | XDeleteProperty (display->display, TermWin.parent[0], |
3698 | display->atom (str)); |
3719 | display->atom (str)); |
3699 | } |
3720 | } |
… | |
… | |
3753 | break; |
3774 | break; |
3754 | case XTerm_Color_RV: |
3775 | case XTerm_Color_RV: |
3755 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3776 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3756 | break; |
3777 | break; |
3757 | #endif |
3778 | #endif |
3758 | #if TRANSPARENT || TINTING |
3779 | #if TRANSPARENT && TINTING |
3759 | case XTerm_Color_tint: |
3780 | case XTerm_Color_tint: |
3760 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3781 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3761 | check_our_parents (); |
3782 | check_our_parents (); |
3762 | if (am_transparent) |
3783 | if (am_transparent) |
3763 | want_full_refresh = want_refresh = 1; |
3784 | want_full_refresh = want_refresh = 1; |
… | |
… | |
4276 | |
4297 | |
4277 | /* ---------------------------------------------------------------------- */ |
4298 | /* ---------------------------------------------------------------------- */ |
4278 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4299 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4279 | * or generated by us in response to a query ESC sequence. |
4300 | * or generated by us in response to a query ESC sequence. |
4280 | */ |
4301 | */ |
|
|
4302 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4303 | |
4281 | void |
4304 | void |
4282 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4305 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4283 | { |
4306 | { |
4284 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4307 | if (v_buflen == 0) |
|
|
4308 | { |
|
|
4309 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4285 | |
4310 | |
4286 | if (len) |
4311 | if ((unsigned int)written == len) |
|
|
4312 | return; |
|
|
4313 | |
|
|
4314 | data += written; |
|
|
4315 | len -= written; |
4287 | { |
4316 | } |
|
|
4317 | |
|
|
4318 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4319 | |
|
|
4320 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4321 | v_buflen += len; |
|
|
4322 | |
|
|
4323 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4324 | } |
|
|
4325 | |
|
|
4326 | void rxvt_term::pty_write () |
|
|
4327 | { |
|
|
4328 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4329 | |
|
|
4330 | if (written > 0) |
|
|
4331 | { |
|
|
4332 | v_buflen -= written; |
|
|
4333 | |
4288 | if (v_buflen == 0) |
4334 | if (v_buflen == 0) |
4289 | { |
4335 | { |
4290 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4291 | |
|
|
4292 | if ((unsigned int)written == len) |
|
|
4293 | return; |
|
|
4294 | |
|
|
4295 | data += written; |
|
|
4296 | len -= written; |
|
|
4297 | } |
|
|
4298 | |
|
|
4299 | |
|
|
4300 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4301 | |
|
|
4302 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4303 | v_buflen += len; |
|
|
4304 | } |
|
|
4305 | |
|
|
4306 | for (;;) |
|
|
4307 | { |
|
|
4308 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4309 | |
|
|
4310 | if (written > 0) |
|
|
4311 | { |
|
|
4312 | v_buflen -= written; |
|
|
4313 | |
|
|
4314 | if (v_buflen == 0) |
|
|
4315 | { |
|
|
4316 | free (v_buffer); |
4336 | free (v_buffer); |
4317 | v_buffer = 0; |
4337 | v_buffer = 0; |
4318 | v_buflen = 0; |
4338 | v_buflen = 0; |
4319 | |
4339 | |
4320 | pty_ev.set (EVENT_READ); |
4340 | pty_ev.set (EVENT_READ); |
4321 | return; |
|
|
4322 | } |
|
|
4323 | |
|
|
4324 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
4325 | } |
|
|
4326 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4327 | // original code just ignores this... |
|
|
4328 | destroy (); |
|
|
4329 | else |
|
|
4330 | { |
|
|
4331 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4332 | return; |
4341 | return; |
4333 | } |
4342 | } |
|
|
4343 | |
|
|
4344 | memmove (v_buffer, v_buffer + written, v_buflen); |
4334 | } |
4345 | } |
|
|
4346 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4347 | // original code just ignores this... |
|
|
4348 | destroy (); |
4335 | } |
4349 | } |
4336 | |
4350 | |
4337 | /*----------------------- end-of-file (C source) -----------------------*/ |
4351 | /*----------------------- end-of-file (C source) -----------------------*/ |
4338 | |
4352 | |