--- rxvt-unicode/src/init.C 2011/12/22 10:38:09 1.310 +++ rxvt-unicode/src/init.C 2014/12/13 12:24:32 1.340 @@ -16,7 +16,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -40,7 +40,7 @@ #include -#include +#include #include @@ -48,9 +48,7 @@ # define X_LOCALE # include #else -# ifdef HAVE_SETLOCALE -# include -# endif +# include #endif #ifdef HAVE_NL_LANGINFO @@ -80,7 +78,7 @@ #include #include -static char * +static char * ecb_cold rxvt_network_display (const char *display) { char buffer[1024], *rval = NULL; @@ -523,7 +521,7 @@ #ifdef RXVT_SCROLLBAR COLOR_SCROLLTROUGH, #endif -#if ENABLE_TRANSPARENCY +#if BG_IMAGE_FROM_ROOT NULL, #endif #if OFF_FOCUS_FADING @@ -592,9 +590,11 @@ set (display); extract_resources (); -#if XFT - if (rs[Rs_depth]) - select_visual (strtol (rs[Rs_depth], 0, 0)); +#if ENABLE_FRILLS + if (rs[Rs_visual]) + select_visual (strtol (rs[Rs_visual], 0, 0)); + else if (rs[Rs_depth]) + select_depth (strtol (rs[Rs_depth], 0, 0)); #endif for (int i = NUM_RESOURCES; i--; ) @@ -662,6 +662,13 @@ pointerBlankDelay = 2; #endif + if (rs[Rs_multiClickTime] && (i = atoi (rs[Rs_multiClickTime])) >= 0) + multiClickTime = i; + else + multiClickTime = 500; + + cursor_type = option (Opt_cursorUnderline) ? 1 : 0; + /* no point having a scrollbar without having any scrollback! */ if (!saveLines) set_option (Opt_scrollBar, 0); @@ -743,6 +750,10 @@ this->argv = argv; this->envv = envv; + env = new char *[this->envv->size ()]; + for (int i = 0; i < this->envv->size (); i++) + env[i] = this->envv->at (i); + init2 (argv->size () - 1, argv->begin ()); } @@ -770,7 +781,7 @@ { SET_R (this); set_locale (""); - set_environ (envv); // a few things in X do not call setlocale :( + set_environ (env); // a few things in X do not call setlocale :( init_vars (); @@ -795,16 +806,6 @@ pty = ptytty::create (); -#ifdef HAVE_AFTERIMAGE - set_application_name ((char *)rs[Rs_name]); - set_output_threshold (OUTPUT_LEVEL_WARNING); -#endif - - // must be called before create_windows, because the latter may call set_icon -#ifdef HAVE_PIXBUF - g_type_init (); -#endif - create_windows (argc, argv); init_xlocale (); @@ -817,44 +818,16 @@ if (option (Opt_scrollBar)) scrollBar.resize (); /* create and map scrollbar */ -#ifdef HAVE_BG_PIXMAP - { - bg_init (); - -#ifdef ENABLE_TRANSPARENCY - if (option (Opt_transparent)) - { - bg_set_transparent (); - - if (rs [Rs_blurradius]) - bg_set_blur (rs [Rs_blurradius]); - if (ISSET_PIXCOLOR (Color_tint)) - bg_set_tint (pix_colors_focused [Color_tint]); - - if (rs [Rs_shade]) - bg_set_shade (rs [Rs_shade]); - - bg_set_root_pixmap (); - XSelectInput (dpy, display->root, PropertyChangeMask); - rootwin_ev.start (display, display->root); - } -#endif - -#ifdef BG_IMAGE_FROM_FILE - if (rs[Rs_backgroundPixmap]) - if (bg_set_file (rs[Rs_backgroundPixmap])) - if (!bg_window_position_sensitive ()) - update_background (); -#endif - } +#ifdef HAVE_BG_PIXMAP + bg_init (); #endif #if ENABLE_PERL rootwin_ev.start (display, display->root); #endif - set_colorfgbg (); + init_done = 1; init_command (cmd_argv); @@ -908,6 +881,10 @@ rxvt_term::init_env () { char *val; + char *env_display; + char *env_windowid; + char *env_colorfgbg; + char *env_term; #ifdef DISPLAY_IS_IP /* Fixup display_name for export over pty to any interested terminal @@ -934,6 +911,7 @@ sprintf (env_display, "DISPLAY=%s", val); + env_windowid = (char *)rxvt_malloc (21); sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent); /* add entries to the environment: @@ -947,8 +925,8 @@ putenv (env_display); putenv (env_windowid); - if (env_colorfgbg) - putenv (env_colorfgbg); + env_colorfgbg = get_colorfgbg (); + putenv (env_colorfgbg); #ifdef RXVT_TERMINFO putenv ("TERMINFO=" RXVT_TERMINFO); @@ -980,9 +958,8 @@ void rxvt_term::set_locale (const char *locale) { - set_environ (envv); + set_environ (env); -#if HAVE_XSETLOCALE || HAVE_SETLOCALE free (this->locale); this->locale = setlocale (LC_CTYPE, locale); @@ -1003,7 +980,6 @@ this->locale = strdup (this->locale); SET_LOCALE (this->locale); mbstate.reset (); -#endif #if HAVE_NL_LANGINFO char *codeset = nl_langinfo (CODESET); @@ -1020,9 +996,9 @@ void rxvt_term::init_xlocale () { - set_environ (envv); + set_environ (env); -#ifdef USE_XIM +#if USE_XIM if (!locale) rxvt_warn ("setting locale failed, continuing without locale support.\n"); else @@ -1082,7 +1058,7 @@ /*----------------------------------------------------------------------*/ void -rxvt_term::get_colours () +rxvt_term::get_colors () { int i; @@ -1090,7 +1066,7 @@ pix_colors = pix_colors_focused; #endif - for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) + for (i = 0; i < NRS_COLORS; i++) { const char *name = rs[Rs_color + i]; @@ -1111,6 +1087,8 @@ if (!name) continue; + xcol.free (this); + if (!set_color (xcol, name)) { switch (i) @@ -1139,13 +1117,6 @@ rs[Rs_color + i] = name; } - if (depth <= 2) - { - if (!rs[Rs_color + Color_pointer_fg]) alias_color (Color_pointer_fg, Color_fg); - if (!rs[Rs_color + Color_pointer_bg]) alias_color (Color_pointer_bg, Color_bg); - if (!rs[Rs_color + Color_border] ) alias_color (Color_border, Color_fg); - } - /* * get scrollBar shadow colors * @@ -1153,35 +1124,25 @@ * from the fvwm window manager. */ #ifdef RXVT_SCROLLBAR - if (depth <= 2) - { - /* Monochrome */ - alias_color (Color_scroll, Color_fg); - alias_color (Color_topShadow, Color_bg); - alias_color (Color_bottomShadow, Color_bg); - } - else - { - pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); + pix_colors [Color_scroll].fade (this, 50, pix_colors [Color_bottomShadow]); - rgba cscroll; - pix_colors [Color_scroll].get (cscroll); + rgba cscroll; + pix_colors [Color_scroll].get (cscroll); - /* topShadowColor */ - if (!pix_colors[Color_topShadow].set (this, - rgba ( - min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), - min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), - min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), - cscroll.a) - )) - alias_color (Color_topShadow, Color_White); - } + /* topShadowColor */ + if (!pix_colors[Color_topShadow].set (this, + rgba ( + min ((int)rgba::MAX_CC, max (cscroll.r / 5, cscroll.r) * 7 / 5), + min ((int)rgba::MAX_CC, max (cscroll.g / 5, cscroll.g) * 7 / 5), + min ((int)rgba::MAX_CC, max (cscroll.b / 5, cscroll.b) * 7 / 5), + cscroll.a) + )) + alias_color (Color_topShadow, Color_White); #endif #ifdef OFF_FOCUS_FADING - for (i = 0; i < (depth <= 2 ? 2 : NRS_COLORS); i++) - update_fade_color (i); + for (i = 0; i < NRS_COLORS; i++) + update_fade_color (i, true); #endif } @@ -1190,7 +1151,7 @@ void rxvt_term::color_aliases (int idx) { - if (rs[Rs_color + idx] && isdigit (* (rs[Rs_color + idx]))) + if (rs[Rs_color + idx] && isdigit (*rs[Rs_color + idx])) { int i = atoi (rs[Rs_color + idx]); @@ -1240,7 +1201,7 @@ if (kc[k] == 0) break; - switch (XKeycodeToKeysym (dpy, kc[k], 0)) + switch (rxvt_XKeycodeToKeysym (dpy, kc[k], 0)) { case XK_Num_Lock: ModNumLockMask = modmasks[i - 1]; @@ -1295,58 +1256,7 @@ void rxvt_term::set_icon (const char *file) { -#ifdef HAVE_AFTERIMAGE - init_asv (); - - ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL); - if (!im) - { - rxvt_warn ("Loading image icon failed, continuing without.\n"); - return; - } - - unsigned int w = im->width; - unsigned int h = im->height; - - if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) - { - rxvt_warn ("Icon image too big, continuing without.\n"); - destroy_asimage (&im); - return; - } - - ASImage *result = scale_asimage (asv, im, - w, h, ASA_ARGB32, - 100, ASIMAGE_QUALITY_DEFAULT); - destroy_asimage (&im); - - if (!result) - { - rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n"); - return; - } - - long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)); - if (buffer) - { - ARGB32 *asbuf = result->alt.argb32; - buffer [0] = w; - buffer [1] = h; - - for (unsigned int i = 0; i < w * h; ++i) - buffer [i + 2] = asbuf [i]; - - XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, - PropModeReplace, (const unsigned char *) buffer, 2 + w * h); - free (buffer); - } - else - rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); - - destroy_asimage (&result); -#endif - -#ifdef HAVE_PIXBUF +#if HAVE_PIXBUF GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); if (!pixbuf) { @@ -1421,7 +1331,7 @@ dLocal (Display *, dpy); /* grab colors before netscape does */ - get_colours (); + get_colors (); if (!set_fonts ()) rxvt_fatal ("unable to load base fontset, please specify a valid one using -fn, aborting.\n"); @@ -1476,9 +1386,6 @@ this->parent = top; - old_width = szHint.width; - old_height = szHint.height; - set_title (rs [Rs_title]); set_icon_name (rs [Rs_iconName]); @@ -1487,7 +1394,9 @@ wmHint.flags = InputHint | StateHint | WindowGroupHint; wmHint.input = True; - wmHint.initial_state = option (Opt_iconic) ? IconicState : NormalState; + wmHint.initial_state = option (Opt_iconic) ? IconicState + : option (Opt_dockapp) ? WithdrawnState + : NormalState; wmHint.window_group = top; XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, @@ -1499,9 +1408,7 @@ */ if (rs [Rs_iconfile]) - { - set_icon (rs [Rs_iconfile]); - } + set_icon (rs [Rs_iconfile]); #endif #if ENABLE_FRILLS @@ -1550,7 +1457,7 @@ /* the vt window */ vt = XCreateSimpleWindow (dpy, top, window_vt_x, window_vt_y, - width, height, + vt_width, vt_height, 0, pix_colors_focused[Color_fg], pix_colors_focused[Color_bg]); @@ -1587,7 +1494,7 @@ #endif pointer_unblank (); - scr_recolour (); + scr_recolor (); } /*----------------------------------------------------------------------*/ @@ -1720,8 +1627,10 @@ fd = open (CONSOLE, O_WRONLY, 0); if (fd >= 0) - if (ioctl (fd, SRIOCSREDIR, NULL) < 0) + { + ioctl (fd, SRIOCSREDIR, STDIN_FILENO); close (fd); + } #endif /* SRIOCSREDIR */ }