ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/init.C
(Generate patch)

Comparing rxvt-unicode/src/init.C (file contents):
Revision 1.239 by ayin, Sat Jan 19 13:00:07 2008 UTC vs.
Revision 1.254 by root, Tue Nov 4 11:03:29 2008 UTC

10 * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM> 10 * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM>
11 * Copyright (c) 1997 mj olesen <olesen@me.queensu.ca> 11 * Copyright (c) 1997 mj olesen <olesen@me.queensu.ca>
12 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> 12 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
13 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> 13 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
14 * - extensive modifications 14 * - extensive modifications
15 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com> 15 * Copyright (c) 2003-2008 Marc Lehmann <pcg@goof.com>
16 * 16 *
17 * This program is free software; you can redistribute it and/or modify 17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by 18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or 19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version. 20 * (at your option) any later version.
267 NULL, // Color_underline 267 NULL, // Color_underline
268#endif 268#endif
269#ifdef OPTION_HC 269#ifdef OPTION_HC
270 NULL, 270 NULL,
271#endif 271#endif
272#ifdef KEEP_SCROLLCOLOR
273 COLOR_SCROLLBAR, 272 COLOR_SCROLLBAR,
273#ifdef RXVT_SCROLLBAR
274 COLOR_SCROLLTROUGH, 274 COLOR_SCROLLTROUGH,
275#endif /* KEEP_SCROLLCOLOR */ 275#endif
276#if ENABLE_TRANSPARENCY 276#if ENABLE_TRANSPARENCY
277 NULL, 277 NULL,
278#endif 278#endif
279#if OFF_FOCUS_FADING 279#if OFF_FOCUS_FADING
280 "rgb:00/00/00", 280 "rgb:00/00/00",
308 set_option (Opt_secondaryScreen); 308 set_option (Opt_secondaryScreen);
309 set_option (Opt_secondaryScroll); 309 set_option (Opt_secondaryScroll);
310 set_option (Opt_pastableTabs); 310 set_option (Opt_pastableTabs);
311 set_option (Opt_intensityStyles); 311 set_option (Opt_intensityStyles);
312 set_option (Opt_iso14755_52); 312 set_option (Opt_iso14755_52);
313 set_option (Opt_buffered);
313} 314}
314 315
315void 316static void
316rxvt_term::init_secondary () 317init_secondary ()
317{ 318{
318 int i; 319 int i;
319 320
320 /*
321 * Close all unused file descriptors
322 * We don't want them, we don't need them.
323 */
324 if ((i = open ("/dev/null", O_RDONLY)) < 0) 321 if ((i = open ("/dev/null", O_RDONLY)) < 0)
325 { 322 {
326 /* TODO: BOO HISS */
327 dup2 (STDERR_FILENO, STDIN_FILENO); 323 dup2 (STDERR_FILENO, STDIN_FILENO);
328 } 324 }
329 else if (i != STDIN_FILENO) 325 else if (i != STDIN_FILENO)
330 { 326 {
331 dup2 (i, STDIN_FILENO); 327 dup2 (i, STDIN_FILENO);
332 close (i); 328 close (i);
333 } 329 }
334 330
335 dup2 (STDERR_FILENO, STDOUT_FILENO); 331 dup2 (STDERR_FILENO, STDOUT_FILENO);
336
337#if 0 // schmorp sayz closing filies is murder
338 for (i = STDERR_FILENO + 1; i < num_fds; i++)
339 {
340#ifdef __sgi /* Alex Coventry says we need 4 & 7 too */
341 if (i == 4 || i == 7)
342 continue;
343#endif
344 close (i);
345 }
346#endif
347} 332}
348 333
349/*----------------------------------------------------------------------*/ 334/*----------------------------------------------------------------------*/
350const char ** 335const char **
351rxvt_term::init_resources (int argc, const char *const *argv) 336rxvt_term::init_resources (int argc, const char *const *argv)
474 459
475 /* no point having a scrollbar without having any scrollback! */ 460 /* no point having a scrollbar without having any scrollback! */
476 if (!saveLines) 461 if (!saveLines)
477 set_option (Opt_scrollBar, 0); 462 set_option (Opt_scrollBar, 0);
478 463
479#ifdef PRINTPIPE
480 if (!rs[Rs_print_pipe])
481 rs[Rs_print_pipe] = PRINTPIPE;
482#endif
483
484 if (!rs[Rs_cutchars]) 464 if (!rs[Rs_cutchars])
485 rs[Rs_cutchars] = CUTCHARS; 465 rs[Rs_cutchars] = CUTCHARS;
486 466
487#ifndef NO_BACKSPACE_KEY 467#ifndef NO_BACKSPACE_KEY
488 if (!rs[Rs_backspace_key]) 468 if (!rs[Rs_backspace_key])
500# else 480# else
501 rs[Rs_delete_key] = "\033[3~"; 481 rs[Rs_delete_key] = "\033[3~";
502# endif 482# endif
503#endif 483#endif
504 484
505#ifdef HAVE_SCROLLBARS 485 scrollBar.setup (this);
506 setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]);
507#endif
508 486
509#ifdef XTERM_REVERSE_VIDEO 487#ifdef XTERM_REVERSE_VIDEO
510 /* this is how xterm implements reverseVideo */ 488 /* this is how xterm implements reverseVideo */
511 if (option (Opt_reverseVideo)) 489 if (option (Opt_reverseVideo))
512 { 490 {
556{ 534{
557 this->envv = envv; 535 this->envv = envv;
558 536
559 SET_R (this); 537 SET_R (this);
560 set_locale (""); 538 set_locale ("");
561 set_environ (envv); // few things in X do not call setlocale :( 539 set_environ (envv); // a few things in X do not call setlocale :(
562 540
563 init_vars (); 541 init_vars ();
564 542
565 init_secondary (); 543 init_secondary ();
566 544
568 546
569#ifdef KEYSYM_RESOURCE 547#ifdef KEYSYM_RESOURCE
570 keyboard->register_done (); 548 keyboard->register_done ();
571#endif 549#endif
572 550
573#ifdef HAVE_SCROLLBARS 551 if (const char *path = rs[Rs_chdir])
552 if (*path) // ignored if empty
553 {
554 if (*path != '/')
555 rxvt_fatal ("specified shell working directory must start with a slash, aborting.\n");
556
557 if (chdir (path))
558 rxvt_fatal ("unable to change into specified shell working directory, aborting.\n");
559 }
560
574 if (option (Opt_scrollBar)) 561 if (option (Opt_scrollBar))
575 scrollBar.setIdle (); /* set existence for size calculations */ 562 scrollBar.state = STATE_IDLE; /* set existence for size calculations */
576#endif
577 563
578 pty = ptytty::create (); 564 pty = ptytty::create ();
579 565
580 create_windows (argc, argv); 566 create_windows (argc, argv);
581 567
585 571
586#if 0 572#if 0
587 XSynchronize (dpy, True); 573 XSynchronize (dpy, True);
588#endif 574#endif
589 575
590#ifdef HAVE_SCROLLBARS
591 if (option (Opt_scrollBar)) 576 if (option (Opt_scrollBar))
592 resize_scrollbar (); /* create and map scrollbar */ 577 scrollBar.resize (); /* create and map scrollbar */
593#endif
594#ifdef HAVE_BG_PIXMAP 578#ifdef HAVE_BG_PIXMAP
595 { 579 {
596 bgPixmap.set_target (this); 580 bgPixmap.set_target (this);
597 bgPixmap.invalidate (); 581 bgPixmap.invalidate ();
598 582
853 run_command (argv); 837 run_command (argv);
854} 838}
855 839
856/*----------------------------------------------------------------------*/ 840/*----------------------------------------------------------------------*/
857void 841void
858rxvt_term::Get_Colours () 842rxvt_term::get_colours ()
859{ 843{
860 int i; 844 int i;
861 845
862#ifdef OFF_FOCUS_FADING 846#ifdef OFF_FOCUS_FADING
863 pix_colors = pix_colors_focused; 847 pix_colors = pix_colors_focused;
923 * get scrollBar shadow colors 907 * get scrollBar shadow colors
924 * 908 *
925 * The calculations of topShadow/bottomShadow values are adapted 909 * The calculations of topShadow/bottomShadow values are adapted
926 * from the fvwm window manager. 910 * from the fvwm window manager.
927 */ 911 */
928#ifdef KEEP_SCROLLCOLOR 912#ifdef RXVT_SCROLLBAR
929 if (depth <= 2) 913 if (depth <= 2)
930 { 914 {
931 /* Monochrome */ 915 /* Monochrome */
932 alias_color (Color_scroll, Color_fg); 916 alias_color (Color_scroll, Color_fg);
933 alias_color (Color_topShadow, Color_bg); 917 alias_color (Color_topShadow, Color_bg);
948 min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), 932 min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5),
949 cscroll.a) 933 cscroll.a)
950 )) 934 ))
951 alias_color (Color_topShadow, Color_White); 935 alias_color (Color_topShadow, Color_White);
952 } 936 }
953#endif /* KEEP_SCROLLCOLOR */ 937#endif
954 938
955#ifdef OFF_FOCUS_FADING 939#ifdef OFF_FOCUS_FADING
956 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) 940 for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++)
957 update_fade_color (i); 941 update_fade_color (i);
958#endif 942#endif
1080 Window top, parent; 1064 Window top, parent;
1081 1065
1082 dLocal (Display *, dpy); 1066 dLocal (Display *, dpy);
1083 1067
1084 /* grab colors before netscape does */ 1068 /* grab colors before netscape does */
1085 Get_Colours (); 1069 get_colours ();
1086 1070
1087 if (!set_fonts ()) 1071 if (!set_fonts ())
1088 rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); 1072 rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n");
1089 1073
1090 parent = display->root; 1074 parent = display->root;
1151 wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState; 1135 wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState;
1152 wmHint.window_group = top; 1136 wmHint.window_group = top;
1153 1137
1154 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, 1138 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
1155 &szHint, &wmHint, &classHint); 1139 &szHint, &wmHint, &classHint);
1140#if ENABLE_EWMH
1141# ifdef HAVE_AFTERIMAGE
1142 /*
1143 * set up icon hint
1144 * rs [Rs_iconfile] is path to icon, asv has been created in init_resources
1145 */
1146 if (rs [Rs_iconfile] && asv)
1147 {
1148 ASImage *im = file2ASImage (rs [Rs_iconfile], 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
1149 if (im)
1150 {
1151 int w = im->width;
1152 int h = im->height;
1153 long* buffer = (long *)malloc ((2 + w * h) * sizeof (long));
1154 ASImage *result = scale_asimage (asv, im,
1155 w, h, ASA_ARGB32,
1156 100, ASIMAGE_QUALITY_DEFAULT);
1157 destroy_asimage (&im);
1158
1159 if (buffer && result)
1160 {
1161 ARGB32 *asbuf = result->alt.argb32;
1162 buffer [0] = w;
1163 buffer [1] = h;
1164
1165 for (unsigned int i = 0; i < w * h; ++i)
1166 buffer [i + 2] = asbuf [i];
1167
1168 destroy_asimage (&result);
1169 XChangeProperty (dpy, top, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1170 PropModeReplace, (const unsigned char*) buffer, 2 + w * h);
1171 free (buffer);
1172 }
1173 else
1174 {
1175 if (!buffer)
1176 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1177
1178 if (!result)
1179 rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n");
1180 }
1181 }
1182 else
1183 rxvt_warn ("Loading image icon failed, continuing without.\n");
1184 }
1185# endif
1186#endif
1156 1187
1157#if ENABLE_FRILLS 1188#if ENABLE_FRILLS
1158 if (mwmhints.flags) 1189 if (mwmhints.flags)
1159 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, 1190 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32,
1160 PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); 1191 PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS);
1545 signal (SIGTSTP, SIG_IGN); 1576 signal (SIGTSTP, SIG_IGN);
1546 signal (SIGTTIN, SIG_IGN); 1577 signal (SIGTTIN, SIG_IGN);
1547 signal (SIGTTOU, SIG_IGN); 1578 signal (SIGTTOU, SIG_IGN);
1548#endif /* SIGTSTP */ 1579#endif /* SIGTSTP */
1549 1580
1550 // unblock signals (signals are blocked by iom.C
1551 sigset_t ss;
1552 sigemptyset (&ss);
1553 sigprocmask (SIG_SETMASK, &ss, 0);
1554
1555 /* command interpreter path */ 1581 /* command interpreter path */
1556 if (argv) 1582 if (argv)
1557 { 1583 {
1558# ifdef DEBUG_CMD 1584# ifdef DEBUG_CMD
1559 int i; 1585 int i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines