1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------*; |
2 | * File: main.c |
2 | * File: main.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
… | |
… | |
11 | * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> |
11 | * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> |
12 | * - extensive modifications |
12 | * - extensive modifications |
13 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
13 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
14 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
14 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
15 | * - extensive modifications |
15 | * - extensive modifications |
|
|
16 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
16 | * |
17 | * |
17 | * This program is free software; you can redistribute it and/or modify |
18 | * 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 |
19 | * 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 |
20 | * the Free Software Foundation; either version 2 of the License, or |
20 | * (at your option) any later version. |
21 | * (at your option) any later version. |
… | |
… | |
90 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
91 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
91 | #endif |
92 | #endif |
92 | #ifdef POINTER_BLANK |
93 | #ifdef POINTER_BLANK |
93 | pointer_ev (this, &rxvt_term::pointer_cb), |
94 | pointer_ev (this, &rxvt_term::pointer_cb), |
94 | #endif |
95 | #endif |
|
|
96 | #ifdef USE_XIM |
|
|
97 | im_ev (this, &rxvt_term::im_cb), |
|
|
98 | #endif |
95 | check_ev (this, &rxvt_term::check_cb), |
99 | check_ev (this, &rxvt_term::check_cb), |
96 | destroy_ev (this, &rxvt_term::destroy_cb), |
100 | destroy_ev (this, &rxvt_term::destroy_cb), |
97 | pty_ev (this, &rxvt_term::pty_cb), |
101 | pty_ev (this, &rxvt_term::pty_cb), |
98 | incr_ev (this, &rxvt_term::incr_cb), |
102 | incr_ev (this, &rxvt_term::incr_cb) |
99 | #ifdef USE_XIM |
|
|
100 | im_ev (this, &rxvt_term::im_cb) |
|
|
101 | #endif |
|
|
102 | { |
103 | { |
103 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
104 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
104 | } |
105 | } |
105 | |
106 | |
106 | rxvt_term::~rxvt_term () |
107 | rxvt_term::~rxvt_term () |
107 | { |
108 | { |
108 | if (cmd_fd >= 0) |
109 | if (cmd_fd >= 0) |
109 | close (cmd_fd); |
110 | close (cmd_fd); |
110 | |
111 | |
|
|
112 | #ifndef NO_SETOWNER_TTYDEV |
|
|
113 | privileged_ttydev (RESTORE); |
|
|
114 | #endif |
|
|
115 | #ifdef UTMP_SUPPORT |
|
|
116 | privileged_utmp (RESTORE); |
|
|
117 | #endif |
|
|
118 | |
|
|
119 | delete TermWin.fontset; |
|
|
120 | |
|
|
121 | if (display) |
|
|
122 | if (TermWin.parent[0]) |
|
|
123 | XDestroyWindow (display->display, TermWin.parent[0]); |
|
|
124 | |
|
|
125 | // TODO: free pixcolours, colours should become part of rxvt_display |
|
|
126 | |
|
|
127 | delete PixColors; |
|
|
128 | |
|
|
129 | displays.put (display); |
|
|
130 | |
111 | scr_release (); |
131 | scr_release (); |
112 | |
132 | |
|
|
133 | free (env_windowid); |
|
|
134 | free (env_display); |
|
|
135 | free (env_term); |
|
|
136 | free (env_colorfgbg); |
113 | free (locale); |
137 | free (locale); |
114 | free (codeset); |
138 | free (codeset); |
115 | |
139 | |
116 | #ifndef NO_SETOWNER_TTYDEV |
140 | delete envv; |
117 | privileged_ttydev (RESTORE); |
141 | delete argv; |
118 | #endif |
|
|
119 | #ifdef UTMP_SUPPORT |
|
|
120 | privileged_utmp (RESTORE); |
|
|
121 | #endif |
|
|
122 | |
|
|
123 | // TODO: free pixcolours, colours should become part of rxvt_display |
|
|
124 | |
|
|
125 | delete PixColors; |
|
|
126 | delete TermWin.fontset; |
|
|
127 | |
|
|
128 | displays.put (display); |
|
|
129 | } |
142 | } |
130 | |
143 | |
131 | void |
144 | void |
132 | rxvt_term::destroy () |
145 | rxvt_term::destroy () |
133 | { |
146 | { |
134 | if (display) |
147 | if (display) |
135 | { |
148 | { |
136 | if (TermWin.parent[0]) |
|
|
137 | XDestroyWindow (display->display, TermWin.parent[0]); |
|
|
138 | |
|
|
139 | rootwin_ev.stop (display); |
149 | rootwin_ev.stop (display); |
140 | termwin_ev.stop (display); |
150 | termwin_ev.stop (display); |
141 | vt_ev.stop (display); |
151 | vt_ev.stop (display); |
142 | |
|
|
143 | #ifdef USE_XIM |
152 | #ifdef USE_XIM |
144 | im_destroy (); |
153 | im_destroy (); |
145 | im_ev.stop (display); |
154 | im_ev.stop (display); |
146 | #endif |
155 | #endif |
147 | #ifdef HAVE_SCROLLBARS |
156 | #ifdef HAVE_SCROLLBARS |
… | |
… | |
253 | create_windows (argc, argv); |
262 | create_windows (argc, argv); |
254 | |
263 | |
255 | init_xlocale (); |
264 | init_xlocale (); |
256 | |
265 | |
257 | scr_reset (); /* initialize screen */ |
266 | scr_reset (); /* initialize screen */ |
258 | #ifdef RXVT_GRAPHICS |
|
|
259 | Gr_reset (); /* reset graphics */ |
|
|
260 | #endif |
|
|
261 | |
267 | |
262 | #if 0 |
268 | #if 0 |
263 | #ifdef DEBUG_X |
|
|
264 | XSynchronize (display->display, True); |
269 | XSynchronize (display->display, True); |
265 | #endif |
|
|
266 | #endif |
270 | #endif |
267 | |
271 | |
268 | #ifdef HAVE_SCROLLBARS |
272 | #ifdef HAVE_SCROLLBARS |
269 | if (Options & Opt_scrollBar) |
273 | if (Options & Opt_scrollBar) |
270 | resize_scrollbar (); /* create and map scrollbar */ |
274 | resize_scrollbar (); /* create and map scrollbar */ |
… | |
… | |
284 | rootwin_ev.start (display, display->root); |
288 | rootwin_ev.start (display, display->root); |
285 | |
289 | |
286 | XMapWindow (display->display, TermWin.vt); |
290 | XMapWindow (display->display, TermWin.vt); |
287 | XMapWindow (display->display, TermWin.parent[0]); |
291 | XMapWindow (display->display, TermWin.parent[0]); |
288 | |
292 | |
289 | init_env (); |
|
|
290 | init_command (cmd_argv); |
293 | init_command (cmd_argv); |
291 | |
294 | |
292 | pty_ev.start (cmd_fd, EVENT_READ); |
295 | pty_ev.start (cmd_fd, EVENT_READ); |
293 | |
296 | |
294 | check_ev.start (); |
297 | check_ev.start (); |
… | |
… | |
873 | #ifdef XPM_BACKGROUND |
876 | #ifdef XPM_BACKGROUND |
874 | xpmb = "default;"; |
877 | xpmb = "default;"; |
875 | #endif |
878 | #endif |
876 | break; |
879 | break; |
877 | } |
880 | } |
|
|
881 | |
878 | sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); |
882 | sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); |
879 | putenv (env_colorfgbg); |
|
|
880 | |
883 | |
881 | #ifndef NO_BRIGHTCOLOR |
884 | #ifndef NO_BRIGHTCOLOR |
882 | colorfgbg = DEFAULT_RSTYLE; |
885 | colorfgbg = DEFAULT_RSTYLE; |
883 | for (i = minCOLOR; i <= maxCOLOR; i++) |
886 | for (i = minCOLOR; i <= maxCOLOR; i++) |
884 | { |
887 | { |
… | |
… | |
989 | 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); |
992 | 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); |
990 | |
993 | |
991 | XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, |
994 | XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, |
992 | window_vt_y, TermWin_TotalWidth (), |
995 | window_vt_y, TermWin_TotalWidth (), |
993 | TermWin_TotalHeight ()); |
996 | TermWin_TotalHeight ()); |
994 | #ifdef RXVT_GRAPHICS |
|
|
995 | if (old_height) |
|
|
996 | Gr_Resize (old_width - szHint.base_width, |
|
|
997 | old_height - szHint.base_height); |
|
|
998 | #endif |
|
|
999 | scr_clear (); |
997 | scr_clear (); |
1000 | #ifdef XPM_BACKGROUND |
998 | #ifdef XPM_BACKGROUND |
1001 | resize_pixmap (); |
999 | resize_pixmap (); |
1002 | #endif |
1000 | #endif |
1003 | |
1001 | |
… | |
… | |
1309 | if (Input_Context) |
1307 | if (Input_Context) |
1310 | return; |
1308 | return; |
1311 | |
1309 | |
1312 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1310 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1313 | if (rs[Rs_imLocale]) |
1311 | if (rs[Rs_imLocale]) |
1314 | setlocale (LC_CTYPE, rs[Rs_imLocale]); |
1312 | SET_LOCALE (rs[Rs_imLocale]); |
1315 | #endif |
1313 | #endif |
1316 | |
1314 | |
1317 | p = rs[Rs_inputMethod]; |
1315 | p = rs[Rs_inputMethod]; |
1318 | if (p && *p) |
1316 | if (p && *p) |
1319 | { |
1317 | { |
… | |
… | |
1350 | goto done; |
1348 | goto done; |
1351 | |
1349 | |
1352 | done: |
1350 | done: |
1353 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1351 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1354 | if (rs[Rs_imLocale]) |
1352 | if (rs[Rs_imLocale]) |
1355 | setlocale (LC_CTYPE, locale); |
1353 | SET_LOCALE (locale); |
1356 | #endif |
1354 | #endif |
1357 | } |
1355 | } |
1358 | |
1356 | |
1359 | void |
1357 | void |
1360 | rxvt_term::IMSetStatusPosition () |
1358 | rxvt_term::IMSetStatusPosition () |