… | |
… | |
227 | delete fontset[0]; |
227 | delete fontset[0]; |
228 | |
228 | |
229 | #ifdef HAVE_BG_PIXMAP |
229 | #ifdef HAVE_BG_PIXMAP |
230 | bgPixmap.destroy (); |
230 | bgPixmap.destroy (); |
231 | #endif |
231 | #endif |
|
|
232 | #ifdef HAVE_AFTERIMAGE |
|
|
233 | if (asv) |
|
|
234 | destroy_asvisual (asv, 0); |
|
|
235 | if (asimman) |
|
|
236 | destroy_image_manager (asimman, 0); |
|
|
237 | #endif |
232 | |
238 | |
233 | if (display) |
239 | if (display) |
234 | { |
240 | { |
235 | selection_clear (); |
241 | selection_clear (); |
236 | |
242 | |
237 | #ifdef USE_XIM |
243 | #ifdef USE_XIM |
238 | im_destroy (); |
244 | im_destroy (); |
239 | #endif |
245 | #endif |
240 | #ifdef XTERM_SCROLLBAR |
246 | scrollBar.destroy (); |
241 | if (xscrollbarGC) XFreeGC (dpy, xscrollbarGC); |
|
|
242 | if (ShadowGC) XFreeGC (dpy, ShadowGC); |
|
|
243 | #endif |
|
|
244 | #ifdef PLAIN_SCROLLBAR |
|
|
245 | if (pscrollbarGC) XFreeGC (dpy, pscrollbarGC); |
|
|
246 | #endif |
|
|
247 | #ifdef NEXT_SCROLLBAR |
|
|
248 | if (blackGC) XFreeGC (dpy, blackGC); |
|
|
249 | if (whiteGC) XFreeGC (dpy, whiteGC); |
|
|
250 | if (grayGC) XFreeGC (dpy, grayGC); |
|
|
251 | if (darkGC) XFreeGC (dpy, darkGC); |
|
|
252 | if (stippleGC) XFreeGC (dpy, stippleGC); |
|
|
253 | if (dimple) XFreePixmap (dpy, dimple); |
|
|
254 | if (upArrow) XFreePixmap (dpy, upArrow); |
|
|
255 | if (downArrow) XFreePixmap (dpy, downArrow); |
|
|
256 | if (upArrowHi) XFreePixmap (dpy, upArrowHi); |
|
|
257 | if (downArrowHi) XFreePixmap (dpy, downArrowHi); |
|
|
258 | #endif |
|
|
259 | #ifdef RXVT_SCROLLBAR |
|
|
260 | if (topShadowGC) XFreeGC (dpy, topShadowGC); |
|
|
261 | if (botShadowGC) XFreeGC (dpy, botShadowGC); |
|
|
262 | if (scrollbarGC) XFreeGC (dpy, scrollbarGC); |
|
|
263 | #endif |
|
|
264 | if (gc) XFreeGC (dpy, gc); |
247 | if (gc) XFreeGC (dpy, gc); |
265 | |
248 | |
266 | delete drawable; |
249 | delete drawable; |
267 | // destroy all windows |
250 | // destroy all windows |
268 | if (parent[0]) |
251 | if (parent[0]) |
… | |
… | |
525 | */ |
508 | */ |
526 | void |
509 | void |
527 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
510 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
528 | { |
511 | { |
529 | short recalc_x, recalc_y; |
512 | short recalc_x, recalc_y; |
530 | int x, y, sb_w, flags; |
513 | int x, y, flags; |
531 | unsigned int w, h; |
514 | unsigned int w, h; |
532 | unsigned int max_width, max_height; |
515 | unsigned int max_width, max_height; |
533 | |
516 | |
534 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
517 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
535 | szHint.win_gravity = NorthWestGravity; |
518 | szHint.win_gravity = NorthWestGravity; |
… | |
… | |
545 | if (rs[Rs_geometry]) |
528 | if (rs[Rs_geometry]) |
546 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
529 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
547 | |
530 | |
548 | if (flags & WidthValue) |
531 | if (flags & WidthValue) |
549 | { |
532 | { |
|
|
533 | if (!w) |
|
|
534 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
535 | |
550 | ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); |
536 | ncol = clamp (w, 1, std::numeric_limits<int16_t>::max ()); |
551 | szHint.flags |= USSize; |
537 | szHint.flags |= USSize; |
552 | } |
538 | } |
553 | |
539 | |
554 | if (flags & HeightValue) |
540 | if (flags & HeightValue) |
555 | { |
541 | { |
|
|
542 | if (!h) |
|
|
543 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
544 | |
556 | nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); |
545 | nrow = clamp (h, 1, std::numeric_limits<int16_t>::max ()); |
557 | szHint.flags |= USSize; |
546 | szHint.flags |= USSize; |
558 | } |
547 | } |
559 | |
548 | |
560 | if (flags & XValue) |
549 | if (flags & XValue) |
561 | { |
550 | { |
… | |
… | |
592 | max_width = MAX_COLS * fwidth; |
581 | max_width = MAX_COLS * fwidth; |
593 | max_height = MAX_ROWS * fheight; |
582 | max_height = MAX_ROWS * fheight; |
594 | |
583 | |
595 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
584 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
596 | |
585 | |
597 | sb_w = 0; |
|
|
598 | window_vt_x = window_vt_y = int_bwidth; |
586 | window_vt_x = window_vt_y = int_bwidth; |
599 | |
587 | |
600 | if (scrollBar.state) |
588 | if (scrollBar.state) |
601 | { |
589 | { |
602 | sb_w = scrollBar.total_width (); |
590 | int sb_w = scrollBar.total_width (); |
603 | szHint.base_width += sb_w; |
591 | szHint.base_width += sb_w; |
604 | |
592 | |
605 | if (!option (Opt_scrollBar_right)) |
593 | if (!option (Opt_scrollBar_right)) |
606 | window_vt_x += sb_w; |
594 | window_vt_x += sb_w; |
607 | } |
595 | } |
… | |
… | |
631 | { |
619 | { |
632 | min_it (height, max_height); |
620 | min_it (height, max_height); |
633 | szHint.height = szHint.base_height + height; |
621 | szHint.height = szHint.base_height + height; |
634 | } |
622 | } |
635 | |
623 | |
636 | if (scrollBar.state && option (Opt_scrollBar_right)) |
|
|
637 | window_sb_x = szHint.width - sb_w; |
|
|
638 | |
|
|
639 | if (recalc_x) |
624 | if (recalc_x) |
640 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
625 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
641 | |
626 | |
642 | if (recalc_y) |
627 | if (recalc_y) |
643 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
628 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
644 | |
629 | |
645 | ncol = width / fwidth; |
630 | ncol = width / fwidth; |
646 | nrow = height / fheight; |
631 | nrow = height / fheight; |
647 | } |
632 | } |
648 | |
633 | |
649 | /*----------------------------------------------------------------------*/ |
634 | /*----------------------------------------------------------------------*/ |
650 | /* |
635 | /* |
… | |
… | |
661 | |
646 | |
662 | ws.ws_col = ncol; |
647 | ws.ws_col = ncol; |
663 | ws.ws_row = nrow; |
648 | ws.ws_row = nrow; |
664 | ws.ws_xpixel = width; |
649 | ws.ws_xpixel = width; |
665 | ws.ws_ypixel = height; |
650 | ws.ws_ypixel = height; |
666 | (void)ioctl (pty->pty, TIOCSWINSZ, &ws); |
651 | ioctl (pty->pty, TIOCSWINSZ, &ws); |
667 | |
652 | |
668 | #if 0 |
653 | #if 0 |
669 | // TIOCSWINSZ is supposed to do this automatically and correctly |
654 | // TIOCSWINSZ is supposed to do this automatically and correctly |
670 | if (cmd_pid) /* force through to the command */ |
655 | if (cmd_pid) /* force through to the command */ |
671 | kill (-cmd_pid, SIGWINCH); |
656 | kill (-cmd_pid, SIGWINCH); |
… | |
… | |
703 | delete fontset[0]; |
688 | delete fontset[0]; |
704 | fontset[0] = fs; |
689 | fontset[0] = fs; |
705 | |
690 | |
706 | prop = (*fs)[1]->properties (); |
691 | prop = (*fs)[1]->properties (); |
707 | prop.height += lineSpace; |
692 | prop.height += lineSpace; |
|
|
693 | prop.width += letterSpace; |
708 | |
694 | |
709 | fs->set_prop (prop, false); |
695 | fs->set_prop (prop, false); |
710 | |
696 | |
711 | fwidth = prop.width; |
697 | fwidth = prop.width; |
712 | fheight = prop.height; |
698 | fheight = prop.height; |
… | |
… | |
926 | int old_width = szHint.width; |
912 | int old_width = szHint.width; |
927 | int old_height = szHint.height; |
913 | int old_height = szHint.height; |
928 | |
914 | |
929 | window_calc (newwidth, newheight); |
915 | window_calc (newwidth, newheight); |
930 | |
916 | |
931 | if (!HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END))) |
917 | bool set_hint = !HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
|
|
918 | |
|
|
919 | // to avoid races between us and the wm, we clear the incremental size hints around the xresizewindow |
|
|
920 | if (set_hint) |
|
|
921 | { |
|
|
922 | szHint.flags &= ~(PBaseSize | PResizeInc); |
932 | XSetWMNormalHints (dpy, parent[0], &szHint); |
923 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
924 | szHint.flags |= PBaseSize | PResizeInc; |
|
|
925 | } |
933 | |
926 | |
934 | if (!ignoreparent) |
927 | if (!ignoreparent) |
935 | { |
928 | { |
936 | #ifdef SMART_RESIZE |
929 | #ifdef SMART_RESIZE |
937 | /* |
930 | /* |
… | |
… | |
977 | #else |
970 | #else |
978 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
971 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
979 | #endif |
972 | #endif |
980 | } |
973 | } |
981 | |
974 | |
|
|
975 | if (set_hint) |
|
|
976 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
977 | |
982 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
978 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
983 | |
979 | |
984 | if (fix_screen || newwidth != old_width || newheight != old_height) |
980 | if (fix_screen || newwidth != old_width || newheight != old_height) |
985 | { |
981 | { |
986 | if (scrollBar.state) |
982 | if (scrollBar.state) |
987 | { |
983 | scrollBar.resize (); |
988 | XMoveResizeWindow (dpy, scrollBar.win, |
|
|
989 | window_sb_x, 0, |
|
|
990 | scrollBar.total_width (), szHint.height); |
|
|
991 | resize_scrollbar (); |
|
|
992 | } |
|
|
993 | |
984 | |
994 | XMoveResizeWindow (dpy, vt, |
985 | XMoveResizeWindow (dpy, vt, |
995 | window_vt_x, window_vt_y, |
986 | window_vt_x, window_vt_y, |
996 | width, height); |
987 | width, height); |
997 | |
988 | |
998 | #ifdef HAVE_BG_PIXMAP |
989 | #ifdef HAVE_BG_PIXMAP |
999 | if (bgPixmap.window_size_sensitive ()) |
990 | if (bgPixmap.window_size_sensitive ()) |
1000 | update_background (); |
991 | update_background (); |
1001 | #endif |
992 | #endif |
1002 | |
|
|
1003 | scr_clear (); |
|
|
1004 | } |
993 | } |
1005 | |
994 | |
1006 | if (fix_screen || old_height == 0) |
995 | if (fix_screen || old_height == 0) |
1007 | scr_reset (); |
996 | scr_reset (); |
1008 | |
997 | |
… | |
… | |
1087 | |
1076 | |
1088 | /* Checking whether input method is running. */ |
1077 | /* Checking whether input method is running. */ |
1089 | bool |
1078 | bool |
1090 | rxvt_term::IMisRunning () |
1079 | rxvt_term::IMisRunning () |
1091 | { |
1080 | { |
1092 | char *p; |
|
|
1093 | Atom atom; |
1081 | Atom atom; |
1094 | Window win; |
1082 | Window win; |
1095 | char server[IMBUFSIZ]; |
1083 | char server[IMBUFSIZ]; |
1096 | |
1084 | |
1097 | /* get current locale modifier */ |
1085 | /* get current locale modifier */ |
1098 | if ((p = XSetLocaleModifiers (NULL)) != NULL) |
1086 | if (char *p = XSetLocaleModifiers (0)) |
1099 | { |
1087 | { |
1100 | strcpy (server, "@server="); |
1088 | strcpy (server, "@server="); |
1101 | strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ |
1089 | strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */ |
1102 | |
1090 | |
1103 | if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ |
1091 | if (p = strchr (server + 1, '@')) /* first one only */ |
1104 | *p = '\0'; |
1092 | *p = '\0'; |
1105 | |
1093 | |
1106 | atom = XInternAtom (dpy, server, False); |
1094 | atom = XInternAtom (dpy, server, False); |
1107 | win = XGetSelectionOwner (dpy, atom); |
1095 | win = XGetSelectionOwner (dpy, atom); |
1108 | |
1096 | |