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.65 by pcg, Fri Apr 2 15:15:26 2004 UTC vs.
Revision 1.76 by root, Wed Aug 4 03:29:28 2004 UTC

1/*--------------------------------*-C-*---------------------------------*; 1/*--------------------------------*-C-*---------------------------------*
2 * File: main.c 2 * File: main.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
7 * - original version 7 * - original version
155 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), 155 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
156#endif 156#endif
157#ifdef TEXT_BLINK 157#ifdef TEXT_BLINK
158 text_blink_ev (this, &rxvt_term::text_blink_cb), 158 text_blink_ev (this, &rxvt_term::text_blink_cb),
159#endif 159#endif
160#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
161 cont_scroll_ev (this, &rxvt_term::cont_scroll_cb),
162#endif
163#ifdef SELECTION_SCROLLING
164 sel_scroll_ev (this, &rxvt_term::sel_scroll_cb),
165#endif
166#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
167 slip_wheel_ev (this, &rxvt_term::slip_wheel_cb),
168#endif
160#ifdef POINTER_BLANK 169#ifdef POINTER_BLANK
161 pointer_ev (this, &rxvt_term::pointer_cb), 170 pointer_ev (this, &rxvt_term::pointer_cb),
162#endif 171#endif
163#ifdef USE_XIM 172#ifdef USE_XIM
164 im_ev (this, &rxvt_term::im_cb), 173 im_ev (this, &rxvt_term::im_cb),
165#endif 174#endif
166 check_ev (this, &rxvt_term::check_cb), 175 check_ev (this, &rxvt_term::check_cb),
176 flush_ev (this, &rxvt_term::flush_cb),
167 destroy_ev (this, &rxvt_term::destroy_cb), 177 destroy_ev (this, &rxvt_term::destroy_cb),
168 pty_ev (this, &rxvt_term::pty_cb), 178 pty_ev (this, &rxvt_term::pty_cb),
169 incr_ev (this, &rxvt_term::incr_cb) 179 incr_ev (this, &rxvt_term::incr_cb)
170{ 180{
171 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 181 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
233 XDestroyWindow (display->display, TermWin.parent[0]); 243 XDestroyWindow (display->display, TermWin.parent[0]);
234 } 244 }
235 245
236 // TODO: free pixcolours, colours should become part of rxvt_display 246 // TODO: free pixcolours, colours should become part of rxvt_display
237 247
238 delete PixColors; 248 delete PixColorsFocused;
249#ifdef OFF_FOCUS_FADING
250 delete PixColorsUnFocused;
251#endif
239 252
240 displays.put (display); 253 displays.put (display);
241 254
242 scr_release (); 255 scr_release ();
243 256
285#ifdef CURSOR_BLINK 298#ifdef CURSOR_BLINK
286 cursor_blink_ev.stop (); 299 cursor_blink_ev.stop ();
287#endif 300#endif
288#ifdef TEXT_BLINK 301#ifdef TEXT_BLINK
289 text_blink_ev.stop (); 302 text_blink_ev.stop ();
303#endif
304#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
305 cont_scroll_ev.stop ();
306#endif
307#ifdef SELECTION_SCROLLING
308 sel_scroll_ev.stop ();
290#endif 309#endif
291#ifdef POINTER_BLANK 310#ifdef POINTER_BLANK
292 pointer_ev.stop (); 311 pointer_ev.stop ();
293#endif 312#endif
294 313
740 max_height = MAX_ROWS * TermWin.fheight; 759 max_height = MAX_ROWS * TermWin.fheight;
741 760
742 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; 761 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth;
743 762
744 sb_w = mb_h = 0; 763 sb_w = mb_h = 0;
745 window_vt_x = window_vt_y = 0; 764 window_vt_x = window_vt_y = TermWin.int_bwidth;
765
746 if (scrollbar_visible ()) 766 if (scrollbar_visible ())
747 { 767 {
748 sb_w = scrollbar_TotalWidth (); 768 sb_w = scrollbar_TotalWidth ();
749 szHint.base_width += sb_w; 769 szHint.base_width += sb_w;
750 if (! (Options & Opt_scrollBar_right)) 770 if (!(Options & Opt_scrollBar_right))
751 window_vt_x = sb_w; 771 window_vt_x += sb_w;
752 } 772 }
773
753 if (menubar_visible ()) 774 if (menubar_visible ())
754 { 775 {
755 mb_h = menuBar_TotalHeight (); 776 mb_h = menuBar_TotalHeight ();
756 szHint.base_height += mb_h; 777 szHint.base_height += mb_h;
757 window_vt_y = mb_h; 778 window_vt_y += mb_h;
758 } 779 }
780
759 szHint.width_inc = TermWin.fwidth; 781 szHint.width_inc = TermWin.fwidth;
760 szHint.height_inc = TermWin.fheight; 782 szHint.height_inc = TermWin.fheight;
761 szHint.min_width = szHint.base_width + szHint.width_inc; 783 szHint.min_width = szHint.base_width + szHint.width_inc;
762 szHint.min_height = szHint.base_height + szHint.height_inc; 784 szHint.min_height = szHint.base_height + szHint.height_inc;
763 785
769 else 791 else
770 { 792 {
771 MIN_IT (TermWin.width, max_width); 793 MIN_IT (TermWin.width, max_width);
772 szHint.width = szHint.base_width + TermWin.width; 794 szHint.width = szHint.base_width + TermWin.width;
773 } 795 }
796
774 if (height && height - szHint.base_height < max_height) 797 if (height && height - szHint.base_height < max_height)
775 { 798 {
776 szHint.height = height; 799 szHint.height = height;
777 TermWin.height = height - szHint.base_height; 800 TermWin.height = height - szHint.base_height;
778 } 801 }
779 else 802 else
780 { 803 {
781 MIN_IT (TermWin.height, max_height); 804 MIN_IT (TermWin.height, max_height);
782 szHint.height = szHint.base_height + TermWin.height; 805 szHint.height = szHint.base_height + TermWin.height;
783 } 806 }
807
784 if (scrollbar_visible () && (Options & Opt_scrollBar_right)) 808 if (scrollbar_visible () && (Options & Opt_scrollBar_right))
785 window_sb_x = szHint.width - sb_w; 809 window_sb_x = szHint.width - sb_w;
786 810
787 if (recalc_x) 811 if (recalc_x)
788 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 812 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display))
863 resize_all_windows (0, 0, 0); 887 resize_all_windows (0, 0, 0);
864 scr_remap_chars (); 888 scr_remap_chars ();
865 scr_touch (true); 889 scr_touch (true);
866 } 890 }
867 891
892 for (unicode_t ch = 0x20; ch <= 0x7f; ch++)
893 TermWin.ascii_map [ch - 0x20] = fs->find_font (ch);
894
868 return true; 895 return true;
869 } 896 }
870 } 897 }
871 898
872 return false; 899 return false;
935 i = atoi (color); 962 i = atoi (color);
936 if (i >= 8 && i <= 15) 963 if (i >= 8 && i <= 15)
937 { /* bright colors */ 964 { /* bright colors */
938 i -= 8; 965 i -= 8;
939# ifndef NO_BRIGHTCOLOR 966# ifndef NO_BRIGHTCOLOR
940 PixColors[idx] = PixColors[minBrightCOLOR + i]; 967 PixColorsFocused[idx] = PixColorsFocused[minBrightCOLOR + i];
941 SET_PIXCOLOR (idx); 968 SET_PIXCOLOR (idx);
942 goto Done; 969 goto Done;
943# endif 970# endif
944 971
945 } 972 }
946 if (i >= 0 && i <= 7) 973 if (i >= 0 && i <= 7)
947 { /* normal colors */ 974 { /* normal colors */
948 PixColors[idx] = PixColors[minCOLOR + i]; 975 PixColorsFocused[idx] = PixColorsFocused[minCOLOR + i];
949 SET_PIXCOLOR (idx); 976 SET_PIXCOLOR (idx);
950 goto Done; 977 goto Done;
951 } 978 }
952 } 979 }
953 980
954 if (!rXParseAllocColor (& xcol, color)) 981 if (!rXParseAllocColor (& xcol, color))
955 return; 982 return;
956 983
957 /* XStoreColor (display->display, XCMAP, XColor*); */ 984 /* XStoreColor (display->display, display->cmap, XColor*); */
958 985
959 /* 986 /*
960 * FIXME: should free colors here, but no idea how to do it so instead, 987 * FIXME: should free colors here, but no idea how to do it so instead,
961 * so just keep gobbling up the colormap 988 * so just keep gobbling up the colormap
962 */ 989 */
965 if (PixColors[idx] == PixColors[i]) 992 if (PixColors[idx] == PixColors[i])
966 break; 993 break;
967 if (i > Color_White) 994 if (i > Color_White)
968 { 995 {
969 /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ 996 /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */
970 XFreeColors (display->display, XCMAP, (PixColors + idx), 1, 997 XFreeColors (display->display, display->cmap, (PixColors + idx), 1,
971 DisplayPlanes (display->display, display->screen)); 998 DisplayPlanes (display->display, display->screen));
972 } 999 }
973# endif 1000# endif
974 1001
975 PixColors[idx] = xcol; 1002 PixColorsFocused[idx] = xcol;
976 SET_PIXCOLOR (idx); 1003 SET_PIXCOLOR (idx);
977 1004
978 /* XSetWindowAttributes attr; */ 1005 /* XSetWindowAttributes attr; */
979 /* Cursor cursor; */ 1006 /* Cursor cursor; */
980Done: 1007Done:
1008#ifdef OFF_FOCUS_FADING
1009 PixColorsUnFocused[idx] = PixColorsFocused[idx].fade (display, atoi (rs[Rs_fade]));
1010#endif
981 if (idx == Color_bg && ! (Options & Opt_transparent)) 1011 if (idx == Color_bg && ! (Options & Opt_transparent))
982 XSetWindowBackground (display->display, TermWin.vt, 1012 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
983 PixColors[Color_bg]);
984 1013
985 /* handle Color_BD, scrollbar background, etc. */ 1014 /* handle Color_BD, scrollbar background, etc. */
986 1015
987 set_colorfgbg (); 1016 set_colorfgbg ();
988 recolour_cursor (); 1017 recolour_cursor ();
996void 1025void
997rxvt_term::recolour_cursor () 1026rxvt_term::recolour_cursor ()
998{ 1027{
999 XColor xcol[2]; 1028 XColor xcol[2];
1000 1029
1001 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg]; 1030 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColorsFocused[Color_pointer_fg] : PixColorsFocused[Color_fg];
1002 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColors[Color_pointer_bg] : PixColors[Color_bg]; 1031 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColorsFocused[Color_pointer_bg] : PixColorsFocused[Color_bg];
1003 XQueryColors (display->display, XCMAP, xcol, 2); 1032 XQueryColors (display->display, display->cmap, xcol, 2);
1004 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1); 1033 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
1005} 1034}
1006 1035
1007/*----------------------------------------------------------------------*/ 1036/*----------------------------------------------------------------------*/
1008/* 1037/*
1079 int old_width = szHint.width, old_height = szHint.height; 1108 int old_width = szHint.width, old_height = szHint.height;
1080#endif 1109#endif
1081 1110
1082 window_calc (width, height); 1111 window_calc (width, height);
1083 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1112 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint);
1113
1084 if (!ignoreparent) 1114 if (!ignoreparent)
1085 { 1115 {
1086#ifdef SMART_RESIZE 1116#ifdef SMART_RESIZE
1087 /* 1117 /*
1088 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> 1118 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt>
1123 dy /= 2; 1153 dy /= 2;
1124 1154
1125 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1155 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy,
1126 szHint.width, szHint.height); 1156 szHint.width, szHint.height);
1127#else 1157#else
1128 XResizeWindow (display->display, TermWin.parent[0], szHint.width, 1158 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height);
1129 szHint.height);
1130#endif 1159#endif
1131
1132 } 1160 }
1133 1161
1134 fix_screen = (TermWin.ncol != prev_ncol 1162 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1135 || TermWin.nrow != prev_nrow);
1136 1163
1137 if (fix_screen || width != old_width || height != old_height) 1164 if (fix_screen || width != old_width || height != old_height)
1138 { 1165 {
1139 if (scrollbar_visible ()) 1166 if (scrollbar_visible ())
1140 { 1167 {
1141 XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, 1168 XMoveResizeWindow (display->display, scrollBar.win,
1169 window_sb_x, 0,
1142 0, scrollbar_TotalWidth (), szHint.height); 1170 scrollbar_TotalWidth (), szHint.height);
1143 resize_scrollbar (); 1171 resize_scrollbar ();
1144 } 1172 }
1145 1173
1146 if (menubar_visible ()) 1174 if (menubar_visible ())
1147 XMoveResizeWindow (display->display, menuBar.win, window_vt_x, 1175 XMoveResizeWindow (display->display, menuBar.win,
1176 window_vt_x, 0,
1148 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); 1177 TermWin_TotalWidth (), menuBar_TotalHeight ());
1149 1178
1150 XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, 1179 XMoveResizeWindow (display->display, TermWin.vt,
1151 window_vt_y, TermWin_TotalWidth (), 1180 window_vt_x, window_vt_y,
1152 TermWin_TotalHeight ()); 1181 TermWin_TotalWidth (), TermWin_TotalHeight ());
1153 scr_clear (height != old_height); 1182 scr_clear ();
1154#ifdef XPM_BACKGROUND 1183#ifdef XPM_BACKGROUND
1155 resize_pixmap (); 1184 resize_pixmap ();
1156#endif 1185#endif
1157
1158 } 1186 }
1159 1187
1160 if (fix_screen || old_height == 0) 1188 if (fix_screen || old_height == 0)
1161 { 1189 {
1162 int curr_screen = -1; 1190 int curr_screen = -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines