1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
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> |
… | |
… | |
166 | #endif |
166 | #endif |
167 | #ifdef KEEP_SCROLLCOLOR |
167 | #ifdef KEEP_SCROLLCOLOR |
168 | COLOR_SCROLLBAR, |
168 | COLOR_SCROLLBAR, |
169 | COLOR_SCROLLTROUGH, |
169 | COLOR_SCROLLTROUGH, |
170 | #endif /* KEEP_SCROLLCOLOR */ |
170 | #endif /* KEEP_SCROLLCOLOR */ |
171 | #if TINTING |
171 | #if ENABLE_TRANSPARENCY |
172 | NULL, |
172 | NULL, |
173 | #endif |
173 | #endif |
174 | #if OFF_FOCUS_FADING |
174 | #if OFF_FOCUS_FADING |
175 | "rgb:00/00/00", |
175 | "rgb:00/00/00", |
176 | #endif |
176 | #endif |
… | |
… | |
183 | pix_colors_focused = new rxvt_color [TOTAL_COLORS]; |
183 | pix_colors_focused = new rxvt_color [TOTAL_COLORS]; |
184 | #ifdef OFF_FOCUS_FADING |
184 | #ifdef OFF_FOCUS_FADING |
185 | pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; |
185 | pix_colors_unfocused = new rxvt_color [TOTAL_COLORS]; |
186 | #endif |
186 | #endif |
187 | |
187 | |
188 | #if defined(XPM_BACKGROUND) || defined(ENABLE_TRANSPARENCY) |
|
|
189 | pixmap = None; |
|
|
190 | #endif |
|
|
191 | |
188 | |
192 | MEvent.time = CurrentTime; |
189 | MEvent.time = CurrentTime; |
193 | MEvent.button = AnyButton; |
190 | MEvent.button = AnyButton; |
194 | want_refresh = 1; |
191 | want_refresh = 1; |
195 | priv_modes = SavedModes = PrivMode_Default; |
192 | priv_modes = SavedModes = PrivMode_Default; |
… | |
… | |
202 | numpix_colors = TOTAL_COLORS; |
199 | numpix_colors = TOTAL_COLORS; |
203 | |
200 | |
204 | refresh_type = SLOW_REFRESH; |
201 | refresh_type = SLOW_REFRESH; |
205 | |
202 | |
206 | oldcursor.row = oldcursor.col = -1; |
203 | oldcursor.row = oldcursor.col = -1; |
207 | #ifdef XPM_BACKGROUND |
|
|
208 | /* bgPixmap.w = bgPixmap.h = 0; */ |
|
|
209 | bgPixmap.x = bgPixmap.y = 0; |
|
|
210 | bgPixmap.pixmap = None; |
|
|
211 | #endif |
|
|
212 | |
|
|
213 | last_bot = last_state = -1; |
204 | last_bot = last_state = -1; |
214 | |
205 | |
215 | set_option (Opt_scrollBar); |
206 | set_option (Opt_scrollBar); |
216 | set_option (Opt_scrollTtyOutput); |
207 | set_option (Opt_scrollTtyOutput); |
217 | set_option (Opt_jumpScroll); |
208 | set_option (Opt_jumpScroll); |
… | |
… | |
262 | /*----------------------------------------------------------------------*/ |
253 | /*----------------------------------------------------------------------*/ |
263 | const char ** |
254 | const char ** |
264 | rxvt_term::init_resources (int argc, const char *const *argv) |
255 | rxvt_term::init_resources (int argc, const char *const *argv) |
265 | { |
256 | { |
266 | int i, r_argc; |
257 | int i, r_argc; |
267 | char *val; |
|
|
268 | const char **cmd_argv, **r_argv; |
258 | const char **cmd_argv, **r_argv; |
269 | |
259 | |
270 | /* |
260 | /* |
271 | * Look for -e option. Find => split and make cmd_argv[] of command args |
261 | * Look for -e option. Find => split and make cmd_argv[] of command args |
272 | */ |
262 | */ |
… | |
… | |
291 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
281 | cmd_argv[i] = (const char *)argv[i + r_argc + 1]; |
292 | |
282 | |
293 | cmd_argv[i] = NULL; |
283 | cmd_argv[i] = NULL; |
294 | } |
284 | } |
295 | |
285 | |
296 | rs[Rs_name] = rxvt_r_basename (argv[0]); |
286 | rs[Rs_name] = rxvt_basename (argv[0]); |
297 | |
287 | |
298 | /* |
288 | /* |
299 | * Open display, get options/resources and create the window |
289 | * Open display, get options/resources and create the window |
300 | */ |
290 | */ |
301 | |
291 | |
… | |
… | |
344 | * set any defaults not already set |
334 | * set any defaults not already set |
345 | */ |
335 | */ |
346 | if (cmd_argv && cmd_argv[0]) |
336 | if (cmd_argv && cmd_argv[0]) |
347 | { |
337 | { |
348 | if (!rs[Rs_title]) |
338 | if (!rs[Rs_title]) |
349 | rs[Rs_title] = rxvt_r_basename (cmd_argv[0]); |
339 | rs[Rs_title] = rxvt_basename (cmd_argv[0]); |
350 | if (!rs[Rs_iconName]) |
340 | if (!rs[Rs_iconName]) |
351 | rs[Rs_iconName] = rs[Rs_title]; |
341 | rs[Rs_iconName] = rs[Rs_title]; |
352 | } |
342 | } |
353 | else |
343 | else |
354 | { |
344 | { |
… | |
… | |
392 | rs[Rs_cutchars] = CUTCHARS; |
382 | rs[Rs_cutchars] = CUTCHARS; |
393 | |
383 | |
394 | #ifndef NO_BACKSPACE_KEY |
384 | #ifndef NO_BACKSPACE_KEY |
395 | if (!rs[Rs_backspace_key]) |
385 | if (!rs[Rs_backspace_key]) |
396 | # ifdef DEFAULT_BACKSPACE |
386 | # ifdef DEFAULT_BACKSPACE |
397 | key_backspace = DEFAULT_BACKSPACE; |
387 | rs[Rs_backspace_key] = DEFAULT_BACKSPACE; |
398 | # else |
388 | # else |
399 | key_backspace = "DEC"; /* can toggle between \010 or \177 */ |
389 | rs[Rs_backspace_key] = "DEC"; /* can toggle between \010 or \177 */ |
400 | # endif |
390 | # endif |
401 | else |
|
|
402 | { |
|
|
403 | val = strdup (rs[Rs_backspace_key]); |
|
|
404 | rxvt_Str_trim (val); |
|
|
405 | rxvt_Str_escaped (val); |
|
|
406 | key_backspace = val; |
|
|
407 | } |
|
|
408 | #endif |
391 | #endif |
409 | |
392 | |
410 | #ifndef NO_DELETE_KEY |
393 | #ifndef NO_DELETE_KEY |
411 | if (!rs[Rs_delete_key]) |
394 | if (!rs[Rs_delete_key]) |
412 | # ifdef DEFAULT_DELETE |
395 | # ifdef DEFAULT_DELETE |
413 | key_delete = DEFAULT_DELETE; |
396 | rs[Rs_delete_key] = DEFAULT_DELETE; |
414 | # else |
397 | # else |
415 | key_delete = "\033[3~"; |
398 | rs[Rs_delete_key] = "\033[3~"; |
416 | # endif |
|
|
417 | else |
|
|
418 | { |
|
|
419 | val = strdup (rs[Rs_delete_key]); |
|
|
420 | rxvt_Str_trim (val); |
|
|
421 | rxvt_Str_escaped (val); |
|
|
422 | key_delete = val; |
|
|
423 | } |
|
|
424 | #endif |
399 | # endif |
425 | if (rs[Rs_answerbackstring]) |
400 | #endif |
426 | { |
|
|
427 | rxvt_Str_trim ((char *)rs[Rs_answerbackstring]); |
|
|
428 | rxvt_Str_escaped ((char *)rs[Rs_answerbackstring]); |
|
|
429 | } |
|
|
430 | |
401 | |
431 | #ifdef HAVE_SCROLLBARS |
402 | #ifdef HAVE_SCROLLBARS |
432 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]); |
403 | setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]); |
433 | #endif |
404 | #endif |
434 | |
405 | |
… | |
… | |
479 | /*----------------------------------------------------------------------*/ |
450 | /*----------------------------------------------------------------------*/ |
480 | void |
451 | void |
481 | rxvt_term::init_env () |
452 | rxvt_term::init_env () |
482 | { |
453 | { |
483 | int i; |
454 | int i; |
484 | unsigned int u; |
|
|
485 | char *val; |
455 | char *val; |
486 | |
456 | |
487 | #ifdef DISPLAY_IS_IP |
457 | #ifdef DISPLAY_IS_IP |
488 | /* Fixup display_name for export over pty to any interested terminal |
458 | /* Fixup display_name for export over pty to any interested terminal |
489 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
459 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
… | |
… | |
504 | |
474 | |
505 | if (rs[Rs_display_name] == NULL) |
475 | if (rs[Rs_display_name] == NULL) |
506 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
476 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
507 | |
477 | |
508 | i = strlen (val); |
478 | i = strlen (val); |
509 | env_display = (char *)rxvt_malloc ((i + 9) * sizeof (char)); |
479 | env_display = (char *)rxvt_malloc (i + 9); |
510 | |
480 | |
511 | sprintf (env_display, "DISPLAY=%s", val); |
481 | sprintf (env_display, "DISPLAY=%s", val); |
512 | |
482 | |
513 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); |
483 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); |
514 | |
484 | |
… | |
… | |
535 | else |
505 | else |
536 | putenv ("COLORTERM=" COLORTERMENVFULL); |
506 | putenv ("COLORTERM=" COLORTERMENVFULL); |
537 | |
507 | |
538 | if (rs[Rs_term_name] != NULL) |
508 | if (rs[Rs_term_name] != NULL) |
539 | { |
509 | { |
540 | env_term = (char *)rxvt_malloc ((strlen (rs[Rs_term_name]) + 6) * sizeof (char)); |
510 | env_term = (char *)rxvt_malloc (strlen (rs[Rs_term_name]) + 6); |
541 | sprintf (env_term, "TERM=%s", rs[Rs_term_name]); |
511 | sprintf (env_term, "TERM=%s", rs[Rs_term_name]); |
542 | putenv (env_term); |
512 | putenv (env_term); |
543 | } |
513 | } |
544 | else |
514 | else |
545 | putenv ("TERM=" TERMENV); |
515 | putenv ("TERM=" TERMENV); |
… | |
… | |
645 | priv_modes |= PrivMode_Keypress; |
615 | priv_modes |= PrivMode_Keypress; |
646 | if (!option (Opt_jumpScroll)) |
616 | if (!option (Opt_jumpScroll)) |
647 | priv_modes |= PrivMode_smoothScroll; |
617 | priv_modes |= PrivMode_smoothScroll; |
648 | |
618 | |
649 | #ifndef NO_BACKSPACE_KEY |
619 | #ifndef NO_BACKSPACE_KEY |
650 | if (strcmp (key_backspace, "DEC") == 0) |
620 | if (strcmp (rs[Rs_backspace_key], "DEC") == 0) |
651 | priv_modes |= PrivMode_HaveBackSpace; |
621 | priv_modes |= PrivMode_HaveBackSpace; |
652 | #endif |
622 | #endif |
653 | |
623 | |
654 | /* add value for scrollBar */ |
624 | /* add value for scrollBar */ |
655 | if (scrollBar.state) |
625 | if (scrollBar.state) |
… | |
… | |
882 | rxvt_term::create_windows (int argc, const char *const *argv) |
852 | rxvt_term::create_windows (int argc, const char *const *argv) |
883 | { |
853 | { |
884 | XClassHint classHint; |
854 | XClassHint classHint; |
885 | XWMHints wmHint; |
855 | XWMHints wmHint; |
886 | #if ENABLE_FRILLS |
856 | #if ENABLE_FRILLS |
887 | MWMHints mwmhints; |
857 | MWMHints mwmhints = { }; |
888 | #endif |
858 | #endif |
889 | XGCValues gcvalue; |
859 | XGCValues gcvalue; |
890 | XSetWindowAttributes attributes; |
860 | XSetWindowAttributes attributes; |
891 | Window top, parent; |
861 | Window top, parent; |
892 | |
862 | |
… | |
… | |
905 | #if ENABLE_FRILLS |
875 | #if ENABLE_FRILLS |
906 | if (option (Opt_borderLess)) |
876 | if (option (Opt_borderLess)) |
907 | { |
877 | { |
908 | if (XInternAtom (dpy, "_MOTIF_WM_INFO", True) == None) |
878 | if (XInternAtom (dpy, "_MOTIF_WM_INFO", True) == None) |
909 | { |
879 | { |
910 | /* print_warning("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n");*/ |
880 | // rxvt_warn("Window Manager does not support MWM hints. Bypassing window manager control for borderless window.\n"); |
911 | attributes.override_redirect = true; |
881 | attributes.override_redirect = true; |
912 | mwmhints.flags = 0; |
|
|
913 | } |
882 | } |
914 | else |
883 | else |
915 | { |
884 | { |
916 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
885 | mwmhints.flags = MWM_HINTS_DECORATIONS; |
917 | mwmhints.decorations = 0; |
|
|
918 | } |
886 | } |
919 | } |
887 | } |
920 | else |
|
|
921 | mwmhints.flags = 0; |
|
|
922 | #endif |
888 | #endif |
923 | |
889 | |
924 | #if ENABLE_XEMBED |
890 | #if ENABLE_XEMBED |
925 | if (rs[Rs_embed]) |
891 | if (rs[Rs_embed]) |
926 | { |
892 | { |
… | |
… | |
1036 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1002 | vt_emask |= Button1MotionMask | Button3MotionMask; |
1037 | |
1003 | |
1038 | vt_select_input (); |
1004 | vt_select_input (); |
1039 | |
1005 | |
1040 | vt_ev.start (display, vt); |
1006 | vt_ev.start (display, vt); |
1041 | |
|
|
1042 | #ifdef XPM_BACKGROUND |
|
|
1043 | if (rs[Rs_backgroundPixmap] != NULL |
|
|
1044 | #ifndef HAVE_AFTERIMAGE |
|
|
1045 | && !option (Opt_transparent) |
|
|
1046 | #endif |
|
|
1047 | ) |
|
|
1048 | { |
|
|
1049 | const char *p = rs[Rs_backgroundPixmap]; |
|
|
1050 | |
|
|
1051 | if ((p = strchr (p, ';')) != NULL) |
|
|
1052 | { |
|
|
1053 | p++; |
|
|
1054 | scale_pixmap (p); |
|
|
1055 | } |
|
|
1056 | |
|
|
1057 | set_bgPixmap (rs[Rs_backgroundPixmap]); |
|
|
1058 | scr_touch (true); |
|
|
1059 | } |
|
|
1060 | #endif |
|
|
1061 | |
1007 | |
1062 | /* graphics context for the vt window */ |
1008 | /* graphics context for the vt window */ |
1063 | gcvalue.foreground = pix_colors[Color_fg]; |
1009 | gcvalue.foreground = pix_colors[Color_fg]; |
1064 | gcvalue.background = pix_colors[Color_bg]; |
1010 | gcvalue.background = pix_colors[Color_bg]; |
1065 | gcvalue.graphics_exposures = 0; |
1011 | gcvalue.graphics_exposures = 0; |
… | |
… | |
1282 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1228 | rxvt_fatal ("can't initialize pseudo-tty, aborting.\n"); |
1283 | |
1229 | |
1284 | int er; |
1230 | int er; |
1285 | |
1231 | |
1286 | #ifndef NO_BACKSPACE_KEY |
1232 | #ifndef NO_BACKSPACE_KEY |
1287 | if (key_backspace[0] && !key_backspace[1]) |
1233 | if (rs[Rs_backspace_key][0] && !rs[Rs_backspace_key][1]) |
1288 | er = key_backspace[0]; |
1234 | er = rs[Rs_backspace_key][0]; |
1289 | else if (strcmp (key_backspace, "DEC") == 0) |
1235 | else if (strcmp (rs[Rs_backspace_key], "DEC") == 0) |
1290 | er = '\177'; /* the initial state anyway */ |
1236 | er = '\177'; /* the initial state anyway */ |
1291 | else |
1237 | else |
1292 | #endif |
1238 | #endif |
1293 | er = -1; |
1239 | er = -1; |
1294 | |
1240 | |
… | |
… | |
1398 | sigset_t ss; |
1344 | sigset_t ss; |
1399 | sigemptyset (&ss); |
1345 | sigemptyset (&ss); |
1400 | sigprocmask (SIG_SETMASK, &ss, 0); |
1346 | sigprocmask (SIG_SETMASK, &ss, 0); |
1401 | |
1347 | |
1402 | /* command interpreter path */ |
1348 | /* command interpreter path */ |
1403 | if (argv != NULL) |
1349 | if (argv) |
1404 | { |
1350 | { |
1405 | # ifdef DEBUG_CMD |
1351 | # ifdef DEBUG_CMD |
1406 | int i; |
1352 | int i; |
1407 | |
1353 | |
1408 | for (i = 0; argv[i]; i++) |
1354 | for (i = 0; argv[i]; i++) |
… | |
… | |
1417 | const char *argv0, *shell; |
1363 | const char *argv0, *shell; |
1418 | |
1364 | |
1419 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1365 | if ((shell = getenv ("SHELL")) == NULL || *shell == '\0') |
1420 | shell = "/bin/sh"; |
1366 | shell = "/bin/sh"; |
1421 | |
1367 | |
1422 | argv0 = (const char *)rxvt_r_basename (shell); |
1368 | argv0 = (const char *)rxvt_basename (shell); |
1423 | |
1369 | |
1424 | if (option (Opt_loginShell)) |
1370 | if (option (Opt_loginShell)) |
1425 | { |
1371 | { |
1426 | login = (char *)rxvt_malloc ((strlen (argv0) + 2) * sizeof (char)); |
1372 | login = (char *)rxvt_malloc (strlen (argv0) + 2); |
1427 | |
1373 | |
1428 | login[0] = '-'; |
1374 | login[0] = '-'; |
1429 | strcpy (&login[1], argv0); |
1375 | strcpy (&login[1], argv0); |
1430 | argv0 = login; |
1376 | argv0 = login; |
1431 | } |
1377 | } |
1432 | |
1378 | |
1433 | execlp (shell, argv0, NULL); |
1379 | execlp (shell, argv0, (char *)0); |
1434 | /* no error message: STDERR is closed! */ |
1380 | /* no error message: STDERR is closed! */ |
1435 | } |
1381 | } |
1436 | |
1382 | |
1437 | return -1; |
1383 | return -1; |
1438 | } |
1384 | } |