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.328 by root, Thu Jun 7 16:04:31 2012 UTC vs.
Revision 1.341 by root, Mon Dec 15 00:51:06 2014 UTC

14 * - extensive modifications 14 * - extensive modifications
15 * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de> 15 * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de>
16 * 16 *
17 * This program is free software; you can redistribute it and/or modify 17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by 18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or 19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version. 20 * (at your option) any later version.
21 * 21 *
22 * This program is distributed in the hope that it will be useful, 22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
519#endif 519#endif
520 COLOR_SCROLLBAR, 520 COLOR_SCROLLBAR,
521#ifdef RXVT_SCROLLBAR 521#ifdef RXVT_SCROLLBAR
522 COLOR_SCROLLTROUGH, 522 COLOR_SCROLLTROUGH,
523#endif 523#endif
524#if ENABLE_TRANSPARENCY 524#if BG_IMAGE_FROM_ROOT
525 NULL, 525 NULL,
526#endif 526#endif
527#if OFF_FOCUS_FADING 527#if OFF_FOCUS_FADING
528 "rgb:00/00/00", 528 "rgb:00/00/00",
529#endif 529#endif
659 if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) 659 if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0)
660 pointerBlankDelay = i; 660 pointerBlankDelay = i;
661 else 661 else
662 pointerBlankDelay = 2; 662 pointerBlankDelay = 2;
663#endif 663#endif
664
665 if (rs[Rs_multiClickTime] && (i = atoi (rs[Rs_multiClickTime])) >= 0)
666 multiClickTime = i;
667 else
668 multiClickTime = 500;
669
670 cursor_type = option (Opt_cursorUnderline) ? 1 : 0;
664 671
665 /* no point having a scrollbar without having any scrollback! */ 672 /* no point having a scrollbar without having any scrollback! */
666 if (!saveLines) 673 if (!saveLines)
667 set_option (Opt_scrollBar, 0); 674 set_option (Opt_scrollBar, 0);
668 675
741 envv->push_back (0); 748 envv->push_back (0);
742 749
743 this->argv = argv; 750 this->argv = argv;
744 this->envv = envv; 751 this->envv = envv;
745 752
753 env = new char *[this->envv->size ()];
754 for (int i = 0; i < this->envv->size (); i++)
755 env[i] = this->envv->at (i);
756
746 init2 (argv->size () - 1, argv->begin ()); 757 init2 (argv->size () - 1, argv->begin ());
747} 758}
748 759
749void 760void
750rxvt_term::init (int argc, const char *const *argv, const char *const *envv) 761rxvt_term::init (int argc, const char *const *argv, const char *const *envv)
768void 779void
769rxvt_term::init2 (int argc, const char *const *argv) 780rxvt_term::init2 (int argc, const char *const *argv)
770{ 781{
771 SET_R (this); 782 SET_R (this);
772 set_locale (""); 783 set_locale ("");
773 set_environ (envv); // a few things in X do not call setlocale :( 784 set_environ (env); // a few things in X do not call setlocale :(
774 785
775 init_vars (); 786 init_vars ();
776 787
777 const char **cmd_argv = init_resources (argc, argv); 788 const char **cmd_argv = init_resources (argc, argv);
778 789
805 XSynchronize (dpy, True); 816 XSynchronize (dpy, True);
806#endif 817#endif
807 818
808 if (option (Opt_scrollBar)) 819 if (option (Opt_scrollBar))
809 scrollBar.resize (); /* create and map scrollbar */ 820 scrollBar.resize (); /* create and map scrollbar */
821
810#ifdef HAVE_BG_PIXMAP 822#ifdef HAVE_BG_PIXMAP
811 {
812 bg_init (); 823 bg_init ();
813
814#if ENABLE_TRANSPARENCY
815 if (option (Opt_transparent))
816 {
817 bg_set_transparent ();
818
819 if (rs [Rs_blurradius])
820 root_effects.set_blur (rs [Rs_blurradius]);
821
822 if (ISSET_PIXCOLOR (Color_tint))
823 root_effects.set_tint (pix_colors_focused [Color_tint]);
824
825 if (rs [Rs_shade])
826 root_effects.set_shade (rs [Rs_shade]);
827
828 bg_set_root_pixmap ();
829 XSelectInput (dpy, display->root, PropertyChangeMask);
830 rootwin_ev.start (display, display->root);
831 }
832#endif
833 }
834#endif 824#endif
835 825
836#if ENABLE_PERL 826#if ENABLE_PERL
837 rootwin_ev.start (display, display->root); 827 rootwin_ev.start (display, display->root);
838#endif 828#endif
966 956
967/*----------------------------------------------------------------------*/ 957/*----------------------------------------------------------------------*/
968void 958void
969rxvt_term::set_locale (const char *locale) 959rxvt_term::set_locale (const char *locale)
970{ 960{
971 set_environ (envv); 961 set_environ (env);
972 962
973 free (this->locale); 963 free (this->locale);
974 this->locale = setlocale (LC_CTYPE, locale); 964 this->locale = setlocale (LC_CTYPE, locale);
975 965
976 if (!this->locale) 966 if (!this->locale)
1004} 994}
1005 995
1006void 996void
1007rxvt_term::init_xlocale () 997rxvt_term::init_xlocale ()
1008{ 998{
1009 set_environ (envv); 999 set_environ (env);
1010 1000
1011#if USE_XIM 1001#if USE_XIM
1012 if (!locale) 1002 if (!locale)
1013 rxvt_warn ("setting locale failed, continuing without locale support.\n"); 1003 rxvt_warn ("setting locale failed, continuing without locale support.\n");
1014 else 1004 else
1066 run_command (argv); 1056 run_command (argv);
1067} 1057}
1068 1058
1069/*----------------------------------------------------------------------*/ 1059/*----------------------------------------------------------------------*/
1070void 1060void
1071rxvt_term::get_colours () 1061rxvt_term::get_colors ()
1072{ 1062{
1073 int i; 1063 int i;
1074 1064
1075#ifdef OFF_FOCUS_FADING 1065#ifdef OFF_FOCUS_FADING
1076 pix_colors = pix_colors_focused; 1066 pix_colors = pix_colors_focused;
1077#endif 1067#endif
1078 1068
1079 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 1069 for (i = 0; i < NRS_COLORS; i++)
1080 { 1070 {
1081 const char *name = rs[Rs_color + i]; 1071 const char *name = rs[Rs_color + i];
1082 1072
1083 if (!name) 1073 if (!name)
1084 continue; 1074 continue;
1085 1075
1086 rxvt_color xcol;
1087
1088 if (!set_color (xcol, name)) 1076 set_color (pix_colors [i], name);
1089 {
1090#ifndef XTERM_REVERSE_VIDEO
1091 if (i < 2 && option (Opt_reverseVideo))
1092 name = def_colorName [1 - i];
1093 else
1094#endif
1095 name = def_colorName [i];
1096
1097 if (!name)
1098 continue;
1099
1100 if (!set_color (xcol, name))
1101 {
1102 switch (i)
1103 {
1104 case Color_fg:
1105 case Color_bg:
1106 rxvt_warn ("unable to get foreground/background colour, continuing.\n");
1107 name = "";
1108 break;
1109#ifndef NO_CURSORCOLOR
1110 case Color_cursor2:
1111#endif
1112 case Color_pointer_fg:
1113 name = rs[Rs_color + Color_fg];
1114 xcol.set (this, name);
1115 break;
1116 default:
1117 name = rs[Rs_color + Color_bg];
1118 xcol.set (this, name);
1119 break;
1120 }
1121 }
1122 }
1123
1124 pix_colors[i] = xcol;
1125 rs[Rs_color + i] = name;
1126 }
1127
1128 if (depth <= 2)
1129 {
1130 if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg);
1131 if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg);
1132 if (!rs[Rs_color + Color_border] ) alias_color (Color_border, Color_fg);
1133 } 1077 }
1134 1078
1135 /* 1079 /*
1136 * get scrollBar shadow colors 1080 * get scrollBar shadow colors
1137 * 1081 *
1138 * The calculations of topShadow/bottomShadow values are adapted 1082 * The calculations of topShadow/bottomShadow values are adapted
1139 * from the fvwm window manager. 1083 * from the fvwm window manager.
1140 */ 1084 */
1141#ifdef RXVT_SCROLLBAR 1085#ifdef RXVT_SCROLLBAR
1142 if (depth <= 2)
1143 {
1144 /* Monochrome */
1145 alias_color (Color_scroll, Color_fg);
1146 alias_color (Color_topShadow, Color_bg);
1147 alias_color (Color_bottomShadow, Color_bg);
1148 }
1149 else
1150 {
1151 pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); 1086 pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]);
1152 1087
1153 rgba cscroll; 1088 rgba cscroll;
1154 pix_colors [Color_scroll].get (cscroll); 1089 pix_colors [Color_scroll].get (cscroll);
1155 1090
1156 /* topShadowColor */ 1091 /* topShadowColor */
1157 if (!pix_colors[Color_topShadow].set (this, 1092 if (!pix_colors[Color_topShadow].set (this,
1158 rgba ( 1093 rgba (
1159 min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), 1094 min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5),
1160 min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), 1095 min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5),
1161 min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), 1096 min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5),
1162 cscroll.a) 1097 cscroll.a)
1163 )) 1098 ))
1164 alias_color (Color_topShadow, Color_White); 1099 alias_color (Color_topShadow, Color_White);
1165 }
1166#endif 1100#endif
1167 1101
1168#ifdef OFF_FOCUS_FADING 1102#ifdef OFF_FOCUS_FADING
1169 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 1103 for (i = 0; i < NRS_COLORS; i++)
1170 update_fade_color (i); 1104 update_fade_color (i, true);
1171#endif 1105#endif
1172} 1106}
1173 1107
1174/*----------------------------------------------------------------------*/ 1108/*----------------------------------------------------------------------*/
1175/* color aliases, fg/bg bright-bold */ 1109/* color aliases, fg/bg bright-bold */
1224 for (j = map->max_keypermod; j--; k++) 1158 for (j = map->max_keypermod; j--; k++)
1225 { 1159 {
1226 if (kc[k] == 0) 1160 if (kc[k] == 0)
1227 break; 1161 break;
1228 1162
1229 switch (XKeycodeToKeysym (dpy, kc[k], 0)) 1163 switch (rxvt_XKeycodeToKeysym (dpy, kc[k], 0))
1230 { 1164 {
1231 case XK_Num_Lock: 1165 case XK_Num_Lock:
1232 ModNumLockMask = modmasks[i - 1]; 1166 ModNumLockMask = modmasks[i - 1];
1233 continue; 1167 continue;
1234 1168
1354 Window top, parent; 1288 Window top, parent;
1355 1289
1356 dLocal (Display *, dpy); 1290 dLocal (Display *, dpy);
1357 1291
1358 /* grab colors before netscape does */ 1292 /* grab colors before netscape does */
1359 get_colours (); 1293 get_colors ();
1360 1294
1361 if (!set_fonts ()) 1295 if (!set_fonts ())
1362 rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); 1296 rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n");
1363 1297
1364 parent = display->root; 1298 parent = display->root;
1417 classHint.res_name = (char *)rs[Rs_name]; 1351 classHint.res_name = (char *)rs[Rs_name];
1418 classHint.res_class = (char *)RESCLASS; 1352 classHint.res_class = (char *)RESCLASS;
1419 1353
1420 wmHint.flags = InputHint | StateHint | WindowGroupHint; 1354 wmHint.flags = InputHint | StateHint | WindowGroupHint;
1421 wmHint.input = True; 1355 wmHint.input = True;
1422 wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState; 1356 wmHint.initial_state = option (Opt_iconic) ? IconicState
1357 : option (Opt_dockapp) ? WithdrawnState
1358 : NormalState;
1423 wmHint.window_group = top; 1359 wmHint.window_group = top;
1424 1360
1425 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, 1361 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
1426 &szHint, &wmHint, &classHint); 1362 &szHint, &wmHint, &classHint);
1427#if ENABLE_EWMH 1363#if ENABLE_EWMH
1429 * set up icon hint 1365 * set up icon hint
1430 * rs [Rs_iconfile] is path to icon 1366 * rs [Rs_iconfile] is path to icon
1431 */ 1367 */
1432 1368
1433 if (rs [Rs_iconfile]) 1369 if (rs [Rs_iconfile])
1434 {
1435 set_icon (rs [Rs_iconfile]); 1370 set_icon (rs [Rs_iconfile]);
1436 }
1437#endif 1371#endif
1438 1372
1439#if ENABLE_FRILLS 1373#if ENABLE_FRILLS
1440 if (mwmhints.flags) 1374 if (mwmhints.flags)
1441 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, 1375 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32,
1517 if (rs[Rs_fade]) 1451 if (rs[Rs_fade])
1518 pix_colors = pix_colors_unfocused; 1452 pix_colors = pix_colors_unfocused;
1519#endif 1453#endif
1520 1454
1521 pointer_unblank (); 1455 pointer_unblank ();
1522 scr_recolour (); 1456 scr_recolor ();
1523} 1457}
1524 1458
1525/*----------------------------------------------------------------------*/ 1459/*----------------------------------------------------------------------*/
1526/* 1460/*
1527 * Run the command in a subprocess and return a file descriptor for the 1461 * Run the command in a subprocess and return a file descriptor for the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines