ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/main.C
(Generate patch)

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.303 by ayin, Sun Jan 27 22:48:33 2008 UTC vs.
Revision 1.330 by sf-exg, Mon Jul 26 09:57:53 2010 UTC

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);
397 char mesg[BUFSIZ]; 383 char mesg[BUFSIZ];
398 char number[32]; 384 char number[32];
399 char *mtype = "XlibMessage"; 385 char *mtype = "XlibMessage";
400 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); 386 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
401 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); 387 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
402 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");
403 rxvt_warn ("%s: %s\n", mesg, buffer); 389 rxvt_warn ("%s: %s\n", mesg, buffer);
404 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); 390 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
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
441int 427int
493char **rxvt_environ; // startup environment 479char **rxvt_environ; // startup environment
494 480
495void 481void
496rxvt_init () 482rxvt_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
505 signal (SIGHUP, SIG_IGN); 494 signal (SIGHUP, SIG_IGN);
506 signal (SIGPIPE, SIG_IGN); 495 signal (SIGPIPE, SIG_IGN);
507 496
508 sig_handlers.sw_term.start (SIGTERM); ev_unref (); 497 sig_handlers.sw_term.start (SIGTERM); ev_unref ();
509 sig_handlers.sw_int.start (SIGINT); ev_unref (); 498 sig_handlers.sw_int.start (SIGINT); ev_unref ();
510
511 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
512 /* signal (SIGURG, SIG_DFL); */
513 499
514 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 500 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
515 // TODO: handle this with exceptions and tolerate the memory loss 501 // TODO: handle this with exceptions and tolerate the memory loss
516 XSetIOErrorHandler (rxvt_xioerror_handler); 502 XSetIOErrorHandler (rxvt_xioerror_handler);
517 503
525 */ 511 */
526void 512void
527rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) 513rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight)
528{ 514{
529 short recalc_x, recalc_y; 515 short recalc_x, recalc_y;
530 int x, y, sb_w, flags; 516 int x, y, flags;
531 unsigned int w, h; 517 unsigned int w, h;
532 unsigned int max_width, max_height; 518 unsigned int max_width, max_height;
533 519
534 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; 520 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
535 szHint.win_gravity = NorthWestGravity; 521 szHint.win_gravity = NorthWestGravity;
545 if (rs[Rs_geometry]) 531 if (rs[Rs_geometry])
546 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); 532 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);
547 533
548 if (flags & WidthValue) 534 if (flags & WidthValue)
549 { 535 {
536 if (!w)
537 rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n");
538
550 ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); 539 ncol = clamp (w, 1, std::numeric_limits<int16_t>::max ());
551 szHint.flags |= USSize; 540 szHint.flags |= USSize;
552 } 541 }
553 542
554 if (flags & HeightValue) 543 if (flags & HeightValue)
555 { 544 {
545 if (!h)
546 rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n");
547
556 nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); 548 nrow = clamp (h, 1, std::numeric_limits<int16_t>::max ());
557 szHint.flags |= USSize; 549 szHint.flags |= USSize;
558 } 550 }
559 551
560 if (flags & XValue) 552 if (flags & XValue)
561 { 553 {
592 max_width = MAX_COLS * fwidth; 584 max_width = MAX_COLS * fwidth;
593 max_height = MAX_ROWS * fheight; 585 max_height = MAX_ROWS * fheight;
594 586
595 szHint.base_width = szHint.base_height = 2 * int_bwidth; 587 szHint.base_width = szHint.base_height = 2 * int_bwidth;
596 588
597 sb_w = 0;
598 window_vt_x = window_vt_y = int_bwidth; 589 window_vt_x = window_vt_y = int_bwidth;
599 590
600 if (scrollBar.state) 591 if (scrollBar.state)
601 { 592 {
602 sb_w = scrollbar_TotalWidth (); 593 int sb_w = scrollBar.total_width ();
603 szHint.base_width += sb_w; 594 szHint.base_width += sb_w;
604 595
605 if (!option (Opt_scrollBar_right)) 596 if (!option (Opt_scrollBar_right))
606 window_vt_x += sb_w; 597 window_vt_x += sb_w;
607 } 598 }
631 { 622 {
632 min_it (height, max_height); 623 min_it (height, max_height);
633 szHint.height = szHint.base_height + height; 624 szHint.height = szHint.base_height + height;
634 } 625 }
635 626
636 if (scrollBar.state && option (Opt_scrollBar_right))
637 window_sb_x = szHint.width - sb_w;
638
639 if (recalc_x) 627 if (recalc_x)
640 szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; 628 szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth;
641 629
642 if (recalc_y) 630 if (recalc_y)
643 szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; 631 szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth;
644 632
645 ncol = width / fwidth; 633 ncol = width / fwidth;
646 nrow = height / fheight; 634 nrow = height / fheight;
647} 635}
648 636
649/*----------------------------------------------------------------------*/ 637/*----------------------------------------------------------------------*/
650/* 638/*
661 649
662 ws.ws_col = ncol; 650 ws.ws_col = ncol;
663 ws.ws_row = nrow; 651 ws.ws_row = nrow;
664 ws.ws_xpixel = width; 652 ws.ws_xpixel = width;
665 ws.ws_ypixel = height; 653 ws.ws_ypixel = height;
666 (void)ioctl (pty->pty, TIOCSWINSZ, &ws); 654 ioctl (pty->pty, TIOCSWINSZ, &ws);
667 655
668#if 0 656#if 0
669 // TIOCSWINSZ is supposed to do this automatically and correctly 657 // TIOCSWINSZ is supposed to do this automatically and correctly
670 if (cmd_pid) /* force through to the command */ 658 if (cmd_pid) /* force through to the command */
671 kill (-cmd_pid, SIGWINCH); 659 kill (-cmd_pid, SIGWINCH);
701#endif 689#endif
702 690
703 delete fontset[0]; 691 delete fontset[0];
704 fontset[0] = fs; 692 fontset[0] = fs;
705 693
706 prop = (*fs)[1]->properties (); 694 prop = (*fs)[rxvt_fontset::firstFont]->properties ();
707 prop.height += lineSpace; 695 prop.height += lineSpace;
696 prop.width += letterSpace;
708 697
709 fs->set_prop (prop, false); 698 fs->set_prop (prop, false);
710 699
711 fwidth = prop.width; 700 fwidth = prop.width;
712 fheight = prop.height; 701 fheight = prop.height;
762 prop, XA_STRING, 8, PropModeReplace, 751 prop, XA_STRING, 8, PropModeReplace,
763 (const unsigned char *)str, len >= 0 ? len : strlen (str)); 752 (const unsigned char *)str, len >= 0 ? len : strlen (str));
764} 753}
765 754
766void 755void
756rxvt_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
767void
767rxvt_term::set_utf8_property (Atom prop, const char *str, int len) 768rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
768{ 769{
769 wchar_t *ws = rxvt_mbstowcs (str, len); 770 wchar_t *ws = rxvt_mbstowcs (str, len);
770 char *s = rxvt_wcstoutf8 (ws); 771 char *s = rxvt_wcstoutf8 (ws);
771 772
781/*----------------------------------------------------------------------*/ 782/*----------------------------------------------------------------------*/
782/* xterm sequences - title, iconName, color (exptl) */ 783/* xterm sequences - title, iconName, color (exptl) */
783void 784void
784rxvt_term::set_title (const char *str) 785rxvt_term::set_title (const char *str)
785{ 786{
786 set_string_property (XA_WM_NAME, str); 787 set_mbstring_property (XA_WM_NAME, str);
787#if ENABLE_EWMH 788#if ENABLE_EWMH
788 set_utf8_property (xa[XA_NET_WM_NAME], str); 789 set_utf8_property (xa[XA_NET_WM_NAME], str);
789#endif 790#endif
790} 791}
791 792
792void 793void
793rxvt_term::set_icon_name (const char *str) 794rxvt_term::set_icon_name (const char *str)
794{ 795{
795 set_string_property (XA_WM_ICON_NAME, str); 796 set_mbstring_property (XA_WM_ICON_NAME, str);
796#if ENABLE_EWMH 797#if ENABLE_EWMH
797 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); 798 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str);
798#endif 799#endif
799} 800}
800 801
801void 802void
802rxvt_term::set_window_color (int idx, const char *color) 803rxvt_term::set_window_color (int idx, const char *color)
803{ 804{
804#ifdef XTERM_COLOR_CHANGE 805#ifdef XTERM_COLOR_CHANGE
805 rxvt_color xcol; 806 rxvt_color xcol;
806 int i;
807 807
808 if (color == NULL || *color == '\0') 808 if (color == NULL || *color == '\0')
809 return; 809 return;
810 810
811 color = strdup (color); 811 color = strdup (color);
813 rs[Rs_color + idx] = color; 813 rs[Rs_color + idx] = color;
814 814
815 /* handle color aliases */ 815 /* handle color aliases */
816 if (isdigit (*color)) 816 if (isdigit (*color))
817 { 817 {
818 i = atoi (color); 818 int i = atoi (color);
819 819
820 if (i >= 8 && i <= 15) 820 if (i >= 8 && i <= 15)
821 { 821 {
822 /* bright colors */ 822 /* bright colors */
823 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; 823 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8];
927 int old_width = szHint.width; 927 int old_width = szHint.width;
928 int old_height = szHint.height; 928 int old_height = szHint.height;
929 929
930 window_calc (newwidth, newheight); 930 window_calc (newwidth, newheight);
931 931
932 if (!HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END))) 932 bool set_hint = !HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END));
933
934 // to avoid races between us and the wm, we clear the incremental size hints around the xresizewindow
935 if (set_hint)
936 {
937 szHint.flags &= ~(PBaseSize | PResizeInc);
933 XSetWMNormalHints (dpy, parent[0], &szHint); 938 XSetWMNormalHints (dpy, parent[0], &szHint);
939 szHint.flags |= PBaseSize | PResizeInc;
940 }
934 941
935 if (!ignoreparent) 942 if (!ignoreparent)
936 { 943 {
937#ifdef SMART_RESIZE 944#ifdef SMART_RESIZE
938 /* 945 /*
978#else 985#else
979 XResizeWindow (dpy, parent[0], szHint.width, szHint.height); 986 XResizeWindow (dpy, parent[0], szHint.width, szHint.height);
980#endif 987#endif
981 } 988 }
982 989
990 if (set_hint)
991 XSetWMNormalHints (dpy, parent[0], &szHint);
992
983 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 993 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
984 994
985 if (fix_screen || newwidth != old_width || newheight != old_height) 995 if (fix_screen || newwidth != old_width || newheight != old_height)
986 { 996 {
987 if (scrollBar.state) 997 if (scrollBar.state)
988 { 998 scrollBar.resize ();
989 XMoveResizeWindow (dpy, scrollBar.win,
990 window_sb_x, 0,
991 scrollbar_TotalWidth (), szHint.height);
992 resize_scrollbar ();
993 }
994 999
995 XMoveResizeWindow (dpy, vt, 1000 XMoveResizeWindow (dpy, vt,
996 window_vt_x, window_vt_y, 1001 window_vt_x, window_vt_y,
997 width, height); 1002 width, height);
998 1003
999#ifdef HAVE_BG_PIXMAP 1004#ifdef HAVE_BG_PIXMAP
1000 if (bgPixmap.window_size_sensitive ()) 1005 if (bgPixmap.window_size_sensitive ())
1001 update_background (); 1006 update_background ();
1002#endif 1007#endif
1003
1004 scr_clear ();
1005 } 1008 }
1006 1009
1007 if (fix_screen || old_height == 0) 1010 if (fix_screen || old_height == 0)
1008 scr_reset (); 1011 scr_reset ();
1009
1010 // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version
1011 //scr_touch (false);
1012 1012
1013#ifdef HAVE_BG_PIXMAP 1013#ifdef HAVE_BG_PIXMAP
1014// 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 ?
1015// if (bgPixmap.pixmap) 1015// if (bgPixmap.pixmap)
1016// scr_touch (false); 1016// scr_touch (false);
1088 1088
1089/* Checking whether input method is running. */ 1089/* Checking whether input method is running. */
1090bool 1090bool
1091rxvt_term::IMisRunning () 1091rxvt_term::IMisRunning ()
1092{ 1092{
1093 char *p;
1094 Atom atom; 1093 Atom atom;
1095 Window win; 1094 Window win;
1096 char server[IMBUFSIZ]; 1095 char server[IMBUFSIZ];
1097 1096
1098 /* get current locale modifier */ 1097 /* get current locale modifier */
1099 if ((p = XSetLocaleModifiers (NULL)) != NULL) 1098 if (char *p = XSetLocaleModifiers (0))
1100 { 1099 {
1101 strcpy (server, "@server="); 1100 strcpy (server, "@server=");
1102 strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ 1101 strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */
1103 1102
1104 if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ 1103 if (p = strchr (server + 1, '@')) /* first one only */
1105 *p = '\0'; 1104 *p = '\0';
1106 1105
1107 atom = XInternAtom (dpy, server, False); 1106 atom = XInternAtom (dpy, server, False);
1108 win = XGetSelectionOwner (dpy, atom); 1107 win = XGetSelectionOwner (dpy, atom);
1109 1108
1176 1175
1177 term->make_current (); 1176 term->make_current ();
1178 1177
1179 if (text) 1178 if (text)
1180 { 1179 {
1181 void *str; 1180 wchar_t *str;
1182 1181
1183 if (!text->encoding_is_wchar && text->string.multi_byte) 1182 if (!text->encoding_is_wchar && text->string.multi_byte)
1184 { 1183 {
1185 // of course, X makes it ugly again 1184 // of course, X makes it ugly again
1186 if (term->rs[Rs_imLocale]) 1185 if (term->rs[Rs_imLocale])
1187 SET_LOCALE (term->rs[Rs_imLocale]); 1186 SET_LOCALE (term->rs[Rs_imLocale]);
1188 1187
1189 str = rxvt_temp_buf ((text->length + 1) * sizeof (wchar_t)); 1188 str = rxvt_temp_buf<wchar_t> (text->length + 1);
1190 mbstowcs ((wchar_t *)str, text->string.multi_byte, text->length + 1); 1189 mbstowcs (str, text->string.multi_byte, text->length + 1);
1191 1190
1192 if (term->rs[Rs_imLocale]) 1191 if (term->rs[Rs_imLocale])
1193 SET_LOCALE (term->locale); 1192 SET_LOCALE (term->locale);
1194 } 1193 }
1195 else 1194 else
1196 str = (void *)text->string.wide_char; 1195 str = text->string.wide_char;
1197 1196
1198 HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, 1197 HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW,
1199 DT_INT, call_data->caret, 1198 DT_INT, call_data->caret,
1200 DT_INT, call_data->chg_first, 1199 DT_INT, call_data->chg_first,
1201 DT_INT, call_data->chg_length, 1200 DT_INT, call_data->chg_length,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines