… | |
… | |
35 | #include "keyboard.h" |
35 | #include "keyboard.h" |
36 | #include "rxvtperl.h" |
36 | #include "rxvtperl.h" |
37 | |
37 | |
38 | #include <limits> |
38 | #include <limits> |
39 | |
39 | |
|
|
40 | #include <cassert> |
40 | #include <csignal> |
41 | #include <csignal> |
41 | #include <cstring> |
42 | #include <cstring> |
42 | |
43 | |
43 | #include <termios.h> |
44 | #include <termios.h> |
44 | |
45 | |
… | |
… | |
101 | { |
102 | { |
102 | if (cc->c2 == c2) return c1; |
103 | if (cc->c2 == c2) return c1; |
103 | cc = (*this)[cc->c1]; |
104 | cc = (*this)[cc->c1]; |
104 | } |
105 | } |
105 | |
106 | |
106 | // check to see wether this combination already exists otherwise |
107 | // check to see whether this combination already exists otherwise |
107 | for (cc = v.end (); cc-- > v.begin (); ) |
108 | for (cc = v.end (); cc-- > v.begin (); ) |
108 | { |
109 | { |
109 | if (cc->c1 == c1 && cc->c2 == c2) |
110 | if (cc->c1 == c1 && cc->c2 == c2) |
110 | return COMPOSE_LO + (cc - v.begin ()); |
111 | return COMPOSE_LO + (cc - v.begin ()); |
111 | } |
112 | } |
… | |
… | |
382 | char mesg[BUFSIZ]; |
383 | char mesg[BUFSIZ]; |
383 | char number[32]; |
384 | char number[32]; |
384 | char *mtype = "XlibMessage"; |
385 | char *mtype = "XlibMessage"; |
385 | XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); |
386 | XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); |
386 | XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); |
387 | XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); |
387 | rxvt_warn ("An X Error occured, trying to continue after report.\n"); |
388 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
388 | rxvt_warn ("%s: %s\n", mesg, buffer); |
389 | rxvt_warn ("%s: %s\n", mesg, buffer); |
389 | XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
390 | XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
390 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
391 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
391 | sprintf(number, "%d", event->request_code); |
392 | sprintf(number, "%d", event->request_code); |
392 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
393 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
393 | rxvt_warn ("(which is %s)\n", buffer); |
394 | rxvt_warn ("(which is %s)\n", buffer); |
394 | if (event->request_code >= 128) { |
395 | if (event->request_code >= 128) { |
395 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
396 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
396 | mesg, BUFSIZ); |
397 | mesg, BUFSIZ); |
397 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
398 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
398 | } |
399 | } |
399 | if ((event->error_code == BadWindow) || |
400 | if ((event->error_code == BadWindow) || |
400 | (event->error_code == BadPixmap) || |
401 | (event->error_code == BadPixmap) || |
401 | (event->error_code == BadCursor) || |
402 | (event->error_code == BadCursor) || |
402 | (event->error_code == BadFont) || |
403 | (event->error_code == BadFont) || |
403 | (event->error_code == BadDrawable) || |
404 | (event->error_code == BadDrawable) || |
404 | (event->error_code == BadColor) || |
405 | (event->error_code == BadColor) || |
405 | (event->error_code == BadGC) || |
406 | (event->error_code == BadGC) || |
406 | (event->error_code == BadIDChoice) || |
407 | (event->error_code == BadIDChoice) || |
407 | (event->error_code == BadValue) || |
408 | (event->error_code == BadValue) || |
408 | (event->error_code == BadAtom)) { |
409 | (event->error_code == BadAtom)) { |
409 | if (event->error_code == BadValue) |
410 | if (event->error_code == BadValue) |
410 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
411 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
411 | mesg, BUFSIZ); |
412 | mesg, BUFSIZ); |
412 | else if (event->error_code == BadAtom) |
413 | else if (event->error_code == BadAtom) |
413 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
414 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
414 | mesg, BUFSIZ); |
415 | mesg, BUFSIZ); |
415 | else |
416 | else |
416 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
417 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
417 | mesg, BUFSIZ); |
418 | mesg, BUFSIZ); |
418 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
419 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
419 | } |
420 | } |
420 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
421 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
421 | mesg, BUFSIZ); |
422 | mesg, BUFSIZ); |
422 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
423 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
423 | } |
424 | } |
424 | #endif |
425 | #endif |
425 | |
426 | |
426 | int |
427 | int |
… | |
… | |
478 | char **rxvt_environ; // startup environment |
479 | char **rxvt_environ; // startup environment |
479 | |
480 | |
480 | void |
481 | void |
481 | rxvt_init () |
482 | rxvt_init () |
482 | { |
483 | { |
|
|
484 | assert (("fontMask must not overlap other RS masks", |
|
|
485 | 0 == (RS_fontMask & (RS_Sel | RS_baseattrMask | RS_customMask | RS_bgMask | RS_fgMask)))); |
|
|
486 | |
483 | ptytty::init (); |
487 | ptytty::init (); |
484 | |
488 | |
485 | if (!ev_default_loop (0)) |
489 | if (!ev_default_loop (0)) |
486 | rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); |
490 | rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); |
487 | |
491 | |
… | |
… | |
490 | signal (SIGHUP, SIG_IGN); |
494 | signal (SIGHUP, SIG_IGN); |
491 | signal (SIGPIPE, SIG_IGN); |
495 | signal (SIGPIPE, SIG_IGN); |
492 | |
496 | |
493 | sig_handlers.sw_term.start (SIGTERM); ev_unref (); |
497 | sig_handlers.sw_term.start (SIGTERM); ev_unref (); |
494 | sig_handlers.sw_int.start (SIGINT); ev_unref (); |
498 | sig_handlers.sw_int.start (SIGINT); ev_unref (); |
495 | |
|
|
496 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
497 | /* signal (SIGURG, SIG_DFL); */ |
|
|
498 | |
499 | |
499 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
500 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
500 | // TODO: handle this with exceptions and tolerate the memory loss |
501 | // TODO: handle this with exceptions and tolerate the memory loss |
501 | XSetIOErrorHandler (rxvt_xioerror_handler); |
502 | XSetIOErrorHandler (rxvt_xioerror_handler); |
502 | |
503 | |
… | |
… | |
688 | #endif |
689 | #endif |
689 | |
690 | |
690 | delete fontset[0]; |
691 | delete fontset[0]; |
691 | fontset[0] = fs; |
692 | fontset[0] = fs; |
692 | |
693 | |
693 | prop = (*fs)[1]->properties (); |
694 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
694 | prop.height += lineSpace; |
695 | prop.height += lineSpace; |
695 | prop.width += letterSpace; |
696 | prop.width += letterSpace; |
696 | |
697 | |
697 | fs->set_prop (prop, false); |
698 | fs->set_prop (prop, false); |
698 | |
699 | |
… | |
… | |
750 | prop, XA_STRING, 8, PropModeReplace, |
751 | prop, XA_STRING, 8, PropModeReplace, |
751 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
752 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
752 | } |
753 | } |
753 | |
754 | |
754 | void |
755 | void |
|
|
756 | rxvt_term::set_mbstring_property (Atom prop, const char *str, int len) |
|
|
757 | { |
|
|
758 | XTextProperty ct; |
|
|
759 | |
|
|
760 | if (XmbTextListToTextProperty (dpy, (char **)&str, 1, XStdICCTextStyle, &ct) >= 0) |
|
|
761 | { |
|
|
762 | XSetTextProperty (dpy, parent[0], &ct, prop); |
|
|
763 | XFree (ct.value); |
|
|
764 | } |
|
|
765 | } |
|
|
766 | |
|
|
767 | void |
755 | rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
768 | rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
756 | { |
769 | { |
757 | wchar_t *ws = rxvt_mbstowcs (str, len); |
770 | wchar_t *ws = rxvt_mbstowcs (str, len); |
758 | char *s = rxvt_wcstoutf8 (ws); |
771 | char *s = rxvt_wcstoutf8 (ws); |
759 | |
772 | |
… | |
… | |
769 | /*----------------------------------------------------------------------*/ |
782 | /*----------------------------------------------------------------------*/ |
770 | /* xterm sequences - title, iconName, color (exptl) */ |
783 | /* xterm sequences - title, iconName, color (exptl) */ |
771 | void |
784 | void |
772 | rxvt_term::set_title (const char *str) |
785 | rxvt_term::set_title (const char *str) |
773 | { |
786 | { |
774 | set_string_property (XA_WM_NAME, str); |
787 | set_mbstring_property (XA_WM_NAME, str); |
775 | #if ENABLE_EWMH |
788 | #if ENABLE_EWMH |
776 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
789 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
777 | #endif |
790 | #endif |
778 | } |
791 | } |
779 | |
792 | |
780 | void |
793 | void |
781 | rxvt_term::set_icon_name (const char *str) |
794 | rxvt_term::set_icon_name (const char *str) |
782 | { |
795 | { |
783 | set_string_property (XA_WM_ICON_NAME, str); |
796 | set_mbstring_property (XA_WM_ICON_NAME, str); |
784 | #if ENABLE_EWMH |
797 | #if ENABLE_EWMH |
785 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
798 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
786 | #endif |
799 | #endif |
787 | } |
800 | } |
788 | |
801 | |
… | |
… | |
995 | } |
1008 | } |
996 | |
1009 | |
997 | if (fix_screen || old_height == 0) |
1010 | if (fix_screen || old_height == 0) |
998 | scr_reset (); |
1011 | scr_reset (); |
999 | |
1012 | |
1000 | // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version |
|
|
1001 | //scr_touch (false); |
|
|
1002 | |
|
|
1003 | #ifdef HAVE_BG_PIXMAP |
1013 | #ifdef HAVE_BG_PIXMAP |
1004 | // TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? |
1014 | // TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? |
1005 | // if (bgPixmap.pixmap) |
1015 | // if (bgPixmap.pixmap) |
1006 | // scr_touch (false); |
1016 | // scr_touch (false); |
1007 | #endif |
1017 | #endif |
… | |
… | |
1165 | |
1175 | |
1166 | term->make_current (); |
1176 | term->make_current (); |
1167 | |
1177 | |
1168 | if (text) |
1178 | if (text) |
1169 | { |
1179 | { |
1170 | void *str; |
1180 | wchar_t *str; |
1171 | |
1181 | |
1172 | if (!text->encoding_is_wchar && text->string.multi_byte) |
1182 | if (!text->encoding_is_wchar && text->string.multi_byte) |
1173 | { |
1183 | { |
1174 | // of course, X makes it ugly again |
1184 | // of course, X makes it ugly again |
1175 | if (term->rs[Rs_imLocale]) |
1185 | if (term->rs[Rs_imLocale]) |
1176 | SET_LOCALE (term->rs[Rs_imLocale]); |
1186 | SET_LOCALE (term->rs[Rs_imLocale]); |
1177 | |
1187 | |
1178 | str = rxvt_temp_buf ((text->length + 1) * sizeof (wchar_t)); |
1188 | str = rxvt_temp_buf<wchar_t> (text->length + 1); |
1179 | mbstowcs ((wchar_t *)str, text->string.multi_byte, text->length + 1); |
1189 | mbstowcs (str, text->string.multi_byte, text->length + 1); |
1180 | |
1190 | |
1181 | if (term->rs[Rs_imLocale]) |
1191 | if (term->rs[Rs_imLocale]) |
1182 | SET_LOCALE (term->locale); |
1192 | SET_LOCALE (term->locale); |
1183 | } |
1193 | } |
1184 | else |
1194 | else |
1185 | str = (void *)text->string.wide_char; |
1195 | str = text->string.wide_char; |
1186 | |
1196 | |
1187 | HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, |
1197 | HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, |
1188 | DT_INT, call_data->caret, |
1198 | DT_INT, call_data->caret, |
1189 | DT_INT, call_data->chg_first, |
1199 | DT_INT, call_data->chg_first, |
1190 | DT_INT, call_data->chg_length, |
1200 | DT_INT, call_data->chg_length, |