… | |
… | |
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 | } |
… | |
… | |
227 | delete fontset[0]; |
228 | delete fontset[0]; |
228 | |
229 | |
229 | #ifdef HAVE_BG_PIXMAP |
230 | #ifdef HAVE_BG_PIXMAP |
230 | bgPixmap.destroy (); |
231 | bgPixmap.destroy (); |
231 | #endif |
232 | #endif |
|
|
233 | #ifdef HAVE_AFTERIMAGE |
|
|
234 | if (asv) |
|
|
235 | destroy_asvisual (asv, 0); |
|
|
236 | if (asimman) |
|
|
237 | destroy_image_manager (asimman, 0); |
|
|
238 | #endif |
232 | |
239 | |
233 | if (display) |
240 | if (display) |
234 | { |
241 | { |
235 | selection_clear (); |
242 | selection_clear (); |
|
|
243 | selection_clear (true); |
236 | |
244 | |
237 | #ifdef USE_XIM |
245 | #ifdef USE_XIM |
238 | im_destroy (); |
246 | im_destroy (); |
239 | #endif |
247 | #endif |
240 | scrollBar.destroy (); |
248 | scrollBar.destroy (); |
… | |
… | |
265 | /* clear all resources */ |
273 | /* clear all resources */ |
266 | for (int i = 0; i < allocated.size (); i++) |
274 | for (int i = 0; i < allocated.size (); i++) |
267 | free (allocated [i]); |
275 | free (allocated [i]); |
268 | |
276 | |
269 | free (selection.text); |
277 | free (selection.text); |
|
|
278 | free (selection.clip_text); |
270 | // TODO: manage env vars in child only(!) |
279 | // TODO: manage env vars in child only(!) |
271 | free (env_display); |
280 | free (env_display); |
272 | free (env_term); |
281 | free (env_term); |
273 | free (locale); |
282 | free (locale); |
274 | free (v_buffer); |
283 | free (v_buffer); |
… | |
… | |
374 | char mesg[BUFSIZ]; |
383 | char mesg[BUFSIZ]; |
375 | char number[32]; |
384 | char number[32]; |
376 | char *mtype = "XlibMessage"; |
385 | char *mtype = "XlibMessage"; |
377 | XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); |
386 | XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); |
378 | XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); |
387 | XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); |
379 | 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"); |
380 | rxvt_warn ("%s: %s\n", mesg, buffer); |
389 | rxvt_warn ("%s: %s\n", mesg, buffer); |
381 | XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
390 | XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
382 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
391 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
383 | sprintf(number, "%d", event->request_code); |
392 | sprintf(number, "%d", event->request_code); |
384 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
393 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
385 | rxvt_warn ("(which is %s)\n", buffer); |
394 | rxvt_warn ("(which is %s)\n", buffer); |
386 | if (event->request_code >= 128) { |
395 | if (event->request_code >= 128) { |
387 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
396 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
388 | mesg, BUFSIZ); |
397 | mesg, BUFSIZ); |
389 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
398 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
390 | } |
399 | } |
391 | if ((event->error_code == BadWindow) || |
400 | if ((event->error_code == BadWindow) || |
392 | (event->error_code == BadPixmap) || |
401 | (event->error_code == BadPixmap) || |
393 | (event->error_code == BadCursor) || |
402 | (event->error_code == BadCursor) || |
394 | (event->error_code == BadFont) || |
403 | (event->error_code == BadFont) || |
395 | (event->error_code == BadDrawable) || |
404 | (event->error_code == BadDrawable) || |
396 | (event->error_code == BadColor) || |
405 | (event->error_code == BadColor) || |
397 | (event->error_code == BadGC) || |
406 | (event->error_code == BadGC) || |
398 | (event->error_code == BadIDChoice) || |
407 | (event->error_code == BadIDChoice) || |
399 | (event->error_code == BadValue) || |
408 | (event->error_code == BadValue) || |
400 | (event->error_code == BadAtom)) { |
409 | (event->error_code == BadAtom)) { |
401 | if (event->error_code == BadValue) |
410 | if (event->error_code == BadValue) |
402 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
411 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
403 | mesg, BUFSIZ); |
412 | mesg, BUFSIZ); |
404 | else if (event->error_code == BadAtom) |
413 | else if (event->error_code == BadAtom) |
405 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
414 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
406 | mesg, BUFSIZ); |
415 | mesg, BUFSIZ); |
407 | else |
416 | else |
408 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
417 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
409 | mesg, BUFSIZ); |
418 | mesg, BUFSIZ); |
410 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
419 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
411 | } |
420 | } |
412 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
421 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
413 | mesg, BUFSIZ); |
422 | mesg, BUFSIZ); |
414 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
423 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
415 | } |
424 | } |
416 | #endif |
425 | #endif |
417 | |
426 | |
418 | int |
427 | int |
… | |
… | |
470 | char **rxvt_environ; // startup environment |
479 | char **rxvt_environ; // startup environment |
471 | |
480 | |
472 | void |
481 | void |
473 | rxvt_init () |
482 | rxvt_init () |
474 | { |
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 | |
|
|
487 | // get rid of stdin/stdout as we don't need them, to free resources |
|
|
488 | dup2 (STDERR_FILENO, STDIN_FILENO); |
|
|
489 | dup2 (STDERR_FILENO, STDOUT_FILENO); |
|
|
490 | |
475 | ptytty::init (); |
491 | ptytty::init (); |
476 | |
492 | |
477 | if (!ev_default_loop (0)) |
493 | if (!ev_default_loop (0)) |
478 | rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); |
494 | rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); |
479 | |
495 | |
… | |
… | |
482 | signal (SIGHUP, SIG_IGN); |
498 | signal (SIGHUP, SIG_IGN); |
483 | signal (SIGPIPE, SIG_IGN); |
499 | signal (SIGPIPE, SIG_IGN); |
484 | |
500 | |
485 | sig_handlers.sw_term.start (SIGTERM); ev_unref (); |
501 | sig_handlers.sw_term.start (SIGTERM); ev_unref (); |
486 | sig_handlers.sw_int.start (SIGINT); ev_unref (); |
502 | sig_handlers.sw_int.start (SIGINT); ev_unref (); |
487 | |
|
|
488 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
489 | /* signal (SIGURG, SIG_DFL); */ |
|
|
490 | |
503 | |
491 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
504 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
492 | // TODO: handle this with exceptions and tolerate the memory loss |
505 | // TODO: handle this with exceptions and tolerate the memory loss |
493 | XSetIOErrorHandler (rxvt_xioerror_handler); |
506 | XSetIOErrorHandler (rxvt_xioerror_handler); |
494 | |
507 | |
… | |
… | |
522 | if (rs[Rs_geometry]) |
535 | if (rs[Rs_geometry]) |
523 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
536 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
524 | |
537 | |
525 | if (flags & WidthValue) |
538 | if (flags & WidthValue) |
526 | { |
539 | { |
|
|
540 | if (!w) |
|
|
541 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
542 | |
527 | ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); |
543 | ncol = clamp (w, 1, std::numeric_limits<int16_t>::max ()); |
528 | szHint.flags |= USSize; |
544 | szHint.flags |= USSize; |
529 | } |
545 | } |
530 | |
546 | |
531 | if (flags & HeightValue) |
547 | if (flags & HeightValue) |
532 | { |
548 | { |
|
|
549 | if (!h) |
|
|
550 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
551 | |
533 | nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); |
552 | nrow = clamp (h, 1, std::numeric_limits<int16_t>::max ()); |
534 | szHint.flags |= USSize; |
553 | szHint.flags |= USSize; |
535 | } |
554 | } |
536 | |
555 | |
537 | if (flags & XValue) |
556 | if (flags & XValue) |
538 | { |
557 | { |
… | |
… | |
559 | szHint.win_gravity = SouthEastGravity; |
578 | szHint.win_gravity = SouthEastGravity; |
560 | else |
579 | else |
561 | szHint.win_gravity = SouthWestGravity; |
580 | szHint.win_gravity = SouthWestGravity; |
562 | } |
581 | } |
563 | } |
582 | } |
564 | |
|
|
565 | if (!szHint.width || !szHint.height) |
|
|
566 | rxvt_fatal ("window width or height must not be zero, aborting.\n"); |
|
|
567 | } |
583 | } |
568 | |
584 | |
569 | /* TODO: BOUNDS */ |
585 | /* TODO: BOUNDS */ |
570 | width = ncol * fwidth; |
586 | width = ncol * fwidth; |
571 | height = nrow * fheight; |
587 | height = nrow * fheight; |
… | |
… | |
616 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
632 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
617 | |
633 | |
618 | if (recalc_y) |
634 | if (recalc_y) |
619 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
635 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
620 | |
636 | |
621 | ncol = width / fwidth; |
637 | ncol = width / fwidth; |
622 | nrow = height / fheight; |
638 | nrow = height / fheight; |
623 | } |
639 | } |
624 | |
640 | |
625 | /*----------------------------------------------------------------------*/ |
641 | /*----------------------------------------------------------------------*/ |
626 | /* |
642 | /* |
… | |
… | |
637 | |
653 | |
638 | ws.ws_col = ncol; |
654 | ws.ws_col = ncol; |
639 | ws.ws_row = nrow; |
655 | ws.ws_row = nrow; |
640 | ws.ws_xpixel = width; |
656 | ws.ws_xpixel = width; |
641 | ws.ws_ypixel = height; |
657 | ws.ws_ypixel = height; |
642 | (void)ioctl (pty->pty, TIOCSWINSZ, &ws); |
658 | ioctl (pty->pty, TIOCSWINSZ, &ws); |
643 | |
659 | |
644 | #if 0 |
660 | #if 0 |
645 | // TIOCSWINSZ is supposed to do this automatically and correctly |
661 | // TIOCSWINSZ is supposed to do this automatically and correctly |
646 | if (cmd_pid) /* force through to the command */ |
662 | if (cmd_pid) /* force through to the command */ |
647 | kill (-cmd_pid, SIGWINCH); |
663 | kill (-cmd_pid, SIGWINCH); |
… | |
… | |
677 | #endif |
693 | #endif |
678 | |
694 | |
679 | delete fontset[0]; |
695 | delete fontset[0]; |
680 | fontset[0] = fs; |
696 | fontset[0] = fs; |
681 | |
697 | |
682 | prop = (*fs)[1]->properties (); |
698 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
683 | prop.height += lineSpace; |
699 | prop.height += lineSpace; |
|
|
700 | prop.width += letterSpace; |
684 | |
701 | |
685 | fs->set_prop (prop, false); |
702 | fs->set_prop (prop, false); |
686 | |
703 | |
687 | fwidth = prop.width; |
704 | fwidth = prop.width; |
688 | fheight = prop.height; |
705 | fheight = prop.height; |
… | |
… | |
738 | prop, XA_STRING, 8, PropModeReplace, |
755 | prop, XA_STRING, 8, PropModeReplace, |
739 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
756 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
740 | } |
757 | } |
741 | |
758 | |
742 | void |
759 | void |
|
|
760 | rxvt_term::set_mbstring_property (Atom prop, const char *str, int len) |
|
|
761 | { |
|
|
762 | XTextProperty ct; |
|
|
763 | |
|
|
764 | if (XmbTextListToTextProperty (dpy, (char **)&str, 1, XStdICCTextStyle, &ct) >= 0) |
|
|
765 | { |
|
|
766 | XSetTextProperty (dpy, parent[0], &ct, prop); |
|
|
767 | XFree (ct.value); |
|
|
768 | } |
|
|
769 | } |
|
|
770 | |
|
|
771 | void |
743 | rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
772 | rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
744 | { |
773 | { |
745 | wchar_t *ws = rxvt_mbstowcs (str, len); |
774 | wchar_t *ws = rxvt_mbstowcs (str, len); |
746 | char *s = rxvt_wcstoutf8 (ws); |
775 | char *s = rxvt_wcstoutf8 (ws); |
747 | |
776 | |
… | |
… | |
757 | /*----------------------------------------------------------------------*/ |
786 | /*----------------------------------------------------------------------*/ |
758 | /* xterm sequences - title, iconName, color (exptl) */ |
787 | /* xterm sequences - title, iconName, color (exptl) */ |
759 | void |
788 | void |
760 | rxvt_term::set_title (const char *str) |
789 | rxvt_term::set_title (const char *str) |
761 | { |
790 | { |
762 | set_string_property (XA_WM_NAME, str); |
791 | set_mbstring_property (XA_WM_NAME, str); |
763 | #if ENABLE_EWMH |
792 | #if ENABLE_EWMH |
764 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
793 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
765 | #endif |
794 | #endif |
766 | } |
795 | } |
767 | |
796 | |
768 | void |
797 | void |
769 | rxvt_term::set_icon_name (const char *str) |
798 | rxvt_term::set_icon_name (const char *str) |
770 | { |
799 | { |
771 | set_string_property (XA_WM_ICON_NAME, str); |
800 | set_mbstring_property (XA_WM_ICON_NAME, str); |
772 | #if ENABLE_EWMH |
801 | #if ENABLE_EWMH |
773 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
802 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
774 | #endif |
803 | #endif |
775 | } |
804 | } |
776 | |
805 | |
… | |
… | |
902 | int old_width = szHint.width; |
931 | int old_width = szHint.width; |
903 | int old_height = szHint.height; |
932 | int old_height = szHint.height; |
904 | |
933 | |
905 | window_calc (newwidth, newheight); |
934 | window_calc (newwidth, newheight); |
906 | |
935 | |
907 | if (!HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END))) |
936 | bool set_hint = !HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
|
|
937 | |
|
|
938 | // to avoid races between us and the wm, we clear the incremental size hints around the xresizewindow |
|
|
939 | if (set_hint) |
|
|
940 | { |
|
|
941 | szHint.flags &= ~(PBaseSize | PResizeInc); |
908 | XSetWMNormalHints (dpy, parent[0], &szHint); |
942 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
943 | szHint.flags |= PBaseSize | PResizeInc; |
|
|
944 | } |
909 | |
945 | |
910 | if (!ignoreparent) |
946 | if (!ignoreparent) |
911 | { |
947 | { |
912 | #ifdef SMART_RESIZE |
948 | #ifdef SMART_RESIZE |
913 | /* |
949 | /* |
… | |
… | |
953 | #else |
989 | #else |
954 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
990 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
955 | #endif |
991 | #endif |
956 | } |
992 | } |
957 | |
993 | |
|
|
994 | if (set_hint) |
|
|
995 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
996 | |
958 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
997 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
959 | |
998 | |
960 | if (fix_screen || newwidth != old_width || newheight != old_height) |
999 | if (fix_screen || newwidth != old_width || newheight != old_height) |
961 | { |
1000 | { |
962 | if (scrollBar.state) |
1001 | if (scrollBar.state) |
… | |
… | |
968 | |
1007 | |
969 | #ifdef HAVE_BG_PIXMAP |
1008 | #ifdef HAVE_BG_PIXMAP |
970 | if (bgPixmap.window_size_sensitive ()) |
1009 | if (bgPixmap.window_size_sensitive ()) |
971 | update_background (); |
1010 | update_background (); |
972 | #endif |
1011 | #endif |
973 | |
|
|
974 | scr_clear (); |
|
|
975 | } |
1012 | } |
976 | |
1013 | |
977 | if (fix_screen || old_height == 0) |
1014 | if (fix_screen || old_height == 0) |
978 | scr_reset (); |
1015 | scr_reset (); |
979 | |
|
|
980 | // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version |
|
|
981 | //scr_touch (false); |
|
|
982 | |
1016 | |
983 | #ifdef HAVE_BG_PIXMAP |
1017 | #ifdef HAVE_BG_PIXMAP |
984 | // TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? |
1018 | // TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? |
985 | // if (bgPixmap.pixmap) |
1019 | // if (bgPixmap.pixmap) |
986 | // scr_touch (false); |
1020 | // scr_touch (false); |
… | |
… | |
1058 | |
1092 | |
1059 | /* Checking whether input method is running. */ |
1093 | /* Checking whether input method is running. */ |
1060 | bool |
1094 | bool |
1061 | rxvt_term::IMisRunning () |
1095 | rxvt_term::IMisRunning () |
1062 | { |
1096 | { |
1063 | char *p; |
|
|
1064 | Atom atom; |
1097 | Atom atom; |
1065 | Window win; |
1098 | Window win; |
1066 | char server[IMBUFSIZ]; |
1099 | char server[IMBUFSIZ]; |
1067 | |
1100 | |
1068 | /* get current locale modifier */ |
1101 | /* get current locale modifier */ |
1069 | if ((p = XSetLocaleModifiers (NULL)) != NULL) |
1102 | if (char *p = XSetLocaleModifiers (0)) |
1070 | { |
1103 | { |
1071 | strcpy (server, "@server="); |
1104 | strcpy (server, "@server="); |
1072 | strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ |
1105 | strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */ |
1073 | |
1106 | |
1074 | if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ |
1107 | if (p = strchr (server + 1, '@')) /* first one only */ |
1075 | *p = '\0'; |
1108 | *p = '\0'; |
1076 | |
1109 | |
1077 | atom = XInternAtom (dpy, server, False); |
1110 | atom = XInternAtom (dpy, server, False); |
1078 | win = XGetSelectionOwner (dpy, atom); |
1111 | win = XGetSelectionOwner (dpy, atom); |
1079 | |
1112 | |
… | |
… | |
1146 | |
1179 | |
1147 | term->make_current (); |
1180 | term->make_current (); |
1148 | |
1181 | |
1149 | if (text) |
1182 | if (text) |
1150 | { |
1183 | { |
1151 | void *str; |
1184 | wchar_t *str; |
1152 | |
1185 | |
1153 | if (!text->encoding_is_wchar && text->string.multi_byte) |
1186 | if (!text->encoding_is_wchar && text->string.multi_byte) |
1154 | { |
1187 | { |
1155 | // of course, X makes it ugly again |
1188 | // of course, X makes it ugly again |
1156 | if (term->rs[Rs_imLocale]) |
1189 | if (term->rs[Rs_imLocale]) |
1157 | SET_LOCALE (term->rs[Rs_imLocale]); |
1190 | SET_LOCALE (term->rs[Rs_imLocale]); |
1158 | |
1191 | |
1159 | str = rxvt_temp_buf ((text->length + 1) * sizeof (wchar_t)); |
1192 | str = rxvt_temp_buf<wchar_t> (text->length + 1); |
1160 | mbstowcs ((wchar_t *)str, text->string.multi_byte, text->length + 1); |
1193 | mbstowcs (str, text->string.multi_byte, text->length + 1); |
1161 | |
1194 | |
1162 | if (term->rs[Rs_imLocale]) |
1195 | if (term->rs[Rs_imLocale]) |
1163 | SET_LOCALE (term->locale); |
1196 | SET_LOCALE (term->locale); |
1164 | } |
1197 | } |
1165 | else |
1198 | else |
1166 | str = (void *)text->string.wide_char; |
1199 | str = text->string.wide_char; |
1167 | |
1200 | |
1168 | HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, |
1201 | HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, |
1169 | DT_INT, call_data->caret, |
1202 | DT_INT, call_data->caret, |
1170 | DT_INT, call_data->chg_first, |
1203 | DT_INT, call_data->chg_first, |
1171 | DT_INT, call_data->chg_length, |
1204 | DT_INT, call_data->chg_length, |