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.325 by sf-exg, Thu May 31 05:53:46 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
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
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 root_effects.set_blur (rs [Rs_blurradius]);
824
825 if (ISSET_PIXCOLOR (Color_tint))
826 root_effects.set_tint (pix_colors_focused [Color_tint]);
827
828 if (rs [Rs_shade])
829 root_effects.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#endif 828#endif
838 829
839#if ENABLE_PERL 830#if ENABLE_PERL
840 rootwin_ev.start (display, display->root); 831 rootwin_ev.start (display, display->root);
841#endif 832#endif
969 960
970/*----------------------------------------------------------------------*/ 961/*----------------------------------------------------------------------*/
971void 962void
972rxvt_term::set_locale (const char *locale) 963rxvt_term::set_locale (const char *locale)
973{ 964{
974 set_environ (envv); 965 set_environ (env);
975 966
976 free (this->locale); 967 free (this->locale);
977 this->locale = setlocale (LC_CTYPE, locale); 968 this->locale = setlocale (LC_CTYPE, locale);
978 969
979 if (!this->locale) 970 if (!this->locale)
1007} 998}
1008 999
1009void 1000void
1010rxvt_term::init_xlocale () 1001rxvt_term::init_xlocale ()
1011{ 1002{
1012 set_environ (envv); 1003 set_environ (env);
1013 1004
1014#ifdef USE_XIM 1005#if USE_XIM
1015 if (!locale) 1006 if (!locale)
1016 rxvt_warn ("setting locale failed, continuing without locale support.\n"); 1007 rxvt_warn ("setting locale failed, continuing without locale support.\n");
1017 else 1008 else
1018 { 1009 {
1019 set_string_property (xa[XA_WM_LOCALE_NAME], locale); 1010 set_string_property (xa[XA_WM_LOCALE_NAME], locale);
1069 run_command (argv); 1060 run_command (argv);
1070} 1061}
1071 1062
1072/*----------------------------------------------------------------------*/ 1063/*----------------------------------------------------------------------*/
1073void 1064void
1074rxvt_term::get_colours () 1065rxvt_term::get_colors ()
1075{ 1066{
1076 int i; 1067 int i;
1077 1068
1078#ifdef OFF_FOCUS_FADING 1069#ifdef OFF_FOCUS_FADING
1079 pix_colors = pix_colors_focused; 1070 pix_colors = pix_colors_focused;
1080#endif 1071#endif
1081 1072
1082 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 1073 for (i = 0; i < NRS_COLORS; i++)
1083 {
1084 const char *name = rs[Rs_color + i]; 1074 if (const char *name = rs[Rs_color + i])
1085
1086 if (!name)
1087 continue;
1088
1089 rxvt_color xcol;
1090
1091 if (!set_color (xcol, name)) 1075 set_color (pix_colors [i], name);
1092 {
1093#ifndef XTERM_REVERSE_VIDEO
1094 if (i < 2 && option (Opt_reverseVideo))
1095 name = def_colorName [1 - i];
1096 else
1097#endif
1098 name = def_colorName [i];
1099
1100 if (!name)
1101 continue;
1102
1103 if (!set_color (xcol, name))
1104 {
1105 switch (i)
1106 {
1107 case Color_fg:
1108 case Color_bg:
1109 rxvt_warn ("unable to get foreground/background colour, continuing.\n");
1110 name = "";
1111 break;
1112#ifndef NO_CURSORCOLOR
1113 case Color_cursor2:
1114#endif
1115 case Color_pointer_fg:
1116 name = rs[Rs_color + Color_fg];
1117 xcol.set (this, name);
1118 break;
1119 default:
1120 name = rs[Rs_color + Color_bg];
1121 xcol.set (this, name);
1122 break;
1123 }
1124 }
1125 }
1126
1127 pix_colors[i] = xcol;
1128 rs[Rs_color + i] = name;
1129 }
1130
1131 if (depth <= 2)
1132 {
1133 if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg);
1134 if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg);
1135 if (!rs[Rs_color + Color_border] ) alias_color (Color_border, Color_fg);
1136 }
1137 1076
1138 /* 1077 /*
1139 * get scrollBar shadow colors 1078 * get scrollBar shadow colors
1140 * 1079 *
1141 * The calculations of topShadow/bottomShadow values are adapted 1080 * The calculations of topShadow/bottomShadow values are adapted
1142 * from the fvwm window manager. 1081 * from the fvwm window manager.
1143 */ 1082 */
1144#ifdef RXVT_SCROLLBAR 1083#ifdef RXVT_SCROLLBAR
1145 if (depth <= 2)
1146 {
1147 /* Monochrome */
1148 alias_color (Color_scroll, Color_fg);
1149 alias_color (Color_topShadow, Color_bg);
1150 alias_color (Color_bottomShadow, Color_bg);
1151 }
1152 else
1153 {
1154 pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); 1084 pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]);
1155 1085
1156 rgba cscroll; 1086 rgba cscroll;
1157 pix_colors [Color_scroll].get (cscroll); 1087 pix_colors [Color_scroll].get (cscroll);
1158 1088
1159 /* topShadowColor */ 1089 /* topShadowColor */
1160 if (!pix_colors[Color_topShadow].set (this, 1090 if (!pix_colors[Color_topShadow].set (this,
1161 rgba ( 1091 rgba (
1162 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),
1163 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),
1164 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),
1165 cscroll.a) 1095 cscroll.a)
1166 )) 1096 ))
1167 alias_color (Color_topShadow, Color_White); 1097 alias_color (Color_topShadow, Color_White);
1168 }
1169#endif 1098#endif
1170 1099
1171#ifdef OFF_FOCUS_FADING 1100#ifdef OFF_FOCUS_FADING
1172 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 1101 for (i = 0; i < NRS_COLORS; i++)
1173 update_fade_color (i); 1102 update_fade_color (i, true);
1174#endif 1103#endif
1175} 1104}
1176 1105
1177/*----------------------------------------------------------------------*/ 1106/*----------------------------------------------------------------------*/
1178/* color aliases, fg/bg bright-bold */ 1107/* color aliases, fg/bg bright-bold */
1227 for (j = map->max_keypermod; j--; k++) 1156 for (j = map->max_keypermod; j--; k++)
1228 { 1157 {
1229 if (kc[k] == 0) 1158 if (kc[k] == 0)
1230 break; 1159 break;
1231 1160
1232 switch (XKeycodeToKeysym (dpy, kc[k], 0)) 1161 switch (rxvt_XKeycodeToKeysym (dpy, kc[k], 0))
1233 { 1162 {
1234 case XK_Num_Lock: 1163 case XK_Num_Lock:
1235 ModNumLockMask = modmasks[i - 1]; 1164 ModNumLockMask = modmasks[i - 1];
1236 continue; 1165 continue;
1237 1166
1282} 1211}
1283 1212
1284void 1213void
1285rxvt_term::set_icon (const char *file) 1214rxvt_term::set_icon (const char *file)
1286{ 1215{
1287#ifdef HAVE_PIXBUF 1216#if HAVE_PIXBUF && ENABLE_EWMH
1288 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); 1217 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL);
1289 if (!pixbuf) 1218 if (!pixbuf)
1290 { 1219 {
1291 rxvt_warn ("Loading image icon failed, continuing without.\n"); 1220 rxvt_warn ("Loading image icon failed, continuing without.\n");
1292 return; 1221 return;
1357 Window top, parent; 1286 Window top, parent;
1358 1287
1359 dLocal (Display *, dpy); 1288 dLocal (Display *, dpy);
1360 1289
1361 /* grab colors before netscape does */ 1290 /* grab colors before netscape does */
1362 get_colours (); 1291 get_colors ();
1363 1292
1364 if (!set_fonts ()) 1293 if (!set_fonts ())
1365 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");
1366 1295
1367 parent = display->root; 1296 parent = display->root;
1420 classHint.res_name = (char *)rs[Rs_name]; 1349 classHint.res_name = (char *)rs[Rs_name];
1421 classHint.res_class = (char *)RESCLASS; 1350 classHint.res_class = (char *)RESCLASS;
1422 1351
1423 wmHint.flags = InputHint | StateHint | WindowGroupHint; 1352 wmHint.flags = InputHint | StateHint | WindowGroupHint;
1424 wmHint.input = True; 1353 wmHint.input = True;
1425 wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState; 1354 wmHint.initial_state = option (Opt_iconic) ? IconicState
1355 : option (Opt_dockapp) ? WithdrawnState
1356 : NormalState;
1426 wmHint.window_group = top; 1357 wmHint.window_group = top;
1427 1358
1428 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, 1359 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
1429 &szHint, &wmHint, &classHint); 1360 &szHint, &wmHint, &classHint);
1430#if ENABLE_EWMH 1361#if ENABLE_EWMH
1432 * set up icon hint 1363 * set up icon hint
1433 * rs [Rs_iconfile] is path to icon 1364 * rs [Rs_iconfile] is path to icon
1434 */ 1365 */
1435 1366
1436 if (rs [Rs_iconfile]) 1367 if (rs [Rs_iconfile])
1437 {
1438 set_icon (rs [Rs_iconfile]); 1368 set_icon (rs [Rs_iconfile]);
1439 }
1440#endif 1369#endif
1441 1370
1442#if ENABLE_FRILLS 1371#if ENABLE_FRILLS
1443 if (mwmhints.flags) 1372 if (mwmhints.flags)
1444 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,
1478 | ExposureMask | StructureNotifyMask); 1407 | ExposureMask | StructureNotifyMask);
1479 1408
1480 termwin_ev.start (display, top); 1409 termwin_ev.start (display, top);
1481 1410
1482 /* 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
1483 TermWin_cursor = XCreateFontCursor (dpy, XC_xterm); 1423 TermWin_cursor = XCreateFontCursor (dpy, shape);
1484 1424
1485 /* the vt window */ 1425 /* the vt window */
1486 vt = XCreateSimpleWindow (dpy, top, 1426 vt = XCreateSimpleWindow (dpy, top,
1487 window_vt_x, window_vt_y, 1427 window_vt_x, window_vt_y,
1488 vt_width, vt_height, 1428 vt_width, vt_height,
1520 if (rs[Rs_fade]) 1460 if (rs[Rs_fade])
1521 pix_colors = pix_colors_unfocused; 1461 pix_colors = pix_colors_unfocused;
1522#endif 1462#endif
1523 1463
1524 pointer_unblank (); 1464 pointer_unblank ();
1525 scr_recolour (); 1465 scr_recolor ();
1526} 1466}
1527 1467
1528/*----------------------------------------------------------------------*/ 1468/*----------------------------------------------------------------------*/
1529/* 1469/*
1530 * 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