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.80 by root, Fri Aug 13 19:31:23 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
140 free (p); 140 free (p);
141} 141}
142 142
143rxvt_term::rxvt_term () 143rxvt_term::rxvt_term ()
144 : 144 :
145#if TRANSPARENT
145 rootwin_ev (this, &rxvt_term::rootwin_cb), 146 rootwin_ev (this, &rxvt_term::rootwin_cb),
147#endif
148#ifdef HAVE_SCROLLBARS
149 scrollbar_ev (this, &rxvt_term::x_cb),
150#endif
151#ifdef MENUBAR
152 menubar_ev (this, &rxvt_term::x_cb),
153#endif
154#ifdef CURSOR_BLINK
155 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
156#endif
157#ifdef TEXT_BLINK
158 text_blink_ev (this, &rxvt_term::text_blink_cb),
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
169#ifdef POINTER_BLANK
170 pointer_ev (this, &rxvt_term::pointer_cb),
171#endif
172#ifdef USE_XIM
173 im_ev (this, &rxvt_term::im_cb),
174#endif
146 termwin_ev (this, &rxvt_term::x_cb), 175 termwin_ev (this, &rxvt_term::x_cb),
147 vt_ev (this, &rxvt_term::x_cb), 176 vt_ev (this, &rxvt_term::x_cb),
148#ifdef HAVE_SCROLLBARS
149 scrollbar_ev (this, &rxvt_term::x_cb),
150#endif
151#ifdef MENUBAR
152 menubar_ev (this, &rxvt_term::x_cb),
153#endif
154#ifdef CURSOR_BLINK
155 cursor_blink_ev (this, &rxvt_term::cursor_blink_cb),
156#endif
157#ifdef TEXT_BLINK
158 text_blink_ev (this, &rxvt_term::text_blink_cb),
159#endif
160#ifdef POINTER_BLANK
161 pointer_ev (this, &rxvt_term::pointer_cb),
162#endif
163#ifdef USE_XIM
164 im_ev (this, &rxvt_term::im_cb),
165#endif
166 check_ev (this, &rxvt_term::check_cb), 177 check_ev (this, &rxvt_term::check_cb),
178 flush_ev (this, &rxvt_term::flush_cb),
167 destroy_ev (this, &rxvt_term::destroy_cb), 179 destroy_ev (this, &rxvt_term::destroy_cb),
168 pty_ev (this, &rxvt_term::pty_cb), 180 pty_ev (this, &rxvt_term::pty_cb),
169 incr_ev (this, &rxvt_term::incr_cb) 181 incr_ev (this, &rxvt_term::incr_cb)
170{ 182{
171 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 183 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
191 203
192 if (display) 204 if (display)
193 { 205 {
194 selection_clear (); 206 selection_clear ();
195 207
208#ifdef USE_XIM
209 im_destroy ();
210#endif
196#ifdef MENUBAR 211#ifdef MENUBAR
197 if (menubarGC) XFreeGC (display->display, menubarGC); 212 if (menubarGC) XFreeGC (display->display, menubarGC);
198#endif 213#endif
199#ifdef XTERM_SCROLLBAR 214#ifdef XTERM_SCROLLBAR
200 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); 215 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC);
233 XDestroyWindow (display->display, TermWin.parent[0]); 248 XDestroyWindow (display->display, TermWin.parent[0]);
234 } 249 }
235 250
236 // TODO: free pixcolours, colours should become part of rxvt_display 251 // TODO: free pixcolours, colours should become part of rxvt_display
237 252
238 delete PixColors; 253 delete PixColorsFocused;
254#ifdef OFF_FOCUS_FADING
255 delete PixColorsUnFocused;
256#endif
239 257
240 displays.put (display); 258 displays.put (display);
241 259
242 scr_release (); 260 scr_release ();
243 261
261} 279}
262 280
263void 281void
264rxvt_term::destroy () 282rxvt_term::destroy ()
265{ 283{
284 if (destroy_ev.active)
285 return;
286
266 if (display) 287 if (display)
267 { 288 {
289#if USE_XIM
290 im_ev.stop (display);
291#endif
292#if HAVE_SCROLLBARS
293 scrollbar_ev.stop (display);
294#endif
295#if MENUBAR
296 menubar_ev.stop (display);
297#endif
298#if TRANSPARENT
268 rootwin_ev.stop (display); 299 rootwin_ev.stop (display);
300#endif
301 incr_ev.stop ();
269 termwin_ev.stop (display); 302 termwin_ev.stop (display);
270 vt_ev.stop (display); 303 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 } 304 }
282 305
283 check_ev.stop (); 306 check_ev.stop ();
284 pty_ev.stop (); 307 pty_ev.stop ();
285#ifdef CURSOR_BLINK 308#ifdef CURSOR_BLINK
286 cursor_blink_ev.stop (); 309 cursor_blink_ev.stop ();
287#endif 310#endif
288#ifdef TEXT_BLINK 311#ifdef TEXT_BLINK
289 text_blink_ev.stop (); 312 text_blink_ev.stop ();
313#endif
314#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
315 cont_scroll_ev.stop ();
316#endif
317#ifdef SELECTION_SCROLLING
318 sel_scroll_ev.stop ();
290#endif 319#endif
291#ifdef POINTER_BLANK 320#ifdef POINTER_BLANK
292 pointer_ev.stop (); 321 pointer_ev.stop ();
293#endif 322#endif
294 323
358#ifdef TRANSPARENT 387#ifdef TRANSPARENT
359 if (Options & Opt_transparent) 388 if (Options & Opt_transparent)
360 { 389 {
361 XSelectInput (display->display, display->root, PropertyChangeMask); 390 XSelectInput (display->display, display->root, PropertyChangeMask);
362 check_our_parents (); 391 check_our_parents ();
363 }
364#endif
365
366 rootwin_ev.start (display, display->root); 392 rootwin_ev.start (display, display->root);
393 }
394#endif
367 395
368 XMapWindow (display->display, TermWin.vt); 396 XMapWindow (display->display, TermWin.vt);
369 XMapWindow (display->display, TermWin.parent[0]); 397 XMapWindow (display->display, TermWin.parent[0]);
370 398
371 init_command (cmd_argv); 399 init_command (cmd_argv);
740 max_height = MAX_ROWS * TermWin.fheight; 768 max_height = MAX_ROWS * TermWin.fheight;
741 769
742 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; 770 szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth;
743 771
744 sb_w = mb_h = 0; 772 sb_w = mb_h = 0;
745 window_vt_x = window_vt_y = 0; 773 window_vt_x = window_vt_y = TermWin.int_bwidth;
774
746 if (scrollbar_visible ()) 775 if (scrollbar_visible ())
747 { 776 {
748 sb_w = scrollbar_TotalWidth (); 777 sb_w = scrollbar_TotalWidth ();
749 szHint.base_width += sb_w; 778 szHint.base_width += sb_w;
750 if (! (Options & Opt_scrollBar_right)) 779 if (!(Options & Opt_scrollBar_right))
751 window_vt_x = sb_w; 780 window_vt_x += sb_w;
752 } 781 }
782
753 if (menubar_visible ()) 783 if (menubar_visible ())
754 { 784 {
755 mb_h = menuBar_TotalHeight (); 785 mb_h = menuBar_TotalHeight ();
756 szHint.base_height += mb_h; 786 szHint.base_height += mb_h;
757 window_vt_y = mb_h; 787 window_vt_y += mb_h;
758 } 788 }
789
759 szHint.width_inc = TermWin.fwidth; 790 szHint.width_inc = TermWin.fwidth;
760 szHint.height_inc = TermWin.fheight; 791 szHint.height_inc = TermWin.fheight;
761 szHint.min_width = szHint.base_width + szHint.width_inc; 792 szHint.min_width = szHint.base_width + szHint.width_inc;
762 szHint.min_height = szHint.base_height + szHint.height_inc; 793 szHint.min_height = szHint.base_height + szHint.height_inc;
763 794
769 else 800 else
770 { 801 {
771 MIN_IT (TermWin.width, max_width); 802 MIN_IT (TermWin.width, max_width);
772 szHint.width = szHint.base_width + TermWin.width; 803 szHint.width = szHint.base_width + TermWin.width;
773 } 804 }
805
774 if (height && height - szHint.base_height < max_height) 806 if (height && height - szHint.base_height < max_height)
775 { 807 {
776 szHint.height = height; 808 szHint.height = height;
777 TermWin.height = height - szHint.base_height; 809 TermWin.height = height - szHint.base_height;
778 } 810 }
779 else 811 else
780 { 812 {
781 MIN_IT (TermWin.height, max_height); 813 MIN_IT (TermWin.height, max_height);
782 szHint.height = szHint.base_height + TermWin.height; 814 szHint.height = szHint.base_height + TermWin.height;
783 } 815 }
816
784 if (scrollbar_visible () && (Options & Opt_scrollBar_right)) 817 if (scrollbar_visible () && (Options & Opt_scrollBar_right))
785 window_sb_x = szHint.width - sb_w; 818 window_sb_x = szHint.width - sb_w;
786 819
787 if (recalc_x) 820 if (recalc_x)
788 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 821 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display))
863 resize_all_windows (0, 0, 0); 896 resize_all_windows (0, 0, 0);
864 scr_remap_chars (); 897 scr_remap_chars ();
865 scr_touch (true); 898 scr_touch (true);
866 } 899 }
867 900
901 for (unicode_t ch = 0x20; ch <= 0x7f; ch++)
902 TermWin.ascii_map [ch - 0x20] = fs->find_font (ch);
903
868 return true; 904 return true;
869 } 905 }
870 } 906 }
871 907
872 return false; 908 return false;
935 i = atoi (color); 971 i = atoi (color);
936 if (i >= 8 && i <= 15) 972 if (i >= 8 && i <= 15)
937 { /* bright colors */ 973 { /* bright colors */
938 i -= 8; 974 i -= 8;
939# ifndef NO_BRIGHTCOLOR 975# ifndef NO_BRIGHTCOLOR
940 PixColors[idx] = PixColors[minBrightCOLOR + i]; 976 PixColorsFocused[idx] = PixColorsFocused[minBrightCOLOR + i];
941 SET_PIXCOLOR (idx); 977 SET_PIXCOLOR (idx);
942 goto Done; 978 goto Done;
943# endif 979# endif
944 980
945 } 981 }
946 if (i >= 0 && i <= 7) 982 if (i >= 0 && i <= 7)
947 { /* normal colors */ 983 { /* normal colors */
948 PixColors[idx] = PixColors[minCOLOR + i]; 984 PixColorsFocused[idx] = PixColorsFocused[minCOLOR + i];
949 SET_PIXCOLOR (idx); 985 SET_PIXCOLOR (idx);
950 goto Done; 986 goto Done;
951 } 987 }
952 } 988 }
953 989
954 if (!rXParseAllocColor (& xcol, color)) 990 if (!rXParseAllocColor (& xcol, color))
955 return; 991 return;
956 992
957 /* XStoreColor (display->display, XCMAP, XColor*); */ 993 /* XStoreColor (display->display, display->cmap, XColor*); */
958 994
959 /* 995 /*
960 * FIXME: should free colors here, but no idea how to do it so instead, 996 * FIXME: should free colors here, but no idea how to do it so instead,
961 * so just keep gobbling up the colormap 997 * so just keep gobbling up the colormap
962 */ 998 */
965 if (PixColors[idx] == PixColors[i]) 1001 if (PixColors[idx] == PixColors[i])
966 break; 1002 break;
967 if (i > Color_White) 1003 if (i > Color_White)
968 { 1004 {
969 /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ 1005 /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */
970 XFreeColors (display->display, XCMAP, (PixColors + idx), 1, 1006 XFreeColors (display->display, display->cmap, (PixColors + idx), 1,
971 DisplayPlanes (display->display, display->screen)); 1007 DisplayPlanes (display->display, display->screen));
972 } 1008 }
973# endif 1009# endif
974 1010
975 PixColors[idx] = xcol; 1011 PixColorsFocused[idx] = xcol;
976 SET_PIXCOLOR (idx); 1012 SET_PIXCOLOR (idx);
977 1013
978 /* XSetWindowAttributes attr; */ 1014 /* XSetWindowAttributes attr; */
979 /* Cursor cursor; */ 1015 /* Cursor cursor; */
980Done: 1016Done:
1017#ifdef OFF_FOCUS_FADING
1018 PixColorsUnFocused[idx] = PixColorsFocused[idx].fade (display, atoi (rs[Rs_fade]));
1019#endif
981 if (idx == Color_bg && ! (Options & Opt_transparent)) 1020 if (idx == Color_bg && ! (Options & Opt_transparent))
982 XSetWindowBackground (display->display, TermWin.vt, 1021 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
983 PixColors[Color_bg]);
984 1022
985 /* handle Color_BD, scrollbar background, etc. */ 1023 /* handle Color_BD, scrollbar background, etc. */
986 1024
987 set_colorfgbg (); 1025 set_colorfgbg ();
988 recolour_cursor (); 1026 recolour_cursor ();
996void 1034void
997rxvt_term::recolour_cursor () 1035rxvt_term::recolour_cursor ()
998{ 1036{
999 XColor xcol[2]; 1037 XColor xcol[2];
1000 1038
1001 xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColors[Color_pointer_fg] : PixColors[Color_fg]; 1039 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]; 1040 xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColorsFocused[Color_pointer_bg] : PixColorsFocused[Color_bg];
1003 XQueryColors (display->display, XCMAP, xcol, 2); 1041 XQueryColors (display->display, display->cmap, xcol, 2);
1004 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1); 1042 XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1);
1005} 1043}
1006 1044
1007/*----------------------------------------------------------------------*/ 1045/*----------------------------------------------------------------------*/
1008/* 1046/*
1079 int old_width = szHint.width, old_height = szHint.height; 1117 int old_width = szHint.width, old_height = szHint.height;
1080#endif 1118#endif
1081 1119
1082 window_calc (width, height); 1120 window_calc (width, height);
1083 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1121 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint);
1122
1084 if (!ignoreparent) 1123 if (!ignoreparent)
1085 { 1124 {
1086#ifdef SMART_RESIZE 1125#ifdef SMART_RESIZE
1087 /* 1126 /*
1088 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> 1127 * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt>
1123 dy /= 2; 1162 dy /= 2;
1124 1163
1125 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1164 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy,
1126 szHint.width, szHint.height); 1165 szHint.width, szHint.height);
1127#else 1166#else
1128 XResizeWindow (display->display, TermWin.parent[0], szHint.width, 1167 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height);
1129 szHint.height);
1130#endif 1168#endif
1131
1132 } 1169 }
1133 1170
1134 fix_screen = (TermWin.ncol != prev_ncol 1171 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1135 || TermWin.nrow != prev_nrow);
1136 1172
1137 if (fix_screen || width != old_width || height != old_height) 1173 if (fix_screen || width != old_width || height != old_height)
1138 { 1174 {
1139 if (scrollbar_visible ()) 1175 if (scrollbar_visible ())
1140 { 1176 {
1141 XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, 1177 XMoveResizeWindow (display->display, scrollBar.win,
1178 window_sb_x, 0,
1142 0, scrollbar_TotalWidth (), szHint.height); 1179 scrollbar_TotalWidth (), szHint.height);
1143 resize_scrollbar (); 1180 resize_scrollbar ();
1144 } 1181 }
1145 1182
1146 if (menubar_visible ()) 1183 if (menubar_visible ())
1147 XMoveResizeWindow (display->display, menuBar.win, window_vt_x, 1184 XMoveResizeWindow (display->display, menuBar.win,
1185 window_vt_x, 0,
1148 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); 1186 TermWin_TotalWidth (), menuBar_TotalHeight ());
1149 1187
1150 XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, 1188 XMoveResizeWindow (display->display, TermWin.vt,
1151 window_vt_y, TermWin_TotalWidth (), 1189 window_vt_x, window_vt_y,
1152 TermWin_TotalHeight ()); 1190 TermWin_TotalWidth (), TermWin_TotalHeight ());
1153 scr_clear (height != old_height); 1191 scr_clear ();
1154#ifdef XPM_BACKGROUND 1192#ifdef XPM_BACKGROUND
1155 resize_pixmap (); 1193 resize_pixmap ();
1156#endif 1194#endif
1157
1158 } 1195 }
1159 1196
1160 if (fix_screen || old_height == 0) 1197 if (fix_screen || old_height == 0)
1161 { 1198 {
1162 int curr_screen = -1; 1199 int curr_screen = -1;
1203 if (width == 0) 1240 if (width == 0)
1204 width = wattr.width - szHint.base_width; 1241 width = wattr.width - szHint.base_width;
1205 if (height == 0) 1242 if (height == 0)
1206 height = wattr.height - szHint.base_height; 1243 height = wattr.height - szHint.base_height;
1207 } 1244 }
1245
1208 if (width != TermWin.width || height != TermWin.height) 1246 if (width != TermWin.width || height != TermWin.height)
1209 { 1247 {
1210 width += szHint.base_width; 1248 width += szHint.base_width;
1211 height += szHint.base_height; 1249 height += szHint.base_height;
1212 resize_all_windows (width, height, 0); 1250 resize_all_windows (width, height, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines