… | |
… | |
174 | |
174 | |
175 | delete this; |
175 | delete this; |
176 | } |
176 | } |
177 | |
177 | |
178 | /*----------------------------------------------------------------------*/ |
178 | /*----------------------------------------------------------------------*/ |
179 | /* rxvt_init() */ |
179 | /* rxvt_init () */ |
180 | /* LIBPROTO */ |
180 | /* LIBPROTO */ |
181 | rxvt_t |
181 | rxvt_t |
182 | rxvt_init (int argc, const char *const *argv) |
182 | rxvt_init (int argc, const char *const *argv) |
183 | { |
183 | { |
184 | SET_R (new rxvt_term); |
184 | SET_R (new rxvt_term); |
… | |
… | |
190 | } |
190 | } |
191 | |
191 | |
192 | return GET_R; |
192 | return GET_R; |
193 | } |
193 | } |
194 | |
194 | |
195 | static int (*old_xerror_handler)(Display *dpy, XErrorEvent *event); |
195 | static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event); |
196 | |
196 | |
197 | void |
197 | void |
198 | rxvt_init_signals () |
198 | rxvt_init_signals () |
199 | { |
199 | { |
200 | /* install exit handler for cleanup */ |
200 | /* install exit handler for cleanup */ |
201 | #if 0 |
201 | #if 0 |
202 | #ifdef HAVE_ATEXIT |
202 | #ifdef HAVE_ATEXIT |
203 | atexit(rxvt_clean_exit); |
203 | atexit (rxvt_clean_exit); |
204 | #else |
204 | #else |
205 | #endif |
205 | #endif |
206 | #endif |
206 | #endif |
207 | |
207 | |
208 | struct sigaction sa; |
208 | struct sigaction sa; |
… | |
… | |
259 | Gr_reset (); /* reset graphics */ |
259 | Gr_reset (); /* reset graphics */ |
260 | #endif |
260 | #endif |
261 | |
261 | |
262 | #if 0 |
262 | #if 0 |
263 | #ifdef DEBUG_X |
263 | #ifdef DEBUG_X |
264 | XSynchronize(display->display, True); |
264 | XSynchronize (display->display, True); |
265 | #endif |
265 | #endif |
266 | #endif |
266 | #endif |
267 | |
267 | |
268 | #ifdef HAVE_SCROLLBARS |
268 | #ifdef HAVE_SCROLLBARS |
269 | if (Options & Opt_scrollBar) |
269 | if (Options & Opt_scrollBar) |
270 | resize_scrollbar (); /* create and map scrollbar */ |
270 | resize_scrollbar (); /* create and map scrollbar */ |
271 | #endif |
271 | #endif |
272 | #if (MENUBAR_MAX) |
272 | #if (MENUBAR_MAX) |
273 | if (menubar_visible(r)) |
273 | if (menubar_visible (r)) |
274 | XMapWindow (display->display, menuBar.win); |
274 | XMapWindow (display->display, menuBar.win); |
275 | #endif |
275 | #endif |
276 | #ifdef TRANSPARENT |
276 | #ifdef TRANSPARENT |
277 | if (Options & Opt_transparent) |
277 | if (Options & Opt_transparent) |
278 | { |
278 | { |
… | |
… | |
303 | * Catch a SIGCHLD signal and exit if the direct child has died |
303 | * Catch a SIGCHLD signal and exit if the direct child has died |
304 | */ |
304 | */ |
305 | /* ARGSUSED */ |
305 | /* ARGSUSED */ |
306 | /* EXTPROTO */ |
306 | /* EXTPROTO */ |
307 | RETSIGTYPE |
307 | RETSIGTYPE |
308 | rxvt_Child_signal(int sig __attribute__ ((unused))) |
308 | rxvt_Child_signal (int sig __attribute__ ((unused))) |
309 | { |
309 | { |
310 | int pid, save_errno = errno; |
310 | int pid, save_errno = errno; |
311 | while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) |
311 | while ((pid = waitpid (-1, NULL, WNOHANG)) == -1 && errno == EINTR) |
312 | ; |
312 | ; |
313 | errno = save_errno; |
313 | errno = save_errno; |
… | |
… | |
321 | /* |
321 | /* |
322 | * Catch a fatal signal and tidy up before quitting |
322 | * Catch a fatal signal and tidy up before quitting |
323 | */ |
323 | */ |
324 | /* EXTPROTO */ |
324 | /* EXTPROTO */ |
325 | RETSIGTYPE |
325 | RETSIGTYPE |
326 | rxvt_Exit_signal(int sig) |
326 | rxvt_Exit_signal (int sig) |
327 | { |
327 | { |
328 | signal (sig, SIG_DFL); |
328 | signal (sig, SIG_DFL); |
329 | #ifdef DEBUG_CMD |
329 | #ifdef DEBUG_CMD |
330 | rxvt_print_error ("signal %d", sig); |
330 | rxvt_print_error ("signal %d", sig); |
331 | #endif |
331 | #endif |
332 | rxvt_clean_exit(); |
332 | rxvt_clean_exit (); |
333 | kill (getpid (), sig); |
333 | kill (getpid (), sig); |
334 | } |
334 | } |
335 | |
335 | |
336 | /* INTPROTO */ |
336 | /* INTPROTO */ |
337 | int |
337 | int |
… | |
… | |
365 | /* ------------------------------------------------------------------------- * |
365 | /* ------------------------------------------------------------------------- * |
366 | * MEMORY ALLOCATION WRAPPERS * |
366 | * MEMORY ALLOCATION WRAPPERS * |
367 | * ------------------------------------------------------------------------- */ |
367 | * ------------------------------------------------------------------------- */ |
368 | /* EXTPROTO */ |
368 | /* EXTPROTO */ |
369 | void * |
369 | void * |
370 | rxvt_malloc(size_t size) |
370 | rxvt_malloc (size_t size) |
371 | { |
371 | { |
372 | void *p; |
372 | void *p; |
373 | |
373 | |
374 | p = malloc(size); |
374 | p = malloc (size); |
375 | if (p) |
375 | if (p) |
376 | return p; |
376 | return p; |
377 | |
377 | |
378 | fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); |
378 | fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); |
379 | rxvt_clean_exit(); |
379 | rxvt_clean_exit (); |
380 | exit(EXIT_FAILURE); |
380 | exit (EXIT_FAILURE); |
381 | /* NOTREACHED */ |
381 | /* NOTREACHED */ |
382 | } |
382 | } |
383 | |
383 | |
384 | /* EXTPROTO */ |
384 | /* EXTPROTO */ |
385 | void * |
385 | void * |
386 | rxvt_calloc(size_t number, size_t size) |
386 | rxvt_calloc (size_t number, size_t size) |
387 | { |
387 | { |
388 | void *p; |
388 | void *p; |
389 | |
389 | |
390 | p = calloc(number, size); |
390 | p = calloc (number, size); |
391 | if (p) |
391 | if (p) |
392 | return p; |
392 | return p; |
393 | |
393 | |
394 | fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); |
394 | fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); |
395 | rxvt_clean_exit(); |
395 | rxvt_clean_exit (); |
396 | exit(EXIT_FAILURE); |
396 | exit (EXIT_FAILURE); |
397 | /* NOTREACHED */ |
397 | /* NOTREACHED */ |
398 | } |
398 | } |
399 | |
399 | |
400 | /* EXTPROTO */ |
400 | /* EXTPROTO */ |
401 | void * |
401 | void * |
402 | rxvt_realloc(void *ptr, size_t size) |
402 | rxvt_realloc (void *ptr, size_t size) |
403 | { |
403 | { |
404 | void *p; |
404 | void *p; |
405 | |
405 | |
406 | if (ptr) |
406 | if (ptr) |
407 | p = realloc(ptr, size); |
407 | p = realloc (ptr, size); |
408 | else |
408 | else |
409 | p = malloc(size); |
409 | p = malloc (size); |
410 | if (p) |
410 | if (p) |
411 | return p; |
411 | return p; |
412 | |
412 | |
413 | fprintf(stderr, APL_NAME ": memory allocation failure. Aborting"); |
413 | fprintf (stderr, APL_NAME ": memory allocation failure. Aborting"); |
414 | rxvt_clean_exit(); |
414 | rxvt_clean_exit (); |
415 | exit(EXIT_FAILURE); |
415 | exit (EXIT_FAILURE); |
416 | /* NOTREACHED */ |
416 | /* NOTREACHED */ |
417 | } |
417 | } |
418 | |
418 | |
419 | /* ------------------------------------------------------------------------- * |
419 | /* ------------------------------------------------------------------------- * |
420 | * PRIVILEGED OPERATIONS * |
420 | * PRIVILEGED OPERATIONS * |
… | |
… | |
423 | void |
423 | void |
424 | rxvt_term::privileges (int mode) |
424 | rxvt_term::privileges (int mode) |
425 | { |
425 | { |
426 | #if ! defined(__CYGWIN32__) |
426 | #if ! defined(__CYGWIN32__) |
427 | # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
427 | # if !defined(HAVE_SETEUID) && defined(HAVE_SETREUID) |
428 | /* setreuid() is the poor man's setuid(), seteuid() */ |
428 | /* setreuid () is the poor man's setuid (), seteuid () */ |
429 | # define seteuid(a) setreuid(-1, (a)) |
429 | # define seteuid(a) setreuid(-1, (a)) |
430 | # define setegid(a) setregid(-1, (a)) |
430 | # define setegid(a) setregid(-1, (a)) |
431 | # define HAVE_SETEUID |
431 | # define HAVE_SETEUID |
432 | # endif |
432 | # endif |
433 | # ifdef HAVE_SETEUID |
433 | # ifdef HAVE_SETEUID |
… | |
… | |
436 | case IGNORE: |
436 | case IGNORE: |
437 | /* |
437 | /* |
438 | * change effective uid/gid - not real uid/gid - so we can switch |
438 | * change effective uid/gid - not real uid/gid - so we can switch |
439 | * back to root later, as required |
439 | * back to root later, as required |
440 | */ |
440 | */ |
441 | seteuid(getuid()); |
441 | seteuid (getuid ()); |
442 | setegid(getgid()); |
442 | setegid (getgid ()); |
443 | break; |
443 | break; |
444 | case SAVE: |
444 | case SAVE: |
445 | euid = geteuid(); |
445 | euid = geteuid (); |
446 | egid = getegid(); |
446 | egid = getegid (); |
447 | break; |
447 | break; |
448 | case RESTORE: |
448 | case RESTORE: |
449 | seteuid(euid); |
449 | seteuid (euid); |
450 | setegid(egid); |
450 | setegid (egid); |
451 | break; |
451 | break; |
452 | } |
452 | } |
453 | # else |
453 | # else |
454 | switch (mode) |
454 | switch (mode) |
455 | { |
455 | { |
456 | case IGNORE: |
456 | case IGNORE: |
457 | setuid(getuid()); |
457 | setuid (getuid ()); |
458 | setgid(getgid()); |
458 | setgid (getgid ()); |
459 | /* FALLTHROUGH */ |
459 | /* FALLTHROUGH */ |
460 | case SAVE: |
460 | case SAVE: |
461 | /* FALLTHROUGH */ |
461 | /* FALLTHROUGH */ |
462 | case RESTORE: |
462 | case RESTORE: |
463 | break; |
463 | break; |
… | |
… | |
468 | |
468 | |
469 | #ifdef UTMP_SUPPORT |
469 | #ifdef UTMP_SUPPORT |
470 | void |
470 | void |
471 | rxvt_term::privileged_utmp (char action) |
471 | rxvt_term::privileged_utmp (char action) |
472 | { |
472 | { |
473 | D_MAIN((stderr, "rxvt_privileged_utmp(%c); waiting for: %c (pid: %d)", |
473 | D_MAIN ((stderr, "rxvt_privileged_utmp (%c); waiting for: %c (pid: %d)", |
474 | action, next_utmp_action, getpid())); |
474 | action, next_utmp_action, getpid ())); |
475 | if (next_utmp_action != action || (action != SAVE && action != RESTORE) |
475 | if (next_utmp_action != action || (action != SAVE && action != RESTORE) |
476 | || (Options & Opt_utmpInhibit) |
476 | || (Options & Opt_utmpInhibit) |
477 | || ttydev == NULL || *ttydev == '\0') |
477 | || ttydev == NULL || *ttydev == '\0') |
478 | return; |
478 | return; |
479 | |
479 | |
… | |
… | |
494 | |
494 | |
495 | #ifndef NO_SETOWNER_TTYDEV |
495 | #ifndef NO_SETOWNER_TTYDEV |
496 | void |
496 | void |
497 | rxvt_term::privileged_ttydev (char action) |
497 | rxvt_term::privileged_ttydev (char action) |
498 | { |
498 | { |
499 | D_MAIN((stderr, |
499 | D_MAIN ((stderr, |
500 | "privileged_ttydev (%c); waiting for: %c (pid: %d)", |
500 | "privileged_ttydev (%c); waiting for: %c (pid: %d)", |
501 | action, next_tty_action, getpid())); |
501 | action, next_tty_action, getpid ())); |
502 | if (next_tty_action != action || (action != SAVE && action != RESTORE) |
502 | if (next_tty_action != action || (action != SAVE && action != RESTORE) |
503 | || ttydev == NULL || *ttydev == '\0') |
503 | || ttydev == NULL || *ttydev == '\0') |
504 | return; |
504 | return; |
505 | |
505 | |
506 | privileges (RESTORE); |
506 | privileges (RESTORE); |
507 | |
507 | |
508 | if (action == SAVE) |
508 | if (action == SAVE) |
509 | { |
509 | { |
510 | next_tty_action = RESTORE; |
510 | next_tty_action = RESTORE; |
511 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
511 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
512 | /* store original tty status for restoration rxvt_clean_exit() -- rgg 04/12/95 */ |
512 | /* store original tty status for restoration rxvt_clean_exit () -- rgg 04/12/95 */ |
513 | if (lstat(ttydev, &ttyfd_stat) < 0) /* you lose out */ |
513 | if (lstat (ttydev, &ttyfd_stat) < 0) /* you lose out */ |
514 | next_tty_action = IGNORE; |
514 | next_tty_action = IGNORE; |
515 | else |
515 | else |
516 | # endif |
516 | # endif |
517 | |
517 | |
518 | { |
518 | { |
519 | chown(ttydev, getuid(), ttygid); /* fail silently */ |
519 | chown (ttydev, getuid (), ttygid); /* fail silently */ |
520 | chmod(ttydev, ttymode); |
520 | chmod (ttydev, ttymode); |
521 | # ifdef HAVE_REVOKE |
521 | # ifdef HAVE_REVOKE |
522 | revoke(ttydev); |
522 | revoke (ttydev); |
523 | # endif |
523 | # endif |
524 | |
524 | |
525 | } |
525 | } |
526 | } |
526 | } |
527 | else |
527 | else |
528 | { /* action == RESTORE */ |
528 | { /* action == RESTORE */ |
529 | next_tty_action = IGNORE; |
529 | next_tty_action = IGNORE; |
530 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
530 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
531 | chmod(ttydev, ttyfd_stat.st_mode); |
531 | chmod (ttydev, ttyfd_stat.st_mode); |
532 | chown(ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid); |
532 | chown (ttydev, ttyfd_stat.st_uid, ttyfd_stat.st_gid); |
533 | # else |
533 | # else |
534 | chmod(ttydev, |
534 | chmod (ttydev, |
535 | (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); |
535 | (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)); |
536 | chown(ttydev, 0, 0); |
536 | chown (ttydev, 0, 0); |
537 | # endif |
537 | # endif |
538 | |
538 | |
539 | } |
539 | } |
540 | |
540 | |
541 | privileges (IGNORE); |
541 | privileges (IGNORE); |
542 | |
542 | |
543 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
543 | # ifndef RESET_TTY_TO_COMMON_DEFAULTS |
544 | D_MAIN((stderr, "%s \"%s\": mode %03o, uid %d, gid %d", |
544 | D_MAIN ((stderr, "%s \"%s\": mode %03o, uid %d, gid %d", |
545 | action == RESTORE ? "Restoring" : (action == |
545 | action == RESTORE ? "Restoring" : (action == |
546 | SAVE ? "Saving" : |
546 | SAVE ? "Saving" : |
547 | "UNKNOWN ERROR for"), ttydev, |
547 | "UNKNOWN ERROR for"), ttydev, |
548 | ttyfd_stat.st_mode, ttyfd_stat.st_uid, |
548 | ttyfd_stat.st_mode, ttyfd_stat.st_uid, |
549 | ttyfd_stat.st_gid)); |
549 | ttyfd_stat.st_gid)); |
… | |
… | |
562 | short recalc_x, recalc_y; |
562 | short recalc_x, recalc_y; |
563 | int x, y, sb_w, mb_h, flags; |
563 | int x, y, sb_w, mb_h, flags; |
564 | unsigned int w, h; |
564 | unsigned int w, h; |
565 | unsigned int max_width, max_height; |
565 | unsigned int max_width, max_height; |
566 | |
566 | |
567 | D_SIZE((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
567 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
568 | TermWin.ncol, TermWin.nrow, szHint.width, |
568 | TermWin.ncol, TermWin.nrow, szHint.width, |
569 | szHint.height)); |
569 | szHint.height)); |
570 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
570 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
571 | szHint.win_gravity = NorthWestGravity; |
571 | szHint.win_gravity = NorthWestGravity; |
572 | /* szHint.min_aspect.x = szHint.min_aspect.y = 1; */ |
572 | /* szHint.min_aspect.x = szHint.min_aspect.y = 1; */ |
… | |
… | |
575 | flags = 0; |
575 | flags = 0; |
576 | if (!parsed_geometry) |
576 | if (!parsed_geometry) |
577 | { |
577 | { |
578 | parsed_geometry = 1; |
578 | parsed_geometry = 1; |
579 | if (rs[Rs_geometry]) |
579 | if (rs[Rs_geometry]) |
580 | flags = XParseGeometry(rs[Rs_geometry], &x, &y, &w, &h); |
580 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
581 | if (flags & WidthValue) |
581 | if (flags & WidthValue) |
582 | { |
582 | { |
583 | TermWin.ncol = BOUND_POSITIVE_INT16(w); |
583 | TermWin.ncol = BOUND_POSITIVE_INT16 (w); |
584 | szHint.flags |= USSize; |
584 | szHint.flags |= USSize; |
585 | } |
585 | } |
586 | if (flags & HeightValue) |
586 | if (flags & HeightValue) |
587 | { |
587 | { |
588 | TermWin.nrow = BOUND_POSITIVE_INT16(h); |
588 | TermWin.nrow = BOUND_POSITIVE_INT16 (h); |
589 | szHint.flags |= USSize; |
589 | szHint.flags |= USSize; |
590 | } |
590 | } |
591 | if (flags & XValue) |
591 | if (flags & XValue) |
592 | { |
592 | { |
593 | szHint.x = x; |
593 | szHint.x = x; |
… | |
… | |
622 | |
622 | |
623 | sb_w = mb_h = 0; |
623 | sb_w = mb_h = 0; |
624 | window_vt_x = window_vt_y = 0; |
624 | window_vt_x = window_vt_y = 0; |
625 | if (scrollbar_visible ()) |
625 | if (scrollbar_visible ()) |
626 | { |
626 | { |
627 | sb_w = scrollbar_TotalWidth(); |
627 | sb_w = scrollbar_TotalWidth (); |
628 | szHint.base_width += sb_w; |
628 | szHint.base_width += sb_w; |
629 | if (!(Options & Opt_scrollBar_right)) |
629 | if (! (Options & Opt_scrollBar_right)) |
630 | window_vt_x = sb_w; |
630 | window_vt_x = sb_w; |
631 | } |
631 | } |
632 | if (menubar_visible ()) |
632 | if (menubar_visible ()) |
633 | { |
633 | { |
634 | mb_h = menuBar_TotalHeight(); |
634 | mb_h = menuBar_TotalHeight (); |
635 | szHint.base_height += mb_h; |
635 | szHint.base_height += mb_h; |
636 | window_vt_y = mb_h; |
636 | window_vt_y = mb_h; |
637 | } |
637 | } |
638 | szHint.width_inc = TermWin.fwidth; |
638 | szHint.width_inc = TermWin.fwidth; |
639 | szHint.height_inc = TermWin.fheight; |
639 | szHint.height_inc = TermWin.fheight; |
… | |
… | |
645 | szHint.width = width; |
645 | szHint.width = width; |
646 | TermWin.width = width - szHint.base_width; |
646 | TermWin.width = width - szHint.base_width; |
647 | } |
647 | } |
648 | else |
648 | else |
649 | { |
649 | { |
650 | MIN_IT(TermWin.width, max_width); |
650 | MIN_IT (TermWin.width, max_width); |
651 | szHint.width = szHint.base_width + TermWin.width; |
651 | szHint.width = szHint.base_width + TermWin.width; |
652 | } |
652 | } |
653 | if (height && height - szHint.base_height < max_height) |
653 | if (height && height - szHint.base_height < max_height) |
654 | { |
654 | { |
655 | szHint.height = height; |
655 | szHint.height = height; |
656 | TermWin.height = height - szHint.base_height; |
656 | TermWin.height = height - szHint.base_height; |
657 | } |
657 | } |
658 | else |
658 | else |
659 | { |
659 | { |
660 | MIN_IT(TermWin.height, max_height); |
660 | MIN_IT (TermWin.height, max_height); |
661 | szHint.height = szHint.base_height + TermWin.height; |
661 | szHint.height = szHint.base_height + TermWin.height; |
662 | } |
662 | } |
663 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
663 | if (scrollbar_visible () && (Options & Opt_scrollBar_right)) |
664 | window_sb_x = szHint.width - sb_w; |
664 | window_sb_x = szHint.width - sb_w; |
665 | |
665 | |
… | |
… | |
670 | szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) |
670 | szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) |
671 | - szHint.height - 2 * TermWin.ext_bwidth); |
671 | - szHint.height - 2 * TermWin.ext_bwidth); |
672 | |
672 | |
673 | TermWin.ncol = TermWin.width / TermWin.fwidth; |
673 | TermWin.ncol = TermWin.width / TermWin.fwidth; |
674 | TermWin.nrow = TermWin.height / TermWin.fheight; |
674 | TermWin.nrow = TermWin.height / TermWin.fheight; |
675 | D_SIZE((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
675 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
676 | TermWin.ncol, TermWin.nrow, szHint.width, |
676 | TermWin.ncol, TermWin.nrow, szHint.width, |
677 | szHint.height)); |
677 | szHint.height)); |
678 | return; |
678 | return; |
679 | } |
679 | } |
680 | |
680 | |
… | |
… | |
696 | ws.ws_xpixel = ws.ws_ypixel = 0; |
696 | ws.ws_xpixel = ws.ws_ypixel = 0; |
697 | #ifndef DEBUG_SIZE |
697 | #ifndef DEBUG_SIZE |
698 | (void)ioctl (cmd_fd, TIOCSWINSZ, &ws); |
698 | (void)ioctl (cmd_fd, TIOCSWINSZ, &ws); |
699 | #else |
699 | #else |
700 | if (ioctl (cmd_fd, TIOCSWINSZ, &ws) < 0) |
700 | if (ioctl (cmd_fd, TIOCSWINSZ, &ws) < 0) |
701 | D_SIZE((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); |
701 | D_SIZE ((stderr, "Failed to send TIOCSWINSZ to fd %d", fd)); |
702 | # ifdef SIGWINCH |
702 | # ifdef SIGWINCH |
703 | else if (cmd_pid) /* force through to the command */ |
703 | else if (cmd_pid) /* force through to the command */ |
704 | kill (cmd_pid, SIGWINCH); |
704 | kill (cmd_pid, SIGWINCH); |
705 | # endif |
705 | # endif |
706 | #endif |
706 | #endif |
707 | } |
707 | } |
708 | |
708 | |
709 | /*----------------------------------------------------------------------*/ |
709 | /*----------------------------------------------------------------------*/ |
710 | /* rxvt_change_font() - Switch to a new font */ |
710 | /* rxvt_change_font () - Switch to a new font */ |
711 | /* |
711 | /* |
712 | * init = 1 - initialize |
712 | * init = 1 - initialize |
713 | * |
713 | * |
714 | * fontname == FONT_UP - switch to bigger font |
714 | * fontname == FONT_UP - switch to bigger font |
715 | * fontname == FONT_DN - switch to smaller font |
715 | * fontname == FONT_DN - switch to smaller font |
… | |
… | |
727 | /* xterm sequences - title, iconName, color (exptl) */ |
727 | /* xterm sequences - title, iconName, color (exptl) */ |
728 | void |
728 | void |
729 | rxvt_term::set_title (const char *str) |
729 | rxvt_term::set_title (const char *str) |
730 | { |
730 | { |
731 | #ifndef SMART_WINDOW_TITLE |
731 | #ifndef SMART_WINDOW_TITLE |
732 | XStoreName(display->display, TermWin.parent[0], str); |
732 | XStoreName (display->display, TermWin.parent[0], str); |
733 | #else |
733 | #else |
734 | char *name; |
734 | char *name; |
735 | |
735 | |
736 | if (XFetchName(display->display, TermWin.parent[0], &name) == 0) |
736 | if (XFetchName (display->display, TermWin.parent[0], &name) == 0) |
737 | name = NULL; |
737 | name = NULL; |
738 | if (name == NULL || STRCMP(name, str)) |
738 | if (name == NULL || STRCMP (name, str)) |
739 | XStoreName(display->display, TermWin.parent[0], str); |
739 | XStoreName (display->display, TermWin.parent[0], str); |
740 | if (name) |
740 | if (name) |
741 | XFree(name); |
741 | XFree (name); |
742 | #endif |
742 | #endif |
743 | } |
743 | } |
744 | |
744 | |
745 | void |
745 | void |
746 | rxvt_term::set_iconName (const char *str) |
746 | rxvt_term::set_iconName (const char *str) |
747 | { |
747 | { |
748 | #ifndef SMART_WINDOW_TITLE |
748 | #ifndef SMART_WINDOW_TITLE |
749 | XSetIconName(display->display, TermWin.parent[0], str); |
749 | XSetIconName (display->display, TermWin.parent[0], str); |
750 | #else |
750 | #else |
751 | char *name; |
751 | char *name; |
752 | |
752 | |
753 | if (XGetIconName(display->display, TermWin.parent[0], &name)) |
753 | if (XGetIconName (display->display, TermWin.parent[0], &name)) |
754 | name = NULL; |
754 | name = NULL; |
755 | if (name == NULL || STRCMP(name, str)) |
755 | if (name == NULL || STRCMP (name, str)) |
756 | XSetIconName(display->display, TermWin.parent[0], str); |
756 | XSetIconName (display->display, TermWin.parent[0], str); |
757 | if (name) |
757 | if (name) |
758 | XFree(name); |
758 | XFree (name); |
759 | #endif |
759 | #endif |
760 | } |
760 | } |
761 | |
761 | |
762 | #ifdef XTERM_COLOR_CHANGE |
762 | #ifdef XTERM_COLOR_CHANGE |
763 | void |
763 | void |
… | |
… | |
768 | |
768 | |
769 | if (color == NULL || *color == '\0') |
769 | if (color == NULL || *color == '\0') |
770 | return; |
770 | return; |
771 | |
771 | |
772 | /* handle color aliases */ |
772 | /* handle color aliases */ |
773 | if (isdigit(*color)) |
773 | if (isdigit (*color)) |
774 | { |
774 | { |
775 | i = atoi(color); |
775 | i = atoi (color); |
776 | if (i >= 8 && i <= 15) |
776 | if (i >= 8 && i <= 15) |
777 | { /* bright colors */ |
777 | { /* bright colors */ |
778 | i -= 8; |
778 | i -= 8; |
779 | # ifndef NO_BRIGHTCOLOR |
779 | # ifndef NO_BRIGHTCOLOR |
780 | PixColors[idx] = PixColors[minBrightCOLOR + i]; |
780 | PixColors[idx] = PixColors[minBrightCOLOR + i]; |
781 | SET_PIXCOLOR(idx); |
781 | SET_PIXCOLOR (idx); |
782 | goto Done; |
782 | goto Done; |
783 | # endif |
783 | # endif |
784 | |
784 | |
785 | } |
785 | } |
786 | if (i >= 0 && i <= 7) |
786 | if (i >= 0 && i <= 7) |
787 | { /* normal colors */ |
787 | { /* normal colors */ |
788 | PixColors[idx] = PixColors[minCOLOR + i]; |
788 | PixColors[idx] = PixColors[minCOLOR + i]; |
789 | SET_PIXCOLOR(idx); |
789 | SET_PIXCOLOR (idx); |
790 | goto Done; |
790 | goto Done; |
791 | } |
791 | } |
792 | } |
792 | } |
793 | if (!rXParseAllocColor (& xcol, color)) |
793 | if (!rXParseAllocColor (& xcol, color)) |
794 | return; |
794 | return; |
… | |
… | |
803 | if (PixColors[idx] == PixColors[i]) |
803 | if (PixColors[idx] == PixColors[i]) |
804 | break; |
804 | break; |
805 | if (i > Color_White) |
805 | if (i > Color_White) |
806 | { |
806 | { |
807 | /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ |
807 | /* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */ |
808 | XFreeColors(display->display, XCMAP, (PixColors + idx), 1, |
808 | XFreeColors (display->display, XCMAP, (PixColors + idx), 1, |
809 | DisplayPlanes(display->display, display->screen)); |
809 | DisplayPlanes (display->display, display->screen)); |
810 | } |
810 | } |
811 | # endif |
811 | # endif |
812 | |
812 | |
813 | PixColors[idx] = xcol; |
813 | PixColors[idx] = xcol; |
814 | SET_PIXCOLOR(idx); |
814 | SET_PIXCOLOR (idx); |
815 | |
815 | |
816 | /* XSetWindowAttributes attr; */ |
816 | /* XSetWindowAttributes attr; */ |
817 | /* Cursor cursor; */ |
817 | /* Cursor cursor; */ |
818 | Done: |
818 | Done: |
819 | if (idx == Color_bg && !(Options & Opt_transparent)) |
819 | if (idx == Color_bg && ! (Options & Opt_transparent)) |
820 | XSetWindowBackground(display->display, TermWin.vt, |
820 | XSetWindowBackground (display->display, TermWin.vt, |
821 | PixColors[Color_bg]); |
821 | PixColors[Color_bg]); |
822 | |
822 | |
823 | /* handle Color_BD, scrollbar background, etc. */ |
823 | /* handle Color_BD, scrollbar background, etc. */ |
824 | |
824 | |
825 | set_colorfgbg (); |
825 | set_colorfgbg (); |
… | |
… | |
839 | rxvt_color xcol[2]; |
839 | rxvt_color xcol[2]; |
840 | |
840 | |
841 | xcol[0] = PixColors[Color_pointer]; |
841 | xcol[0] = PixColors[Color_pointer]; |
842 | xcol[1] = PixColors[Color_bg]; |
842 | xcol[1] = PixColors[Color_bg]; |
843 | XQueryColors (display->display, XCMAP, xcol, 2); |
843 | XQueryColors (display->display, XCMAP, xcol, 2); |
844 | XRecolorCursor (display->display, TermWin_cursor, &(xcol[0]), &(xcol[1])); |
844 | XRecolorCursor (display->display, TermWin_cursor, & (xcol[0]), & (xcol[1])); |
845 | #endif |
845 | #endif |
846 | } |
846 | } |
847 | |
847 | |
848 | /*----------------------------------------------------------------------*/ |
848 | /*----------------------------------------------------------------------*/ |
849 | /* |
849 | /* |
… | |
… | |
852 | void |
852 | void |
853 | rxvt_term::set_colorfgbg () |
853 | rxvt_term::set_colorfgbg () |
854 | { |
854 | { |
855 | unsigned int i; |
855 | unsigned int i; |
856 | const char *xpmb = "\0"; |
856 | const char *xpmb = "\0"; |
857 | char fstr[sizeof("default") + 1], bstr[sizeof("default") + 1]; |
857 | char fstr[sizeof ("default") + 1], bstr[sizeof ("default") + 1]; |
858 | |
858 | |
859 | env_colorfgbg = |
859 | env_colorfgbg = |
860 | (char *)rxvt_malloc(sizeof("COLORFGBG=default;default;bg") + 1); |
860 | (char *)rxvt_malloc (sizeof ("COLORFGBG=default;default;bg") + 1); |
861 | STRCPY(fstr, "default"); |
861 | STRCPY (fstr, "default"); |
862 | STRCPY(bstr, "default"); |
862 | STRCPY (bstr, "default"); |
863 | for (i = Color_Black; i <= Color_White; i++) |
863 | for (i = Color_Black; i <= Color_White; i++) |
864 | if (PixColors[Color_fg] == PixColors[i]) |
864 | if (PixColors[Color_fg] == PixColors[i]) |
865 | { |
865 | { |
866 | sprintf(fstr, "%d", (i - Color_Black)); |
866 | sprintf (fstr, "%d", (i - Color_Black)); |
867 | break; |
867 | break; |
868 | } |
868 | } |
869 | for (i = Color_Black; i <= Color_White; i++) |
869 | for (i = Color_Black; i <= Color_White; i++) |
870 | if (PixColors[Color_bg] == PixColors[i]) |
870 | if (PixColors[Color_bg] == PixColors[i]) |
871 | { |
871 | { |
872 | sprintf(bstr, "%d", (i - Color_Black)); |
872 | sprintf (bstr, "%d", (i - Color_Black)); |
873 | #ifdef XPM_BACKGROUND |
873 | #ifdef XPM_BACKGROUND |
874 | xpmb = "default;"; |
874 | xpmb = "default;"; |
875 | #endif |
875 | #endif |
876 | break; |
876 | break; |
877 | } |
877 | } |
878 | sprintf(env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); |
878 | sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); |
879 | putenv(env_colorfgbg); |
879 | putenv (env_colorfgbg); |
880 | |
880 | |
881 | #ifndef NO_BRIGHTCOLOR |
881 | #ifndef NO_BRIGHTCOLOR |
882 | colorfgbg = DEFAULT_RSTYLE; |
882 | colorfgbg = DEFAULT_RSTYLE; |
883 | for (i = minCOLOR; i <= maxCOLOR; i++) |
883 | for (i = minCOLOR; i <= maxCOLOR; i++) |
884 | { |
884 | { |
885 | if (PixColors[Color_fg] == PixColors[i]) |
885 | if (PixColors[Color_fg] == PixColors[i]) |
886 | colorfgbg = SET_FGCOLOR(colorfgbg, i); |
886 | colorfgbg = SET_FGCOLOR (colorfgbg, i); |
887 | if (PixColors[Color_bg] == PixColors[i]) |
887 | if (PixColors[Color_bg] == PixColors[i]) |
888 | colorfgbg = SET_BGCOLOR(colorfgbg, i); |
888 | colorfgbg = SET_BGCOLOR (colorfgbg, i); |
889 | } |
889 | } |
890 | #endif |
890 | #endif |
891 | } |
891 | } |
892 | |
892 | |
893 | /*----------------------------------------------------------------------*/ |
893 | /*----------------------------------------------------------------------*/ |
… | |
… | |
899 | int |
899 | int |
900 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
900 | rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) |
901 | { |
901 | { |
902 | if (!screen_in_out->set (display, colour)) |
902 | if (!screen_in_out->set (display, colour)) |
903 | { |
903 | { |
904 | rxvt_print_error("can't allocate colour: %s", colour); |
904 | rxvt_print_error ("can't allocate colour: %s", colour); |
905 | return false; |
905 | return false; |
906 | } |
906 | } |
907 | |
907 | |
908 | return true; |
908 | return true; |
909 | } |
909 | } |
… | |
… | |
1015 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
1015 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
1016 | curr_screen = scr_change_screen (PRIMARY); |
1016 | curr_screen = scr_change_screen (PRIMARY); |
1017 | TermWin.ncol = ncol; |
1017 | TermWin.ncol = ncol; |
1018 | } |
1018 | } |
1019 | |
1019 | |
1020 | scr_reset(); |
1020 | scr_reset (); |
1021 | |
1021 | |
1022 | if (curr_screen >= 0) /* this is not the first time through */ |
1022 | if (curr_screen >= 0) /* this is not the first time through */ |
1023 | { |
1023 | { |
1024 | scr_change_screen (curr_screen); |
1024 | scr_change_screen (curr_screen); |
1025 | selection_check (old_ncol != TermWin.ncol ? 4 : 0); |
1025 | selection_check (old_ncol != TermWin.ncol ? 4 : 0); |
… | |
… | |
1043 | { |
1043 | { |
1044 | XWindowAttributes wattr; |
1044 | XWindowAttributes wattr; |
1045 | |
1045 | |
1046 | if (width == 0 || height == 0) |
1046 | if (width == 0 || height == 0) |
1047 | { |
1047 | { |
1048 | XGetWindowAttributes(display->display, display->root, &wattr); |
1048 | XGetWindowAttributes (display->display, display->root, &wattr); |
1049 | if (width == 0) |
1049 | if (width == 0) |
1050 | width = wattr.width - szHint.base_width; |
1050 | width = wattr.width - szHint.base_width; |
1051 | if (height == 0) |
1051 | if (height == 0) |
1052 | height = wattr.height - szHint.base_height; |
1052 | height = wattr.height - szHint.base_height; |
1053 | } |
1053 | } |
… | |
… | |
1067 | void |
1067 | void |
1068 | rxvt_term::im_set_size (XRectangle *size) |
1068 | rxvt_term::im_set_size (XRectangle *size) |
1069 | { |
1069 | { |
1070 | size->x = TermWin.int_bwidth; |
1070 | size->x = TermWin.int_bwidth; |
1071 | size->y = TermWin.int_bwidth; |
1071 | size->y = TermWin.int_bwidth; |
1072 | size->width = Width2Pixel(TermWin.ncol); |
1072 | size->width = Width2Pixel (TermWin.ncol); |
1073 | size->height = Height2Pixel(TermWin.nrow); |
1073 | size->height = Height2Pixel (TermWin.nrow); |
1074 | } |
1074 | } |
1075 | |
1075 | |
1076 | void |
1076 | void |
1077 | rxvt_term::im_set_color (unsigned long *fg, unsigned long *bg) |
1077 | rxvt_term::im_set_color (unsigned long *fg, unsigned long *bg) |
1078 | { |
1078 | { |
… | |
… | |
1088 | Atom atom; |
1088 | Atom atom; |
1089 | Window win; |
1089 | Window win; |
1090 | char server[IMBUFSIZ]; |
1090 | char server[IMBUFSIZ]; |
1091 | |
1091 | |
1092 | /* get current locale modifier */ |
1092 | /* get current locale modifier */ |
1093 | if ((p = XSetLocaleModifiers(NULL)) != NULL) |
1093 | if ((p = XSetLocaleModifiers (NULL)) != NULL) |
1094 | { |
1094 | { |
1095 | STRCPY(server, "@server="); |
1095 | STRCPY (server, "@server="); |
1096 | STRNCAT(server, &(p[4]), IMBUFSIZ - 9); /* skip "@im=" */ |
1096 | STRNCAT (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ |
1097 | if ((p = STRCHR(server + 1, '@')) != NULL) /* first one only */ |
1097 | if ((p = STRCHR (server + 1, '@')) != NULL) /* first one only */ |
1098 | *p = '\0'; |
1098 | *p = '\0'; |
1099 | |
1099 | |
1100 | atom = XInternAtom(display->display, server, False); |
1100 | atom = XInternAtom (display->display, server, False); |
1101 | win = XGetSelectionOwner(display->display, atom); |
1101 | win = XGetSelectionOwner (display->display, atom); |
1102 | if (win != None) |
1102 | if (win != None) |
1103 | return True; |
1103 | return True; |
1104 | } |
1104 | } |
1105 | return False; |
1105 | return False; |
1106 | } |
1106 | } |
… | |
… | |
1110 | { |
1110 | { |
1111 | XPoint spot; |
1111 | XPoint spot; |
1112 | XVaNestedList preedit_attr; |
1112 | XVaNestedList preedit_attr; |
1113 | |
1113 | |
1114 | if (Input_Context == NULL |
1114 | if (Input_Context == NULL |
1115 | || !TermWin.focus || !(input_style & XIMPreeditPosition) |
1115 | || !TermWin.focus || ! (input_style & XIMPreeditPosition) |
1116 | || !(event_type == KeyPress |
1116 | || ! (event_type == KeyPress |
1117 | || event_type == Expose |
1117 | || event_type == Expose |
1118 | || event_type == NoExpose |
1118 | || event_type == NoExpose |
1119 | || event_type == SelectionNotify |
1119 | || event_type == SelectionNotify |
1120 | || event_type == ButtonRelease || event_type == FocusIn) |
1120 | || event_type == ButtonRelease || event_type == FocusIn) |
1121 | || !IMisRunning ()) |
1121 | || !IMisRunning ()) |
1122 | return; |
1122 | return; |
1123 | |
1123 | |
1124 | im_set_position (&spot); |
1124 | im_set_position (&spot); |
1125 | |
1125 | |
1126 | preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); |
1126 | preedit_attr = XVaCreateNestedList (0, XNSpotLocation, &spot, NULL); |
1127 | XSetICValues(Input_Context, XNPreeditAttributes, preedit_attr, NULL); |
1127 | XSetICValues (Input_Context, XNPreeditAttributes, preedit_attr, NULL); |
1128 | XFree(preedit_attr); |
1128 | XFree (preedit_attr); |
1129 | } |
1129 | } |
1130 | |
1130 | |
1131 | void |
1131 | void |
1132 | rxvt_term::im_set_preedit_area (XRectangle * preedit_rect, XRectangle * status_rect, |
1132 | rxvt_term::im_set_preedit_area (XRectangle * preedit_rect, XRectangle * status_rect, |
1133 | XRectangle * needed_rect) |
1133 | XRectangle * needed_rect) |
1134 | { |
1134 | { |
1135 | int mbh, vtx = 0; |
1135 | int mbh, vtx = 0; |
1136 | |
1136 | |
1137 | if (scrollbar_visible () && !(Options & Opt_scrollBar_right)) |
1137 | if (scrollbar_visible () && ! (Options & Opt_scrollBar_right)) |
1138 | vtx = scrollbar_TotalWidth(); |
1138 | vtx = scrollbar_TotalWidth (); |
1139 | |
1139 | |
1140 | mbh = menubar_visible () ? menuBar_TotalHeight() : 0; |
1140 | mbh = menubar_visible () ? menuBar_TotalHeight () : 0; |
1141 | mbh -= TermWin.lineSpace; |
1141 | mbh -= TermWin.lineSpace; |
1142 | |
1142 | |
1143 | preedit_rect->x = needed_rect->width + vtx; |
1143 | preedit_rect->x = needed_rect->width + vtx; |
1144 | preedit_rect->y = Height2Pixel(TermWin.nrow - 1) + mbh; |
1144 | preedit_rect->y = Height2Pixel (TermWin.nrow - 1) + mbh; |
1145 | |
1145 | |
1146 | preedit_rect->width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width + vtx; |
1146 | preedit_rect->width = Width2Pixel (TermWin.ncol + 1) - needed_rect->width + vtx; |
1147 | preedit_rect->height = Height2Pixel(1); |
1147 | preedit_rect->height = Height2Pixel (1); |
1148 | |
1148 | |
1149 | status_rect->x = vtx; |
1149 | status_rect->x = vtx; |
1150 | status_rect->y = Height2Pixel(TermWin.nrow - 1) + mbh; |
1150 | status_rect->y = Height2Pixel (TermWin.nrow - 1) + mbh; |
1151 | |
1151 | |
1152 | status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel(TermWin.ncol + 1); |
1152 | status_rect->width = needed_rect->width ? needed_rect->width : Width2Pixel (TermWin.ncol + 1); |
1153 | status_rect->height = Height2Pixel(1); |
1153 | status_rect->height = Height2Pixel (1); |
1154 | } |
1154 | } |
1155 | |
1155 | |
1156 | void |
1156 | void |
1157 | rxvt_term::im_destroy () |
1157 | rxvt_term::im_destroy () |
1158 | { |
1158 | { |
… | |
… | |
1184 | const char *p; |
1184 | const char *p; |
1185 | char **s; |
1185 | char **s; |
1186 | XIMStyles *xim_styles; |
1186 | XIMStyles *xim_styles; |
1187 | XVaNestedList preedit_attr, status_attr; |
1187 | XVaNestedList preedit_attr, status_attr; |
1188 | |
1188 | |
1189 | if (!((p = XSetLocaleModifiers (modifiers)) && *p)) |
1189 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1190 | return false; |
1190 | return false; |
1191 | |
1191 | |
1192 | D_MAIN((stderr, "rxvt_IM_get_IC()")); |
1192 | D_MAIN ((stderr, "rxvt_IM_get_IC ()")); |
1193 | input_method = display->get_xim (locale, modifiers); |
1193 | input_method = display->get_xim (locale, modifiers); |
1194 | if (input_method == NULL) |
1194 | if (input_method == NULL) |
1195 | return false; |
1195 | return false; |
1196 | |
1196 | |
1197 | xim = input_method->xim; |
1197 | xim = input_method->xim; |
… | |
… | |
1203 | display->put_xim (input_method); |
1203 | display->put_xim (input_method); |
1204 | return false; |
1204 | return false; |
1205 | } |
1205 | } |
1206 | |
1206 | |
1207 | p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root"; |
1207 | p = rs[Rs_preeditType] ? rs[Rs_preeditType] : "OverTheSpot,OffTheSpot,Root"; |
1208 | s = rxvt_splitcommastring(p); |
1208 | s = rxvt_splitcommastring (p); |
1209 | for (i = found = 0; !found && s[i]; i++) |
1209 | for (i = found = 0; !found && s[i]; i++) |
1210 | { |
1210 | { |
1211 | if (!STRCMP(s[i], "OverTheSpot")) |
1211 | if (!STRCMP (s[i], "OverTheSpot")) |
1212 | input_style = (XIMPreeditPosition | XIMStatusNothing); |
1212 | input_style = (XIMPreeditPosition | XIMStatusNothing); |
1213 | else if (!STRCMP(s[i], "OffTheSpot")) |
1213 | else if (!STRCMP (s[i], "OffTheSpot")) |
1214 | input_style = (XIMPreeditArea | XIMStatusArea); |
1214 | input_style = (XIMPreeditArea | XIMStatusArea); |
1215 | else if (!STRCMP(s[i], "Root")) |
1215 | else if (!STRCMP (s[i], "Root")) |
1216 | input_style = (XIMPreeditNothing | XIMStatusNothing); |
1216 | input_style = (XIMPreeditNothing | XIMStatusNothing); |
1217 | |
1217 | |
1218 | for (j = 0; j < xim_styles->count_styles; j++) |
1218 | for (j = 0; j < xim_styles->count_styles; j++) |
1219 | if (input_style == xim_styles->supported_styles[j]) |
1219 | if (input_style == xim_styles->supported_styles[j]) |
1220 | { |
1220 | { |
… | |
… | |
1241 | { |
1241 | { |
1242 | im_set_size (&rect); |
1242 | im_set_size (&rect); |
1243 | im_set_position (&spot); |
1243 | im_set_position (&spot); |
1244 | im_set_color (&fg, &bg); |
1244 | im_set_color (&fg, &bg); |
1245 | |
1245 | |
1246 | preedit_attr = XVaCreateNestedList(0, XNArea, &rect, |
1246 | preedit_attr = XVaCreateNestedList (0, XNArea, &rect, |
1247 | XNSpotLocation, &spot, |
1247 | XNSpotLocation, &spot, |
1248 | XNForeground, fg, XNBackground, bg, |
1248 | XNForeground, fg, XNBackground, bg, |
1249 | //XNFontSet, TermWin.fontset, |
1249 | //XNFontSet, TermWin.fontset, |
1250 | NULL); |
1250 | NULL); |
1251 | } |
1251 | } |
… | |
… | |
1259 | */ |
1259 | */ |
1260 | needed_rect.width = 0; |
1260 | needed_rect.width = 0; |
1261 | |
1261 | |
1262 | im_set_preedit_area (&rect, &status_rect, &needed_rect); |
1262 | im_set_preedit_area (&rect, &status_rect, &needed_rect); |
1263 | |
1263 | |
1264 | preedit_attr = XVaCreateNestedList(0, XNArea, &rect, |
1264 | preedit_attr = XVaCreateNestedList (0, XNArea, &rect, |
1265 | XNForeground, fg, XNBackground, bg, |
1265 | XNForeground, fg, XNBackground, bg, |
1266 | //XNFontSet, TermWin.fontset, |
1266 | //XNFontSet, TermWin.fontset, |
1267 | NULL); |
1267 | NULL); |
1268 | status_attr = XVaCreateNestedList(0, XNArea, &status_rect, |
1268 | status_attr = XVaCreateNestedList (0, XNArea, &status_rect, |
1269 | XNForeground, fg, XNBackground, bg, |
1269 | XNForeground, fg, XNBackground, bg, |
1270 | //XNFontSet, TermWin.fontset, |
1270 | //XNFontSet, TermWin.fontset, |
1271 | NULL); |
1271 | NULL); |
1272 | } |
1272 | } |
1273 | |
1273 | |
1274 | Input_Context = XCreateIC(xim, XNInputStyle, input_style, |
1274 | Input_Context = XCreateIC (xim, XNInputStyle, input_style, |
1275 | XNClientWindow, TermWin.parent[0], |
1275 | XNClientWindow, TermWin.parent[0], |
1276 | XNFocusWindow, TermWin.parent[0], |
1276 | XNFocusWindow, TermWin.parent[0], |
1277 | preedit_attr ? XNPreeditAttributes : NULL, |
1277 | preedit_attr ? XNPreeditAttributes : NULL, |
1278 | preedit_attr, |
1278 | preedit_attr, |
1279 | status_attr ? XNStatusAttributes : NULL, |
1279 | status_attr ? XNStatusAttributes : NULL, |
1280 | status_attr, NULL); |
1280 | status_attr, NULL); |
1281 | if (preedit_attr) XFree(preedit_attr); |
1281 | if (preedit_attr) XFree (preedit_attr); |
1282 | if (status_attr) XFree(status_attr); |
1282 | if (status_attr) XFree (status_attr); |
1283 | |
1283 | |
1284 | if (Input_Context == NULL) |
1284 | if (Input_Context == NULL) |
1285 | { |
1285 | { |
1286 | rxvt_print_error("failed to create input context"); |
1286 | rxvt_print_error ("failed to create input context"); |
1287 | display->put_xim (input_method); |
1287 | display->put_xim (input_method); |
1288 | return false; |
1288 | return false; |
1289 | } |
1289 | } |
1290 | |
1290 | |
1291 | if (input_style & XIMPreeditArea) |
1291 | if (input_style & XIMPreeditArea) |
1292 | IMSetStatusPosition (); |
1292 | IMSetStatusPosition (); |
1293 | |
1293 | |
1294 | D_MAIN((stderr, "rxvt_IM_get_IC() - successful connection")); |
1294 | D_MAIN ((stderr, "rxvt_IM_get_IC () - successful connection")); |
1295 | return true; |
1295 | return true; |
1296 | } |
1296 | } |
1297 | |
1297 | |
1298 | void |
1298 | void |
1299 | rxvt_term::im_cb () |
1299 | rxvt_term::im_cb () |
… | |
… | |
1303 | char **s; |
1303 | char **s; |
1304 | char buf[IMBUFSIZ]; |
1304 | char buf[IMBUFSIZ]; |
1305 | |
1305 | |
1306 | im_destroy (); |
1306 | im_destroy (); |
1307 | |
1307 | |
1308 | D_MAIN((stderr, "rxvt_IMInstantiateCallback()")); |
1308 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1309 | if (Input_Context) |
1309 | if (Input_Context) |
1310 | return; |
1310 | return; |
1311 | |
1311 | |
1312 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1312 | #if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE) |
1313 | if (rs[Rs_imLocale]) |
1313 | if (rs[Rs_imLocale]) |
… | |
… | |
1332 | break; |
1332 | break; |
1333 | } |
1333 | } |
1334 | } |
1334 | } |
1335 | } |
1335 | } |
1336 | for (i = 0; s[i]; i++) |
1336 | for (i = 0; s[i]; i++) |
1337 | free(s[i]); |
1337 | free (s[i]); |
1338 | free(s); |
1338 | free (s); |
1339 | |
1339 | |
1340 | if (found) |
1340 | if (found) |
1341 | goto done; |
1341 | goto done; |
1342 | } |
1342 | } |
1343 | |
1343 | |
… | |
… | |
1361 | { |
1361 | { |
1362 | XRectangle preedit_rect, status_rect, *needed_rect; |
1362 | XRectangle preedit_rect, status_rect, *needed_rect; |
1363 | XVaNestedList preedit_attr, status_attr; |
1363 | XVaNestedList preedit_attr, status_attr; |
1364 | |
1364 | |
1365 | if (Input_Context == NULL |
1365 | if (Input_Context == NULL |
1366 | || !TermWin.focus || !(input_style & XIMPreeditArea) |
1366 | || !TermWin.focus || ! (input_style & XIMPreeditArea) |
1367 | || !IMisRunning ()) |
1367 | || !IMisRunning ()) |
1368 | return; |
1368 | return; |
1369 | |
1369 | |
1370 | /* Getting the necessary width of preedit area */ |
1370 | /* Getting the necessary width of preedit area */ |
1371 | status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL); |
1371 | status_attr = XVaCreateNestedList (0, XNAreaNeeded, &needed_rect, NULL); |
1372 | XGetICValues(Input_Context, XNStatusAttributes, status_attr, NULL); |
1372 | XGetICValues (Input_Context, XNStatusAttributes, status_attr, NULL); |
1373 | XFree(status_attr); |
1373 | XFree (status_attr); |
1374 | |
1374 | |
1375 | im_set_preedit_area (&preedit_rect, &status_rect, needed_rect); |
1375 | im_set_preedit_area (&preedit_rect, &status_rect, needed_rect); |
1376 | |
1376 | |
1377 | preedit_attr = XVaCreateNestedList(0, XNArea, &preedit_rect, NULL); |
1377 | preedit_attr = XVaCreateNestedList (0, XNArea, &preedit_rect, NULL); |
1378 | status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL); |
1378 | status_attr = XVaCreateNestedList (0, XNArea, &status_rect, NULL); |
1379 | |
1379 | |
1380 | XSetICValues(Input_Context, |
1380 | XSetICValues (Input_Context, |
1381 | XNPreeditAttributes, preedit_attr, |
1381 | XNPreeditAttributes, preedit_attr, |
1382 | XNStatusAttributes, status_attr, NULL); |
1382 | XNStatusAttributes, status_attr, NULL); |
1383 | |
1383 | |
1384 | XFree(preedit_attr); |
1384 | XFree (preedit_attr); |
1385 | XFree(status_attr); |
1385 | XFree (status_attr); |
1386 | } |
1386 | } |
1387 | #endif /* USE_XIM */ |
1387 | #endif /* USE_XIM */ |
1388 | |
1388 | |
1389 | /*----------------------------------------------------------------------*/ |
1389 | /*----------------------------------------------------------------------*/ |
1390 | rxvt_t rxvt_current_term; |
1390 | rxvt_t rxvt_current_term; |