… | |
… | |
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 | #ifdef KEYSYM_RESOURCE |
|
|
54 | # include "keyboard.h" |
|
|
55 | #endif |
|
|
56 | |
53 | #include <wchar.h> |
57 | #include <cwchar> |
|
|
58 | #include <csignal> |
54 | |
59 | |
55 | /*----------------------------------------------------------------------*/ |
60 | /*----------------------------------------------------------------------*/ |
56 | |
61 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
62 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
63 | |
… | |
… | |
343 | valid_keysym = keysym != NoSymbol; |
348 | valid_keysym = keysym != NoSymbol; |
344 | } |
349 | } |
345 | |
350 | |
346 | if (valid_keysym) |
351 | if (valid_keysym) |
347 | { |
352 | { |
|
|
353 | #ifdef KEYSYM_RESOURCE |
|
|
354 | if (keyboard->dispatch (this, keysym, ev.state)) |
|
|
355 | return; |
|
|
356 | #endif |
|
|
357 | |
348 | if (TermWin.saveLines) |
358 | if (TermWin.saveLines) |
349 | { |
359 | { |
350 | #ifdef UNSHIFTED_SCROLLKEYS |
360 | #ifdef UNSHIFTED_SCROLLKEYS |
351 | if (!ctrl && !meta) |
361 | if (!ctrl && !meta) |
352 | #else |
362 | #else |
… | |
… | |
417 | { |
427 | { |
418 | /* normal XTerm key bindings */ |
428 | /* normal XTerm key bindings */ |
419 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
429 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | selection_request (ev.time, 0, 0); |
430 | selection_request (ev.time, 0, 0); |
421 | return; |
431 | return; |
422 | #if TODO // TODO |
432 | #if TODO |
423 | /* rxvt extras */ |
433 | /* rxvt extras */ |
424 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
434 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | change_font (FONT_UP); |
435 | change_font (FONT_UP); |
426 | return; |
436 | return; |
427 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
437 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
486 | } |
496 | } |
487 | #endif |
497 | #endif |
488 | |
498 | |
489 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
499 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
490 | { |
500 | { |
491 | #ifdef KEYSYM_RESOURCE |
|
|
492 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
|
|
493 | { |
|
|
494 | unsigned int l; |
|
|
495 | const unsigned char *kbuf0; |
|
|
496 | |
|
|
497 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
|
|
498 | l = (unsigned int)*kbuf0++; |
|
|
499 | |
|
|
500 | /* escape prefix */ |
|
|
501 | if (meta |
|
|
502 | # ifdef META8_OPTION |
|
|
503 | && meta_char == C0_ESC |
|
|
504 | # endif |
|
|
505 | ) |
|
|
506 | { |
|
|
507 | const unsigned char ch = C0_ESC; |
|
|
508 | tt_write (&ch, 1); |
|
|
509 | } |
|
|
510 | |
|
|
511 | tt_write (kbuf0, l); |
|
|
512 | return; |
|
|
513 | } |
|
|
514 | else |
|
|
515 | #endif |
|
|
516 | { |
501 | { |
517 | newlen = 1; |
502 | newlen = 1; |
518 | switch (keysym) |
503 | switch (keysym) |
519 | { |
504 | { |
520 | #ifndef NO_BACKSPACE_KEY |
505 | #ifndef NO_BACKSPACE_KEY |
… | |
… | |
787 | #undef FKEY |
772 | #undef FKEY |
788 | default: |
773 | default: |
789 | newlen = 0; |
774 | newlen = 0; |
790 | break; |
775 | break; |
791 | } |
776 | } |
|
|
777 | |
792 | if (newlen) |
778 | if (newlen) |
793 | len = strlen (kbuf); |
779 | len = strlen (kbuf); |
794 | } |
780 | } |
795 | |
781 | |
796 | /* |
782 | /* |
… | |
… | |
804 | } |
790 | } |
805 | else if (ctrl && keysym == XK_minus) |
791 | else if (ctrl && keysym == XK_minus) |
806 | { |
792 | { |
807 | len = 1; |
793 | len = 1; |
808 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
794 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
795 | } |
|
|
796 | else if (keysym == XK_ISO_Left_Tab) |
|
|
797 | { |
|
|
798 | strcpy (kbuf, "\033[Z"); |
|
|
799 | len = 3; |
809 | } |
800 | } |
810 | else |
801 | else |
811 | { |
802 | { |
812 | #ifdef META8_OPTION |
803 | #ifdef META8_OPTION |
813 | /* set 8-bit on */ |
804 | /* set 8-bit on */ |
… | |
… | |
872 | #endif /* DEBUG_CMD */ |
863 | #endif /* DEBUG_CMD */ |
873 | tt_write (kbuf, (unsigned int)len); |
864 | tt_write (kbuf, (unsigned int)len); |
874 | } |
865 | } |
875 | /*}}} */ |
866 | /*}}} */ |
876 | |
867 | |
877 | #if (MENUBAR_MAX) |
868 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
878 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
869 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
879 | /* attempt to `write' count to the input buffer */ |
870 | /* attempt to `write' count to the input buffer */ |
880 | unsigned int |
871 | unsigned int |
881 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
872 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
882 | { |
873 | { |
… | |
… | |
905 | |
896 | |
906 | cmd_parse (); |
897 | cmd_parse (); |
907 | |
898 | |
908 | return 0; |
899 | return 0; |
909 | } |
900 | } |
910 | #endif /* MENUBAR_MAX */ |
901 | #endif |
911 | |
902 | |
912 | void |
903 | void |
913 | rxvt_term::flush () |
904 | rxvt_term::flush () |
914 | { |
905 | { |
|
|
906 | flush_ev.stop (); |
|
|
907 | |
915 | #ifdef TRANSPARENT |
908 | #ifdef TRANSPARENT |
916 | if (want_full_refresh) |
909 | if (want_full_refresh) |
917 | { |
910 | { |
918 | want_full_refresh = 0; |
911 | want_full_refresh = 0; |
919 | scr_clear (); |
912 | scr_clear (); |
… | |
… | |
929 | IMSendSpot (); |
922 | IMSendSpot (); |
930 | #endif |
923 | #endif |
931 | } |
924 | } |
932 | |
925 | |
933 | display->flush (); |
926 | display->flush (); |
934 | |
|
|
935 | flush_ev.stop (); |
|
|
936 | } |
927 | } |
937 | |
928 | |
938 | void |
929 | void |
939 | rxvt_term::check_cb (check_watcher &w) |
930 | rxvt_term::check_cb (check_watcher &w) |
940 | { |
931 | { |
… | |
… | |
1016 | { |
1007 | { |
1017 | if (mouse_slip_wheel_speed == 0 |
1008 | if (mouse_slip_wheel_speed == 0 |
1018 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1009 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1019 | : scr_page (UP, mouse_slip_wheel_speed)) |
1010 | : scr_page (UP, mouse_slip_wheel_speed)) |
1020 | { |
1011 | { |
|
|
1012 | if (TermWin.view_start == TermWin.nscrolled || |
|
|
1013 | TermWin.view_start == 0) |
|
|
1014 | mouse_slip_wheel_speed = 0; |
|
|
1015 | |
1021 | refresh_type |= SMOOTH_REFRESH; |
1016 | refresh_type |= SMOOTH_REFRESH; |
1022 | want_refresh = 1; |
1017 | want_refresh = 1; |
1023 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1018 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1024 | } |
1019 | } |
1025 | } |
1020 | } |
… | |
… | |
1057 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1052 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1058 | { |
1053 | { |
1059 | SET_R (this); |
1054 | SET_R (this); |
1060 | SET_LOCALE (locale); |
1055 | SET_LOCALE (locale); |
1061 | |
1056 | |
1062 | if (revents & EVENT_WRITE) |
|
|
1063 | tt_write (0, 0); |
|
|
1064 | else if (revents & EVENT_READ) |
1057 | if (revents & EVENT_READ) |
1065 | // loop, but don't allow a single term to monopolize us |
1058 | // loop, but don't allow a single term to monopolize us |
1066 | while (pty_fill ()) |
1059 | while (pty_fill ()) |
1067 | if (cmd_parse ()) |
1060 | if (cmd_parse ()) |
1068 | break; |
1061 | break; |
|
|
1062 | |
|
|
1063 | if (revents & EVENT_WRITE) |
|
|
1064 | pty_write (); |
1069 | } |
1065 | } |
1070 | |
1066 | |
1071 | void |
1067 | void |
1072 | rxvt_term::pointer_unblank () |
1068 | rxvt_term::pointer_unblank () |
1073 | { |
1069 | { |
… | |
… | |
1087 | rxvt_term::pointer_blank () |
1083 | rxvt_term::pointer_blank () |
1088 | { |
1084 | { |
1089 | if (! (options & Opt_pointerBlank)) |
1085 | if (! (options & Opt_pointerBlank)) |
1090 | return; |
1086 | return; |
1091 | |
1087 | |
1092 | XDefineCursor (display->display, TermWin.vt, blank_cursor); |
1088 | XDefineCursor (display->display, TermWin.vt, display->blank_cursor); |
1093 | XFlush (display->display); |
1089 | XFlush (display->display); |
1094 | |
1090 | |
1095 | hidden_pointer = 1; |
1091 | hidden_pointer = 1; |
1096 | } |
1092 | } |
1097 | |
1093 | |
… | |
… | |
1216 | if (ev.type == KeyPress && hidden_pointer == 0) |
1212 | if (ev.type == KeyPress && hidden_pointer == 0) |
1217 | pointer_blank (); |
1213 | pointer_blank (); |
1218 | } |
1214 | } |
1219 | #endif |
1215 | #endif |
1220 | |
1216 | |
1221 | #ifdef USE_XIM |
|
|
1222 | if (XFilterEvent (&ev, None)) |
|
|
1223 | return; |
|
|
1224 | #endif |
|
|
1225 | |
|
|
1226 | Window unused_root, unused_child; |
1217 | Window unused_root, unused_child; |
1227 | int unused_root_x, unused_root_y; |
1218 | int unused_root_x, unused_root_y; |
1228 | unsigned int unused_mask; |
1219 | unsigned int unused_mask; |
1229 | |
1220 | |
1230 | switch (ev.type) |
1221 | switch (ev.type) |
1231 | { |
1222 | { |
1232 | case KeyPress: |
1223 | case KeyPress: |
1233 | #if ISO_14755 |
1224 | #if ISO_14755 |
… | |
… | |
1338 | 0L, 1000000L, |
1329 | 0L, 1000000L, |
1339 | False, AnyPropertyType, |
1330 | False, AnyPropertyType, |
1340 | &ActualType, &ActualFormat, |
1331 | &ActualType, &ActualFormat, |
1341 | &Size, &RemainingBytes, |
1332 | &Size, &RemainingBytes, |
1342 | &data); |
1333 | &data); |
1343 | XChangeProperty (display->display, display->root, |
1334 | set_string_property (XA_CUT_BUFFER0, data); |
1344 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1345 | 8, PropModeReplace, |
|
|
1346 | data, strlen (data)); |
|
|
1347 | XFree (data); |
1335 | XFree (data); |
1348 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1336 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1349 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1337 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1350 | } |
1338 | } |
1351 | #endif /* OFFIX_DND */ |
1339 | #endif /* OFFIX_DND */ |
1352 | break; |
1340 | break; |
1353 | |
1341 | |
… | |
… | |
1457 | resize_all_windows (width, height, 1); |
1445 | resize_all_windows (width, height, 1); |
1458 | } |
1446 | } |
1459 | |
1447 | |
1460 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1448 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1461 | if (options & Opt_transparent) |
1449 | if (options & Opt_transparent) |
1462 | { |
|
|
1463 | check_our_parents (); |
1450 | check_our_parents (); |
1464 | if (am_transparent) |
|
|
1465 | want_refresh = want_full_refresh = 1; |
|
|
1466 | } |
|
|
1467 | #endif |
1451 | #endif |
1468 | } |
1452 | } |
1469 | break; |
1453 | break; |
1470 | |
1454 | |
1471 | case PropertyNotify: |
1455 | case PropertyNotify: |
… | |
… | |
1479 | selection_clear (); |
1463 | selection_clear (); |
1480 | break; |
1464 | break; |
1481 | |
1465 | |
1482 | case SelectionNotify: |
1466 | case SelectionNotify: |
1483 | if (selection_wait == Sel_normal) |
1467 | if (selection_wait == Sel_normal) |
1484 | selection_paste (ev.xselection.requestor, |
1468 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1485 | ev.xselection.property, True); |
|
|
1486 | break; |
1469 | break; |
1487 | |
1470 | |
1488 | case SelectionRequest: |
1471 | case SelectionRequest: |
1489 | selection_send (ev.xselectionrequest); |
1472 | selection_send (ev.xselectionrequest); |
1490 | break; |
1473 | break; |
… | |
… | |
1562 | { |
1545 | { |
1563 | menubar_control (ev.xbutton); |
1546 | menubar_control (ev.xbutton); |
1564 | break; |
1547 | break; |
1565 | } |
1548 | } |
1566 | #endif |
1549 | #endif |
1567 | if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1550 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1568 | break; |
1551 | break; |
1569 | |
1552 | |
1570 | if (ev.xany.window == TermWin.vt) |
1553 | if (ev.xany.window == TermWin.vt) |
1571 | { |
1554 | { |
1572 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1555 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
… | |
… | |
1575 | ; |
1558 | ; |
1576 | |
1559 | |
1577 | XQueryPointer (display->display, TermWin.vt, |
1560 | XQueryPointer (display->display, TermWin.vt, |
1578 | &unused_root, &unused_child, |
1561 | &unused_root, &unused_child, |
1579 | &unused_root_x, &unused_root_y, |
1562 | &unused_root_x, &unused_root_y, |
1580 | & (ev.xbutton.x), & (ev.xbutton.y), |
1563 | &ev.xbutton.x, &ev.xbutton.y, |
1581 | &unused_mask); |
1564 | &ev.xbutton.state); |
1582 | #ifdef MOUSE_THRESHOLD |
1565 | #ifdef MOUSE_THRESHOLD |
1583 | /* deal with a `jumpy' mouse */ |
1566 | /* deal with a `jumpy' mouse */ |
1584 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1567 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1585 | { |
1568 | { |
1586 | #endif |
1569 | #endif |
… | |
… | |
1591 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1574 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1592 | break; |
1575 | break; |
1593 | } |
1576 | } |
1594 | #endif |
1577 | #endif |
1595 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1578 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1596 | (ev.xbutton.state & Button3Mask) ? 2 : 0); |
1579 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1580 | |
1597 | #ifdef SELECTION_SCROLLING |
1581 | #ifdef SELECTION_SCROLLING |
1598 | if (ev.xbutton.y < TermWin.int_bwidth |
1582 | if (ev.xbutton.y < TermWin.int_bwidth |
1599 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1583 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1600 | { |
1584 | { |
1601 | int dist; |
1585 | int dist; |
… | |
… | |
1612 | selection_save_x = ev.xbutton.x; |
1596 | selection_save_x = ev.xbutton.x; |
1613 | selection_save_y = ev.xbutton.y; |
1597 | selection_save_y = ev.xbutton.y; |
1614 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1598 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1615 | |
1599 | |
1616 | /* calc number of lines to scroll */ |
1600 | /* calc number of lines to scroll */ |
1617 | if (ev.xbutton.y<TermWin.int_bwidth) |
1601 | if (ev.xbutton.y < TermWin.int_bwidth) |
1618 | { |
1602 | { |
1619 | scroll_selection_dir = UP; |
1603 | scroll_selection_dir = UP; |
1620 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1604 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1621 | } |
1605 | } |
1622 | else |
1606 | else |
… | |
… | |
1646 | } |
1630 | } |
1647 | } |
1631 | } |
1648 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1632 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1649 | { |
1633 | { |
1650 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1634 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1651 | MotionNotify, &ev)) ; |
1635 | MotionNotify, &ev)) |
|
|
1636 | ; |
|
|
1637 | |
1652 | XQueryPointer (display->display, scrollBar.win, |
1638 | XQueryPointer (display->display, scrollBar.win, |
1653 | &unused_root, &unused_child, |
1639 | &unused_root, &unused_child, |
1654 | &unused_root_x, &unused_root_y, |
1640 | &unused_root_x, &unused_root_y, |
1655 | & (ev.xbutton.x), & (ev.xbutton.y), |
1641 | &ev.xbutton.x, &ev.xbutton.y, |
1656 | &unused_mask); |
1642 | &unused_mask); |
1657 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1643 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1658 | scrollbar_size ()); |
1644 | scrollbar_size ()); |
1659 | scr_refresh (refresh_type); |
1645 | scr_refresh (refresh_type); |
1660 | refresh_limit = 0; |
1646 | refresh_limit = 0; |
… | |
… | |
1676 | case PropertyNotify: |
1662 | case PropertyNotify: |
1677 | /* |
1663 | /* |
1678 | * if user used some Esetroot compatible prog to set the root bg, |
1664 | * 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. |
1665 | * use the property to determine the pixmap. We use it later on. |
1680 | */ |
1666 | */ |
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]) |
1667 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1668 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1685 | return; |
1669 | return; |
1686 | |
1670 | |
1687 | /* FALLTHROUGH */ |
1671 | /* FALLTHROUGH */ |
1688 | case ReparentNotify: |
1672 | case ReparentNotify: |
1689 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1673 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
1715 | return; |
1699 | return; |
1716 | } |
1700 | } |
1717 | #endif |
1701 | #endif |
1718 | |
1702 | |
1719 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1703 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
|
|
1704 | |
1720 | if (reportmode) |
1705 | if (reportmode) |
1721 | { |
1706 | { |
1722 | /* mouse report from vt window */ |
1707 | /* mouse report from vt window */ |
1723 | /* save the xbutton state (for ButtonRelease) */ |
1708 | /* save the xbutton state (for ButtonRelease) */ |
1724 | MEvent.state = ev.state; |
1709 | MEvent.state = ev.state; |
… | |
… | |
1753 | } |
1738 | } |
1754 | else |
1739 | else |
1755 | { |
1740 | { |
1756 | if (ev.button != MEvent.button) |
1741 | if (ev.button != MEvent.button) |
1757 | MEvent.clicks = 0; |
1742 | MEvent.clicks = 0; |
|
|
1743 | |
1758 | switch (ev.button) |
1744 | switch (ev.button) |
1759 | { |
1745 | { |
1760 | case Button1: |
1746 | case Button1: |
|
|
1747 | /* allow meta + click to select rectangular areas */ |
|
|
1748 | /* should be done in screen.C */ |
|
|
1749 | #if ENABLE_FRILLS |
|
|
1750 | selection.rect = !!(ev.state & ModMetaMask); |
|
|
1751 | #else |
|
|
1752 | selection.rect = false; |
|
|
1753 | #endif |
|
|
1754 | |
1761 | /* allow shift+left click to extend selection */ |
1755 | /* allow shift+left click to extend selection */ |
1762 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1756 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1763 | { |
1757 | { |
1764 | if (MEvent.button == Button1 && clickintime) |
1758 | if (MEvent.button == Button1 && clickintime) |
1765 | selection_rotate (ev.x, ev.y); |
1759 | selection_rotate (ev.x, ev.y); |
… | |
… | |
2349 | /* |
2343 | /* |
2350 | * Make the frame window set by the window manager have |
2344 | * Make the frame window set by the window manager have |
2351 | * the root background. Some window managers put multiple nested frame |
2345 | * the root background. Some window managers put multiple nested frame |
2352 | * windows for each client, so we have to take care about that. |
2346 | * windows for each client, so we have to take care about that. |
2353 | */ |
2347 | */ |
2354 | i = (xa[XA_XROOTPMAPID] |
2348 | i = (xa[XA_XROOTPMAP_ID] |
2355 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2349 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], |
2356 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2350 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2357 | &nitems, &bytes_after, &prop) == Success); |
2351 | &nitems, &bytes_after, &prop) == Success); |
2358 | |
2352 | |
2359 | if (!i || prop == NULL) |
2353 | if (!i || prop == NULL) |
2360 | i = (xa[XA_XSETROOTID] |
2354 | i = (xa[XA_ESETROOT_PMAP_ID] |
2361 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2355 | && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], |
2362 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2356 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2363 | &nitems, &bytes_after, &prop) == Success); |
2357 | &nitems, &bytes_after, &prop) == Success); |
2364 | |
2358 | |
2365 | if (!i || prop == NULL |
2359 | if (!i || prop == NULL |
2366 | #if TINTING |
2360 | #if TINTING |
… | |
… | |
2407 | sy = 0; |
2401 | sy = 0; |
2408 | } |
2402 | } |
2409 | |
2403 | |
2410 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2404 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2411 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2405 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2406 | |
|
|
2407 | XSync (display->display, False); |
2412 | allowedxerror = -1; |
2408 | allowedxerror = -1; |
2413 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2409 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2414 | |
2410 | |
2415 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2411 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2416 | /* XXX: may need a delay here? */ |
2412 | /* XXX: may need a delay here? */ |
… | |
… | |
2462 | |
2458 | |
2463 | am_transparent = am_pixmap_trans = 1; |
2459 | am_transparent = am_pixmap_trans = 1; |
2464 | } |
2460 | } |
2465 | } |
2461 | } |
2466 | |
2462 | |
2467 | if (!am_pixmap_trans) |
2463 | if (am_pixmap_trans) |
|
|
2464 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
|
|
2465 | else |
2468 | { |
2466 | { |
2469 | unsigned int n; |
2467 | unsigned int n; |
2470 | /* |
2468 | /* |
2471 | * InheritPixmap transparency |
2469 | * InheritPixmap transparency |
2472 | */ |
2470 | */ |
… | |
… | |
2535 | if (scrollBar.win) |
2533 | if (scrollBar.win) |
2536 | { |
2534 | { |
2537 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2535 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2538 | scrollBar.setIdle (); |
2536 | scrollBar.setIdle (); |
2539 | scrollbar_show (0); |
2537 | scrollbar_show (0); |
|
|
2538 | } |
|
|
2539 | |
|
|
2540 | if (am_transparent) |
|
|
2541 | { |
|
|
2542 | want_refresh = want_full_refresh = 1; |
|
|
2543 | if (am_pixmap_trans) |
|
|
2544 | flush (); |
2540 | } |
2545 | } |
2541 | |
2546 | |
2542 | return pchanged; |
2547 | return pchanged; |
2543 | } |
2548 | } |
2544 | #endif |
2549 | #endif |
… | |
… | |
2696 | if (len == (size_t)-1) |
2701 | if (len == (size_t)-1) |
2697 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2702 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2698 | |
2703 | |
2699 | // assume wchar == unicode |
2704 | // assume wchar == unicode |
2700 | cmdbuf_ptr += len; |
2705 | cmdbuf_ptr += len; |
2701 | return wc; |
2706 | return wc & UNICODE_MASK; |
2702 | } |
2707 | } |
2703 | |
2708 | |
2704 | return NOCHAR; |
2709 | return NOCHAR; |
2705 | } |
2710 | } |
2706 | |
2711 | |
… | |
… | |
3504 | * ends_how is terminator used. returned input must be free()'d |
3509 | * ends_how is terminator used. returned input must be free()'d |
3505 | */ |
3510 | */ |
3506 | unsigned char * |
3511 | unsigned char * |
3507 | rxvt_term::get_to_st (unicode_t &ends_how) |
3512 | rxvt_term::get_to_st (unicode_t &ends_how) |
3508 | { |
3513 | { |
3509 | unicode_t seen_esc = 0, ch; |
3514 | unicode_t ch; |
|
|
3515 | bool seen_esc = false; |
3510 | unsigned int n = 0; |
3516 | unsigned int n = 0; |
3511 | unsigned char *s; |
|
|
3512 | unsigned char string[STRING_MAX]; |
3517 | wchar_t string[STRING_MAX]; |
3513 | |
3518 | |
3514 | while ((ch = cmd_getc ()) != NOCHAR) |
3519 | while ((ch = cmd_getc ()) != NOCHAR) |
3515 | { |
3520 | { |
3516 | if (seen_esc) |
3521 | if (seen_esc) |
3517 | { |
3522 | { |
… | |
… | |
3520 | else |
3525 | else |
3521 | return NULL; |
3526 | return NULL; |
3522 | } |
3527 | } |
3523 | else if (ch == C0_ESC) |
3528 | else if (ch == C0_ESC) |
3524 | { |
3529 | { |
3525 | seen_esc = 1; |
3530 | seen_esc = true; |
3526 | continue; |
3531 | continue; |
3527 | } |
3532 | } |
3528 | else if (ch == C0_BEL || ch == CHAR_ST) |
3533 | else if (ch == C0_BEL || ch == CHAR_ST) |
3529 | break; |
3534 | break; |
3530 | else if (ch < 0x20) |
3535 | else if (ch < 0x20) |
3531 | return NULL; /* other control character - exit */ |
3536 | return NULL; /* other control character - exit */ |
3532 | |
3537 | |
3533 | seen_esc = 0; |
3538 | seen_esc = false; |
3534 | |
3539 | |
3535 | if (n >= sizeof (string) - 1) |
3540 | if (n >= sizeof (string) - 1) |
3536 | // stop at some sane length |
3541 | // stop at some sane length |
3537 | return NULL; |
3542 | return NULL; |
3538 | |
3543 | |
… | |
… | |
3542 | string[n++] = ch; |
3547 | string[n++] = ch; |
3543 | } |
3548 | } |
3544 | |
3549 | |
3545 | string[n++] = '\0'; |
3550 | string[n++] = '\0'; |
3546 | |
3551 | |
3547 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3548 | return NULL; |
|
|
3549 | |
|
|
3550 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3552 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3551 | strncpy (s, string, n); |
3553 | |
3552 | return s; |
3554 | return (unsigned char *)rxvt_wcstombs (string); |
3553 | } |
3555 | } |
3554 | |
3556 | |
3555 | /*----------------------------------------------------------------------*/ |
3557 | /*----------------------------------------------------------------------*/ |
3556 | /* |
3558 | /* |
3557 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3559 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3658 | set_title (str); |
3660 | set_title (str); |
3659 | break; |
3661 | break; |
3660 | case XTerm_property: |
3662 | case XTerm_property: |
3661 | if (str[0] == '?') |
3663 | if (str[0] == '?') |
3662 | { |
3664 | { |
3663 | Atom prop = XInternAtom (display->display, str + 1, True); |
3665 | Atom prop = display->atom (str + 1); |
3664 | Atom actual_type; |
3666 | Atom actual_type; |
3665 | int actual_format; |
3667 | int actual_format; |
3666 | unsigned long nitems; |
3668 | unsigned long nitems; |
3667 | unsigned long bytes_after; |
3669 | unsigned long bytes_after; |
3668 | unsigned char *value = 0; |
3670 | unsigned char *value = 0; |
… | |
… | |
3686 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3688 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3687 | |
3689 | |
3688 | if (eq) |
3690 | if (eq) |
3689 | { |
3691 | { |
3690 | *eq = 0; |
3692 | *eq = 0; |
3691 | XChangeProperty (display->display, TermWin.parent[0], |
3693 | 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 | } |
3694 | } |
3696 | else |
3695 | else |
3697 | XDeleteProperty (display->display, TermWin.parent[0], |
3696 | XDeleteProperty (display->display, TermWin.parent[0], |
3698 | display->atom (str)); |
3697 | display->atom (str)); |
3699 | } |
3698 | } |
… | |
… | |
3753 | break; |
3752 | break; |
3754 | case XTerm_Color_RV: |
3753 | case XTerm_Color_RV: |
3755 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3754 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3756 | break; |
3755 | break; |
3757 | #endif |
3756 | #endif |
3758 | #if TRANSPARENT || TINTING |
3757 | #if TRANSPARENT && TINTING |
3759 | case XTerm_Color_tint: |
3758 | case XTerm_Color_tint: |
3760 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3759 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3761 | check_our_parents (); |
3760 | check_our_parents (); |
3762 | if (am_transparent) |
3761 | if (am_transparent) |
3763 | want_full_refresh = want_refresh = 1; |
3762 | want_full_refresh = want_refresh = 1; |
… | |
… | |
3829 | if (query) |
3828 | if (query) |
3830 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3829 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3831 | else |
3830 | else |
3832 | { |
3831 | { |
3833 | set_locale (str); |
3832 | set_locale (str); |
|
|
3833 | pty.set_utf8_mode (enc_utf8); |
3834 | # ifdef USE_XIM |
3834 | # ifdef USE_XIM |
3835 | im_cb (); |
3835 | im_cb (); |
3836 | # endif |
3836 | # endif |
3837 | } |
3837 | } |
3838 | break; |
3838 | break; |
… | |
… | |
4276 | |
4276 | |
4277 | /* ---------------------------------------------------------------------- */ |
4277 | /* ---------------------------------------------------------------------- */ |
4278 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4278 | /* 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. |
4279 | * or generated by us in response to a query ESC sequence. |
4280 | */ |
4280 | */ |
|
|
4281 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4282 | |
4281 | void |
4283 | void |
4282 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4284 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4283 | { |
4285 | { |
4284 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4286 | if (v_buflen == 0) |
|
|
4287 | { |
|
|
4288 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4285 | |
4289 | |
4286 | if (len) |
4290 | if ((unsigned int)written == len) |
|
|
4291 | return; |
|
|
4292 | |
|
|
4293 | data += written; |
|
|
4294 | len -= written; |
4287 | { |
4295 | } |
|
|
4296 | |
|
|
4297 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4298 | |
|
|
4299 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4300 | v_buflen += len; |
|
|
4301 | |
|
|
4302 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4303 | } |
|
|
4304 | |
|
|
4305 | void rxvt_term::pty_write () |
|
|
4306 | { |
|
|
4307 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4308 | |
|
|
4309 | if (written > 0) |
|
|
4310 | { |
|
|
4311 | v_buflen -= written; |
|
|
4312 | |
4288 | if (v_buflen == 0) |
4313 | if (v_buflen == 0) |
4289 | { |
4314 | { |
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); |
4315 | free (v_buffer); |
4317 | v_buffer = 0; |
4316 | v_buffer = 0; |
4318 | v_buflen = 0; |
4317 | v_buflen = 0; |
4319 | |
4318 | |
4320 | pty_ev.set (EVENT_READ); |
4319 | 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; |
4320 | return; |
4333 | } |
4321 | } |
|
|
4322 | |
|
|
4323 | memmove (v_buffer, v_buffer + written, v_buflen); |
4334 | } |
4324 | } |
|
|
4325 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4326 | // original code just ignores this... |
|
|
4327 | destroy (); |
4335 | } |
4328 | } |
4336 | |
4329 | |
4337 | /*----------------------- end-of-file (C source) -----------------------*/ |
4330 | /*----------------------- end-of-file (C source) -----------------------*/ |
4338 | |
4331 | |