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.67 by root, Tue Aug 3 22:19:51 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 < (display->depth <= 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])
875 continue; 892 continue;
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 (display->depth <= 2)
919 { 940 {
920 if (!rs[Rs_color + Color_pointer_fg]) PixColors[Color_pointer_fg] = PixColors[Color_fg]; 941 if (!rs[Rs_color + Color_pointer_fg]) PixColors[Color_pointer_fg] = PixColors[Color_fg];
921 if (!rs[Rs_color + Color_pointer_bg]) PixColors[Color_pointer_bg] = PixColors[Color_bg]; 942 if (!rs[Rs_color + Color_pointer_bg]) PixColors[Color_pointer_bg] = PixColors[Color_bg];
922 if (!rs[Rs_color + Color_border] ) PixColors[Color_border] = PixColors[Color_fg]; 943 if (!rs[Rs_color + Color_border] ) PixColors[Color_border] = PixColors[Color_fg];
923 } 944 }
928 * The calculations of topShadow/bottomShadow values are adapted 949 * The calculations of topShadow/bottomShadow values are adapted
929 * from the fvwm window manager. 950 * from the fvwm window manager.
930 */ 951 */
931#ifdef KEEP_SCROLLCOLOR 952#ifdef KEEP_SCROLLCOLOR
932 953
933 if (XDEPTH <= 2) 954 if (display->depth <= 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;
1091#ifndef NO_FRILLS
1092 Atom prop = None;
1093 MWMHints mwmhints;
1094#endif
1079 XGCValues gcvalue; 1095 XGCValues gcvalue;
1080 long vt_emask; 1096 long vt_emask;
1081 1097 XSetWindowAttributes attributes;
1082 XWindowAttributes gattr; 1098 XWindowAttributes gattr;
1083 1099
1084 if (Options & Opt_transparent) 1100 if (Options & Opt_transparent)
1085 { 1101 {
1086 XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); 1102 XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr);
1087 display->depth = gattr.depth; // doh //TODO, per-term not per-display? 1103 display->depth = gattr.depth; // doh //TODO, per-term not per-display?
1088 } 1104 }
1105
1106#ifndef NO_FRILLS
1107 if (Options & Opt_borderLess)
1108 {
1109 prop = XInternAtom(display->display, "_MOTIF_WM_INFO", True);
1110 if (prop == None)
1111 {
1112 /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/
1113#ifdef PREFER_24BIT
1114 attributes.override_redirect = TRUE;
1115#endif
1116 mwmhints.flags = 0;
1117 }
1118 else
1119 {
1120 mwmhints.flags = MWM_HINTS_DECORATIONS;
1121 mwmhints.decorations = 0;
1122 }
1123 }
1124 else
1125 {
1126 mwmhints.flags = 0;
1127 }
1128#endif
1089 1129
1090 /* grab colors before netscape does */ 1130 /* grab colors before netscape does */
1091 Get_Colours (); 1131 Get_Colours ();
1092 1132
1093 if (!change_font (rs[Rs_font])) 1133 if (!change_font (rs[Rs_font]))
1099 1139
1100 window_calc (0, 0); 1140 window_calc (0, 0);
1101 old_width = szHint.width; 1141 old_width = szHint.width;
1102 old_height = szHint.height; 1142 old_height = szHint.height;
1103 1143
1104 /* parent window - reverse video so we can see placement errors
1105 * sub-window placement & size in rxvt_resize_subwindows () 1144 /* sub-window placement & size in rxvt_resize_subwindows () */
1106 */
1107 1145
1108#ifdef PREFER_24BIT 1146#ifdef PREFER_24BIT
1109 XSetWindowAttributes attributes;
1110
1111 attributes.background_pixel = PixColors[Color_fg]; 1147 attributes.background_pixel = PixColors[Color_bg];
1112 attributes.border_pixel = PixColors[Color_border]; 1148 attributes.border_pixel = PixColors[Color_border];
1113 attributes.colormap = display->cmap; 1149 attributes.colormap = display->cmap;
1114 TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display), 1150 TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display),
1115 szHint.x, szHint.y, 1151 szHint.x, szHint.y,
1116 szHint.width, szHint.height, 1152 szHint.width, szHint.height,
1117 TermWin.ext_bwidth, 1153 TermWin.ext_bwidth,
1118 display->depth, InputOutput, 1154 display->depth, InputOutput,
1119 display->visual, 1155 display->visual,
1120 CWBackPixel | CWBorderPixel | CWColormap, &attributes); 1156 CWColormap | CWBackPixel | CWBorderPixel, &attributes);
1121#else 1157#else
1122 TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display), 1158 TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display),
1123 szHint.x, szHint.y, 1159 szHint.x, szHint.y,
1124 szHint.width, 1160 szHint.width, szHint.height,
1125 szHint.height,
1126 TermWin.ext_bwidth, 1161 TermWin.ext_bwidth,
1127 PixColors[Color_border], 1162 PixColors[Color_border],
1128 PixColors[Color_fg]); 1163 PixColors[Color_bg]);
1129#endif 1164#endif
1130 1165
1131 process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); 1166 process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST);
1132 process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); 1167 process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST);
1133 1168
1134 classHint.res_name = (char *)rs[Rs_name]; 1169 classHint.res_name = (char *)rs[Rs_name];
1135 classHint.res_class = (char *)RESCLASS; 1170 classHint.res_class = (char *)RESCLASS;
1136 1171
1137 wmHint.flags = (InputHint | StateHint | WindowGroupHint); 1172 wmHint.flags = InputHint | StateHint | WindowGroupHint;
1138 wmHint.input = True; 1173 wmHint.input = True;
1139 wmHint.initial_state = (Options & Opt_iconic ? IconicState 1174 wmHint.initial_state = Options & Opt_iconic ? IconicState : NormalState;
1140 : NormalState);
1141 wmHint.window_group = TermWin.parent[0]; 1175 wmHint.window_group = TermWin.parent[0];
1142 1176
1143 XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL, 1177 XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL,
1144 (char **)argv, argc, &szHint, &wmHint, &classHint); 1178 (char **)argv, argc, &szHint, &wmHint, &classHint);
1145 1179
1149 display->atom ("_NET_WM_PID"), XA_CARDINAL, 32, 1183 display->atom ("_NET_WM_PID"), XA_CARDINAL, 32,
1150 PropModeReplace, (unsigned char *)&pid, 1); 1184 PropModeReplace, (unsigned char *)&pid, 1);
1151#endif 1185#endif
1152 1186
1153 XSelectInput (display->display, TermWin.parent[0], 1187 XSelectInput (display->display, TermWin.parent[0],
1154 KeyPressMask 1188 KeyPressMask
1155#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1189#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1156 | KeyReleaseMask 1190 | KeyReleaseMask
1157#endif 1191#endif
1158 | FocusChangeMask | VisibilityChangeMask 1192 | FocusChangeMask | VisibilityChangeMask
1193 | ExposureMask
1159 | StructureNotifyMask); 1194 | StructureNotifyMask);
1160 termwin_ev.start (display, TermWin.parent[0]); 1195 termwin_ev.start (display, TermWin.parent[0]);
1196
1197#ifndef NO_FRILLS
1198 if (mwmhints.flags)
1199 {
1200 prop = XInternAtom(display->display, "_MOTIF_WM_HINTS", False);
1201 XChangeProperty(display->display, TermWin.parent[0], prop, prop, 32, PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS);
1202 }
1203#endif
1161 1204
1162 /* vt cursor: Black-on-White is standard, but this is more popular */ 1205 /* vt cursor: Black-on-White is standard, but this is more popular */
1163 TermWin_cursor = XCreateFontCursor (display->display, XC_xterm); 1206 TermWin_cursor = XCreateFontCursor (display->display, XC_xterm);
1164 1207
1165#if defined(HAVE_SCROLLBARS) || defined(MENUBAR) 1208#if defined(HAVE_SCROLLBARS) || defined(MENUBAR)
1180 } 1223 }
1181#endif 1224#endif
1182 1225
1183 /* the vt window */ 1226 /* the vt window */
1184 TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0], 1227 TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0],
1185 window_vt_x, window_vt_y, 1228 window_vt_x,
1229 window_vt_y,
1186 TermWin_TotalWidth (), 1230 TermWin_TotalWidth (),
1187 TermWin_TotalHeight (), 1231 TermWin_TotalHeight (),
1188 0, 1232 0,
1189 PixColors[Color_fg], 1233 PixColors[Color_fg],
1190 PixColors[Color_bg]); 1234 PixColors[Color_bg]);
1191
1192#ifdef DEBUG_X 1235#ifdef DEBUG_X
1193 XStoreName (display->display, TermWin.vt, "vt window"); 1236 XStoreName (display->display, TermWin.vt, "vt window");
1194#endif 1237#endif
1195 1238
1239 attributes.bit_gravity = NorthWestGravity;
1240 XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes);
1241
1196 vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask 1242 vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask;
1197 | PropertyChangeMask); 1243
1244 pointer_unblank ();
1198 1245
1199#ifdef POINTER_BLANK 1246#ifdef POINTER_BLANK
1200 pointer_unblank ();
1201
1202 if ((Options & Opt_pointerBlank)) 1247 if (Options & Opt_pointerBlank)
1203 vt_emask |= PointerMotionMask; 1248 vt_emask |= PointerMotionMask;
1204 else 1249 else
1205#endif 1250#endif
1206 vt_emask |= (Button1MotionMask | Button3MotionMask); 1251 vt_emask |= Button1MotionMask | Button3MotionMask;
1207 1252
1208 XSelectInput (display->display, TermWin.vt, vt_emask); 1253 XSelectInput (display->display, TermWin.vt, vt_emask);
1209 vt_ev.start (display, TermWin.vt); 1254 vt_ev.start (display, TermWin.vt);
1210 1255
1211#if defined(MENUBAR) && (MENUBAR_MAX > 1) 1256#if defined(MENUBAR) && (MENUBAR_MAX > 1)
1237 1282
1238#ifdef XPM_BACKGROUND 1283#ifdef XPM_BACKGROUND
1239 if (rs[Rs_backgroundPixmap] != NULL 1284 if (rs[Rs_backgroundPixmap] != NULL
1240 && ! (Options & Opt_transparent)) 1285 && ! (Options & Opt_transparent))
1241 { 1286 {
1242 const char *p = rs[Rs_backgroundPixmap]; 1287 const char *p = rs[Rs_backgroundPixmap];
1243 1288
1244 if ((p = STRCHR (p, ';')) != NULL) 1289 if ((p = STRCHR (p, ';')) != NULL)
1245 { 1290 {
1246 p++; 1291 p++;
1247 scale_pixmap (p); 1292 scale_pixmap (p);
1264#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 1309#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
1265 gcvalue.foreground = PixColors[Color_topShadow]; 1310 gcvalue.foreground = PixColors[Color_topShadow];
1266 topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 1311 topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
1267 gcvalue.foreground = PixColors[Color_bottomShadow]; 1312 gcvalue.foreground = PixColors[Color_bottomShadow];
1268 botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 1313 botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
1269 gcvalue.foreground = PixColors[ (XDEPTH <= 2 ? Color_fg : Color_scroll)]; 1314 gcvalue.foreground = PixColors[ (display->depth <= 2 ? Color_fg : Color_scroll)];
1270 scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 1315 scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
1316#endif
1317
1318#ifdef OFF_FOCUS_FADING
1319 // initially we are in unfocused state
1320 if (rs[Rs_fade])
1321 PixColors = PixColorsUnFocused;
1271#endif 1322#endif
1272} 1323}
1273 1324
1274/*----------------------------------------------------------------------*/ 1325/*----------------------------------------------------------------------*/
1275/* 1326/*

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines