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.16 by pcg, Thu Dec 18 07:31:19 2003 UTC vs.
Revision 1.21 by pcg, Thu Jan 29 23:26:01 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: main.c 2 * File: main.c
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * $Id: main.C,v 1.16 2003/12/18 07:31:19 pcg Exp $ 4 * $Id: main.C,v 1.21 2004/01/29 23:26:01 pcg Exp $
5 * 5 *
6 * All portions of code are copyright by their respective author/s. 6 * All portions of code are copyright by their respective author/s.
7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 7 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
8 * - original version 8 * - original version
9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> 9 * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
72{ 72{
73 free (p); 73 free (p);
74} 74}
75 75
76rxvt_term::rxvt_term () 76rxvt_term::rxvt_term ()
77: pty_ev (this, &rxvt_term::pty_cb), 77: destroy_ev (this, &rxvt_term::destroy_cb),
78#ifdef CURSOR_BLINK 78#ifdef CURSOR_BLINK
79 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
80#endif
81#ifdef TEXT_BLINK
79 blink_ev (this, &rxvt_term::blink_cb), 82 text_blink_ev (this, &rxvt_term::text_blink_cb),
80#endif 83#endif
81#ifdef POINTER_BLANK 84#ifdef POINTER_BLANK
82 pointer_ev (this, &rxvt_term::pointer_cb), 85 pointer_ev (this, &rxvt_term::pointer_cb),
83#endif 86#endif
84 x_ev (this, &rxvt_term::x_cb), 87 x_ev (this, &rxvt_term::x_cb),
85 destroy_ev (this, &rxvt_term::destroy_cb),
86 check_ev (this, &rxvt_term::check_cb), 88 check_ev (this, &rxvt_term::check_cb),
87 incr_ev (this, &rxvt_term::incr_cb) 89 incr_ev (this, &rxvt_term::incr_cb),
90 pty_ev (this, &rxvt_term::pty_cb)
88{ 91{
89 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 92 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
90} 93}
91 94
92rxvt_term::~rxvt_term () 95rxvt_term::~rxvt_term ()
124{ 127{
125 check_ev.stop (); 128 check_ev.stop ();
126 pty_ev.stop (); 129 pty_ev.stop ();
127 x_ev.stop (); 130 x_ev.stop ();
128#ifdef CURSOR_BLINK 131#ifdef CURSOR_BLINK
132 cursor_blink_ev.stop ();
133#endif
134#ifdef TEXT_BLINK
129 blink_ev.stop (); 135 text_blink_ev.stop ();
130#endif 136#endif
131#ifdef POINTER_BLANK 137#ifdef POINTER_BLANK
132 pointer_ev.stop (); 138 pointer_ev.stop ();
133#endif 139#endif
134 140
216#ifdef HAVE_SCROLLBARS 222#ifdef HAVE_SCROLLBARS
217 if (Options & Opt_scrollBar) 223 if (Options & Opt_scrollBar)
218 scrollBar.setIdle (); /* set existence for size calculations */ 224 scrollBar.setIdle (); /* set existence for size calculations */
219#endif 225#endif
220 226
221 rxvt_Create_Windows (this, argc, argv); 227 create_windows (argc, argv);
222 228
223 init_xlocale (); 229 init_xlocale ();
224 230
225 scr_reset (); /* initialize screen */ 231 scr_reset (); /* initialize screen */
226#ifdef RXVT_GRAPHICS 232#ifdef RXVT_GRAPHICS
233#endif 239#endif
234#endif 240#endif
235 241
236#ifdef HAVE_SCROLLBARS 242#ifdef HAVE_SCROLLBARS
237 if (Options & Opt_scrollBar) 243 if (Options & Opt_scrollBar)
238 rxvt_Resize_scrollBar (this); /* create and map scrollbar */ 244 resize_scrollbar (); /* create and map scrollbar */
239#endif 245#endif
240#if (MENUBAR_MAX) 246#if (MENUBAR_MAX)
241 if (menubar_visible(r)) 247 if (menubar_visible(r))
242 XMapWindow (Xdisplay, menuBar.win); 248 XMapWindow (Xdisplay, menuBar.win);
243#endif 249#endif
521/*----------------------------------------------------------------------*/ 527/*----------------------------------------------------------------------*/
522/* 528/*
523 * window size/position calculcations for XSizeHint and other storage. 529 * window size/position calculcations for XSizeHint and other storage.
524 * if width/height are non-zero then override calculated width/height 530 * if width/height are non-zero then override calculated width/height
525 */ 531 */
526/* EXTPROTO */
527void 532void
528rxvt_window_calc(pR_ unsigned int width, unsigned int height) 533rxvt_term::window_calc (unsigned int width, unsigned int height)
529{ 534{
530 short recalc_x, recalc_y; 535 short recalc_x, recalc_y;
531 int x, y, sb_w, mb_h, flags; 536 int x, y, sb_w, mb_h, flags;
532 unsigned int w, h; 537 unsigned int w, h;
533 unsigned int max_width, max_height; 538 unsigned int max_width, max_height;
534 539
535 D_SIZE((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 540 D_SIZE((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
536 R->TermWin.ncol, R->TermWin.nrow, R->szHint.width, 541 TermWin.ncol, TermWin.nrow, szHint.width,
537 R->szHint.height)); 542 szHint.height));
538 R->szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; 543 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
539 R->szHint.win_gravity = NorthWestGravity; 544 szHint.win_gravity = NorthWestGravity;
540/* R->szHint.min_aspect.x = R->szHint.min_aspect.y = 1; */ 545/* szHint.min_aspect.x = szHint.min_aspect.y = 1; */
541 546
542 recalc_x = recalc_y = 0; 547 recalc_x = recalc_y = 0;
543 flags = 0; 548 flags = 0;
544 if (!R->parsed_geometry) { 549 if (!parsed_geometry) {
545 R->parsed_geometry = 1; 550 parsed_geometry = 1;
546 if (R->rs[Rs_geometry]) 551 if (rs[Rs_geometry])
547 flags = XParseGeometry(R->rs[Rs_geometry], &x, &y, &w, &h); 552 flags = XParseGeometry(rs[Rs_geometry], &x, &y, &w, &h);
548 if (flags & WidthValue) { 553 if (flags & WidthValue) {
549 R->TermWin.ncol = BOUND_POSITIVE_INT16(w); 554 TermWin.ncol = BOUND_POSITIVE_INT16(w);
550 R->szHint.flags |= USSize; 555 szHint.flags |= USSize;
551 } 556 }
552 if (flags & HeightValue) { 557 if (flags & HeightValue) {
553 R->TermWin.nrow = BOUND_POSITIVE_INT16(h); 558 TermWin.nrow = BOUND_POSITIVE_INT16(h);
554 R->szHint.flags |= USSize; 559 szHint.flags |= USSize;
555 } 560 }
556 if (flags & XValue) { 561 if (flags & XValue) {
557 R->szHint.x = x; 562 szHint.x = x;
558 R->szHint.flags |= USPosition; 563 szHint.flags |= USPosition;
559 if (flags & XNegative) { 564 if (flags & XNegative) {
560 recalc_x = 1; 565 recalc_x = 1;
561 R->szHint.win_gravity = NorthEastGravity; 566 szHint.win_gravity = NorthEastGravity;
562 } 567 }
563 } 568 }
564 if (flags & YValue) { 569 if (flags & YValue) {
565 R->szHint.y = y; 570 szHint.y = y;
566 R->szHint.flags |= USPosition; 571 szHint.flags |= USPosition;
567 if (flags & YNegative) { 572 if (flags & YNegative) {
568 recalc_y = 1; 573 recalc_y = 1;
569 if (R->szHint.win_gravity == NorthEastGravity) 574 if (szHint.win_gravity == NorthEastGravity)
570 R->szHint.win_gravity = SouthEastGravity; 575 szHint.win_gravity = SouthEastGravity;
571 else 576 else
572 R->szHint.win_gravity = SouthWestGravity; 577 szHint.win_gravity = SouthWestGravity;
573 } 578 }
574 } 579 }
575 } 580 }
576/* TODO: BOUNDS */ 581/* TODO: BOUNDS */
577 R->TermWin.width = R->TermWin.ncol * R->TermWin.fwidth; 582 TermWin.width = TermWin.ncol * TermWin.fwidth;
578 R->TermWin.height = R->TermWin.nrow * R->TermWin.fheight; 583 TermWin.height = TermWin.nrow * TermWin.fheight;
579 max_width = MAX_COLS * R->TermWin.fwidth; 584 max_width = MAX_COLS * TermWin.fwidth;
580 max_height = MAX_ROWS * R->TermWin.fheight; 585 max_height = MAX_ROWS * TermWin.fheight;
581 586
582 R->szHint.base_width = R->szHint.base_height = 2 * R->TermWin.int_bwidth; 587 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth;
583 588
584 sb_w = mb_h = 0; 589 sb_w = mb_h = 0;
585 R->window_vt_x = R->window_vt_y = 0; 590 window_vt_x = window_vt_y = 0;
586 if (scrollbar_visible(R)) { 591 if (scrollbar_visible (this)) {
587 sb_w = scrollbar_TotalWidth(); 592 sb_w = scrollbar_TotalWidth();
588 R->szHint.base_width += sb_w; 593 szHint.base_width += sb_w;
589 if (!(R->Options & Opt_scrollBar_right)) 594 if (!(Options & Opt_scrollBar_right))
590 R->window_vt_x = sb_w; 595 window_vt_x = sb_w;
591 } 596 }
592 if (menubar_visible(R)) { 597 if (menubar_visible (this)) {
593 mb_h = menuBar_TotalHeight(); 598 mb_h = menuBar_TotalHeight();
594 R->szHint.base_height += mb_h; 599 szHint.base_height += mb_h;
595 R->window_vt_y = mb_h; 600 window_vt_y = mb_h;
596 } 601 }
597 R->szHint.width_inc = R->TermWin.fwidth; 602 szHint.width_inc = TermWin.fwidth;
598 R->szHint.height_inc = R->TermWin.fheight; 603 szHint.height_inc = TermWin.fheight;
599 R->szHint.min_width = R->szHint.base_width + R->szHint.width_inc; 604 szHint.min_width = szHint.base_width + szHint.width_inc;
600 R->szHint.min_height = R->szHint.base_height + R->szHint.height_inc; 605 szHint.min_height = szHint.base_height + szHint.height_inc;
601 606
602 if (width && width - R->szHint.base_width < max_width) { 607 if (width && width - szHint.base_width < max_width) {
603 R->szHint.width = width; 608 szHint.width = width;
604 R->TermWin.width = width - R->szHint.base_width; 609 TermWin.width = width - szHint.base_width;
605 } else { 610 } else {
606 MIN_IT(R->TermWin.width, max_width); 611 MIN_IT(TermWin.width, max_width);
607 R->szHint.width = R->szHint.base_width + R->TermWin.width; 612 szHint.width = szHint.base_width + TermWin.width;
608 } 613 }
609 if (height && height - R->szHint.base_height < max_height) { 614 if (height && height - szHint.base_height < max_height) {
610 R->szHint.height = height; 615 szHint.height = height;
611 R->TermWin.height = height - R->szHint.base_height; 616 TermWin.height = height - szHint.base_height;
612 } else { 617 } else {
613 MIN_IT(R->TermWin.height, max_height); 618 MIN_IT(TermWin.height, max_height);
614 R->szHint.height = R->szHint.base_height + R->TermWin.height; 619 szHint.height = szHint.base_height + TermWin.height;
615 } 620 }
616 if (scrollbar_visible(R) && (R->Options & Opt_scrollBar_right)) 621 if (scrollbar_visible (this) && (Options & Opt_scrollBar_right))
617 R->window_sb_x = R->szHint.width - sb_w; 622 window_sb_x = szHint.width - sb_w;
618 623
619 if (recalc_x) 624 if (recalc_x)
620 R->szHint.x += (DisplayWidth(R->Xdisplay, Xscreen) 625 szHint.x += (DisplayWidth (Xdisplay, DefaultScreen (Xdisplay))
621 - R->szHint.width - 2 * R->TermWin.ext_bwidth); 626 - szHint.width - 2 * TermWin.ext_bwidth);
622 if (recalc_y) 627 if (recalc_y)
623 R->szHint.y += (DisplayHeight(R->Xdisplay, Xscreen) 628 szHint.y += (DisplayHeight (Xdisplay, DefaultScreen (Xdisplay))
624 - R->szHint.height - 2 * R->TermWin.ext_bwidth); 629 - szHint.height - 2 * TermWin.ext_bwidth);
625 630
626 R->TermWin.ncol = R->TermWin.width / R->TermWin.fwidth; 631 TermWin.ncol = TermWin.width / TermWin.fwidth;
627 R->TermWin.nrow = R->TermWin.height / R->TermWin.fheight; 632 TermWin.nrow = TermWin.height / TermWin.fheight;
628 D_SIZE((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 633 D_SIZE((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
629 R->TermWin.ncol, R->TermWin.nrow, R->szHint.width, 634 TermWin.ncol, TermWin.nrow, szHint.width,
630 R->szHint.height)); 635 szHint.height));
631 return; 636 return;
632} 637}
633 638
634/*----------------------------------------------------------------------*/ 639/*----------------------------------------------------------------------*/
635/* 640/*
637 * Called after a window size change. 642 * Called after a window size change.
638 */ 643 */
639void 644void
640rxvt_term::tt_winch () 645rxvt_term::tt_winch ()
641{ 646{
642 struct winsize ws; 647 struct winsize ws;
643 648
644 if (cmd_fd < 0) 649 if (cmd_fd < 0)
645 return; 650 return;
646 651
647 ws.ws_col = TermWin.ncol; 652 ws.ws_col = TermWin.ncol;
864} 869}
865 870
866/* -------------------------------------------------------------------- * 871/* -------------------------------------------------------------------- *
867 * - WINDOW RESIZING - * 872 * - WINDOW RESIZING - *
868 * -------------------------------------------------------------------- */ 873 * -------------------------------------------------------------------- */
869/* EXTPROTO */
870void 874void
871rxvt_resize_all_windows(pR_ unsigned int width, unsigned int height, 875rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent)
872 int ignoreparent)
873{ 876{
874 int fix_screen; 877 int fix_screen;
875 878
876#ifdef SMART_RESIZE 879#ifdef SMART_RESIZE
877 int old_width = R->szHint.width, old_height = R->szHint.height; 880 int old_width = szHint.width, old_height = szHint.height;
878#endif 881#endif
879 882
880 rxvt_window_calc(aR_ width, height); 883 window_calc (width, height);
881 XSetWMNormalHints(R->Xdisplay, R->TermWin.parent[0], &R->szHint); 884 XSetWMNormalHints (Xdisplay, TermWin.parent[0], &szHint);
882 if (!ignoreparent) { 885 if (!ignoreparent)
886 {
883#ifdef SMART_RESIZE 887#ifdef SMART_RESIZE
884/* 888 /*
885 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> 889 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt>
886 * reposition window on resize depending on placement on screen 890 * reposition window on resize depending on placement on screen
887 */ 891 */
888 int x, y, x1, y1; 892 int x, y, x1, y1;
889 int dx, dy; 893 int dx, dy;
890 unsigned int unused_w1, unused_h1, unused_b1, unused_d1; 894 unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
891 Window unused_cr; 895 Window unused_cr;
892 896
893 XTranslateCoordinates(R->Xdisplay, R->TermWin.parent[0], Xroot, 897 XTranslateCoordinates (Xdisplay, TermWin.parent[0], Xroot,
894 0, 0, &x, &y, &unused_cr); 898 0, 0, &x, &y, &unused_cr);
895 XGetGeometry(R->Xdisplay, R->TermWin.parent[0], &unused_cr, &x1, &y1, 899 XGetGeometry (Xdisplay, TermWin.parent[0], &unused_cr, &x1, &y1,
896 &unused_w1, &unused_h1, &unused_b1, &unused_d1); 900 &unused_w1, &unused_h1, &unused_b1, &unused_d1);
897 /* 901 /*
898 * if Xroot isn't the parent window, a WM will probably have offset 902 * if Xroot isn't the parent window, a WM will probably have offset
899 * our position for handles and decorations. Counter it 903 * our position for handles and decorations. Counter it
900 */ 904 */
901 if (x1 != x || y1 != y) { 905 if (x1 != x || y1 != y) {
902 x -= x1; 906 x -= x1;
903 y -= y1; 907 y -= y1;
908 }
909
910 x1 = (DisplayWidth (Xdisplay, Xscreen) - old_width) / 2;
911 y1 = (DisplayHeight (Xdisplay, Xscreen) - old_height) / 2;
912 dx = old_width - szHint.width;
913 dy = old_height - szHint.height;
914
915 /* Check position of the center of the window */
916 if (x < x1) /* left half */
917 dx = 0;
918 else if (x == x1) /* exact center */
919 dx /= 2;
920 if (y < y1) /* top half */
921 dy = 0;
922 else if (y == y1) /* exact center */
923 dy /= 2;
924
925 XMoveResizeWindow (Xdisplay, TermWin.parent[0], x + dx, y + dy,
926 szHint.width, szHint.height);
927#else
928 XResizeWindow (Xdisplay, TermWin.parent[0], szHint.width,
929 szHint.height);
930#endif
931 }
932
933 fix_screen = (TermWin.ncol != prev_ncol
934 || TermWin.nrow != prev_nrow);
935
936 if (fix_screen || width != old_width || height != old_height)
937 {
938 if (scrollbar_visible (this))
939 {
940 XMoveResizeWindow (Xdisplay, scrollBar.win, window_sb_x,
941 0, scrollbar_TotalWidth (), szHint.height);
942 resize_scrollbar ();
904 } 943 }
905 944
906 x1 = (DisplayWidth(R->Xdisplay, Xscreen) - old_width) / 2; 945 if (menubar_visible (this))
907 y1 = (DisplayHeight(R->Xdisplay, Xscreen) - old_height) / 2; 946 XMoveResizeWindow (Xdisplay, menuBar.win, window_vt_x,
908 dx = old_width - R->szHint.width; 947 0, TermWin_TotalWidth (), menuBar_TotalHeight ());
909 dy = old_height - R->szHint.height;
910 948
911 /* Check position of the center of the window */ 949 XMoveResizeWindow (Xdisplay, TermWin.vt, window_vt_x,
912 if (x < x1) /* left half */ 950 window_vt_y, TermWin_TotalWidth (),
913 dx = 0; 951 TermWin_TotalHeight ());
914 else if (x == x1) /* exact center */ 952#ifdef RXVT_GRAPHICS
915 dx /= 2; 953 if (old_height)
916 if (y < y1) /* top half */ 954 rxvt_Gr_Resize (this, old_width - szHint.base_width,
917 dy = 0;
918 else if (y == y1) /* exact center */
919 dy /= 2;
920
921 XMoveResizeWindow(R->Xdisplay, R->TermWin.parent[0], x + dx, y + dy,
922 R->szHint.width, R->szHint.height);
923#else
924 XResizeWindow(R->Xdisplay, R->TermWin.parent[0], R->szHint.width,
925 R->szHint.height); 955 old_height - szHint.base_height);
926#endif 956#endif
957 scr_clear ();
958#ifdef XPM_BACKGROUND
959 rxvt_resize_pixmap (this);
960#endif
961 }
962
963 if (fix_screen || old_height == 0)
927 } 964 {
965 int curr_screen = -1;
966 int old_ncol = prev_ncol;
928 967
929 fix_screen = (R->TermWin.ncol != R->prev_ncol 968 /* scr_reset only works on the primary screen */
930 || R->TermWin.nrow != R->prev_nrow); 969 if (old_height) /* this is not the first time through */
931 if (fix_screen || width != R->old_width || height != R->old_height) { 970 {
932 if (scrollbar_visible(R)) { 971 unsigned int ncol = TermWin.ncol;
933 XMoveResizeWindow(R->Xdisplay, R->scrollBar.win, R->window_sb_x, 972 TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this
934 0, scrollbar_TotalWidth(), R->szHint.height); 973 curr_screen = rxvt_scr_change_screen (this, PRIMARY);
935 rxvt_Resize_scrollBar(aR); 974 TermWin.ncol = ncol;
936 } 975 }
937 if (menubar_visible(R))
938 XMoveResizeWindow(R->Xdisplay, R->menuBar.win, R->window_vt_x,
939 0, TermWin_TotalWidth(), menuBar_TotalHeight());
940 XMoveResizeWindow(R->Xdisplay, R->TermWin.vt, R->window_vt_x,
941 R->window_vt_y, TermWin_TotalWidth(),
942 TermWin_TotalHeight());
943#ifdef RXVT_GRAPHICS
944 if (R->old_height)
945 rxvt_Gr_Resize(aR_ R->old_width - R->szHint.base_width,
946 R->old_height - R->szHint.base_height);
947#endif
948 rxvt_scr_clear(aR);
949#ifdef XPM_BACKGROUND
950 rxvt_resize_pixmap(aR);
951#endif
952 }
953 976
954 if (fix_screen || R->old_height == 0) {
955 int curr_screen = -1;
956 uint16_t old_ncol = R->prev_ncol;
957
958 /* scr_reset only works on the primary screen */
959 if (R->old_height) /* this is not the first time through */
960 curr_screen = rxvt_scr_change_screen(aR_ PRIMARY);
961
962 R->scr_reset(); 977 scr_reset();
963 978
964 if (curr_screen >= 0) { /* this is not the first time through */ 979 if (curr_screen >= 0) /* this is not the first time through */
980 {
965 rxvt_scr_change_screen(aR_ curr_screen); 981 rxvt_scr_change_screen (this, curr_screen);
966 rxvt_selection_check(aR_(old_ncol != R->TermWin.ncol ? 4 : 0)); 982 rxvt_selection_check (this, old_ncol != TermWin.ncol ? 4 : 0);
967 } 983 }
968 } 984 }
969 985
970 R->old_width = R->szHint.width; 986 old_width = szHint.width;
971 R->old_height = R->szHint.height; 987 old_height = szHint.height;
972 988
973#ifdef USE_XIM 989#ifdef USE_XIM
974 rxvt_IMSetStatusPosition(aR); 990 rxvt_IMSetStatusPosition (this);
975#endif 991#endif
976} 992}
977 993
978/* 994/*
979 * Set the width/height of the vt window in characters. Units are pixels. 995 * Set the width/height of the vt window in characters. Units are pixels.
993 height = wattr.height - R->szHint.base_height; 1009 height = wattr.height - R->szHint.base_height;
994 } 1010 }
995 if (width != R->TermWin.width || height != R->TermWin.height) { 1011 if (width != R->TermWin.width || height != R->TermWin.height) {
996 width += R->szHint.base_width; 1012 width += R->szHint.base_width;
997 height += R->szHint.base_height; 1013 height += R->szHint.base_height;
998 rxvt_resize_all_windows(aR_ width, height, 0); 1014 R->resize_all_windows (width, height, 0);
999 } 1015 }
1000} 1016}
1001 1017
1002/* -------------------------------------------------------------------- * 1018/* -------------------------------------------------------------------- *
1003 * - X INPUT METHOD ROUTINES - * 1019 * - X INPUT METHOD ROUTINES - *
1004 * -------------------------------------------------------------------- */ 1020 * -------------------------------------------------------------------- */
1005#ifdef USE_XIM 1021#ifdef USE_XIM
1006/* INTPROTO */
1007void 1022void
1008rxvt_setSize(pR_ XRectangle * size) 1023rxvt_term::set_size (XRectangle *size)
1009{ 1024{
1010 size->x = R->TermWin.int_bwidth; 1025 size->x = TermWin.int_bwidth;
1011 size->y = R->TermWin.int_bwidth; 1026 size->y = TermWin.int_bwidth;
1012 size->width = Width2Pixel(R->TermWin.ncol); 1027 size->width = Width2Pixel(TermWin.ncol);
1013 size->height = Height2Pixel(R->TermWin.nrow); 1028 size->height = Height2Pixel(TermWin.nrow);
1014} 1029}
1015 1030
1016/* INTPROTO */
1017void 1031void
1018rxvt_setColor(pR_ unsigned long *fg, unsigned long *bg) 1032rxvt_term::set_color (unsigned long *fg, unsigned long *bg)
1019{ 1033{
1020 *fg = R->PixColors[Color_fg]; 1034 *fg = PixColors[Color_fg];
1021 *bg = R->PixColors[Color_bg]; 1035 *bg = PixColors[Color_bg];
1022} 1036}
1023 1037
1024/* Checking whether input method is running. */ 1038/* Checking whether input method is running. */
1025/* INTPROTO */ 1039/* INTPROTO */
1026Bool 1040Bool
1061 || R->event_type == SelectionNotify 1075 || R->event_type == SelectionNotify
1062 || R->event_type == ButtonRelease || R->event_type == FocusIn) 1076 || R->event_type == ButtonRelease || R->event_type == FocusIn)
1063 || !rxvt_IMisRunning(aR)) 1077 || !rxvt_IMisRunning(aR))
1064 return; 1078 return;
1065 1079
1066 rxvt_setPosition(aR_ & spot); 1080 R->set_position (&spot);
1067 1081
1068 preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); 1082 preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
1069 XSetICValues(R->Input_Context, XNPreeditAttributes, preedit_attr, NULL); 1083 XSetICValues(R->Input_Context, XNPreeditAttributes, preedit_attr, NULL);
1070 XFree(preedit_attr); 1084 XFree(preedit_attr);
1071} 1085}
1072 1086
1073/* INTPROTO */
1074void 1087void
1075rxvt_setPreeditArea (pR_ XRectangle * preedit_rect, XRectangle * status_rect, 1088rxvt_term::set_preedit_area (XRectangle * preedit_rect, XRectangle * status_rect,
1076 XRectangle * needed_rect) 1089 XRectangle * needed_rect)
1077{ 1090{
1078 int mbh, vtx = 0; 1091 int mbh, vtx = 0;
1079 1092
1080 if (scrollbar_visible(R) && !(R->Options & Opt_scrollBar_right)) 1093 if (scrollbar_visible (this) && !(Options & Opt_scrollBar_right))
1081 vtx = scrollbar_TotalWidth(); 1094 vtx = scrollbar_TotalWidth();
1095
1082 mbh = menubar_visible(R) ? menuBar_TotalHeight() : 0; 1096 mbh = menubar_visible (this) ? menuBar_TotalHeight() : 0;
1083 mbh -= R->TermWin.lineSpace; 1097 mbh -= TermWin.lineSpace;
1084 1098
1085 preedit_rect->x = needed_rect->width + vtx; 1099 preedit_rect->x = needed_rect->width + vtx;
1086 preedit_rect->y = Height2Pixel(R->TermWin.nrow - 1) + mbh; 1100 preedit_rect->y = Height2Pixel(TermWin.nrow - 1) + mbh;
1087 1101
1088 preedit_rect->width = Width2Pixel(R->TermWin.ncol + 1) - needed_rect->width 1102 preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width + vtx;
1089 + vtx;
1090 preedit_rect->height = Height2Pixel(1); 1103 preedit_rect->height = Height2Pixel(1);
1091 1104
1092 status_rect->x = vtx; 1105 status_rect->x = vtx;
1093 status_rect->y = Height2Pixel(R->TermWin.nrow - 1) + mbh; 1106 status_rect->y = Height2Pixel(TermWin.nrow - 1) + mbh;
1094 1107
1095 status_rect->width = needed_rect->width ? needed_rect->width 1108 status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel(TermWin.ncol + 1);
1096 : Width2Pixel(R->TermWin.ncol + 1);
1097 status_rect->height = Height2Pixel(1); 1109 status_rect->height = Height2Pixel(1);
1098} 1110}
1099 1111
1100/* ARGSUSED */ 1112/* ARGSUSED */
1101/* INTPROTO */ 1113/* INTPROTO */
1102void 1114void
1176 XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL); 1188 XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL);
1177 1189
1178 preedit_attr = status_attr = NULL; 1190 preedit_attr = status_attr = NULL;
1179 1191
1180 if (R->input_style & XIMPreeditPosition) { 1192 if (R->input_style & XIMPreeditPosition) {
1181 rxvt_setSize(aR_ & rect); 1193 R->set_size (&rect);
1182 rxvt_setPosition(aR_ & spot); 1194 R->set_position (&spot);
1183 rxvt_setColor(aR_ & fg, &bg); 1195 R->set_color (&fg, &bg);
1184 1196
1185 preedit_attr = XVaCreateNestedList(0, XNArea, &rect, 1197 preedit_attr = XVaCreateNestedList(0, XNArea, &rect,
1186 XNSpotLocation, &spot, 1198 XNSpotLocation, &spot,
1187 XNForeground, fg, XNBackground, bg, 1199 XNForeground, fg, XNBackground, bg,
1188 //XNFontSet, R->TermWin.fontset, 1200 //XNFontSet, R->TermWin.fontset,
1189 NULL); 1201 NULL);
1190 } else if (R->input_style & XIMPreeditArea) { 1202 } else if (R->input_style & XIMPreeditArea) {
1191 rxvt_setColor(aR_ & fg, &bg); 1203 R->set_color (&fg, &bg);
1192 1204
1193 /* 1205 /*
1194 * The necessary width of preedit area is unknown 1206 * The necessary width of preedit area is unknown
1195 * until create input context. 1207 * until create input context.
1196 */ 1208 */
1197 needed_rect.width = 0; 1209 needed_rect.width = 0;
1198 1210
1199 rxvt_setPreeditArea(aR_ & rect, &status_rect, &needed_rect); 1211 R->set_preedit_area(&rect, &status_rect, &needed_rect);
1200 1212
1201 preedit_attr = XVaCreateNestedList(0, XNArea, &rect, 1213 preedit_attr = XVaCreateNestedList(0, XNArea, &rect,
1202 XNForeground, fg, XNBackground, bg, 1214 XNForeground, fg, XNBackground, bg,
1203 //XNFontSet, R->TermWin.fontset, 1215 //XNFontSet, R->TermWin.fontset,
1204 NULL); 1216 NULL);
1319/* Getting the necessary width of preedit area */ 1331/* Getting the necessary width of preedit area */
1320 status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL); 1332 status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL);
1321 XGetICValues(R->Input_Context, XNStatusAttributes, status_attr, NULL); 1333 XGetICValues(R->Input_Context, XNStatusAttributes, status_attr, NULL);
1322 XFree(status_attr); 1334 XFree(status_attr);
1323 1335
1324 rxvt_setPreeditArea(aR_ & preedit_rect, &status_rect, needed_rect); 1336 R->set_preedit_area(&preedit_rect, &status_rect, needed_rect);
1325 1337
1326 preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL); 1338 preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL);
1327 status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL); 1339 status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL);
1328 1340
1329 XSetICValues(R->Input_Context, 1341 XSetICValues(R->Input_Context,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines