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

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.54 by pcg, Mon Mar 15 00:08:11 2004 UTC vs.
Revision 1.60 by pcg, Sun Mar 28 02:07:08 2004 UTC

182 182
183 delete TermWin.fontset; 183 delete TermWin.fontset;
184 184
185 if (display) 185 if (display)
186 { 186 {
187 selection_clear ();
188
189#ifdef MENUBAR
190 if (menubarGC) XFreeGC (display->display, menubarGC);
191#endif
192#ifdef XTERM_SCROLLBAR
193 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC);
194 if (ShadowGC) XFreeGC (display->display, ShadowGC);
195#endif
196#ifdef PLAIN_SCROLLBAR
197 if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC);
198#endif
199#ifdef NEXT_SCROLLBAR
200 if (blackGC) XFreeGC (display->display, blackGC);
201 if (whiteGC) XFreeGC (display->display, whiteGC);
202 if (grayGC) XFreeGC (display->display, grayGC);
203 if (darkGC) XFreeGC (display->display, darkGC);
204 if (stippleGC) XFreeGC (display->display, stippleGC);
205 if (dimple) XFreePixmap (display->display, dimple);
206 if (upArrow) XFreePixmap (display->display, upArrow);
207 if (downArrow) XFreePixmap (display->display, downArrow);
208 if (upArrowHi) XFreePixmap (display->display, upArrowHi);
209 if (downArrowHi) XFreePixmap (display->display, downArrowHi);
210#endif
211#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
212 if (topShadowGC) XFreeGC (display->display, topShadowGC);
213 if (botShadowGC) XFreeGC (display->display, botShadowGC);
214 if (scrollbarGC) XFreeGC (display->display, scrollbarGC);
215#endif
216 if (TermWin.gc) XFreeGC (display->display, TermWin.gc);
217
187#if defined(MENUBAR) && (MENUBAR_MAX > 1) 218#if defined(MENUBAR) && (MENUBAR_MAX > 1)
188 delete menuBar.drawable; 219 delete menuBar.drawable;
189 //if (menuBar.win) 220 //if (menuBar.win)
190 // XDestroyWindow (display->display, menuBar.win); 221 // XDestroyWindow (display->display, menuBar.win);
191#endif 222#endif
201 232
202 displays.put (display); 233 displays.put (display);
203 234
204 scr_release (); 235 scr_release ();
205 236
237 /* clear all resources */
238 for (int i = 0; i < allocated.size (); i++)
239 free (allocated[i]);
240
241 free (selection.text);
242 // TODO: manage env vars in child only(!)
206 free (env_windowid); 243 free (env_windowid);
207 free (env_display); 244 free (env_display);
208 free (env_term); 245 free (env_term);
209 free (env_colorfgbg); 246 free (env_colorfgbg);
210 free (locale); 247 free (locale);
248#if 0
211 free (codeset); 249 free (codeset);
250#endif
212 251
213 delete envv; 252 delete envv;
214 delete argv; 253 delete argv;
215} 254}
216 255
257 delete this; 296 delete this;
258} 297}
259 298
260/*----------------------------------------------------------------------*/ 299/*----------------------------------------------------------------------*/
261/* rxvt_init () */ 300/* rxvt_init () */
262/* LIBPROTO */
263rxvt_t
264rxvt_init (int argc, const char *const *argv)
265{
266 SET_R (new rxvt_term);
267
268 if (!GET_R->init_vars () || !GET_R->init (argc, argv))
269 {
270 delete GET_R;
271 SET_R (0);
272 }
273
274 return GET_R;
275}
276
277static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
278
279void
280rxvt_init_signals ()
281{
282 /* install exit handler for cleanup */
283#if 0
284#ifdef HAVE_ATEXIT
285 atexit (rxvt_clean_exit);
286#else
287#endif
288#endif
289
290 struct sigaction sa;
291
292 sigfillset (&sa.sa_mask);
293 sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
294 sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0);
295 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
296 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0);
297 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0);
298 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0);
299 sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0);
300
301 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
302 /* signal (SIGURG, SIG_DFL); */
303
304 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
305 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler);
306}
307
308bool 301bool
309rxvt_term::init (int argc, const char *const *argv) 302rxvt_term::init (int argc, const char *const *argv)
310{ 303{
304 SET_R (this);
305
306 if (!init_vars ())
307 return false;
308
311 /* 309 /*
312 * Save and then give up any super-user privileges 310 * Save and then give up any super-user privileges
313 * If we need privileges in any area then we must specifically request it. 311 * If we need privileges in any area then we must specifically request it.
314 * We should only need to be root in these cases: 312 * We should only need to be root in these cases:
315 * 1. write utmp entries on some systems 313 * 1. write utmp entries on some systems
368 pty_ev.start (cmd_fd, EVENT_READ); 366 pty_ev.start (cmd_fd, EVENT_READ);
369 367
370 check_ev.start (); 368 check_ev.start ();
371 369
372 return true; 370 return true;
371}
372
373static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
374
375void
376rxvt_init_signals ()
377{
378 /* install exit handler for cleanup */
379#if 0
380#ifdef HAVE_ATEXIT
381 atexit (rxvt_clean_exit);
382#else
383#endif
384#endif
385
386 struct sigaction sa;
387
388 sigfillset (&sa.sa_mask);
389 sa.sa_flags = SA_NOCLDSTOP | SA_RESTART;
390 sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0);
391 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
392 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0);
393 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0);
394 sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0);
395 sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0);
396
397 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
398 /* signal (SIGURG, SIG_DFL); */
399
400 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
401 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler);
373} 402}
374 403
375/* ------------------------------------------------------------------------- * 404/* ------------------------------------------------------------------------- *
376 * SIGNAL HANDLING & EXIT HANDLER * 405 * SIGNAL HANDLING & EXIT HANDLER *
377 * ------------------------------------------------------------------------- */ 406 * ------------------------------------------------------------------------- */
401RETSIGTYPE 430RETSIGTYPE
402rxvt_Exit_signal (int sig) 431rxvt_Exit_signal (int sig)
403{ 432{
404 signal (sig, SIG_DFL); 433 signal (sig, SIG_DFL);
405#ifdef DEBUG_CMD 434#ifdef DEBUG_CMD
406 rxvt_print_error ("signal %d", sig); 435 rxvt_warn ("caught signal %d, exiting.\n", sig);
407#endif 436#endif
408 rxvt_clean_exit (); 437 rxvt_clean_exit ();
409 kill (getpid (), sig); 438 kill (getpid (), sig);
410} 439}
411 440
843#ifndef SMART_WINDOW_TITLE 872#ifndef SMART_WINDOW_TITLE
844 XStoreName (display->display, TermWin.parent[0], str); 873 XStoreName (display->display, TermWin.parent[0], str);
845#else 874#else
846 char *name; 875 char *name;
847 876
848 if (XFetchName (display->display, TermWin.parent[0], &name) == 0) 877 if (!XFetchName (display->display, TermWin.parent[0], &name))
849 name = NULL; 878 name = NULL;
879
850 if (name == NULL || STRCMP (name, str)) 880 if (name == NULL || STRCMP (name, str))
851 XStoreName (display->display, TermWin.parent[0], str); 881 XStoreName (display->display, TermWin.parent[0], str);
882
852 if (name) 883 if (name)
853 XFree (name); 884 XFree (name);
854#endif 885#endif
855} 886}
856 887
857void 888void
858rxvt_term::set_iconName (const char *str) 889rxvt_term::set_icon_name (const char *str)
859{ 890{
860#ifndef SMART_WINDOW_TITLE 891#ifndef SMART_WINDOW_TITLE
861 XSetIconName (display->display, TermWin.parent[0], str); 892 XSetIconName (display->display, TermWin.parent[0], str);
862#else 893#else
863 char *name; 894 char *name;
864 895
865 if (XGetIconName (display->display, TermWin.parent[0], &name)) 896 if (!XGetIconName (display->display, TermWin.parent[0], &name))
866 name = NULL; 897 name = NULL;
898
867 if (name == NULL || STRCMP (name, str)) 899 if (name == NULL || STRCMP (name, str))
868 XSetIconName (display->display, TermWin.parent[0], str); 900 XSetIconName (display->display, TermWin.parent[0], str);
901
869 if (name) 902 if (name)
870 XFree (name); 903 XFree (name);
871#endif 904#endif
872} 905}
873 906
1011int 1044int
1012rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1045rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
1013{ 1046{
1014 if (!screen_in_out->set (display, colour)) 1047 if (!screen_in_out->set (display, colour))
1015 { 1048 {
1016 rxvt_print_error ("can't allocate colour: %s", colour); 1049 rxvt_warn ("can't get colour '%s', continuing without.\n", colour);
1017 return false; 1050 return false;
1018 } 1051 }
1019 1052
1020 return true; 1053 return true;
1021} 1054}
1388 if (preedit_attr) XFree (preedit_attr); 1421 if (preedit_attr) XFree (preedit_attr);
1389 if (status_attr) XFree (status_attr); 1422 if (status_attr) XFree (status_attr);
1390 1423
1391 if (Input_Context == NULL) 1424 if (Input_Context == NULL)
1392 { 1425 {
1393 rxvt_print_error ("failed to create input context"); 1426 rxvt_warn ("failed to create input context, continuing without XIM.\n");
1394 display->put_xim (input_method); 1427 display->put_xim (input_method);
1395 return false; 1428 return false;
1396 } 1429 }
1397 1430
1398 if (input_style & XIMPreeditArea) 1431 if (input_style & XIMPreeditArea)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines