… | |
… | |
63 | #include <csignal> |
63 | #include <csignal> |
64 | |
64 | |
65 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
66 | |
66 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
|
|
69 | // exception thrown when the command parser runs out of input data |
|
|
70 | class out_of_input { } out_of_input; |
|
|
71 | |
68 | |
72 | #if ENABLE_FRILLS || ISO_14755 |
69 | #if ENABLE_FRILLS || ISO_14755 |
73 | |
70 | |
74 | #define ISO_14755_STARTED 0x80000000UL |
71 | #define ISO_14755_STARTED 0x80000000UL |
75 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
72 | #define ISO_14755_51 0x40000000UL // basic (section 5.1) |
… | |
… | |
1044 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1041 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1045 | { |
1042 | { |
1046 | hidden_cursor = !hidden_cursor; |
1043 | hidden_cursor = !hidden_cursor; |
1047 | want_refresh = 1; |
1044 | want_refresh = 1; |
1048 | |
1045 | |
1049 | w.start (w.at + BLINK_INTERVAL); |
1046 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
1050 | } |
1047 | } |
1051 | #endif |
1048 | #endif |
1052 | |
1049 | |
1053 | #ifdef TEXT_BLINK |
1050 | #ifdef TEXT_BLINK |
1054 | void |
1051 | void |
… | |
… | |
1405 | button_release (ev.xbutton); |
1402 | button_release (ev.xbutton); |
1406 | break; |
1403 | break; |
1407 | |
1404 | |
1408 | case ClientMessage: |
1405 | case ClientMessage: |
1409 | if (ev.xclient.format == 32 |
1406 | if (ev.xclient.format == 32 |
1410 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1407 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1411 | { |
1408 | { |
|
|
1409 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1410 | { |
|
|
1411 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1412 | { |
1412 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1413 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1414 | { |
|
|
1415 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1413 | destroy (); |
1416 | destroy (); |
|
|
1417 | } |
1414 | #if ENABLE_EWMH |
1418 | #if ENABLE_EWMH |
1415 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1419 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1416 | XSendEvent (disp, ev.xclient.window = display->root, |
1420 | XSendEvent (disp, ev.xclient.window = display->root, |
1417 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1421 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1418 | &ev); |
1422 | &ev); |
|
|
1423 | #endif |
|
|
1424 | } |
|
|
1425 | } |
|
|
1426 | #if ENABLE_XEMBED |
|
|
1427 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1428 | { |
|
|
1429 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1430 | focus_in (); |
|
|
1431 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1432 | focus_out (); |
|
|
1433 | } |
1419 | #endif |
1434 | #endif |
1420 | } |
1435 | } |
1421 | #if ENABLE_XEMBED |
|
|
1422 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1423 | { |
|
|
1424 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1425 | focus_in (); |
|
|
1426 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1427 | focus_out (); |
|
|
1428 | } |
|
|
1429 | #endif |
|
|
1430 | #ifdef OFFIX_DND |
|
|
1431 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1432 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1433 | && (ev.xclient.data.l[0] == DndFile |
|
|
1434 | || ev.xclient.data.l[0] == DndDir |
|
|
1435 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1436 | { |
|
|
1437 | /* Get Dnd data */ |
|
|
1438 | Atom ActualType; |
|
|
1439 | int ActualFormat; |
|
|
1440 | unsigned char *data; |
|
|
1441 | unsigned long Size, RemainingBytes; |
|
|
1442 | |
|
|
1443 | XGetWindowProperty (disp, display->root, |
|
|
1444 | xa[XA_DNDSELECTION], |
|
|
1445 | 0L, 1000000L, |
|
|
1446 | False, AnyPropertyType, |
|
|
1447 | &ActualType, &ActualFormat, |
|
|
1448 | &Size, &RemainingBytes, |
|
|
1449 | &data); |
|
|
1450 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1451 | XFree (data); |
|
|
1452 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1453 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1454 | } |
|
|
1455 | #endif /* OFFIX_DND */ |
|
|
1456 | break; |
1436 | break; |
1457 | |
1437 | |
1458 | case MappingNotify: |
1438 | case MappingNotify: |
1459 | XRefreshKeyboardMapping (&ev.xmapping); |
1439 | XRefreshKeyboardMapping (&ev.xmapping); |
1460 | break; |
1440 | break; |
… | |
… | |
1512 | #endif |
1492 | #endif |
1513 | } |
1493 | } |
1514 | break; |
1494 | break; |
1515 | |
1495 | |
1516 | case PropertyNotify: |
1496 | case PropertyNotify: |
|
|
1497 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1517 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1498 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1518 | && ev.xproperty.state == PropertyNewValue) |
1499 | && ev.xproperty.state == PropertyNewValue) |
1519 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1500 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1520 | |
1501 | |
1521 | break; |
1502 | break; |
1522 | |
1503 | |
1523 | case SelectionClear: |
1504 | case SelectionClear: |
1524 | selection_clear (); |
1505 | selection_clear (); |
… | |
… | |
1713 | { |
1694 | { |
1714 | hidden_cursor = 0; |
1695 | hidden_cursor = 0; |
1715 | want_refresh = 1; |
1696 | want_refresh = 1; |
1716 | } |
1697 | } |
1717 | |
1698 | |
1718 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1699 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1719 | } |
1700 | } |
1720 | #endif |
1701 | #endif |
1721 | |
1702 | |
1722 | #if defined(POINTER_BLANK) |
1703 | #if defined(POINTER_BLANK) |
1723 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1704 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
… | |
… | |
1751 | XSetICFocus (Input_Context); |
1732 | XSetICFocus (Input_Context); |
1752 | } |
1733 | } |
1753 | #endif |
1734 | #endif |
1754 | #if CURSOR_BLINK |
1735 | #if CURSOR_BLINK |
1755 | if (OPTION (Opt_cursorBlink)) |
1736 | if (OPTION (Opt_cursorBlink)) |
1756 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
1737 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1757 | #endif |
1738 | #endif |
1758 | #if OFF_FOCUS_FADING |
1739 | #if OFF_FOCUS_FADING |
1759 | if (rs[Rs_fade]) |
1740 | if (rs[Rs_fade]) |
1760 | { |
1741 | { |
1761 | pix_colors = pix_colors_focused; |
1742 | pix_colors = pix_colors_focused; |
… | |
… | |
1842 | /* |
1823 | /* |
1843 | * VT window processing of button press |
1824 | * VT window processing of button press |
1844 | */ |
1825 | */ |
1845 | if (ev.window == vt) |
1826 | if (ev.window == vt) |
1846 | { |
1827 | { |
|
|
1828 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1829 | return; |
|
|
1830 | |
1847 | #if ISO_14755 |
1831 | #if ISO_14755 |
1848 | // 5.4 |
1832 | // 5.4 |
1849 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1833 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1850 | { |
1834 | { |
1851 | iso14755_54 (ev.x, ev.y); |
1835 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1893 | else |
1877 | else |
1894 | { |
1878 | { |
1895 | if (ev.button != MEvent.button) |
1879 | if (ev.button != MEvent.button) |
1896 | MEvent.clicks = 0; |
1880 | MEvent.clicks = 0; |
1897 | |
1881 | |
1898 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1899 | switch (ev.button) |
1882 | switch (ev.button) |
1900 | { |
1883 | { |
1901 | case Button1: |
1884 | case Button1: |
1902 | /* allow meta + click to select rectangular areas */ |
1885 | /* allow meta + click to select rectangular areas */ |
1903 | /* should be done in screen.C */ |
1886 | /* should be done in screen.C */ |
1904 | #if ENABLE_FRILLS |
1887 | #if ENABLE_FRILLS |
1905 | selection.rect = !!(ev.state & ModMetaMask); |
1888 | selection.rect = !!(ev.state & ModMetaMask); |
1906 | #else |
1889 | #else |
1907 | selection.rect = false; |
1890 | selection.rect = false; |
1908 | #endif |
1891 | #endif |
1909 | |
1892 | |
1910 | /* allow shift+left click to extend selection */ |
1893 | /* allow shift+left click to extend selection */ |
1911 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1894 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1912 | { |
1895 | { |
1913 | if (MEvent.button == Button1 && clickintime) |
1896 | if (MEvent.button == Button1 && clickintime) |
1914 | selection_rotate (ev.x, ev.y); |
1897 | selection_rotate (ev.x, ev.y); |
1915 | else |
1898 | else |
1916 | selection_extend (ev.x, ev.y, 1); |
1899 | selection_extend (ev.x, ev.y, 1); |
1917 | } |
1900 | } |
1918 | else |
1901 | else |
1919 | { |
1902 | { |
1920 | if (MEvent.button == Button1 && clickintime) |
1903 | if (MEvent.button == Button1 && clickintime) |
1921 | MEvent.clicks++; |
1904 | MEvent.clicks++; |
1922 | else |
1905 | else |
1923 | MEvent.clicks = 1; |
1906 | MEvent.clicks = 1; |
1924 | |
1907 | |
1925 | selection_click (MEvent.clicks, ev.x, ev.y); |
1908 | selection_click (MEvent.clicks, ev.x, ev.y); |
1926 | } |
1909 | } |
1927 | |
1910 | |
1928 | MEvent.button = Button1; |
1911 | MEvent.button = Button1; |
1929 | break; |
1912 | break; |
1930 | |
1913 | |
1931 | case Button3: |
1914 | case Button3: |
1932 | if (MEvent.button == Button3 && clickintime) |
1915 | if (MEvent.button == Button3 && clickintime) |
1933 | selection_rotate (ev.x, ev.y); |
1916 | selection_rotate (ev.x, ev.y); |
1934 | else |
1917 | else |
1935 | selection_extend (ev.x, ev.y, 1); |
1918 | selection_extend (ev.x, ev.y, 1); |
1936 | |
1919 | |
1937 | MEvent.button = Button3; |
1920 | MEvent.button = Button3; |
1938 | break; |
1921 | break; |
1939 | } |
1922 | } |
1940 | } |
1923 | } |
1941 | |
1924 | |
1942 | MEvent.time = ev.time; |
1925 | MEvent.time = ev.time; |
1943 | return; |
1926 | return; |
1944 | } |
1927 | } |
1945 | |
1928 | |
… | |
… | |
2108 | sel_scroll_ev.stop(); |
2091 | sel_scroll_ev.stop(); |
2109 | #endif |
2092 | #endif |
2110 | |
2093 | |
2111 | if (ev.window == vt) |
2094 | if (ev.window == vt) |
2112 | { |
2095 | { |
|
|
2096 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2097 | return; |
|
|
2098 | |
2113 | #if ISO_14755 |
2099 | #if ISO_14755 |
2114 | // 5.4 |
2100 | // 5.4 |
2115 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2101 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2116 | return; |
2102 | return; |
2117 | #endif |
2103 | #endif |
|
|
2104 | |
2118 | if (reportmode) |
2105 | if (reportmode) |
2119 | { |
2106 | { |
2120 | /* mouse report from vt window */ |
2107 | /* mouse report from vt window */ |
2121 | /* don't report release of wheel "buttons" */ |
2108 | /* don't report release of wheel "buttons" */ |
2122 | if (ev.button >= 4) |
2109 | if (ev.button >= 4) |
… | |
… | |
2146 | if (priv_modes & PrivMode_mouse_report |
2133 | if (priv_modes & PrivMode_mouse_report |
2147 | && bypass_keystate |
2134 | && bypass_keystate |
2148 | && ev.button == Button1 && MEvent.clicks <= 1) |
2135 | && ev.button == Button1 && MEvent.clicks <= 1) |
2149 | selection_extend (ev.x, ev.y, 0); |
2136 | selection_extend (ev.x, ev.y, 0); |
2150 | |
2137 | |
2151 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2152 | return; |
|
|
2153 | |
|
|
2154 | switch (ev.button) |
2138 | switch (ev.button) |
2155 | { |
2139 | { |
2156 | case Button1: |
2140 | case Button1: |
2157 | case Button3: |
2141 | case Button3: |
2158 | selection_make (ev.time); |
2142 | selection_make (ev.time); |
2159 | break; |
2143 | break; |
2160 | |
2144 | |
2161 | case Button2: |
2145 | case Button2: |
2162 | if (IN_RANGE_EXC (ev.x, 0, width) |
2146 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2163 | && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2147 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2164 | selection_request (ev.time); |
|
|
2165 | |
|
|
2166 | break; |
2148 | break; |
2167 | |
2149 | |
2168 | #ifdef MOUSE_WHEEL |
2150 | #ifdef MOUSE_WHEEL |
2169 | case Button4: |
2151 | case Button4: |
2170 | case Button5: |
2152 | case Button5: |
… | |
… | |
2650 | am_transparent = 0; |
2632 | am_transparent = 0; |
2651 | /* XXX: also turn off Opt_transparent? */ |
2633 | /* XXX: also turn off Opt_transparent? */ |
2652 | } |
2634 | } |
2653 | else |
2635 | else |
2654 | { |
2636 | { |
2655 | #if WAIT_FOR_WM |
|
|
2656 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2657 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2658 | sleep (1); |
|
|
2659 | #endif |
|
|
2660 | for (n = 0; n < (unsigned int)i; n++) |
2637 | for (n = 0; n < (unsigned int)i; n++) |
2661 | { |
2638 | { |
2662 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2639 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2663 | XClearWindow (disp, parent[n]); |
2640 | XClearWindow (disp, parent[n]); |
2664 | } |
2641 | } |
… | |
… | |
2827 | return flag; |
2804 | return flag; |
2828 | } |
2805 | } |
2829 | |
2806 | |
2830 | // read the next character |
2807 | // read the next character |
2831 | wchar_t |
2808 | wchar_t |
2832 | rxvt_term::next_char () |
2809 | rxvt_term::next_char () NOTHROW |
2833 | { |
2810 | { |
2834 | while (cmdbuf_ptr < cmdbuf_endp) |
2811 | while (cmdbuf_ptr < cmdbuf_endp) |
2835 | { |
2812 | { |
2836 | // assume 7-bit to be ascii ALWAYS |
2813 | // assume 7-bit to be ascii ALWAYS |
2837 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2814 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
… | |
… | |
2858 | return NOCHAR; |
2835 | return NOCHAR; |
2859 | } |
2836 | } |
2860 | |
2837 | |
2861 | // read the next octet |
2838 | // read the next octet |
2862 | uint32_t |
2839 | uint32_t |
2863 | rxvt_term::next_octet () |
2840 | rxvt_term::next_octet () NOTHROW |
2864 | { |
2841 | { |
2865 | return cmdbuf_ptr < cmdbuf_endp |
2842 | return cmdbuf_ptr < cmdbuf_endp |
2866 | ? (unsigned char)*cmdbuf_ptr++ |
2843 | ? (unsigned char)*cmdbuf_ptr++ |
2867 | : NOCHAR; |
2844 | : NOCHAR; |
2868 | } |
2845 | } |
|
|
2846 | |
|
|
2847 | static class out_of_input out_of_input; |
2869 | |
2848 | |
2870 | /* rxvt_cmd_getc () - Return next input character */ |
2849 | /* rxvt_cmd_getc () - Return next input character */ |
2871 | /* |
2850 | /* |
2872 | * Return the next input character after first passing any keyboard input |
2851 | * Return the next input character after first passing any keyboard input |
2873 | * to the command. |
2852 | * to the command. |
2874 | */ |
2853 | */ |
2875 | wchar_t |
2854 | wchar_t |
2876 | rxvt_term::cmd_getc () |
2855 | rxvt_term::cmd_getc () THROW ((class out_of_input)) |
2877 | { |
2856 | { |
2878 | wchar_t c = next_char (); |
2857 | wchar_t c = next_char (); |
2879 | |
2858 | |
2880 | if (c == NOCHAR) |
2859 | if (c == NOCHAR) |
2881 | throw out_of_input; |
2860 | throw out_of_input; |
2882 | |
2861 | |
2883 | return c; |
2862 | return c; |
2884 | } |
2863 | } |
2885 | |
2864 | |
2886 | uint32_t |
2865 | uint32_t |
2887 | rxvt_term::cmd_get8 () |
2866 | rxvt_term::cmd_get8 () THROW ((class out_of_input)) |
2888 | { |
2867 | { |
2889 | uint32_t c = next_octet (); |
2868 | uint32_t c = next_octet (); |
2890 | |
2869 | |
2891 | if (c == NOCHAR) |
2870 | if (c == NOCHAR) |
2892 | throw out_of_input; |
2871 | throw out_of_input; |
… | |
… | |
3329 | { |
3308 | { |
3330 | switch (priv) |
3309 | switch (priv) |
3331 | { |
3310 | { |
3332 | case '>': |
3311 | case '>': |
3333 | if (ch == CSI_DA) /* secondary device attributes */ |
3312 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
3313 | { |
|
|
3314 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3315 | // 'U' for rxvt-unicode <= 7.2, and Mm85 (e.g. 7385 for 7.3) for later versions. |
|
|
3316 | // |
|
|
3317 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3318 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3319 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3320 | // |
3334 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3321 | tt_printf ("\033[>%c%c85;94;0c", VERSION[0], VERSION[1]); |
|
|
3322 | } |
3335 | break; |
3323 | break; |
3336 | case '?': |
3324 | case '?': |
3337 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3325 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3338 | process_terminal_mode (ch, priv, nargs, arg); |
3326 | process_terminal_mode (ch, priv, nargs, arg); |
3339 | break; |
3327 | break; |
… | |
… | |
4042 | return state; |
4030 | return state; |
4043 | } |
4031 | } |
4044 | |
4032 | |
4045 | /* we're not using priv _yet_ */ |
4033 | /* we're not using priv _yet_ */ |
4046 | void |
4034 | void |
4047 | rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) |
4035 | rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) |
4048 | { |
4036 | { |
4049 | unsigned int i, j; |
4037 | unsigned int i, j; |
4050 | int state; |
4038 | int state; |
4051 | |
4039 | |
4052 | static const struct |
4040 | static const struct |