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