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.333 by mikachu, Tue Jul 29 13:50:05 2014 UTC vs.
Revision 1.344 by sf-exg, Tue Jun 16 11:58:26 2015 UTC

41#include <limits> 41#include <limits>
42 42
43#include <signal.h> 43#include <signal.h>
44 44
45#include <fcntl.h> 45#include <fcntl.h>
46
47#ifdef HAVE_XMU
48# include <X11/Xmu/CurUtil.h>
49#endif
46 50
47#ifdef HAVE_XSETLOCALE 51#ifdef HAVE_XSETLOCALE
48# define X_LOCALE 52# define X_LOCALE
49# include <X11/Xlocale.h> 53# include <X11/Xlocale.h>
50#else 54#else
660 pointerBlankDelay = i; 664 pointerBlankDelay = i;
661 else 665 else
662 pointerBlankDelay = 2; 666 pointerBlankDelay = 2;
663#endif 667#endif
664 668
669 if (rs[Rs_multiClickTime] && (i = atoi (rs[Rs_multiClickTime])) >= 0)
670 multiClickTime = i;
671 else
672 multiClickTime = 500;
673
674 cursor_type = option (Opt_cursorUnderline) ? 1 : 0;
675
665 /* no point having a scrollbar without having any scrollback! */ 676 /* no point having a scrollbar without having any scrollback! */
666 if (!saveLines) 677 if (!saveLines)
667 set_option (Opt_scrollBar, 0); 678 set_option (Opt_scrollBar, 0);
668 679
669 if (!rs[Rs_cutchars]) 680 if (!rs[Rs_cutchars])
741 envv->push_back (0); 752 envv->push_back (0);
742 753
743 this->argv = argv; 754 this->argv = argv;
744 this->envv = envv; 755 this->envv = envv;
745 756
757 env = new char *[this->envv->size ()];
758 for (int i = 0; i < this->envv->size (); i++)
759 env[i] = this->envv->at (i);
760
746 init2 (argv->size () - 1, argv->begin ()); 761 init2 (argv->size () - 1, argv->begin ());
747} 762}
748 763
749void 764void
750rxvt_term::init (int argc, const char *const *argv, const char *const *envv) 765rxvt_term::init (int argc, const char *const *argv, const char *const *envv)
768void 783void
769rxvt_term::init2 (int argc, const char *const *argv) 784rxvt_term::init2 (int argc, const char *const *argv)
770{ 785{
771 SET_R (this); 786 SET_R (this);
772 set_locale (""); 787 set_locale ("");
773 set_environ (envv); // a few things in X do not call setlocale :( 788 set_environ (env); // a few things in X do not call setlocale :(
774 789
775 init_vars (); 790 init_vars ();
776 791
777 const char **cmd_argv = init_resources (argc, argv); 792 const char **cmd_argv = init_resources (argc, argv);
778 793
945 960
946/*----------------------------------------------------------------------*/ 961/*----------------------------------------------------------------------*/
947void 962void
948rxvt_term::set_locale (const char *locale) 963rxvt_term::set_locale (const char *locale)
949{ 964{
950 set_environ (envv); 965 set_environ (env);
951 966
952 free (this->locale); 967 free (this->locale);
953 this->locale = setlocale (LC_CTYPE, locale); 968 this->locale = setlocale (LC_CTYPE, locale);
954 969
955 if (!this->locale) 970 if (!this->locale)
983} 998}
984 999
985void 1000void
986rxvt_term::init_xlocale () 1001rxvt_term::init_xlocale ()
987{ 1002{
988 set_environ (envv); 1003 set_environ (env);
989 1004
990#if USE_XIM 1005#if USE_XIM
991 if (!locale) 1006 if (!locale)
992 rxvt_warn ("setting locale failed, continuing without locale support.\n"); 1007 rxvt_warn ("setting locale failed, continuing without locale support.\n");
993 else 1008 else
1045 run_command (argv); 1060 run_command (argv);
1046} 1061}
1047 1062
1048/*----------------------------------------------------------------------*/ 1063/*----------------------------------------------------------------------*/
1049void 1064void
1050rxvt_term::get_colours () 1065rxvt_term::get_colors ()
1051{ 1066{
1052 int i; 1067 int i;
1053 1068
1054#ifdef OFF_FOCUS_FADING 1069#ifdef OFF_FOCUS_FADING
1055 pix_colors = pix_colors_focused; 1070 pix_colors = pix_colors_focused;
1056#endif 1071#endif
1057 1072
1058 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 1073 for (i = 0; i < NRS_COLORS; i++)
1059 {
1060 const char *name = rs[Rs_color + i]; 1074 if (const char *name = rs[Rs_color + i])
1061
1062 if (!name)
1063 continue;
1064
1065 rxvt_color xcol;
1066
1067 if (!set_color (xcol, name)) 1075 set_color (pix_colors [i], name);
1068 {
1069#ifndef XTERM_REVERSE_VIDEO
1070 if (i < 2 && option (Opt_reverseVideo))
1071 name = def_colorName [1 - i];
1072 else
1073#endif
1074 name = def_colorName [i];
1075
1076 if (!name)
1077 continue;
1078
1079 if (!set_color (xcol, name))
1080 {
1081 switch (i)
1082 {
1083 case Color_fg:
1084 case Color_bg:
1085 rxvt_warn ("unable to get foreground/background colour, continuing.\n");
1086 name = "";
1087 break;
1088#ifndef NO_CURSORCOLOR
1089 case Color_cursor2:
1090#endif
1091 case Color_pointer_fg:
1092 name = rs[Rs_color + Color_fg];
1093 xcol.set (this, name);
1094 break;
1095 default:
1096 name = rs[Rs_color + Color_bg];
1097 xcol.set (this, name);
1098 break;
1099 }
1100 }
1101 }
1102
1103 pix_colors[i] = xcol;
1104 rs[Rs_color + i] = name;
1105 }
1106
1107 if (depth <= 2)
1108 {
1109 if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg);
1110 if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg);
1111 if (!rs[Rs_color + Color_border] ) alias_color (Color_border, Color_fg);
1112 }
1113 1076
1114 /* 1077 /*
1115 * get scrollBar shadow colors 1078 * get scrollBar shadow colors
1116 * 1079 *
1117 * The calculations of topShadow/bottomShadow values are adapted 1080 * The calculations of topShadow/bottomShadow values are adapted
1118 * from the fvwm window manager. 1081 * from the fvwm window manager.
1119 */ 1082 */
1120#ifdef RXVT_SCROLLBAR 1083#ifdef RXVT_SCROLLBAR
1121 if (depth <= 2)
1122 {
1123 /* Monochrome */
1124 alias_color (Color_scroll, Color_fg);
1125 alias_color (Color_topShadow, Color_bg);
1126 alias_color (Color_bottomShadow, Color_bg);
1127 }
1128 else
1129 {
1130 pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); 1084 pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]);
1131 1085
1132 rgba cscroll; 1086 rgba cscroll;
1133 pix_colors [Color_scroll].get (cscroll); 1087 pix_colors [Color_scroll].get (cscroll);
1134 1088
1135 /* topShadowColor */ 1089 /* topShadowColor */
1136 if (!pix_colors[Color_topShadow].set (this, 1090 if (!pix_colors[Color_topShadow].set (this,
1137 rgba ( 1091 rgba (
1138 min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), 1092 min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5),
1139 min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), 1093 min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5),
1140 min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), 1094 min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5),
1141 cscroll.a) 1095 cscroll.a)
1142 )) 1096 ))
1143 alias_color (Color_topShadow, Color_White); 1097 alias_color (Color_topShadow, Color_White);
1144 }
1145#endif 1098#endif
1146 1099
1147#ifdef OFF_FOCUS_FADING 1100#ifdef OFF_FOCUS_FADING
1148 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 1101 for (i = 0; i < NRS_COLORS; i++)
1149 update_fade_color (i); 1102 update_fade_color (i, true);
1150#endif 1103#endif
1151} 1104}
1152 1105
1153/*----------------------------------------------------------------------*/ 1106/*----------------------------------------------------------------------*/
1154/* color aliases, fg/bg bright-bold */ 1107/* color aliases, fg/bg bright-bold */
1203 for (j = map->max_keypermod; j--; k++) 1156 for (j = map->max_keypermod; j--; k++)
1204 { 1157 {
1205 if (kc[k] == 0) 1158 if (kc[k] == 0)
1206 break; 1159 break;
1207 1160
1208 switch (XKeycodeToKeysym (dpy, kc[k], 0)) 1161 switch (rxvt_XKeycodeToKeysym (dpy, kc[k], 0))
1209 { 1162 {
1210 case XK_Num_Lock: 1163 case XK_Num_Lock:
1211 ModNumLockMask = modmasks[i - 1]; 1164 ModNumLockMask = modmasks[i - 1];
1212 continue; 1165 continue;
1213 1166
1258} 1211}
1259 1212
1260void 1213void
1261rxvt_term::set_icon (const char *file) 1214rxvt_term::set_icon (const char *file)
1262{ 1215{
1263#if HAVE_PIXBUF 1216#if HAVE_PIXBUF && ENABLE_EWMH
1264 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); 1217 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL);
1265 if (!pixbuf) 1218 if (!pixbuf)
1266 { 1219 {
1267 rxvt_warn ("Loading image icon failed, continuing without.\n"); 1220 rxvt_warn ("Loading image icon failed, continuing without.\n");
1268 return; 1221 return;
1333 Window top, parent; 1286 Window top, parent;
1334 1287
1335 dLocal (Display *, dpy); 1288 dLocal (Display *, dpy);
1336 1289
1337 /* grab colors before netscape does */ 1290 /* grab colors before netscape does */
1338 get_colours (); 1291 get_colors ();
1339 1292
1340 if (!set_fonts ()) 1293 if (!set_fonts ())
1341 rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); 1294 rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n");
1342 1295
1343 parent = display->root; 1296 parent = display->root;
1454 | ExposureMask | StructureNotifyMask); 1407 | ExposureMask | StructureNotifyMask);
1455 1408
1456 termwin_ev.start (display, top); 1409 termwin_ev.start (display, top);
1457 1410
1458 /* vt cursor: Black-on-White is standard, but this is more popular */ 1411 /* vt cursor: Black-on-White is standard, but this is more popular */
1412 unsigned int shape = XC_xterm;
1413
1414#ifdef HAVE_XMU
1415 if (rs[Rs_pointerShape])
1416 {
1417 int stmp = XmuCursorNameToIndex (rs[Rs_pointerShape]);
1418 if (stmp >= 0)
1419 shape = stmp;
1420 }
1421#endif
1422
1459 TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); 1423 TermWin_cursor = XCreateFontCursor (dpy, shape);
1460 1424
1461 /* the vt window */ 1425 /* the vt window */
1462 vt = XCreateSimpleWindow (dpy, top, 1426 vt = XCreateSimpleWindow (dpy, top,
1463 window_vt_x, window_vt_y, 1427 window_vt_x, window_vt_y,
1464 vt_width, vt_height, 1428 vt_width, vt_height,
1496 if (rs[Rs_fade]) 1460 if (rs[Rs_fade])
1497 pix_colors = pix_colors_unfocused; 1461 pix_colors = pix_colors_unfocused;
1498#endif 1462#endif
1499 1463
1500 pointer_unblank (); 1464 pointer_unblank ();
1501 scr_recolour (); 1465 scr_recolor ();
1502} 1466}
1503 1467
1504/*----------------------------------------------------------------------*/ 1468/*----------------------------------------------------------------------*/
1505/* 1469/*
1506 * Run the command in a subprocess and return a file descriptor for the 1470 * Run the command in a subprocess and return a file descriptor for the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines