… | |
… | |
174 | #if OFF_FOCUS_FADING |
174 | #if OFF_FOCUS_FADING |
175 | "black", |
175 | "black", |
176 | #endif |
176 | #endif |
177 | }; |
177 | }; |
178 | |
178 | |
179 | const char *const xa_names[] = |
|
|
180 | { |
|
|
181 | "TEXT", |
|
|
182 | "COMPOUND_TEXT", |
|
|
183 | "UTF8_STRING", |
|
|
184 | "MULTIPLE", |
|
|
185 | "TARGETS", |
|
|
186 | "TIMESTAMP", |
|
|
187 | "VT_SELECTION", |
|
|
188 | "INCR", |
|
|
189 | "WM_PROTOCOLS", |
|
|
190 | "WM_DELETE_WINDOW", |
|
|
191 | "CLIPBOARD", |
|
|
192 | #if ENABLE_FRILLS |
|
|
193 | "_MOTIF_WM_HINTS", |
|
|
194 | #endif |
|
|
195 | #if ENABLE_EWMH |
|
|
196 | "_NET_WM_PID", |
|
|
197 | "_NET_WM_NAME", |
|
|
198 | "_NET_WM_ICON_NAME", |
|
|
199 | "_NET_WM_PING", |
|
|
200 | #endif |
|
|
201 | #if USE_XIM |
|
|
202 | "WM_LOCALE_NAME", |
|
|
203 | #endif |
|
|
204 | #ifdef TRANSPARENT |
|
|
205 | "_XROOTPMAP_ID", |
|
|
206 | "ESETROOT_PMAP_ID", |
|
|
207 | #endif |
|
|
208 | #ifdef OFFIX_DND |
|
|
209 | "DndProtocol", |
|
|
210 | "DndSelection", |
|
|
211 | #endif |
|
|
212 | #if ENABLE_XEMBED |
|
|
213 | "_XEMBED", |
|
|
214 | "_XEMBED_INFO", |
|
|
215 | #endif |
|
|
216 | }; |
|
|
217 | |
|
|
218 | bool |
179 | bool |
219 | rxvt_term::init_vars () |
180 | rxvt_term::init_vars () |
220 | { |
181 | { |
|
|
182 | pix_colors = // |
221 | pix_colors_focused = new rxvt_color [TOTAL_COLORS]; |
183 | pix_colors_focused = new rxvt_color [TOTAL_COLORS]; |
222 | #ifdef OFF_FOCUS_FADING |
184 | #ifdef OFF_FOCUS_FADING |
223 | pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; |
185 | pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; |
224 | #endif |
186 | #endif |
225 | pix_colors = pix_colors_focused; |
|
|
226 | |
|
|
227 | if (pix_colors == NULL) |
|
|
228 | return false; |
|
|
229 | |
187 | |
230 | #if defined(XPM_BACKGROUND) || defined(TRANSPARENT) |
188 | #if defined(XPM_BACKGROUND) || defined(TRANSPARENT) |
231 | pixmap = None; |
189 | pixmap = None; |
232 | #endif |
190 | #endif |
233 | |
191 | |
… | |
… | |
256 | bgPixmap.pixmap = None; |
214 | bgPixmap.pixmap = None; |
257 | #endif |
215 | #endif |
258 | |
216 | |
259 | last_bot = last_state = -1; |
217 | last_bot = last_state = -1; |
260 | |
218 | |
261 | #ifdef MENUBAR |
|
|
262 | menu_readonly = 1; |
|
|
263 | # if ! (MENUBAR_MAX > 1) |
|
|
264 | CurrentBar = &BarList; |
|
|
265 | # endif /* (MENUBAR_MAX > 1) */ |
|
|
266 | #endif |
|
|
267 | |
|
|
268 | return true; |
219 | return true; |
269 | } |
220 | } |
270 | |
221 | |
271 | void |
222 | void |
272 | rxvt_term::init_secondary () |
223 | rxvt_term::init_secondary () |
… | |
… | |
339 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
290 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
340 | |
291 | |
341 | /* |
292 | /* |
342 | * Open display, get options/resources and create the window |
293 | * Open display, get options/resources and create the window |
343 | */ |
294 | */ |
|
|
295 | |
344 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
296 | if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) |
345 | rs[Rs_display_name] = ":0"; |
297 | rs[Rs_display_name] = ":0"; |
346 | |
298 | |
347 | get_options (r_argc, r_argv); |
299 | get_options (r_argc, r_argv); |
348 | |
300 | |
349 | if (!(display = displays.get (rs[Rs_display_name]))) |
301 | if (!(display = displays.get (rs[Rs_display_name]))) |
350 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
302 | rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); |
351 | |
303 | |
352 | extract_resources (); |
304 | extract_resources (); |
|
|
305 | |
353 | free (r_argv); |
306 | free (r_argv); |
|
|
307 | |
|
|
308 | #if ENABLE_PERL |
|
|
309 | if (!rs[Rs_perl_ext_1]) |
|
|
310 | rs[Rs_perl_ext_1] = "default"; |
|
|
311 | |
|
|
312 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
|
|
313 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
|
|
314 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
|
|
315 | { |
|
|
316 | rxvt_perl.init (this); |
|
|
317 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
|
|
318 | } |
|
|
319 | #endif |
354 | |
320 | |
355 | /* |
321 | /* |
356 | * set any defaults not already set |
322 | * set any defaults not already set |
357 | */ |
323 | */ |
358 | if (cmd_argv && cmd_argv[0]) |
324 | if (cmd_argv && cmd_argv[0]) |
… | |
… | |
391 | pointerBlankDelay = 2; |
357 | pointerBlankDelay = 2; |
392 | #endif |
358 | #endif |
393 | |
359 | |
394 | /* no point having a scrollbar without having any scrollback! */ |
360 | /* no point having a scrollbar without having any scrollback! */ |
395 | if (!saveLines) |
361 | if (!saveLines) |
396 | CLR_OPTION (Opt_scrollBar); |
362 | set_option (Opt_scrollBar, 0); |
397 | |
363 | |
398 | #ifdef PRINTPIPE |
364 | #ifdef PRINTPIPE |
399 | if (!rs[Rs_print_pipe]) |
365 | if (!rs[Rs_print_pipe]) |
400 | rs[Rs_print_pipe] = PRINTPIPE; |
366 | rs[Rs_print_pipe] = PRINTPIPE; |
401 | #endif |
367 | #endif |
… | |
… | |
576 | * This should support all European type languages. |
542 | * This should support all European type languages. |
577 | */ |
543 | */ |
578 | void |
544 | void |
579 | rxvt_term::set_locale (const char *locale) |
545 | rxvt_term::set_locale (const char *locale) |
580 | { |
546 | { |
|
|
547 | set_environ (envv); |
|
|
548 | |
581 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
549 | #if HAVE_XSETLOCALE || HAVE_SETLOCALE |
582 | free (this->locale); |
550 | free (this->locale); |
583 | this->locale = setlocale (LC_CTYPE, locale); |
551 | this->locale = setlocale (LC_CTYPE, locale); |
584 | |
552 | |
585 | if (!this->locale) |
553 | if (!this->locale) |
586 | { |
554 | { |
587 | if (*locale) |
555 | if (*locale) |
588 | { |
556 | { |
589 | rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale); |
557 | rxvt_warn ("unable to set locale \"%s\", using C locale instead.\n", locale); |
590 | setlocale (LC_CTYPE, ""); |
558 | setlocale (LC_CTYPE, "C"); |
591 | } |
559 | } |
592 | else |
560 | else |
593 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
561 | rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n"); |
594 | |
562 | |
595 | this->locale = ""; |
563 | this->locale = "C"; |
596 | } |
564 | } |
597 | |
565 | |
598 | |
566 | |
599 | this->locale = rxvt_strdup (this->locale); |
567 | this->locale = rxvt_strdup (this->locale); |
600 | SET_LOCALE (this->locale); |
568 | SET_LOCALE (this->locale); |
… | |
… | |
615 | } |
583 | } |
616 | |
584 | |
617 | void |
585 | void |
618 | rxvt_term::init_xlocale () |
586 | rxvt_term::init_xlocale () |
619 | { |
587 | { |
|
|
588 | set_environ (envv); |
|
|
589 | |
620 | #ifdef USE_XIM |
590 | #ifdef USE_XIM |
621 | if (!locale) |
591 | if (!locale) |
622 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
592 | rxvt_warn ("setting locale failed, working without locale support.\n"); |
623 | else |
593 | else |
624 | { |
594 | { |
… | |
… | |
664 | if (strcmp (key_backspace, "DEC") == 0) |
634 | if (strcmp (key_backspace, "DEC") == 0) |
665 | priv_modes |= PrivMode_HaveBackSpace; |
635 | priv_modes |= PrivMode_HaveBackSpace; |
666 | #endif |
636 | #endif |
667 | |
637 | |
668 | /* add value for scrollBar */ |
638 | /* add value for scrollBar */ |
669 | if (scrollbar_visible ()) |
639 | if (scrollBar.state) |
670 | { |
640 | { |
671 | priv_modes |= PrivMode_scrollBar; |
641 | priv_modes |= PrivMode_scrollBar; |
672 | SavedModes |= PrivMode_scrollBar; |
642 | SavedModes |= PrivMode_scrollBar; |
673 | } |
|
|
674 | |
|
|
675 | if (menubar_visible ()) |
|
|
676 | { |
|
|
677 | priv_modes |= PrivMode_menuBar; |
|
|
678 | SavedModes |= PrivMode_menuBar; |
|
|
679 | } |
643 | } |
680 | |
644 | |
681 | run_command (argv); |
645 | run_command (argv); |
682 | } |
646 | } |
683 | |
647 | |
… | |
… | |
751 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
715 | if (!rs[Rs_color + Color_pointer_bg]) pix_colors[Color_pointer_bg] = pix_colors[Color_bg]; |
752 | if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg]; |
716 | if (!rs[Rs_color + Color_border] ) pix_colors[Color_border] = pix_colors[Color_fg]; |
753 | } |
717 | } |
754 | |
718 | |
755 | /* |
719 | /* |
756 | * get scrollBar/menuBar shadow colors |
720 | * get scrollBar shadow colors |
757 | * |
721 | * |
758 | * The calculations of topShadow/bottomShadow values are adapted |
722 | * The calculations of topShadow/bottomShadow values are adapted |
759 | * from the fvwm window manager. |
723 | * from the fvwm window manager. |
760 | */ |
724 | */ |
761 | #ifdef KEEP_SCROLLCOLOR |
725 | #ifdef KEEP_SCROLLCOLOR |
… | |
… | |
912 | rxvt_term::create_windows (int argc, const char *const *argv) |
876 | rxvt_term::create_windows (int argc, const char *const *argv) |
913 | { |
877 | { |
914 | XClassHint classHint; |
878 | XClassHint classHint; |
915 | XWMHints wmHint; |
879 | XWMHints wmHint; |
916 | #if ENABLE_FRILLS |
880 | #if ENABLE_FRILLS |
917 | Atom prop = None; |
|
|
918 | MWMHints mwmhints; |
881 | MWMHints mwmhints; |
919 | #endif |
882 | #endif |
920 | XGCValues gcvalue; |
883 | XGCValues gcvalue; |
921 | long vt_emask; |
|
|
922 | XSetWindowAttributes attributes; |
884 | XSetWindowAttributes attributes; |
923 | XWindowAttributes gattr; |
|
|
924 | Window top, parent; |
885 | Window top, parent; |
925 | dDisp; |
886 | dDisp; |
926 | |
887 | |
927 | #ifdef USING_W11LIB |
888 | xa = display->xa; |
928 | /* enable W11 callbacks */ |
|
|
929 | W11AddEventHandler (disp, rxvt_W11_process_x_event); |
|
|
930 | #endif |
|
|
931 | |
889 | |
932 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
890 | /* grab colors before netscape does */ |
933 | XInternAtoms (disp, (char **)xa_names, NUM_XA, False, xa); |
891 | Get_Colours (); |
934 | |
892 | |
935 | if (OPTION (Opt_transparent)) |
893 | if (!set_fonts ()) |
936 | { |
894 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
937 | XGetWindowAttributes (disp, RootWindow (disp, display->screen), &gattr); |
895 | |
938 | display->depth = gattr.depth; // doh //TODO, per-term not per-display? |
896 | parent = display->root; |
939 | } |
897 | |
|
|
898 | attributes.override_redirect = !!OPTION (Opt_override_redirect); |
940 | |
899 | |
941 | #if ENABLE_FRILLS |
900 | #if ENABLE_FRILLS |
942 | if (OPTION (Opt_borderLess)) |
901 | if (OPTION (Opt_borderLess)) |
943 | { |
902 | { |
944 | prop = XInternAtom(disp, "_MOTIF_WM_INFO", True); |
903 | if (XInternAtom (disp, "_MOTIF_WM_INFO", True) == None) |
945 | |
|
|
946 | if (prop == None) |
|
|
947 | { |
904 | { |
948 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
905 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
949 | #ifdef PREFER_24BIT |
|
|
950 | attributes.override_redirect = TRUE; |
906 | attributes.override_redirect = TRUE; |
951 | #endif |
|
|
952 | mwmhints.flags = 0; |
907 | mwmhints.flags = 0; |
953 | } |
908 | } |
954 | else |
909 | else |
955 | { |
910 | { |
956 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
911 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
… | |
… | |
959 | } |
914 | } |
960 | else |
915 | else |
961 | mwmhints.flags = 0; |
916 | mwmhints.flags = 0; |
962 | #endif |
917 | #endif |
963 | |
918 | |
964 | /* grab colors before netscape does */ |
|
|
965 | Get_Colours (); |
|
|
966 | |
|
|
967 | if (!set_fonts ()) |
|
|
968 | rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); |
|
|
969 | |
|
|
970 | parent = DefaultRootWindow (disp); |
|
|
971 | |
|
|
972 | #if ENABLE_XEMBED |
919 | #if ENABLE_XEMBED |
973 | if (rs[Rs_embed]) |
920 | if (rs[Rs_embed]) |
974 | { |
921 | { |
975 | XWindowAttributes wattr; |
922 | XWindowAttributes wattr; |
976 | |
923 | |
… | |
… | |
984 | #endif |
931 | #endif |
985 | |
932 | |
986 | window_calc (0, 0); |
933 | window_calc (0, 0); |
987 | |
934 | |
988 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
935 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
989 | #ifdef PREFER_24BIT |
|
|
990 | attributes.background_pixel = pix_colors_focused[Color_border]; |
936 | attributes.background_pixel = pix_colors_focused[Color_border]; |
991 | attributes.border_pixel = pix_colors_focused[Color_border]; |
937 | attributes.border_pixel = pix_colors_focused[Color_border]; |
992 | attributes.colormap = display->cmap; |
938 | attributes.colormap = display->cmap; |
|
|
939 | |
993 | top = XCreateWindow (disp, parent, |
940 | top = XCreateWindow (disp, parent, |
994 | szHint.x, szHint.y, |
941 | szHint.x, szHint.y, |
995 | szHint.width, szHint.height, |
942 | szHint.width, szHint.height, |
996 | ext_bwidth, |
943 | ext_bwidth, |
997 | display->depth, InputOutput, |
944 | display->depth, InputOutput, |
998 | display->visual, |
945 | display->visual, |
999 | CWColormap | CWBackPixel | CWBorderPixel, &attributes); |
946 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1000 | #else |
947 | &attributes); |
1001 | top = XCreateSimpleWindow (disp, parent, |
|
|
1002 | szHint.x, szHint.y, |
|
|
1003 | szHint.width, szHint.height, |
|
|
1004 | ext_bwidth, |
|
|
1005 | pix_colors_focused[Color_border], |
|
|
1006 | pix_colors_focused[Color_border]); |
|
|
1007 | #endif |
|
|
1008 | |
948 | |
1009 | this->parent[0] = top; |
949 | this->parent[0] = top; |
1010 | |
950 | |
1011 | old_width = szHint.width; |
951 | old_width = szHint.width; |
1012 | old_height = szHint.height; |
952 | old_height = szHint.height; |
1013 | |
953 | |
1014 | process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); |
954 | process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); |
1015 | process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); |
955 | process_xterm_seq (XTerm_iconName, rs[Rs_iconName], CHAR_ST); |
1016 | |
956 | |
1017 | classHint.res_name = (char *)rs[Rs_name]; |
957 | classHint.res_name = (char *)rs[Rs_name]; |
1018 | classHint.res_class = (char *)RESCLASS; |
958 | classHint.res_class = (char *)RESCLASS; |
1019 | |
959 | |
1020 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
960 | wmHint.flags = InputHint | StateHint | WindowGroupHint; |
1021 | wmHint.input = True; |
961 | wmHint.input = True; |
1022 | wmHint.initial_state = OPTION (Opt_iconic) ? IconicState : NormalState; |
962 | wmHint.initial_state = OPTION (Opt_iconic) ? IconicState : NormalState; |
1023 | wmHint.window_group = top; |
963 | wmHint.window_group = top; |
1024 | |
964 | |
1025 | XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, |
965 | XmbSetWMProperties (disp, top, NULL, NULL, (char **)argv, argc, |
1026 | &szHint, &wmHint, &classHint); |
966 | &szHint, &wmHint, &classHint); |
|
|
967 | |
|
|
968 | #if ENABLE_FRILLS |
|
|
969 | if (mwmhints.flags) |
|
|
970 | XChangeProperty (disp, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
|
|
971 | PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); |
|
|
972 | #endif |
1027 | |
973 | |
1028 | Atom protocols[] = { |
974 | Atom protocols[] = { |
1029 | xa[XA_WM_DELETE_WINDOW], |
975 | xa[XA_WM_DELETE_WINDOW], |
1030 | #if ENABLE_EWMH |
976 | #if ENABLE_EWMH |
1031 | xa[XA_NET_WM_PING], |
977 | xa[XA_NET_WM_PING], |
… | |
… | |
1057 | | FocusChangeMask | VisibilityChangeMask |
1003 | | FocusChangeMask | VisibilityChangeMask |
1058 | | ExposureMask | StructureNotifyMask); |
1004 | | ExposureMask | StructureNotifyMask); |
1059 | |
1005 | |
1060 | termwin_ev.start (display, top); |
1006 | termwin_ev.start (display, top); |
1061 | |
1007 | |
1062 | #if ENABLE_FRILLS |
|
|
1063 | if (mwmhints.flags) |
|
|
1064 | XChangeProperty (disp, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
|
|
1065 | PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); |
|
|
1066 | #endif |
|
|
1067 | |
|
|
1068 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1008 | /* vt cursor: Black-on-White is standard, but this is more popular */ |
1069 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1009 | TermWin_cursor = XCreateFontCursor (disp, XC_xterm); |
1070 | |
1010 | |
1071 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
1011 | #ifdef HAVE_SCROLLBARS |
1072 | /* cursor (menuBar/scrollBar): Black-on-White */ |
1012 | /* cursor scrollBar: Black-on-White */ |
1073 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1013 | leftptr_cursor = XCreateFontCursor (disp, XC_left_ptr); |
1074 | #endif |
1014 | #endif |
1075 | |
1015 | |
1076 | /* the vt window */ |
1016 | /* the vt window */ |
1077 | vt = XCreateSimpleWindow (disp, top, |
1017 | vt = XCreateSimpleWindow (disp, top, |
1078 | window_vt_x, |
|
|
1079 | window_vt_y, |
1018 | window_vt_x, window_vt_y, |
1080 | width, |
|
|
1081 | height, |
1019 | width, height, |
1082 | 0, |
1020 | 0, |
1083 | pix_colors_focused[Color_fg], |
1021 | pix_colors_focused[Color_fg], |
1084 | pix_colors_focused[Color_bg]); |
1022 | pix_colors_focused[Color_bg]); |
1085 | #ifdef DEBUG_X |
|
|
1086 | XStoreName (disp, vt, "vt window"); |
|
|
1087 | #endif |
|
|
1088 | |
1023 | |
1089 | attributes.bit_gravity = NorthWestGravity; |
1024 | attributes.bit_gravity = NorthWestGravity; |
1090 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1025 | XChangeWindowAttributes (disp, vt, CWBitGravity, &attributes); |
1091 | |
1026 | |
1092 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1027 | vt_emask = ExposureMask | ButtonPressMask | ButtonReleaseMask | PropertyChangeMask; |
1093 | |
1028 | |
1094 | if (OPTION (Opt_pointerBlank) |
1029 | if (OPTION (Opt_pointerBlank)) |
1095 | #ifdef ENABLE_PERL |
|
|
1096 | || self |
|
|
1097 | #endif |
|
|
1098 | ) |
|
|
1099 | vt_emask |= PointerMotionMask; |
1030 | vt_emask |= PointerMotionMask; |
1100 | else |
1031 | else |
1101 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1032 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1102 | |
1033 | |
1103 | XSelectInput (disp, vt, vt_emask); |
1034 | vt_select_input (); |
|
|
1035 | |
1104 | vt_ev.start (display, vt); |
1036 | vt_ev.start (display, vt); |
1105 | |
|
|
1106 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
|
|
1107 | if (menuBar_height ()) |
|
|
1108 | { |
|
|
1109 | menuBar.win = XCreateSimpleWindow (disp, top, |
|
|
1110 | window_vt_x, 0, |
|
|
1111 | width, |
|
|
1112 | menuBar_TotalHeight (), |
|
|
1113 | 0, |
|
|
1114 | pix_colors_focused[Color_fg], |
|
|
1115 | pix_colors_focused[Color_scroll]); |
|
|
1116 | |
|
|
1117 | #ifdef DEBUG_X |
|
|
1118 | XStoreName (disp, menuBar.win, "menubar"); |
|
|
1119 | #endif |
|
|
1120 | |
|
|
1121 | menuBar.drawable = new rxvt_drawable (display, menuBar.win); |
|
|
1122 | |
|
|
1123 | XDefineCursor (disp, menuBar.win, |
|
|
1124 | XCreateFontCursor (disp, XC_left_ptr)); |
|
|
1125 | |
|
|
1126 | XSelectInput (disp, menuBar.win, |
|
|
1127 | (ExposureMask | ButtonPressMask | ButtonReleaseMask | Button1MotionMask)); |
|
|
1128 | menubar_ev.start (display, menuBar.win); |
|
|
1129 | } |
|
|
1130 | #endif |
|
|
1131 | |
1037 | |
1132 | #ifdef XPM_BACKGROUND |
1038 | #ifdef XPM_BACKGROUND |
1133 | if (rs[Rs_backgroundPixmap] != NULL |
1039 | if (rs[Rs_backgroundPixmap] != NULL |
1134 | && ! OPTION (Opt_transparent)) |
1040 | && !OPTION (Opt_transparent)) |
1135 | { |
1041 | { |
1136 | const char *p = rs[Rs_backgroundPixmap]; |
1042 | const char *p = rs[Rs_backgroundPixmap]; |
1137 | |
1043 | |
1138 | if ((p = strchr (p, ';')) != NULL) |
1044 | if ((p = strchr (p, ';')) != NULL) |
1139 | { |
1045 | { |
… | |
… | |
1145 | scr_touch (true); |
1051 | scr_touch (true); |
1146 | } |
1052 | } |
1147 | #endif |
1053 | #endif |
1148 | |
1054 | |
1149 | /* graphics context for the vt window */ |
1055 | /* graphics context for the vt window */ |
1150 | gcvalue.foreground = pix_colors[Color_fg]; |
1056 | gcvalue.foreground = pix_colors[Color_fg]; |
1151 | gcvalue.background = pix_colors[Color_bg]; |
1057 | gcvalue.background = pix_colors[Color_bg]; |
1152 | gcvalue.graphics_exposures = 1; |
1058 | gcvalue.graphics_exposures = 1; |
|
|
1059 | |
1153 | gc = XCreateGC (disp, vt, |
1060 | gc = XCreateGC (disp, vt, |
1154 | GCForeground | GCBackground | GCGraphicsExposures, |
1061 | GCForeground | GCBackground | GCGraphicsExposures, |
1155 | &gcvalue); |
1062 | &gcvalue); |
1156 | |
1063 | |
1157 | drawable = new rxvt_drawable (display, vt); |
1064 | drawable = new rxvt_drawable (display, vt); |
1158 | |
1065 | |
1159 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
1066 | #ifdef RXVT_SCROLLBAR |
1160 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1067 | gcvalue.foreground = pix_colors[Color_topShadow]; |
1161 | topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1068 | topShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1162 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1069 | gcvalue.foreground = pix_colors[Color_bottomShadow]; |
1163 | botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1070 | botShadowGC = XCreateGC (disp, vt, GCForeground, &gcvalue); |
1164 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
1071 | gcvalue.foreground = pix_colors[ (display->depth <= 2 ? Color_fg : Color_scroll)]; |
… | |
… | |
1171 | pix_colors = pix_colors_unfocused; |
1078 | pix_colors = pix_colors_unfocused; |
1172 | #endif |
1079 | #endif |
1173 | |
1080 | |
1174 | pointer_unblank (); |
1081 | pointer_unblank (); |
1175 | scr_recolour (); |
1082 | scr_recolour (); |
1176 | |
|
|
1177 | #if ENABLE_XEMBED |
|
|
1178 | if (rs[Rs_embed]) |
|
|
1179 | { |
|
|
1180 | long info[2] = { 0, XEMBED_MAPPED }; |
|
|
1181 | |
|
|
1182 | XChangeProperty (disp, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], |
|
|
1183 | 32, PropModeReplace, (unsigned char *)&info, 2); |
|
|
1184 | } |
|
|
1185 | #endif |
|
|
1186 | } |
1083 | } |
1187 | |
1084 | |
1188 | /* ------------------------------------------------------------------------- * |
1085 | /* ------------------------------------------------------------------------- * |
1189 | * GET TTY CURRENT STATE * |
1086 | * GET TTY CURRENT STATE * |
1190 | * ------------------------------------------------------------------------- */ |
1087 | * ------------------------------------------------------------------------- */ |
… | |
… | |
1407 | rxvt_term::run_command (const char *const *argv) |
1304 | rxvt_term::run_command (const char *const *argv) |
1408 | { |
1305 | { |
1409 | #if ENABLE_FRILLS |
1306 | #if ENABLE_FRILLS |
1410 | if (rs[Rs_pty_fd]) |
1307 | if (rs[Rs_pty_fd]) |
1411 | { |
1308 | { |
1412 | pty.pty = atoi (rs[Rs_pty_fd]); |
1309 | pty->pty = atoi (rs[Rs_pty_fd]); |
1413 | |
1310 | |
1414 | if (pty.pty >= 0) |
1311 | if (pty->pty >= 0) |
1415 | { |
1312 | { |
1416 | if (getfd_hook) |
1313 | if (getfd_hook) |
1417 | pty.pty = (*getfd_hook) (pty.pty); |
1314 | pty->pty = (*getfd_hook) (pty->pty); |
1418 | |
1315 | |
1419 | if (pty.pty < 0 || fcntl (pty.pty, F_SETFL, O_NONBLOCK)) |
1316 | if (pty->pty < 0 || fcntl (pty->pty, F_SETFL, O_NONBLOCK)) |
1420 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1317 | rxvt_fatal ("unusable pty-fd filehandle, aborting.\n"); |
1421 | } |
1318 | } |
1422 | } |
1319 | } |
1423 | else |
1320 | else |
1424 | #endif |
1321 | #endif |
1425 | if (!pty.get ()) |
1322 | if (!pty->get ()) |
1426 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1323 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1427 | |
1324 | |
1428 | pty.set_utf8_mode (enc_utf8); |
1325 | pty->set_utf8_mode (enc_utf8); |
1429 | |
1326 | |
1430 | /* set initial window size */ |
1327 | /* set initial window size */ |
1431 | tt_winch (); |
1328 | tt_winch (); |
1432 | |
1329 | |
1433 | int er; |
1330 | int er; |
… | |
… | |
1446 | #if ENABLE_FRILLS |
1343 | #if ENABLE_FRILLS |
1447 | if (rs[Rs_pty_fd]) |
1344 | if (rs[Rs_pty_fd]) |
1448 | return; |
1345 | return; |
1449 | #endif |
1346 | #endif |
1450 | |
1347 | |
1451 | #ifndef __QNX__ |
|
|
1452 | /* spin off the command interpreter */ |
1348 | /* spin off the command interpreter */ |
1453 | switch (cmd_pid = fork ()) |
1349 | switch (cmd_pid = fork ()) |
1454 | { |
1350 | { |
1455 | case -1: |
1351 | case -1: |
1456 | { |
1352 | { |
… | |
… | |
1458 | rxvt_fatal ("can't fork, aborting.\n"); |
1354 | rxvt_fatal ("can't fork, aborting.\n"); |
1459 | } |
1355 | } |
1460 | case 0: |
1356 | case 0: |
1461 | init_env (); |
1357 | init_env (); |
1462 | |
1358 | |
1463 | if (!pty.make_controlling_tty ()) |
1359 | if (!pty->make_controlling_tty ()) |
1464 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1360 | fprintf (stderr, "%s: could not obtain control of tty.", RESNAME); |
1465 | else |
1361 | else |
1466 | { |
1362 | { |
1467 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1363 | /* Reopen stdin, stdout and stderr over the tty file descriptor */ |
1468 | dup2 (pty.tty, STDIN_FILENO); |
1364 | dup2 (pty->tty, STDIN_FILENO); |
1469 | dup2 (pty.tty, STDOUT_FILENO); |
1365 | dup2 (pty->tty, STDOUT_FILENO); |
1470 | dup2 (pty.tty, STDERR_FILENO); |
1366 | dup2 (pty->tty, STDERR_FILENO); |
1471 | |
1367 | |
1472 | // close all our file handles that we do no longer need |
1368 | // close all our file handles that we do no longer need |
1473 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1369 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
1474 | { |
1370 | { |
1475 | if ((*t)->pty.pty > 2) close ((*t)->pty.pty); |
1371 | if ((*t)->pty->pty > 2) close ((*t)->pty->pty); |
1476 | if ((*t)->pty.tty > 2) close ((*t)->pty.tty); |
1372 | if ((*t)->pty->tty > 2) close ((*t)->pty->tty); |
1477 | } |
1373 | } |
1478 | |
1374 | |
1479 | run_child (argv); |
1375 | run_child (argv); |
1480 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1376 | fprintf (stderr, "%s: unable to exec child.", RESNAME); |
1481 | } |
1377 | } |
1482 | |
1378 | |
1483 | _exit (EXIT_FAILURE); |
1379 | _exit (EXIT_FAILURE); |
1484 | |
1380 | |
1485 | default: |
1381 | default: |
1486 | { |
1382 | if (!OPTION (Opt_utmpInhibit)) |
1487 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1383 | pty->login (cmd_pid, OPTION (Opt_loginShell), rs[Rs_display_name]); |
1488 | int fdstdin; |
|
|
1489 | |
1384 | |
1490 | fdstdin = dup (STDIN_FILENO); |
1385 | pty->close_tty (); |
1491 | dup2 (pty.tty, STDIN_FILENO); |
|
|
1492 | #endif |
|
|
1493 | |
1386 | |
1494 | #ifdef UTMP_SUPPORT |
1387 | child_ev.start (cmd_pid); |
1495 | privileged_utmp (SAVE); |
|
|
1496 | #endif |
|
|
1497 | |
1388 | |
1498 | #if defined(HAVE_STRUCT_UTMP) && defined(HAVE_TTYSLOT) |
1389 | HOOK_INVOKE ((this, HOOK_CHILD_START, DT_INT, cmd_pid, DT_END)); |
1499 | |
|
|
1500 | dup2 (fdstdin, STDIN_FILENO); |
|
|
1501 | close (fdstdin); |
|
|
1502 | #endif |
|
|
1503 | } |
|
|
1504 | |
|
|
1505 | pty.close_tty (); /* keep STDERR_FILENO, pty.pty, display->fd () open */ |
|
|
1506 | break; |
1390 | break; |
1507 | } |
1391 | } |
1508 | #else /* __QNX__ uses qnxspawn () */ |
|
|
1509 | fchmod (pty.tty, 0622); |
|
|
1510 | fcntl (pty.tty, F_SETFD, FD_CLOEXEC); |
|
|
1511 | fcntl (pty.pty, F_SETFD, FD_CLOEXEC); |
|
|
1512 | |
|
|
1513 | if (run_child (argv) == -1) |
|
|
1514 | exit (EXIT_FAILURE); |
|
|
1515 | #endif |
|
|
1516 | } |
1392 | } |
1517 | |
1393 | |
1518 | /* ------------------------------------------------------------------------- * |
1394 | /* ------------------------------------------------------------------------- * |
1519 | * CHILD PROCESS OPERATIONS * |
1395 | * CHILD PROCESS OPERATIONS * |
1520 | * ------------------------------------------------------------------------- */ |
1396 | * ------------------------------------------------------------------------- */ |
… | |
… | |
1564 | // unblock signals (signals are blocked by iom.C |
1440 | // unblock signals (signals are blocked by iom.C |
1565 | sigset_t ss; |
1441 | sigset_t ss; |
1566 | sigemptyset (&ss); |
1442 | sigemptyset (&ss); |
1567 | sigprocmask (SIG_SETMASK, &ss, 0); |
1443 | sigprocmask (SIG_SETMASK, &ss, 0); |
1568 | |
1444 | |
1569 | #ifndef __QNX__ |
|
|
1570 | /* command interpreter path */ |
1445 | /* command interpreter path */ |
1571 | if (argv != NULL) |
1446 | if (argv != NULL) |
1572 | { |
1447 | { |
1573 | # ifdef DEBUG_CMD |
1448 | # ifdef DEBUG_CMD |
1574 | int i; |
1449 | int i; |
… | |
… | |
1580 | execvp (argv[0], (char *const *)argv); |
1455 | execvp (argv[0], (char *const *)argv); |
1581 | /* no error message: STDERR is closed! */ |
1456 | /* no error message: STDERR is closed! */ |
1582 | } |
1457 | } |
1583 | else |
1458 | else |
1584 | { |
1459 | { |
1585 | const char *argv0, *shell; |
1460 | const char *argv0, *shell; |
1586 | |
1461 | |
1587 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1462 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1588 | shell = "/bin/sh"; |
1463 | shell = "/bin/sh"; |
1589 | |
1464 | |
1590 | argv0 = (const char *)rxvt_r_basename (shell); |
1465 | argv0 = (const char *)rxvt_r_basename (shell); |
… | |
… | |
1595 | |
1470 | |
1596 | login[0] = '-'; |
1471 | login[0] = '-'; |
1597 | strcpy (&login[1], argv0); |
1472 | strcpy (&login[1], argv0); |
1598 | argv0 = login; |
1473 | argv0 = login; |
1599 | } |
1474 | } |
|
|
1475 | |
1600 | execlp (shell, argv0, NULL); |
1476 | execlp (shell, argv0, NULL); |
1601 | /* no error message: STDERR is closed! */ |
1477 | /* no error message: STDERR is closed! */ |
1602 | } |
1478 | } |
1603 | |
1479 | |
1604 | #else /* __QNX__ uses qnxspawn () */ |
|
|
1605 | |
|
|
1606 | char iov_a[10] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; |
|
|
1607 | char *command = NULL, fullcommand[_MAX_PATH]; |
|
|
1608 | char **arg_v, *arg_a[2] = { NULL, NULL }; |
|
|
1609 | |
|
|
1610 | if (argv != NULL) |
|
|
1611 | { |
|
|
1612 | if (access (argv[0], X_OK) == -1) |
|
|
1613 | { |
|
|
1614 | if (strchr (argv[0], '/') == NULL) |
|
|
1615 | { |
|
|
1616 | searchenv (argv[0], "PATH", fullcommand); |
|
|
1617 | |
|
|
1618 | if (fullcommand[0] != '\0') |
|
|
1619 | command = fullcommand; |
|
|
1620 | } |
|
|
1621 | |
|
|
1622 | if (access (command, X_OK) == -1) |
|
|
1623 | return -1; |
|
|
1624 | } |
|
|
1625 | else |
|
|
1626 | command = argv[0]; |
|
|
1627 | |
|
|
1628 | arg_v = argv; |
|
|
1629 | } |
|
|
1630 | else |
|
|
1631 | { |
|
|
1632 | if ((command = getenv ("SHELL")) == NULL || *command == '\0') |
|
|
1633 | command = "/bin/sh"; |
|
|
1634 | |
|
|
1635 | arg_a[0] = my_basename (command); |
|
|
1636 | |
|
|
1637 | if (OPTION (Opt_loginShell)) |
|
|
1638 | { |
|
|
1639 | login = rxvt_malloc ((strlen (arg_a[0]) + 2) * sizeof (char)); |
|
|
1640 | |
|
|
1641 | login[0] = '-'; |
|
|
1642 | strcpy (&login[1], arg_a[0]); |
|
|
1643 | arg_a[0] = login; |
|
|
1644 | } |
|
|
1645 | |
|
|
1646 | arg_v = arg_a; |
|
|
1647 | } |
|
|
1648 | |
|
|
1649 | iov_a[0] = iov_a[1] = iov_a[2] = pty.tty; |
|
|
1650 | cmd_pid = qnx_spawn (0, 0, 0, -1, -1, |
|
|
1651 | _SPAWN_SETSID | _SPAWN_TCSETPGRP, |
|
|
1652 | command, arg_v, environ, iov_a, 0); |
|
|
1653 | if (login) |
|
|
1654 | free (login); |
|
|
1655 | |
|
|
1656 | pty.close_tty (); |
|
|
1657 | return pty.pty; |
|
|
1658 | #endif |
|
|
1659 | |
|
|
1660 | return -1; |
1480 | return -1; |
1661 | } |
1481 | } |
1662 | |
1482 | |
1663 | /*----------------------- end-of-file (C source) -----------------------*/ |
1483 | /*----------------------- end-of-file (C source) -----------------------*/ |