--- rxvt-unicode/src/main.C 2003/11/27 10:12:10 1.8 +++ rxvt-unicode/src/main.C 2003/12/17 09:00:35 1.13 @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: main.c *----------------------------------------------------------------------* - * $Id: main.C,v 1.8 2003/11/27 10:12:10 pcg Exp $ + * $Id: main.C,v 1.13 2003/12/17 09:00:35 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1992 John Bovey, University of Kent at Canterbury @@ -68,14 +68,16 @@ pointer_ev (this, &rxvt_term::pointer_cb), #endif x_ev (this, &rxvt_term::x_cb), - destroy_ev (this, &rxvt_term::destroy_cb) + destroy_ev (this, &rxvt_term::destroy_cb), + check_ev (this, &rxvt_term::check_cb), + incr_ev (this, &rxvt_term::incr_cb) { cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; } rxvt_term::~rxvt_term () { - rxvt_scr_release (this); + scr_release (); #ifndef NO_SETOWNER_TTYDEV rxvt_privileged_ttydev (this, RESTORE); @@ -103,6 +105,7 @@ void rxvt_term::destroy () { + check_ev.stop (); pty_ev.stop (); x_ev.stop (); #ifdef CURSOR_BLINK @@ -127,9 +130,9 @@ /* rxvt_init() */ /* LIBPROTO */ rxvt_t -rxvt_init(int argc, const char *const *argv) +rxvt_init (int argc, const char *const *argv) { - SET_R(new rxvt_term); + SET_R (new rxvt_term); dR; if (!R->init_vars () || !R->init (argc, argv)) @@ -150,9 +153,6 @@ #ifdef HAVE_ATEXIT atexit(rxvt_clean_exit); #else -# ifdef HAVE_ON_EXIT - on_exit(rxvt_clean_exit, NULL); /* non-ANSI exit handler */ -# endif #endif #endif @@ -160,7 +160,8 @@ sigfillset (&sa.sa_mask); sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; - sa.sa_handler = rxvt_Exit_signal; sigaction (SIGHUP , &sa, 0); //TODO, also: SIGPIPE + sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0); + sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); @@ -204,7 +205,7 @@ rxvt_init_xlocale (this); - rxvt_scr_reset (this); /* initialize screen */ + scr_reset (); /* initialize screen */ #ifdef RXVT_GRAPHICS rxvt_Gr_reset (this); /* reset graphics */ #endif @@ -239,7 +240,9 @@ x_ev.start (Xfd, EVENT_READ); pty_ev.start (cmd_fd, EVENT_READ); - flush (); + check_ev.start (); + + process_x_events (); return true; } @@ -616,26 +619,25 @@ * Tell the teletype handler what size the window is. * Called after a window size change. */ -/* EXTPROTO */ void -rxvt_tt_winsize(int fd, unsigned short col, unsigned short row, int pid) +rxvt_term::tt_winch () { - struct winsize ws; + struct winsize ws; - if (fd < 0) - return; - ws.ws_col = col; - ws.ws_row = row; - ws.ws_xpixel = ws.ws_ypixel = 0; + if (cmd_fd < 0) + return; + + ws.ws_col = TermWin.ncol; + ws.ws_row = TermWin.nrow; + ws.ws_xpixel = ws.ws_ypixel = 0; #ifndef DEBUG_SIZE - (void)ioctl(fd, TIOCSWINSZ, &ws); + (void)ioctl (cmd_fd, TIOCSWINSZ, &ws); #else - if (ioctl(fd, TIOCSWINSZ, &ws) < 0) { - D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); - } + if (ioctl (cmd_fd, TIOCSWINSZ, &ws) < 0) + D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); # ifdef SIGWINCH - else if (pid) /* force through to the command */ - kill(pid, SIGWINCH); + else if (cmd_pid) /* force through to the command */ + kill (cmd_pid, SIGWINCH); # endif #endif } @@ -940,7 +942,9 @@ /* scr_reset only works on the primary screen */ if (R->old_height) /* this is not the first time through */ curr_screen = rxvt_scr_change_screen(aR_ PRIMARY); - rxvt_scr_reset(aR); + + R->scr_reset(); + if (curr_screen >= 0) { /* this is not the first time through */ rxvt_scr_change_screen(aR_ curr_screen); rxvt_selection_check(aR_(old_ncol != R->TermWin.ncol ? 4 : 0)); @@ -1064,8 +1068,8 @@ /* INTPROTO */ void -rxvt_setPreeditArea(pR_ XRectangle * preedit_rect, XRectangle * status_rect, - XRectangle * needed_rect) +rxvt_setPreeditArea (pR_ XRectangle * preedit_rect, XRectangle * status_rect, + XRectangle * needed_rect) { int mbh, vtx = 0; @@ -1119,49 +1123,53 @@ __attribute__ ((unused)), XPointer call_data __attribute__ ((unused))) { - dR; - int i, found, had_im; - const char *p; - char **s; - char buf[IMBUFSIZ]; + dR; + int i, found, had_im; + const char *p; + char **s; + char buf[IMBUFSIZ]; - D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); - if (R->Input_Context) - return; + D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); + if (R->Input_Context) + return; + + p = R->rs[Rs_inputMethod]; + if (p && *p) + { + bool found = false; - found = had_im = 0; - p = R->rs[Rs_inputMethod]; - if (p && *p) { - had_im = 1; - s = rxvt_splitcommastring(p); - for (i = 0; s[i]; i++) { - if (*s[i]) { - STRCPY(buf, "@im="); - STRNCAT(buf, s[i], IMBUFSIZ - 5); - if ((p = XSetLocaleModifiers(buf)) != NULL && *p - && (rxvt_IM_get_IC(aR) == True)) { - found = 1; - break; + s = rxvt_splitcommastring (p); + for (i = 0; s[i]; i++) + { + if (*s[i]) + { + STRCPY (buf, "@im="); + STRNCAT (buf, s[i], IMBUFSIZ - 5); + if ((p = XSetLocaleModifiers (buf)) && *p + && rxvt_IM_get_IC (aR)) + { + found = true; + break; } } } - for (i = 0; s[i]; i++) - free(s[i]); - free(s); - } - if (found) - return; + for (i = 0; s[i]; i++) + free(s[i]); + free(s); -/* try with XMODIFIERS env. var. */ - if ((p = XSetLocaleModifiers("")) != NULL && *p) { - rxvt_IM_get_IC(aR); + if (found) return; } +/* try with XMODIFIERS env. var. */ + if ((p = XSetLocaleModifiers ("")) && *p + && rxvt_IM_get_IC (aR)) + return; + /* try with no modifiers base IF the user didn't specify an IM */ - if (!had_im && (p = XSetLocaleModifiers("@im=none")) != NULL && *p - && rxvt_IM_get_IC(aR) == True) - return; + if ((p = XSetLocaleModifiers ("@im=none")) && *p + && rxvt_IM_get_IC (aR) == True) + return; } /*