… | |
… | |
169 | COLOR_SCROLLTROUGH, |
169 | COLOR_SCROLLTROUGH, |
170 | #endif /* KEEP_SCROLLCOLOR */ |
170 | #endif /* KEEP_SCROLLCOLOR */ |
171 | #if TINTING |
171 | #if TINTING |
172 | NULL, |
172 | NULL, |
173 | #endif |
173 | #endif |
|
|
174 | #if OFF_FOCUS_FADING |
|
|
175 | "black", |
|
|
176 | #endif |
174 | }; |
177 | }; |
175 | |
178 | |
176 | const char *const xa_names[] = |
179 | const char *const xa_names[] = |
177 | { |
180 | { |
178 | "TEXT", |
181 | "TEXT", |
… | |
… | |
181 | "MULTIPLE", |
184 | "MULTIPLE", |
182 | "TARGETS", |
185 | "TARGETS", |
183 | "TIMESTAMP", |
186 | "TIMESTAMP", |
184 | "VT_SELECTION", |
187 | "VT_SELECTION", |
185 | "INCR", |
188 | "INCR", |
|
|
189 | "WM_PROTOCOLS", |
186 | "WM_DELETE_WINDOW", |
190 | "WM_DELETE_WINDOW", |
187 | "CLIPBOARD", |
191 | "CLIPBOARD", |
188 | #if ENABLE_FRILLS |
192 | #if ENABLE_FRILLS |
|
|
193 | "_MOTIF_WM_HINTS", |
|
|
194 | #endif |
|
|
195 | #if ENABLE_EWMH |
189 | "_NET_WM_PID", |
196 | "_NET_WM_PID", |
190 | "_MOTIF_WM_HINTS", |
|
|
191 | "_NET_WM_NAME", |
197 | "_NET_WM_NAME", |
192 | "_NET_WM_ICON_NAME", |
198 | "_NET_WM_ICON_NAME", |
|
|
199 | "_NET_WM_PING", |
193 | #endif |
200 | #endif |
194 | #if USE_XIM |
201 | #if USE_XIM |
195 | "WM_LOCALE_NAME", |
202 | "WM_LOCALE_NAME", |
196 | #endif |
203 | #endif |
197 | #ifdef TRANSPARENT |
204 | #ifdef TRANSPARENT |
… | |
… | |
199 | "ESETROOT_PMAP_ID", |
206 | "ESETROOT_PMAP_ID", |
200 | #endif |
207 | #endif |
201 | #ifdef OFFIX_DND |
208 | #ifdef OFFIX_DND |
202 | "DndProtocol", |
209 | "DndProtocol", |
203 | "DndSelection", |
210 | "DndSelection", |
|
|
211 | #endif |
|
|
212 | #if ENABLE_XEMBED |
|
|
213 | "_XEMBED", |
|
|
214 | "_XEMBED_INFO", |
204 | #endif |
215 | #endif |
205 | }; |
216 | }; |
206 | |
217 | |
207 | bool |
218 | bool |
208 | rxvt_term::init_vars () |
219 | rxvt_term::init_vars () |
209 | { |
220 | { |
210 | sw_term.start (SIGTERM); |
221 | sw_term.start (SIGTERM); |
|
|
222 | sw_int.start (SIGINT); |
211 | |
223 | |
212 | pix_colors_focused = new rxvt_color [TOTAL_COLORS]; |
224 | pix_colors_focused = new rxvt_color [TOTAL_COLORS]; |
213 | #ifdef OFF_FOCUS_FADING |
225 | #ifdef OFF_FOCUS_FADING |
214 | pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; |
226 | pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; |
215 | #endif |
227 | #endif |
… | |
… | |
224 | |
236 | |
225 | MEvent.time = CurrentTime; |
237 | MEvent.time = CurrentTime; |
226 | MEvent.button = AnyButton; |
238 | MEvent.button = AnyButton; |
227 | options = DEFAULT_OPTIONS; |
239 | options = DEFAULT_OPTIONS; |
228 | want_refresh = 1; |
240 | want_refresh = 1; |
229 | cmd_pid = -1; |
|
|
230 | pty.pty = pty.tty = -1; |
|
|
231 | priv_modes = SavedModes = PrivMode_Default; |
241 | priv_modes = SavedModes = PrivMode_Default; |
232 | TermWin.focus = 0; |
242 | TermWin.focus = 0; |
233 | TermWin.ncol = 80; |
243 | TermWin.ncol = 80; |
234 | TermWin.nrow = 24; |
244 | TermWin.nrow = 24; |
235 | TermWin.int_bwidth = INTERNALBORDERWIDTH; |
245 | TermWin.int_bwidth = INTERNALBORDERWIDTH; |
… | |
… | |
252 | last_bot = last_state = -1; |
262 | last_bot = last_state = -1; |
253 | |
263 | |
254 | #ifdef MENUBAR |
264 | #ifdef MENUBAR |
255 | menu_readonly = 1; |
265 | menu_readonly = 1; |
256 | # if ! (MENUBAR_MAX > 1) |
266 | # if ! (MENUBAR_MAX > 1) |
257 | CurrentBar = & (BarList); |
267 | CurrentBar = &BarList; |
258 | # endif /* (MENUBAR_MAX > 1) */ |
268 | # endif /* (MENUBAR_MAX > 1) */ |
259 | #endif |
269 | #endif |
260 | |
270 | |
261 | return true; |
271 | return true; |
262 | } |
272 | } |
… | |
… | |
336 | */ |
346 | */ |
337 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
347 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
338 | rs[Rs_display_name] = ":0"; |
348 | rs[Rs_display_name] = ":0"; |
339 | |
349 | |
340 | get_options (r_argc, r_argv); |
350 | get_options (r_argc, r_argv); |
|
|
351 | |
|
|
352 | if (!(display = displays.get (rs[Rs_display_name]))) |
|
|
353 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
|
|
354 | |
|
|
355 | extract_resources (); |
341 | free (r_argv); |
356 | free (r_argv); |
342 | |
|
|
343 | #ifdef LOCAL_X_IS_UNIX |
|
|
344 | if (rs[Rs_display_name][0] == ':') |
|
|
345 | { |
|
|
346 | val = rxvt_malloc (5 + strlen (rs[Rs_display_name])); |
|
|
347 | strcpy (val, "unix"); |
|
|
348 | strcat (val, rs[Rs_display_name]); |
|
|
349 | display = displays.get (val); |
|
|
350 | free (val); |
|
|
351 | } |
|
|
352 | #endif |
|
|
353 | |
|
|
354 | if (!display |
|
|
355 | && ! (display = displays.get (rs[Rs_display_name]))) |
|
|
356 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
|
|
357 | |
|
|
358 | extract_resources (display->display, rs[Rs_name]); |
|
|
359 | |
357 | |
360 | /* |
358 | /* |
361 | * set any defaults not already set |
359 | * set any defaults not already set |
362 | */ |
360 | */ |
363 | if (cmd_argv && cmd_argv[0]) |
361 | if (cmd_argv && cmd_argv[0]) |
… | |
… | |
672 | if (scrollbar_visible ()) |
670 | if (scrollbar_visible ()) |
673 | { |
671 | { |
674 | priv_modes |= PrivMode_scrollBar; |
672 | priv_modes |= PrivMode_scrollBar; |
675 | SavedModes |= PrivMode_scrollBar; |
673 | SavedModes |= PrivMode_scrollBar; |
676 | } |
674 | } |
|
|
675 | |
677 | if (menubar_visible ()) |
676 | if (menubar_visible ()) |
678 | { |
677 | { |
679 | priv_modes |= PrivMode_menuBar; |
678 | priv_modes |= PrivMode_menuBar; |
680 | SavedModes |= PrivMode_menuBar; |
679 | SavedModes |= PrivMode_menuBar; |
681 | } |
680 | } |
… | |
… | |
741 | } |
740 | } |
742 | } |
741 | } |
743 | } |
742 | } |
744 | |
743 | |
745 | pix_colors[i] = xcol; |
744 | pix_colors[i] = xcol; |
|
|
745 | SET_PIXCOLOR (i); |
|
|
746 | } |
|
|
747 | |
746 | #ifdef OFF_FOCUS_FADING |
748 | #ifdef OFF_FOCUS_FADING |
747 | if (rs[Rs_fade]) |
749 | if (rs[Rs_fade]) |
|
|
750 | for (i = 0; i < (display->depth <= 2 ? 2 : NRS_COLORS); i++) |
748 | pix_colors_unfocused[i] = xcol.fade (display, atoi (rs[Rs_fade])); |
751 | pix_colors_unfocused[i] = pix_colors_focused[i].fade (display, atoi (rs[Rs_fade]), pix_colors[Color_fade]); |
749 | #endif |
752 | #endif |
750 | SET_PIXCOLOR (i); |
|
|
751 | } |
|
|
752 | |
753 | |
753 | if (display->depth <= 2) |
754 | if (display->depth <= 2) |
754 | { |
755 | { |
755 | if (!rs[Rs_color + Color_pointer_fg]) pix_colors[Color_pointer_fg] = pix_colors[Color_fg]; |
756 | if (!rs[Rs_color + Color_pointer_fg]) pix_colors[Color_pointer_fg] = pix_colors[Color_fg]; |
756 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
757 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
… | |
… | |
764 | * from the fvwm window manager. |
765 | * from the fvwm window manager. |
765 | */ |
766 | */ |
766 | #ifdef KEEP_SCROLLCOLOR |
767 | #ifdef KEEP_SCROLLCOLOR |
767 | |
768 | |
768 | if (display->depth <= 2) |
769 | if (display->depth <= 2) |
|
|
770 | { |
769 | { /* Monochrome */ |
771 | /* Monochrome */ |
770 | pix_colors[Color_scroll] = pix_colors[Color_fg]; |
772 | pix_colors[Color_scroll] = pix_colors[Color_fg]; |
771 | pix_colors[Color_topShadow] = pix_colors[Color_bg]; |
773 | pix_colors[Color_topShadow] = pix_colors[Color_bg]; |
772 | pix_colors[Color_bottomShadow] = pix_colors[Color_bg]; |
774 | pix_colors[Color_bottomShadow] = pix_colors[Color_bg]; |
773 | } |
775 | } |
774 | else |
776 | else |
… | |
… | |
829 | * Use resource ``modifier'' to override the Meta modifier |
831 | * Use resource ``modifier'' to override the Meta modifier |
830 | */ |
832 | */ |
831 | void |
833 | void |
832 | rxvt_term::get_ourmods () |
834 | rxvt_term::get_ourmods () |
833 | { |
835 | { |
834 | int i, j, k; |
836 | int i, j, k; |
835 | int requestedmeta, realmeta, realalt; |
837 | int requestedmeta, realmeta, realalt; |
836 | const char *cm, *rsmod; |
838 | const char *cm, *rsmod; |
837 | XModifierKeymap *map; |
839 | XModifierKeymap *map; |
838 | KeyCode *kc; |
840 | KeyCode *kc; |
839 | const unsigned int modmasks[] = |
841 | const unsigned int modmasks[] = |
840 | { |
842 | { |
841 | Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask |
843 | Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask |
842 | }; |
844 | }; |
843 | |
845 | |
… | |
… | |
925 | #endif |
927 | #endif |
926 | XGCValues gcvalue; |
928 | XGCValues gcvalue; |
927 | long vt_emask; |
929 | long vt_emask; |
928 | XSetWindowAttributes attributes; |
930 | XSetWindowAttributes attributes; |
929 | XWindowAttributes gattr; |
931 | XWindowAttributes gattr; |
|
|
932 | Window top, parent; |
|
|
933 | dDisp; |
930 | |
934 | |
931 | #ifdef USING_W11LIB |
935 | #ifdef USING_W11LIB |
932 | /* enable W11 callbacks */ |
936 | /* enable W11 callbacks */ |
933 | W11AddEventHandler (display->display, rxvt_W11_process_x_event); |
937 | W11AddEventHandler (disp, rxvt_W11_process_x_event); |
934 | #endif |
938 | #endif |
935 | |
939 | |
936 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
940 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
937 | XInternAtoms (display->display, (char **)xa_names, NUM_XA, False, xa); |
941 | XInternAtoms (disp, (char **)xa_names, NUM_XA, False, xa); |
938 | |
942 | |
939 | if (options & Opt_transparent) |
943 | if (options & Opt_transparent) |
940 | { |
944 | { |
941 | XGetWindowAttributes (display->display, RootWindow (display->display, display->screen), &gattr); |
945 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
942 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
946 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
943 | } |
947 | } |
944 | |
948 | |
945 | #if ENABLE_FRILLS |
949 | #if ENABLE_FRILLS |
946 | if (options & Opt_borderLess) |
950 | if (options & Opt_borderLess) |
947 | { |
951 | { |
948 | prop = XInternAtom(display->display, "_MOTIF_WM_INFO", True); |
952 | prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); |
949 | |
953 | |
950 | if (prop == None) |
954 | if (prop == None) |
951 | { |
955 | { |
952 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
956 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
953 | #ifdef PREFER_24BIT |
957 | #ifdef PREFER_24BIT |
… | |
… | |
960 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
964 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
961 | mwmhints.decorations = 0; |
965 | mwmhints.decorations = 0; |
962 | } |
966 | } |
963 | } |
967 | } |
964 | else |
968 | else |
965 | { |
|
|
966 | mwmhints.flags = 0; |
969 | mwmhints.flags = 0; |
967 | } |
|
|
968 | #endif |
970 | #endif |
969 | |
971 | |
970 | /* grab colors before netscape does */ |
972 | /* grab colors before netscape does */ |
971 | Get_Colours (); |
973 | Get_Colours (); |
972 | |
974 | |
973 | if (!set_fonts ()) |
975 | if (!set_fonts ()) |
974 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
976 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
975 | |
977 | |
|
|
978 | parent = DefaultRootWindow (disp); |
|
|
979 | |
|
|
980 | #if ENABLE_XEMBED |
|
|
981 | if (rs[Rs_embed]) |
|
|
982 | { |
|
|
983 | XWindowAttributes wattr; |
|
|
984 | |
|
|
985 | parent = strtol (rs[Rs_embed], 0, 0); |
|
|
986 | |
|
|
987 | if (!XGetWindowAttributes (disp, parent, &wattr)) |
|
|
988 | rxvt_fatal ("invalid window-id specified with -embed, aborting.\n"); |
|
|
989 | |
|
|
990 | window_calc (wattr.width, wattr.height); |
|
|
991 | } |
|
|
992 | |
|
|
993 | #endif |
976 | window_calc (0, 0); |
994 | window_calc (0, 0); |
977 | old_width = szHint.width; |
|
|
978 | old_height = szHint.height; |
|
|
979 | |
995 | |
980 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
996 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
981 | |
|
|
982 | #ifdef PREFER_24BIT |
997 | #ifdef PREFER_24BIT |
983 | attributes.background_pixel = pix_colors_focused[Color_border]; |
998 | attributes.background_pixel = pix_colors_focused[Color_border]; |
984 | attributes.border_pixel = pix_colors_focused[Color_border]; |
999 | attributes.border_pixel = pix_colors_focused[Color_border]; |
985 | attributes.colormap = display->cmap; |
1000 | attributes.colormap = display->cmap; |
986 | TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display), |
1001 | top = XCreateWindow (disp, parent, |
987 | szHint.x, szHint.y, |
1002 | szHint.x, szHint.y, |
988 | szHint.width, szHint.height, |
1003 | szHint.width, szHint.height, |
989 | TermWin.ext_bwidth, |
1004 | TermWin.ext_bwidth, |
990 | display->depth, InputOutput, |
1005 | display->depth, InputOutput, |
991 | display->visual, |
1006 | display->visual, |
992 | CWColormap | CWBackPixel | CWBorderPixel, &attributes); |
1007 | CWColormap | CWBackPixel | CWBorderPixel, &attributes); |
993 | #else |
1008 | #else |
994 | TermWin.parent[0] = XCreateSimpleWindow (display->display, DefaultRootWindow (display->display), |
1009 | top = XCreateSimpleWindow (disp, parent, |
995 | szHint.x, szHint.y, |
1010 | szHint.x, szHint.y, |
996 | szHint.width, szHint.height, |
1011 | szHint.width, szHint.height, |
997 | TermWin.ext_bwidth, |
1012 | TermWin.ext_bwidth, |
998 | pix_colors_focused[Color_border], |
1013 | pix_colors_focused[Color_border], |
999 | pix_colors_focused[Color_border]); |
1014 | pix_colors_focused[Color_border]); |
1000 | #endif |
1015 | #endif |
|
|
1016 | |
|
|
1017 | TermWin.parent[0] = top; |
|
|
1018 | |
|
|
1019 | old_width = szHint.width; |
|
|
1020 | old_height = szHint.height; |
1001 | |
1021 | |
1002 | process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); |
1022 | process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); |
1003 | process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); |
1023 | process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); |
1004 | |
1024 | |
1005 | classHint.res_name = (char *)rs[Rs_name]; |
1025 | classHint.res_name = (char *)rs[Rs_name]; |
1006 | classHint.res_class = (char *)RESCLASS; |
1026 | classHint.res_class = (char *)RESCLASS; |
1007 | |
1027 | |
1008 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1028 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1009 | wmHint.input = True; |
1029 | wmHint.input = True; |
1010 | wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; |
1030 | wmHint.initial_state = options & Opt_iconic ? IconicState : NormalState; |
1011 | wmHint.window_group = TermWin.parent[0]; |
1031 | wmHint.window_group = top; |
1012 | |
1032 | |
1013 | XSetWMProperties (display->display, TermWin.parent[0], NULL, NULL, |
1033 | XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, |
1014 | (char **)argv, argc, &szHint, &wmHint, &classHint); |
1034 | &szHint, &wmHint, &classHint); |
1015 | |
1035 | |
1016 | /* Enable delete window protocol */ |
1036 | Atom protocols[] = { |
1017 | XSetWMProtocols (display->display, TermWin.parent[0], |
1037 | xa[XA_WM_DELETE_WINDOW], |
1018 | &xa[XA_WMDELETEWINDOW], 1); |
1038 | #if ENABLE_EWMH |
|
|
1039 | xa[XA_NET_WM_PING], |
|
|
1040 | #endif |
|
|
1041 | }; |
1019 | |
1042 | |
1020 | #if ENABLE_FRILLS |
1043 | XSetWMProtocols (disp, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
|
|
1044 | |
|
|
1045 | #if ENABLE_EWMH |
1021 | long pid = getpid (); |
1046 | long pid = getpid (); |
1022 | |
1047 | |
1023 | XChangeProperty (display->display, TermWin.parent[0], |
1048 | XChangeProperty (disp, top, |
1024 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
1049 | xa[XA_NET_WM_PID], XA_CARDINAL, 32, |
1025 | PropModeReplace, (unsigned char *)&pid, 1); |
1050 | PropModeReplace, (unsigned char *)&pid, 1); |
1026 | #endif |
|
|
1027 | |
1051 | |
1028 | XSelectInput (display->display, TermWin.parent[0], |
1052 | // _NET_WM_WINDOW_TYPE is NORMAL, which is the default |
|
|
1053 | #endif |
|
|
1054 | |
|
|
1055 | XSelectInput (disp, top, |
1029 | KeyPressMask |
1056 | KeyPressMask |
1030 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755 |
1057 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755 |
1031 | | KeyReleaseMask |
1058 | | KeyReleaseMask |
1032 | #endif |
1059 | #endif |
1033 | | FocusChangeMask | VisibilityChangeMask |
1060 | | FocusChangeMask | VisibilityChangeMask |
1034 | | ExposureMask |
|
|
1035 | | StructureNotifyMask); |
1061 | | ExposureMask | StructureNotifyMask); |
|
|
1062 | |
1036 | termwin_ev.start (display, TermWin.parent[0]); |
1063 | termwin_ev.start (display, top); |
1037 | |
1064 | |
1038 | #if ENABLE_FRILLS |
1065 | #if ENABLE_FRILLS |
1039 | if (mwmhints.flags) |
1066 | if (mwmhints.flags) |
1040 | XChangeProperty (display->display, TermWin.parent[0], xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
1067 | XChangeProperty (disp, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
1041 | PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); |
1068 | PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); |
1042 | #endif |
1069 | #endif |
1043 | |
1070 | |
1044 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1071 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1045 | TermWin_cursor = XCreateFontCursor (display->display, XC_xterm); |
1072 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1046 | |
1073 | |
1047 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
1074 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
1048 | /* cursor (menuBar/scrollBar): Black-on-White */ |
1075 | /* cursor (menuBar/scrollBar): Black-on-White */ |
1049 | leftptr_cursor = XCreateFontCursor (display->display, XC_left_ptr); |
1076 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1050 | #endif |
1077 | #endif |
1051 | |
1078 | |
1052 | /* the vt window */ |
1079 | /* the vt window */ |
1053 | TermWin.vt = XCreateSimpleWindow (display->display, TermWin.parent[0], |
1080 | TermWin.vt = XCreateSimpleWindow (disp, top, |
1054 | window_vt_x, |
1081 | window_vt_x, |
1055 | window_vt_y, |
1082 | window_vt_y, |
1056 | TermWin_TotalWidth (), |
1083 | TermWin_TotalWidth (), |
1057 | TermWin_TotalHeight (), |
1084 | TermWin_TotalHeight (), |
1058 | 0, |
1085 | 0, |
1059 | pix_colors_focused[Color_fg], |
1086 | pix_colors_focused[Color_fg], |
1060 | pix_colors_focused[Color_bg]); |
1087 | pix_colors_focused[Color_bg]); |
1061 | #ifdef DEBUG_X |
1088 | #ifdef DEBUG_X |
1062 | XStoreName (display->display, TermWin.vt, "vt window"); |
1089 | XStoreName (disp, TermWin.vt, "vt window"); |
1063 | #endif |
1090 | #endif |
1064 | |
1091 | |
1065 | attributes.bit_gravity = NorthWestGravity; |
1092 | attributes.bit_gravity = NorthWestGravity; |
1066 | XChangeWindowAttributes (display->display, TermWin.vt, CWBitGravity, &attributes); |
1093 | XChangeWindowAttributes (disp, TermWin.vt, CWBitGravity, &attributes); |
1067 | |
1094 | |
1068 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1095 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1069 | |
|
|
1070 | pointer_unblank (); |
|
|
1071 | |
1096 | |
1072 | #ifdef POINTER_BLANK |
1097 | #ifdef POINTER_BLANK |
1073 | if (options & Opt_pointerBlank) |
1098 | if (options & Opt_pointerBlank) |
1074 | vt_emask |= PointerMotionMask; |
1099 | vt_emask |= PointerMotionMask; |
1075 | else |
1100 | else |
1076 | #endif |
1101 | #endif |
1077 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1102 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1078 | |
1103 | |
1079 | XSelectInput (display->display, TermWin.vt, vt_emask); |
1104 | XSelectInput (disp, TermWin.vt, vt_emask); |
1080 | vt_ev.start (display, TermWin.vt); |
1105 | vt_ev.start (display, TermWin.vt); |
1081 | |
1106 | |
1082 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
1107 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
1083 | if (menuBar_height ()) |
1108 | if (menuBar_height ()) |
1084 | { |
1109 | { |
1085 | menuBar.win = XCreateSimpleWindow (display->display, TermWin.parent[0], |
1110 | menuBar.win = XCreateSimpleWindow (disp, top, |
1086 | window_vt_x, 0, |
1111 | window_vt_x, 0, |
1087 | TermWin_TotalWidth (), |
1112 | TermWin_TotalWidth (), |
1088 | menuBar_TotalHeight (), |
1113 | menuBar_TotalHeight (), |
1089 | 0, |
1114 | 0, |
1090 | pix_colors_focused[Color_fg], |
1115 | pix_colors_focused[Color_fg], |
1091 | pix_colors_focused[Color_scroll]); |
1116 | pix_colors_focused[Color_scroll]); |
1092 | |
1117 | |
1093 | #ifdef DEBUG_X |
1118 | #ifdef DEBUG_X |
1094 | XStoreName (display->display, menuBar.win, "menubar"); |
1119 | XStoreName (disp, menuBar.win, "menubar"); |
1095 | #endif |
1120 | #endif |
1096 | |
1121 | |
1097 | menuBar.drawable = new rxvt_drawable (display, menuBar.win); |
1122 | menuBar.drawable = new rxvt_drawable (display, menuBar.win); |
1098 | |
1123 | |
1099 | XDefineCursor (display->display, menuBar.win, |
1124 | XDefineCursor (disp, menuBar.win, |
1100 | XCreateFontCursor (display->display, XC_left_ptr)); |
1125 | XCreateFontCursor (disp, XC_left_ptr)); |
1101 | |
1126 | |
1102 | XSelectInput (display->display, menuBar.win, |
1127 | XSelectInput (disp, menuBar.win, |
1103 | (ExposureMask | ButtonPressMask | ButtonReleaseMask |
1128 | (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask)); |
1104 | | Button1MotionMask)); |
|
|
1105 | menubar_ev.start (display, menuBar.win); |
1129 | menubar_ev.start (display, menuBar.win); |
1106 | } |
1130 | } |
1107 | #endif |
1131 | #endif |
1108 | |
1132 | |
1109 | #ifdef XPM_BACKGROUND |
1133 | #ifdef XPM_BACKGROUND |
… | |
… | |
1125 | |
1149 | |
1126 | /* graphics context for the vt window */ |
1150 | /* graphics context for the vt window */ |
1127 | gcvalue.foreground = pix_colors[Color_fg]; |
1151 | gcvalue.foreground = pix_colors[Color_fg]; |
1128 | gcvalue.background = pix_colors[Color_bg]; |
1152 | gcvalue.background = pix_colors[Color_bg]; |
1129 | gcvalue.graphics_exposures = 1; |
1153 | gcvalue.graphics_exposures = 1; |
1130 | TermWin.gc = XCreateGC (display->display, TermWin.vt, |
1154 | TermWin.gc = XCreateGC (disp, TermWin.vt, |
1131 | GCForeground | GCBackground | GCGraphicsExposures, |
1155 | GCForeground | GCBackground | GCGraphicsExposures, |
1132 | &gcvalue); |
1156 | &gcvalue); |
1133 | |
1157 | |
1134 | TermWin.drawable = new rxvt_drawable (display, TermWin.vt); |
1158 | TermWin.drawable = new rxvt_drawable (display, TermWin.vt); |
1135 | |
1159 | |
1136 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1160 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1137 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1161 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1138 | topShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1162 | topShadowGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue); |
1139 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1163 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1140 | botShadowGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1164 | botShadowGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue); |
1141 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
1165 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
1142 | scrollbarGC = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); |
1166 | scrollbarGC = XCreateGC (disp, TermWin.vt, GCForeground, &gcvalue); |
1143 | #endif |
1167 | #endif |
1144 | |
1168 | |
1145 | #ifdef OFF_FOCUS_FADING |
1169 | #ifdef OFF_FOCUS_FADING |
1146 | // initially we are in unfocused state |
1170 | // initially we are in unfocused state |
1147 | if (rs[Rs_fade]) |
1171 | if (rs[Rs_fade]) |
1148 | pix_colors = pix_colors_unfocused; |
1172 | pix_colors = pix_colors_unfocused; |
1149 | #endif |
1173 | #endif |
1150 | |
1174 | |
|
|
1175 | pointer_unblank (); |
1151 | scr_recolour (); |
1176 | scr_recolour (); |
|
|
1177 | |
|
|
1178 | #if ENABLE_XEMBED |
|
|
1179 | if (rs[Rs_embed]) |
|
|
1180 | { |
|
|
1181 | long info[2] = { 0, XEMBED_MAPPED }; |
|
|
1182 | |
|
|
1183 | XChangeProperty (disp, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], |
|
|
1184 | 32, PropModeReplace, (unsigned char *)&info, 2); |
|
|
1185 | } |
|
|
1186 | #endif |
1152 | } |
1187 | } |
1153 | |
1188 | |
1154 | /* ------------------------------------------------------------------------- * |
1189 | /* ------------------------------------------------------------------------- * |
1155 | * GET TTY CURRENT STATE * |
1190 | * GET TTY CURRENT STATE * |
1156 | * ------------------------------------------------------------------------- */ |
1191 | * ------------------------------------------------------------------------- */ |
… | |
… | |
1170 | tio->c_cc[VKILL] = CKILL; |
1205 | tio->c_cc[VKILL] = CKILL; |
1171 | tio->c_cc[VSTART] = CSTART; |
1206 | tio->c_cc[VSTART] = CSTART; |
1172 | tio->c_cc[VSTOP] = CSTOP; |
1207 | tio->c_cc[VSTOP] = CSTOP; |
1173 | tio->c_cc[VSUSP] = CSUSP; |
1208 | tio->c_cc[VSUSP] = CSUSP; |
1174 | # ifdef VDSUSP |
1209 | # ifdef VDSUSP |
1175 | |
|
|
1176 | tio->c_cc[VDSUSP] = CDSUSP; |
1210 | tio->c_cc[VDSUSP] = CDSUSP; |
1177 | # endif |
1211 | # endif |
1178 | # ifdef VREPRINT |
1212 | # ifdef VREPRINT |
1179 | |
|
|
1180 | tio->c_cc[VREPRINT] = CRPRNT; |
1213 | tio->c_cc[VREPRINT] = CRPRNT; |
1181 | # endif |
1214 | # endif |
1182 | # ifdef VDISCRD |
1215 | # ifdef VDISCRD |
1183 | |
|
|
1184 | tio->c_cc[VDISCRD] = CFLUSH; |
1216 | tio->c_cc[VDISCRD] = CFLUSH; |
1185 | # endif |
1217 | # endif |
1186 | # ifdef VWERSE |
1218 | # ifdef VWERSE |
1187 | |
|
|
1188 | tio->c_cc[VWERSE] = CWERASE; |
1219 | tio->c_cc[VWERSE] = CWERASE; |
1189 | # endif |
1220 | # endif |
1190 | # ifdef VLNEXT |
1221 | # ifdef VLNEXT |
1191 | |
|
|
1192 | tio->c_cc[VLNEXT] = CLNEXT; |
1222 | tio->c_cc[VLNEXT] = CLNEXT; |
1193 | # endif |
1223 | # endif |
1194 | |
|
|
1195 | } |
1224 | } |
|
|
1225 | |
1196 | tio->c_cc[VEOF] = CEOF; |
1226 | tio->c_cc[VEOF] = CEOF; |
1197 | tio->c_cc[VEOL] = VDISABLE; |
1227 | tio->c_cc[VEOL] = VDISABLE; |
1198 | # ifdef VEOL2 |
1228 | # ifdef VEOL2 |
1199 | |
|
|
1200 | tio->c_cc[VEOL2] = VDISABLE; |
1229 | tio->c_cc[VEOL2] = VDISABLE; |
1201 | # endif |
1230 | # endif |
1202 | # ifdef VSWTC |
1231 | # ifdef VSWTC |
1203 | |
|
|
1204 | tio->c_cc[VSWTC] = VDISABLE; |
1232 | tio->c_cc[VSWTC] = VDISABLE; |
1205 | # endif |
1233 | # endif |
1206 | # ifdef VSWTCH |
1234 | # ifdef VSWTCH |
1207 | |
|
|
1208 | tio->c_cc[VSWTCH] = VDISABLE; |
1235 | tio->c_cc[VSWTCH] = VDISABLE; |
1209 | # endif |
1236 | # endif |
1210 | # if VMIN != VEOF |
1237 | # if VMIN != VEOF |
1211 | |
|
|
1212 | tio->c_cc[VMIN] = 1; |
1238 | tio->c_cc[VMIN] = 1; |
1213 | # endif |
1239 | # endif |
1214 | # if VTIME != VEOL |
1240 | # if VTIME != VEOL |
1215 | |
|
|
1216 | tio->c_cc[VTIME] = 0; |
1241 | tio->c_cc[VTIME] = 0; |
1217 | # endif |
1242 | # endif |
1218 | |
1243 | |
1219 | if (erase != -1) |
1244 | if (erase != -1) |
1220 | tio->c_cc[VERASE] = (char)erase; |
1245 | tio->c_cc[VERASE] = (char)erase; |
… | |
… | |
1248 | if (ioctl (STDIN_FILENO, TIOCGETP, & (tio->sg)) < 0) |
1273 | if (ioctl (STDIN_FILENO, TIOCGETP, & (tio->sg)) < 0) |
1249 | { |
1274 | { |
1250 | tio->sg.sg_erase = CERASE; /* ^H */ |
1275 | tio->sg.sg_erase = CERASE; /* ^H */ |
1251 | tio->sg.sg_kill = CKILL; /* ^U */ |
1276 | tio->sg.sg_kill = CKILL; /* ^U */ |
1252 | } |
1277 | } |
|
|
1278 | |
1253 | if (erase != -1) |
1279 | if (erase != -1) |
1254 | tio->sg.sg_erase = (char)erase; |
1280 | tio->sg.sg_erase = (char)erase; |
1255 | |
1281 | |
1256 | tio->sg.sg_flags = (CRMOD | ECHO | EVENP | ODDP); |
1282 | tio->sg.sg_flags = (CRMOD | ECHO | EVENP | ODDP); |
1257 | |
1283 | |
… | |
… | |
1263 | tio->tc.t_startc = CSTART; /* ^Q */ |
1289 | tio->tc.t_startc = CSTART; /* ^Q */ |
1264 | tio->tc.t_stopc = CSTOP; /* ^S */ |
1290 | tio->tc.t_stopc = CSTOP; /* ^S */ |
1265 | tio->tc.t_eofc = CEOF; /* ^D */ |
1291 | tio->tc.t_eofc = CEOF; /* ^D */ |
1266 | tio->tc.t_brkc = -1; |
1292 | tio->tc.t_brkc = -1; |
1267 | } |
1293 | } |
|
|
1294 | |
1268 | /* get local special chars */ |
1295 | /* get local special chars */ |
1269 | if (ioctl (STDIN_FILENO, TIOCGLTC, & (tio->lc)) < 0) |
1296 | if (ioctl (STDIN_FILENO, TIOCGLTC, & (tio->lc)) < 0) |
1270 | { |
1297 | { |
1271 | tio->lc.t_suspc = CSUSP; /* ^Z */ |
1298 | tio->lc.t_suspc = CSUSP; /* ^Z */ |
1272 | tio->lc.t_dsuspc = CDSUSP; /* ^Y */ |
1299 | tio->lc.t_dsuspc = CDSUSP; /* ^Y */ |
… | |
… | |
1276 | tio->lc.t_lnextc = CLNEXT; /* ^V */ |
1303 | tio->lc.t_lnextc = CLNEXT; /* ^V */ |
1277 | } |
1304 | } |
1278 | /* get line discipline */ |
1305 | /* get line discipline */ |
1279 | ioctl (STDIN_FILENO, TIOCGETD, & (tio->line)); |
1306 | ioctl (STDIN_FILENO, TIOCGETD, & (tio->line)); |
1280 | # ifdef NTTYDISC |
1307 | # ifdef NTTYDISC |
1281 | |
|
|
1282 | tio->line = NTTYDISC; |
1308 | tio->line = NTTYDISC; |
1283 | # endif /* NTTYDISC */ |
1309 | # endif /* NTTYDISC */ |
1284 | |
1310 | |
1285 | tio->local = (LCRTBS | LCRTERA | LCTLECH | LPASS8 | LCRTKIL); |
1311 | tio->local = (LCRTBS | LCRTERA | LCTLECH | LPASS8 | LCRTKIL); |
1286 | #endif /* HAVE_TERMIOS_H */ |
1312 | #endif /* HAVE_TERMIOS_H */ |
… | |
… | |
1309 | FOO (IGNCR, "IGNCR"); |
1335 | FOO (IGNCR, "IGNCR"); |
1310 | FOO (ICRNL, "ICRNL"); |
1336 | FOO (ICRNL, "ICRNL"); |
1311 | FOO (IXON, "IXON"); |
1337 | FOO (IXON, "IXON"); |
1312 | FOO (IXOFF, "IXOFF"); |
1338 | FOO (IXOFF, "IXOFF"); |
1313 | # ifdef IUCLC |
1339 | # ifdef IUCLC |
1314 | |
|
|
1315 | FOO (IUCLC, "IUCLC"); |
1340 | FOO (IUCLC, "IUCLC"); |
1316 | # endif |
1341 | # endif |
1317 | # ifdef IXANY |
1342 | # ifdef IXANY |
1318 | |
|
|
1319 | FOO (IXANY, "IXANY"); |
1343 | FOO (IXANY, "IXANY"); |
1320 | # endif |
1344 | # endif |
1321 | # ifdef IMAXBEL |
1345 | # ifdef IMAXBEL |
1322 | |
|
|
1323 | FOO (IMAXBEL, "IMAXBEL"); |
1346 | FOO (IMAXBEL, "IMAXBEL"); |
1324 | # endif |
1347 | # endif |
1325 | |
1348 | |
1326 | fprintf (stderr, "\n"); |
1349 | fprintf (stderr, "\n"); |
1327 | |
1350 | |
… | |
… | |
1334 | FOO (VERASE, "VERASE"); |
1357 | FOO (VERASE, "VERASE"); |
1335 | FOO (VKILL, "VKILL"); |
1358 | FOO (VKILL, "VKILL"); |
1336 | FOO (VEOF, "VEOF"); |
1359 | FOO (VEOF, "VEOF"); |
1337 | FOO (VEOL, "VEOL"); |
1360 | FOO (VEOL, "VEOL"); |
1338 | # ifdef VEOL2 |
1361 | # ifdef VEOL2 |
1339 | |
|
|
1340 | FOO (VEOL2, "VEOL2"); |
1362 | FOO (VEOL2, "VEOL2"); |
1341 | # endif |
1363 | # endif |
1342 | # ifdef VSWTC |
1364 | # ifdef VSWTC |
1343 | |
|
|
1344 | FOO (VSWTC, "VSWTC"); |
1365 | FOO (VSWTC, "VSWTC"); |
1345 | # endif |
1366 | # endif |
1346 | # ifdef VSWTCH |
1367 | # ifdef VSWTCH |
1347 | |
|
|
1348 | FOO (VSWTCH, "VSWTCH"); |
1368 | FOO (VSWTCH, "VSWTCH"); |
1349 | # endif |
1369 | # endif |
1350 | |
|
|
1351 | FOO (VSTART, "VSTART"); |
1370 | FOO (VSTART, "VSTART"); |
1352 | FOO (VSTOP, "VSTOP"); |
1371 | FOO (VSTOP, "VSTOP"); |
1353 | FOO (VSUSP, "VSUSP"); |
1372 | FOO (VSUSP, "VSUSP"); |
1354 | # ifdef VDSUSP |
1373 | # ifdef VDSUSP |
1355 | |
|
|
1356 | FOO (VDSUSP, "VDSUSP"); |
1374 | FOO (VDSUSP, "VDSUSP"); |
1357 | # endif |
1375 | # endif |
1358 | # ifdef VREPRINT |
1376 | # ifdef VREPRINT |
1359 | |
|
|
1360 | FOO (VREPRINT, "VREPRINT"); |
1377 | FOO (VREPRINT, "VREPRINT"); |
1361 | # endif |
1378 | # endif |
1362 | # ifdef VDISCRD |
1379 | # ifdef VDISCRD |
1363 | |
|
|
1364 | FOO (VDISCRD, "VDISCRD"); |
1380 | FOO (VDISCRD, "VDISCRD"); |
1365 | # endif |
1381 | # endif |
1366 | # ifdef VWERSE |
1382 | # ifdef VWERSE |
1367 | |
|
|
1368 | FOO (VWERSE, "VWERSE"); |
1383 | FOO (VWERSE, "VWERSE"); |
1369 | # endif |
1384 | # endif |
1370 | # ifdef VLNEXT |
1385 | # ifdef VLNEXT |
1371 | |
|
|
1372 | FOO (VLNEXT, "VLNEXT"); |
1386 | FOO (VLNEXT, "VLNEXT"); |
1373 | # endif |
1387 | # endif |
1374 | |
1388 | |
1375 | fprintf (stderr, "\n"); |
1389 | fprintf (stderr, "\n"); |
1376 | # undef FOO |
1390 | # undef FOO |
… | |
… | |
1385 | * the slave. |
1399 | * the slave. |
1386 | */ |
1400 | */ |
1387 | void |
1401 | void |
1388 | rxvt_term::run_command (const char *const *argv) |
1402 | rxvt_term::run_command (const char *const *argv) |
1389 | { |
1403 | { |
|
|
1404 | #if ENABLE_FRILLS |
|
|
1405 | if (rs[Rs_pty_fd]) |
|
|
1406 | { |
|
|
1407 | pty.pty = atoi (rs[Rs_pty_fd]); |
|
|
1408 | fcntl (pty.pty, F_SETFL, O_NONBLOCK); |
|
|
1409 | } |
|
|
1410 | else |
|
|
1411 | #endif |
1390 | if (!pty.get ()) |
1412 | if (!pty.get ()) |
1391 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1413 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1392 | |
1414 | |
1393 | pty.set_utf8_mode (enc_utf8); |
1415 | pty.set_utf8_mode (enc_utf8); |
1394 | |
1416 | |
1395 | /* set initial window size */ |
1417 | /* set initial window size */ |
1396 | tt_winch (); |
1418 | tt_winch (); |
… | |
… | |
1406 | #endif |
1428 | #endif |
1407 | er = -1; |
1429 | er = -1; |
1408 | |
1430 | |
1409 | rxvt_get_ttymode (&tio, er); |
1431 | rxvt_get_ttymode (&tio, er); |
1410 | |
1432 | |
|
|
1433 | #if ENABLE_FRILLS |
|
|
1434 | if (rs[Rs_pty_fd]) |
|
|
1435 | return; |
|
|
1436 | #endif |
|
|
1437 | |
1411 | sw_chld.start (SIGCHLD); |
1438 | sw_chld.start (SIGCHLD); |
1412 | |
1439 | |
1413 | #ifndef __QNX__ |
1440 | #ifndef __QNX__ |
1414 | /* spin off the command interpreter */ |
1441 | /* spin off the command interpreter */ |
1415 | switch (cmd_pid = fork ()) |
1442 | switch (cmd_pid = fork ()) |
1416 | { |
1443 | { |
1417 | case -1: |
1444 | case -1: |
|
|
1445 | { |
|
|
1446 | cmd_pid = 0; |
1418 | rxvt_fatal ("can't fork, aborting.\n"); |
1447 | rxvt_fatal ("can't fork, aborting.\n"); |
|
|
1448 | } |
1419 | case 0: |
1449 | case 0: |
1420 | init_env (); |
1450 | init_env (); |
1421 | |
1451 | |
1422 | if (!pty.make_controlling_tty ()) |
1452 | if (!pty.make_controlling_tty ()) |
1423 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1453 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |