… | |
… | |
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 | |
|
|
36 | #include <limits> |
36 | |
37 | |
37 | #include <csignal> |
38 | #include <csignal> |
38 | #include <cstring> |
39 | #include <cstring> |
39 | |
40 | |
40 | #ifdef TTY_GID_SUPPORT |
41 | #ifdef TTY_GID_SUPPORT |
… | |
… | |
158 | pointer_ev (this, &rxvt_term::pointer_cb), |
159 | pointer_ev (this, &rxvt_term::pointer_cb), |
159 | #endif |
160 | #endif |
160 | #ifdef USE_XIM |
161 | #ifdef USE_XIM |
161 | im_ev (this, &rxvt_term::im_cb), |
162 | im_ev (this, &rxvt_term::im_cb), |
162 | #endif |
163 | #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), |
164 | termwin_ev (this, &rxvt_term::x_cb), |
167 | vt_ev (this, &rxvt_term::x_cb), |
165 | vt_ev (this, &rxvt_term::x_cb), |
168 | check_ev (this, &rxvt_term::check_cb), |
166 | check_ev (this, &rxvt_term::check_cb), |
169 | flush_ev (this, &rxvt_term::flush_cb), |
167 | flush_ev (this, &rxvt_term::flush_cb), |
170 | destroy_ev (this, &rxvt_term::destroy_cb), |
168 | destroy_ev (this, &rxvt_term::destroy_cb), |
… | |
… | |
203 | |
201 | |
204 | emergency_cleanup (); |
202 | emergency_cleanup (); |
205 | |
203 | |
206 | #if ENABLE_STYLES |
204 | #if ENABLE_STYLES |
207 | for (int i = RS_styleCount; --i; ) |
205 | for (int i = RS_styleCount; --i; ) |
208 | if (TermWin.fontset[i] != TermWin.fontset[0]) |
206 | if (fontset[i] != fontset[0]) |
209 | delete TermWin.fontset[i]; |
207 | delete fontset[i]; |
210 | #endif |
208 | #endif |
211 | delete TermWin.fontset[0]; |
209 | delete fontset[0]; |
212 | |
210 | |
213 | if (display) |
211 | if (display) |
214 | { |
212 | { |
215 | dDisp; |
213 | dDisp; |
216 | |
214 | |
… | |
… | |
244 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
242 | #if defined(MENUBAR) || defined(RXVT_SCROLLBAR) |
245 | if (topShadowGC) XFreeGC (disp, topShadowGC); |
243 | if (topShadowGC) XFreeGC (disp, topShadowGC); |
246 | if (botShadowGC) XFreeGC (disp, botShadowGC); |
244 | if (botShadowGC) XFreeGC (disp, botShadowGC); |
247 | if (scrollbarGC) XFreeGC (disp, scrollbarGC); |
245 | if (scrollbarGC) XFreeGC (disp, scrollbarGC); |
248 | #endif |
246 | #endif |
249 | if (TermWin.gc) XFreeGC (disp, TermWin.gc); |
247 | if (gc) XFreeGC (disp, gc); |
250 | |
248 | |
251 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
249 | #if defined(MENUBAR) && (MENUBAR_MAX > 1) |
252 | delete menuBar.drawable; |
250 | delete menuBar.drawable; |
253 | //if (menuBar.win) |
251 | //if (menuBar.win) |
254 | // XDestroyWindow (disp, menuBar.win); |
252 | // XDestroyWindow (disp, menuBar.win); |
255 | #endif |
253 | #endif |
256 | delete TermWin.drawable; |
254 | delete drawable; |
257 | // destroy all windows |
255 | // destroy all windows |
258 | if (TermWin.parent[0]) |
256 | if (parent[0]) |
259 | XDestroyWindow (disp, TermWin.parent[0]); |
257 | XDestroyWindow (disp, parent[0]); |
260 | } |
258 | } |
261 | |
259 | |
262 | // TODO: free pixcolours, colours should become part of rxvt_display |
260 | // TODO: free pixcolours, colours should become part of rxvt_display |
263 | |
261 | |
264 | delete pix_colors_focused; |
262 | delete pix_colors_focused; |
265 | #ifdef OFF_FOCUS_FADING |
263 | #if OFF_FOCUS_FADING |
266 | delete pix_colors_unfocused; |
264 | delete pix_colors_unfocused; |
267 | #endif |
265 | #endif |
268 | |
266 | |
269 | displays.put (display); |
267 | displays.put (display); |
270 | |
268 | |
… | |
… | |
288 | delete argv; |
286 | delete argv; |
289 | |
287 | |
290 | #ifdef KEYSYM_RESOURCE |
288 | #ifdef KEYSYM_RESOURCE |
291 | delete keyboard; |
289 | delete keyboard; |
292 | #endif |
290 | #endif |
|
|
291 | } |
|
|
292 | |
|
|
293 | void |
|
|
294 | rxvt_term::child_exit () |
|
|
295 | { |
|
|
296 | cmd_pid = 0; |
|
|
297 | |
|
|
298 | if (!(options & Opt_hold)) |
|
|
299 | destroy (); |
293 | } |
300 | } |
294 | |
301 | |
295 | void |
302 | void |
296 | rxvt_term::destroy () |
303 | rxvt_term::destroy () |
297 | { |
304 | { |
… | |
… | |
418 | { |
425 | { |
419 | if (GET_R->allowedxerror == -1) |
426 | if (GET_R->allowedxerror == -1) |
420 | GET_R->allowedxerror = event->error_code; |
427 | GET_R->allowedxerror = event->error_code; |
421 | else |
428 | else |
422 | { |
429 | { |
423 | //TODO: GET_R is most likely not the terminal which caused the error |
430 | // GET_R is most likely not the terminal which caused the error, |
424 | //TODO: maybe just output the error and continue? |
431 | // so just output the error and continue |
425 | #if ENABLE_FRILLS |
432 | #if ENABLE_FRILLS |
426 | print_x_error (display, event); |
433 | print_x_error (display, event); |
427 | #else |
434 | #else |
428 | old_xerror_handler (display, event); |
435 | old_xerror_handler (display, event); |
429 | #endif |
436 | #endif |
… | |
… | |
439 | DisplayString (display)); |
446 | DisplayString (display)); |
440 | rxvt_emergency_cleanup (); |
447 | rxvt_emergency_cleanup (); |
441 | _exit (EXIT_FAILURE); |
448 | _exit (EXIT_FAILURE); |
442 | } |
449 | } |
443 | |
450 | |
444 | /* |
|
|
445 | * Catch a fatal signal and tidy up before quitting |
|
|
446 | */ |
|
|
447 | void |
|
|
448 | rxvt_term::sig_term (sig_watcher &w) |
|
|
449 | { |
|
|
450 | #ifdef DEBUG_CMD |
|
|
451 | rxvt_warn ("caught signal %d, exiting.\n", w.signum); |
|
|
452 | #endif |
|
|
453 | rxvt_emergency_cleanup (); |
|
|
454 | signal (w.signum, SIG_DFL); |
|
|
455 | kill (getpid (), w.signum); |
|
|
456 | } |
|
|
457 | |
|
|
458 | /*----------------------------------------------------------------------*/ |
451 | /*----------------------------------------------------------------------*/ |
459 | /* rxvt_init () */ |
|
|
460 | bool |
452 | bool |
461 | rxvt_term::init (int argc, const char *const *argv) |
453 | rxvt_term::init (int argc, const char *const *argv) |
462 | { |
454 | { |
463 | SET_R (this); |
455 | SET_R (this); |
464 | |
456 | |
… | |
… | |
510 | check_our_parents (); |
502 | check_our_parents (); |
511 | rootwin_ev.start (display, display->root); |
503 | rootwin_ev.start (display, display->root); |
512 | } |
504 | } |
513 | #endif |
505 | #endif |
514 | |
506 | |
515 | XMapWindow (disp, TermWin.vt); |
507 | XMapWindow (disp, vt); |
516 | XMapWindow (disp, TermWin.parent[0]); |
508 | XMapWindow (disp, parent[0]); |
517 | |
509 | |
518 | set_colorfgbg (); |
510 | set_colorfgbg (); |
519 | |
511 | |
520 | init_command (cmd_argv); |
512 | init_command (cmd_argv); |
521 | |
513 | |
… | |
… | |
525 | |
517 | |
526 | check_ev.start (); |
518 | check_ev.start (); |
527 | |
519 | |
528 | return true; |
520 | return true; |
529 | } |
521 | } |
|
|
522 | |
|
|
523 | static struct sig_handlers |
|
|
524 | { |
|
|
525 | sig_watcher sw_chld, sw_term, sw_int; |
|
|
526 | |
|
|
527 | void sig_chld (sig_watcher &w) |
|
|
528 | { |
|
|
529 | // we are being called for every SIGCHLD, find the corresponding term |
|
|
530 | int pid; |
|
|
531 | |
|
|
532 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
|
|
533 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
|
|
534 | if (pid == (*t)->cmd_pid) |
|
|
535 | { |
|
|
536 | (*t)->child_exit (); |
|
|
537 | break; |
|
|
538 | } |
|
|
539 | } |
|
|
540 | |
|
|
541 | /* |
|
|
542 | * Catch a fatal signal and tidy up before quitting |
|
|
543 | */ |
|
|
544 | void |
|
|
545 | sig_term (sig_watcher &w) |
|
|
546 | { |
|
|
547 | #ifdef DEBUG_CMD |
|
|
548 | rxvt_warn ("caught signal %d, exiting.\n", w.signum); |
|
|
549 | #endif |
|
|
550 | rxvt_emergency_cleanup (); |
|
|
551 | signal (w.signum, SIG_DFL); |
|
|
552 | kill (getpid (), w.signum); |
|
|
553 | } |
|
|
554 | |
|
|
555 | sig_handlers () |
|
|
556 | : sw_chld (this, &sig_handlers::sig_chld), |
|
|
557 | sw_term (this, &sig_handlers::sig_term), |
|
|
558 | sw_int (this, &sig_handlers::sig_term) |
|
|
559 | { |
|
|
560 | } |
|
|
561 | } sig_handlers; |
530 | |
562 | |
531 | void |
563 | void |
532 | rxvt_init () |
564 | rxvt_init () |
533 | { |
565 | { |
534 | /* |
566 | /* |
… | |
… | |
542 | rxvt_privileges (IGNORE); |
574 | rxvt_privileges (IGNORE); |
543 | |
575 | |
544 | signal (SIGHUP, SIG_IGN); |
576 | signal (SIGHUP, SIG_IGN); |
545 | signal (SIGPIPE, SIG_IGN); |
577 | signal (SIGPIPE, SIG_IGN); |
546 | |
578 | |
|
|
579 | sig_handlers.sw_chld.start (SIGCHLD); |
|
|
580 | sig_handlers.sw_term.start (SIGTERM); |
|
|
581 | sig_handlers.sw_int.start (SIGINT); |
|
|
582 | |
547 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
583 | /* need to trap SIGURG for SVR4 (Unixware) rlogin */ |
548 | /* signal (SIGURG, SIG_DFL); */ |
584 | /* signal (SIGURG, SIG_DFL); */ |
549 | |
585 | |
550 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
586 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
551 | // TODO: handle this with exceptions and tolerate the memory loss |
587 | // TODO: handle this with exceptions and tolerate the memory loss |
552 | XSetIOErrorHandler (rxvt_xioerror_handler); |
588 | XSetIOErrorHandler (rxvt_xioerror_handler); |
553 | } |
|
|
554 | |
|
|
555 | /* ------------------------------------------------------------------------- * |
|
|
556 | * SIGNAL HANDLING & EXIT HANDLER * |
|
|
557 | * ------------------------------------------------------------------------- */ |
|
|
558 | /* |
|
|
559 | * Catch a SIGCHLD signal and exit if the direct child has died |
|
|
560 | */ |
|
|
561 | |
|
|
562 | void |
|
|
563 | rxvt_term::sig_chld (sig_watcher &w) |
|
|
564 | { |
|
|
565 | // we are being called for every SIGCHLD, not just ours |
|
|
566 | int pid; |
|
|
567 | |
|
|
568 | while ((pid = waitpid (-1, NULL, WNOHANG)) > 0) |
|
|
569 | for (rxvt_term **t = termlist.begin (); t < termlist.end (); t++) |
|
|
570 | if (pid == (*t)->cmd_pid) |
|
|
571 | { |
|
|
572 | (*t)->destroy (); |
|
|
573 | break; |
|
|
574 | } |
|
|
575 | } |
589 | } |
576 | |
590 | |
577 | /* ------------------------------------------------------------------------- * |
591 | /* ------------------------------------------------------------------------- * |
578 | * MEMORY ALLOCATION WRAPPERS * |
592 | * MEMORY ALLOCATION WRAPPERS * |
579 | * ------------------------------------------------------------------------- */ |
593 | * ------------------------------------------------------------------------- */ |
… | |
… | |
586 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
600 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
587 | |
601 | |
588 | return p; |
602 | return p; |
589 | } |
603 | } |
590 | |
604 | |
591 | /* INTPROTO */ |
605 | void * |
592 | void * |
|
|
593 | rxvt_calloc (size_t number, size_t size) |
606 | rxvt_calloc (size_t number, size_t size) |
594 | { |
607 | { |
595 | void *p = calloc (number, size); |
608 | void *p = calloc (number, size); |
596 | |
609 | |
597 | if (!p) |
610 | if (!p) |
598 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
611 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
599 | |
612 | |
600 | return p; |
613 | return p; |
601 | } |
614 | } |
602 | |
615 | |
603 | /* INTPROTO */ |
|
|
604 | void * |
616 | void * |
605 | rxvt_realloc (void *ptr, size_t size) |
617 | rxvt_realloc (void *ptr, size_t size) |
606 | { |
618 | { |
607 | void *p = realloc (ptr, size); |
619 | void *p = realloc (ptr, size); |
608 | |
620 | |
… | |
… | |
690 | /* |
702 | /* |
691 | * window size/position calculcations for XSizeHint and other storage. |
703 | * window size/position calculcations for XSizeHint and other storage. |
692 | * if width/height are non-zero then override calculated width/height |
704 | * if width/height are non-zero then override calculated width/height |
693 | */ |
705 | */ |
694 | void |
706 | void |
695 | rxvt_term::window_calc (unsigned int width, unsigned int height) |
707 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
696 | { |
708 | { |
697 | short recalc_x, recalc_y; |
709 | short recalc_x, recalc_y; |
698 | int x, y, sb_w, mb_h, flags; |
710 | int x, y, sb_w, mb_h, flags; |
699 | unsigned int w, h; |
711 | unsigned int w, h; |
700 | unsigned int max_width, max_height; |
712 | unsigned int max_width, max_height; |
701 | dDisp; |
713 | dDisp; |
702 | |
714 | |
703 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
715 | D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
704 | TermWin.ncol, TermWin.nrow, szHint.width, |
716 | ncol, nrow, szHint.width, szHint.height)); |
705 | szHint.height)); |
717 | |
706 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
718 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
707 | szHint.win_gravity = NorthWestGravity; |
719 | szHint.win_gravity = NorthWestGravity; |
708 | /* szHint.min_aspect.x = szHint.min_aspect.y = 1; */ |
720 | /* szHint.min_aspect.x = szHint.min_aspect.y = 1; */ |
709 | |
721 | |
710 | recalc_x = recalc_y = 0; |
722 | recalc_x = recalc_y = 0; |
711 | flags = 0; |
723 | flags = 0; |
|
|
724 | |
712 | if (!parsed_geometry) |
725 | if (!parsed_geometry) |
713 | { |
726 | { |
714 | parsed_geometry = 1; |
727 | parsed_geometry = 1; |
|
|
728 | |
715 | if (rs[Rs_geometry]) |
729 | if (rs[Rs_geometry]) |
716 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
730 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
|
|
731 | |
717 | if (flags & WidthValue) |
732 | if (flags & WidthValue) |
718 | { |
733 | { |
719 | TermWin.ncol = BOUND_POSITIVE_INT16 (w); |
734 | ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); |
720 | szHint.flags |= USSize; |
735 | szHint.flags |= USSize; |
721 | } |
736 | } |
|
|
737 | |
722 | if (flags & HeightValue) |
738 | if (flags & HeightValue) |
723 | { |
739 | { |
724 | TermWin.nrow = BOUND_POSITIVE_INT16 (h); |
740 | nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); |
725 | szHint.flags |= USSize; |
741 | szHint.flags |= USSize; |
726 | } |
742 | } |
|
|
743 | |
727 | if (flags & XValue) |
744 | if (flags & XValue) |
728 | { |
745 | { |
729 | szHint.x = x; |
746 | szHint.x = x; |
730 | szHint.flags |= USPosition; |
747 | szHint.flags |= USPosition; |
|
|
748 | |
731 | if (flags & XNegative) |
749 | if (flags & XNegative) |
732 | { |
750 | { |
733 | recalc_x = 1; |
751 | recalc_x = 1; |
734 | szHint.win_gravity = NorthEastGravity; |
752 | szHint.win_gravity = NorthEastGravity; |
735 | } |
753 | } |
736 | } |
754 | } |
|
|
755 | |
737 | if (flags & YValue) |
756 | if (flags & YValue) |
738 | { |
757 | { |
739 | szHint.y = y; |
758 | szHint.y = y; |
740 | szHint.flags |= USPosition; |
759 | szHint.flags |= USPosition; |
|
|
760 | |
741 | if (flags & YNegative) |
761 | if (flags & YNegative) |
742 | { |
762 | { |
743 | recalc_y = 1; |
763 | recalc_y = 1; |
|
|
764 | |
744 | if (szHint.win_gravity == NorthEastGravity) |
765 | if (szHint.win_gravity == NorthEastGravity) |
745 | szHint.win_gravity = SouthEastGravity; |
766 | szHint.win_gravity = SouthEastGravity; |
746 | else |
767 | else |
747 | szHint.win_gravity = SouthWestGravity; |
768 | szHint.win_gravity = SouthWestGravity; |
748 | } |
769 | } |
749 | } |
770 | } |
750 | } |
771 | } |
751 | |
772 | |
752 | /* TODO: BOUNDS */ |
773 | /* TODO: BOUNDS */ |
753 | TermWin.width = TermWin.ncol * TermWin.fwidth; |
774 | width = ncol * fwidth; |
754 | TermWin.height = TermWin.nrow * TermWin.fheight; |
775 | height = nrow * fheight; |
755 | max_width = MAX_COLS * TermWin.fwidth; |
776 | max_width = MAX_COLS * fwidth; |
756 | max_height = MAX_ROWS * TermWin.fheight; |
777 | max_height = MAX_ROWS * fheight; |
757 | |
778 | |
758 | szHint.base_width = szHint.base_height = 2 * TermWin.int_bwidth; |
779 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
759 | |
780 | |
760 | sb_w = mb_h = 0; |
781 | sb_w = mb_h = 0; |
761 | window_vt_x = window_vt_y = TermWin.int_bwidth; |
782 | window_vt_x = window_vt_y = int_bwidth; |
762 | |
783 | |
763 | if (scrollbar_visible ()) |
784 | if (scrollbar_visible ()) |
764 | { |
785 | { |
765 | sb_w = scrollbar_TotalWidth (); |
786 | sb_w = scrollbar_TotalWidth (); |
766 | szHint.base_width += sb_w; |
787 | szHint.base_width += sb_w; |
… | |
… | |
773 | mb_h = menuBar_TotalHeight (); |
794 | mb_h = menuBar_TotalHeight (); |
774 | szHint.base_height += mb_h; |
795 | szHint.base_height += mb_h; |
775 | window_vt_y += mb_h; |
796 | window_vt_y += mb_h; |
776 | } |
797 | } |
777 | |
798 | |
778 | szHint.width_inc = TermWin.fwidth; |
799 | szHint.width_inc = fwidth; |
779 | szHint.height_inc = TermWin.fheight; |
800 | szHint.height_inc = fheight; |
780 | szHint.min_width = szHint.base_width + szHint.width_inc; |
801 | szHint.min_width = szHint.base_width + szHint.width_inc; |
781 | szHint.min_height = szHint.base_height + szHint.height_inc; |
802 | szHint.min_height = szHint.base_height + szHint.height_inc; |
782 | |
803 | |
783 | if (width && width - szHint.base_width < max_width) |
804 | if (newwidth && newwidth - szHint.base_width < max_width) |
784 | { |
805 | { |
785 | szHint.width = width; |
806 | szHint.width = newwidth; |
786 | TermWin.width = width - szHint.base_width; |
807 | width = newwidth - szHint.base_width; |
787 | } |
808 | } |
788 | else |
809 | else |
789 | { |
810 | { |
790 | MIN_IT (TermWin.width, max_width); |
811 | min_it (width, max_width); |
791 | szHint.width = szHint.base_width + TermWin.width; |
812 | szHint.width = szHint.base_width + width; |
792 | } |
813 | } |
793 | |
814 | |
794 | if (height && height - szHint.base_height < max_height) |
815 | if (newheight && newheight - szHint.base_height < max_height) |
795 | { |
816 | { |
796 | szHint.height = height; |
817 | szHint.height = newheight; |
797 | TermWin.height = height - szHint.base_height; |
818 | height = newheight - szHint.base_height; |
798 | } |
819 | } |
799 | else |
820 | else |
800 | { |
821 | { |
801 | MIN_IT (TermWin.height, max_height); |
822 | min_it (height, max_height); |
802 | szHint.height = szHint.base_height + TermWin.height; |
823 | szHint.height = szHint.base_height + height; |
803 | } |
824 | } |
804 | |
825 | |
805 | if (scrollbar_visible () && (options & Opt_scrollBar_right)) |
826 | if (scrollbar_visible () && (options & Opt_scrollBar_right)) |
806 | window_sb_x = szHint.width - sb_w; |
827 | window_sb_x = szHint.width - sb_w; |
807 | |
828 | |
808 | if (recalc_x) |
829 | if (recalc_x) |
809 | szHint.x += (DisplayWidth (disp, display->screen) |
830 | szHint.x += DisplayWidth (disp, display->screen) - szHint.width - 2 * ext_bwidth; |
810 | - szHint.width - 2 * TermWin.ext_bwidth); |
|
|
811 | if (recalc_y) |
831 | if (recalc_y) |
812 | szHint.y += (DisplayHeight (disp, display->screen) |
832 | szHint.y += DisplayHeight (disp, display->screen) - szHint.height - 2 * ext_bwidth; |
813 | - szHint.height - 2 * TermWin.ext_bwidth); |
|
|
814 | |
833 | |
815 | TermWin.ncol = TermWin.width / TermWin.fwidth; |
834 | ncol = width / fwidth; |
816 | TermWin.nrow = TermWin.height / TermWin.fheight; |
835 | nrow = height / fheight; |
817 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
836 | D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", |
818 | TermWin.ncol, TermWin.nrow, szHint.width, |
837 | ncol, nrow, szHint.width, |
819 | szHint.height)); |
838 | szHint.height)); |
820 | return; |
839 | return; |
821 | } |
840 | } |
822 | |
841 | |
823 | /*----------------------------------------------------------------------*/ |
842 | /*----------------------------------------------------------------------*/ |
… | |
… | |
831 | if (pty.pty < 0) |
850 | if (pty.pty < 0) |
832 | return; |
851 | return; |
833 | |
852 | |
834 | struct winsize ws; |
853 | struct winsize ws; |
835 | |
854 | |
836 | ws.ws_col = TermWin.ncol; |
855 | ws.ws_col = ncol; |
837 | ws.ws_row = TermWin.nrow; |
856 | ws.ws_row = nrow; |
838 | ws.ws_xpixel = TermWin.width; |
857 | ws.ws_xpixel = width; |
839 | ws.ws_ypixel = TermWin.height; |
858 | ws.ws_ypixel = height; |
840 | (void)ioctl (pty.pty, TIOCSWINSZ, &ws); |
859 | (void)ioctl (pty.pty, TIOCSWINSZ, &ws); |
841 | |
860 | |
842 | #if 0 |
861 | #if 0 |
843 | // TIOCSWINSZ⎈ is supposed to do this automatically and correctly |
862 | // TIOCSWINSZ⎈ is supposed to do this automatically and correctly |
844 | if (cmd_pid) /* force through to the command */ |
863 | if (cmd_pid) /* force through to the command */ |
845 | kill (cmd_pid, SIGWINCH); |
864 | kill (-cmd_pid, SIGWINCH); |
846 | #endif |
865 | #endif |
847 | } |
866 | } |
848 | |
867 | |
849 | /*----------------------------------------------------------------------*/ |
868 | /*----------------------------------------------------------------------*/ |
850 | /* set_fonts () - load and set the various fonts |
869 | /* set_fonts () - load and set the various fonts |
851 | /* |
870 | * |
852 | * init = 1 - initialize |
871 | * init = 1 - initialize |
853 | * |
872 | * |
854 | * fontname == FONT_UP - switch to bigger font |
873 | * fontname == FONT_UP - switch to bigger font |
855 | * fontname == FONT_DN - switch to smaller font |
874 | * fontname == FONT_DN - switch to smaller font |
856 | */ |
875 | */ |
… | |
… | |
868 | return false; |
887 | return false; |
869 | } |
888 | } |
870 | |
889 | |
871 | #if ENABLE_STYLES |
890 | #if ENABLE_STYLES |
872 | for (int i = RS_styleCount; --i; ) |
891 | for (int i = RS_styleCount; --i; ) |
873 | if (TermWin.fontset[i] != TermWin.fontset[0]) |
892 | if (fontset[i] != fontset[0]) |
874 | delete TermWin.fontset[i]; |
893 | delete fontset[i]; |
875 | #endif |
894 | #endif |
876 | |
895 | |
877 | delete TermWin.fontset[0]; |
896 | delete fontset[0]; |
878 | TermWin.fontset[0] = fs; |
897 | fontset[0] = fs; |
879 | |
898 | |
880 | prop = (*fs)[1]->properties (); |
899 | prop = (*fs)[1]->properties (); |
881 | prop.height += TermWin.lineSpace; |
900 | prop.height += lineSpace; |
882 | fs->set_prop (prop); |
901 | fs->set_prop (prop); |
883 | |
902 | |
884 | TermWin.fwidth = prop.width; |
903 | fwidth = prop.width; |
885 | TermWin.fheight = prop.height; |
904 | fheight = prop.height; |
886 | TermWin.fweight = prop.weight; |
|
|
887 | TermWin.fslant = prop.slant; |
|
|
888 | TermWin.fbase = (*fs)[1]->ascent; |
905 | fbase = (*fs)[1]->ascent; |
889 | |
906 | |
890 | for (int style = 1; style < 4; style++) |
907 | for (int style = 1; style < 4; style++) |
891 | { |
908 | { |
892 | #if ENABLE_STYLES |
909 | #if ENABLE_STYLES |
893 | const char *res = rs[Rs_font + style]; |
910 | const char *res = rs[Rs_font + style]; |
894 | |
911 | |
895 | if (res && !*res) |
912 | if (res && !*res) |
896 | TermWin.fontset[style] = TermWin.fontset[0]; |
913 | fontset[style] = fontset[0]; |
897 | else |
914 | else |
898 | { |
915 | { |
899 | TermWin.fontset[style] = fs = new rxvt_fontset (this); |
916 | fontset[style] = fs = new rxvt_fontset (this); |
900 | rxvt_fontprop prop2 = prop; |
917 | rxvt_fontprop prop2 = prop; |
901 | |
918 | |
902 | if (res) |
919 | if (res) |
903 | prop2.weight = prop2.slant = rxvt_fontprop::unset; |
920 | prop2.weight = prop2.slant = rxvt_fontprop::unset; |
904 | else |
921 | else |
905 | { |
922 | { |
906 | res = TermWin.fontset[0]->fontdesc; |
923 | res = fontset[0]->fontdesc; |
907 | |
924 | |
908 | if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold; |
925 | if (SET_STYLE (0, style) & RS_Bold) prop2.weight = rxvt_fontprop::bold; |
909 | if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic; |
926 | if (SET_STYLE (0, style) & RS_Italic) prop2.slant = rxvt_fontprop::italic; |
910 | } |
927 | } |
911 | |
928 | |
912 | fs->populate (res); |
929 | fs->populate (res); |
913 | fs->set_prop (prop2); |
930 | fs->set_prop (prop2); |
914 | } |
931 | } |
915 | #else |
932 | #else |
916 | TermWin.fontset[style] = TermWin.fontset[0]; |
933 | fontset[style] = fontset[0]; |
917 | #endif |
934 | #endif |
918 | } |
935 | } |
919 | |
936 | |
920 | if (TermWin.parent[0]) |
937 | if (parent[0]) |
921 | { |
938 | { |
922 | resize_all_windows (0, 0, 0); |
939 | resize_all_windows (0, 0, 0); |
923 | scr_remap_chars (); |
940 | scr_remap_chars (); |
924 | scr_touch (true); |
941 | scr_touch (true); |
925 | } |
942 | } |
… | |
… | |
927 | return true; |
944 | return true; |
928 | } |
945 | } |
929 | |
946 | |
930 | void rxvt_term::set_string_property (Atom prop, const char *str, int len) |
947 | void rxvt_term::set_string_property (Atom prop, const char *str, int len) |
931 | { |
948 | { |
932 | // TODO: SMART_WINDOW_TITLE |
|
|
933 | XChangeProperty (display->display, TermWin.parent[0], |
949 | XChangeProperty (display->display, parent[0], |
934 | prop, XA_STRING, 8, PropModeReplace, |
950 | prop, XA_STRING, 8, PropModeReplace, |
935 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
951 | (const unsigned char *)str, len >= 0 ? len : strlen (str)); |
936 | } |
952 | } |
937 | |
953 | |
938 | void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
954 | void rxvt_term::set_utf8_property (Atom prop, const char *str, int len) |
939 | { |
955 | { |
940 | // TODO: SMART_WINDOW_TITLE |
|
|
941 | wchar_t *ws = rxvt_mbstowcs (str, len); |
956 | wchar_t *ws = rxvt_mbstowcs (str, len); |
942 | char *s = rxvt_wcstoutf8 (ws); |
957 | char *s = rxvt_wcstoutf8 (ws); |
943 | |
958 | |
944 | XChangeProperty (display->display, TermWin.parent[0], |
959 | XChangeProperty (display->display, parent[0], |
945 | prop, xa[XA_UTF8_STRING], 8, PropModeReplace, |
960 | prop, xa[XA_UTF8_STRING], 8, PropModeReplace, |
946 | (const unsigned char *)s, strlen (s)); |
961 | (const unsigned char *)s, strlen (s)); |
947 | |
962 | |
948 | free (s); |
963 | free (s); |
949 | free (ws); |
964 | free (ws); |
… | |
… | |
954 | /* xterm sequences - title, iconName, color (exptl) */ |
969 | /* xterm sequences - title, iconName, color (exptl) */ |
955 | void |
970 | void |
956 | rxvt_term::set_title (const char *str) |
971 | rxvt_term::set_title (const char *str) |
957 | { |
972 | { |
958 | set_string_property (XA_WM_NAME, str); |
973 | set_string_property (XA_WM_NAME, str); |
959 | #if ENABLE_FRILLS |
974 | #if ENABLE_EWMH |
960 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
975 | set_utf8_property (xa[XA_NET_WM_NAME], str); |
961 | #endif |
976 | #endif |
962 | } |
977 | } |
963 | |
978 | |
964 | void |
979 | void |
965 | rxvt_term::set_icon_name (const char *str) |
980 | rxvt_term::set_icon_name (const char *str) |
966 | { |
981 | { |
967 | set_string_property (XA_WM_ICON_NAME, str); |
982 | set_string_property (XA_WM_ICON_NAME, str); |
968 | #if ENABLE_FRILLS |
983 | #if ENABLE_EWMH |
969 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
984 | set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); |
970 | #endif |
985 | #endif |
971 | } |
986 | } |
972 | |
987 | |
973 | #ifdef XTERM_COLOR_CHANGE |
988 | #ifdef XTERM_COLOR_CHANGE |
… | |
… | |
989 | { /* bright colors */ |
1004 | { /* bright colors */ |
990 | i -= 8; |
1005 | i -= 8; |
991 | # ifndef NO_BRIGHTCOLOR |
1006 | # ifndef NO_BRIGHTCOLOR |
992 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
1007 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
993 | SET_PIXCOLOR (idx); |
1008 | SET_PIXCOLOR (idx); |
994 | goto Done; |
1009 | goto done; |
995 | # endif |
1010 | # endif |
996 | } |
1011 | } |
997 | |
1012 | |
998 | if (i >= 0 && i <= 7) |
1013 | if (i >= 0 && i <= 7) |
999 | { /* normal colors */ |
1014 | { /* normal colors */ |
1000 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
1015 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
1001 | SET_PIXCOLOR (idx); |
1016 | SET_PIXCOLOR (idx); |
1002 | goto Done; |
1017 | goto done; |
1003 | } |
1018 | } |
1004 | } |
1019 | } |
1005 | |
1020 | |
1006 | if (!rXParseAllocColor (&xcol, color)) |
1021 | if (!rXParseAllocColor (&xcol, color)) |
1007 | return; |
1022 | return; |
… | |
… | |
1027 | pix_colors_focused[idx] = xcol; |
1042 | pix_colors_focused[idx] = xcol; |
1028 | SET_PIXCOLOR (idx); |
1043 | SET_PIXCOLOR (idx); |
1029 | |
1044 | |
1030 | /* XSetWindowAttributes attr; */ |
1045 | /* XSetWindowAttributes attr; */ |
1031 | /* Cursor cursor; */ |
1046 | /* Cursor cursor; */ |
1032 | Done: |
1047 | done: |
|
|
1048 | |
1033 | #ifdef OFF_FOCUS_FADING |
1049 | #if OFF_FOCUS_FADING |
1034 | if (rs[Rs_fade]) |
1050 | if (rs[Rs_fade]) |
1035 | pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade])); |
1051 | pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade]), pix_colors[Color_fade]); |
1036 | #endif |
1052 | #endif |
1037 | |
1053 | |
1038 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
1054 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
1039 | |
1055 | |
1040 | recolour_cursor (); |
1056 | recolour_cursor (); |
… | |
… | |
1111 | |
1127 | |
1112 | /* -------------------------------------------------------------------- * |
1128 | /* -------------------------------------------------------------------- * |
1113 | * - WINDOW RESIZING - * |
1129 | * - WINDOW RESIZING - * |
1114 | * -------------------------------------------------------------------- */ |
1130 | * -------------------------------------------------------------------- */ |
1115 | void |
1131 | void |
1116 | rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) |
1132 | rxvt_term::resize_all_windows (unsigned int newwidth, unsigned int newheight, int ignoreparent) |
1117 | { |
1133 | { |
1118 | int fix_screen; |
1134 | int fix_screen; |
1119 | #ifdef SMART_RESIZE |
|
|
1120 | int old_width = szHint.width, old_height = szHint.height; |
1135 | int old_width = szHint.width, old_height = szHint.height; |
1121 | #endif |
|
|
1122 | dDisp; |
1136 | dDisp; |
1123 | |
1137 | |
1124 | window_calc (width, height); |
1138 | window_calc (newwidth, newheight); |
1125 | XSetWMNormalHints (disp, TermWin.parent[0], &szHint); |
1139 | XSetWMNormalHints (disp, parent[0], &szHint); |
1126 | |
1140 | |
1127 | if (!ignoreparent) |
1141 | if (!ignoreparent) |
1128 | { |
1142 | { |
1129 | #ifdef SMART_RESIZE |
1143 | #ifdef SMART_RESIZE |
1130 | /* |
1144 | /* |
… | |
… | |
1134 | int x, y, x1, y1; |
1148 | int x, y, x1, y1; |
1135 | int dx, dy; |
1149 | int dx, dy; |
1136 | unsigned int unused_w1, unused_h1, unused_b1, unused_d1; |
1150 | unsigned int unused_w1, unused_h1, unused_b1, unused_d1; |
1137 | Window unused_cr; |
1151 | Window unused_cr; |
1138 | |
1152 | |
1139 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
1153 | XTranslateCoordinates (disp, parent[0], display->root, |
1140 | 0, 0, &x, &y, &unused_cr); |
1154 | 0, 0, &x, &y, &unused_cr); |
1141 | XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1, |
1155 | XGetGeometry (disp, parent[0], &unused_cr, &x1, &y1, |
1142 | &unused_w1, &unused_h1, &unused_b1, &unused_d1); |
1156 | &unused_w1, &unused_h1, &unused_b1, &unused_d1); |
1143 | /* |
1157 | /* |
1144 | * if display->root isn't the parent window, a WM will probably have offset |
1158 | * if display->root isn't the parent window, a WM will probably have offset |
1145 | * our position for handles and decorations. Counter it |
1159 | * our position for handles and decorations. Counter it |
1146 | */ |
1160 | */ |
… | |
… | |
1163 | if (y < y1) /* top half */ |
1177 | if (y < y1) /* top half */ |
1164 | dy = 0; |
1178 | dy = 0; |
1165 | else if (y == y1) /* exact center */ |
1179 | else if (y == y1) /* exact center */ |
1166 | dy /= 2; |
1180 | dy /= 2; |
1167 | |
1181 | |
1168 | XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy, |
1182 | XMoveResizeWindow (disp, parent[0], x + dx, y + dy, |
1169 | szHint.width, szHint.height); |
1183 | szHint.width, szHint.height); |
1170 | #else |
1184 | #else |
1171 | XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height); |
1185 | XResizeWindow (disp, parent[0], szHint.width, szHint.height); |
1172 | #endif |
1186 | #endif |
1173 | } |
1187 | } |
1174 | |
1188 | |
1175 | fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; |
1189 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
1176 | |
1190 | |
1177 | if (fix_screen || width != old_width || height != old_height) |
1191 | if (fix_screen || newwidth != old_width || newheight != old_height) |
1178 | { |
1192 | { |
1179 | if (scrollbar_visible ()) |
1193 | if (scrollbar_visible ()) |
1180 | { |
1194 | { |
1181 | XMoveResizeWindow (disp, scrollBar.win, |
1195 | XMoveResizeWindow (disp, scrollBar.win, |
1182 | window_sb_x, 0, |
1196 | window_sb_x, 0, |
… | |
… | |
1187 | if (menubar_visible ()) |
1201 | if (menubar_visible ()) |
1188 | XMoveResizeWindow (disp, menuBar.win, |
1202 | XMoveResizeWindow (disp, menuBar.win, |
1189 | window_vt_x, 0, |
1203 | window_vt_x, 0, |
1190 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1204 | TermWin_TotalWidth (), menuBar_TotalHeight ()); |
1191 | |
1205 | |
1192 | XMoveResizeWindow (disp, TermWin.vt, |
1206 | XMoveResizeWindow (disp, vt, |
1193 | window_vt_x, window_vt_y, |
1207 | window_vt_x, window_vt_y, |
1194 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1208 | TermWin_TotalWidth (), TermWin_TotalHeight ()); |
1195 | |
1209 | |
1196 | scr_clear (); |
1210 | scr_clear (); |
1197 | #ifdef XPM_BACKGROUND |
1211 | #ifdef XPM_BACKGROUND |
… | |
… | |
1205 | int old_ncol = prev_ncol; |
1219 | int old_ncol = prev_ncol; |
1206 | |
1220 | |
1207 | /* scr_reset only works on the primary screen */ |
1221 | /* scr_reset only works on the primary screen */ |
1208 | if (old_height) /* this is not the first time through */ |
1222 | if (old_height) /* this is not the first time through */ |
1209 | { |
1223 | { |
1210 | unsigned int ncol = TermWin.ncol; |
1224 | unsigned int ocol = ncol; |
1211 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
1225 | ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
1212 | curr_screen = scr_change_screen (PRIMARY); |
1226 | curr_screen = scr_change_screen (PRIMARY); |
1213 | TermWin.ncol = ncol; |
1227 | ncol = ocol; |
1214 | } |
1228 | } |
1215 | |
1229 | |
1216 | scr_reset (); |
1230 | scr_reset (); |
1217 | |
1231 | |
1218 | if (curr_screen >= 0) /* this is not the first time through */ |
1232 | if (curr_screen >= 0) /* this is not the first time through */ |
1219 | { |
1233 | { |
1220 | scr_change_screen (curr_screen); |
1234 | scr_change_screen (curr_screen); |
1221 | selection_check (old_ncol != TermWin.ncol ? 4 : 0); |
1235 | selection_check (old_ncol != ncol ? 4 : 0); |
1222 | } |
1236 | } |
1223 | } |
1237 | } |
1224 | |
1238 | |
1225 | old_width = szHint.width; |
1239 | old_width = szHint.width; |
1226 | old_height = szHint.height; |
1240 | old_height = szHint.height; |
1227 | |
1241 | |
1228 | #ifdef XPM_BACKGROUND |
1242 | #ifdef XPM_BACKGROUND |
1229 | if (TermWin.pixmap) |
1243 | if (pixmap) |
1230 | scr_touch (false); |
1244 | scr_touch (false); |
1231 | #endif |
1245 | #endif |
1232 | |
1246 | |
1233 | #ifdef USE_XIM |
1247 | #ifdef USE_XIM |
1234 | IMSetStatusPosition (); |
1248 | IMSetStatusPosition (); |
… | |
… | |
1238 | /* |
1252 | /* |
1239 | * Set the width/height of the vt window in characters. Units are pixels. |
1253 | * Set the width/height of the vt window in characters. Units are pixels. |
1240 | * good for toggling 80/132 columns |
1254 | * good for toggling 80/132 columns |
1241 | */ |
1255 | */ |
1242 | void |
1256 | void |
1243 | rxvt_term::set_widthheight (unsigned int width, unsigned int height) |
1257 | rxvt_term::set_widthheight (unsigned int newwidth, unsigned int newheight) |
1244 | { |
1258 | { |
1245 | XWindowAttributes wattr; |
1259 | XWindowAttributes wattr; |
1246 | |
1260 | |
1247 | if (width == 0 || height == 0) |
1261 | if (newwidth == 0 || newheight == 0) |
1248 | { |
1262 | { |
1249 | XGetWindowAttributes (display->display, display->root, &wattr); |
1263 | XGetWindowAttributes (display->display, display->root, &wattr); |
|
|
1264 | |
1250 | if (width == 0) |
1265 | if (newwidth == 0) |
1251 | width = wattr.width - szHint.base_width; |
1266 | newwidth = wattr.width - szHint.base_width; |
1252 | if (height == 0) |
1267 | if (newheight == 0) |
1253 | height = wattr.height - szHint.base_height; |
1268 | newheight = wattr.height - szHint.base_height; |
1254 | } |
|
|
1255 | |
|
|
1256 | if (width != TermWin.width || height != TermWin.height) |
|
|
1257 | { |
1269 | } |
|
|
1270 | |
|
|
1271 | if (newwidth != width || newheight != height) |
|
|
1272 | { |
1258 | width += szHint.base_width; |
1273 | newwidth += szHint.base_width; |
1259 | height += szHint.base_height; |
1274 | newheight += szHint.base_height; |
1260 | resize_all_windows (width, height, 0); |
1275 | resize_all_windows (newwidth, newheight, 0); |
1261 | } |
1276 | } |
1262 | } |
1277 | } |
1263 | |
1278 | |
1264 | /* -------------------------------------------------------------------- * |
1279 | /* -------------------------------------------------------------------- * |
1265 | * - X INPUT METHOD ROUTINES - * |
1280 | * - X INPUT METHOD ROUTINES - * |
… | |
… | |
1275 | |
1290 | |
1276 | void |
1291 | void |
1277 | rxvt_term::im_set_size (XRectangle &size) |
1292 | rxvt_term::im_set_size (XRectangle &size) |
1278 | { |
1293 | { |
1279 | // the int_bwidth terms make no sense to me |
1294 | // the int_bwidth terms make no sense to me |
1280 | size.x = TermWin.int_bwidth; |
1295 | size.x = int_bwidth; |
1281 | size.y = TermWin.int_bwidth; |
1296 | size.y = int_bwidth; |
1282 | size.width = Width2Pixel (TermWin.ncol) + TermWin.int_bwidth; |
1297 | size.width = Width2Pixel (ncol) + int_bwidth; |
1283 | size.height = Height2Pixel (TermWin.nrow) + TermWin.int_bwidth; |
1298 | size.height = Height2Pixel (nrow) + int_bwidth; |
1284 | } |
1299 | } |
1285 | |
1300 | |
1286 | void |
1301 | void |
1287 | rxvt_term::im_set_preedit_area (XRectangle &preedit_rect, |
1302 | rxvt_term::im_set_preedit_area (XRectangle &preedit_rect, |
1288 | XRectangle &status_rect, |
1303 | XRectangle &status_rect, |
1289 | const XRectangle &needed_rect) |
1304 | const XRectangle &needed_rect) |
1290 | { |
1305 | { |
1291 | preedit_rect.x = needed_rect.width; |
1306 | preedit_rect.x = needed_rect.width; |
1292 | preedit_rect.y = 0; |
1307 | preedit_rect.y = 0; |
1293 | preedit_rect.width = Width2Pixel (TermWin.ncol) - needed_rect.width + 1; |
1308 | preedit_rect.width = Width2Pixel (ncol) - needed_rect.width + 1; |
1294 | preedit_rect.height = TermWin.fheight; |
1309 | preedit_rect.height = fheight; |
1295 | |
1310 | |
1296 | status_rect.x = 0; |
1311 | status_rect.x = 0; |
1297 | status_rect.y = 0; |
1312 | status_rect.y = 0; |
1298 | status_rect.width = needed_rect.width ? needed_rect.width : Width2Pixel (TermWin.ncol) + 1; |
1313 | status_rect.width = needed_rect.width ? needed_rect.width : Width2Pixel (ncol) + 1; |
1299 | status_rect.height = TermWin.fheight; |
1314 | status_rect.height = fheight; |
1300 | } |
1315 | } |
1301 | |
1316 | |
1302 | /* Checking whether input method is running. */ |
1317 | /* Checking whether input method is running. */ |
1303 | bool |
1318 | bool |
1304 | rxvt_term::IMisRunning () |
1319 | rxvt_term::IMisRunning () |
… | |
… | |
1332 | { |
1347 | { |
1333 | XPoint nspot; |
1348 | XPoint nspot; |
1334 | XVaNestedList preedit_attr; |
1349 | XVaNestedList preedit_attr; |
1335 | |
1350 | |
1336 | if (!Input_Context |
1351 | if (!Input_Context |
1337 | || !TermWin.focus |
1352 | || !focus |
1338 | || !(input_style & XIMPreeditPosition)) |
1353 | || !(input_style & XIMPreeditPosition)) |
1339 | return; |
1354 | return; |
1340 | |
1355 | |
1341 | im_set_position (nspot); |
1356 | im_set_position (nspot); |
1342 | |
1357 | |
… | |
… | |
1462 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1477 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1463 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1478 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1464 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1479 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1465 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1480 | "-*-*-*-R-*-*-%d-*-*-*-*-*-*," |
1466 | "*", |
1481 | "*", |
1467 | TermWin.fheight, |
1482 | fheight, |
1468 | TermWin.fheight + 1, TermWin.fheight - 1, |
1483 | fheight + 1, fheight - 1, |
1469 | TermWin.fheight - 2, TermWin.fheight + 2); |
1484 | fheight - 2, fheight + 2); |
1470 | |
1485 | |
1471 | fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat, |
1486 | fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat, |
1472 | &missing_charset_list, &missing_charset_count, &def_string); |
1487 | &missing_charset_list, &missing_charset_count, &def_string); |
1473 | |
1488 | |
1474 | if (missing_charset_list) |
1489 | if (missing_charset_list) |
… | |
… | |
1520 | NULL); |
1535 | NULL); |
1521 | } |
1536 | } |
1522 | |
1537 | |
1523 | Input_Context = XCreateIC (xim, |
1538 | Input_Context = XCreateIC (xim, |
1524 | XNInputStyle, input_style, |
1539 | XNInputStyle, input_style, |
1525 | XNClientWindow, TermWin.vt, |
1540 | XNClientWindow, vt, |
1526 | XNFocusWindow, TermWin.parent[0], |
1541 | XNFocusWindow, parent[0], |
1527 | preedit_attr ? XNPreeditAttributes : NULL, |
1542 | preedit_attr ? XNPreeditAttributes : NULL, |
1528 | preedit_attr, |
1543 | preedit_attr, |
1529 | status_attr ? XNStatusAttributes : NULL, |
1544 | status_attr ? XNStatusAttributes : NULL, |
1530 | status_attr, NULL); |
1545 | status_attr, NULL); |
1531 | |
1546 | |
… | |
… | |
1548 | } |
1563 | } |
1549 | |
1564 | |
1550 | void |
1565 | void |
1551 | rxvt_term::im_cb () |
1566 | rxvt_term::im_cb () |
1552 | { |
1567 | { |
1553 | int i, found, had_im; |
1568 | int i; |
1554 | const char *p; |
1569 | const char *p; |
1555 | char **s; |
1570 | char **s; |
1556 | char buf[IMBUFSIZ]; |
1571 | char buf[IMBUFSIZ]; |
1557 | |
1572 | |
1558 | SET_R (this); |
1573 | SET_R (this); |
… | |
… | |
1615 | { |
1630 | { |
1616 | XRectangle preedit_rect, status_rect, *needed_rect; |
1631 | XRectangle preedit_rect, status_rect, *needed_rect; |
1617 | XVaNestedList preedit_attr, status_attr; |
1632 | XVaNestedList preedit_attr, status_attr; |
1618 | |
1633 | |
1619 | if (!Input_Context |
1634 | if (!Input_Context |
1620 | || !TermWin.focus |
1635 | || !focus |
1621 | || !(input_style & XIMPreeditArea) |
1636 | || !(input_style & XIMPreeditArea) |
1622 | || !IMisRunning ()) |
1637 | || !IMisRunning ()) |
1623 | return; |
1638 | return; |
1624 | |
1639 | |
1625 | /* Getting the necessary width of preedit area */ |
1640 | /* Getting the necessary width of preedit area */ |