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.77 by root, Tue Aug 10 20:39:19 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;
191 201
192 if (display) 202 if (display)
193 { 203 {
194 selection_clear (); 204 selection_clear ();
195 205
206#ifdef USE_XIM
207 im_destroy ();
208#endif
196#ifdef MENUBAR 209#ifdef MENUBAR
197 if (menubarGC) XFreeGC (display->display, menubarGC); 210 if (menubarGC) XFreeGC (display->display, menubarGC);
198#endif 211#endif
199#ifdef XTERM_SCROLLBAR 212#ifdef XTERM_SCROLLBAR
200 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); 213 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC);
233 XDestroyWindow (display->display, TermWin.parent[0]); 246 XDestroyWindow (display->display, TermWin.parent[0]);
234 } 247 }
235 248
236 // TODO: free pixcolours, colours should become part of rxvt_display 249 // TODO: free pixcolours, colours should become part of rxvt_display
237 250
238 delete PixColors; 251 delete PixColorsFocused;
252#ifdef OFF_FOCUS_FADING
253 delete PixColorsUnFocused;
254#endif
239 255
240 displays.put (display); 256 displays.put (display);
241 257
242 scr_release (); 258 scr_release ();
243 259
261} 277}
262 278
263void 279void
264rxvt_term::destroy () 280rxvt_term::destroy ()
265{ 281{
282 if (destroy_ev.active)
283 return;
284
266 if (display) 285 if (display)
267 { 286 {
287#ifdef USE_XIM
288 im_ev.stop (display);
289#endif
290#ifdef HAVE_SCROLLBARS
291 scrollbar_ev.stop (display);
292#endif
293#ifdef MENUBAR
294 menubar_ev.stop (display);
295#endif
268 rootwin_ev.stop (display); 296 rootwin_ev.stop (display);
269 termwin_ev.stop (display); 297 termwin_ev.stop (display);
270 vt_ev.stop (display); 298 vt_ev.stop (display);
271#ifdef USE_XIM
272 im_destroy ();
273 im_ev.stop (display);
274#endif
275#ifdef HAVE_SCROLLBARS
276 scrollbar_ev.stop (display);
277#endif
278#ifdef MENUBAR
279 menubar_ev.stop (display);
280#endif
281 } 299 }
282 300
283 check_ev.stop (); 301 check_ev.stop ();
284 pty_ev.stop (); 302 pty_ev.stop ();
285#ifdef CURSOR_BLINK 303#ifdef CURSOR_BLINK
286 cursor_blink_ev.stop (); 304 cursor_blink_ev.stop ();
287#endif 305#endif
288#ifdef TEXT_BLINK 306#ifdef TEXT_BLINK
289 text_blink_ev.stop (); 307 text_blink_ev.stop ();
308#endif
309#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
310 cont_scroll_ev.stop ();
311#endif
312#ifdef SELECTION_SCROLLING
313 sel_scroll_ev.stop ();
290#endif 314#endif
291#ifdef POINTER_BLANK 315#ifdef POINTER_BLANK
292 pointer_ev.stop (); 316 pointer_ev.stop ();
293#endif 317#endif
294 318
740 max_height = MAX_ROWS * TermWin.fheight; 764 max_height = MAX_ROWS * TermWin.fheight;
741 765
742 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; 766 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth;
743 767
744 sb_w = mb_h = 0; 768 sb_w = mb_h = 0;
745 window_vt_x = window_vt_y = 0; 769 window_vt_x = window_vt_y = TermWin.int_bwidth;
770
746 if (scrollbar_visible ()) 771 if (scrollbar_visible ())
747 { 772 {
748 sb_w = scrollbar_TotalWidth (); 773 sb_w = scrollbar_TotalWidth ();
749 szHint.base_width += sb_w; 774 szHint.base_width += sb_w;
750 if (! (Options & Opt_scrollBar_right)) 775 if (!(Options & Opt_scrollBar_right))
751 window_vt_x = sb_w; 776 window_vt_x += sb_w;
752 } 777 }
778
753 if (menubar_visible ()) 779 if (menubar_visible ())
754 { 780 {
755 mb_h = menuBar_TotalHeight (); 781 mb_h = menuBar_TotalHeight ();
756 szHint.base_height += mb_h; 782 szHint.base_height += mb_h;
757 window_vt_y = mb_h; 783 window_vt_y += mb_h;
758 } 784 }
785
759 szHint.width_inc = TermWin.fwidth; 786 szHint.width_inc = TermWin.fwidth;
760 szHint.height_inc = TermWin.fheight; 787 szHint.height_inc = TermWin.fheight;
761 szHint.min_width = szHint.base_width + szHint.width_inc; 788 szHint.min_width = szHint.base_width + szHint.width_inc;
762 szHint.min_height = szHint.base_height + szHint.height_inc; 789 szHint.min_height = szHint.base_height + szHint.height_inc;
763 790
769 else 796 else
770 { 797 {
771 MIN_IT (TermWin.width, max_width); 798 MIN_IT (TermWin.width, max_width);
772 szHint.width = szHint.base_width + TermWin.width; 799 szHint.width = szHint.base_width + TermWin.width;
773 } 800 }
801
774 if (height && height - szHint.base_height < max_height) 802 if (height && height - szHint.base_height < max_height)
775 { 803 {
776 szHint.height = height; 804 szHint.height = height;
777 TermWin.height = height - szHint.base_height; 805 TermWin.height = height - szHint.base_height;
778 } 806 }
779 else 807 else
780 { 808 {
781 MIN_IT (TermWin.height, max_height); 809 MIN_IT (TermWin.height, max_height);
782 szHint.height = szHint.base_height + TermWin.height; 810 szHint.height = szHint.base_height + TermWin.height;
783 } 811 }
812
784 if (scrollbar_visible () && (Options & Opt_scrollBar_right)) 813 if (scrollbar_visible () && (Options & Opt_scrollBar_right))
785 window_sb_x = szHint.width - sb_w; 814 window_sb_x = szHint.width - sb_w;
786 815
787 if (recalc_x) 816 if (recalc_x)
788 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 817 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display))
863 resize_all_windows (0, 0, 0); 892 resize_all_windows (0, 0, 0);
864 scr_remap_chars (); 893 scr_remap_chars ();
865 scr_touch (true); 894 scr_touch (true);
866 } 895 }
867 896
897 for (unicode_t ch = 0x20; ch <= 0x7f; ch++)
898 TermWin.ascii_map [ch - 0x20] = fs->find_font (ch);
899
868 return true; 900 return true;
869 } 901 }
870 } 902 }
871 903
872 return false; 904 return false;
935 i = atoi (color); 967 i = atoi (color);
936 if (i >= 8 && i <= 15) 968 if (i >= 8 && i <= 15)
937 { /* bright colors */ 969 { /* bright colors */
938 i -= 8; 970 i -= 8;
939# ifndef NO_BRIGHTCOLOR 971# ifndef NO_BRIGHTCOLOR
940 PixColors[idx] = PixColors[minBrightCOLOR + i]; 972 PixColorsFocused[idx] = PixColorsFocused[minBrightCOLOR + i];
941 SET_PIXCOLOR (idx); 973 SET_PIXCOLOR (idx);
942 goto Done; 974 goto Done;
943# endif 975# endif
944 976
945 } 977 }
946 if (i >= 0 && i <= 7) 978 if (i >= 0 && i <= 7)
947 { /* normal colors */ 979 { /* normal colors */
948 PixColors[idx] = PixColors[minCOLOR + i]; 980 PixColorsFocused[idx] = PixColorsFocused[minCOLOR + i];
949 SET_PIXCOLOR (idx); 981 SET_PIXCOLOR (idx);
950 goto Done; 982 goto Done;
951 } 983 }
952 } 984 }
953 985
954 if (!rXParseAllocColor (& xcol, color)) 986 if (!rXParseAllocColor (& xcol, color))
955 return; 987 return;
956 988
957 /* XStoreColor (display->display, XCMAP, XColor*); */ 989 /* XStoreColor (display->display, display->cmap, XColor*); */
958 990
959 /* 991 /*
960 * FIXME: should free colors here, but no idea how to do it so instead, 992 * FIXME: should free colors here, but no idea how to do it so instead,
961 * so just keep gobbling up the colormap 993 * so just keep gobbling up the colormap
962 */ 994 */
965 if (PixColors[idx] == PixColors[i]) 997 if (PixColors[idx] == PixColors[i])
966 break; 998 break;
967 if (i > Color_White) 999 if (i > Color_White)
968 { 1000 {
969 /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ 1001 /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */
970 XFreeColors (display->display, XCMAP, (PixColors + idx), 1, 1002 XFreeColors (display->display, display->cmap, (PixColors + idx), 1,
971 DisplayPlanes (display->display, display->screen)); 1003 DisplayPlanes (display->display, display->screen));
972 } 1004 }
973# endif 1005# endif
974 1006
975 PixColors[idx] = xcol; 1007 PixColorsFocused[idx] = xcol;
976 SET_PIXCOLOR (idx); 1008 SET_PIXCOLOR (idx);
977 1009
978 /* XSetWindowAttributes attr; */ 1010 /* XSetWindowAttributes attr; */
979 /* Cursor cursor; */ 1011 /* Cursor cursor; */
980Done: 1012Done:
1013#ifdef OFF_FOCUS_FADING
1014 PixColorsUnFocused[idx] = PixColorsFocused[idx].fade (display, atoi (rs[Rs_fade]));
1015#endif
981 if (idx == Color_bg && ! (Options & Opt_transparent)) 1016 if (idx == Color_bg && ! (Options & Opt_transparent))
982 XSetWindowBackground (display->display, TermWin.vt, 1017 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
983 PixColors[Color_bg]);
984 1018
985 /* handle Color_BD, scrollbar background, etc. */ 1019 /* handle Color_BD, scrollbar background, etc. */
986 1020
987 set_colorfgbg (); 1021 set_colorfgbg ();
988 recolour_cursor (); 1022 recolour_cursor ();
996void 1030void
997rxvt_term::recolour_cursor () 1031rxvt_term::recolour_cursor ()
998{ 1032{
999 XColor xcol[2]; 1033 XColor xcol[2];
1000 1034
1001 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg]; 1035 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]; 1036 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColorsFocused[Color_pointer_bg] : PixColorsFocused[Color_bg];
1003 XQueryColors (display->display, XCMAP, xcol, 2); 1037 XQueryColors (display->display, display->cmap, xcol, 2);
1004 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1); 1038 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
1005} 1039}
1006 1040
1007/*----------------------------------------------------------------------*/ 1041/*----------------------------------------------------------------------*/
1008/* 1042/*
1079 int old_width = szHint.width, old_height = szHint.height; 1113 int old_width = szHint.width, old_height = szHint.height;
1080#endif 1114#endif
1081 1115
1082 window_calc (width, height); 1116 window_calc (width, height);
1083 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1117 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint);
1118
1084 if (!ignoreparent) 1119 if (!ignoreparent)
1085 { 1120 {
1086#ifdef SMART_RESIZE 1121#ifdef SMART_RESIZE
1087 /* 1122 /*
1088 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> 1123 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt>
1123 dy /= 2; 1158 dy /= 2;
1124 1159
1125 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1160 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy,
1126 szHint.width, szHint.height); 1161 szHint.width, szHint.height);
1127#else 1162#else
1128 XResizeWindow (display->display, TermWin.parent[0], szHint.width, 1163 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height);
1129 szHint.height);
1130#endif 1164#endif
1131
1132 } 1165 }
1133 1166
1134 fix_screen = (TermWin.ncol != prev_ncol 1167 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1135 || TermWin.nrow != prev_nrow);
1136 1168
1137 if (fix_screen || width != old_width || height != old_height) 1169 if (fix_screen || width != old_width || height != old_height)
1138 { 1170 {
1139 if (scrollbar_visible ()) 1171 if (scrollbar_visible ())
1140 { 1172 {
1141 XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, 1173 XMoveResizeWindow (display->display, scrollBar.win,
1174 window_sb_x, 0,
1142 0, scrollbar_TotalWidth (), szHint.height); 1175 scrollbar_TotalWidth (), szHint.height);
1143 resize_scrollbar (); 1176 resize_scrollbar ();
1144 } 1177 }
1145 1178
1146 if (menubar_visible ()) 1179 if (menubar_visible ())
1147 XMoveResizeWindow (display->display, menuBar.win, window_vt_x, 1180 XMoveResizeWindow (display->display, menuBar.win,
1181 window_vt_x, 0,
1148 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); 1182 TermWin_TotalWidth (), menuBar_TotalHeight ());
1149 1183
1150 XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, 1184 XMoveResizeWindow (display->display, TermWin.vt,
1151 window_vt_y, TermWin_TotalWidth (), 1185 window_vt_x, window_vt_y,
1152 TermWin_TotalHeight ()); 1186 TermWin_TotalWidth (), TermWin_TotalHeight ());
1153 scr_clear (height != old_height); 1187 scr_clear ();
1154#ifdef XPM_BACKGROUND 1188#ifdef XPM_BACKGROUND
1155 resize_pixmap (); 1189 resize_pixmap ();
1156#endif 1190#endif
1157
1158 } 1191 }
1159 1192
1160 if (fix_screen || old_height == 0) 1193 if (fix_screen || old_height == 0)
1161 { 1194 {
1162 int curr_screen = -1; 1195 int curr_screen = -1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines