… | |
… | |
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 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
17 | * |
17 | * |
18 | * 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 |
19 | * 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 |
20 | * the Free Software Foundation; either version 2 of the License, or |
20 | * the Free Software Foundation; either version 2 of the License, or |
21 | * (at your option) any later version. |
21 | * (at your option) any later version. |
… | |
… | |
30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
31 | *---------------------------------------------------------------------*/ |
31 | *---------------------------------------------------------------------*/ |
32 | |
32 | |
33 | #include "../config.h" /* NECESSARY */ |
33 | #include "../config.h" /* NECESSARY */ |
34 | #include "rxvt.h" /* NECESSARY */ |
34 | #include "rxvt.h" /* NECESSARY */ |
35 | #include "main.intpro" /* PROTOS for internal routines */ |
35 | #include "keyboard.h" |
|
|
36 | #include "rxvtperl.h" |
|
|
37 | |
|
|
38 | #include <limits> |
36 | |
39 | |
37 | #include <csignal> |
40 | #include <csignal> |
38 | #include <cstring> |
41 | #include <cstring> |
39 | |
42 | |
40 | #ifdef TTY_GID_SUPPORT |
43 | #ifdef TTY_GID_SUPPORT |
… | |
… | |
43 | |
46 | |
44 | #ifdef HAVE_TERMIOS_H |
47 | #ifdef HAVE_TERMIOS_H |
45 | # include <termios.h> |
48 | # include <termios.h> |
46 | #endif |
49 | #endif |
47 | |
50 | |
48 | #ifdef KEYSYM_RESOURCE |
|
|
49 | # include "keyboard.h" |
|
|
50 | #endif |
|
|
51 | |
|
|
52 | vector<rxvt_term *> rxvt_term::termlist; |
51 | vector<rxvt_term *> rxvt_term::termlist; |
53 | |
52 | |
54 | static char curlocale[128]; |
53 | static char curlocale[128], savelocale[128]; |
55 | |
54 | |
56 | bool |
55 | bool |
57 | rxvt_set_locale (const char *locale) |
56 | rxvt_set_locale (const char *locale) |
58 | { |
57 | { |
59 | if (!locale || !strncmp (locale, curlocale, 128)) |
58 | if (!locale || !strncmp (locale, curlocale, 128)) |
60 | return false; |
59 | return false; |
61 | |
60 | |
62 | strncpy (curlocale, locale, 128); |
61 | strncpy (curlocale, locale, 128); |
63 | setlocale (LC_CTYPE, curlocale); |
62 | setlocale (LC_CTYPE, curlocale); |
64 | return true; |
63 | return true; |
|
|
64 | } |
|
|
65 | |
|
|
66 | void |
|
|
67 | rxvt_push_locale (const char *locale) |
|
|
68 | { |
|
|
69 | strcpy (savelocale, curlocale); |
|
|
70 | rxvt_set_locale (locale); |
|
|
71 | } |
|
|
72 | |
|
|
73 | void |
|
|
74 | rxvt_pop_locale () |
|
|
75 | { |
|
|
76 | rxvt_set_locale (savelocale); |
65 | } |
77 | } |
66 | |
78 | |
67 | #if ENABLE_COMBINING |
79 | #if ENABLE_COMBINING |
68 | class rxvt_composite_vec rxvt_composite; |
80 | class rxvt_composite_vec rxvt_composite; |
69 | |
81 | |
… | |
… | |
134 | rootwin_ev (this, &rxvt_term::rootwin_cb), |
146 | rootwin_ev (this, &rxvt_term::rootwin_cb), |
135 | #endif |
147 | #endif |
136 | #ifdef HAVE_SCROLLBARS |
148 | #ifdef HAVE_SCROLLBARS |
137 | scrollbar_ev (this, &rxvt_term::x_cb), |
149 | scrollbar_ev (this, &rxvt_term::x_cb), |
138 | #endif |
150 | #endif |
139 | #ifdef MENUBAR |
|
|
140 | menubar_ev (this, &rxvt_term::x_cb), |
|
|
141 | #endif |
|
|
142 | #ifdef CURSOR_BLINK |
151 | #ifdef CURSOR_BLINK |
143 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
152 | cursor_blink_ev (this, &rxvt_term::cursor_blink_cb), |
144 | #endif |
153 | #endif |
145 | #ifdef TEXT_BLINK |
154 | #ifdef TEXT_BLINK |
146 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
155 | text_blink_ev (this, &rxvt_term::text_blink_cb), |
… | |
… | |
158 | pointer_ev (this, &rxvt_term::pointer_cb), |
167 | pointer_ev (this, &rxvt_term::pointer_cb), |
159 | #endif |
168 | #endif |
160 | #ifdef USE_XIM |
169 | #ifdef USE_XIM |
161 | im_ev (this, &rxvt_term::im_cb), |
170 | im_ev (this, &rxvt_term::im_cb), |
162 | #endif |
171 | #endif |
163 | sw_term (this, &rxvt_term::sig_term), |
|
|
164 | sw_int (this, &rxvt_term::sig_term), |
|
|
165 | sw_chld (this, &rxvt_term::sig_chld), |
|
|
166 | termwin_ev (this, &rxvt_term::x_cb), |
172 | termwin_ev (this, &rxvt_term::x_cb), |
167 | vt_ev (this, &rxvt_term::x_cb), |
173 | vt_ev (this, &rxvt_term::x_cb), |
|
|
174 | child_ev (this, &rxvt_term::child_cb), |
168 | check_ev (this, &rxvt_term::check_cb), |
175 | check_ev (this, &rxvt_term::check_cb), |
169 | flush_ev (this, &rxvt_term::flush_cb), |
176 | flush_ev (this, &rxvt_term::flush_cb), |
170 | destroy_ev (this, &rxvt_term::destroy_cb), |
177 | destroy_ev (this, &rxvt_term::destroy_cb), |
171 | pty_ev (this, &rxvt_term::pty_cb), |
178 | pty_ev (this, &rxvt_term::pty_cb), |
172 | incr_ev (this, &rxvt_term::incr_cb) |
179 | incr_ev (this, &rxvt_term::incr_cb) |
… | |
… | |
188 | void rxvt_term::emergency_cleanup () |
195 | void rxvt_term::emergency_cleanup () |
189 | { |
196 | { |
190 | if (cmd_pid) |
197 | if (cmd_pid) |
191 | kill (-cmd_pid, SIGHUP); |
198 | kill (-cmd_pid, SIGHUP); |
192 | |
199 | |
193 | #ifdef UTMP_SUPPORT |
200 | delete pty; pty = 0; |
194 | privileged_utmp (RESTORE); |
|
|
195 | #endif |
|
|
196 | |
|
|
197 | pty.put (); |
|
|
198 | } |
201 | } |
199 | |
202 | |
200 | rxvt_term::~rxvt_term () |
203 | rxvt_term::~rxvt_term () |
201 | { |
204 | { |
|
|
205 | HOOK_INVOKE ((this, HOOK_DESTROY, DT_END)); |
|
|
206 | |
202 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
207 | termlist.erase (find (termlist.begin (), termlist.end(), this)); |
203 | |
208 | |
204 | emergency_cleanup (); |
209 | emergency_cleanup (); |
205 | |
210 | |
206 | #if ENABLE_STYLES |
211 | #if ENABLE_STYLES |
207 | for (int i = RS_styleCount; --i; ) |
212 | for (int i = RS_styleCount; --i; ) |
208 | if (TermWin.fontset[i] != TermWin.fontset[0]) |
213 | if (fontset[i] != fontset[0]) |
209 | delete TermWin.fontset[i]; |
214 | delete fontset[i]; |
210 | #endif |
215 | #endif |
211 | delete TermWin.fontset[0]; |
216 | delete fontset[0]; |
212 | |
217 | |
213 | if (display) |
218 | if (display) |
214 | { |
219 | { |
215 | dDisp; |
220 | dDisp; |
216 | |
221 | |
217 | selection_clear (); |
222 | selection_clear (); |
218 | |
223 | |
219 | #ifdef USE_XIM |
224 | #ifdef USE_XIM |
220 | im_destroy (); |
225 | im_destroy (); |
221 | #endif |
|
|
222 | #ifdef MENUBAR |
|
|
223 | if (menubarGC) XFreeGC (disp, menubarGC); |
|
|
224 | #endif |
226 | #endif |
225 | #ifdef XTERM_SCROLLBAR |
227 | #ifdef XTERM_SCROLLBAR |
226 | if (xscrollbarGC) XFreeGC (disp, xscrollbarGC); |
228 | if (xscrollbarGC) XFreeGC (disp, xscrollbarGC); |
227 | if (ShadowGC) XFreeGC (disp, ShadowGC); |
229 | if (ShadowGC) XFreeGC (disp, ShadowGC); |
228 | #endif |
230 | #endif |
… | |
… | |
239 | if (upArrow) XFreePixmap (disp, upArrow); |
241 | if (upArrow) XFreePixmap (disp, upArrow); |
240 | if (downArrow) XFreePixmap (disp, downArrow); |
242 | if (downArrow) XFreePixmap (disp, downArrow); |
241 | if (upArrowHi) XFreePixmap (disp, upArrowHi); |
243 | if (upArrowHi) XFreePixmap (disp, upArrowHi); |
242 | if (downArrowHi) XFreePixmap (disp, downArrowHi); |
244 | if (downArrowHi) XFreePixmap (disp, downArrowHi); |
243 | #endif |
245 | #endif |
244 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
246 | #ifdef RXVT_SCROLLBAR |
245 | if (topShadowGC) XFreeGC (disp, topShadowGC); |
247 | if (topShadowGC) XFreeGC (disp, topShadowGC); |
246 | if (botShadowGC) XFreeGC (disp, botShadowGC); |
248 | if (botShadowGC) XFreeGC (disp, botShadowGC); |
247 | if (scrollbarGC) XFreeGC (disp, scrollbarGC); |
249 | if (scrollbarGC) XFreeGC (disp, scrollbarGC); |
248 | #endif |
250 | #endif |
249 | if (TermWin.gc) XFreeGC (disp, TermWin.gc); |
251 | if (gc) XFreeGC (disp, gc); |
250 | |
252 | |
251 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
|
|
252 | delete menuBar.drawable; |
253 | delete drawable; |
253 | //if (menuBar.win) |
|
|
254 | // XDestroyWindow (disp, menuBar.win); |
|
|
255 | #endif |
|
|
256 | delete TermWin.drawable; |
|
|
257 | // destroy all windows |
254 | // destroy all windows |
258 | if (TermWin.parent[0] |
255 | if (parent[0]) |
259 | #if ENABLE_FRILLS |
|
|
260 | && !rs[Rs_embed] |
|
|
261 | #endif |
|
|
262 | ) |
|
|
263 | XDestroyWindow (disp, TermWin.parent[0]); |
256 | XDestroyWindow (disp, parent[0]); |
264 | } |
257 | } |
265 | |
258 | |
266 | // TODO: free pixcolours, colours should become part of rxvt_display |
259 | // TODO: free pixcolours, colours should become part of rxvt_display |
267 | |
|
|
268 | delete pix_colors_focused; |
260 | delete pix_colors_focused; |
269 | #ifdef OFF_FOCUS_FADING |
261 | #if OFF_FOCUS_FADING |
270 | delete pix_colors_unfocused; |
262 | delete pix_colors_unfocused; |
271 | #endif |
263 | #endif |
272 | |
264 | |
273 | displays.put (display); |
265 | displays.put (display); |
274 | |
266 | |
… | |
… | |
294 | #ifdef KEYSYM_RESOURCE |
286 | #ifdef KEYSYM_RESOURCE |
295 | delete keyboard; |
287 | delete keyboard; |
296 | #endif |
288 | #endif |
297 | } |
289 | } |
298 | |
290 | |
|
|
291 | // child has exited, usually destroys |
|
|
292 | void |
|
|
293 | rxvt_term::child_cb (child_watcher &w, int status) |
|
|
294 | { |
|
|
295 | HOOK_INVOKE ((this, HOOK_CHILD_EXIT, DT_INT, status, DT_END)); |
|
|
296 | |
|
|
297 | cmd_pid = 0; |
|
|
298 | |
|
|
299 | if (!OPTION (Opt_hold)) |
|
|
300 | destroy (); |
|
|
301 | } |
|
|
302 | |
299 | void |
303 | void |
300 | rxvt_term::destroy () |
304 | rxvt_term::destroy () |
301 | { |
305 | { |
302 | if (destroy_ev.active) |
306 | if (destroy_ev.active) |
303 | return; |
307 | return; |
… | |
… | |
311 | #if USE_XIM |
315 | #if USE_XIM |
312 | im_ev.stop (display); |
316 | im_ev.stop (display); |
313 | #endif |
317 | #endif |
314 | #if HAVE_SCROLLBARS |
318 | #if HAVE_SCROLLBARS |
315 | scrollbar_ev.stop (display); |
319 | scrollbar_ev.stop (display); |
316 | #endif |
|
|
317 | #if MENUBAR |
|
|
318 | menubar_ev.stop (display); |
|
|
319 | #endif |
320 | #endif |
320 | #if TRANSPARENT |
321 | #if TRANSPARENT |
321 | rootwin_ev.stop (display); |
322 | rootwin_ev.stop (display); |
322 | #endif |
323 | #endif |
323 | incr_ev.stop (); |
324 | incr_ev.stop (); |
… | |
… | |
347 | } |
348 | } |
348 | |
349 | |
349 | void |
350 | void |
350 | rxvt_term::destroy_cb (time_watcher &w) |
351 | rxvt_term::destroy_cb (time_watcher &w) |
351 | { |
352 | { |
352 | SET_R (this); |
353 | make_current (); |
353 | |
354 | |
354 | delete this; |
355 | delete this; |
355 | } |
356 | } |
356 | |
357 | |
357 | /*----------------------------------------------------------------------*/ |
358 | /*----------------------------------------------------------------------*/ |
… | |
… | |
422 | { |
423 | { |
423 | if (GET_R->allowedxerror == -1) |
424 | if (GET_R->allowedxerror == -1) |
424 | GET_R->allowedxerror = event->error_code; |
425 | GET_R->allowedxerror = event->error_code; |
425 | else |
426 | else |
426 | { |
427 | { |
427 | //TODO: GET_R is most likely not the terminal which caused the error |
428 | // GET_R is most likely not the terminal which caused the error, |
428 | //TODO: maybe just output the error and continue? |
429 | // so just output the error and continue |
429 | #if ENABLE_FRILLS |
430 | #if ENABLE_FRILLS |
430 | print_x_error (display, event); |
431 | print_x_error (display, event); |
431 | #else |
432 | #else |
432 | old_xerror_handler (display, event); |
433 | old_xerror_handler (display, event); |
433 | #endif |
434 | #endif |
… | |
… | |
443 | DisplayString (display)); |
444 | DisplayString (display)); |
444 | rxvt_emergency_cleanup (); |
445 | rxvt_emergency_cleanup (); |
445 | _exit (EXIT_FAILURE); |
446 | _exit (EXIT_FAILURE); |
446 | } |
447 | } |
447 | |
448 | |
448 | /* |
|
|
449 | * Catch a fatal signal and tidy up before quitting |
|
|
450 | */ |
|
|
451 | void |
|
|
452 | rxvt_term::sig_term (sig_watcher &w) |
|
|
453 | { |
|
|
454 | #ifdef DEBUG_CMD |
|
|
455 | rxvt_warn ("caught signal %d, exiting.\n", w.signum); |
|
|
456 | #endif |
|
|
457 | rxvt_emergency_cleanup (); |
|
|
458 | signal (w.signum, SIG_DFL); |
|
|
459 | kill (getpid (), w.signum); |
|
|
460 | } |
|
|
461 | |
|
|
462 | /*----------------------------------------------------------------------*/ |
449 | /*----------------------------------------------------------------------*/ |
463 | /* rxvt_init () */ |
|
|
464 | bool |
450 | bool |
465 | rxvt_term::init (int argc, const char *const *argv) |
451 | rxvt_term::init (int argc, const char *const *argv) |
466 | { |
452 | { |
467 | SET_R (this); |
453 | SET_R (this); |
468 | |
|
|
469 | set_locale (""); |
454 | set_locale (""); |
|
|
455 | set_environ (envv); // few things in X do not call setlocale :( |
470 | |
456 | |
471 | if (!init_vars ()) |
457 | if (!init_vars ()) |
472 | return false; |
458 | return false; |
473 | |
459 | |
474 | init_secondary (); |
460 | init_secondary (); |
… | |
… | |
477 | |
463 | |
478 | #ifdef KEYSYM_RESOURCE |
464 | #ifdef KEYSYM_RESOURCE |
479 | keyboard->register_done (); |
465 | keyboard->register_done (); |
480 | #endif |
466 | #endif |
481 | |
467 | |
482 | #if MENUBAR_MAX |
468 | #if ENABLE_PERL |
483 | menubar_read (rs[Rs_menu]); |
469 | if (!rs[Rs_perl_ext_1]) |
|
|
470 | rs[Rs_perl_ext_1] = "default"; |
|
|
471 | |
|
|
472 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
|
|
473 | || (rs[Rs_perl_ext_2] && *rs[Rs_perl_ext_2]) |
|
|
474 | || (rs[Rs_perl_eval] && *rs[Rs_perl_eval])) |
|
|
475 | { |
|
|
476 | rxvt_perl.init (this); |
|
|
477 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
|
|
478 | } |
484 | #endif |
479 | #endif |
|
|
480 | |
485 | #ifdef HAVE_SCROLLBARS |
481 | #ifdef HAVE_SCROLLBARS |
486 | if (options & Opt_scrollBar) |
482 | if (OPTION (Opt_scrollBar)) |
487 | scrollBar.setIdle (); /* set existence for size calculations */ |
483 | scrollBar.setIdle (); /* set existence for size calculations */ |
488 | #endif |
484 | #endif |
489 | |
485 | |
|
|
486 | pty = rxvt_new_ptytty (); |
|
|
487 | |
490 | create_windows (argc, argv); |
488 | create_windows (argc, argv); |
491 | |
489 | |
492 | dDisp; |
490 | dDisp; |
493 | |
491 | |
494 | init_xlocale (); |
492 | init_xlocale (); |
495 | |
493 | |
496 | scr_reset (); /* initialize screen */ |
494 | scr_reset (); // initialize screen |
497 | |
495 | |
498 | #if 0 |
496 | #if 0 |
499 | XSynchronize (disp, True); |
497 | XSynchronize (disp, True); |
500 | #endif |
498 | #endif |
501 | |
499 | |
502 | #ifdef HAVE_SCROLLBARS |
500 | #ifdef HAVE_SCROLLBARS |
503 | if (options & Opt_scrollBar) |
501 | if (OPTION (Opt_scrollBar)) |
504 | resize_scrollbar (); /* create and map scrollbar */ |
502 | resize_scrollbar (); /* create and map scrollbar */ |
505 | #endif |
503 | #endif |
506 | #if (MENUBAR_MAX) |
|
|
507 | if (menubar_visible ()) |
|
|
508 | XMapWindow (disp, menuBar.win); |
|
|
509 | #endif |
|
|
510 | #ifdef TRANSPARENT |
504 | #ifdef TRANSPARENT |
511 | if (options & Opt_transparent) |
505 | if (OPTION (Opt_transparent)) |
512 | { |
506 | { |
513 | XSelectInput (disp, display->root, PropertyChangeMask); |
507 | XSelectInput (disp, display->root, PropertyChangeMask); |
514 | check_our_parents (); |
508 | check_our_parents (); |
515 | rootwin_ev.start (display, display->root); |
509 | rootwin_ev.start (display, display->root); |
516 | } |
510 | } |
517 | #endif |
511 | #endif |
518 | |
512 | |
519 | XMapWindow (disp, TermWin.vt); |
513 | XMapWindow (disp, vt); |
520 | XMapWindow (disp, TermWin.parent[0]); |
514 | XMapWindow (disp, parent[0]); |
521 | |
515 | |
522 | set_colorfgbg (); |
516 | set_colorfgbg (); |
523 | |
517 | |
524 | init_command (cmd_argv); |
518 | init_command (cmd_argv); |
525 | |
519 | |
526 | free (cmd_argv); |
520 | free (cmd_argv); |
527 | |
521 | |
|
|
522 | if (pty->pty >= 0) |
528 | pty_ev.start (pty.pty, EVENT_READ); |
523 | pty_ev.start (pty->pty, EVENT_READ); |
529 | |
524 | |
530 | check_ev.start (); |
525 | check_ev.start (); |
531 | |
526 | |
|
|
527 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
|
|
528 | |
532 | return true; |
529 | return true; |
533 | } |
530 | } |
534 | |
531 | |
|
|
532 | static struct sig_handlers |
|
|
533 | { |
|
|
534 | sig_watcher sw_term, sw_int; |
|
|
535 | |
|
|
536 | /* |
|
|
537 | * Catch a fatal signal and tidy up before quitting |
|
|
538 | */ |
|
|
539 | void |
|
|
540 | sig_term (sig_watcher &w) |
|
|
541 | { |
|
|
542 | #ifdef DEBUG_CMD |
|
|
543 | rxvt_warn ("caught signal %d, exiting.\n", w.signum); |
|
|
544 | #endif |
|
|
545 | rxvt_emergency_cleanup (); |
|
|
546 | signal (w.signum, SIG_DFL); |
|
|
547 | kill (getpid (), w.signum); |
|
|
548 | } |
|
|
549 | |
|
|
550 | sig_handlers () |
|
|
551 | : sw_term (this, &sig_handlers::sig_term), |
|
|
552 | sw_int (this, &sig_handlers::sig_term) |
|
|
553 | { |
|
|
554 | } |
|
|
555 | } sig_handlers; |
|
|
556 | |
|
|
557 | char **rxvt_environ; // startup environment |
|
|
558 | |
535 | void |
559 | void |
536 | rxvt_init () |
560 | rxvt_init () |
537 | { |
561 | { |
538 | /* |
562 | uid_t uid = getuid (); |
539 | * Save and then give up any super-user privileges |
563 | gid_t gid = getgid (); |
540 | * If we need privileges in any area then we must specifically request it. |
564 | |
541 | * We should only need to be root in these cases: |
565 | // before doing anything else, check for setuid/setgid operation, |
542 | * 1. write utmp entries on some systems |
566 | // start the helper process and drop privileges |
543 | * 2. chown tty on some systems |
567 | if (uid != geteuid () |
544 | */ |
568 | || gid != getegid ()) |
545 | rxvt_privileges (SAVE); |
569 | { |
546 | rxvt_privileges (IGNORE); |
570 | #if PTYTTY_HELPER |
|
|
571 | rxvt_ptytty_server (); |
|
|
572 | #else |
|
|
573 | rxvt_warn ("running setuid/setgid without pty helper compiled in, continuing unprivileged.\n"); |
|
|
574 | #endif |
|
|
575 | |
|
|
576 | // drop privileges |
|
|
577 | #if HAVE_SETRESUID |
|
|
578 | setresgid (gid, gid, gid); |
|
|
579 | setresuid (uid, uid, uid); |
|
|
580 | #elif HAVE_SETREUID |
|
|
581 | setregid (gid, gid); |
|
|
582 | setreuid (uid, uid); |
|
|
583 | #elif HAVE_SETUID |
|
|
584 | setgid (gid); |
|
|
585 | setuid (uid); |
|
|
586 | #endif |
|
|
587 | |
|
|
588 | if (uid != geteuid () |
|
|
589 | || gid != getegid ()) |
|
|
590 | rxvt_fatal ("unable to drop privileges, aborting.\n"); |
|
|
591 | } |
|
|
592 | |
|
|
593 | rxvt_environ = environ; |
547 | |
594 | |
548 | signal (SIGHUP, SIG_IGN); |
595 | signal (SIGHUP, SIG_IGN); |
549 | signal (SIGPIPE, SIG_IGN); |
596 | signal (SIGPIPE, SIG_IGN); |
|
|
597 | |
|
|
598 | sig_handlers.sw_term.start (SIGTERM); |
|
|
599 | sig_handlers.sw_int.start (SIGINT); |
550 | |
600 | |
551 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
601 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
552 | /* signal (SIGURG, SIG_DFL); */ |
602 | /* signal (SIGURG, SIG_DFL); */ |
553 | |
603 | |
554 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
604 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
555 | // TODO: handle this with exceptions and tolerate the memory loss |
605 | // TODO: handle this with exceptions and tolerate the memory loss |
556 | XSetIOErrorHandler (rxvt_xioerror_handler); |
606 | XSetIOErrorHandler (rxvt_xioerror_handler); |
557 | } |
|
|
558 | |
607 | |
559 | /* ------------------------------------------------------------------------- * |
608 | XrmInitialize (); |
560 | * SIGNAL HANDLING & EXIT HANDLER * |
|
|
561 | * ------------------------------------------------------------------------- */ |
|
|
562 | /* |
|
|
563 | * Catch a SIGCHLD signal and exit if the direct child has died |
|
|
564 | */ |
|
|
565 | |
|
|
566 | void |
|
|
567 | rxvt_term::sig_chld (sig_watcher &w) |
|
|
568 | { |
|
|
569 | // we are being called for every SIGCHLD, not just ours |
|
|
570 | int pid; |
|
|
571 | |
|
|
572 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
|
|
573 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
|
|
574 | if (pid == (*t)->cmd_pid) |
|
|
575 | { |
|
|
576 | (*t)->destroy (); |
|
|
577 | break; |
|
|
578 | } |
|
|
579 | } |
609 | } |
580 | |
610 | |
581 | /* ------------------------------------------------------------------------- * |
611 | /* ------------------------------------------------------------------------- * |
582 | * MEMORY ALLOCATION WRAPPERS * |
612 | * MEMORY ALLOCATION WRAPPERS * |
583 | * ------------------------------------------------------------------------- */ |
613 | * ------------------------------------------------------------------------- */ |
… | |
… | |
590 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
620 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
591 | |
621 | |
592 | return p; |
622 | return p; |
593 | } |
623 | } |
594 | |
624 | |
595 | /* INTPROTO */ |
625 | void * |
596 | void * |
|
|
597 | rxvt_calloc (size_t number, size_t size) |
626 | rxvt_calloc (size_t number, size_t size) |
598 | { |
627 | { |
599 | void *p = calloc (number, size); |
628 | void *p = calloc (number, size); |
600 | |
629 | |
601 | if (!p) |
630 | if (!p) |
602 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
631 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
603 | |
632 | |
604 | return p; |
633 | return p; |
605 | } |
634 | } |
606 | |
635 | |
607 | /* INTPROTO */ |
|
|
608 | void * |
636 | void * |
609 | rxvt_realloc (void *ptr, size_t size) |
637 | rxvt_realloc (void *ptr, size_t size) |
610 | { |
638 | { |
611 | void *p = realloc (ptr, size); |
639 | void *p = realloc (ptr, size); |
612 | |
640 | |
613 | if (!p) |
641 | if (!p) |
614 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
642 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
615 | |
643 | |
616 | return p; |
644 | return p; |
617 | } |
645 | } |
618 | |
|
|
619 | /* ------------------------------------------------------------------------- * |
|
|
620 | * PRIVILEGED OPERATIONS * |
|
|
621 | * ------------------------------------------------------------------------- */ |
|
|
622 | /* take care of suid/sgid super-user (root) privileges */ |
|
|
623 | void |
|
|
624 | rxvt_privileges (rxvt_privaction action) |
|
|
625 | { |
|
|
626 | #if (defined(HAVE_SETEUID) || defined(HAVE_SETREUID)) && !defined(__CYGWIN32__) |
|
|
627 | static uid_t euid; |
|
|
628 | static gid_t egid; |
|
|
629 | #endif |
|
|
630 | |
|
|
631 | #if ! defined(__CYGWIN32__) |
|
|
632 | # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
|
|
633 | /* setreuid () is the poor man's setuid (), seteuid () */ |
|
|
634 | # define seteuid(a) setreuid(-1, (a)) |
|
|
635 | # define setegid(a) setregid(-1, (a)) |
|
|
636 | # define HAVE_SETEUID |
|
|
637 | # endif |
|
|
638 | # ifdef HAVE_SETEUID |
|
|
639 | switch (action) |
|
|
640 | { |
|
|
641 | case IGNORE: |
|
|
642 | /* |
|
|
643 | * change effective uid/gid - not real uid/gid - so we can switch |
|
|
644 | * back to root later, as required |
|
|
645 | */ |
|
|
646 | seteuid (getuid ()); |
|
|
647 | setegid (getgid ()); |
|
|
648 | break; |
|
|
649 | case SAVE: |
|
|
650 | euid = geteuid (); |
|
|
651 | egid = getegid (); |
|
|
652 | break; |
|
|
653 | case RESTORE: |
|
|
654 | seteuid (euid); |
|
|
655 | setegid (egid); |
|
|
656 | break; |
|
|
657 | } |
|
|
658 | # else |
|
|
659 | switch (action) |
|
|
660 | { |
|
|
661 | case IGNORE: |
|
|
662 | setuid (getuid ()); |
|
|
663 | setgid (getgid ()); |
|
|
664 | /* FALLTHROUGH */ |
|
|
665 | case SAVE: |
|
|
666 | /* FALLTHROUGH */ |
|
|
667 | case RESTORE: |
|
|
668 | break; |
|
|
669 | } |
|
|
670 | # endif |
|
|
671 | #endif |
|
|
672 | } |
|
|
673 | |
|
|
674 | #ifdef UTMP_SUPPORT |
|
|
675 | void |
|
|
676 | rxvt_term::privileged_utmp (rxvt_privaction action) |
|
|
677 | { |
|
|
678 | if ((options & Opt_utmpInhibit) |
|
|
679 | || !pty.name || !*pty.name) |
|
|
680 | return; |
|
|
681 | |
|
|
682 | rxvt_privileges (RESTORE); |
|
|
683 | |
|
|
684 | if (action == SAVE) |
|
|
685 | makeutent (pty.name, rs[Rs_display_name]); |
|
|
686 | else |
|
|
687 | cleanutent (); |
|
|
688 | |
|
|
689 | rxvt_privileges (IGNORE); |
|
|
690 | } |
|
|
691 | #endif |
|
|
692 | |
646 | |
693 | /*----------------------------------------------------------------------*/ |
647 | /*----------------------------------------------------------------------*/ |
694 | /* |
648 | /* |
695 | * window size/position calculcations for XSizeHint and other storage. |
649 | * window size/position calculcations for XSizeHint and other storage. |
696 | * if width/height are non-zero then override calculated width/height |
650 | * if width/height are non-zero then override calculated width/height |
697 | */ |
651 | */ |
698 | void |
652 | void |
699 | rxvt_term::window_calc (unsigned int width, unsigned int height) |
653 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
700 | { |
654 | { |
701 | short recalc_x, recalc_y; |
655 | short recalc_x, recalc_y; |
702 | int x, y, sb_w, mb_h, flags; |
656 | int x, y, sb_w, flags; |
703 | unsigned int w, h; |
657 | unsigned int w, h; |
704 | unsigned int max_width, max_height; |
658 | unsigned int max_width, max_height; |
705 | dDisp; |
659 | dDisp; |
706 | |
660 | |
707 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
661 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
708 | TermWin.ncol, TermWin.nrow, szHint.width, |
662 | ncol, nrow, szHint.width, szHint.height)); |
709 | szHint.height)); |
663 | |
710 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
664 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
711 | szHint.win_gravity = NorthWestGravity; |
665 | szHint.win_gravity = NorthWestGravity; |
712 | /* szHint.min_aspect.x = szHint.min_aspect.y = 1; */ |
666 | /* szHint.min_aspect.x = szHint.min_aspect.y = 1; */ |
713 | |
667 | |
714 | recalc_x = recalc_y = 0; |
668 | recalc_x = recalc_y = 0; |
715 | flags = 0; |
669 | flags = 0; |
|
|
670 | |
716 | if (!parsed_geometry) |
671 | if (!parsed_geometry) |
717 | { |
672 | { |
718 | parsed_geometry = 1; |
673 | parsed_geometry = 1; |
|
|
674 | |
719 | if (rs[Rs_geometry]) |
675 | if (rs[Rs_geometry]) |
720 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
676 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
721 | |
677 | |
722 | if (flags & WidthValue) |
678 | if (flags & WidthValue) |
723 | { |
679 | { |
724 | TermWin.ncol = BOUND_POSITIVE_INT16 (w); |
680 | ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); |
725 | szHint.flags |= USSize; |
681 | szHint.flags |= USSize; |
726 | } |
682 | } |
727 | |
683 | |
728 | if (flags & HeightValue) |
684 | if (flags & HeightValue) |
729 | { |
685 | { |
730 | TermWin.nrow = BOUND_POSITIVE_INT16 (h); |
686 | nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); |
731 | szHint.flags |= USSize; |
687 | szHint.flags |= USSize; |
732 | } |
688 | } |
733 | |
689 | |
734 | if (flags & XValue) |
690 | if (flags & XValue) |
735 | { |
691 | { |
736 | szHint.x = x; |
692 | szHint.x = x; |
737 | szHint.flags |= USPosition; |
693 | szHint.flags |= USPosition; |
|
|
694 | |
738 | if (flags & XNegative) |
695 | if (flags & XNegative) |
739 | { |
696 | { |
740 | recalc_x = 1; |
697 | recalc_x = 1; |
741 | szHint.win_gravity = NorthEastGravity; |
698 | szHint.win_gravity = NorthEastGravity; |
742 | } |
699 | } |
… | |
… | |
744 | |
701 | |
745 | if (flags & YValue) |
702 | if (flags & YValue) |
746 | { |
703 | { |
747 | szHint.y = y; |
704 | szHint.y = y; |
748 | szHint.flags |= USPosition; |
705 | szHint.flags |= USPosition; |
|
|
706 | |
749 | if (flags & YNegative) |
707 | if (flags & YNegative) |
750 | { |
708 | { |
751 | recalc_y = 1; |
709 | recalc_y = 1; |
|
|
710 | |
752 | if (szHint.win_gravity == NorthEastGravity) |
711 | if (szHint.win_gravity == NorthEastGravity) |
753 | szHint.win_gravity = SouthEastGravity; |
712 | szHint.win_gravity = SouthEastGravity; |
754 | else |
713 | else |
755 | szHint.win_gravity = SouthWestGravity; |
714 | szHint.win_gravity = SouthWestGravity; |
756 | } |
715 | } |
757 | } |
716 | } |
758 | } |
717 | } |
759 | |
718 | |
760 | /* TODO: BOUNDS */ |
719 | /* TODO: BOUNDS */ |
761 | TermWin.width = TermWin.ncol * TermWin.fwidth; |
720 | width = ncol * fwidth; |
762 | TermWin.height = TermWin.nrow * TermWin.fheight; |
721 | height = nrow * fheight; |
763 | max_width = MAX_COLS * TermWin.fwidth; |
722 | max_width = MAX_COLS * fwidth; |
764 | max_height = MAX_ROWS * TermWin.fheight; |
723 | max_height = MAX_ROWS * fheight; |
765 | |
724 | |
766 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
725 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
767 | |
726 | |
768 | sb_w = mb_h = 0; |
727 | sb_w = 0; |
769 | window_vt_x = window_vt_y = TermWin.int_bwidth; |
728 | window_vt_x = window_vt_y = int_bwidth; |
770 | |
729 | |
771 | if (scrollbar_visible ()) |
730 | if (scrollBar.state) |
772 | { |
731 | { |
773 | sb_w = scrollbar_TotalWidth (); |
732 | sb_w = scrollbar_TotalWidth (); |
774 | szHint.base_width += sb_w; |
733 | szHint.base_width += sb_w; |
775 | if (!(options & Opt_scrollBar_right)) |
734 | if (!OPTION (Opt_scrollBar_right)) |
776 | window_vt_x += sb_w; |
735 | window_vt_x += sb_w; |
777 | } |
736 | } |
778 | |
737 | |
779 | if (menubar_visible ()) |
|
|
780 | { |
|
|
781 | mb_h = menuBar_TotalHeight (); |
|
|
782 | szHint.base_height += mb_h; |
|
|
783 | window_vt_y += mb_h; |
|
|
784 | } |
|
|
785 | |
|
|
786 | szHint.width_inc = TermWin.fwidth; |
738 | szHint.width_inc = fwidth; |
787 | szHint.height_inc = TermWin.fheight; |
739 | szHint.height_inc = fheight; |
788 | szHint.min_width = szHint.base_width + szHint.width_inc; |
740 | szHint.min_width = szHint.base_width + szHint.width_inc; |
789 | szHint.min_height = szHint.base_height + szHint.height_inc; |
741 | szHint.min_height = szHint.base_height + szHint.height_inc; |
790 | |
742 | |
791 | if (width && width - szHint.base_width < max_width) |
743 | if (newwidth && newwidth - szHint.base_width < max_width) |
792 | { |
744 | { |
793 | szHint.width = width; |
745 | szHint.width = newwidth; |
794 | TermWin.width = width - szHint.base_width; |
746 | width = newwidth - szHint.base_width; |
795 | } |
747 | } |
796 | else |
748 | else |
797 | { |
749 | { |
798 | MIN_IT (TermWin.width, max_width); |
750 | min_it (width, max_width); |
799 | szHint.width = szHint.base_width + TermWin.width; |
751 | szHint.width = szHint.base_width + width; |
800 | } |
752 | } |
801 | |
753 | |
802 | if (height && height - szHint.base_height < max_height) |
754 | if (newheight && newheight - szHint.base_height < max_height) |
803 | { |
755 | { |
804 | szHint.height = height; |
756 | szHint.height = newheight; |
805 | TermWin.height = height - szHint.base_height; |
757 | height = newheight - szHint.base_height; |
806 | } |
758 | } |
807 | else |
759 | else |
808 | { |
760 | { |
809 | MIN_IT (TermWin.height, max_height); |
761 | min_it (height, max_height); |
810 | szHint.height = szHint.base_height + TermWin.height; |
762 | szHint.height = szHint.base_height + height; |
811 | } |
763 | } |
812 | |
764 | |
813 | if (scrollbar_visible () && (options & Opt_scrollBar_right)) |
765 | if (scrollBar.state && OPTION (Opt_scrollBar_right)) |
814 | window_sb_x = szHint.width - sb_w; |
766 | window_sb_x = szHint.width - sb_w; |
815 | |
767 | |
816 | if (recalc_x) |
768 | if (recalc_x) |
817 | szHint.x += (DisplayWidth (disp, display->screen) |
769 | szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; |
818 | - szHint.width - 2 * TermWin.ext_bwidth); |
|
|
819 | if (recalc_y) |
770 | if (recalc_y) |
820 | szHint.y += (DisplayHeight (disp, display->screen) |
771 | szHint.y += DisplayHeight (disp, display->screen) - szHint.height - 2 * ext_bwidth; |
821 | - szHint.height - 2 * TermWin.ext_bwidth); |
|
|
822 | |
772 | |
823 | TermWin.ncol = TermWin.width / TermWin.fwidth; |
773 | ncol = width / fwidth; |
824 | TermWin.nrow = TermWin.height / TermWin.fheight; |
774 | nrow = height / fheight; |
825 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
775 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
826 | TermWin.ncol, TermWin.nrow, szHint.width, |
776 | ncol, nrow, szHint.width, |
827 | szHint.height)); |
777 | szHint.height)); |
828 | return; |
778 | return; |
829 | } |
779 | } |
830 | |
780 | |
831 | /*----------------------------------------------------------------------*/ |
781 | /*----------------------------------------------------------------------*/ |
… | |
… | |
834 | * Called after a window size change. |
784 | * Called after a window size change. |
835 | */ |
785 | */ |
836 | void |
786 | void |
837 | rxvt_term::tt_winch () |
787 | rxvt_term::tt_winch () |
838 | { |
788 | { |
839 | if (pty.pty < 0) |
789 | if (pty->pty < 0) |
840 | return; |
790 | return; |
841 | |
791 | |
842 | struct winsize ws; |
792 | struct winsize ws; |
843 | |
793 | |
844 | ws.ws_col = TermWin.ncol; |
794 | ws.ws_col = ncol; |
845 | ws.ws_row = TermWin.nrow; |
795 | ws.ws_row = nrow; |
846 | ws.ws_xpixel = TermWin.width; |
796 | ws.ws_xpixel = width; |
847 | ws.ws_ypixel = TermWin.height; |
797 | ws.ws_ypixel = height; |
848 | (void)ioctl (pty.pty, TIOCSWINSZ, &ws); |
798 | (void)ioctl (pty->pty, TIOCSWINSZ, &ws); |
849 | |
799 | |
850 | #if 0 |
800 | #if 0 |
851 | // TIOCSWINSZ⎈ is supposed to do this automatically and correctly |
801 | // TIOCSWINSZ⎈ is supposed to do this automatically and correctly |
852 | if (cmd_pid) /* force through to the command */ |
802 | if (cmd_pid) /* force through to the command */ |
853 | kill (cmd_pid, SIGWINCH); |
803 | kill (-cmd_pid, SIGWINCH); |
854 | #endif |
804 | #endif |
855 | } |
805 | } |
856 | |
806 | |
857 | /*----------------------------------------------------------------------*/ |
807 | /*----------------------------------------------------------------------*/ |
858 | /* set_fonts () - load and set the various fonts |
808 | /* set_fonts () - load and set the various fonts |
859 | /* |
809 | * |
860 | * init = 1 - initialize |
810 | * init = 1 - initialize |
861 | * |
811 | * |
862 | * fontname == FONT_UP - switch to bigger font |
812 | * fontname == FONT_UP - switch to bigger font |
863 | * fontname == FONT_DN - switch to smaller font |
813 | * fontname == FONT_DN - switch to smaller font |
864 | */ |
814 | */ |
… | |
… | |
876 | return false; |
826 | return false; |
877 | } |
827 | } |
878 | |
828 | |
879 | #if ENABLE_STYLES |
829 | #if ENABLE_STYLES |
880 | for (int i = RS_styleCount; --i; ) |
830 | for (int i = RS_styleCount; --i; ) |
881 | if (TermWin.fontset[i] != TermWin.fontset[0]) |
831 | if (fontset[i] != fontset[0]) |
882 | delete TermWin.fontset[i]; |
832 | delete fontset[i]; |
883 | #endif |
833 | #endif |
884 | |
834 | |
885 | delete TermWin.fontset[0]; |
835 | delete fontset[0]; |
886 | TermWin.fontset[0] = fs; |
836 | fontset[0] = fs; |
887 | |
837 | |
888 | prop = (*fs)[1]->properties (); |
838 | prop = (*fs)[1]->properties (); |
889 | prop.height += TermWin.lineSpace; |
839 | prop.height += lineSpace; |
890 | fs->set_prop (prop); |
840 | fs->set_prop (prop); |
891 | |
841 | |
892 | TermWin.fwidth = prop.width; |
842 | fwidth = prop.width; |
893 | TermWin.fheight = prop.height; |
843 | fheight = prop.height; |
894 | TermWin.fweight = prop.weight; |
844 | fbase = prop.ascent; |
895 | TermWin.fslant = prop.slant; |
|
|
896 | TermWin.fbase = (*fs)[1]->ascent; |
|
|
897 | |
845 | |
898 | for (int style = 1; style < 4; style++) |
846 | for (int style = 1; style < 4; style++) |
899 | { |
847 | { |
900 | #if ENABLE_STYLES |
848 | #if ENABLE_STYLES |
901 | const char *res = rs[Rs_font + style]; |
849 | const char *res = rs[Rs_font + style]; |
902 | |
850 | |
903 | if (res && !*res) |
851 | if (res && !*res) |
904 | TermWin.fontset[style] = TermWin.fontset[0]; |
852 | fontset[style] = fontset[0]; |
905 | else |
853 | else |
906 | { |
854 | { |
907 | TermWin.fontset[style] = fs = new rxvt_fontset (this); |
855 | fontset[style] = fs = new rxvt_fontset (this); |
908 | rxvt_fontprop prop2 = prop; |
856 | rxvt_fontprop prop2 = prop; |
909 | |
857 | |
910 | if (res) |
858 | if (res) |
911 | prop2.weight = prop2.slant = rxvt_fontprop::unset; |
859 | prop2.weight = prop2.slant = rxvt_fontprop::unset; |
912 | else |
860 | else |
913 | { |
861 | { |
914 | res = TermWin.fontset[0]->fontdesc; |
862 | res = fontset[0]->fontdesc; |
915 | |
863 | |
916 | if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold; |
864 | if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold; |
917 | if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic; |
865 | if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic; |
918 | } |
866 | } |
919 | |
867 | |
920 | fs->populate (res); |
868 | fs->populate (res); |
921 | fs->set_prop (prop2); |
869 | fs->set_prop (prop2); |
922 | } |
870 | } |
923 | #else |
871 | #else |
924 | TermWin.fontset[style] = TermWin.fontset[0]; |
872 | fontset[style] = fontset[0]; |
925 | #endif |
873 | #endif |
926 | } |
874 | } |
927 | |
875 | |
928 | if (TermWin.parent[0]) |
876 | if (parent[0]) |
929 | { |
877 | { |
930 | resize_all_windows (0, 0, 0); |
878 | resize_all_windows (0, 0, 0); |
931 | scr_remap_chars (); |
879 | scr_remap_chars (); |
932 | scr_touch (true); |
880 | scr_touch (true); |
933 | } |
881 | } |
… | |
… | |
935 | return true; |
883 | return true; |
936 | } |
884 | } |
937 | |
885 | |
938 | void rxvt_term::set_string_property (Atom prop, const char *str, int len) |
886 | void rxvt_term::set_string_property (Atom prop, const char *str, int len) |
939 | { |
887 | { |
940 | // TODO: SMART_WINDOW_TITLE |
|
|
941 | XChangeProperty (display->display, TermWin.parent[0], |
888 | XChangeProperty (display->display, parent[0], |
942 | prop, XA_STRING, 8, PropModeReplace, |
889 | prop, XA_STRING, 8, PropModeReplace, |
943 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
890 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
944 | } |
891 | } |
945 | |
892 | |
946 | void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
893 | void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
947 | { |
894 | { |
948 | // TODO: SMART_WINDOW_TITLE |
|
|
949 | wchar_t *ws = rxvt_mbstowcs (str, len); |
895 | wchar_t *ws = rxvt_mbstowcs (str, len); |
950 | char *s = rxvt_wcstoutf8 (ws); |
896 | char *s = rxvt_wcstoutf8 (ws); |
951 | |
897 | |
952 | XChangeProperty (display->display, TermWin.parent[0], |
898 | XChangeProperty (display->display, parent[0], |
953 | prop, xa[XA_UTF8_STRING], 8, PropModeReplace, |
899 | prop, xa[XA_UTF8_STRING], 8, PropModeReplace, |
954 | (const unsigned char *)s, strlen (s)); |
900 | (const unsigned char *)s, strlen (s)); |
955 | |
901 | |
956 | free (s); |
902 | free (s); |
957 | free (ws); |
903 | free (ws); |
… | |
… | |
962 | /* xterm sequences - title, iconName, color (exptl) */ |
908 | /* xterm sequences - title, iconName, color (exptl) */ |
963 | void |
909 | void |
964 | rxvt_term::set_title (const char *str) |
910 | rxvt_term::set_title (const char *str) |
965 | { |
911 | { |
966 | set_string_property (XA_WM_NAME, str); |
912 | set_string_property (XA_WM_NAME, str); |
967 | #if ENABLE_FRILLS |
913 | #if ENABLE_EWMH |
968 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
914 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
969 | #endif |
915 | #endif |
970 | } |
916 | } |
971 | |
917 | |
972 | void |
918 | void |
973 | rxvt_term::set_icon_name (const char *str) |
919 | rxvt_term::set_icon_name (const char *str) |
974 | { |
920 | { |
975 | set_string_property (XA_WM_ICON_NAME, str); |
921 | set_string_property (XA_WM_ICON_NAME, str); |
976 | #if ENABLE_FRILLS |
922 | #if ENABLE_EWMH |
977 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
923 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
978 | #endif |
924 | #endif |
979 | } |
925 | } |
980 | |
926 | |
981 | #ifdef XTERM_COLOR_CHANGE |
927 | #ifdef XTERM_COLOR_CHANGE |
… | |
… | |
994 | i = atoi (color); |
940 | i = atoi (color); |
995 | |
941 | |
996 | if (i >= 8 && i <= 15) |
942 | if (i >= 8 && i <= 15) |
997 | { /* bright colors */ |
943 | { /* bright colors */ |
998 | i -= 8; |
944 | i -= 8; |
999 | # ifndef NO_BRIGHTCOLOR |
|
|
1000 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
945 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
1001 | SET_PIXCOLOR (idx); |
946 | SET_PIXCOLOR (idx); |
1002 | goto Done; |
947 | goto done; |
1003 | # endif |
|
|
1004 | } |
948 | } |
1005 | |
949 | |
1006 | if (i >= 0 && i <= 7) |
950 | if (i >= 0 && i <= 7) |
1007 | { /* normal colors */ |
951 | { /* normal colors */ |
1008 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
952 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
1009 | SET_PIXCOLOR (idx); |
953 | SET_PIXCOLOR (idx); |
1010 | goto Done; |
954 | goto done; |
1011 | } |
955 | } |
1012 | } |
956 | } |
1013 | |
957 | |
1014 | if (!rXParseAllocColor (&xcol, color)) |
958 | if (!rXParseAllocColor (&xcol, color)) |
1015 | return; |
959 | return; |
… | |
… | |
1035 | pix_colors_focused[idx] = xcol; |
979 | pix_colors_focused[idx] = xcol; |
1036 | SET_PIXCOLOR (idx); |
980 | SET_PIXCOLOR (idx); |
1037 | |
981 | |
1038 | /* XSetWindowAttributes attr; */ |
982 | /* XSetWindowAttributes attr; */ |
1039 | /* Cursor cursor; */ |
983 | /* Cursor cursor; */ |
1040 | Done: |
984 | done: |
|
|
985 | |
1041 | #ifdef OFF_FOCUS_FADING |
986 | #if OFF_FOCUS_FADING |
1042 | if (rs[Rs_fade]) |
987 | if (rs[Rs_fade]) |
1043 | pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade])); |
988 | pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade]), pix_colors[Color_fade]); |
1044 | #endif |
989 | #endif |
1045 | |
990 | |
1046 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
991 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
1047 | |
992 | |
1048 | recolour_cursor (); |
993 | recolour_cursor (); |
… | |
… | |
1119 | |
1064 | |
1120 | /* -------------------------------------------------------------------- * |
1065 | /* -------------------------------------------------------------------- * |
1121 | * - WINDOW RESIZING - * |
1066 | * - WINDOW RESIZING - * |
1122 | * -------------------------------------------------------------------- */ |
1067 | * -------------------------------------------------------------------- */ |
1123 | void |
1068 | void |
1124 | rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) |
1069 | rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent) |
1125 | { |
1070 | { |
1126 | int fix_screen; |
1071 | int fix_screen; |
1127 | #ifdef SMART_RESIZE |
|
|
1128 | int old_width = szHint.width, old_height = szHint.height; |
1072 | int old_width = szHint.width, old_height = szHint.height; |
1129 | #endif |
|
|
1130 | dDisp; |
1073 | dDisp; |
1131 | |
1074 | |
1132 | window_calc (width, height); |
1075 | window_calc (newwidth, newheight); |
1133 | XSetWMNormalHints (disp, TermWin.parent[0], &szHint); |
1076 | XSetWMNormalHints (disp, parent[0], &szHint); |
1134 | |
1077 | |
1135 | if (!ignoreparent) |
1078 | if (!ignoreparent) |
1136 | { |
1079 | { |
1137 | #ifdef SMART_RESIZE |
1080 | #ifdef SMART_RESIZE |
1138 | /* |
1081 | /* |
… | |
… | |
1142 | int x, y, x1, y1; |
1085 | int x, y, x1, y1; |
1143 | int dx, dy; |
1086 | int dx, dy; |
1144 | unsigned int unused_w1, unused_h1, unused_b1, unused_d1; |
1087 | unsigned int unused_w1, unused_h1, unused_b1, unused_d1; |
1145 | Window unused_cr; |
1088 | Window unused_cr; |
1146 | |
1089 | |
1147 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
1090 | XTranslateCoordinates (disp, parent[0], display->root, |
1148 | 0, 0, &x, &y, &unused_cr); |
1091 | 0, 0, &x, &y, &unused_cr); |
1149 | XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1, |
1092 | XGetGeometry (disp, parent[0], &unused_cr, &x1, &y1, |
1150 | &unused_w1, &unused_h1, &unused_b1, &unused_d1); |
1093 | &unused_w1, &unused_h1, &unused_b1, &unused_d1); |
1151 | /* |
1094 | /* |
1152 | * if display->root isn't the parent window, a WM will probably have offset |
1095 | * if display->root isn't the parent window, a WM will probably have offset |
1153 | * our position for handles and decorations. Counter it |
1096 | * our position for handles and decorations. Counter it |
1154 | */ |
1097 | */ |
… | |
… | |
1171 | if (y < y1) /* top half */ |
1114 | if (y < y1) /* top half */ |
1172 | dy = 0; |
1115 | dy = 0; |
1173 | else if (y == y1) /* exact center */ |
1116 | else if (y == y1) /* exact center */ |
1174 | dy /= 2; |
1117 | dy /= 2; |
1175 | |
1118 | |
1176 | XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy, |
1119 | XMoveResizeWindow (disp, parent[0], x + dx, y + dy, |
1177 | szHint.width, szHint.height); |
1120 | szHint.width, szHint.height); |
1178 | #else |
1121 | #else |
1179 | XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height); |
1122 | XResizeWindow (disp, parent[0], szHint.width, szHint.height); |
1180 | #endif |
1123 | #endif |
1181 | } |
1124 | } |
1182 | |
1125 | |
1183 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1126 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
1184 | |
1127 | |
1185 | if (fix_screen || width != old_width || height != old_height) |
1128 | if (fix_screen || newwidth != old_width || newheight != old_height) |
1186 | { |
1129 | { |
1187 | if (scrollbar_visible ()) |
1130 | if (scrollBar.state) |
1188 | { |
1131 | { |
1189 | XMoveResizeWindow (disp, scrollBar.win, |
1132 | XMoveResizeWindow (disp, scrollBar.win, |
1190 | window_sb_x, 0, |
1133 | window_sb_x, 0, |
1191 | scrollbar_TotalWidth (), szHint.height); |
1134 | scrollbar_TotalWidth (), szHint.height); |
1192 | resize_scrollbar (); |
1135 | resize_scrollbar (); |
1193 | } |
1136 | } |
1194 | |
1137 | |
1195 | if (menubar_visible ()) |
|
|
1196 | XMoveResizeWindow (disp, menuBar.win, |
|
|
1197 | window_vt_x, 0, |
|
|
1198 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
|
|
1199 | |
|
|
1200 | XMoveResizeWindow (disp, TermWin.vt, |
1138 | XMoveResizeWindow (disp, vt, |
1201 | window_vt_x, window_vt_y, |
1139 | window_vt_x, window_vt_y, |
1202 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1140 | width, height); |
1203 | |
1141 | |
1204 | scr_clear (); |
1142 | scr_clear (); |
1205 | #ifdef XPM_BACKGROUND |
1143 | #ifdef XPM_BACKGROUND |
1206 | resize_pixmap (); |
1144 | resize_pixmap (); |
1207 | #endif |
1145 | #endif |
… | |
… | |
1213 | int old_ncol = prev_ncol; |
1151 | int old_ncol = prev_ncol; |
1214 | |
1152 | |
1215 | /* scr_reset only works on the primary screen */ |
1153 | /* scr_reset only works on the primary screen */ |
1216 | if (old_height) /* this is not the first time through */ |
1154 | if (old_height) /* this is not the first time through */ |
1217 | { |
1155 | { |
1218 | unsigned int ncol = TermWin.ncol; |
1156 | unsigned int ocol = ncol; |
1219 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
1157 | ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
1220 | curr_screen = scr_change_screen (PRIMARY); |
1158 | curr_screen = scr_change_screen (PRIMARY); |
1221 | TermWin.ncol = ncol; |
1159 | ncol = ocol; |
1222 | } |
1160 | } |
1223 | |
1161 | |
1224 | scr_reset (); |
1162 | scr_reset (); |
1225 | |
1163 | |
1226 | if (curr_screen >= 0) /* this is not the first time through */ |
1164 | if (curr_screen >= 0) /* this is not the first time through */ |
1227 | { |
1165 | { |
1228 | scr_change_screen (curr_screen); |
1166 | scr_change_screen (curr_screen); |
1229 | selection_check (old_ncol != TermWin.ncol ? 4 : 0); |
1167 | selection_check (old_ncol != ncol ? 4 : 0); |
1230 | } |
1168 | } |
1231 | } |
1169 | } |
1232 | |
1170 | |
1233 | old_width = szHint.width; |
1171 | old_width = szHint.width; |
1234 | old_height = szHint.height; |
1172 | old_height = szHint.height; |
1235 | |
1173 | |
1236 | #ifdef XPM_BACKGROUND |
1174 | #ifdef XPM_BACKGROUND |
1237 | if (TermWin.pixmap) |
1175 | if (pixmap) |
1238 | scr_touch (false); |
1176 | scr_touch (false); |
1239 | #endif |
1177 | #endif |
1240 | |
1178 | |
1241 | #ifdef USE_XIM |
1179 | #ifdef USE_XIM |
1242 | IMSetStatusPosition (); |
1180 | IMSetStatusPosition (); |
… | |
… | |
1246 | /* |
1184 | /* |
1247 | * Set the width/height of the vt window in characters. Units are pixels. |
1185 | * Set the width/height of the vt window in characters. Units are pixels. |
1248 | * good for toggling 80/132 columns |
1186 | * good for toggling 80/132 columns |
1249 | */ |
1187 | */ |
1250 | void |
1188 | void |
1251 | rxvt_term::set_widthheight (unsigned int width, unsigned int height) |
1189 | rxvt_term::set_widthheight (unsigned int newwidth, unsigned int newheight) |
1252 | { |
1190 | { |
1253 | XWindowAttributes wattr; |
1191 | XWindowAttributes wattr; |
1254 | |
1192 | |
1255 | if (width == 0 || height == 0) |
1193 | if (newwidth == 0 || newheight == 0) |
1256 | { |
1194 | { |
1257 | XGetWindowAttributes (display->display, display->root, &wattr); |
1195 | XGetWindowAttributes (display->display, display->root, &wattr); |
|
|
1196 | |
1258 | if (width == 0) |
1197 | if (newwidth == 0) |
1259 | width = wattr.width - szHint.base_width; |
1198 | newwidth = wattr.width - szHint.base_width; |
1260 | if (height == 0) |
1199 | if (newheight == 0) |
1261 | height = wattr.height - szHint.base_height; |
1200 | newheight = wattr.height - szHint.base_height; |
1262 | } |
|
|
1263 | |
|
|
1264 | if (width != TermWin.width || height != TermWin.height) |
|
|
1265 | { |
1201 | } |
|
|
1202 | |
|
|
1203 | if (newwidth != width || newheight != height) |
|
|
1204 | { |
1266 | width += szHint.base_width; |
1205 | newwidth += szHint.base_width; |
1267 | height += szHint.base_height; |
1206 | newheight += szHint.base_height; |
1268 | resize_all_windows (width, height, 0); |
1207 | resize_all_windows (newwidth, newheight, 0); |
1269 | } |
1208 | } |
1270 | } |
1209 | } |
1271 | |
1210 | |
1272 | /* -------------------------------------------------------------------- * |
1211 | /* -------------------------------------------------------------------- * |
1273 | * - X INPUT METHOD ROUTINES - * |
1212 | * - X INPUT METHOD ROUTINES - * |
… | |
… | |
1283 | |
1222 | |
1284 | void |
1223 | void |
1285 | rxvt_term::im_set_size (XRectangle &size) |
1224 | rxvt_term::im_set_size (XRectangle &size) |
1286 | { |
1225 | { |
1287 | // the int_bwidth terms make no sense to me |
1226 | // the int_bwidth terms make no sense to me |
1288 | size.x = TermWin.int_bwidth; |
1227 | size.x = int_bwidth; |
1289 | size.y = TermWin.int_bwidth; |
1228 | size.y = int_bwidth; |
1290 | size.width = Width2Pixel (TermWin.ncol) + TermWin.int_bwidth; |
1229 | size.width = Width2Pixel (ncol) + int_bwidth; |
1291 | size.height = Height2Pixel (TermWin.nrow) + TermWin.int_bwidth; |
1230 | size.height = Height2Pixel (nrow) + int_bwidth; |
1292 | } |
1231 | } |
1293 | |
1232 | |
1294 | void |
1233 | void |
1295 | rxvt_term::im_set_preedit_area (XRectangle &preedit_rect, |
1234 | rxvt_term::im_set_preedit_area (XRectangle &preedit_rect, |
1296 | XRectangle &status_rect, |
1235 | XRectangle &status_rect, |
1297 | const XRectangle &needed_rect) |
1236 | const XRectangle &needed_rect) |
1298 | { |
1237 | { |
1299 | preedit_rect.x = needed_rect.width; |
1238 | preedit_rect.x = needed_rect.width; |
1300 | preedit_rect.y = 0; |
1239 | preedit_rect.y = 0; |
1301 | preedit_rect.width = Width2Pixel (TermWin.ncol) - needed_rect.width + 1; |
1240 | preedit_rect.width = Width2Pixel (ncol) - needed_rect.width + 1; |
1302 | preedit_rect.height = TermWin.fheight; |
1241 | preedit_rect.height = fheight; |
1303 | |
1242 | |
1304 | status_rect.x = 0; |
1243 | status_rect.x = 0; |
1305 | status_rect.y = 0; |
1244 | status_rect.y = 0; |
1306 | status_rect.width = needed_rect.width ? needed_rect.width : Width2Pixel (TermWin.ncol) + 1; |
1245 | status_rect.width = needed_rect.width ? needed_rect.width : Width2Pixel (ncol) + 1; |
1307 | status_rect.height = TermWin.fheight; |
1246 | status_rect.height = fheight; |
1308 | } |
1247 | } |
1309 | |
1248 | |
1310 | /* Checking whether input method is running. */ |
1249 | /* Checking whether input method is running. */ |
1311 | bool |
1250 | bool |
1312 | rxvt_term::IMisRunning () |
1251 | rxvt_term::IMisRunning () |
… | |
… | |
1340 | { |
1279 | { |
1341 | XPoint nspot; |
1280 | XPoint nspot; |
1342 | XVaNestedList preedit_attr; |
1281 | XVaNestedList preedit_attr; |
1343 | |
1282 | |
1344 | if (!Input_Context |
1283 | if (!Input_Context |
1345 | || !TermWin.focus |
1284 | || !focus |
1346 | || !(input_style & XIMPreeditPosition)) |
1285 | || !(input_style & XIMPreeditPosition)) |
1347 | return; |
1286 | return; |
1348 | |
1287 | |
1349 | im_set_position (nspot); |
1288 | im_set_position (nspot); |
1350 | |
1289 | |
… | |
… | |
1386 | XRectangle rect, status_rect, needed_rect; |
1325 | XRectangle rect, status_rect, needed_rect; |
1387 | unsigned long fg, bg; |
1326 | unsigned long fg, bg; |
1388 | const char *p; |
1327 | const char *p; |
1389 | char **s; |
1328 | char **s; |
1390 | XIMStyles *xim_styles; |
1329 | XIMStyles *xim_styles; |
|
|
1330 | |
|
|
1331 | set_environ (envv); |
1391 | |
1332 | |
1392 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1333 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1393 | return false; |
1334 | return false; |
1394 | |
1335 | |
1395 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
1336 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
… | |
… | |
1470 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1411 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1471 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1412 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1472 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1413 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1473 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1414 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1474 | "*", |
1415 | "*", |
1475 | TermWin.fheight, |
1416 | fheight, |
1476 | TermWin.fheight + 1, TermWin.fheight - 1, |
1417 | fheight + 1, fheight - 1, |
1477 | TermWin.fheight - 2, TermWin.fheight + 2); |
1418 | fheight - 2, fheight + 2); |
1478 | |
1419 | |
1479 | fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat, |
1420 | fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat, |
1480 | &missing_charset_list, &missing_charset_count, &def_string); |
1421 | &missing_charset_list, &missing_charset_count, &def_string); |
1481 | |
1422 | |
1482 | if (missing_charset_list) |
1423 | if (missing_charset_list) |
… | |
… | |
1528 | NULL); |
1469 | NULL); |
1529 | } |
1470 | } |
1530 | |
1471 | |
1531 | Input_Context = XCreateIC (xim, |
1472 | Input_Context = XCreateIC (xim, |
1532 | XNInputStyle, input_style, |
1473 | XNInputStyle, input_style, |
1533 | XNClientWindow, TermWin.vt, |
1474 | XNClientWindow, vt, |
1534 | XNFocusWindow, TermWin.parent[0], |
1475 | XNFocusWindow, parent[0], |
1535 | preedit_attr ? XNPreeditAttributes : NULL, |
1476 | preedit_attr ? XNPreeditAttributes : NULL, |
1536 | preedit_attr, |
1477 | preedit_attr, |
1537 | status_attr ? XNStatusAttributes : NULL, |
1478 | status_attr ? XNStatusAttributes : NULL, |
1538 | status_attr, NULL); |
1479 | status_attr, NULL); |
1539 | |
1480 | |
… | |
… | |
1556 | } |
1497 | } |
1557 | |
1498 | |
1558 | void |
1499 | void |
1559 | rxvt_term::im_cb () |
1500 | rxvt_term::im_cb () |
1560 | { |
1501 | { |
1561 | int i, found, had_im; |
1502 | int i; |
1562 | const char *p; |
1503 | const char *p; |
1563 | char **s; |
1504 | char **s; |
1564 | char buf[IMBUFSIZ]; |
1505 | char buf[IMBUFSIZ]; |
1565 | |
1506 | |
1566 | SET_R (this); |
1507 | make_current (); |
1567 | |
1508 | |
1568 | im_destroy (); |
1509 | im_destroy (); |
1569 | |
1510 | |
1570 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1511 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1571 | if (Input_Context) |
1512 | if (Input_Context) |
… | |
… | |
1623 | { |
1564 | { |
1624 | XRectangle preedit_rect, status_rect, *needed_rect; |
1565 | XRectangle preedit_rect, status_rect, *needed_rect; |
1625 | XVaNestedList preedit_attr, status_attr; |
1566 | XVaNestedList preedit_attr, status_attr; |
1626 | |
1567 | |
1627 | if (!Input_Context |
1568 | if (!Input_Context |
1628 | || !TermWin.focus |
1569 | || !focus |
1629 | || !(input_style & XIMPreeditArea) |
1570 | || !(input_style & XIMPreeditArea) |
1630 | || !IMisRunning ()) |
1571 | || !IMisRunning ()) |
1631 | return; |
1572 | return; |
1632 | |
1573 | |
1633 | /* Getting the necessary width of preedit area */ |
1574 | /* Getting the necessary width of preedit area */ |