… | |
… | |
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 |
… | |
… | |
660 | pointerBlankDelay = i; |
660 | pointerBlankDelay = i; |
661 | else |
661 | else |
662 | pointerBlankDelay = 2; |
662 | pointerBlankDelay = 2; |
663 | #endif |
663 | #endif |
664 | |
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; |
|
|
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 | |
669 | if (!rs[Rs_cutchars]) |
676 | if (!rs[Rs_cutchars]) |
… | |
… | |
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 | |
749 | void |
760 | void |
750 | rxvt_term::init (int argc, const char *const *argv, const char *const *envv) |
761 | rxvt_term::init (int argc, const char *const *argv, const char *const *envv) |
… | |
… | |
768 | void |
779 | void |
769 | rxvt_term::init2 (int argc, const char *const *argv) |
780 | rxvt_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 | |
… | |
… | |
945 | |
956 | |
946 | /*----------------------------------------------------------------------*/ |
957 | /*----------------------------------------------------------------------*/ |
947 | void |
958 | void |
948 | rxvt_term::set_locale (const char *locale) |
959 | rxvt_term::set_locale (const char *locale) |
949 | { |
960 | { |
950 | set_environ (envv); |
961 | set_environ (env); |
951 | |
962 | |
952 | free (this->locale); |
963 | free (this->locale); |
953 | this->locale = setlocale (LC_CTYPE, locale); |
964 | this->locale = setlocale (LC_CTYPE, locale); |
954 | |
965 | |
955 | if (!this->locale) |
966 | if (!this->locale) |
… | |
… | |
983 | } |
994 | } |
984 | |
995 | |
985 | void |
996 | void |
986 | rxvt_term::init_xlocale () |
997 | rxvt_term::init_xlocale () |
987 | { |
998 | { |
988 | set_environ (envv); |
999 | set_environ (env); |
989 | |
1000 | |
990 | #if USE_XIM |
1001 | #if USE_XIM |
991 | if (!locale) |
1002 | if (!locale) |
992 | rxvt_warn ("setting locale failed, continuing without locale support.\n"); |
1003 | rxvt_warn ("setting locale failed, continuing without locale support.\n"); |
993 | else |
1004 | else |
… | |
… | |
1045 | run_command (argv); |
1056 | run_command (argv); |
1046 | } |
1057 | } |
1047 | |
1058 | |
1048 | /*----------------------------------------------------------------------*/ |
1059 | /*----------------------------------------------------------------------*/ |
1049 | void |
1060 | void |
1050 | rxvt_term::get_colours () |
1061 | rxvt_term::get_colors () |
1051 | { |
1062 | { |
1052 | int i; |
1063 | int i; |
1053 | |
1064 | |
1054 | #ifdef OFF_FOCUS_FADING |
1065 | #ifdef OFF_FOCUS_FADING |
1055 | pix_colors = pix_colors_focused; |
1066 | pix_colors = pix_colors_focused; |
1056 | #endif |
1067 | #endif |
1057 | |
1068 | |
1058 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
1069 | for (i = 0; i < NRS_COLORS; i++) |
1059 | { |
1070 | { |
1060 | const char *name = rs[Rs_color + i]; |
1071 | const char *name = rs[Rs_color + i]; |
1061 | |
1072 | |
1062 | if (!name) |
1073 | if (!name) |
1063 | continue; |
1074 | continue; |
… | |
… | |
1073 | #endif |
1084 | #endif |
1074 | name = def_colorName [i]; |
1085 | name = def_colorName [i]; |
1075 | |
1086 | |
1076 | if (!name) |
1087 | if (!name) |
1077 | continue; |
1088 | continue; |
|
|
1089 | |
|
|
1090 | xcol.free (this); |
1078 | |
1091 | |
1079 | if (!set_color (xcol, name)) |
1092 | if (!set_color (xcol, name)) |
1080 | { |
1093 | { |
1081 | switch (i) |
1094 | switch (i) |
1082 | { |
1095 | { |
… | |
… | |
1102 | |
1115 | |
1103 | pix_colors[i] = xcol; |
1116 | pix_colors[i] = xcol; |
1104 | rs[Rs_color + i] = name; |
1117 | rs[Rs_color + i] = name; |
1105 | } |
1118 | } |
1106 | |
1119 | |
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 | |
|
|
1114 | /* |
1120 | /* |
1115 | * get scrollBar shadow colors |
1121 | * get scrollBar shadow colors |
1116 | * |
1122 | * |
1117 | * The calculations of topShadow/bottomShadow values are adapted |
1123 | * The calculations of topShadow/bottomShadow values are adapted |
1118 | * from the fvwm window manager. |
1124 | * from the fvwm window manager. |
1119 | */ |
1125 | */ |
1120 | #ifdef RXVT_SCROLLBAR |
1126 | #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]); |
1127 | pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); |
1131 | |
1128 | |
1132 | rgba cscroll; |
1129 | rgba cscroll; |
1133 | pix_colors [Color_scroll].get (cscroll); |
1130 | pix_colors [Color_scroll].get (cscroll); |
1134 | |
1131 | |
1135 | /* topShadowColor */ |
1132 | /* topShadowColor */ |
1136 | if (!pix_colors[Color_topShadow].set (this, |
1133 | if (!pix_colors[Color_topShadow].set (this, |
1137 | rgba ( |
1134 | rgba ( |
1138 | min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), |
1135 | 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), |
1136 | 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), |
1137 | min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), |
1141 | cscroll.a) |
1138 | cscroll.a) |
1142 | )) |
1139 | )) |
1143 | alias_color (Color_topShadow, Color_White); |
1140 | alias_color (Color_topShadow, Color_White); |
1144 | } |
|
|
1145 | #endif |
1141 | #endif |
1146 | |
1142 | |
1147 | #ifdef OFF_FOCUS_FADING |
1143 | #ifdef OFF_FOCUS_FADING |
1148 | for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) |
1144 | for (i = 0; i < NRS_COLORS; i++) |
1149 | update_fade_color (i); |
1145 | update_fade_color (i, true); |
1150 | #endif |
1146 | #endif |
1151 | } |
1147 | } |
1152 | |
1148 | |
1153 | /*----------------------------------------------------------------------*/ |
1149 | /*----------------------------------------------------------------------*/ |
1154 | /* color aliases, fg/bg bright-bold */ |
1150 | /* color aliases, fg/bg bright-bold */ |
… | |
… | |
1203 | for (j = map->max_keypermod; j--; k++) |
1199 | for (j = map->max_keypermod; j--; k++) |
1204 | { |
1200 | { |
1205 | if (kc[k] == 0) |
1201 | if (kc[k] == 0) |
1206 | break; |
1202 | break; |
1207 | |
1203 | |
1208 | switch (XKeycodeToKeysym (dpy, kc[k], 0)) |
1204 | switch (rxvt_XKeycodeToKeysym (dpy, kc[k], 0)) |
1209 | { |
1205 | { |
1210 | case XK_Num_Lock: |
1206 | case XK_Num_Lock: |
1211 | ModNumLockMask = modmasks[i - 1]; |
1207 | ModNumLockMask = modmasks[i - 1]; |
1212 | continue; |
1208 | continue; |
1213 | |
1209 | |
… | |
… | |
1333 | Window top, parent; |
1329 | Window top, parent; |
1334 | |
1330 | |
1335 | dLocal (Display *, dpy); |
1331 | dLocal (Display *, dpy); |
1336 | |
1332 | |
1337 | /* grab colors before netscape does */ |
1333 | /* grab colors before netscape does */ |
1338 | get_colours (); |
1334 | get_colors (); |
1339 | |
1335 | |
1340 | if (!set_fonts ()) |
1336 | if (!set_fonts ()) |
1341 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
1337 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
1342 | |
1338 | |
1343 | parent = display->root; |
1339 | parent = display->root; |
… | |
… | |
1396 | classHint.res_name = (char *)rs[Rs_name]; |
1392 | classHint.res_name = (char *)rs[Rs_name]; |
1397 | classHint.res_class = (char *)RESCLASS; |
1393 | classHint.res_class = (char *)RESCLASS; |
1398 | |
1394 | |
1399 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1395 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1400 | wmHint.input = True; |
1396 | wmHint.input = True; |
1401 | wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState; |
1397 | wmHint.initial_state = option (Opt_iconic) ? IconicState |
|
|
1398 | : option (Opt_dockapp) ? WithdrawnState |
|
|
1399 | : NormalState; |
1402 | wmHint.window_group = top; |
1400 | wmHint.window_group = top; |
1403 | |
1401 | |
1404 | XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, |
1402 | XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, |
1405 | &szHint, &wmHint, &classHint); |
1403 | &szHint, &wmHint, &classHint); |
1406 | #if ENABLE_EWMH |
1404 | #if ENABLE_EWMH |
… | |
… | |
1408 | * set up icon hint |
1406 | * set up icon hint |
1409 | * rs [Rs_iconfile] is path to icon |
1407 | * rs [Rs_iconfile] is path to icon |
1410 | */ |
1408 | */ |
1411 | |
1409 | |
1412 | if (rs [Rs_iconfile]) |
1410 | if (rs [Rs_iconfile]) |
1413 | { |
|
|
1414 | set_icon (rs [Rs_iconfile]); |
1411 | set_icon (rs [Rs_iconfile]); |
1415 | } |
|
|
1416 | #endif |
1412 | #endif |
1417 | |
1413 | |
1418 | #if ENABLE_FRILLS |
1414 | #if ENABLE_FRILLS |
1419 | if (mwmhints.flags) |
1415 | if (mwmhints.flags) |
1420 | XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
1416 | XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
… | |
… | |
1496 | if (rs[Rs_fade]) |
1492 | if (rs[Rs_fade]) |
1497 | pix_colors = pix_colors_unfocused; |
1493 | pix_colors = pix_colors_unfocused; |
1498 | #endif |
1494 | #endif |
1499 | |
1495 | |
1500 | pointer_unblank (); |
1496 | pointer_unblank (); |
1501 | scr_recolour (); |
1497 | scr_recolor (); |
1502 | } |
1498 | } |
1503 | |
1499 | |
1504 | /*----------------------------------------------------------------------*/ |
1500 | /*----------------------------------------------------------------------*/ |
1505 | /* |
1501 | /* |
1506 | * Run the command in a subprocess and return a file descriptor for the |
1502 | * Run the command in a subprocess and return a file descriptor for the |