--- rxvt-unicode/src/main.C 2005/02/17 15:07:48 1.140 +++ rxvt-unicode/src/main.C 2005/11/30 21:05:39 1.148 @@ -159,9 +159,6 @@ #ifdef USE_XIM im_ev (this, &rxvt_term::im_cb), #endif - sw_term (this, &rxvt_term::sig_term), - sw_int (this, &rxvt_term::sig_term), - sw_chld (this, &rxvt_term::sig_chld), termwin_ev (this, &rxvt_term::x_cb), vt_ev (this, &rxvt_term::x_cb), check_ev (this, &rxvt_term::check_cb), @@ -254,18 +251,14 @@ #endif delete TermWin.drawable; // destroy all windows - if (TermWin.parent[0] -#if ENABLE_FRILLS - && !rs[Rs_embed] -#endif - ) + if (TermWin.parent[0]) XDestroyWindow (disp, TermWin.parent[0]); } // TODO: free pixcolours, colours should become part of rxvt_display delete pix_colors_focused; -#ifdef OFF_FOCUS_FADING +#if OFF_FOCUS_FADING delete pix_colors_unfocused; #endif @@ -423,8 +416,8 @@ GET_R->allowedxerror = event->error_code; else { - //TODO: GET_R is most likely not the terminal which caused the error - //TODO: maybe just output the error and continue? + // GET_R is most likely not the terminal which caused the error, + // so just output the error and continue #if ENABLE_FRILLS print_x_error (display, event); #else @@ -444,22 +437,7 @@ _exit (EXIT_FAILURE); } -/* - * Catch a fatal signal and tidy up before quitting - */ -void -rxvt_term::sig_term (sig_watcher &w) -{ -#ifdef DEBUG_CMD - rxvt_warn ("caught signal %d, exiting.\n", w.signum); -#endif - rxvt_emergency_cleanup (); - signal (w.signum, SIG_DFL); - kill (getpid (), w.signum); -} - /*----------------------------------------------------------------------*/ -/* rxvt_init () */ bool rxvt_term::init (int argc, const char *const *argv) { @@ -531,6 +509,46 @@ return true; } +static struct sig_handlers +{ + sig_watcher sw_chld, sw_term, sw_int; + + void sig_chld (sig_watcher &w) + { + // we are being called for every SIGCHLD, find the corresponding term + int pid; + + while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) + for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) + if (pid == (*t)->cmd_pid) + { + (*t)->destroy (); + break; + } + } + + /* + * Catch a fatal signal and tidy up before quitting + */ + void + sig_term (sig_watcher &w) + { +#ifdef DEBUG_CMD + rxvt_warn ("caught signal %d, exiting.\n", w.signum); +#endif + rxvt_emergency_cleanup (); + signal (w.signum, SIG_DFL); + kill (getpid (), w.signum); + } + + sig_handlers () + : sw_chld (this, &sig_handlers::sig_chld), + sw_term (this, &sig_handlers::sig_term), + sw_int (this, &sig_handlers::sig_term) + { + } +} sig_handlers; + void rxvt_init () { @@ -547,6 +565,10 @@ signal (SIGHUP, SIG_IGN); signal (SIGPIPE, SIG_IGN); + sig_handlers.sw_chld.start (SIGCHLD); + sig_handlers.sw_term.start (SIGTERM); + sig_handlers.sw_int.start (SIGINT); + /* need to trap SIGURG for SVR4 (Unixware) rlogin */ /* signal (SIGURG, SIG_DFL); */ @@ -556,28 +578,6 @@ } /* ------------------------------------------------------------------------- * - * SIGNAL HANDLING & EXIT HANDLER * - * ------------------------------------------------------------------------- */ -/* - * Catch a SIGCHLD signal and exit if the direct child has died - */ - -void -rxvt_term::sig_chld (sig_watcher &w) -{ - // we are being called for every SIGCHLD, not just ours - int pid; - - while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) - for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) - if (pid == (*t)->cmd_pid) - { - (*t)->destroy (); - break; - } -} - -/* ------------------------------------------------------------------------- * * MEMORY ALLOCATION WRAPPERS * * ------------------------------------------------------------------------- */ void * @@ -591,7 +591,7 @@ return p; } -void * +void * rxvt_calloc (size_t number, size_t size) { void *p = calloc (number, size); @@ -853,7 +853,7 @@ /*----------------------------------------------------------------------*/ /* set_fonts () - load and set the various fonts -/* + * * init = 1 - initialize * * fontname == FONT_UP - switch to bigger font @@ -961,7 +961,7 @@ rxvt_term::set_title (const char *str) { set_string_property (XA_WM_NAME, str); -#if ENABLE_FRILLS +#if ENABLE_EWMH set_utf8_property (xa[XA_NET_WM_NAME], str); #endif } @@ -970,7 +970,7 @@ rxvt_term::set_icon_name (const char *str) { set_string_property (XA_WM_ICON_NAME, str); -#if ENABLE_FRILLS +#if ENABLE_EWMH set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); #endif } @@ -996,7 +996,7 @@ # ifndef NO_BRIGHTCOLOR pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; SET_PIXCOLOR (idx); - goto Done; + goto done; # endif } @@ -1004,7 +1004,7 @@ { /* normal colors */ pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; SET_PIXCOLOR (idx); - goto Done; + goto done; } } @@ -1034,10 +1034,11 @@ /* XSetWindowAttributes attr; */ /* Cursor cursor; */ -Done: -#ifdef OFF_FOCUS_FADING +done: + +#if OFF_FOCUS_FADING if (rs[Rs_fade]) - pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade])); + pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade]), pix_colors[Color_fade]); #endif /*TODO: handle Color_BD, scrollbar background, etc. */ @@ -1252,6 +1253,7 @@ if (width == 0 || height == 0) { XGetWindowAttributes (display->display, display->root, &wattr); + if (width == 0) width = wattr.width - szHint.base_width; if (height == 0) @@ -1555,7 +1557,7 @@ void rxvt_term::im_cb () { - int i, found, had_im; + int i; const char *p; char **s; char buf[IMBUFSIZ];