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> |
7 | * - original version |
7 | * - original version |
… | |
… | |
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. |
… | |
… | |
43 | # include <termios.h> |
44 | # include <termios.h> |
44 | #endif |
45 | #endif |
45 | |
46 | |
46 | #include <cstring> |
47 | #include <cstring> |
47 | |
48 | |
|
|
49 | vector<rxvt_term *> rxvt_term::termlist; |
|
|
50 | |
48 | static char curlocale[128]; |
51 | static char curlocale[128]; |
49 | |
52 | |
50 | void |
53 | bool |
51 | rxvt_set_locale (const char *locale) |
54 | rxvt_set_locale (const char *locale) |
52 | { |
55 | { |
53 | if (locale && STRNCMP (locale, curlocale, 128)) |
56 | if (!locale || !STRNCMP (locale, curlocale, 128)) |
54 | { |
57 | return false; |
|
|
58 | |
55 | STRNCPY (curlocale, locale, 128); |
59 | STRNCPY (curlocale, locale, 128); |
56 | setlocale (LC_CTYPE, curlocale); |
60 | setlocale (LC_CTYPE, curlocale); |
|
|
61 | return true; |
|
|
62 | } |
|
|
63 | |
|
|
64 | #if ENABLE_COMBINING |
|
|
65 | class rxvt_composite_vec rxvt_composite; |
|
|
66 | |
|
|
67 | text_t rxvt_composite_vec::compose (unicode_t c1, unicode_t c2) |
|
|
68 | { |
|
|
69 | compose_char *cc; |
|
|
70 | |
|
|
71 | // break compose chains, as stupid readline really likes to duplicate |
|
|
72 | // composing characters for some reason near the end of a line. |
|
|
73 | cc = (*this)[c1]; |
|
|
74 | while (cc) |
57 | } |
75 | { |
|
|
76 | if (cc->c2 == c2) return c1; |
|
|
77 | cc = (*this)[cc->c1]; |
|
|
78 | } |
|
|
79 | |
|
|
80 | // check to see wether this combination already exists otherwise |
|
|
81 | for (cc = v.end (); cc-- > v.begin (); ) |
|
|
82 | { |
|
|
83 | if (cc->c1 == c1 && cc->c2 == c2) |
|
|
84 | return COMPOSE_LO + (cc - v.begin ()); |
|
|
85 | } |
|
|
86 | |
|
|
87 | // allocate a new combination |
|
|
88 | if (v.size () == COMPOSE_HI - COMPOSE_LO + 1) |
|
|
89 | { |
|
|
90 | static int seen; |
|
|
91 | |
|
|
92 | if (!seen++) |
|
|
93 | fprintf (stderr, "too many unrepresentable composite characters, try --enable-unicode3\n"); |
|
|
94 | |
|
|
95 | return REPLACEMENT_CHAR; |
|
|
96 | } |
|
|
97 | |
|
|
98 | v.push_back (compose_char (c1, c2)); |
|
|
99 | |
|
|
100 | return v.size () - 1 + COMPOSE_LO; |
58 | } |
101 | } |
|
|
102 | |
|
|
103 | int rxvt_composite_vec::expand (unicode_t c, wchar_t *r) |
|
|
104 | { |
|
|
105 | compose_char *cc = (*this)[c]; |
|
|
106 | |
|
|
107 | if (!cc) |
|
|
108 | { |
|
|
109 | if (r) *r = c; |
|
|
110 | return 1; |
|
|
111 | } |
|
|
112 | |
|
|
113 | int len = expand (cc->c1, r); |
|
|
114 | |
|
|
115 | if (r) r += len; |
|
|
116 | |
|
|
117 | if (cc->c2 != NOCHAR) |
|
|
118 | { |
|
|
119 | len++; |
|
|
120 | if (r) *r++ = cc->c2; |
|
|
121 | } |
|
|
122 | |
|
|
123 | return len; |
|
|
124 | |
|
|
125 | } |
|
|
126 | #endif |
59 | |
127 | |
60 | void * |
128 | void * |
61 | rxvt_term::operator new (size_t s) |
129 | rxvt_term::operator new (size_t s) |
62 | { |
130 | { |
63 | void *p = malloc (s); |
131 | void *p = malloc (s); |
… | |
… | |
79 | vt_ev (this, &rxvt_term::x_cb), |
147 | vt_ev (this, &rxvt_term::x_cb), |
80 | #ifdef HAVE_SCROLLBARS |
148 | #ifdef HAVE_SCROLLBARS |
81 | scrollbar_ev (this, &rxvt_term::x_cb), |
149 | scrollbar_ev (this, &rxvt_term::x_cb), |
82 | #endif |
150 | #endif |
83 | #ifdef MENUBAR |
151 | #ifdef MENUBAR |
84 | menubar_ev (this, &rxvt_term::x_cb), fixme |
152 | menubar_ev (this, &rxvt_term::x_cb), |
85 | #endif |
153 | #endif |
86 | #ifdef CURSOR_BLINK |
154 | #ifdef CURSOR_BLINK |
87 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
155 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
88 | #endif |
156 | #endif |
89 | #ifdef TEXT_BLINK |
157 | #ifdef TEXT_BLINK |
90 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
158 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
91 | #endif |
159 | #endif |
|
|
160 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
161 | cont_scroll_ev (this, &rxvt_term::cont_scroll_cb), |
|
|
162 | #endif |
|
|
163 | #ifdef SELECTION_SCROLLING |
|
|
164 | sel_scroll_ev (this, &rxvt_term::sel_scroll_cb), |
|
|
165 | #endif |
|
|
166 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
167 | slip_wheel_ev (this, &rxvt_term::slip_wheel_cb), |
|
|
168 | #endif |
92 | #ifdef POINTER_BLANK |
169 | #ifdef POINTER_BLANK |
93 | pointer_ev (this, &rxvt_term::pointer_cb), |
170 | pointer_ev (this, &rxvt_term::pointer_cb), |
|
|
171 | #endif |
|
|
172 | #ifdef USE_XIM |
|
|
173 | im_ev (this, &rxvt_term::im_cb), |
94 | #endif |
174 | #endif |
95 | check_ev (this, &rxvt_term::check_cb), |
175 | check_ev (this, &rxvt_term::check_cb), |
96 | destroy_ev (this, &rxvt_term::destroy_cb), |
176 | destroy_ev (this, &rxvt_term::destroy_cb), |
97 | pty_ev (this, &rxvt_term::pty_cb), |
177 | pty_ev (this, &rxvt_term::pty_cb), |
98 | incr_ev (this, &rxvt_term::incr_cb), |
178 | incr_ev (this, &rxvt_term::incr_cb) |
99 | #ifdef USE_XIM |
|
|
100 | im_ev (this, &rxvt_term::im_cb) |
|
|
101 | #endif |
|
|
102 | { |
179 | { |
103 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
180 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
|
|
181 | |
|
|
182 | termlist.push_back (this); |
104 | } |
183 | } |
105 | |
184 | |
106 | rxvt_term::~rxvt_term () |
185 | rxvt_term::~rxvt_term () |
107 | { |
186 | { |
|
|
187 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
|
|
188 | |
108 | if (cmd_fd >= 0) |
189 | if (cmd_fd >= 0) |
109 | close (cmd_fd); |
190 | close (cmd_fd); |
110 | |
191 | |
111 | #ifndef NO_SETOWNER_TTYDEV |
192 | #ifndef NO_SETOWNER_TTYDEV |
112 | privileged_ttydev (RESTORE); |
193 | privileged_ttydev (RESTORE); |
… | |
… | |
116 | #endif |
197 | #endif |
117 | |
198 | |
118 | delete TermWin.fontset; |
199 | delete TermWin.fontset; |
119 | |
200 | |
120 | if (display) |
201 | if (display) |
|
|
202 | { |
|
|
203 | selection_clear (); |
|
|
204 | |
|
|
205 | #ifdef MENUBAR |
|
|
206 | if (menubarGC) XFreeGC (display->display, menubarGC); |
|
|
207 | #endif |
|
|
208 | #ifdef XTERM_SCROLLBAR |
|
|
209 | if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); |
|
|
210 | if (ShadowGC) XFreeGC (display->display, ShadowGC); |
|
|
211 | #endif |
|
|
212 | #ifdef PLAIN_SCROLLBAR |
|
|
213 | if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC); |
|
|
214 | #endif |
|
|
215 | #ifdef NEXT_SCROLLBAR |
|
|
216 | if (blackGC) XFreeGC (display->display, blackGC); |
|
|
217 | if (whiteGC) XFreeGC (display->display, whiteGC); |
|
|
218 | if (grayGC) XFreeGC (display->display, grayGC); |
|
|
219 | if (darkGC) XFreeGC (display->display, darkGC); |
|
|
220 | if (stippleGC) XFreeGC (display->display, stippleGC); |
|
|
221 | if (dimple) XFreePixmap (display->display, dimple); |
|
|
222 | if (upArrow) XFreePixmap (display->display, upArrow); |
|
|
223 | if (downArrow) XFreePixmap (display->display, downArrow); |
|
|
224 | if (upArrowHi) XFreePixmap (display->display, upArrowHi); |
|
|
225 | if (downArrowHi) XFreePixmap (display->display, downArrowHi); |
|
|
226 | #endif |
|
|
227 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
|
|
228 | if (topShadowGC) XFreeGC (display->display, topShadowGC); |
|
|
229 | if (botShadowGC) XFreeGC (display->display, botShadowGC); |
|
|
230 | if (scrollbarGC) XFreeGC (display->display, scrollbarGC); |
|
|
231 | #endif |
|
|
232 | if (TermWin.gc) XFreeGC (display->display, TermWin.gc); |
|
|
233 | |
|
|
234 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
|
|
235 | delete menuBar.drawable; |
|
|
236 | //if (menuBar.win) |
|
|
237 | // XDestroyWindow (display->display, menuBar.win); |
|
|
238 | #endif |
|
|
239 | delete TermWin.drawable; |
|
|
240 | // destroy all windows |
121 | if (TermWin.parent[0]) |
241 | if (TermWin.parent[0]) |
122 | XDestroyWindow (display->display, TermWin.parent[0]); |
242 | XDestroyWindow (display->display, TermWin.parent[0]); |
|
|
243 | } |
123 | |
244 | |
124 | // TODO: free pixcolours, colours should become part of rxvt_display |
245 | // TODO: free pixcolours, colours should become part of rxvt_display |
125 | |
246 | |
126 | delete PixColors; |
247 | delete PixColorsFocused; |
|
|
248 | #ifdef OFF_FOCUS_FADING |
|
|
249 | delete PixColorsUnFocused; |
|
|
250 | #endif |
127 | |
251 | |
128 | displays.put (display); |
252 | displays.put (display); |
129 | |
253 | |
130 | scr_release (); |
254 | scr_release (); |
131 | |
255 | |
|
|
256 | /* clear all resources */ |
|
|
257 | for (int i = 0; i < allocated.size (); i++) |
|
|
258 | free (allocated[i]); |
|
|
259 | |
|
|
260 | free (selection.text); |
|
|
261 | // TODO: manage env vars in child only(!) |
132 | free (env_windowid); |
262 | free (env_windowid); |
133 | free (env_display); |
263 | free (env_display); |
134 | free (env_term); |
264 | free (env_term); |
135 | free (env_colorfgbg); |
265 | free (env_colorfgbg); |
136 | free (locale); |
266 | free (locale); |
|
|
267 | #if 0 |
137 | free (codeset); |
268 | free (codeset); |
|
|
269 | #endif |
138 | |
270 | |
139 | delete envv; |
271 | delete envv; |
140 | delete argv; |
272 | delete argv; |
141 | } |
273 | } |
142 | |
274 | |
… | |
… | |
166 | cursor_blink_ev.stop (); |
298 | cursor_blink_ev.stop (); |
167 | #endif |
299 | #endif |
168 | #ifdef TEXT_BLINK |
300 | #ifdef TEXT_BLINK |
169 | text_blink_ev.stop (); |
301 | text_blink_ev.stop (); |
170 | #endif |
302 | #endif |
|
|
303 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
304 | cont_scroll_ev.stop (); |
|
|
305 | #endif |
|
|
306 | #ifdef SELECTION_SCROLLING |
|
|
307 | sel_scroll_ev.stop (); |
|
|
308 | #endif |
171 | #ifdef POINTER_BLANK |
309 | #ifdef POINTER_BLANK |
172 | pointer_ev.stop (); |
310 | pointer_ev.stop (); |
173 | #endif |
311 | #endif |
174 | |
312 | |
175 | destroy_ev.start (0); |
313 | destroy_ev.start (0); |
… | |
… | |
183 | delete this; |
321 | delete this; |
184 | } |
322 | } |
185 | |
323 | |
186 | /*----------------------------------------------------------------------*/ |
324 | /*----------------------------------------------------------------------*/ |
187 | /* rxvt_init () */ |
325 | /* rxvt_init () */ |
188 | /* LIBPROTO */ |
|
|
189 | rxvt_t |
|
|
190 | rxvt_init (int argc, const char *const *argv) |
|
|
191 | { |
|
|
192 | SET_R (new rxvt_term); |
|
|
193 | |
|
|
194 | if (!GET_R->init_vars () || !GET_R->init (argc, argv)) |
|
|
195 | { |
|
|
196 | delete GET_R; |
|
|
197 | SET_R (0); |
|
|
198 | } |
|
|
199 | |
|
|
200 | return GET_R; |
|
|
201 | } |
|
|
202 | |
|
|
203 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
|
|
204 | |
|
|
205 | void |
|
|
206 | rxvt_init_signals () |
|
|
207 | { |
|
|
208 | /* install exit handler for cleanup */ |
|
|
209 | #if 0 |
|
|
210 | #ifdef HAVE_ATEXIT |
|
|
211 | atexit (rxvt_clean_exit); |
|
|
212 | #else |
|
|
213 | #endif |
|
|
214 | #endif |
|
|
215 | |
|
|
216 | struct sigaction sa; |
|
|
217 | |
|
|
218 | sigfillset (&sa.sa_mask); |
|
|
219 | sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; |
|
|
220 | sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0); |
|
|
221 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
|
|
222 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); |
|
|
223 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); |
|
|
224 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); |
|
|
225 | sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); |
|
|
226 | |
|
|
227 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
228 | /* signal (SIGURG, SIG_DFL); */ |
|
|
229 | |
|
|
230 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
|
|
231 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
|
|
232 | } |
|
|
233 | |
|
|
234 | bool |
326 | bool |
235 | rxvt_term::init (int argc, const char *const *argv) |
327 | rxvt_term::init (int argc, const char *const *argv) |
236 | { |
328 | { |
|
|
329 | SET_R (this); |
|
|
330 | |
|
|
331 | if (!init_vars ()) |
|
|
332 | return false; |
|
|
333 | |
237 | /* |
334 | /* |
238 | * Save and then give up any super-user privileges |
335 | * Save and then give up any super-user privileges |
239 | * If we need privileges in any area then we must specifically request it. |
336 | * If we need privileges in any area then we must specifically request it. |
240 | * We should only need to be root in these cases: |
337 | * We should only need to be root in these cases: |
241 | * 1. write utmp entries on some systems |
338 | * 1. write utmp entries on some systems |
… | |
… | |
248 | |
345 | |
249 | const char **cmd_argv = init_resources (argc, argv); |
346 | const char **cmd_argv = init_resources (argc, argv); |
250 | |
347 | |
251 | set_locale (""); |
348 | set_locale (""); |
252 | |
349 | |
253 | #if (MENUBAR_MAX) |
350 | #if MENUBAR_MAX |
254 | menubar_read (rs[Rs_menu]); |
351 | menubar_read (rs[Rs_menu]); |
255 | #endif |
352 | #endif |
256 | #ifdef HAVE_SCROLLBARS |
353 | #ifdef HAVE_SCROLLBARS |
257 | if (Options & Opt_scrollBar) |
354 | if (Options & Opt_scrollBar) |
258 | scrollBar.setIdle (); /* set existence for size calculations */ |
355 | scrollBar.setIdle (); /* set existence for size calculations */ |
… | |
… | |
261 | create_windows (argc, argv); |
358 | create_windows (argc, argv); |
262 | |
359 | |
263 | init_xlocale (); |
360 | init_xlocale (); |
264 | |
361 | |
265 | scr_reset (); /* initialize screen */ |
362 | scr_reset (); /* initialize screen */ |
266 | #ifdef RXVT_GRAPHICS |
|
|
267 | Gr_reset (); /* reset graphics */ |
|
|
268 | #endif |
|
|
269 | |
363 | |
270 | #if 1 |
364 | #if 0 |
271 | XSynchronize (display->display, True); |
365 | XSynchronize (display->display, True); |
272 | #endif |
366 | #endif |
273 | |
367 | |
274 | #ifdef HAVE_SCROLLBARS |
368 | #ifdef HAVE_SCROLLBARS |
275 | if (Options & Opt_scrollBar) |
369 | if (Options & Opt_scrollBar) |
276 | resize_scrollbar (); /* create and map scrollbar */ |
370 | resize_scrollbar (); /* create and map scrollbar */ |
277 | #endif |
371 | #endif |
278 | #if (MENUBAR_MAX) |
372 | #if (MENUBAR_MAX) |
279 | if (menubar_visible (r)) |
373 | if (menubar_visible ()) |
280 | XMapWindow (display->display, menuBar.win); |
374 | XMapWindow (display->display, menuBar.win); |
281 | #endif |
375 | #endif |
282 | #ifdef TRANSPARENT |
376 | #ifdef TRANSPARENT |
283 | if (Options & Opt_transparent) |
377 | if (Options & Opt_transparent) |
284 | { |
378 | { |
… | |
… | |
297 | pty_ev.start (cmd_fd, EVENT_READ); |
391 | pty_ev.start (cmd_fd, EVENT_READ); |
298 | |
392 | |
299 | check_ev.start (); |
393 | check_ev.start (); |
300 | |
394 | |
301 | return true; |
395 | return true; |
|
|
396 | } |
|
|
397 | |
|
|
398 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
|
|
399 | |
|
|
400 | void |
|
|
401 | rxvt_init_signals () |
|
|
402 | { |
|
|
403 | /* install exit handler for cleanup */ |
|
|
404 | #if 0 |
|
|
405 | #ifdef HAVE_ATEXIT |
|
|
406 | atexit (rxvt_clean_exit); |
|
|
407 | #else |
|
|
408 | #endif |
|
|
409 | #endif |
|
|
410 | |
|
|
411 | struct sigaction sa; |
|
|
412 | |
|
|
413 | sigfillset (&sa.sa_mask); |
|
|
414 | sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; |
|
|
415 | sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0); |
|
|
416 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
|
|
417 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); |
|
|
418 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); |
|
|
419 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); |
|
|
420 | sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); |
|
|
421 | |
|
|
422 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
423 | /* signal (SIGURG, SIG_DFL); */ |
|
|
424 | |
|
|
425 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
|
|
426 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
302 | } |
427 | } |
303 | |
428 | |
304 | /* ------------------------------------------------------------------------- * |
429 | /* ------------------------------------------------------------------------- * |
305 | * SIGNAL HANDLING & EXIT HANDLER * |
430 | * SIGNAL HANDLING & EXIT HANDLER * |
306 | * ------------------------------------------------------------------------- */ |
431 | * ------------------------------------------------------------------------- */ |
307 | /* |
432 | /* |
308 | * Catch a SIGCHLD signal and exit if the direct child has died |
433 | * Catch a SIGCHLD signal and exit if the direct child has died |
309 | */ |
434 | */ |
|
|
435 | |
|
|
436 | void rxvt_term::child_exited (int pid) |
|
|
437 | { |
|
|
438 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
|
|
439 | if (pid == (*t)->cmd_pid) |
|
|
440 | { |
|
|
441 | (*t)->destroy (); |
|
|
442 | break; |
|
|
443 | } |
|
|
444 | } |
|
|
445 | |
310 | /* ARGSUSED */ |
446 | /* ARGSUSED */ |
311 | /* EXTPROTO */ |
447 | /* EXTPROTO */ |
312 | RETSIGTYPE |
448 | RETSIGTYPE |
313 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
449 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
314 | { |
450 | { |
315 | int pid, save_errno = errno; |
451 | int pid, save_errno = errno; |
|
|
452 | |
316 | while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) |
453 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
317 | ; |
454 | rxvt_term::child_exited (pid); |
|
|
455 | |
318 | errno = save_errno; |
456 | errno = save_errno; |
319 | |
|
|
320 | #if 0 |
|
|
321 | if (pid == cmd_pid) |
|
|
322 | exit (EXIT_SUCCESS); |
|
|
323 | #endif |
|
|
324 | } |
457 | } |
325 | |
458 | |
326 | /* |
459 | /* |
327 | * Catch a fatal signal and tidy up before quitting |
460 | * Catch a fatal signal and tidy up before quitting |
328 | */ |
461 | */ |
… | |
… | |
330 | RETSIGTYPE |
463 | RETSIGTYPE |
331 | rxvt_Exit_signal (int sig) |
464 | rxvt_Exit_signal (int sig) |
332 | { |
465 | { |
333 | signal (sig, SIG_DFL); |
466 | signal (sig, SIG_DFL); |
334 | #ifdef DEBUG_CMD |
467 | #ifdef DEBUG_CMD |
335 | rxvt_print_error ("signal %d", sig); |
468 | rxvt_warn ("caught signal %d, exiting.\n", sig); |
336 | #endif |
469 | #endif |
337 | rxvt_clean_exit (); |
470 | rxvt_clean_exit (); |
338 | kill (getpid (), sig); |
471 | kill (getpid (), sig); |
339 | } |
472 | } |
340 | |
473 | |
… | |
… | |
378 | |
511 | |
379 | p = malloc (size); |
512 | p = malloc (size); |
380 | if (p) |
513 | if (p) |
381 | return p; |
514 | return p; |
382 | |
515 | |
383 | fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); |
516 | fprintf (stderr, RESNAME ": memory allocation failure. Aborting"); |
384 | rxvt_clean_exit (); |
517 | rxvt_clean_exit (); |
385 | exit (EXIT_FAILURE); |
518 | exit (EXIT_FAILURE); |
386 | /* NOTREACHED */ |
519 | /* NOTREACHED */ |
387 | } |
520 | } |
388 | |
521 | |
… | |
… | |
394 | |
527 | |
395 | p = calloc (number, size); |
528 | p = calloc (number, size); |
396 | if (p) |
529 | if (p) |
397 | return p; |
530 | return p; |
398 | |
531 | |
399 | fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); |
532 | fprintf (stderr, RESNAME ": memory allocation failure. Aborting"); |
400 | rxvt_clean_exit (); |
533 | rxvt_clean_exit (); |
401 | exit (EXIT_FAILURE); |
534 | exit (EXIT_FAILURE); |
402 | /* NOTREACHED */ |
535 | /* NOTREACHED */ |
403 | } |
536 | } |
404 | |
537 | |
… | |
… | |
413 | else |
546 | else |
414 | p = malloc (size); |
547 | p = malloc (size); |
415 | if (p) |
548 | if (p) |
416 | return p; |
549 | return p; |
417 | |
550 | |
418 | fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); |
551 | fprintf (stderr, RESNAME ": memory allocation failure. Aborting"); |
419 | rxvt_clean_exit (); |
552 | rxvt_clean_exit (); |
420 | exit (EXIT_FAILURE); |
553 | exit (EXIT_FAILURE); |
421 | /* NOTREACHED */ |
554 | /* NOTREACHED */ |
422 | } |
555 | } |
423 | |
556 | |
… | |
… | |
615 | else |
748 | else |
616 | szHint.win_gravity = SouthWestGravity; |
749 | szHint.win_gravity = SouthWestGravity; |
617 | } |
750 | } |
618 | } |
751 | } |
619 | } |
752 | } |
|
|
753 | |
620 | /* TODO: BOUNDS */ |
754 | /* TODO: BOUNDS */ |
621 | TermWin.width = TermWin.ncol * TermWin.fwidth; |
755 | TermWin.width = TermWin.ncol * TermWin.fwidth; |
622 | TermWin.height = TermWin.nrow * TermWin.fheight; |
756 | TermWin.height = TermWin.nrow * TermWin.fheight; |
623 | max_width = MAX_COLS * TermWin.fwidth; |
757 | max_width = MAX_COLS * TermWin.fwidth; |
624 | max_height = MAX_ROWS * TermWin.fheight; |
758 | max_height = MAX_ROWS * TermWin.fheight; |
625 | |
759 | |
626 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
760 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
627 | |
761 | |
628 | sb_w = mb_h = 0; |
762 | sb_w = mb_h = 0; |
629 | window_vt_x = window_vt_y = 0; |
763 | window_vt_x = window_vt_y = TermWin.int_bwidth; |
|
|
764 | |
630 | if (scrollbar_visible ()) |
765 | if (scrollbar_visible ()) |
631 | { |
766 | { |
632 | sb_w = scrollbar_TotalWidth (); |
767 | sb_w = scrollbar_TotalWidth (); |
633 | szHint.base_width += sb_w; |
768 | szHint.base_width += sb_w; |
634 | if (! (Options & Opt_scrollBar_right)) |
769 | if (!(Options & Opt_scrollBar_right)) |
635 | window_vt_x = sb_w; |
770 | window_vt_x += sb_w; |
636 | } |
771 | } |
|
|
772 | |
637 | if (menubar_visible ()) |
773 | if (menubar_visible ()) |
638 | { |
774 | { |
639 | mb_h = menuBar_TotalHeight (); |
775 | mb_h = menuBar_TotalHeight (); |
640 | szHint.base_height += mb_h; |
776 | szHint.base_height += mb_h; |
641 | window_vt_y = mb_h; |
777 | window_vt_y += mb_h; |
642 | } |
778 | } |
|
|
779 | |
643 | szHint.width_inc = TermWin.fwidth; |
780 | szHint.width_inc = TermWin.fwidth; |
644 | szHint.height_inc = TermWin.fheight; |
781 | szHint.height_inc = TermWin.fheight; |
645 | szHint.min_width = szHint.base_width + szHint.width_inc; |
782 | szHint.min_width = szHint.base_width + szHint.width_inc; |
646 | szHint.min_height = szHint.base_height + szHint.height_inc; |
783 | szHint.min_height = szHint.base_height + szHint.height_inc; |
647 | |
784 | |
… | |
… | |
653 | else |
790 | else |
654 | { |
791 | { |
655 | MIN_IT (TermWin.width, max_width); |
792 | MIN_IT (TermWin.width, max_width); |
656 | szHint.width = szHint.base_width + TermWin.width; |
793 | szHint.width = szHint.base_width + TermWin.width; |
657 | } |
794 | } |
|
|
795 | |
658 | if (height && height - szHint.base_height < max_height) |
796 | if (height && height - szHint.base_height < max_height) |
659 | { |
797 | { |
660 | szHint.height = height; |
798 | szHint.height = height; |
661 | TermWin.height = height - szHint.base_height; |
799 | TermWin.height = height - szHint.base_height; |
662 | } |
800 | } |
663 | else |
801 | else |
664 | { |
802 | { |
665 | MIN_IT (TermWin.height, max_height); |
803 | MIN_IT (TermWin.height, max_height); |
666 | szHint.height = szHint.base_height + TermWin.height; |
804 | szHint.height = szHint.base_height + TermWin.height; |
667 | } |
805 | } |
|
|
806 | |
668 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
807 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
669 | window_sb_x = szHint.width - sb_w; |
808 | window_sb_x = szHint.width - sb_w; |
670 | |
809 | |
671 | if (recalc_x) |
810 | if (recalc_x) |
672 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
811 | szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) |
… | |
… | |
717 | * init = 1 - initialize |
856 | * init = 1 - initialize |
718 | * |
857 | * |
719 | * fontname == FONT_UP - switch to bigger font |
858 | * fontname == FONT_UP - switch to bigger font |
720 | * fontname == FONT_DN - switch to smaller font |
859 | * fontname == FONT_DN - switch to smaller font |
721 | */ |
860 | */ |
722 | void |
861 | bool |
723 | rxvt_term::change_font (int init, const char *fontname) |
862 | rxvt_term::change_font (const char *fontname) |
724 | {} |
863 | { |
|
|
864 | if (fontname == FONT_UP) |
|
|
865 | { |
|
|
866 | // TODO |
|
|
867 | } |
|
|
868 | else if (fontname == FONT_DN) |
|
|
869 | { |
|
|
870 | // TODO |
|
|
871 | } |
|
|
872 | else |
|
|
873 | { |
|
|
874 | rxvt_fontset *fs = new rxvt_fontset (this); |
725 | |
875 | |
726 | void |
876 | if (fs && fs->populate (fontname ? fontname : "fixed")) |
|
|
877 | { |
|
|
878 | delete TermWin.fontset; |
|
|
879 | TermWin.fontset = fs; |
|
|
880 | TermWin.fwidth = fs->base_font ()->width; |
|
|
881 | TermWin.fheight = fs->base_font ()->height; |
|
|
882 | TermWin.fbase = fs->base_font ()->ascent; |
|
|
883 | |
|
|
884 | if (TermWin.parent[0]) |
|
|
885 | { |
|
|
886 | resize_all_windows (0, 0, 0); |
|
|
887 | scr_remap_chars (); |
|
|
888 | scr_touch (true); |
|
|
889 | } |
|
|
890 | |
|
|
891 | return true; |
|
|
892 | } |
|
|
893 | } |
|
|
894 | |
|
|
895 | return false; |
|
|
896 | } |
|
|
897 | |
|
|
898 | bool |
727 | rxvt_term::font_up_down (int n, int direction) |
899 | rxvt_term::font_up_down (int n, int direction) |
728 | {} |
900 | { |
|
|
901 | return false; |
|
|
902 | } |
729 | |
903 | |
730 | /*----------------------------------------------------------------------*/ |
904 | /*----------------------------------------------------------------------*/ |
731 | /*----------------------------------------------------------------------*/ |
905 | /*----------------------------------------------------------------------*/ |
732 | /* xterm sequences - title, iconName, color (exptl) */ |
906 | /* xterm sequences - title, iconName, color (exptl) */ |
733 | void |
907 | void |
734 | rxvt_term::set_title (const char *str) |
908 | rxvt_term::set_title (const char *str) |
735 | { |
909 | { |
736 | #ifndef SMART_WINDOW_TITLE |
910 | #ifdef SMART_WINDOW_TITLE |
737 | XStoreName (display->display, TermWin.parent[0], str); |
911 | char *name; |
738 | #else |
|
|
739 | char *name; |
|
|
740 | |
912 | |
741 | if (XFetchName (display->display, TermWin.parent[0], &name) == 0) |
913 | if (!XFetchName (display->display, TermWin.parent[0], &name)) |
742 | name = NULL; |
914 | name = NULL; |
|
|
915 | |
743 | if (name == NULL || STRCMP (name, str)) |
916 | if (name == NULL || STRCMP (name, str)) |
|
|
917 | #endif |
744 | XStoreName (display->display, TermWin.parent[0], str); |
918 | XStoreName (display->display, TermWin.parent[0], str); |
|
|
919 | |
|
|
920 | #ifdef SMART_WINDOW_TITLE |
745 | if (name) |
921 | if (name) |
746 | XFree (name); |
922 | XFree (name); |
747 | #endif |
923 | #endif |
748 | } |
924 | } |
749 | |
925 | |
750 | void |
926 | void |
751 | rxvt_term::set_iconName (const char *str) |
927 | rxvt_term::set_icon_name (const char *str) |
752 | { |
928 | { |
753 | #ifndef SMART_WINDOW_TITLE |
929 | #ifdef SMART_WINDOW_TITLE |
754 | XSetIconName (display->display, TermWin.parent[0], str); |
930 | char *name; |
755 | #else |
|
|
756 | char *name; |
|
|
757 | |
931 | |
758 | if (XGetIconName (display->display, TermWin.parent[0], &name)) |
932 | if (!XGetIconName (display->display, TermWin.parent[0], &name)) |
759 | name = NULL; |
933 | name = NULL; |
|
|
934 | |
760 | if (name == NULL || STRCMP (name, str)) |
935 | if (name == NULL || STRCMP (name, str)) |
|
|
936 | #endif |
761 | XSetIconName (display->display, TermWin.parent[0], str); |
937 | XSetIconName (display->display, TermWin.parent[0], str); |
|
|
938 | |
|
|
939 | #ifdef SMART_WINDOW_TITLE |
762 | if (name) |
940 | if (name) |
763 | XFree (name); |
941 | XFree (name); |
764 | #endif |
942 | #endif |
765 | } |
943 | } |
766 | |
944 | |
767 | #ifdef XTERM_COLOR_CHANGE |
945 | #ifdef XTERM_COLOR_CHANGE |
768 | void |
946 | void |
769 | rxvt_term::set_window_color (int idx, const char *color) |
947 | rxvt_term::set_window_color (int idx, const char *color) |
770 | { |
948 | { |
771 | rxvt_color xcol; |
949 | rxvt_color xcol; |
772 | int i; |
950 | int i; |
773 | |
951 | |
774 | if (color == NULL || *color == '\0') |
952 | if (color == NULL || *color == '\0') |
775 | return; |
953 | return; |
776 | |
954 | |
777 | /* handle color aliases */ |
955 | /* handle color aliases */ |
… | |
… | |
780 | i = atoi (color); |
958 | i = atoi (color); |
781 | if (i >= 8 && i <= 15) |
959 | if (i >= 8 && i <= 15) |
782 | { /* bright colors */ |
960 | { /* bright colors */ |
783 | i -= 8; |
961 | i -= 8; |
784 | # ifndef NO_BRIGHTCOLOR |
962 | # ifndef NO_BRIGHTCOLOR |
785 | PixColors[idx] = PixColors[minBrightCOLOR + i]; |
963 | PixColorsFocused[idx] = PixColorsFocused[minBrightCOLOR + i]; |
786 | SET_PIXCOLOR (idx); |
964 | SET_PIXCOLOR (idx); |
787 | goto Done; |
965 | goto Done; |
788 | # endif |
966 | # endif |
789 | |
967 | |
790 | } |
968 | } |
791 | if (i >= 0 && i <= 7) |
969 | if (i >= 0 && i <= 7) |
792 | { /* normal colors */ |
970 | { /* normal colors */ |
793 | PixColors[idx] = PixColors[minCOLOR + i]; |
971 | PixColorsFocused[idx] = PixColorsFocused[minCOLOR + i]; |
794 | SET_PIXCOLOR (idx); |
972 | SET_PIXCOLOR (idx); |
795 | goto Done; |
973 | goto Done; |
796 | } |
974 | } |
797 | } |
975 | } |
|
|
976 | |
798 | if (!rXParseAllocColor (& xcol, color)) |
977 | if (!rXParseAllocColor (& xcol, color)) |
799 | return; |
978 | return; |
|
|
979 | |
800 | /* XStoreColor (display->display, XCMAP, XColor*); */ |
980 | /* XStoreColor (display->display, XCMAP, XColor*); */ |
801 | |
981 | |
802 | /* |
982 | /* |
803 | * FIXME: should free colors here, but no idea how to do it so instead, |
983 | * FIXME: should free colors here, but no idea how to do it so instead, |
804 | * so just keep gobbling up the colormap |
984 | * so just keep gobbling up the colormap |
… | |
… | |
813 | XFreeColors (display->display, XCMAP, (PixColors + idx), 1, |
993 | XFreeColors (display->display, XCMAP, (PixColors + idx), 1, |
814 | DisplayPlanes (display->display, display->screen)); |
994 | DisplayPlanes (display->display, display->screen)); |
815 | } |
995 | } |
816 | # endif |
996 | # endif |
817 | |
997 | |
818 | PixColors[idx] = xcol; |
998 | PixColorsFocused[idx] = xcol; |
819 | SET_PIXCOLOR (idx); |
999 | SET_PIXCOLOR (idx); |
820 | |
1000 | |
821 | /* XSetWindowAttributes attr; */ |
1001 | /* XSetWindowAttributes attr; */ |
822 | /* Cursor cursor; */ |
1002 | /* Cursor cursor; */ |
823 | Done: |
1003 | Done: |
|
|
1004 | #ifdef OFF_FOCUS_FADING |
|
|
1005 | PixColorsUnFocused[idx] = PixColorsFocused[idx].fade (display, atoi (rs[Rs_fade])); |
|
|
1006 | #endif |
824 | if (idx == Color_bg && ! (Options & Opt_transparent)) |
1007 | if (idx == Color_bg && ! (Options & Opt_transparent)) |
825 | XSetWindowBackground (display->display, TermWin.vt, |
1008 | XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); |
826 | PixColors[Color_bg]); |
|
|
827 | |
1009 | |
828 | /* handle Color_BD, scrollbar background, etc. */ |
1010 | /* handle Color_BD, scrollbar background, etc. */ |
829 | |
1011 | |
830 | set_colorfgbg (); |
1012 | set_colorfgbg (); |
831 | recolour_cursor (); |
1013 | recolour_cursor (); |
832 | /* the only reasonable way to enforce a clean update */ |
1014 | scr_touch (true); |
833 | scr_poweron (); |
|
|
834 | } |
1015 | } |
835 | |
1016 | |
836 | #else |
1017 | #else |
837 | # define set_window_color (idx,color) ((void)0) |
1018 | # define set_window_color (idx,color) ((void)0) |
838 | #endif /* XTERM_COLOR_CHANGE */ |
1019 | #endif /* XTERM_COLOR_CHANGE */ |
839 | |
1020 | |
840 | void |
1021 | void |
841 | rxvt_term::recolour_cursor () |
1022 | rxvt_term::recolour_cursor () |
842 | { |
1023 | { |
843 | #if TODO |
|
|
844 | rxvt_color xcol[2]; |
1024 | XColor xcol[2]; |
845 | |
1025 | |
846 | xcol[0] = PixColors[Color_pointer]; |
1026 | xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) ? PixColorsFocused[Color_pointer_fg] : PixColorsFocused[Color_fg]; |
847 | xcol[1] = PixColors[Color_bg]; |
1027 | xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) ? PixColorsFocused[Color_pointer_bg] : PixColorsFocused[Color_bg]; |
848 | XQueryColors (display->display, XCMAP, xcol, 2); |
1028 | XQueryColors (display->display, XCMAP, xcol, 2); |
849 | XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); |
1029 | XRecolorCursor (display->display, TermWin_cursor, xcol + 0, xcol + 1); |
850 | #endif |
|
|
851 | } |
1030 | } |
852 | |
1031 | |
853 | /*----------------------------------------------------------------------*/ |
1032 | /*----------------------------------------------------------------------*/ |
854 | /* |
1033 | /* |
855 | * find if fg/bg matches any of the normal (low-intensity) colors |
1034 | * find if fg/bg matches any of the normal (low-intensity) colors |
… | |
… | |
904 | int |
1083 | int |
905 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
1084 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
906 | { |
1085 | { |
907 | if (!screen_in_out->set (display, colour)) |
1086 | if (!screen_in_out->set (display, colour)) |
908 | { |
1087 | { |
909 | rxvt_print_error ("can't allocate colour: %s", colour); |
1088 | rxvt_warn ("can't get colour '%s', continuing without.\n", colour); |
910 | return false; |
1089 | return false; |
911 | } |
1090 | } |
912 | |
1091 | |
913 | return true; |
1092 | return true; |
914 | } |
1093 | } |
… | |
… | |
925 | int old_width = szHint.width, old_height = szHint.height; |
1104 | int old_width = szHint.width, old_height = szHint.height; |
926 | #endif |
1105 | #endif |
927 | |
1106 | |
928 | window_calc (width, height); |
1107 | window_calc (width, height); |
929 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
1108 | XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); |
|
|
1109 | |
930 | if (!ignoreparent) |
1110 | if (!ignoreparent) |
931 | { |
1111 | { |
932 | #ifdef SMART_RESIZE |
1112 | #ifdef SMART_RESIZE |
933 | /* |
1113 | /* |
934 | * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> |
1114 | * resize by Marius Gedminas <marius.gedminas@uosis.mif.vu.lt> |
… | |
… | |
969 | dy /= 2; |
1149 | dy /= 2; |
970 | |
1150 | |
971 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
1151 | XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, |
972 | szHint.width, szHint.height); |
1152 | szHint.width, szHint.height); |
973 | #else |
1153 | #else |
974 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, |
1154 | XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); |
975 | szHint.height); |
|
|
976 | #endif |
1155 | #endif |
977 | |
|
|
978 | } |
1156 | } |
979 | |
1157 | |
980 | fix_screen = (TermWin.ncol != prev_ncol |
1158 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
981 | || TermWin.nrow != prev_nrow); |
|
|
982 | |
1159 | |
983 | if (fix_screen || width != old_width || height != old_height) |
1160 | if (fix_screen || width != old_width || height != old_height) |
984 | { |
1161 | { |
985 | if (scrollbar_visible ()) |
1162 | if (scrollbar_visible ()) |
986 | { |
1163 | { |
987 | XMoveResizeWindow (display->display, scrollBar.win, window_sb_x, |
1164 | XMoveResizeWindow (display->display, scrollBar.win, |
|
|
1165 | window_sb_x, 0, |
988 | 0, scrollbar_TotalWidth (), szHint.height); |
1166 | scrollbar_TotalWidth (), szHint.height); |
989 | resize_scrollbar (); |
1167 | resize_scrollbar (); |
990 | } |
1168 | } |
991 | |
1169 | |
992 | if (menubar_visible ()) |
1170 | if (menubar_visible ()) |
993 | XMoveResizeWindow (display->display, menuBar.win, window_vt_x, |
1171 | XMoveResizeWindow (display->display, menuBar.win, |
|
|
1172 | window_vt_x, 0, |
994 | 0, TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1173 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
995 | |
1174 | |
996 | XMoveResizeWindow (display->display, TermWin.vt, window_vt_x, |
1175 | XMoveResizeWindow (display->display, TermWin.vt, |
997 | window_vt_y, TermWin_TotalWidth (), |
1176 | window_vt_x, window_vt_y, |
998 | TermWin_TotalHeight ()); |
1177 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
999 | #ifdef RXVT_GRAPHICS |
|
|
1000 | if (old_height) |
|
|
1001 | Gr_Resize (old_width - szHint.base_width, |
|
|
1002 | old_height - szHint.base_height); |
|
|
1003 | #endif |
|
|
1004 | scr_clear (); |
1178 | scr_clear (); |
1005 | #ifdef XPM_BACKGROUND |
1179 | #ifdef XPM_BACKGROUND |
1006 | resize_pixmap (); |
1180 | resize_pixmap (); |
1007 | #endif |
1181 | #endif |
1008 | |
|
|
1009 | } |
1182 | } |
1010 | |
1183 | |
1011 | if (fix_screen || old_height == 0) |
1184 | if (fix_screen || old_height == 0) |
1012 | { |
1185 | { |
1013 | int curr_screen = -1; |
1186 | int curr_screen = -1; |
… | |
… | |
1286 | if (preedit_attr) XFree (preedit_attr); |
1459 | if (preedit_attr) XFree (preedit_attr); |
1287 | if (status_attr) XFree (status_attr); |
1460 | if (status_attr) XFree (status_attr); |
1288 | |
1461 | |
1289 | if (Input_Context == NULL) |
1462 | if (Input_Context == NULL) |
1290 | { |
1463 | { |
1291 | rxvt_print_error ("failed to create input context"); |
1464 | rxvt_warn ("failed to create input context, continuing without XIM.\n"); |
1292 | display->put_xim (input_method); |
1465 | display->put_xim (input_method); |
1293 | return false; |
1466 | return false; |
1294 | } |
1467 | } |
1295 | |
1468 | |
1296 | if (input_style & XIMPreeditArea) |
1469 | if (input_style & XIMPreeditArea) |
… | |
… | |
1314 | if (Input_Context) |
1487 | if (Input_Context) |
1315 | return; |
1488 | return; |
1316 | |
1489 | |
1317 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1490 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1318 | if (rs[Rs_imLocale]) |
1491 | if (rs[Rs_imLocale]) |
1319 | setlocale (LC_CTYPE, rs[Rs_imLocale]); |
1492 | SET_LOCALE (rs[Rs_imLocale]); |
1320 | #endif |
1493 | #endif |
1321 | |
1494 | |
1322 | p = rs[Rs_inputMethod]; |
1495 | p = rs[Rs_inputMethod]; |
1323 | if (p && *p) |
1496 | if (p && *p) |
1324 | { |
1497 | { |
… | |
… | |
1355 | goto done; |
1528 | goto done; |
1356 | |
1529 | |
1357 | done: |
1530 | done: |
1358 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1531 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1359 | if (rs[Rs_imLocale]) |
1532 | if (rs[Rs_imLocale]) |
1360 | setlocale (LC_CTYPE, locale); |
1533 | SET_LOCALE (locale); |
1361 | #endif |
1534 | #endif |
1362 | } |
1535 | } |
1363 | |
1536 | |
1364 | void |
1537 | void |
1365 | rxvt_term::IMSetStatusPosition () |
1538 | rxvt_term::IMSetStatusPosition () |