1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: init.c |
2 | * File: init.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * - original version |
7 | * - original version |
… | |
… | |
313 | #endif |
313 | #endif |
314 | #ifndef NO_CURSORCOLOR |
314 | #ifndef NO_CURSORCOLOR |
315 | COLOR_CURSOR_BACKGROUND, |
315 | COLOR_CURSOR_BACKGROUND, |
316 | COLOR_CURSOR_FOREGROUND, |
316 | COLOR_CURSOR_FOREGROUND, |
317 | #endif /* ! NO_CURSORCOLOR */ |
317 | #endif /* ! NO_CURSORCOLOR */ |
318 | NULL, /* Color_pointer */ |
318 | NULL, /* Color_pointer_fg */ |
|
|
319 | NULL, /* Color_pointer_bg */ |
319 | NULL, /* Color_border */ |
320 | NULL, /* Color_border */ |
320 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
321 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
321 | NULL, /* Color_BD */ |
322 | NULL, /* Color_BD */ |
322 | NULL, /* Color_UL */ |
323 | NULL, /* Color_UL */ |
323 | NULL, /* Color_RV */ |
324 | NULL, /* Color_RV */ |
… | |
… | |
327 | #endif |
328 | #endif |
328 | #ifdef KEEP_SCROLLCOLOR |
329 | #ifdef KEEP_SCROLLCOLOR |
329 | COLOR_SCROLLBAR, |
330 | COLOR_SCROLLBAR, |
330 | COLOR_SCROLLTROUGH, |
331 | COLOR_SCROLLTROUGH, |
331 | #endif /* KEEP_SCROLLCOLOR */ |
332 | #endif /* KEEP_SCROLLCOLOR */ |
332 | |
333 | #if TINTING |
|
|
334 | NULL, |
|
|
335 | #endif |
333 | }; |
336 | }; |
334 | |
337 | |
335 | const char *const xa_names[NUM_XA] = |
338 | const char *const xa_names[NUM_XA] = |
336 | { |
339 | { |
337 | "TEXT", |
340 | "TEXT", |
… | |
… | |
644 | color_aliases (Color_bg); |
647 | color_aliases (Color_bg); |
645 | #ifndef NO_CURSORCOLOR |
648 | #ifndef NO_CURSORCOLOR |
646 | color_aliases (Color_cursor); |
649 | color_aliases (Color_cursor); |
647 | color_aliases (Color_cursor2); |
650 | color_aliases (Color_cursor2); |
648 | #endif /* NO_CURSORCOLOR */ |
651 | #endif /* NO_CURSORCOLOR */ |
649 | color_aliases (Color_pointer); |
652 | color_aliases (Color_pointer_fg); |
|
|
653 | color_aliases (Color_pointer_bg); |
650 | color_aliases (Color_border); |
654 | color_aliases (Color_border); |
651 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
655 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
652 | color_aliases (Color_BD); |
656 | color_aliases (Color_BD); |
653 | color_aliases (Color_UL); |
657 | color_aliases (Color_UL); |
654 | color_aliases (Color_RV); |
658 | color_aliases (Color_RV); |
… | |
… | |
748 | void |
752 | void |
749 | rxvt_term::set_locale (const char *locale) |
753 | rxvt_term::set_locale (const char *locale) |
750 | { |
754 | { |
751 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
755 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
752 | free (this->locale); |
756 | free (this->locale); |
753 | this->locale = rxvt_strdup (setlocale (LC_CTYPE, locale)); |
757 | this->locale = setlocale (LC_CTYPE, locale); |
|
|
758 | |
|
|
759 | if (!this->locale) |
|
|
760 | { |
|
|
761 | rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale); |
|
|
762 | setlocale (LC_CTYPE, ""); |
|
|
763 | this->locale = ""; |
|
|
764 | } |
|
|
765 | |
|
|
766 | this->locale = rxvt_strdup (this->locale); |
754 | SET_LOCALE (this->locale); |
767 | SET_LOCALE (this->locale); |
755 | mbstate.reset (); |
768 | mbstate.reset (); |
756 | #endif |
769 | #endif |
757 | #if 0 |
770 | #if 0 |
758 | #if HAVE_NL_LANGINFO |
771 | #if HAVE_NL_LANGINFO |
… | |
… | |
821 | meta_char = (Options & Opt_meta8 ? 0x80 : C0_ESC); |
834 | meta_char = (Options & Opt_meta8 ? 0x80 : C0_ESC); |
822 | #endif |
835 | #endif |
823 | |
836 | |
824 | get_ourmods (); |
837 | get_ourmods (); |
825 | |
838 | |
826 | if (! (Options & Opt_scrollTtyOutput)) |
839 | if (!(Options & Opt_scrollTtyOutput)) |
827 | PrivateModes |= PrivMode_TtyOutputInh; |
840 | PrivateModes |= PrivMode_TtyOutputInh; |
828 | if (Options & Opt_scrollTtyKeypress) |
841 | if (Options & Opt_scrollTtyKeypress) |
829 | PrivateModes |= PrivMode_Keypress; |
842 | PrivateModes |= PrivMode_Keypress; |
830 | if (! (Options & Opt_jumpScroll)) |
843 | if (!(Options & Opt_jumpScroll)) |
831 | PrivateModes |= PrivMode_smoothScroll; |
844 | PrivateModes |= PrivMode_smoothScroll; |
832 | |
845 | |
833 | #ifndef NO_BACKSPACE_KEY |
846 | #ifndef NO_BACKSPACE_KEY |
834 | if (STRCMP (key_backspace, "DEC") == 0) |
847 | if (STRCMP (key_backspace, "DEC") == 0) |
835 | PrivateModes |= PrivMode_HaveBackSpace; |
848 | PrivateModes |= PrivMode_HaveBackSpace; |
… | |
… | |
894 | #ifndef NO_CURSORCOLOR |
907 | #ifndef NO_CURSORCOLOR |
895 | case Color_cursor2: |
908 | case Color_cursor2: |
896 | xcol = PixColors[Color_fg]; |
909 | xcol = PixColors[Color_fg]; |
897 | break; |
910 | break; |
898 | #endif /* ! NO_CURSORCOLOR */ |
911 | #endif /* ! NO_CURSORCOLOR */ |
899 | case Color_pointer: |
912 | case Color_pointer_fg: |
900 | xcol = PixColors[Color_fg]; |
913 | xcol = PixColors[Color_fg]; |
901 | break; |
914 | break; |
902 | default: |
915 | default: |
903 | xcol = PixColors[Color_bg]; /* None */ |
916 | xcol = PixColors[Color_bg]; /* None */ |
904 | break; |
917 | break; |
… | |
… | |
908 | |
921 | |
909 | PixColors[i] = xcol; |
922 | PixColors[i] = xcol; |
910 | SET_PIXCOLOR (i); |
923 | SET_PIXCOLOR (i); |
911 | } |
924 | } |
912 | |
925 | |
913 | if (XDEPTH <= 2 || !rs[Rs_color + Color_pointer]) |
926 | if (XDEPTH <= 2) |
914 | PixColors[Color_pointer] = PixColors[Color_fg]; |
927 | { |
915 | if (XDEPTH <= 2 || !rs[Rs_color + Color_border]) |
928 | if (!rs[Rs_color + Color_pointer_fg]) PixColors[Color_pointer_fg] = PixColors[Color_fg]; |
916 | PixColors[Color_border] = PixColors[Color_fg]; |
929 | if (!rs[Rs_color + Color_pointer_bg]) PixColors[Color_pointer_bg] = PixColors[Color_bg]; |
|
|
930 | if (!rs[Rs_color + Color_border] ) PixColors[Color_border] = PixColors[Color_fg]; |
|
|
931 | } |
917 | |
932 | |
918 | /* |
933 | /* |
919 | * get scrollBar/menuBar shadow colors |
934 | * get scrollBar/menuBar shadow colors |
920 | * |
935 | * |
921 | * The calculations of topShadow/bottomShadow values are adapted |
936 | * The calculations of topShadow/bottomShadow values are adapted |
… | |
… | |
923 | */ |
938 | */ |
924 | #ifdef KEEP_SCROLLCOLOR |
939 | #ifdef KEEP_SCROLLCOLOR |
925 | |
940 | |
926 | if (XDEPTH <= 2) |
941 | if (XDEPTH <= 2) |
927 | { /* Monochrome */ |
942 | { /* Monochrome */ |
928 | PixColors[Color_scroll] = PixColors[Color_fg]; |
943 | PixColors[Color_scroll] = PixColors[Color_fg]; |
929 | PixColors[Color_topShadow] = PixColors[Color_bg]; |
944 | PixColors[Color_topShadow] = PixColors[Color_bg]; |
930 | PixColors[Color_bottomShadow] = PixColors[Color_bg]; |
945 | PixColors[Color_bottomShadow] = PixColors[Color_bg]; |
931 | } |
946 | } |
932 | else |
947 | else |
933 | { |
948 | { |
934 | rxvt_color xcol[3]; |
949 | rxvt_color xcol[3]; |
935 | /* xcol[0] == white |
950 | /* xcol[0] == white |
936 | * xcol[1] == top shadow |
951 | * xcol[1] == top shadow |
937 | * xcol[2] == bot shadow */ |
952 | * xcol[2] == bot shadow */ |
938 | |
953 | |
939 | xcol[1] = PixColors[Color_scroll]; |
954 | xcol[1] = PixColors[Color_scroll]; |
… | |
… | |
1065 | /*----------------------------------------------------------------------*/ |
1080 | /*----------------------------------------------------------------------*/ |
1066 | /* rxvt_Create_Windows () - Open and map the window */ |
1081 | /* rxvt_Create_Windows () - Open and map the window */ |
1067 | void |
1082 | void |
1068 | rxvt_term::create_windows (int argc, const char *const *argv) |
1083 | rxvt_term::create_windows (int argc, const char *const *argv) |
1069 | { |
1084 | { |
1070 | XClassHint classHint; |
1085 | XClassHint classHint; |
1071 | XWMHints wmHint; |
1086 | XWMHints wmHint; |
1072 | XGCValues gcvalue; |
1087 | XGCValues gcvalue; |
1073 | long vt_emask; |
1088 | long vt_emask; |
1074 | |
1089 | XSetWindowAttributes attributes; |
1075 | XWindowAttributes gattr; |
1090 | XWindowAttributes gattr; |
1076 | |
1091 | |
1077 | if (Options & Opt_transparent) |
1092 | if (Options & Opt_transparent) |
1078 | { |
1093 | { |
1079 | XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); |
1094 | XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); |
… | |
… | |
1092 | |
1107 | |
1093 | window_calc (0, 0); |
1108 | window_calc (0, 0); |
1094 | old_width = szHint.width; |
1109 | old_width = szHint.width; |
1095 | old_height = szHint.height; |
1110 | old_height = szHint.height; |
1096 | |
1111 | |
1097 | /* parent window - reverse video so we can see placement errors |
|
|
1098 | * sub-window placement & size in rxvt_resize_subwindows () |
1112 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
1099 | */ |
|
|
1100 | |
1113 | |
1101 | #ifdef PREFER_24BIT |
1114 | #ifdef PREFER_24BIT |
1102 | XSetWindowAttributes attributes; |
|
|
1103 | |
|
|
1104 | attributes.background_pixel = PixColors[Color_fg]; |
1115 | attributes.background_pixel = PixColors[Color_bg]; |
1105 | attributes.border_pixel = PixColors[Color_border]; |
1116 | attributes.border_pixel = PixColors[Color_border]; |
1106 | attributes.colormap = display->cmap; |
1117 | attributes.colormap = display->cmap; |
1107 | TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display), |
1118 | TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display), |
1108 | szHint.x, szHint.y, |
1119 | szHint.x, szHint.y, |
1109 | szHint.width, szHint.height, |
1120 | szHint.width, szHint.height, |
1110 | TermWin.ext_bwidth, |
1121 | TermWin.ext_bwidth, |
1111 | display->depth, InputOutput, |
1122 | display->depth, InputOutput, |
1112 | display->visual, |
1123 | display->visual, |
1113 | CWBackPixel | CWBorderPixel | CWColormap, &attributes); |
1124 | CWColormap | CWBackPixel | CWBorderPixel, &attributes); |
1114 | #else |
1125 | #else |
1115 | TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display), |
1126 | TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display), |
1116 | szHint.x, szHint.y, |
1127 | szHint.x, szHint.y, |
1117 | szHint.width, |
1128 | szHint.width, szHint.height, |
1118 | szHint.height, |
|
|
1119 | TermWin.ext_bwidth, |
1129 | TermWin.ext_bwidth, |
1120 | PixColors[Color_border], |
1130 | PixColors[Color_border], |
1121 | PixColors[Color_fg]); |
1131 | PixColors[Color_bg]); |
1122 | #endif |
1132 | #endif |
1123 | |
1133 | |
1124 | xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); |
1134 | process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); |
1125 | xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); |
1135 | process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); |
1126 | |
1136 | |
1127 | classHint.res_name = (char *)rs[Rs_name]; |
1137 | classHint.res_name = (char *)rs[Rs_name]; |
1128 | classHint.res_class = (char *)RESCLASS; |
1138 | classHint.res_class = (char *)RESCLASS; |
1129 | |
1139 | |
1130 | wmHint.flags = (InputHint | StateHint | WindowGroupHint); |
1140 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1131 | wmHint.input = True; |
1141 | wmHint.input = True; |
1132 | wmHint.initial_state = (Options & Opt_iconic ? IconicState |
1142 | wmHint.initial_state = Options & Opt_iconic ? IconicState : NormalState; |
1133 | : NormalState); |
|
|
1134 | wmHint.window_group = TermWin.parent[0]; |
1143 | wmHint.window_group = TermWin.parent[0]; |
1135 | |
1144 | |
1136 | XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL, |
1145 | XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL, |
1137 | (char **)argv, argc, &szHint, &wmHint, &classHint); |
1146 | (char **)argv, argc, &szHint, &wmHint, &classHint); |
|
|
1147 | |
|
|
1148 | #ifndef NO_FRILLS |
|
|
1149 | long pid = getpid (); |
|
|
1150 | XChangeProperty (display->display, TermWin.parent[0], |
|
|
1151 | display->atom ("_NET_WM_PID"), XA_CARDINAL, 32, |
|
|
1152 | PropModeReplace, (unsigned char *)&pid, 1); |
|
|
1153 | #endif |
1138 | |
1154 | |
1139 | XSelectInput (display->display, TermWin.parent[0], |
1155 | XSelectInput (display->display, TermWin.parent[0], |
1140 | KeyPressMask |
1156 | KeyPressMask |
1141 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1157 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1142 | | KeyReleaseMask |
1158 | | KeyReleaseMask |
… | |
… | |
1166 | } |
1182 | } |
1167 | #endif |
1183 | #endif |
1168 | |
1184 | |
1169 | /* the vt window */ |
1185 | /* the vt window */ |
1170 | TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0], |
1186 | TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0], |
1171 | window_vt_x, window_vt_y, |
1187 | window_vt_x, |
|
|
1188 | window_vt_y, |
1172 | TermWin_TotalWidth (), |
1189 | TermWin_TotalWidth (), |
1173 | TermWin_TotalHeight (), |
1190 | TermWin_TotalHeight (), |
1174 | 0, |
1191 | 0, |
1175 | PixColors[Color_fg], |
1192 | PixColors[Color_fg], |
1176 | PixColors[Color_bg]); |
1193 | PixColors[Color_bg]); |
1177 | |
1194 | |
1178 | #ifdef DEBUG_X |
1195 | #ifdef DEBUG_X |
1179 | XStoreName (display->display, TermWin.vt, "vt window"); |
1196 | XStoreName (display->display, TermWin.vt, "vt window"); |
1180 | #endif |
1197 | #endif |
1181 | |
1198 | |
|
|
1199 | attributes.bit_gravity = NorthWestGravity; |
|
|
1200 | XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes); |
|
|
1201 | |
1182 | vt_emask = (ExposureMask | ButtonPressMask | ButtonReleaseMask |
1202 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1183 | | PropertyChangeMask); |
|
|
1184 | |
1203 | |
1185 | #ifdef POINTER_BLANK |
1204 | #ifdef POINTER_BLANK |
1186 | pointer_unblank (); |
1205 | pointer_unblank (); |
1187 | |
1206 | |
1188 | if ((Options & Opt_pointerBlank)) |
1207 | if (Options & Opt_pointerBlank) |
1189 | vt_emask |= PointerMotionMask; |
1208 | vt_emask |= PointerMotionMask; |
1190 | else |
1209 | else |
1191 | #endif |
1210 | #endif |
1192 | vt_emask |= (Button1MotionMask | Button3MotionMask); |
1211 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1193 | |
1212 | |
1194 | XSelectInput (display->display, TermWin.vt, vt_emask); |
1213 | XSelectInput (display->display, TermWin.vt, vt_emask); |
1195 | vt_ev.start (display, TermWin.vt); |
1214 | vt_ev.start (display, TermWin.vt); |
1196 | |
1215 | |
1197 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
1216 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |