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.321 by sf-exg, Sat Feb 4 21:47:06 2012 UTC vs.
Revision 1.344 by sf-exg, Tue Jun 16 11:58:26 2015 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
42 42
43#include <signal.h> 43#include <signal.h>
44 44
45#include <fcntl.h> 45#include <fcntl.h>
46 46
47#ifdef HAVE_XMU
48# include <X11/Xmu/CurUtil.h>
49#endif
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
51# include <locale.h> 55# include <locale.h>
76#include <netinet/in.h> 80#include <netinet/in.h>
77#include <arpa/inet.h> 81#include <arpa/inet.h>
78#include <net/if.h> 82#include <net/if.h>
79#include <net/if_arp.h> 83#include <net/if_arp.h>
80 84
81static char * 85static char * ecb_cold
82rxvt_network_display (const char *display) 86rxvt_network_display (const char *display)
83{ 87{
84 char buffer[1024], *rval = NULL; 88 char buffer[1024], *rval = NULL;
85 struct ifconf ifc; 89 struct ifconf ifc;
86 struct ifreq *ifr; 90 struct ifreq *ifr;
519#endif 523#endif
520 COLOR_SCROLLBAR, 524 COLOR_SCROLLBAR,
521#ifdef RXVT_SCROLLBAR 525#ifdef RXVT_SCROLLBAR
522 COLOR_SCROLLTROUGH, 526 COLOR_SCROLLTROUGH,
523#endif 527#endif
524#if ENABLE_TRANSPARENCY 528#if BG_IMAGE_FROM_ROOT
525 NULL, 529 NULL,
526#endif 530#endif
527#if OFF_FOCUS_FADING 531#if OFF_FOCUS_FADING
528 "rgb:00/00/00", 532 "rgb:00/00/00",
529#endif 533#endif
588 xa = display->xa; 592 xa = display->xa;
589 593
590 set (display); 594 set (display);
591 extract_resources (); 595 extract_resources ();
592 596
593#if XFT 597#if ENABLE_FRILLS
594 if (rs[Rs_depth]) 598 if (rs[Rs_visual])
595 select_visual (strtol (rs[Rs_depth], 0, 0)); 599 select_visual (strtol (rs[Rs_visual], 0, 0));
600 else if (rs[Rs_depth])
601 select_depth (strtol (rs[Rs_depth], 0, 0));
596#endif 602#endif
597 603
598 for (int i = NUM_RESOURCES; i--; ) 604 for (int i = NUM_RESOURCES; i--; )
599 if (rs [i] == resval_undef) 605 if (rs [i] == resval_undef)
600 rs [i] = 0; 606 rs [i] = 0;
657 if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0) 663 if (rs[Rs_pointerBlankDelay] && (i = atoi (rs[Rs_pointerBlankDelay])) >= 0)
658 pointerBlankDelay = i; 664 pointerBlankDelay = i;
659 else 665 else
660 pointerBlankDelay = 2; 666 pointerBlankDelay = 2;
661#endif 667#endif
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;
662 675
663 /* no point having a scrollbar without having any scrollback! */ 676 /* no point having a scrollbar without having any scrollback! */
664 if (!saveLines) 677 if (!saveLines)
665 set_option (Opt_scrollBar, 0); 678 set_option (Opt_scrollBar, 0);
666 679
739 envv->push_back (0); 752 envv->push_back (0);
740 753
741 this->argv = argv; 754 this->argv = argv;
742 this->envv = envv; 755 this->envv = envv;
743 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
744 init2 (argv->size () - 1, argv->begin ()); 761 init2 (argv->size () - 1, argv->begin ());
745} 762}
746 763
747void 764void
748rxvt_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)
766void 783void
767rxvt_term::init2 (int argc, const char *const *argv) 784rxvt_term::init2 (int argc, const char *const *argv)
768{ 785{
769 SET_R (this); 786 SET_R (this);
770 set_locale (""); 787 set_locale ("");
771 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 :(
772 789
773 init_vars (); 790 init_vars ();
774 791
775 const char **cmd_argv = init_resources (argc, argv); 792 const char **cmd_argv = init_resources (argc, argv);
776 793
791 if (option (Opt_scrollBar)) 808 if (option (Opt_scrollBar))
792 scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */ 809 scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */
793 810
794 pty = ptytty::create (); 811 pty = ptytty::create ();
795 812
796 // must be called before create_windows, because the latter may call set_icon
797#ifdef HAVE_PIXBUF
798 g_type_init ();
799#endif
800
801 create_windows (argc, argv); 813 create_windows (argc, argv);
802 814
803 init_xlocale (); 815 init_xlocale ();
804 816
805 scr_poweron (); // initialize screen 817 scr_poweron (); // initialize screen
808 XSynchronize (dpy, True); 820 XSynchronize (dpy, True);
809#endif 821#endif
810 822
811 if (option (Opt_scrollBar)) 823 if (option (Opt_scrollBar))
812 scrollBar.resize (); /* create and map scrollbar */ 824 scrollBar.resize (); /* create and map scrollbar */
825
813#ifdef HAVE_BG_PIXMAP 826#ifdef HAVE_BG_PIXMAP
814 {
815 bg_init (); 827 bg_init ();
816
817#ifdef ENABLE_TRANSPARENCY
818 if (option (Opt_transparent))
819 {
820 bg_set_transparent ();
821
822 if (rs [Rs_blurradius])
823 bg_set_blur (rs [Rs_blurradius]);
824
825 if (ISSET_PIXCOLOR (Color_tint))
826 bg_set_tint (pix_colors_focused [Color_tint]);
827
828 if (rs [Rs_shade])
829 bg_set_shade (rs [Rs_shade]);
830
831 bg_set_root_pixmap ();
832 XSelectInput (dpy, display->root, PropertyChangeMask);
833 rootwin_ev.start (display, display->root);
834 }
835#endif
836
837#ifdef BG_IMAGE_FROM_FILE
838 if (rs[Rs_backgroundPixmap])
839 if (bg_set_file (rs[Rs_backgroundPixmap]))
840 if (!bg_window_position_sensitive ())
841 update_background ();
842#endif
843 }
844#endif 828#endif
845 829
846#if ENABLE_PERL 830#if ENABLE_PERL
847 rootwin_ev.start (display, display->root); 831 rootwin_ev.start (display, display->root);
848#endif 832#endif
976 960
977/*----------------------------------------------------------------------*/ 961/*----------------------------------------------------------------------*/
978void 962void
979rxvt_term::set_locale (const char *locale) 963rxvt_term::set_locale (const char *locale)
980{ 964{
981 set_environ (envv); 965 set_environ (env);
982 966
983 free (this->locale); 967 free (this->locale);
984 this->locale = setlocale (LC_CTYPE, locale); 968 this->locale = setlocale (LC_CTYPE, locale);
985 969
986 if (!this->locale) 970 if (!this->locale)
1014} 998}
1015 999
1016void 1000void
1017rxvt_term::init_xlocale () 1001rxvt_term::init_xlocale ()
1018{ 1002{
1019 set_environ (envv); 1003 set_environ (env);
1020 1004
1021#ifdef USE_XIM 1005#if USE_XIM
1022 if (!locale) 1006 if (!locale)
1023 rxvt_warn ("setting locale failed, continuing without locale support.\n"); 1007 rxvt_warn ("setting locale failed, continuing without locale support.\n");
1024 else 1008 else
1025 { 1009 {
1026 set_string_property (xa[XA_WM_LOCALE_NAME], locale); 1010 set_string_property (xa[XA_WM_LOCALE_NAME], locale);
1076 run_command (argv); 1060 run_command (argv);
1077} 1061}
1078 1062
1079/*----------------------------------------------------------------------*/ 1063/*----------------------------------------------------------------------*/
1080void 1064void
1081rxvt_term::get_colours () 1065rxvt_term::get_colors ()
1082{ 1066{
1083 int i; 1067 int i;
1084 1068
1085#ifdef OFF_FOCUS_FADING 1069#ifdef OFF_FOCUS_FADING
1086 pix_colors = pix_colors_focused; 1070 pix_colors = pix_colors_focused;
1087#endif 1071#endif
1088 1072
1089 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 1073 for (i = 0; i < NRS_COLORS; i++)
1090 {
1091 const char *name = rs[Rs_color + i]; 1074 if (const char *name = rs[Rs_color + i])
1092
1093 if (!name)
1094 continue;
1095
1096 rxvt_color xcol;
1097
1098 if (!set_color (xcol, name)) 1075 set_color (pix_colors [i], name);
1099 {
1100#ifndef XTERM_REVERSE_VIDEO
1101 if (i < 2 && option (Opt_reverseVideo))
1102 name = def_colorName [1 - i];
1103 else
1104#endif
1105 name = def_colorName [i];
1106
1107 if (!name)
1108 continue;
1109
1110 if (!set_color (xcol, name))
1111 {
1112 switch (i)
1113 {
1114 case Color_fg:
1115 case Color_bg:
1116 rxvt_warn ("unable to get foreground/background colour, continuing.\n");
1117 name = "";
1118 break;
1119#ifndef NO_CURSORCOLOR
1120 case Color_cursor2:
1121#endif
1122 case Color_pointer_fg:
1123 name = rs[Rs_color + Color_fg];
1124 xcol.set (this, name);
1125 break;
1126 default:
1127 name = rs[Rs_color + Color_bg];
1128 xcol.set (this, name);
1129 break;
1130 }
1131 }
1132 }
1133
1134 pix_colors[i] = xcol;
1135 rs[Rs_color + i] = name;
1136 }
1137
1138 if (depth <= 2)
1139 {
1140 if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg);
1141 if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg);
1142 if (!rs[Rs_color + Color_border] ) alias_color (Color_border, Color_fg);
1143 }
1144 1076
1145 /* 1077 /*
1146 * get scrollBar shadow colors 1078 * get scrollBar shadow colors
1147 * 1079 *
1148 * The calculations of topShadow/bottomShadow values are adapted 1080 * The calculations of topShadow/bottomShadow values are adapted
1149 * from the fvwm window manager. 1081 * from the fvwm window manager.
1150 */ 1082 */
1151#ifdef RXVT_SCROLLBAR 1083#ifdef RXVT_SCROLLBAR
1152 if (depth <= 2)
1153 {
1154 /* Monochrome */
1155 alias_color (Color_scroll, Color_fg);
1156 alias_color (Color_topShadow, Color_bg);
1157 alias_color (Color_bottomShadow, Color_bg);
1158 }
1159 else
1160 {
1161 pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); 1084 pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]);
1162 1085
1163 rgba cscroll; 1086 rgba cscroll;
1164 pix_colors [Color_scroll].get (cscroll); 1087 pix_colors [Color_scroll].get (cscroll);
1165 1088
1166 /* topShadowColor */ 1089 /* topShadowColor */
1167 if (!pix_colors[Color_topShadow].set (this, 1090 if (!pix_colors[Color_topShadow].set (this,
1168 rgba ( 1091 rgba (
1169 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),
1170 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),
1171 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),
1172 cscroll.a) 1095 cscroll.a)
1173 )) 1096 ))
1174 alias_color (Color_topShadow, Color_White); 1097 alias_color (Color_topShadow, Color_White);
1175 }
1176#endif 1098#endif
1177 1099
1178#ifdef OFF_FOCUS_FADING 1100#ifdef OFF_FOCUS_FADING
1179 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 1101 for (i = 0; i < NRS_COLORS; i++)
1180 update_fade_color (i); 1102 update_fade_color (i, true);
1181#endif 1103#endif
1182} 1104}
1183 1105
1184/*----------------------------------------------------------------------*/ 1106/*----------------------------------------------------------------------*/
1185/* color aliases, fg/bg bright-bold */ 1107/* color aliases, fg/bg bright-bold */
1234 for (j = map->max_keypermod; j--; k++) 1156 for (j = map->max_keypermod; j--; k++)
1235 { 1157 {
1236 if (kc[k] == 0) 1158 if (kc[k] == 0)
1237 break; 1159 break;
1238 1160
1239 switch (XKeycodeToKeysym (dpy, kc[k], 0)) 1161 switch (rxvt_XKeycodeToKeysym (dpy, kc[k], 0))
1240 { 1162 {
1241 case XK_Num_Lock: 1163 case XK_Num_Lock:
1242 ModNumLockMask = modmasks[i - 1]; 1164 ModNumLockMask = modmasks[i - 1];
1243 continue; 1165 continue;
1244 1166
1289} 1211}
1290 1212
1291void 1213void
1292rxvt_term::set_icon (const char *file) 1214rxvt_term::set_icon (const char *file)
1293{ 1215{
1294#ifdef HAVE_PIXBUF 1216#if HAVE_PIXBUF && ENABLE_EWMH
1295 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); 1217 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL);
1296 if (!pixbuf) 1218 if (!pixbuf)
1297 { 1219 {
1298 rxvt_warn ("Loading image icon failed, continuing without.\n"); 1220 rxvt_warn ("Loading image icon failed, continuing without.\n");
1299 return; 1221 return;
1364 Window top, parent; 1286 Window top, parent;
1365 1287
1366 dLocal (Display *, dpy); 1288 dLocal (Display *, dpy);
1367 1289
1368 /* grab colors before netscape does */ 1290 /* grab colors before netscape does */
1369 get_colours (); 1291 get_colors ();
1370 1292
1371 if (!set_fonts ()) 1293 if (!set_fonts ())
1372 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");
1373 1295
1374 parent = display->root; 1296 parent = display->root;
1427 classHint.res_name = (char *)rs[Rs_name]; 1349 classHint.res_name = (char *)rs[Rs_name];
1428 classHint.res_class = (char *)RESCLASS; 1350 classHint.res_class = (char *)RESCLASS;
1429 1351
1430 wmHint.flags = InputHint | StateHint | WindowGroupHint; 1352 wmHint.flags = InputHint | StateHint | WindowGroupHint;
1431 wmHint.input = True; 1353 wmHint.input = True;
1432 wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState; 1354 wmHint.initial_state = option (Opt_iconic) ? IconicState
1355 : option (Opt_dockapp) ? WithdrawnState
1356 : NormalState;
1433 wmHint.window_group = top; 1357 wmHint.window_group = top;
1434 1358
1435 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, 1359 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
1436 &szHint, &wmHint, &classHint); 1360 &szHint, &wmHint, &classHint);
1437#if ENABLE_EWMH 1361#if ENABLE_EWMH
1439 * set up icon hint 1363 * set up icon hint
1440 * rs [Rs_iconfile] is path to icon 1364 * rs [Rs_iconfile] is path to icon
1441 */ 1365 */
1442 1366
1443 if (rs [Rs_iconfile]) 1367 if (rs [Rs_iconfile])
1444 {
1445 set_icon (rs [Rs_iconfile]); 1368 set_icon (rs [Rs_iconfile]);
1446 }
1447#endif 1369#endif
1448 1370
1449#if ENABLE_FRILLS 1371#if ENABLE_FRILLS
1450 if (mwmhints.flags) 1372 if (mwmhints.flags)
1451 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, 1373 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32,
1485 | ExposureMask | StructureNotifyMask); 1407 | ExposureMask | StructureNotifyMask);
1486 1408
1487 termwin_ev.start (display, top); 1409 termwin_ev.start (display, top);
1488 1410
1489 /* 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
1490 TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); 1423 TermWin_cursor = XCreateFontCursor (dpy, shape);
1491 1424
1492 /* the vt window */ 1425 /* the vt window */
1493 vt = XCreateSimpleWindow (dpy, top, 1426 vt = XCreateSimpleWindow (dpy, top,
1494 window_vt_x, window_vt_y, 1427 window_vt_x, window_vt_y,
1495 vt_width, vt_height, 1428 vt_width, vt_height,
1527 if (rs[Rs_fade]) 1460 if (rs[Rs_fade])
1528 pix_colors = pix_colors_unfocused; 1461 pix_colors = pix_colors_unfocused;
1529#endif 1462#endif
1530 1463
1531 pointer_unblank (); 1464 pointer_unblank ();
1532 scr_recolour (); 1465 scr_recolor ();
1533} 1466}
1534 1467
1535/*----------------------------------------------------------------------*/ 1468/*----------------------------------------------------------------------*/
1536/* 1469/*
1537 * 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