… | |
… | |
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 | #ifdef XTERM_SCROLLBAR |
248 | scrollBar.destroy (); |
241 | if (xscrollbarGC) XFreeGC (dpy, xscrollbarGC); |
|
|
242 | if (ShadowGC) XFreeGC (dpy, ShadowGC); |
|
|
243 | #endif |
|
|
244 | #ifdef PLAIN_SCROLLBAR |
|
|
245 | if (pscrollbarGC) XFreeGC (dpy, pscrollbarGC); |
|
|
246 | #endif |
|
|
247 | #ifdef NEXT_SCROLLBAR |
|
|
248 | if (blackGC) XFreeGC (dpy, blackGC); |
|
|
249 | if (whiteGC) XFreeGC (dpy, whiteGC); |
|
|
250 | if (grayGC) XFreeGC (dpy, grayGC); |
|
|
251 | if (darkGC) XFreeGC (dpy, darkGC); |
|
|
252 | if (stippleGC) XFreeGC (dpy, stippleGC); |
|
|
253 | if (dimple) XFreePixmap (dpy, dimple); |
|
|
254 | if (upArrow) XFreePixmap (dpy, upArrow); |
|
|
255 | if (downArrow) XFreePixmap (dpy, downArrow); |
|
|
256 | if (upArrowHi) XFreePixmap (dpy, upArrowHi); |
|
|
257 | if (downArrowHi) XFreePixmap (dpy, downArrowHi); |
|
|
258 | #endif |
|
|
259 | #ifdef RXVT_SCROLLBAR |
|
|
260 | if (topShadowGC) XFreeGC (dpy, topShadowGC); |
|
|
261 | if (botShadowGC) XFreeGC (dpy, botShadowGC); |
|
|
262 | if (scrollbarGC) XFreeGC (dpy, scrollbarGC); |
|
|
263 | #endif |
|
|
264 | if (gc) XFreeGC (dpy, gc); |
249 | if (gc) XFreeGC (dpy, gc); |
265 | |
250 | |
266 | delete drawable; |
251 | delete drawable; |
267 | // destroy all windows |
252 | // destroy all windows |
268 | if (parent[0]) |
253 | if (parent[0]) |
… | |
… | |
288 | /* clear all resources */ |
273 | /* clear all resources */ |
289 | for (int i = 0; i < allocated.size (); i++) |
274 | for (int i = 0; i < allocated.size (); i++) |
290 | free (allocated [i]); |
275 | free (allocated [i]); |
291 | |
276 | |
292 | free (selection.text); |
277 | free (selection.text); |
|
|
278 | free (selection.clip_text); |
293 | // TODO: manage env vars in child only(!) |
279 | // TODO: manage env vars in child only(!) |
294 | free (env_display); |
280 | free (env_display); |
295 | free (env_term); |
281 | free (env_term); |
296 | free (locale); |
282 | free (locale); |
297 | free (v_buffer); |
283 | free (v_buffer); |
… | |
… | |
405 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
391 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
406 | sprintf(number, "%d", event->request_code); |
392 | sprintf(number, "%d", event->request_code); |
407 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
393 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
408 | rxvt_warn ("(which is %s)\n", buffer); |
394 | rxvt_warn ("(which is %s)\n", buffer); |
409 | if (event->request_code >= 128) { |
395 | if (event->request_code >= 128) { |
410 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
396 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
411 | mesg, BUFSIZ); |
397 | mesg, BUFSIZ); |
412 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
398 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
413 | } |
399 | } |
414 | if ((event->error_code == BadWindow) || |
400 | if ((event->error_code == BadWindow) || |
415 | (event->error_code == BadPixmap) || |
401 | (event->error_code == BadPixmap) || |
416 | (event->error_code == BadCursor) || |
402 | (event->error_code == BadCursor) || |
417 | (event->error_code == BadFont) || |
403 | (event->error_code == BadFont) || |
418 | (event->error_code == BadDrawable) || |
404 | (event->error_code == BadDrawable) || |
419 | (event->error_code == BadColor) || |
405 | (event->error_code == BadColor) || |
420 | (event->error_code == BadGC) || |
406 | (event->error_code == BadGC) || |
421 | (event->error_code == BadIDChoice) || |
407 | (event->error_code == BadIDChoice) || |
422 | (event->error_code == BadValue) || |
408 | (event->error_code == BadValue) || |
423 | (event->error_code == BadAtom)) { |
409 | (event->error_code == BadAtom)) { |
424 | if (event->error_code == BadValue) |
410 | if (event->error_code == BadValue) |
425 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
411 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
426 | mesg, BUFSIZ); |
412 | mesg, BUFSIZ); |
427 | else if (event->error_code == BadAtom) |
413 | else if (event->error_code == BadAtom) |
428 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
414 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
429 | mesg, BUFSIZ); |
415 | mesg, BUFSIZ); |
430 | else |
416 | else |
431 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
417 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
432 | mesg, BUFSIZ); |
418 | mesg, BUFSIZ); |
433 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
419 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
434 | } |
420 | } |
435 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
421 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
436 | mesg, BUFSIZ); |
422 | mesg, BUFSIZ); |
437 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
423 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
438 | } |
424 | } |
439 | #endif |
425 | #endif |
440 | |
426 | |
441 | int |
427 | int |
… | |
… | |
493 | char **rxvt_environ; // startup environment |
479 | char **rxvt_environ; // startup environment |
494 | |
480 | |
495 | void |
481 | void |
496 | rxvt_init () |
482 | rxvt_init () |
497 | { |
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 | |
498 | ptytty::init (); |
487 | ptytty::init (); |
499 | |
488 | |
500 | if (!ev_default_loop (0)) |
489 | if (!ev_default_loop (0)) |
501 | rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); |
490 | rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); |
502 | |
491 | |
… | |
… | |
525 | */ |
514 | */ |
526 | void |
515 | void |
527 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
516 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
528 | { |
517 | { |
529 | short recalc_x, recalc_y; |
518 | short recalc_x, recalc_y; |
530 | int x, y, sb_w, flags; |
519 | int x, y, flags; |
531 | unsigned int w, h; |
520 | unsigned int w, h; |
532 | unsigned int max_width, max_height; |
521 | unsigned int max_width, max_height; |
533 | |
522 | |
534 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
523 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
535 | szHint.win_gravity = NorthWestGravity; |
524 | szHint.win_gravity = NorthWestGravity; |
… | |
… | |
545 | if (rs[Rs_geometry]) |
534 | if (rs[Rs_geometry]) |
546 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
535 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
547 | |
536 | |
548 | if (flags & WidthValue) |
537 | if (flags & WidthValue) |
549 | { |
538 | { |
|
|
539 | if (!w) |
|
|
540 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
541 | |
550 | ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); |
542 | ncol = clamp (w, 1, std::numeric_limits<int16_t>::max ()); |
551 | szHint.flags |= USSize; |
543 | szHint.flags |= USSize; |
552 | } |
544 | } |
553 | |
545 | |
554 | if (flags & HeightValue) |
546 | if (flags & HeightValue) |
555 | { |
547 | { |
|
|
548 | if (!h) |
|
|
549 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
550 | |
556 | nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); |
551 | nrow = clamp (h, 1, std::numeric_limits<int16_t>::max ()); |
557 | szHint.flags |= USSize; |
552 | szHint.flags |= USSize; |
558 | } |
553 | } |
559 | |
554 | |
560 | if (flags & XValue) |
555 | if (flags & XValue) |
561 | { |
556 | { |
… | |
… | |
592 | max_width = MAX_COLS * fwidth; |
587 | max_width = MAX_COLS * fwidth; |
593 | max_height = MAX_ROWS * fheight; |
588 | max_height = MAX_ROWS * fheight; |
594 | |
589 | |
595 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
590 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
596 | |
591 | |
597 | sb_w = 0; |
|
|
598 | window_vt_x = window_vt_y = int_bwidth; |
592 | window_vt_x = window_vt_y = int_bwidth; |
599 | |
593 | |
600 | if (scrollBar.state) |
594 | if (scrollBar.state) |
601 | { |
595 | { |
602 | sb_w = scrollBar.total_width (); |
596 | int sb_w = scrollBar.total_width (); |
603 | szHint.base_width += sb_w; |
597 | szHint.base_width += sb_w; |
604 | |
598 | |
605 | if (!option (Opt_scrollBar_right)) |
599 | if (!option (Opt_scrollBar_right)) |
606 | window_vt_x += sb_w; |
600 | window_vt_x += sb_w; |
607 | } |
601 | } |
… | |
… | |
631 | { |
625 | { |
632 | min_it (height, max_height); |
626 | min_it (height, max_height); |
633 | szHint.height = szHint.base_height + height; |
627 | szHint.height = szHint.base_height + height; |
634 | } |
628 | } |
635 | |
629 | |
636 | if (scrollBar.state && option (Opt_scrollBar_right)) |
|
|
637 | window_sb_x = szHint.width - sb_w; |
|
|
638 | |
|
|
639 | if (recalc_x) |
630 | if (recalc_x) |
640 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
631 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
641 | |
632 | |
642 | if (recalc_y) |
633 | if (recalc_y) |
643 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
634 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
644 | |
635 | |
645 | ncol = width / fwidth; |
636 | ncol = width / fwidth; |
646 | nrow = height / fheight; |
637 | nrow = height / fheight; |
647 | } |
638 | } |
648 | |
639 | |
649 | /*----------------------------------------------------------------------*/ |
640 | /*----------------------------------------------------------------------*/ |
650 | /* |
641 | /* |
… | |
… | |
661 | |
652 | |
662 | ws.ws_col = ncol; |
653 | ws.ws_col = ncol; |
663 | ws.ws_row = nrow; |
654 | ws.ws_row = nrow; |
664 | ws.ws_xpixel = width; |
655 | ws.ws_xpixel = width; |
665 | ws.ws_ypixel = height; |
656 | ws.ws_ypixel = height; |
666 | (void)ioctl (pty->pty, TIOCSWINSZ, &ws); |
657 | ioctl (pty->pty, TIOCSWINSZ, &ws); |
667 | |
658 | |
668 | #if 0 |
659 | #if 0 |
669 | // TIOCSWINSZ is supposed to do this automatically and correctly |
660 | // TIOCSWINSZ is supposed to do this automatically and correctly |
670 | if (cmd_pid) /* force through to the command */ |
661 | if (cmd_pid) /* force through to the command */ |
671 | kill (-cmd_pid, SIGWINCH); |
662 | kill (-cmd_pid, SIGWINCH); |
… | |
… | |
701 | #endif |
692 | #endif |
702 | |
693 | |
703 | delete fontset[0]; |
694 | delete fontset[0]; |
704 | fontset[0] = fs; |
695 | fontset[0] = fs; |
705 | |
696 | |
706 | prop = (*fs)[1]->properties (); |
697 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
707 | prop.height += lineSpace; |
698 | prop.height += lineSpace; |
|
|
699 | prop.width += letterSpace; |
708 | |
700 | |
709 | fs->set_prop (prop, false); |
701 | fs->set_prop (prop, false); |
710 | |
702 | |
711 | fwidth = prop.width; |
703 | fwidth = prop.width; |
712 | fheight = prop.height; |
704 | fheight = prop.height; |
… | |
… | |
762 | prop, XA_STRING, 8, PropModeReplace, |
754 | prop, XA_STRING, 8, PropModeReplace, |
763 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
755 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
764 | } |
756 | } |
765 | |
757 | |
766 | void |
758 | void |
|
|
759 | rxvt_term::set_mbstring_property (Atom prop, const char *str, int len) |
|
|
760 | { |
|
|
761 | XTextProperty ct; |
|
|
762 | |
|
|
763 | if (XmbTextListToTextProperty (dpy, (char **)&str, 1, XStdICCTextStyle, &ct) >= 0) |
|
|
764 | { |
|
|
765 | XSetTextProperty (dpy, parent[0], &ct, prop); |
|
|
766 | XFree (ct.value); |
|
|
767 | } |
|
|
768 | } |
|
|
769 | |
|
|
770 | void |
767 | rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
771 | rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
768 | { |
772 | { |
769 | wchar_t *ws = rxvt_mbstowcs (str, len); |
773 | wchar_t *ws = rxvt_mbstowcs (str, len); |
770 | char *s = rxvt_wcstoutf8 (ws); |
774 | char *s = rxvt_wcstoutf8 (ws); |
771 | |
775 | |
… | |
… | |
781 | /*----------------------------------------------------------------------*/ |
785 | /*----------------------------------------------------------------------*/ |
782 | /* xterm sequences - title, iconName, color (exptl) */ |
786 | /* xterm sequences - title, iconName, color (exptl) */ |
783 | void |
787 | void |
784 | rxvt_term::set_title (const char *str) |
788 | rxvt_term::set_title (const char *str) |
785 | { |
789 | { |
786 | set_string_property (XA_WM_NAME, str); |
790 | set_mbstring_property (XA_WM_NAME, str); |
787 | #if ENABLE_EWMH |
791 | #if ENABLE_EWMH |
788 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
792 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
789 | #endif |
793 | #endif |
790 | } |
794 | } |
791 | |
795 | |
792 | void |
796 | void |
793 | rxvt_term::set_icon_name (const char *str) |
797 | rxvt_term::set_icon_name (const char *str) |
794 | { |
798 | { |
795 | set_string_property (XA_WM_ICON_NAME, str); |
799 | set_mbstring_property (XA_WM_ICON_NAME, str); |
796 | #if ENABLE_EWMH |
800 | #if ENABLE_EWMH |
797 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
801 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
798 | #endif |
802 | #endif |
799 | } |
803 | } |
800 | |
804 | |
… | |
… | |
926 | int old_width = szHint.width; |
930 | int old_width = szHint.width; |
927 | int old_height = szHint.height; |
931 | int old_height = szHint.height; |
928 | |
932 | |
929 | window_calc (newwidth, newheight); |
933 | window_calc (newwidth, newheight); |
930 | |
934 | |
931 | if (!HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END))) |
935 | bool set_hint = !HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
|
|
936 | |
|
|
937 | // to avoid races between us and the wm, we clear the incremental size hints around the xresizewindow |
|
|
938 | if (set_hint) |
|
|
939 | { |
|
|
940 | szHint.flags &= ~(PBaseSize | PResizeInc); |
932 | XSetWMNormalHints (dpy, parent[0], &szHint); |
941 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
942 | szHint.flags |= PBaseSize | PResizeInc; |
|
|
943 | } |
933 | |
944 | |
934 | if (!ignoreparent) |
945 | if (!ignoreparent) |
935 | { |
946 | { |
936 | #ifdef SMART_RESIZE |
947 | #ifdef SMART_RESIZE |
937 | /* |
948 | /* |
… | |
… | |
977 | #else |
988 | #else |
978 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
989 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
979 | #endif |
990 | #endif |
980 | } |
991 | } |
981 | |
992 | |
|
|
993 | if (set_hint) |
|
|
994 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
995 | |
982 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
996 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
983 | |
997 | |
984 | if (fix_screen || newwidth != old_width || newheight != old_height) |
998 | if (fix_screen || newwidth != old_width || newheight != old_height) |
985 | { |
999 | { |
986 | if (scrollBar.state) |
1000 | if (scrollBar.state) |
987 | { |
1001 | scrollBar.resize (); |
988 | XMoveResizeWindow (dpy, scrollBar.win, |
|
|
989 | window_sb_x, 0, |
|
|
990 | scrollBar.total_width (), szHint.height); |
|
|
991 | resize_scrollbar (); |
|
|
992 | } |
|
|
993 | |
1002 | |
994 | XMoveResizeWindow (dpy, vt, |
1003 | XMoveResizeWindow (dpy, vt, |
995 | window_vt_x, window_vt_y, |
1004 | window_vt_x, window_vt_y, |
996 | width, height); |
1005 | width, height); |
997 | |
1006 | |
998 | #ifdef HAVE_BG_PIXMAP |
1007 | #ifdef HAVE_BG_PIXMAP |
999 | if (bgPixmap.window_size_sensitive ()) |
1008 | if (bgPixmap.window_size_sensitive ()) |
1000 | update_background (); |
1009 | update_background (); |
1001 | #endif |
1010 | #endif |
1002 | |
|
|
1003 | scr_clear (); |
|
|
1004 | } |
1011 | } |
1005 | |
1012 | |
1006 | if (fix_screen || old_height == 0) |
1013 | if (fix_screen || old_height == 0) |
1007 | scr_reset (); |
1014 | scr_reset (); |
1008 | |
|
|
1009 | // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version |
|
|
1010 | //scr_touch (false); |
|
|
1011 | |
1015 | |
1012 | #ifdef HAVE_BG_PIXMAP |
1016 | #ifdef HAVE_BG_PIXMAP |
1013 | // TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? |
1017 | // TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? |
1014 | // if (bgPixmap.pixmap) |
1018 | // if (bgPixmap.pixmap) |
1015 | // scr_touch (false); |
1019 | // scr_touch (false); |
… | |
… | |
1087 | |
1091 | |
1088 | /* Checking whether input method is running. */ |
1092 | /* Checking whether input method is running. */ |
1089 | bool |
1093 | bool |
1090 | rxvt_term::IMisRunning () |
1094 | rxvt_term::IMisRunning () |
1091 | { |
1095 | { |
1092 | char *p; |
|
|
1093 | Atom atom; |
1096 | Atom atom; |
1094 | Window win; |
1097 | Window win; |
1095 | char server[IMBUFSIZ]; |
1098 | char server[IMBUFSIZ]; |
1096 | |
1099 | |
1097 | /* get current locale modifier */ |
1100 | /* get current locale modifier */ |
1098 | if ((p = XSetLocaleModifiers (NULL)) != NULL) |
1101 | if (char *p = XSetLocaleModifiers (0)) |
1099 | { |
1102 | { |
1100 | strcpy (server, "@server="); |
1103 | strcpy (server, "@server="); |
1101 | strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ |
1104 | strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */ |
1102 | |
1105 | |
1103 | if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ |
1106 | if (p = strchr (server + 1, '@')) /* first one only */ |
1104 | *p = '\0'; |
1107 | *p = '\0'; |
1105 | |
1108 | |
1106 | atom = XInternAtom (dpy, server, False); |
1109 | atom = XInternAtom (dpy, server, False); |
1107 | win = XGetSelectionOwner (dpy, atom); |
1110 | win = XGetSelectionOwner (dpy, atom); |
1108 | |
1111 | |
… | |
… | |
1175 | |
1178 | |
1176 | term->make_current (); |
1179 | term->make_current (); |
1177 | |
1180 | |
1178 | if (text) |
1181 | if (text) |
1179 | { |
1182 | { |
1180 | void *str; |
1183 | wchar_t *str; |
1181 | |
1184 | |
1182 | if (!text->encoding_is_wchar && text->string.multi_byte) |
1185 | if (!text->encoding_is_wchar && text->string.multi_byte) |
1183 | { |
1186 | { |
1184 | // of course, X makes it ugly again |
1187 | // of course, X makes it ugly again |
1185 | if (term->rs[Rs_imLocale]) |
1188 | if (term->rs[Rs_imLocale]) |
1186 | SET_LOCALE (term->rs[Rs_imLocale]); |
1189 | SET_LOCALE (term->rs[Rs_imLocale]); |
1187 | |
1190 | |
1188 | str = rxvt_temp_buf ((text->length + 1) * sizeof (wchar_t)); |
1191 | str = rxvt_temp_buf<wchar_t> (text->length + 1); |
1189 | mbstowcs ((wchar_t *)str, text->string.multi_byte, text->length + 1); |
1192 | mbstowcs (str, text->string.multi_byte, text->length + 1); |
1190 | |
1193 | |
1191 | if (term->rs[Rs_imLocale]) |
1194 | if (term->rs[Rs_imLocale]) |
1192 | SET_LOCALE (term->locale); |
1195 | SET_LOCALE (term->locale); |
1193 | } |
1196 | } |
1194 | else |
1197 | else |
1195 | str = (void *)text->string.wide_char; |
1198 | str = text->string.wide_char; |
1196 | |
1199 | |
1197 | HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, |
1200 | HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, |
1198 | DT_INT, call_data->caret, |
1201 | DT_INT, call_data->caret, |
1199 | DT_INT, call_data->chg_first, |
1202 | DT_INT, call_data->chg_first, |
1200 | DT_INT, call_data->chg_length, |
1203 | DT_INT, call_data->chg_length, |