… | |
… | |
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 |
… | |
… | |
461 | { |
458 | { |
462 | switch (keysym) |
459 | switch (keysym) |
463 | { |
460 | { |
464 | /* normal XTerm key bindings */ |
461 | /* normal XTerm key bindings */ |
465 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
462 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
466 | selection_request (ev.time, Sel_Primary); |
463 | selection_request (ev.time); |
467 | return; |
464 | return; |
468 | #if TODO |
465 | #if TODO |
469 | /* rxvt extras */ |
466 | /* rxvt extras */ |
470 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
467 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
471 | change_font (FONT_UP); |
468 | change_font (FONT_UP); |
… | |
… | |
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 | { |
… | |
… | |
1402 | button_release (ev.xbutton); |
1379 | button_release (ev.xbutton); |
1403 | break; |
1380 | break; |
1404 | |
1381 | |
1405 | case ClientMessage: |
1382 | case ClientMessage: |
1406 | if (ev.xclient.format == 32 |
1383 | if (ev.xclient.format == 32 |
1407 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
1384 | && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) |
1408 | { |
1385 | { |
|
|
1386 | if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1387 | { |
|
|
1388 | if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) |
|
|
1389 | { |
1409 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1390 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
|
|
1391 | { |
|
|
1392 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1410 | destroy (); |
1393 | destroy (); |
|
|
1394 | } |
1411 | #if ENABLE_EWMH |
1395 | #if ENABLE_EWMH |
1412 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1396 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1413 | XSendEvent (disp, ev.xclient.window = display->root, |
1397 | XSendEvent (disp, ev.xclient.window = display->root, |
1414 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1398 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1415 | &ev); |
1399 | &ev); |
|
|
1400 | #endif |
|
|
1401 | } |
|
|
1402 | } |
|
|
1403 | #if ENABLE_XEMBED |
|
|
1404 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1405 | { |
|
|
1406 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1407 | focus_in (); |
|
|
1408 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1409 | focus_out (); |
|
|
1410 | } |
1416 | #endif |
1411 | #endif |
1417 | } |
1412 | } |
1418 | #if ENABLE_XEMBED |
|
|
1419 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1420 | { |
|
|
1421 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1422 | focus_in (); |
|
|
1423 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1424 | focus_out (); |
|
|
1425 | } |
|
|
1426 | #endif |
|
|
1427 | #ifdef OFFIX_DND |
|
|
1428 | /* OffiX Dnd (drag 'n' drop) protocol */ |
|
|
1429 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
|
|
1430 | && (ev.xclient.data.l[0] == DndFile |
|
|
1431 | || ev.xclient.data.l[0] == DndDir |
|
|
1432 | || ev.xclient.data.l[0] == DndLink)) |
|
|
1433 | { |
|
|
1434 | /* Get Dnd data */ |
|
|
1435 | Atom ActualType; |
|
|
1436 | int ActualFormat; |
|
|
1437 | unsigned char *data; |
|
|
1438 | unsigned long Size, RemainingBytes; |
|
|
1439 | |
|
|
1440 | XGetWindowProperty (disp, display->root, |
|
|
1441 | xa[XA_DNDSELECTION], |
|
|
1442 | 0L, 1000000L, |
|
|
1443 | False, AnyPropertyType, |
|
|
1444 | &ActualType, &ActualFormat, |
|
|
1445 | &Size, &RemainingBytes, |
|
|
1446 | &data); |
|
|
1447 | set_string_property (XA_CUT_BUFFER0, data); |
|
|
1448 | XFree (data); |
|
|
1449 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
|
|
1450 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
|
|
1451 | } |
|
|
1452 | #endif /* OFFIX_DND */ |
|
|
1453 | break; |
1413 | break; |
1454 | |
1414 | |
1455 | case MappingNotify: |
1415 | case MappingNotify: |
1456 | XRefreshKeyboardMapping (&ev.xmapping); |
1416 | XRefreshKeyboardMapping (&ev.xmapping); |
1457 | break; |
1417 | break; |
… | |
… | |
1509 | #endif |
1469 | #endif |
1510 | } |
1470 | } |
1511 | break; |
1471 | break; |
1512 | |
1472 | |
1513 | case PropertyNotify: |
1473 | case PropertyNotify: |
|
|
1474 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1514 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1475 | if (ev.xproperty.atom == xa[XA_VT_SELECTION] |
1515 | && ev.xproperty.state == PropertyNewValue) |
1476 | && ev.xproperty.state == PropertyNewValue) |
1516 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1477 | selection_property (ev.xproperty.window, ev.xproperty.atom); |
1517 | |
1478 | |
1518 | break; |
1479 | break; |
1519 | |
1480 | |
1520 | case SelectionClear: |
1481 | case SelectionClear: |
1521 | selection_clear (); |
1482 | selection_clear (); |
… | |
… | |
1839 | /* |
1800 | /* |
1840 | * VT window processing of button press |
1801 | * VT window processing of button press |
1841 | */ |
1802 | */ |
1842 | if (ev.window == vt) |
1803 | if (ev.window == vt) |
1843 | { |
1804 | { |
|
|
1805 | if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1806 | return; |
|
|
1807 | |
1844 | #if ISO_14755 |
1808 | #if ISO_14755 |
1845 | // 5.4 |
1809 | // 5.4 |
1846 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1810 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
1847 | { |
1811 | { |
1848 | iso14755_54 (ev.x, ev.y); |
1812 | iso14755_54 (ev.x, ev.y); |
… | |
… | |
1890 | else |
1854 | else |
1891 | { |
1855 | { |
1892 | if (ev.button != MEvent.button) |
1856 | if (ev.button != MEvent.button) |
1893 | MEvent.clicks = 0; |
1857 | MEvent.clicks = 0; |
1894 | |
1858 | |
1895 | if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) |
|
|
1896 | switch (ev.button) |
1859 | switch (ev.button) |
1897 | { |
1860 | { |
1898 | case Button1: |
1861 | case Button1: |
1899 | /* allow meta + click to select rectangular areas */ |
1862 | /* allow meta + click to select rectangular areas */ |
1900 | /* should be done in screen.C */ |
1863 | /* should be done in screen.C */ |
1901 | #if ENABLE_FRILLS |
1864 | #if ENABLE_FRILLS |
1902 | selection.rect = !!(ev.state & ModMetaMask); |
1865 | selection.rect = !!(ev.state & ModMetaMask); |
1903 | #else |
1866 | #else |
1904 | selection.rect = false; |
1867 | selection.rect = false; |
1905 | #endif |
1868 | #endif |
1906 | |
1869 | |
1907 | /* allow shift+left click to extend selection */ |
1870 | /* allow shift+left click to extend selection */ |
1908 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1871 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1909 | { |
1872 | { |
1910 | if (MEvent.button == Button1 && clickintime) |
1873 | if (MEvent.button == Button1 && clickintime) |
1911 | selection_rotate (ev.x, ev.y); |
1874 | selection_rotate (ev.x, ev.y); |
1912 | else |
1875 | else |
1913 | selection_extend (ev.x, ev.y, 1); |
1876 | selection_extend (ev.x, ev.y, 1); |
1914 | } |
1877 | } |
1915 | else |
1878 | else |
1916 | { |
1879 | { |
1917 | if (MEvent.button == Button1 && clickintime) |
1880 | if (MEvent.button == Button1 && clickintime) |
1918 | MEvent.clicks++; |
1881 | MEvent.clicks++; |
1919 | else |
1882 | else |
1920 | MEvent.clicks = 1; |
1883 | MEvent.clicks = 1; |
1921 | |
1884 | |
1922 | selection_click (MEvent.clicks, ev.x, ev.y); |
1885 | selection_click (MEvent.clicks, ev.x, ev.y); |
1923 | } |
1886 | } |
1924 | |
1887 | |
1925 | MEvent.button = Button1; |
1888 | MEvent.button = Button1; |
1926 | break; |
1889 | break; |
1927 | |
1890 | |
1928 | case Button3: |
1891 | case Button3: |
1929 | if (MEvent.button == Button3 && clickintime) |
1892 | if (MEvent.button == Button3 && clickintime) |
1930 | selection_rotate (ev.x, ev.y); |
1893 | selection_rotate (ev.x, ev.y); |
1931 | else |
1894 | else |
1932 | selection_extend (ev.x, ev.y, 1); |
1895 | selection_extend (ev.x, ev.y, 1); |
1933 | |
1896 | |
1934 | MEvent.button = Button3; |
1897 | MEvent.button = Button3; |
1935 | break; |
1898 | break; |
1936 | } |
1899 | } |
1937 | } |
1900 | } |
1938 | |
1901 | |
1939 | MEvent.time = ev.time; |
1902 | MEvent.time = ev.time; |
1940 | return; |
1903 | return; |
1941 | } |
1904 | } |
1942 | |
1905 | |
… | |
… | |
2105 | sel_scroll_ev.stop(); |
2068 | sel_scroll_ev.stop(); |
2106 | #endif |
2069 | #endif |
2107 | |
2070 | |
2108 | if (ev.window == vt) |
2071 | if (ev.window == vt) |
2109 | { |
2072 | { |
|
|
2073 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2074 | return; |
|
|
2075 | |
2110 | #if ISO_14755 |
2076 | #if ISO_14755 |
2111 | // 5.4 |
2077 | // 5.4 |
2112 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2078 | if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) |
2113 | return; |
2079 | return; |
2114 | #endif |
2080 | #endif |
|
|
2081 | |
2115 | if (reportmode) |
2082 | if (reportmode) |
2116 | { |
2083 | { |
2117 | /* mouse report from vt window */ |
2084 | /* mouse report from vt window */ |
2118 | /* don't report release of wheel "buttons" */ |
2085 | /* don't report release of wheel "buttons" */ |
2119 | if (ev.button >= 4) |
2086 | if (ev.button >= 4) |
… | |
… | |
2143 | if (priv_modes & PrivMode_mouse_report |
2110 | if (priv_modes & PrivMode_mouse_report |
2144 | && bypass_keystate |
2111 | && bypass_keystate |
2145 | && ev.button == Button1 && MEvent.clicks <= 1) |
2112 | && ev.button == Button1 && MEvent.clicks <= 1) |
2146 | selection_extend (ev.x, ev.y, 0); |
2113 | selection_extend (ev.x, ev.y, 0); |
2147 | |
2114 | |
2148 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
|
|
2149 | return; |
|
|
2150 | |
|
|
2151 | switch (ev.button) |
2115 | switch (ev.button) |
2152 | { |
2116 | { |
2153 | case Button1: |
2117 | case Button1: |
2154 | case Button3: |
2118 | case Button3: |
2155 | selection_make (ev.time); |
2119 | selection_make (ev.time); |
2156 | break; |
2120 | break; |
2157 | |
2121 | |
2158 | case Button2: |
2122 | case Button2: |
2159 | if (IN_RANGE_EXC (ev.x, 0, width) |
2123 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2160 | && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2124 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2161 | { |
|
|
2162 | if (ev.state & ShiftMask) |
|
|
2163 | selection_request (ev.time, Sel_Clipboard); |
|
|
2164 | else |
|
|
2165 | selection_request (ev.time, Sel_Primary); |
|
|
2166 | } |
|
|
2167 | break; |
2125 | break; |
2168 | |
2126 | |
2169 | #ifdef MOUSE_WHEEL |
2127 | #ifdef MOUSE_WHEEL |
2170 | case Button4: |
2128 | case Button4: |
2171 | case Button5: |
2129 | case Button5: |
… | |
… | |
2651 | am_transparent = 0; |
2609 | am_transparent = 0; |
2652 | /* XXX: also turn off Opt_transparent? */ |
2610 | /* XXX: also turn off Opt_transparent? */ |
2653 | } |
2611 | } |
2654 | else |
2612 | else |
2655 | { |
2613 | { |
2656 | #if WAIT_FOR_WM |
|
|
2657 | /* wait (an arbitrary period) for the WM to do its thing |
|
|
2658 | * needed for fvwm2.2.2 (and before?) */ |
|
|
2659 | sleep (1); |
|
|
2660 | #endif |
|
|
2661 | for (n = 0; n < (unsigned int)i; n++) |
2614 | for (n = 0; n < (unsigned int)i; n++) |
2662 | { |
2615 | { |
2663 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2616 | XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); |
2664 | XClearWindow (disp, parent[n]); |
2617 | XClearWindow (disp, parent[n]); |
2665 | } |
2618 | } |
… | |
… | |
3316 | ndef = get_byte_array_bit (csi_defaults, i); |
3269 | ndef = get_byte_array_bit (csi_defaults, i); |
3317 | for (p = 0; p < nargs; p++) |
3270 | for (p = 0; p < nargs; p++) |
3318 | if (arg[p] == -1) |
3271 | if (arg[p] == -1) |
3319 | arg[p] = ndef; |
3272 | arg[p] = ndef; |
3320 | |
3273 | |
3321 | #ifdef DEBUG_CMD |
|
|
3322 | fprintf (stderr, "CSI "); |
|
|
3323 | for (p = 0; p < nargs; p++) |
|
|
3324 | fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); |
|
|
3325 | fprintf (stderr, "%c\n", ch); |
|
|
3326 | #endif |
|
|
3327 | |
|
|
3328 | /* |
3274 | /* |
3329 | * private mode handling |
3275 | * private mode handling |
3330 | */ |
3276 | */ |
3331 | if (priv) |
3277 | if (priv) |
3332 | { |
3278 | { |
3333 | switch (priv) |
3279 | switch (priv) |
3334 | { |
3280 | { |
3335 | case '>': |
3281 | case '>': |
3336 | 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 | // |
3337 | 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 | } |
3338 | break; |
3293 | break; |
3339 | case '?': |
3294 | case '?': |
3340 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3295 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3341 | process_terminal_mode (ch, priv, nargs, arg); |
3296 | process_terminal_mode (ch, priv, nargs, arg); |
3342 | break; |
3297 | break; |