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.51 by pcg, Sun May 9 18:19:49 2004 UTC vs.
Revision 1.68 by root, Tue Aug 10 20:39:19 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),
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 XSetWindowAttributes attributes; 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]))
1143 display->atom ("_NET_WM_PID"), XA_CARDINAL, 32, 1183 display->atom ("_NET_WM_PID"), XA_CARDINAL, 32,
1144 PropModeReplace, (unsigned char *)&pid, 1); 1184 PropModeReplace, (unsigned char *)&pid, 1);
1145#endif 1185#endif
1146 1186
1147 XSelectInput (display->display, TermWin.parent[0], 1187 XSelectInput (display->display, TermWin.parent[0],
1148 KeyPressMask 1188 KeyPressMask
1149#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1189#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1150 | KeyReleaseMask 1190 | KeyReleaseMask
1151#endif 1191#endif
1152 | FocusChangeMask | VisibilityChangeMask 1192 | FocusChangeMask | VisibilityChangeMask
1193 | ExposureMask
1153 | StructureNotifyMask); 1194 | StructureNotifyMask);
1154 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
1155 1204
1156 /* 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 */
1157 TermWin_cursor = XCreateFontCursor (display->display, XC_xterm); 1206 TermWin_cursor = XCreateFontCursor (display->display, XC_xterm);
1158 1207
1159#if defined(HAVE_SCROLLBARS) || defined(MENUBAR) 1208#if defined(HAVE_SCROLLBARS) || defined(MENUBAR)
1174 } 1223 }
1175#endif 1224#endif
1176 1225
1177 /* the vt window */ 1226 /* the vt window */
1178 TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0], 1227 TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0],
1179 window_vt_x, window_vt_y, 1228 window_vt_x,
1229 window_vt_y,
1180 TermWin_TotalWidth (), 1230 TermWin_TotalWidth (),
1181 TermWin_TotalHeight (), 1231 TermWin_TotalHeight (),
1182 0, 1232 0,
1183 PixColors[Color_fg], 1233 PixColors[Color_fg],
1184 PixColors[Color_bg]); 1234 PixColors[Color_bg]);
1185
1186#ifdef DEBUG_X 1235#ifdef DEBUG_X
1187 XStoreName (display->display, TermWin.vt, "vt window"); 1236 XStoreName (display->display, TermWin.vt, "vt window");
1188#endif 1237#endif
1189 1238
1190 attributes.bit_gravity = NorthWestGravity; 1239 attributes.bit_gravity = NorthWestGravity;
1191 XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes); 1240 XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes);
1192 1241
1193 vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; 1242 vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask;
1194 1243
1244 pointer_unblank ();
1245
1195#ifdef POINTER_BLANK 1246#ifdef POINTER_BLANK
1196 pointer_unblank ();
1197
1198 if (Options & Opt_pointerBlank) 1247 if (Options & Opt_pointerBlank)
1199 vt_emask |= PointerMotionMask; 1248 vt_emask |= PointerMotionMask;
1200 else 1249 else
1201#endif 1250#endif
1202 vt_emask |= Button1MotionMask | Button3MotionMask; 1251 vt_emask |= Button1MotionMask | Button3MotionMask;
1233 1282
1234#ifdef XPM_BACKGROUND 1283#ifdef XPM_BACKGROUND
1235 if (rs[Rs_backgroundPixmap] != NULL 1284 if (rs[Rs_backgroundPixmap] != NULL
1236 && ! (Options & Opt_transparent)) 1285 && ! (Options & Opt_transparent))
1237 { 1286 {
1238 const char *p = rs[Rs_backgroundPixmap]; 1287 const char *p = rs[Rs_backgroundPixmap];
1239 1288
1240 if ((p = STRCHR (p, ';')) != NULL) 1289 if ((p = STRCHR (p, ';')) != NULL)
1241 { 1290 {
1242 p++; 1291 p++;
1243 scale_pixmap (p); 1292 scale_pixmap (p);
1260#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 1309#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
1261 gcvalue.foreground = PixColors[Color_topShadow]; 1310 gcvalue.foreground = PixColors[Color_topShadow];
1262 topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 1311 topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
1263 gcvalue.foreground = PixColors[Color_bottomShadow]; 1312 gcvalue.foreground = PixColors[Color_bottomShadow];
1264 botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); 1313 botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue);
1265 gcvalue.foreground = PixColors[ (XDEPTH <= 2 ? Color_fg : Color_scroll)]; 1314 gcvalue.foreground = PixColors[ (display->depth <= 2 ? Color_fg : Color_scroll)];
1266 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;
1267#endif 1322#endif
1268} 1323}
1269 1324
1270/*----------------------------------------------------------------------*/ 1325/*----------------------------------------------------------------------*/
1271/* 1326/*
1295 { 1350 {
1296 close (cfd); 1351 close (cfd);
1297 rxvt_fatal ("can't open slave tty %s", ttydev); 1352 rxvt_fatal ("can't open slave tty %s", ttydev);
1298 } 1353 }
1299 } 1354 }
1355
1300#ifndef NO_BACKSPACE_KEY 1356#ifndef NO_BACKSPACE_KEY
1301 if (key_backspace[0] && !key_backspace[1]) 1357 if (key_backspace[0] && !key_backspace[1])
1302 er = key_backspace[0]; 1358 er = key_backspace[0];
1303 else if (STRCMP (key_backspace, "DEC") == 0) 1359 else if (STRCMP (key_backspace, "DEC") == 0)
1304 er = '\177'; /* the initial state anyway */ 1360 er = '\177'; /* the initial state anyway */
1305 else 1361 else
1306#endif 1362#endif
1307
1308 er = -1; 1363 er = -1;
1309 1364
1310 rxvt_get_ttymode (& (tio), er); 1365 rxvt_get_ttymode (&tio, er);
1311 1366
1312#ifndef __QNX__ 1367#ifndef __QNX__
1313 /* spin off the command interpreter */ 1368 /* spin off the command interpreter */
1314 switch (cmd_pid = fork ()) 1369 switch (cmd_pid = fork ())
1315 { 1370 {
1396#elif defined (SRIOCSREDIR) 1451#elif defined (SRIOCSREDIR)
1397 int fd; 1452 int fd;
1398 1453
1399 fd = open (CONSOLE, O_WRONLY, 0); 1454 fd = open (CONSOLE, O_WRONLY, 0);
1400 if (fd >= 0) 1455 if (fd >= 0)
1401 {
1402 if (ioctl (fd, SRIOCSREDIR, NULL) < 0) 1456 if (ioctl (fd, SRIOCSREDIR, NULL) < 0)
1403 close (fd); 1457 close (fd);
1404 }
1405#endif /* SRIOCSREDIR */ 1458#endif /* SRIOCSREDIR */
1406 1459
1407 } 1460 }
1408 1461
1409 /* reset signals and spin off the command interpreter */ 1462 /* reset signals and spin off the command interpreter */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines