… | |
… | |
299 | rxvt_term::lookup_key (XKeyEvent &ev) |
299 | rxvt_term::lookup_key (XKeyEvent &ev) |
300 | { |
300 | { |
301 | int ctrl, meta, shft, len; |
301 | int ctrl, meta, shft, len; |
302 | unsigned int newlen; |
302 | unsigned int newlen; |
303 | KeySym keysym; |
303 | KeySym keysym; |
304 | #ifdef DEBUG_CMD |
|
|
305 | static int debug_key = 1; /* accessible by a debugger only */ |
|
|
306 | #endif |
|
|
307 | int valid_keysym; |
304 | int valid_keysym; |
308 | char kbuf[KBUFSZ]; |
305 | char kbuf[KBUFSZ]; |
309 | |
306 | |
310 | /* |
307 | /* |
311 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
308 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
… | |
… | |
902 | { |
899 | { |
903 | const char ch = C0_ESC; |
900 | const char ch = C0_ESC; |
904 | tt_write (&ch, 1); |
901 | tt_write (&ch, 1); |
905 | } |
902 | } |
906 | |
903 | |
907 | #if defined(DEBUG_CMD) |
|
|
908 | /* Display keyboard buffer contents */ |
|
|
909 | unsigned char *p; |
|
|
910 | int i; |
|
|
911 | |
|
|
912 | fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); |
|
|
913 | for (i = 0, p = kbuf; i < len; i++, p++) |
|
|
914 | fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); |
|
|
915 | fprintf (stderr, "'\n"); |
|
|
916 | #endif /* DEBUG_CMD */ |
|
|
917 | tt_write (kbuf, (unsigned int)len); |
904 | tt_write (kbuf, (unsigned int)len); |
918 | } |
905 | } |
919 | /*}}} */ |
906 | /*}}} */ |
920 | |
907 | |
921 | #if defined (KEYSYM_RESOURCE) |
908 | #if defined (KEYSYM_RESOURCE) |
… | |
… | |
1278 | tt_printf ("\033[M%c%c%c", |
1265 | tt_printf ("\033[M%c%c%c", |
1279 | (32 + button_number + key_state), |
1266 | (32 + button_number + key_state), |
1280 | (32 + x + 1), |
1267 | (32 + x + 1), |
1281 | (32 + y + 1)); |
1268 | (32 + y + 1)); |
1282 | } |
1269 | } |
1283 | |
|
|
1284 | #ifdef USING_W11LIB |
|
|
1285 | void |
|
|
1286 | rxvt_W11_process_x_event (XEvent *ev) |
|
|
1287 | { |
|
|
1288 | rxvt_t *r = rxvt_get_r (); |
|
|
1289 | |
|
|
1290 | x_cb (*ev); |
|
|
1291 | } |
|
|
1292 | #endif |
|
|
1293 | |
1270 | |
1294 | /*{{{ process an X event */ |
1271 | /*{{{ process an X event */ |
1295 | void |
1272 | void |
1296 | rxvt_term::x_cb (XEvent &ev) |
1273 | rxvt_term::x_cb (XEvent &ev) |
1297 | { |
1274 | { |
… | |
… | |
1492 | #endif |
1469 | #endif |
1493 | } |
1470 | } |
1494 | break; |
1471 | break; |
1495 | |
1472 | |
1496 | case PropertyNotify: |
1473 | case PropertyNotify: |
|
|
1474 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1497 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1475 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1498 | && ev.xproperty.state == PropertyNewValue) |
1476 | && ev.xproperty.state == PropertyNewValue) |
1499 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1477 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1500 | |
1478 | |
1501 | break; |
1479 | break; |
1502 | |
1480 | |
1503 | case SelectionClear: |
1481 | case SelectionClear: |
1504 | selection_clear (); |
1482 | selection_clear (); |
… | |
… | |
1822 | /* |
1800 | /* |
1823 | * VT window processing of button press |
1801 | * VT window processing of button press |
1824 | */ |
1802 | */ |
1825 | if (ev.window == vt) |
1803 | if (ev.window == vt) |
1826 | { |
1804 | { |
|
|
1805 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1806 | return; |
|
|
1807 | |
1827 | #if ISO_14755 |
1808 | #if ISO_14755 |
1828 | // 5.4 |
1809 | // 5.4 |
1829 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1810 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1830 | { |
1811 | { |
1831 | iso14755_54 (ev.x, ev.y); |
1812 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1873 | else |
1854 | else |
1874 | { |
1855 | { |
1875 | if (ev.button != MEvent.button) |
1856 | if (ev.button != MEvent.button) |
1876 | MEvent.clicks = 0; |
1857 | MEvent.clicks = 0; |
1877 | |
1858 | |
1878 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1879 | switch (ev.button) |
1859 | switch (ev.button) |
1880 | { |
1860 | { |
1881 | case Button1: |
1861 | case Button1: |
1882 | /* allow meta + click to select rectangular areas */ |
1862 | /* allow meta + click to select rectangular areas */ |
1883 | /* should be done in screen.C */ |
1863 | /* should be done in screen.C */ |
1884 | #if ENABLE_FRILLS |
1864 | #if ENABLE_FRILLS |
1885 | selection.rect = !!(ev.state & ModMetaMask); |
1865 | selection.rect = !!(ev.state & ModMetaMask); |
1886 | #else |
1866 | #else |
1887 | selection.rect = false; |
1867 | selection.rect = false; |
1888 | #endif |
1868 | #endif |
1889 | |
1869 | |
1890 | /* allow shift+left click to extend selection */ |
1870 | /* allow shift+left click to extend selection */ |
1891 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1871 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1892 | { |
1872 | { |
1893 | if (MEvent.button == Button1 && clickintime) |
1873 | if (MEvent.button == Button1 && clickintime) |
1894 | selection_rotate (ev.x, ev.y); |
1874 | selection_rotate (ev.x, ev.y); |
1895 | else |
1875 | else |
1896 | selection_extend (ev.x, ev.y, 1); |
1876 | selection_extend (ev.x, ev.y, 1); |
1897 | } |
1877 | } |
1898 | else |
1878 | else |
1899 | { |
1879 | { |
1900 | if (MEvent.button == Button1 && clickintime) |
1880 | if (MEvent.button == Button1 && clickintime) |
1901 | MEvent.clicks++; |
1881 | MEvent.clicks++; |
1902 | else |
1882 | else |
1903 | MEvent.clicks = 1; |
1883 | MEvent.clicks = 1; |
1904 | |
1884 | |
1905 | selection_click (MEvent.clicks, ev.x, ev.y); |
1885 | selection_click (MEvent.clicks, ev.x, ev.y); |
1906 | } |
1886 | } |
1907 | |
1887 | |
1908 | MEvent.button = Button1; |
1888 | MEvent.button = Button1; |
1909 | break; |
1889 | break; |
1910 | |
1890 | |
1911 | case Button3: |
1891 | case Button3: |
1912 | if (MEvent.button == Button3 && clickintime) |
1892 | if (MEvent.button == Button3 && clickintime) |
1913 | selection_rotate (ev.x, ev.y); |
1893 | selection_rotate (ev.x, ev.y); |
1914 | else |
1894 | else |
1915 | selection_extend (ev.x, ev.y, 1); |
1895 | selection_extend (ev.x, ev.y, 1); |
1916 | |
1896 | |
1917 | MEvent.button = Button3; |
1897 | MEvent.button = Button3; |
1918 | break; |
1898 | break; |
1919 | } |
1899 | } |
1920 | } |
1900 | } |
1921 | |
1901 | |
1922 | MEvent.time = ev.time; |
1902 | MEvent.time = ev.time; |
1923 | return; |
1903 | return; |
1924 | } |
1904 | } |
1925 | |
1905 | |
… | |
… | |
2088 | sel_scroll_ev.stop(); |
2068 | sel_scroll_ev.stop(); |
2089 | #endif |
2069 | #endif |
2090 | |
2070 | |
2091 | if (ev.window == vt) |
2071 | if (ev.window == vt) |
2092 | { |
2072 | { |
|
|
2073 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2074 | return; |
|
|
2075 | |
2093 | #if ISO_14755 |
2076 | #if ISO_14755 |
2094 | // 5.4 |
2077 | // 5.4 |
2095 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2078 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2096 | return; |
2079 | return; |
2097 | #endif |
2080 | #endif |
|
|
2081 | |
2098 | if (reportmode) |
2082 | if (reportmode) |
2099 | { |
2083 | { |
2100 | /* mouse report from vt window */ |
2084 | /* mouse report from vt window */ |
2101 | /* don't report release of wheel "buttons" */ |
2085 | /* don't report release of wheel "buttons" */ |
2102 | if (ev.button >= 4) |
2086 | if (ev.button >= 4) |
… | |
… | |
2126 | if (priv_modes & PrivMode_mouse_report |
2110 | if (priv_modes & PrivMode_mouse_report |
2127 | && bypass_keystate |
2111 | && bypass_keystate |
2128 | && ev.button == Button1 && MEvent.clicks <= 1) |
2112 | && ev.button == Button1 && MEvent.clicks <= 1) |
2129 | selection_extend (ev.x, ev.y, 0); |
2113 | selection_extend (ev.x, ev.y, 0); |
2130 | |
2114 | |
2131 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2132 | return; |
|
|
2133 | |
|
|
2134 | switch (ev.button) |
2115 | switch (ev.button) |
2135 | { |
2116 | { |
2136 | case Button1: |
2117 | case Button1: |
2137 | case Button3: |
2118 | case Button3: |
2138 | selection_make (ev.time); |
2119 | selection_make (ev.time); |
2139 | break; |
2120 | break; |
2140 | |
2121 | |
2141 | case Button2: |
2122 | case Button2: |
2142 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2123 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2143 | selection_request (ev.time, ev.state & ShiftMask ? Sel_Clipboard : Sel_Primary); |
2124 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2144 | break; |
2125 | break; |
2145 | |
2126 | |
2146 | #ifdef MOUSE_WHEEL |
2127 | #ifdef MOUSE_WHEEL |
2147 | case Button4: |
2128 | case Button4: |
2148 | case Button5: |
2129 | case Button5: |
… | |
… | |
2628 | am_transparent = 0; |
2609 | am_transparent = 0; |
2629 | /* XXX: also turn off Opt_transparent? */ |
2610 | /* XXX: also turn off Opt_transparent? */ |
2630 | } |
2611 | } |
2631 | else |
2612 | else |
2632 | { |
2613 | { |
2633 | #if WAIT_FOR_WM |
|
|
2634 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2635 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2636 | sleep (1); |
|
|
2637 | #endif |
|
|
2638 | for (n = 0; n < (unsigned int)i; n++) |
2614 | for (n = 0; n < (unsigned int)i; n++) |
2639 | { |
2615 | { |
2640 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2616 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2641 | XClearWindow (disp, parent[n]); |
2617 | XClearWindow (disp, parent[n]); |
2642 | } |
2618 | } |
… | |
… | |
3293 | ndef = get_byte_array_bit (csi_defaults, i); |
3269 | ndef = get_byte_array_bit (csi_defaults, i); |
3294 | for (p = 0; p < nargs; p++) |
3270 | for (p = 0; p < nargs; p++) |
3295 | if (arg[p] == -1) |
3271 | if (arg[p] == -1) |
3296 | arg[p] = ndef; |
3272 | arg[p] = ndef; |
3297 | |
3273 | |
3298 | #ifdef DEBUG_CMD |
|
|
3299 | fprintf (stderr, "CSI "); |
|
|
3300 | for (p = 0; p < nargs; p++) |
|
|
3301 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3302 | fprintf (stderr, "%c\n", ch); |
|
|
3303 | #endif |
|
|
3304 | |
|
|
3305 | /* |
3274 | /* |
3306 | * private mode handling |
3275 | * private mode handling |
3307 | */ |
3276 | */ |
3308 | if (priv) |
3277 | if (priv) |
3309 | { |
3278 | { |
3310 | switch (priv) |
3279 | switch (priv) |
3311 | { |
3280 | { |
3312 | case '>': |
3281 | case '>': |
3313 | if (ch == CSI_DA) /* secondary device attributes */ |
3282 | if (ch == CSI_DA) /* secondary device attributes */ |
|
|
3283 | { |
|
|
3284 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
|
|
3285 | // 'U' for rxvt-unicode <= 7.2, and Mm85 (e.g. 7385 for 7.3) for later versions. |
|
|
3286 | // |
|
|
3287 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
|
|
3288 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
|
|
3289 | // that we do not support xterm mouse reporting (should be 95 when we do). |
|
|
3290 | // |
3314 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3291 | tt_printf ("\033[>%c%c85;94;0c", VERSION[0], VERSION[1]); |
|
|
3292 | } |
3315 | break; |
3293 | break; |
3316 | case '?': |
3294 | case '?': |
3317 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3295 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3318 | process_terminal_mode (ch, priv, nargs, arg); |
3296 | process_terminal_mode (ch, priv, nargs, arg); |
3319 | break; |
3297 | break; |