ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/init.C
(Generate patch)

Comparing rxvt-unicode/src/init.C (file contents):
Revision 1.50 by pcg, Thu Apr 8 20:31:45 2004 UTC vs.
Revision 1.65 by root, Fri Jul 30 16:13:46 2004 UTC

324 NULL, /* Color_RV */ 324 NULL, /* Color_RV */
325#endif /* ! NO_BOLD_UNDERLINE_REVERSE */ 325#endif /* ! NO_BOLD_UNDERLINE_REVERSE */
326#ifdef OPTION_HC 326#ifdef OPTION_HC
327 NULL, 327 NULL,
328#endif 328#endif
329#if TINTING
330 NULL,
331#endif
332#ifdef KEEP_SCROLLCOLOR 329#ifdef KEEP_SCROLLCOLOR
333 COLOR_SCROLLBAR, 330 COLOR_SCROLLBAR,
334 COLOR_SCROLLTROUGH, 331 COLOR_SCROLLTROUGH,
335#endif /* KEEP_SCROLLCOLOR */ 332#endif /* KEEP_SCROLLCOLOR */
336 333#if TINTING
334 NULL,
335#endif
337 }; 336 };
338 337
339const char *const xa_names[NUM_XA] = 338const char *const xa_names[NUM_XA] =
340 { 339 {
341 "TEXT", 340 "TEXT",
358 }; 357 };
359 358
360bool 359bool
361rxvt_term::init_vars () 360rxvt_term::init_vars ()
362{ 361{
363 PixColors = new rxvt_color [TOTAL_COLORS]; 362 PixColorsFocused = new rxvt_color [TOTAL_COLORS];
363#ifdef OFF_FOCUS_FADING
364 PixColorsUnFocused = new rxvt_color [TOTAL_COLORS];
365#endif
366 PixColors = PixColorsFocused;
367
364 if (PixColors == NULL) 368 if (PixColors == NULL)
365 return false; 369 return false;
366 370
367#if defined(XPM_BACKGROUND) || defined(TRANSPARENT) 371#if defined(XPM_BACKGROUND) || defined(TRANSPARENT)
368 TermWin.pixmap = None; 372 TermWin.pixmap = None;
753void 757void
754rxvt_term::set_locale (const char *locale) 758rxvt_term::set_locale (const char *locale)
755{ 759{
756#if HAVE_XSETLOCALE || HAVE_SETLOCALE 760#if HAVE_XSETLOCALE || HAVE_SETLOCALE
757 free (this->locale); 761 free (this->locale);
758 this->locale = rxvt_strdup (setlocale (LC_CTYPE, locale)); 762 this->locale = setlocale (LC_CTYPE, locale);
763
764 if (!this->locale)
765 {
766 rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale);
767 setlocale (LC_CTYPE, "");
768 this->locale = "";
769 }
770
771 this->locale = rxvt_strdup (this->locale);
759 SET_LOCALE (this->locale); 772 SET_LOCALE (this->locale);
760 mbstate.reset (); 773 mbstate.reset ();
761#endif 774#endif
762#if 0 775#if 0
763#if HAVE_NL_LANGINFO 776#if HAVE_NL_LANGINFO
826 meta_char = (Options & Opt_meta8 ? 0x80 : C0_ESC); 839 meta_char = (Options & Opt_meta8 ? 0x80 : C0_ESC);
827#endif 840#endif
828 841
829 get_ourmods (); 842 get_ourmods ();
830 843
831 if (! (Options & Opt_scrollTtyOutput)) 844 if (!(Options & Opt_scrollTtyOutput))
832 PrivateModes |= PrivMode_TtyOutputInh; 845 PrivateModes |= PrivMode_TtyOutputInh;
833 if (Options & Opt_scrollTtyKeypress) 846 if (Options & Opt_scrollTtyKeypress)
834 PrivateModes |= PrivMode_Keypress; 847 PrivateModes |= PrivMode_Keypress;
835 if (! (Options & Opt_jumpScroll)) 848 if (!(Options & Opt_jumpScroll))
836 PrivateModes |= PrivMode_smoothScroll; 849 PrivateModes |= PrivMode_smoothScroll;
837 850
838#ifndef NO_BACKSPACE_KEY 851#ifndef NO_BACKSPACE_KEY
839 if (STRCMP (key_backspace, "DEC") == 0) 852 if (STRCMP (key_backspace, "DEC") == 0)
840 PrivateModes |= PrivMode_HaveBackSpace; 853 PrivateModes |= PrivMode_HaveBackSpace;
865void 878void
866rxvt_term::Get_Colours () 879rxvt_term::Get_Colours ()
867{ 880{
868 int i; 881 int i;
869 882
883#ifdef OFF_FOCUS_FADING
884 PixColors = PixColorsFocused;
885#endif
886
870 for (i = 0; i < (XDEPTH <= 2 ? 2 : NRS_COLORS); i++) 887 for (i = 0; i < (XDEPTH <= 2 ? 2 : NRS_COLORS); i++)
871 { 888 {
872 rxvt_color xcol; 889 rxvt_color xcol;
873 890
874 if (!rs[Rs_color + i]) 891 if (!rs[Rs_color + i])
910 } 927 }
911 } 928 }
912 } 929 }
913 930
914 PixColors[i] = xcol; 931 PixColors[i] = xcol;
932#ifdef OFF_FOCUS_FADING
933 if (rs[Rs_fade])
934 PixColorsUnFocused[i] = xcol.fade (display, atoi (rs[Rs_fade]));
935#endif
915 SET_PIXCOLOR (i); 936 SET_PIXCOLOR (i);
916 } 937 }
917 938
918 if (XDEPTH <= 2) 939 if (XDEPTH <= 2)
919 { 940 {
930 */ 951 */
931#ifdef KEEP_SCROLLCOLOR 952#ifdef KEEP_SCROLLCOLOR
932 953
933 if (XDEPTH <= 2) 954 if (XDEPTH <= 2)
934 { /* Monochrome */ 955 { /* Monochrome */
935 PixColors[Color_scroll] = PixColors[Color_fg]; 956 PixColors[Color_scroll] = PixColors[Color_fg];
936 PixColors[Color_topShadow] = PixColors[Color_bg]; 957 PixColors[Color_topShadow] = PixColors[Color_bg];
937 PixColors[Color_bottomShadow] = PixColors[Color_bg]; 958 PixColors[Color_bottomShadow] = PixColors[Color_bg];
938 } 959 }
939 else 960 else
940 { 961 {
941 rxvt_color xcol[3]; 962 rxvt_color xcol[2];
942 /* xcol[0] == white 963 /* xcol[0] == white
943 * xcol[1] == top shadow 964 * xcol[1] == top shadow
944 * xcol[2] == bot shadow */ 965 * xcol[2] == bot shadow */
945 966
946 xcol[1] = PixColors[Color_scroll]; 967 xcol[1] = PixColors[Color_scroll];
947# ifdef PREFER_24BIT
948 xcol[0].set (display, 65535, 65535, 65535); 968 xcol[0].set (display, 65535, 65535, 65535);
949 /* XFreeColors (display->display, XCMAP, & (xcol[0].pixel), 1, ~0); */
950# else
951 xcol[0].set (display, WhitePixel (display->display, display->screen));
952# endif
953 969
954 unsigned short pr1, pg1, pb1, pr0, pg0, pb0; 970 unsigned short pr1, pg1, pb1, pr0, pg0, pb0;
955 971
956 xcol[0].get (display, pr0, pg0, pb0); 972 xcol[0].get (display, pr0, pg0, pb0);
957 xcol[1].get (display, pr1, pg1, pb1); 973 xcol[1].get (display, pr1, pg1, pb1);
958 974
959 /* bottomShadowColor */
960 if (!xcol[2].set (display, pr1 / 2, pg1 / 2, pb1 / 2))
961 xcol[2] = PixColors[Color_Black];
962
963 PixColors[Color_bottomShadow] = xcol[2]; 975 PixColors[Color_bottomShadow] = xcol[1].fade (display, 50);
964 976
965 /* topShadowColor */ 977 /* topShadowColor */
966 if (!xcol[1].set (display, 978 if (!xcol[1].set (display,
967 min (pr0, max (pr0 / 5, pr1) * 7 / 5), 979 min (pr0, max (pr0 / 5, pr1) * 7 / 5),
968 min (pg0, max (pg0 / 5, pg1) * 7 / 5), 980 min (pg0, max (pg0 / 5, pg1) * 7 / 5),
1072/*----------------------------------------------------------------------*/ 1084/*----------------------------------------------------------------------*/
1073/* rxvt_Create_Windows () - Open and map the window */ 1085/* rxvt_Create_Windows () - Open and map the window */
1074void 1086void
1075rxvt_term::create_windows (int argc, const char *const *argv) 1087rxvt_term::create_windows (int argc, const char *const *argv)
1076{ 1088{
1077 XClassHint classHint; 1089 XClassHint classHint;
1078 XWMHints wmHint; 1090 XWMHints wmHint;
1079 XGCValues gcvalue; 1091 XGCValues gcvalue;
1080 long vt_emask; 1092 long vt_emask;
1081 1093 XSetWindowAttributes attributes;
1082 XWindowAttributes gattr; 1094 XWindowAttributes gattr;
1083 1095
1084 if (Options & Opt_transparent) 1096 if (Options & Opt_transparent)
1085 { 1097 {
1086 XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); 1098 XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr);
1099 1111
1100 window_calc (0, 0); 1112 window_calc (0, 0);
1101 old_width = szHint.width; 1113 old_width = szHint.width;
1102 old_height = szHint.height; 1114 old_height = szHint.height;
1103 1115
1104 /* parent window - reverse video so we can see placement errors
1105 * sub-window placement & size in rxvt_resize_subwindows () 1116 /* sub-window placement & size in rxvt_resize_subwindows () */
1106 */
1107 1117
1108#ifdef PREFER_24BIT 1118#ifdef PREFER_24BIT
1109 XSetWindowAttributes attributes;
1110
1111 attributes.background_pixel = PixColors[Color_fg]; 1119 attributes.background_pixel = PixColors[Color_bg];
1112 attributes.border_pixel = PixColors[Color_border]; 1120 attributes.border_pixel = PixColors[Color_border];
1113 attributes.colormap = display->cmap; 1121 attributes.colormap = display->cmap;
1114 TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display), 1122 TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display),
1115 szHint.x, szHint.y, 1123 szHint.x, szHint.y,
1116 szHint.width, szHint.height, 1124 szHint.width, szHint.height,
1117 TermWin.ext_bwidth, 1125 TermWin.ext_bwidth,
1118 display->depth, InputOutput, 1126 display->depth, InputOutput,
1119 display->visual, 1127 display->visual,
1120 CWBackPixel | CWBorderPixel | CWColormap, &attributes); 1128 CWColormap | CWBackPixel | CWBorderPixel, &attributes);
1121#else 1129#else
1122 TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display), 1130 TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display),
1123 szHint.x, szHint.y, 1131 szHint.x, szHint.y,
1124 szHint.width, 1132 szHint.width, szHint.height,
1125 szHint.height,
1126 TermWin.ext_bwidth, 1133 TermWin.ext_bwidth,
1127 PixColors[Color_border], 1134 PixColors[Color_border],
1128 PixColors[Color_fg]); 1135 PixColors[Color_bg]);
1129#endif 1136#endif
1130 1137
1131 process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); 1138 process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST);
1132 process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); 1139 process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST);
1133 1140
1134 classHint.res_name = (char *)rs[Rs_name]; 1141 classHint.res_name = (char *)rs[Rs_name];
1135 classHint.res_class = (char *)RESCLASS; 1142 classHint.res_class = (char *)RESCLASS;
1136 1143
1137 wmHint.flags = (InputHint | StateHint | WindowGroupHint); 1144 wmHint.flags = InputHint | StateHint | WindowGroupHint;
1138 wmHint.input = True; 1145 wmHint.input = True;
1139 wmHint.initial_state = (Options & Opt_iconic ? IconicState 1146 wmHint.initial_state = Options & Opt_iconic ? IconicState : NormalState;
1140 : NormalState);
1141 wmHint.window_group = TermWin.parent[0]; 1147 wmHint.window_group = TermWin.parent[0];
1142 1148
1143 XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL, 1149 XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL,
1144 (char **)argv, argc, &szHint, &wmHint, &classHint); 1150 (char **)argv, argc, &szHint, &wmHint, &classHint);
1145 1151
1149 display->atom ("_NET_WM_PID"), XA_CARDINAL, 32, 1155 display->atom ("_NET_WM_PID"), XA_CARDINAL, 32,
1150 PropModeReplace, (unsigned char *)&pid, 1); 1156 PropModeReplace, (unsigned char *)&pid, 1);
1151#endif 1157#endif
1152 1158
1153 XSelectInput (display->display, TermWin.parent[0], 1159 XSelectInput (display->display, TermWin.parent[0],
1154 KeyPressMask 1160 KeyPressMask
1155#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1161#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1156 | KeyReleaseMask 1162 | KeyReleaseMask
1157#endif 1163#endif
1158 | FocusChangeMask | VisibilityChangeMask 1164 | FocusChangeMask | VisibilityChangeMask
1159 | StructureNotifyMask); 1165 | StructureNotifyMask);
1160 termwin_ev.start (display, TermWin.parent[0]); 1166 termwin_ev.start (display, TermWin.parent[0]);
1161 1167
1162 /* vt cursor: Black-on-White is standard, but this is more popular */ 1168 /* vt cursor: Black-on-White is standard, but this is more popular */
1163 TermWin_cursor = XCreateFontCursor (display->display, XC_xterm); 1169 TermWin_cursor = XCreateFontCursor (display->display, XC_xterm);
1164 1170
1180 } 1186 }
1181#endif 1187#endif
1182 1188
1183 /* the vt window */ 1189 /* the vt window */
1184 TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0], 1190 TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0],
1185 window_vt_x, window_vt_y, 1191 window_vt_x,
1192 window_vt_y,
1186 TermWin_TotalWidth (), 1193 TermWin_TotalWidth (),
1187 TermWin_TotalHeight (), 1194 TermWin_TotalHeight (),
1188 0, 1195 0,
1189 PixColors[Color_fg], 1196 PixColors[Color_fg],
1190 PixColors[Color_bg]); 1197 PixColors[Color_bg]);
1191
1192#ifdef DEBUG_X 1198#ifdef DEBUG_X
1193 XStoreName (display->display, TermWin.vt, "vt window"); 1199 XStoreName (display->display, TermWin.vt, "vt window");
1194#endif 1200#endif
1195 1201
1202 attributes.bit_gravity = NorthWestGravity;
1203 XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes);
1204
1196 vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask 1205 vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask;
1197 | PropertyChangeMask); 1206
1207 pointer_unblank ();
1198 1208
1199#ifdef POINTER_BLANK 1209#ifdef POINTER_BLANK
1200 pointer_unblank ();
1201
1202 if ((Options & Opt_pointerBlank)) 1210 if (Options & Opt_pointerBlank)
1203 vt_emask |= PointerMotionMask; 1211 vt_emask |= PointerMotionMask;
1204 else 1212 else
1205#endif 1213#endif
1206 vt_emask |= (Button1MotionMask | Button3MotionMask); 1214 vt_emask |= Button1MotionMask | Button3MotionMask;
1207 1215
1208 XSelectInput (display->display, TermWin.vt, vt_emask); 1216 XSelectInput (display->display, TermWin.vt, vt_emask);
1209 vt_ev.start (display, TermWin.vt); 1217 vt_ev.start (display, TermWin.vt);
1210 1218
1211#if defined(MENUBAR) && (MENUBAR_MAX > 1) 1219#if defined(MENUBAR) && (MENUBAR_MAX > 1)
1237 1245
1238#ifdef XPM_BACKGROUND 1246#ifdef XPM_BACKGROUND
1239 if (rs[Rs_backgroundPixmap] != NULL 1247 if (rs[Rs_backgroundPixmap] != NULL
1240 && ! (Options & Opt_transparent)) 1248 && ! (Options & Opt_transparent))
1241 { 1249 {
1242 const char *p = rs[Rs_backgroundPixmap]; 1250 const char *p = rs[Rs_backgroundPixmap];
1243 1251
1244 if ((p = STRCHR (p, ';')) != NULL) 1252 if ((p = STRCHR (p, ';')) != NULL)
1245 { 1253 {
1246 p++; 1254 p++;
1247 scale_pixmap (p); 1255 scale_pixmap (p);
1266 topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 1274 topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
1267 gcvalue.foreground = PixColors[Color_bottomShadow]; 1275 gcvalue.foreground = PixColors[Color_bottomShadow];
1268 botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 1276 botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
1269 gcvalue.foreground = PixColors[ (XDEPTH <= 2 ? Color_fg : Color_scroll)]; 1277 gcvalue.foreground = PixColors[ (XDEPTH <= 2 ? Color_fg : Color_scroll)];
1270 scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 1278 scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
1279#endif
1280
1281#ifdef OFF_FOCUS_FADING
1282 // initially we are in unfocused state
1283 if (rs[Rs_fade])
1284 PixColors = PixColorsUnFocused;
1271#endif 1285#endif
1272} 1286}
1273 1287
1274/*----------------------------------------------------------------------*/ 1288/*----------------------------------------------------------------------*/
1275/* 1289/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines