1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: main.c |
2 | * File: main.c |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * $Id: main.C,v 1.3 2003/11/25 11:52:42 pcg Exp $ |
4 | * $Id: main.C,v 1.11 2003/12/08 23:14:40 pcg Exp $ |
5 | * |
5 | * |
6 | * All portions of code are copyright by their respective author/s. |
6 | * All portions of code are copyright by their respective author/s. |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
8 | * - original version |
8 | * - original version |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
9 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
… | |
… | |
42 | |
42 | |
43 | #ifdef HAVE_TERMIOS_H |
43 | #ifdef HAVE_TERMIOS_H |
44 | # include <termios.h> |
44 | # include <termios.h> |
45 | #endif |
45 | #endif |
46 | |
46 | |
47 | rxvt_term::rxvt_term() |
|
|
48 | : pty_ev(this, &rxvt_term::pty_cb), |
|
|
49 | x_ev (this, &rxvt_term::x_cb) |
|
|
50 | { |
|
|
51 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
|
|
52 | } |
|
|
53 | |
|
|
54 | void * |
47 | void * |
55 | rxvt_term::operator new (size_t s) |
48 | rxvt_term::operator new (size_t s) |
56 | { |
49 | { |
57 | void *p = malloc (s); |
50 | void *p = malloc (s); |
58 | |
51 | |
… | |
… | |
62 | |
55 | |
63 | void |
56 | void |
64 | rxvt_term::operator delete (void *p, size_t s) |
57 | rxvt_term::operator delete (void *p, size_t s) |
65 | { |
58 | { |
66 | free (p); |
59 | free (p); |
|
|
60 | } |
|
|
61 | |
|
|
62 | rxvt_term::rxvt_term () |
|
|
63 | : pty_ev (this, &rxvt_term::pty_cb), |
|
|
64 | #ifdef CURSOR_BLINK |
|
|
65 | blink_ev (this, &rxvt_term::blink_cb), |
|
|
66 | #endif |
|
|
67 | #ifdef POINTER_BLANK |
|
|
68 | pointer_ev (this, &rxvt_term::pointer_cb), |
|
|
69 | #endif |
|
|
70 | x_ev (this, &rxvt_term::x_cb), |
|
|
71 | destroy_ev (this, &rxvt_term::destroy_cb), |
|
|
72 | check_ev (this, &rxvt_term::check_cb) |
|
|
73 | { |
|
|
74 | cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; |
|
|
75 | } |
|
|
76 | |
|
|
77 | rxvt_term::~rxvt_term () |
|
|
78 | { |
|
|
79 | rxvt_scr_release (this); |
|
|
80 | |
|
|
81 | #ifndef NO_SETOWNER_TTYDEV |
|
|
82 | rxvt_privileged_ttydev (this, RESTORE); |
|
|
83 | #endif |
|
|
84 | #ifdef UTMP_SUPPORT |
|
|
85 | rxvt_privileged_utmp (this, RESTORE); |
|
|
86 | #endif |
|
|
87 | #ifdef USE_XIM |
|
|
88 | if (Input_Context != NULL) |
|
|
89 | { |
|
|
90 | XDestroyIC (Input_Context); |
|
|
91 | Input_Context = NULL; |
|
|
92 | } |
|
|
93 | #endif |
|
|
94 | |
|
|
95 | if (cmd_fd >= 0) |
|
|
96 | close (cmd_fd); |
|
|
97 | |
|
|
98 | if (Xfd >= 0) |
|
|
99 | XCloseDisplay (Xdisplay); |
|
|
100 | |
|
|
101 | delete PixColors; |
|
|
102 | } |
|
|
103 | |
|
|
104 | void |
|
|
105 | rxvt_term::destroy () |
|
|
106 | { |
|
|
107 | check_ev.stop (); |
|
|
108 | pty_ev.stop (); |
|
|
109 | x_ev.stop (); |
|
|
110 | #ifdef CURSOR_BLINK |
|
|
111 | blink_ev.stop (); |
|
|
112 | #endif |
|
|
113 | #ifdef POINTER_BLANK |
|
|
114 | pointer_ev.stop (); |
|
|
115 | #endif |
|
|
116 | |
|
|
117 | destroy_ev.start (0); |
|
|
118 | } |
|
|
119 | |
|
|
120 | void |
|
|
121 | rxvt_term::destroy_cb (time_watcher &w) |
|
|
122 | { |
|
|
123 | SET_R (this); |
|
|
124 | |
|
|
125 | delete this; |
67 | } |
126 | } |
68 | |
127 | |
69 | /*----------------------------------------------------------------------*/ |
128 | /*----------------------------------------------------------------------*/ |
70 | /* rxvt_init() */ |
129 | /* rxvt_init() */ |
71 | /* LIBPROTO */ |
130 | /* LIBPROTO */ |
72 | rxvt_t |
131 | rxvt_t |
73 | rxvt_init(int argc, const char *const *argv) |
132 | rxvt_init (int argc, const char *const *argv) |
74 | { |
133 | { |
75 | const char **cmd_argv; |
|
|
76 | |
|
|
77 | SET_R(new rxvt_term); |
134 | SET_R (new rxvt_term); |
78 | dR; |
135 | dR; |
79 | |
136 | |
80 | if (rxvt_init_vars(aR) < 0) |
137 | if (!R->init_vars () || !R->init (argc, argv)) |
81 | { |
138 | { |
82 | free(R); |
139 | delete R; |
83 | return NULL; |
140 | return NULL; |
84 | } |
141 | } |
85 | |
142 | |
86 | /* |
143 | return R; |
|
|
144 | } |
|
|
145 | |
|
|
146 | /* EXTPROTO */ |
|
|
147 | void |
|
|
148 | rxvt_init_signals () |
|
|
149 | { |
|
|
150 | /* install exit handler for cleanup */ |
|
|
151 | #if 0 |
|
|
152 | #ifdef HAVE_ATEXIT |
|
|
153 | atexit(rxvt_clean_exit); |
|
|
154 | #else |
|
|
155 | #endif |
|
|
156 | #endif |
|
|
157 | |
|
|
158 | struct sigaction sa; |
|
|
159 | |
|
|
160 | sigfillset (&sa.sa_mask); |
|
|
161 | sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; |
|
|
162 | sa.sa_handler = SIG_IGN; sigaction (SIGHUP , &sa, 0); |
|
|
163 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
|
|
164 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGINT , &sa, 0); |
|
|
165 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGQUIT, &sa, 0); |
|
|
166 | sa.sa_handler = rxvt_Exit_signal; sigaction (SIGTERM, &sa, 0); |
|
|
167 | sa.sa_handler = rxvt_Child_signal; sigaction (SIGCHLD, &sa, 0); |
|
|
168 | |
|
|
169 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
|
|
170 | /* signal (SIGURG, SIG_DFL); */ |
|
|
171 | |
|
|
172 | XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
|
|
173 | //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); |
|
|
174 | } |
|
|
175 | |
|
|
176 | bool |
|
|
177 | rxvt_term::init (int argc, const char *const *argv) |
|
|
178 | { |
|
|
179 | dR;//TODO (scrollbar, setidle) |
|
|
180 | |
|
|
181 | /* |
87 | * Save and then give up any super-user privileges |
182 | * Save and then give up any super-user privileges |
88 | * If we need privileges in any area then we must specifically request it. |
183 | * If we need privileges in any area then we must specifically request it. |
89 | * We should only need to be root in these cases: |
184 | * We should only need to be root in these cases: |
90 | * 1. write utmp entries on some systems |
185 | * 1. write utmp entries on some systems |
91 | * 2. chown tty on some systems |
186 | * 2. chown tty on some systems |
92 | */ |
187 | */ |
93 | rxvt_privileges(aR_ SAVE); |
188 | rxvt_privileges (this, SAVE); |
94 | rxvt_privileges(aR_ IGNORE); |
189 | rxvt_privileges (this, IGNORE); |
95 | |
190 | |
96 | rxvt_init_secondary(aR); |
191 | rxvt_init_secondary (this); |
97 | |
192 | |
98 | cmd_argv = rxvt_init_resources(aR_ argc, argv); |
193 | const char **cmd_argv = rxvt_init_resources (this, argc, argv); |
99 | |
|
|
100 | R->x_ev.start (ConnectionNumber (R->Xdisplay), EVENT_READ); |
|
|
101 | |
194 | |
102 | #if (MENUBAR_MAX) |
195 | #if (MENUBAR_MAX) |
103 | rxvt_menubar_read(aR_ R->rs[Rs_menu]); |
196 | rxvt_menubar_read (this, rs[Rs_menu]); |
104 | #endif |
197 | #endif |
105 | #ifdef HAVE_SCROLLBARS |
198 | #ifdef HAVE_SCROLLBARS |
106 | if (R->Options & Opt_scrollBar) |
199 | if (Options & Opt_scrollBar) |
107 | scrollbar_setIdle(); /* set existence for size calculations */ |
200 | scrollbar_setIdle (); /* set existence for size calculations */ |
108 | #endif |
201 | #endif |
109 | |
202 | |
110 | rxvt_Create_Windows(aR_ argc, argv); |
203 | rxvt_Create_Windows (this, argc, argv); |
111 | |
204 | |
112 | rxvt_init_xlocale(aR); |
205 | rxvt_init_xlocale (this); |
113 | |
206 | |
114 | rxvt_scr_reset(aR); /* initialize screen */ |
207 | rxvt_scr_reset (this); /* initialize screen */ |
115 | #ifdef RXVT_GRAPHICS |
208 | #ifdef RXVT_GRAPHICS |
116 | rxvt_Gr_reset(aR); /* reset graphics */ |
209 | rxvt_Gr_reset (this); /* reset graphics */ |
117 | #endif |
210 | #endif |
118 | |
211 | |
119 | #if 0 |
212 | #if 0 |
120 | #ifdef DEBUG_X |
213 | #ifdef DEBUG_X |
121 | XSynchronize(R->Xdisplay, True); |
214 | XSynchronize(Xdisplay, True); |
122 | XSetErrorHandler((XErrorHandler) abort); |
|
|
123 | #else |
|
|
124 | XSetErrorHandler((XErrorHandler) rxvt_xerror_handler); |
|
|
125 | #endif |
215 | #endif |
126 | #endif |
216 | #endif |
127 | |
217 | |
128 | #ifdef HAVE_SCROLLBARS |
218 | #ifdef HAVE_SCROLLBARS |
129 | if (R->Options & Opt_scrollBar) |
219 | if (Options & Opt_scrollBar) |
130 | rxvt_Resize_scrollBar(aR); /* create and map scrollbar */ |
220 | rxvt_Resize_scrollBar (this); /* create and map scrollbar */ |
131 | #endif |
221 | #endif |
132 | #if (MENUBAR_MAX) |
222 | #if (MENUBAR_MAX) |
133 | if (menubar_visible(r)) |
223 | if (menubar_visible(r)) |
134 | XMapWindow(R->Xdisplay, R->menuBar.win); |
224 | XMapWindow (Xdisplay, menuBar.win); |
135 | #endif |
225 | #endif |
136 | #ifdef TRANSPARENT |
226 | #ifdef TRANSPARENT |
137 | if (R->Options & Opt_transparent) |
227 | if (Options & Opt_transparent) |
138 | { |
228 | { |
139 | XSelectInput(R->Xdisplay, Xroot, PropertyChangeMask); |
229 | XSelectInput (Xdisplay, Xroot, PropertyChangeMask); |
140 | rxvt_check_our_parents(aR); |
230 | rxvt_check_our_parents (this); |
141 | } |
231 | } |
142 | #endif |
232 | #endif |
143 | XMapWindow(R->Xdisplay, R->TermWin.vt); |
233 | XMapWindow (Xdisplay, TermWin.vt); |
144 | XMapWindow(R->Xdisplay, R->TermWin.parent[0]); |
234 | XMapWindow (Xdisplay, TermWin.parent[0]); |
145 | |
235 | |
146 | rxvt_init_env(aR); |
236 | rxvt_init_env (this); |
147 | rxvt_init_command(aR_ cmd_argv); |
237 | rxvt_init_command (this, cmd_argv); |
148 | |
238 | |
|
|
239 | x_ev.start (Xfd, EVENT_READ); |
149 | R->pty_ev.start (R->cmd_fd, EVENT_READ); |
240 | pty_ev.start (cmd_fd, EVENT_READ); |
150 | |
241 | |
151 | return R; |
242 | check_ev.start (); |
|
|
243 | |
|
|
244 | process_x_events (); |
|
|
245 | |
|
|
246 | return true; |
152 | } |
247 | } |
153 | |
248 | |
154 | /* ------------------------------------------------------------------------- * |
249 | /* ------------------------------------------------------------------------- * |
155 | * SIGNAL HANDLING & EXIT HANDLER * |
250 | * SIGNAL HANDLING & EXIT HANDLER * |
156 | * ------------------------------------------------------------------------- */ |
251 | * ------------------------------------------------------------------------- */ |
… | |
… | |
160 | /* ARGSUSED */ |
255 | /* ARGSUSED */ |
161 | /* EXTPROTO */ |
256 | /* EXTPROTO */ |
162 | RETSIGTYPE |
257 | RETSIGTYPE |
163 | rxvt_Child_signal(int sig __attribute__ ((unused))) |
258 | rxvt_Child_signal(int sig __attribute__ ((unused))) |
164 | { |
259 | { |
165 | dR; |
|
|
166 | int pid, save_errno = errno; |
260 | int pid, save_errno = errno; |
167 | |
|
|
168 | do { |
|
|
169 | errno = 0; |
|
|
170 | } while ((pid = waitpid(-1, NULL, WNOHANG)) == -1 && errno == EINTR); |
261 | while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) |
|
|
262 | ; |
|
|
263 | errno = save_errno; |
171 | |
264 | |
|
|
265 | #if 0 |
172 | if (pid == R->cmd_pid) |
266 | if (pid == R->cmd_pid) |
173 | exit(EXIT_SUCCESS); |
267 | exit (EXIT_SUCCESS); |
174 | |
268 | #endif |
175 | errno = save_errno; |
|
|
176 | signal(SIGCHLD, rxvt_Child_signal); |
|
|
177 | } |
269 | } |
178 | |
270 | |
179 | /* |
271 | /* |
180 | * Catch a fatal signal and tidy up before quitting |
272 | * Catch a fatal signal and tidy up before quitting |
181 | */ |
273 | */ |
… | |
… | |
195 | /* INTPROTO */ |
287 | /* INTPROTO */ |
196 | int |
288 | int |
197 | rxvt_xerror_handler(const Display * display |
289 | rxvt_xerror_handler(const Display * display |
198 | __attribute__ ((unused)), const XErrorEvent * event) |
290 | __attribute__ ((unused)), const XErrorEvent * event) |
199 | { |
291 | { |
200 | dR; |
292 | dR; |
201 | |
293 | |
202 | if (R->allowedxerror == -1) { |
294 | if (R->allowedxerror == -1) |
203 | R->allowedxerror = event->error_code; |
295 | R->allowedxerror = event->error_code; |
204 | return 0; /* ignored anyway */ |
296 | else |
205 | } |
297 | { |
206 | rxvt_print_error("XError: Request: %d . %d, Error: %d", |
298 | rxvt_print_error("XError: Request: %d . %d, Error: %d", |
207 | event->request_code, event->minor_code, |
299 | event->request_code, event->minor_code, |
208 | event->error_code); |
300 | event->error_code); |
209 | /* XXX: probably should call rxvt_clean_exit() bypassing X routines */ |
301 | |
210 | exit(EXIT_FAILURE); |
302 | R->destroy (); |
211 | /* NOTREACHED */ |
303 | } |
|
|
304 | |
|
|
305 | return 0; |
212 | } |
306 | } |
213 | |
307 | |
214 | /*----------------------------------------------------------------------*/ |
308 | /*----------------------------------------------------------------------*/ |
215 | /* |
309 | /* |
216 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
310 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
217 | * TODO: if debugging, this should free up any known resources if we can |
311 | * TODO: if debugging, this should free up any known resources if we can |
218 | */ |
312 | */ |
219 | /* EXTPROTO */ |
313 | /* EXTPROTO */ |
220 | void |
314 | void |
221 | rxvt_clean_exit(void) |
315 | rxvt_clean_exit () |
222 | { |
316 | { |
223 | dR; |
317 | dR; |
224 | |
318 | |
225 | #ifdef DEBUG_SCREEN |
319 | R->destroy (); |
226 | rxvt_scr_release(aR); |
|
|
227 | #endif |
|
|
228 | #ifndef NO_SETOWNER_TTYDEV |
|
|
229 | rxvt_privileged_ttydev(aR_ RESTORE); |
|
|
230 | #endif |
|
|
231 | #ifdef UTMP_SUPPORT |
|
|
232 | rxvt_privileged_utmp(aR_ RESTORE); |
|
|
233 | #endif |
|
|
234 | #ifdef USE_XIM |
|
|
235 | if (R->Input_Context != NULL) { |
|
|
236 | XDestroyIC(R->Input_Context); |
|
|
237 | R->Input_Context = NULL; |
|
|
238 | } |
|
|
239 | #endif |
|
|
240 | } |
320 | } |
241 | |
321 | |
242 | /* ------------------------------------------------------------------------- * |
322 | /* ------------------------------------------------------------------------- * |
243 | * MEMORY ALLOCATION WRAPPERS * |
323 | * MEMORY ALLOCATION WRAPPERS * |
244 | * ------------------------------------------------------------------------- */ |
324 | * ------------------------------------------------------------------------- */ |
… | |
… | |
536 | /*----------------------------------------------------------------------*/ |
616 | /*----------------------------------------------------------------------*/ |
537 | /* |
617 | /* |
538 | * Tell the teletype handler what size the window is. |
618 | * Tell the teletype handler what size the window is. |
539 | * Called after a window size change. |
619 | * Called after a window size change. |
540 | */ |
620 | */ |
541 | /* EXTPROTO */ |
|
|
542 | void |
621 | void |
543 | rxvt_tt_winsize(int fd, unsigned short col, unsigned short row, int pid) |
622 | rxvt_term::tt_winch () |
544 | { |
623 | { |
545 | struct winsize ws; |
624 | struct winsize ws; |
546 | |
625 | |
547 | if (fd < 0) |
626 | if (cmd_fd < 0) |
548 | return; |
627 | return; |
|
|
628 | |
549 | ws.ws_col = col; |
629 | ws.ws_col = TermWin.ncol; |
550 | ws.ws_row = row; |
630 | ws.ws_row = TermWin.nrow; |
551 | ws.ws_xpixel = ws.ws_ypixel = 0; |
631 | ws.ws_xpixel = ws.ws_ypixel = 0; |
552 | #ifndef DEBUG_SIZE |
632 | #ifndef DEBUG_SIZE |
553 | (void)ioctl(fd, TIOCSWINSZ, &ws); |
633 | (void)ioctl (cmd_fd, TIOCSWINSZ, &ws); |
554 | #else |
634 | #else |
555 | if (ioctl(fd, TIOCSWINSZ, &ws) < 0) { |
635 | if (ioctl (cmd_fd, TIOCSWINSZ, &ws) < 0) |
556 | D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); |
636 | D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); |
557 | } |
|
|
558 | # ifdef SIGWINCH |
637 | # ifdef SIGWINCH |
559 | else if (pid) /* force through to the command */ |
638 | else if (cmd_pid) /* force through to the command */ |
560 | kill(pid, SIGWINCH); |
639 | kill (cmd_pid, SIGWINCH); |
561 | # endif |
640 | # endif |
562 | #endif |
641 | #endif |
563 | } |
642 | } |
564 | |
643 | |
565 | /*----------------------------------------------------------------------*/ |
644 | /*----------------------------------------------------------------------*/ |
… | |
… | |
984 | return; |
1063 | return; |
985 | } |
1064 | } |
986 | |
1065 | |
987 | /* INTPROTO */ |
1066 | /* INTPROTO */ |
988 | void |
1067 | void |
989 | rxvt_setPreeditArea(pR_ XRectangle * preedit_rect, XRectangle * status_rect, |
1068 | rxvt_setPreeditArea (pR_ XRectangle * preedit_rect, XRectangle * status_rect, |
990 | XRectangle * needed_rect) |
1069 | XRectangle * needed_rect) |
991 | { |
1070 | { |
992 | int mbh, vtx = 0; |
1071 | int mbh, vtx = 0; |
993 | |
1072 | |
994 | if (scrollbar_visible(R) && !(R->Options & Opt_scrollBar_right)) |
1073 | if (scrollbar_visible(R) && !(R->Options & Opt_scrollBar_right)) |
995 | vtx = scrollbar_TotalWidth(); |
1074 | vtx = scrollbar_TotalWidth(); |
… | |
… | |
1039 | rxvt_IMInstantiateCallback(Display * unused |
1118 | rxvt_IMInstantiateCallback(Display * unused |
1040 | __attribute__ ((unused)), XPointer client_data |
1119 | __attribute__ ((unused)), XPointer client_data |
1041 | __attribute__ ((unused)), XPointer call_data |
1120 | __attribute__ ((unused)), XPointer call_data |
1042 | __attribute__ ((unused))) |
1121 | __attribute__ ((unused))) |
1043 | { |
1122 | { |
1044 | dR; |
1123 | dR; |
1045 | int i, found, had_im; |
1124 | int i, found, had_im; |
1046 | const char *p; |
1125 | const char *p; |
1047 | char **s; |
1126 | char **s; |
1048 | char buf[IMBUFSIZ]; |
1127 | char buf[IMBUFSIZ]; |
1049 | |
1128 | |
1050 | D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); |
1129 | D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); |
1051 | if (R->Input_Context) |
1130 | if (R->Input_Context) |
1052 | return; |
1131 | return; |
1053 | |
1132 | |
1054 | found = had_im = 0; |
|
|
1055 | p = R->rs[Rs_inputMethod]; |
1133 | p = R->rs[Rs_inputMethod]; |
1056 | if (p && *p) { |
1134 | if (p && *p) |
1057 | had_im = 1; |
1135 | { |
|
|
1136 | bool found = false; |
|
|
1137 | |
1058 | s = rxvt_splitcommastring(p); |
1138 | s = rxvt_splitcommastring (p); |
1059 | for (i = 0; s[i]; i++) { |
1139 | for (i = 0; s[i]; i++) |
|
|
1140 | { |
1060 | if (*s[i]) { |
1141 | if (*s[i]) |
|
|
1142 | { |
1061 | STRCPY(buf, "@im="); |
1143 | STRCPY (buf, "@im="); |
1062 | STRNCAT(buf, s[i], IMBUFSIZ - 5); |
1144 | STRNCAT (buf, s[i], IMBUFSIZ - 5); |
1063 | if ((p = XSetLocaleModifiers(buf)) != NULL && *p |
1145 | if ((p = XSetLocaleModifiers (buf)) && *p |
1064 | && (rxvt_IM_get_IC(aR) == True)) { |
1146 | && rxvt_IM_get_IC (aR)) |
|
|
1147 | { |
1065 | found = 1; |
1148 | found = true; |
1066 | break; |
1149 | break; |
1067 | } |
1150 | } |
1068 | } |
1151 | } |
1069 | } |
1152 | } |
1070 | for (i = 0; s[i]; i++) |
1153 | for (i = 0; s[i]; i++) |
1071 | free(s[i]); |
1154 | free(s[i]); |
1072 | free(s); |
1155 | free(s); |
1073 | } |
1156 | |
1074 | if (found) |
1157 | if (found) |
1075 | return; |
1158 | return; |
|
|
1159 | } |
1076 | |
1160 | |
1077 | /* try with XMODIFIERS env. var. */ |
1161 | /* try with XMODIFIERS env. var. */ |
1078 | if ((p = XSetLocaleModifiers("")) != NULL && *p) { |
1162 | if ((p = XSetLocaleModifiers ("")) && *p |
1079 | rxvt_IM_get_IC(aR); |
1163 | && rxvt_IM_get_IC (aR)) |
1080 | return; |
1164 | return; |
1081 | } |
|
|
1082 | |
1165 | |
1083 | /* try with no modifiers base IF the user didn't specify an IM */ |
1166 | /* try with no modifiers base IF the user didn't specify an IM */ |
1084 | if (!had_im && (p = XSetLocaleModifiers("@im=none")) != NULL && *p |
1167 | if ((p = XSetLocaleModifiers ("@im=none")) && *p |
1085 | && rxvt_IM_get_IC(aR) == True) |
1168 | && rxvt_IM_get_IC (aR) == True) |
1086 | return; |
1169 | return; |
1087 | } |
1170 | } |
1088 | |
1171 | |
1089 | /* |
1172 | /* |
1090 | * Try to open a XIM with the current modifiers, then see if we can |
1173 | * Try to open a XIM with the current modifiers, then see if we can |
1091 | * open a suitable preedit type |
1174 | * open a suitable preedit type |