… | |
… | |
316 | |
316 | |
317 | // the XOpenIM manpage lies about hardcoding the locale |
317 | // the XOpenIM manpage lies about hardcoding the locale |
318 | // at the point of XOpenIM, so temporarily switch locales |
318 | // at the point of XOpenIM, so temporarily switch locales |
319 | if (rs[Rs_imLocale]) |
319 | if (rs[Rs_imLocale]) |
320 | SET_LOCALE (rs[Rs_imLocale]); |
320 | SET_LOCALE (rs[Rs_imLocale]); |
|
|
321 | |
321 | // assume wchar_t == unicode or better |
322 | // assume wchar_t == unicode or better |
322 | len = XwcLookupString (Input_Context, &ev, wkbuf, |
323 | len = XwcLookupString (Input_Context, &ev, wkbuf, |
323 | KBUFSZ, &keysym, &status_return); |
324 | KBUFSZ, &keysym, &status_return); |
|
|
325 | |
324 | if (rs[Rs_imLocale]) |
326 | if (rs[Rs_imLocale]) |
325 | SET_LOCALE (locale); |
327 | SET_LOCALE (locale); |
326 | |
328 | |
327 | if (status_return == XLookupChars |
329 | if (status_return == XLookupChars |
328 | || status_return == XLookupBoth) |
330 | || status_return == XLookupBoth) |
… | |
… | |
1330 | button_release (ev.xbutton); |
1332 | button_release (ev.xbutton); |
1331 | break; |
1333 | break; |
1332 | |
1334 | |
1333 | case ClientMessage: |
1335 | case ClientMessage: |
1334 | if (ev.xclient.format == 32 |
1336 | if (ev.xclient.format == 32 |
|
|
1337 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1338 | { |
1335 | && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) |
1339 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1336 | destroy (); |
1340 | destroy (); |
|
|
1341 | #if ENABLE_EWMH |
|
|
1342 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
|
|
1343 | XSendEvent (disp, ev.xclient.window = display->root, |
|
|
1344 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
|
|
1345 | &ev); |
|
|
1346 | #endif |
|
|
1347 | } |
|
|
1348 | #if ENABLE_XEMBED |
|
|
1349 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1350 | { |
|
|
1351 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1352 | focus_in (); |
|
|
1353 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1354 | focus_out (); |
|
|
1355 | } |
|
|
1356 | #endif |
1337 | #ifdef OFFIX_DND |
1357 | #ifdef OFFIX_DND |
1338 | /* OffiX Dnd (drag 'n' drop) protocol */ |
1358 | /* OffiX Dnd (drag 'n' drop) protocol */ |
1339 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
1359 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
1340 | && (ev.xclient.data.l[0] == DndFile |
1360 | && (ev.xclient.data.l[0] == DndFile |
1341 | || ev.xclient.data.l[0] == DndDir |
1361 | || ev.xclient.data.l[0] == DndDir |
1342 | || ev.xclient.data.l[0] == DndLink)) |
1362 | || ev.xclient.data.l[0] == DndLink)) |
1343 | { |
1363 | { |
1344 | /* Get Dnd data */ |
1364 | /* Get Dnd data */ |
1345 | Atom ActualType; |
1365 | Atom ActualType; |
1346 | int ActualFormat; |
1366 | int ActualFormat; |
1347 | unsigned char *data; |
1367 | unsigned char *data; |
… | |
… | |
1390 | break; |
1410 | break; |
1391 | } |
1411 | } |
1392 | break; |
1412 | break; |
1393 | |
1413 | |
1394 | case FocusIn: |
1414 | case FocusIn: |
1395 | if (!TermWin.focus) |
1415 | focus_in (); |
1396 | { |
|
|
1397 | TermWin.focus = 1; |
|
|
1398 | want_refresh = 1; |
|
|
1399 | #ifdef USE_XIM |
|
|
1400 | if (Input_Context != NULL) |
|
|
1401 | { |
|
|
1402 | IMSetStatusPosition (); |
|
|
1403 | XSetICFocus (Input_Context); |
|
|
1404 | } |
|
|
1405 | #endif |
|
|
1406 | #ifdef CURSOR_BLINK |
|
|
1407 | if (options & Opt_cursorBlink) |
|
|
1408 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1409 | #endif |
|
|
1410 | #ifdef OFF_FOCUS_FADING |
|
|
1411 | if (rs[Rs_fade]) |
|
|
1412 | { |
|
|
1413 | pix_colors = pix_colors_focused; |
|
|
1414 | scr_recolour (); |
|
|
1415 | } |
|
|
1416 | #endif |
|
|
1417 | |
|
|
1418 | } |
|
|
1419 | break; |
1416 | break; |
1420 | |
1417 | |
1421 | case FocusOut: |
1418 | case FocusOut: |
1422 | if (TermWin.focus) |
1419 | focus_out (); |
1423 | { |
|
|
1424 | TermWin.focus = 0; |
|
|
1425 | want_refresh = 1; |
|
|
1426 | |
|
|
1427 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1428 | iso14755buf = 0; |
|
|
1429 | #endif |
|
|
1430 | #if ENABLE_OVERLAY |
|
|
1431 | scr_overlay_off (); |
|
|
1432 | #endif |
|
|
1433 | #ifdef USE_XIM |
|
|
1434 | if (Input_Context != NULL) |
|
|
1435 | XUnsetICFocus (Input_Context); |
|
|
1436 | #endif |
|
|
1437 | #ifdef CURSOR_BLINK |
|
|
1438 | if (options & Opt_cursorBlink) |
|
|
1439 | cursor_blink_ev.stop (); |
|
|
1440 | hidden_cursor = 0; |
|
|
1441 | #endif |
|
|
1442 | #ifdef OFF_FOCUS_FADING |
|
|
1443 | if (rs[Rs_fade]) |
|
|
1444 | { |
|
|
1445 | pix_colors = pix_colors_unfocused; |
|
|
1446 | scr_recolour (); |
|
|
1447 | } |
|
|
1448 | #endif |
|
|
1449 | } |
|
|
1450 | break; |
1420 | break; |
1451 | |
1421 | |
1452 | case ConfigureNotify: |
1422 | case ConfigureNotify: |
1453 | if (ev.xconfigure.window == TermWin.parent[0]) |
1423 | if (ev.xconfigure.window == TermWin.parent[0]) |
1454 | { |
1424 | { |
… | |
… | |
1668 | scr_refresh (refresh_type); |
1638 | scr_refresh (refresh_type); |
1669 | refresh_limit = 0; |
1639 | refresh_limit = 0; |
1670 | scrollbar_show (1); |
1640 | scrollbar_show (1); |
1671 | } |
1641 | } |
1672 | break; |
1642 | break; |
|
|
1643 | } |
|
|
1644 | } |
|
|
1645 | |
|
|
1646 | void |
|
|
1647 | rxvt_term::focus_in () |
|
|
1648 | { |
|
|
1649 | if (!TermWin.focus) |
|
|
1650 | { |
|
|
1651 | TermWin.focus = 1; |
|
|
1652 | want_refresh = 1; |
|
|
1653 | #ifdef USE_XIM |
|
|
1654 | if (Input_Context != NULL) |
|
|
1655 | { |
|
|
1656 | IMSetStatusPosition (); |
|
|
1657 | XSetICFocus (Input_Context); |
|
|
1658 | } |
|
|
1659 | #endif |
|
|
1660 | #ifdef CURSOR_BLINK |
|
|
1661 | if (options & Opt_cursorBlink) |
|
|
1662 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1663 | #endif |
|
|
1664 | #ifdef OFF_FOCUS_FADING |
|
|
1665 | if (rs[Rs_fade]) |
|
|
1666 | { |
|
|
1667 | pix_colors = pix_colors_focused; |
|
|
1668 | scr_recolour (); |
|
|
1669 | } |
|
|
1670 | #endif |
|
|
1671 | } |
|
|
1672 | } |
|
|
1673 | |
|
|
1674 | void |
|
|
1675 | rxvt_term::focus_out () |
|
|
1676 | { |
|
|
1677 | if (TermWin.focus) |
|
|
1678 | { |
|
|
1679 | TermWin.focus = 0; |
|
|
1680 | want_refresh = 1; |
|
|
1681 | |
|
|
1682 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1683 | iso14755buf = 0; |
|
|
1684 | #endif |
|
|
1685 | #if ENABLE_OVERLAY |
|
|
1686 | scr_overlay_off (); |
|
|
1687 | #endif |
|
|
1688 | #ifdef USE_XIM |
|
|
1689 | if (Input_Context != NULL) |
|
|
1690 | XUnsetICFocus (Input_Context); |
|
|
1691 | #endif |
|
|
1692 | #ifdef CURSOR_BLINK |
|
|
1693 | if (options & Opt_cursorBlink) |
|
|
1694 | cursor_blink_ev.stop (); |
|
|
1695 | hidden_cursor = 0; |
|
|
1696 | #endif |
|
|
1697 | #ifdef OFF_FOCUS_FADING |
|
|
1698 | if (rs[Rs_fade]) |
|
|
1699 | { |
|
|
1700 | pix_colors = pix_colors_unfocused; |
|
|
1701 | scr_recolour (); |
|
|
1702 | } |
|
|
1703 | #endif |
1673 | } |
1704 | } |
1674 | } |
1705 | } |
1675 | |
1706 | |
1676 | #if TRANSPARENT |
1707 | #if TRANSPARENT |
1677 | void |
1708 | void |
… | |
… | |
2602 | // some window managers resize the window early, and these programs |
2633 | // some window managers resize the window early, and these programs |
2603 | // then sometimes get the size wrong. |
2634 | // then sometimes get the size wrong. |
2604 | // unfortunately other programs are even more buggy and dislike |
2635 | // unfortunately other programs are even more buggy and dislike |
2605 | // being sent SIGWINCH, so only do it when we were in fact being |
2636 | // being sent SIGWINCH, so only do it when we were in fact being |
2606 | // resized. |
2637 | // resized. |
2607 | if (seen_resize) |
2638 | if (seen_resize && cmd_pid) |
2608 | kill (-cmd_pid, SIGWINCH); |
2639 | kill (-cmd_pid, SIGWINCH); |
2609 | } |
2640 | } |
2610 | |
2641 | |
2611 | /* Read a text string from the input buffer */ |
2642 | /* Read a text string from the input buffer */ |
2612 | unicode_t buf[UBUFSIZ]; |
2643 | unicode_t buf[UBUFSIZ]; |
… | |
… | |
3559 | else if (ch < 0x20) |
3590 | else if (ch < 0x20) |
3560 | return NULL; /* other control character - exit */ |
3591 | return NULL; /* other control character - exit */ |
3561 | |
3592 | |
3562 | seen_esc = false; |
3593 | seen_esc = false; |
3563 | |
3594 | |
3564 | if (n >= sizeof (string) - 1) |
3595 | if (n >= STRING_MAX - 1) |
3565 | // stop at some sane length |
3596 | // stop at some sane length |
3566 | return NULL; |
3597 | return NULL; |
3567 | |
3598 | |
3568 | if (ch == C0_SYN) |
3599 | if (ch == C0_SYN) |
3569 | string[n++] = cmd_get8 (); |
3600 | string[n++] = cmd_get8 (); |
… | |
… | |
3637 | set_window_color (color, str); |
3668 | set_window_color (color, str); |
3638 | } |
3669 | } |
3639 | |
3670 | |
3640 | /* |
3671 | /* |
3641 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3672 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3642 | * 0 = change iconName/title |
|
|
3643 | * 1 = change iconName |
|
|
3644 | * 2 = change title |
|
|
3645 | * 4 = change color |
|
|
3646 | * 10 = change fg color |
|
|
3647 | * 11 = change bg color |
|
|
3648 | * 12 = change text color |
|
|
3649 | * 13 = change mouse foreground color |
|
|
3650 | * 17 = change highlight character colour |
|
|
3651 | * 18 = change bold character color |
|
|
3652 | * 19 = change underlined character color |
|
|
3653 | * 46 = change logfile (not implemented) |
|
|
3654 | * 50 = change font |
|
|
3655 | * |
|
|
3656 | * rxvt extensions: |
|
|
3657 | * 20 = bg pixmap |
|
|
3658 | * 39 = change default fg color |
|
|
3659 | * 49 = change default bg color |
|
|
3660 | * 55 = dump scrollback buffer and all of screen |
|
|
3661 | * 701 = change locale |
|
|
3662 | * 702 = find font |
|
|
3663 | * 703 = menu |
|
|
3664 | */ |
3673 | */ |
3665 | void |
3674 | void |
3666 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3675 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3667 | { |
3676 | { |
3668 | int changed = 0; |
3677 | int changed = 0; |
… | |
… | |
3767 | break; |
3776 | break; |
3768 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3777 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3769 | case XTerm_Color_BD: |
3778 | case XTerm_Color_BD: |
3770 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3779 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3771 | break; |
3780 | break; |
3772 | case XTerm_Color_IT: |
|
|
3773 | process_color_seq (XTerm_Color_IT, Color_IT, str, resp); |
|
|
3774 | break; |
|
|
3775 | case XTerm_Color_UL: |
3781 | case XTerm_Color_UL: |
3776 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3782 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3777 | break; |
3783 | break; |
3778 | case XTerm_Color_RV: |
3784 | case XTerm_Color_RV: |
3779 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3785 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3780 | break; |
3786 | break; |
|
|
3787 | case URxvt_Color_IT: |
|
|
3788 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
|
|
3789 | break; |
3781 | #endif |
3790 | #endif |
3782 | #if TRANSPARENT && TINTING |
3791 | #if TRANSPARENT && TINTING |
3783 | case XTerm_Color_tint: |
3792 | case URxvt_Color_tint: |
3784 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3793 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3785 | check_our_parents (); |
3794 | check_our_parents (); |
3786 | if (am_transparent) |
3795 | if (am_transparent) |
3787 | want_full_refresh = want_refresh = 1; |
3796 | want_full_refresh = want_refresh = 1; |
3788 | break; |
3797 | break; |
3789 | #endif |
3798 | #endif |
… | |
… | |
3823 | |
3832 | |
3824 | case XTerm_logfile: |
3833 | case XTerm_logfile: |
3825 | // TODO, when secure mode? |
3834 | // TODO, when secure mode? |
3826 | break; |
3835 | break; |
3827 | |
3836 | |
|
|
3837 | #ifdef MENUBAR |
|
|
3838 | case URxvt_Menu: |
|
|
3839 | if (options & Opt_insecure) |
|
|
3840 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3841 | break; |
|
|
3842 | #endif |
|
|
3843 | #if 0 |
|
|
3844 | case XTerm_dumpscreen: /* no error notices */ |
|
|
3845 | { |
|
|
3846 | int fd; |
|
|
3847 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
|
|
3848 | { |
|
|
3849 | scr_dump (fd); |
|
|
3850 | close (fd); |
|
|
3851 | } |
|
|
3852 | } |
|
|
3853 | break; |
|
|
3854 | #endif |
3828 | case XTerm_font: |
3855 | case XTerm_font: |
3829 | op = URxvt_font; |
3856 | op = URxvt_font; |
3830 | case URxvt_font: |
3857 | case URxvt_font: |
3831 | #if ENABLE_STYLES |
3858 | #if ENABLE_STYLES |
3832 | case URxvt_boldFont: |
3859 | case URxvt_boldFont: |
… | |
… | |
3847 | set_fonts (); |
3874 | set_fonts (); |
3848 | } |
3875 | } |
3849 | break; |
3876 | break; |
3850 | |
3877 | |
3851 | #if ENABLE_FRILLS |
3878 | #if ENABLE_FRILLS |
3852 | case XTerm_locale: |
3879 | case URxvt_locale: |
3853 | if (query) |
3880 | if (query) |
3854 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3881 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); |
3855 | else |
3882 | else |
3856 | { |
3883 | { |
3857 | set_locale (str); |
3884 | set_locale (str); |
3858 | pty.set_utf8_mode (enc_utf8); |
3885 | pty.set_utf8_mode (enc_utf8); |
3859 | # ifdef USE_XIM |
|
|
3860 | im_cb (); |
3886 | init_xlocale (); |
3861 | # endif |
|
|
3862 | } |
3887 | } |
3863 | break; |
3888 | break; |
3864 | #endif |
|
|
3865 | |
3889 | |
3866 | #ifdef MENUBAR |
3890 | case URxvt_view_up: |
3867 | case XTerm_Menu: |
3891 | case URxvt_view_down: |
3868 | if (options & Opt_insecure) |
3892 | int lines = atoi (str); |
3869 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3893 | |
3870 | break; |
3894 | if (lines) |
3871 | #endif |
3895 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3872 | #if 0 |
|
|
3873 | case XTerm_dumpscreen: /* no error notices */ |
|
|
3874 | { |
3896 | else |
3875 | int fd; |
|
|
3876 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
|
|
3877 | { |
3897 | { |
3878 | scr_dump (fd); |
3898 | scr_erase_savelines (); |
3879 | close (fd); |
|
|
3880 | } |
3899 | } |
3881 | } |
3900 | |
3882 | break; |
3901 | break; |
3883 | #endif |
3902 | #endif |
3884 | } |
3903 | } |
3885 | } |
3904 | } |
3886 | /*----------------------------------------------------------------------*/ |
3905 | /*----------------------------------------------------------------------*/ |