… | |
… | |
172 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
172 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
173 | #endif |
173 | #endif |
174 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
174 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
175 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
175 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
176 | #endif |
176 | #endif |
177 | #ifdef HAVE_SCROLLBARS |
|
|
178 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
177 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
179 | #endif |
|
|
180 | #ifdef USE_XIM |
178 | #ifdef USE_XIM |
181 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
179 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
182 | #endif |
180 | #endif |
183 | #ifdef POINTER_BLANK |
181 | #ifdef POINTER_BLANK |
184 | pointer_ev.set <rxvt_term, &rxvt_term::pointer_cb> (this); |
182 | pointer_ev.set <rxvt_term, &rxvt_term::pointer_cb> (this); |
… | |
… | |
229 | delete fontset[0]; |
227 | delete fontset[0]; |
230 | |
228 | |
231 | #ifdef HAVE_BG_PIXMAP |
229 | #ifdef HAVE_BG_PIXMAP |
232 | bgPixmap.destroy (); |
230 | bgPixmap.destroy (); |
233 | #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 |
234 | |
238 | |
235 | if (display) |
239 | if (display) |
236 | { |
240 | { |
237 | selection_clear (); |
241 | selection_clear (); |
238 | |
242 | |
239 | #ifdef USE_XIM |
243 | #ifdef USE_XIM |
240 | im_destroy (); |
244 | im_destroy (); |
241 | #endif |
245 | #endif |
242 | #ifdef XTERM_SCROLLBAR |
246 | scrollBar.destroy (); |
243 | if (xscrollbarGC) XFreeGC (dpy, xscrollbarGC); |
|
|
244 | if (ShadowGC) XFreeGC (dpy, ShadowGC); |
|
|
245 | #endif |
|
|
246 | #ifdef PLAIN_SCROLLBAR |
|
|
247 | if (pscrollbarGC) XFreeGC (dpy, pscrollbarGC); |
|
|
248 | #endif |
|
|
249 | #ifdef NEXT_SCROLLBAR |
|
|
250 | if (blackGC) XFreeGC (dpy, blackGC); |
|
|
251 | if (whiteGC) XFreeGC (dpy, whiteGC); |
|
|
252 | if (grayGC) XFreeGC (dpy, grayGC); |
|
|
253 | if (darkGC) XFreeGC (dpy, darkGC); |
|
|
254 | if (stippleGC) XFreeGC (dpy, stippleGC); |
|
|
255 | if (dimple) XFreePixmap (dpy, dimple); |
|
|
256 | if (upArrow) XFreePixmap (dpy, upArrow); |
|
|
257 | if (downArrow) XFreePixmap (dpy, downArrow); |
|
|
258 | if (upArrowHi) XFreePixmap (dpy, upArrowHi); |
|
|
259 | if (downArrowHi) XFreePixmap (dpy, downArrowHi); |
|
|
260 | #endif |
|
|
261 | #ifdef RXVT_SCROLLBAR |
|
|
262 | if (topShadowGC) XFreeGC (dpy, topShadowGC); |
|
|
263 | if (botShadowGC) XFreeGC (dpy, botShadowGC); |
|
|
264 | if (scrollbarGC) XFreeGC (dpy, scrollbarGC); |
|
|
265 | #endif |
|
|
266 | if (gc) XFreeGC (dpy, gc); |
247 | if (gc) XFreeGC (dpy, gc); |
267 | |
248 | |
268 | delete drawable; |
249 | delete drawable; |
269 | // destroy all windows |
250 | // destroy all windows |
270 | if (parent[0]) |
251 | if (parent[0]) |
… | |
… | |
337 | if (display) |
318 | if (display) |
338 | { |
319 | { |
339 | #if USE_XIM |
320 | #if USE_XIM |
340 | im_ev.stop (display); |
321 | im_ev.stop (display); |
341 | #endif |
322 | #endif |
342 | #if HAVE_SCROLLBARS |
|
|
343 | scrollbar_ev.stop (display); |
323 | scrollbar_ev.stop (display); |
344 | #endif |
|
|
345 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
324 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
346 | rootwin_ev.stop (display); |
325 | rootwin_ev.stop (display); |
347 | #endif |
326 | #endif |
348 | incr_ev.stop (); |
327 | incr_ev.stop (); |
349 | termwin_ev.stop (display); |
328 | termwin_ev.stop (display); |
… | |
… | |
529 | */ |
508 | */ |
530 | void |
509 | void |
531 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
510 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
532 | { |
511 | { |
533 | short recalc_x, recalc_y; |
512 | short recalc_x, recalc_y; |
534 | int x, y, sb_w, flags; |
513 | int x, y, flags; |
535 | unsigned int w, h; |
514 | unsigned int w, h; |
536 | unsigned int max_width, max_height; |
515 | unsigned int max_width, max_height; |
537 | |
516 | |
538 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
517 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
539 | szHint.win_gravity = NorthWestGravity; |
518 | szHint.win_gravity = NorthWestGravity; |
… | |
… | |
549 | if (rs[Rs_geometry]) |
528 | if (rs[Rs_geometry]) |
550 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
529 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
551 | |
530 | |
552 | if (flags & WidthValue) |
531 | if (flags & WidthValue) |
553 | { |
532 | { |
|
|
533 | if (!w) |
|
|
534 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
535 | |
554 | ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); |
536 | ncol = clamp (w, 1, std::numeric_limits<int16_t>::max ()); |
555 | szHint.flags |= USSize; |
537 | szHint.flags |= USSize; |
556 | } |
538 | } |
557 | |
539 | |
558 | if (flags & HeightValue) |
540 | if (flags & HeightValue) |
559 | { |
541 | { |
|
|
542 | if (!h) |
|
|
543 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
544 | |
560 | nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); |
545 | nrow = clamp (h, 1, std::numeric_limits<int16_t>::max ()); |
561 | szHint.flags |= USSize; |
546 | szHint.flags |= USSize; |
562 | } |
547 | } |
563 | |
548 | |
564 | if (flags & XValue) |
549 | if (flags & XValue) |
565 | { |
550 | { |
… | |
… | |
596 | max_width = MAX_COLS * fwidth; |
581 | max_width = MAX_COLS * fwidth; |
597 | max_height = MAX_ROWS * fheight; |
582 | max_height = MAX_ROWS * fheight; |
598 | |
583 | |
599 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
584 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
600 | |
585 | |
601 | sb_w = 0; |
|
|
602 | window_vt_x = window_vt_y = int_bwidth; |
586 | window_vt_x = window_vt_y = int_bwidth; |
603 | |
587 | |
604 | if (scrollBar.state) |
588 | if (scrollBar.state) |
605 | { |
589 | { |
606 | sb_w = scrollbar_TotalWidth (); |
590 | int sb_w = scrollBar.total_width (); |
607 | szHint.base_width += sb_w; |
591 | szHint.base_width += sb_w; |
608 | |
592 | |
609 | if (!option (Opt_scrollBar_right)) |
593 | if (!option (Opt_scrollBar_right)) |
610 | window_vt_x += sb_w; |
594 | window_vt_x += sb_w; |
611 | } |
595 | } |
… | |
… | |
635 | { |
619 | { |
636 | min_it (height, max_height); |
620 | min_it (height, max_height); |
637 | szHint.height = szHint.base_height + height; |
621 | szHint.height = szHint.base_height + height; |
638 | } |
622 | } |
639 | |
623 | |
640 | if (scrollBar.state && option (Opt_scrollBar_right)) |
|
|
641 | window_sb_x = szHint.width - sb_w; |
|
|
642 | |
|
|
643 | if (recalc_x) |
624 | if (recalc_x) |
644 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
625 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
645 | |
626 | |
646 | if (recalc_y) |
627 | if (recalc_y) |
647 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
628 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
648 | |
629 | |
649 | ncol = width / fwidth; |
630 | ncol = width / fwidth; |
650 | nrow = height / fheight; |
631 | nrow = height / fheight; |
651 | } |
632 | } |
652 | |
633 | |
653 | /*----------------------------------------------------------------------*/ |
634 | /*----------------------------------------------------------------------*/ |
654 | /* |
635 | /* |
… | |
… | |
665 | |
646 | |
666 | ws.ws_col = ncol; |
647 | ws.ws_col = ncol; |
667 | ws.ws_row = nrow; |
648 | ws.ws_row = nrow; |
668 | ws.ws_xpixel = width; |
649 | ws.ws_xpixel = width; |
669 | ws.ws_ypixel = height; |
650 | ws.ws_ypixel = height; |
670 | (void)ioctl (pty->pty, TIOCSWINSZ, &ws); |
651 | ioctl (pty->pty, TIOCSWINSZ, &ws); |
671 | |
652 | |
672 | #if 0 |
653 | #if 0 |
673 | // TIOCSWINSZ is supposed to do this automatically and correctly |
654 | // TIOCSWINSZ is supposed to do this automatically and correctly |
674 | if (cmd_pid) /* force through to the command */ |
655 | if (cmd_pid) /* force through to the command */ |
675 | kill (-cmd_pid, SIGWINCH); |
656 | kill (-cmd_pid, SIGWINCH); |
… | |
… | |
707 | delete fontset[0]; |
688 | delete fontset[0]; |
708 | fontset[0] = fs; |
689 | fontset[0] = fs; |
709 | |
690 | |
710 | prop = (*fs)[1]->properties (); |
691 | prop = (*fs)[1]->properties (); |
711 | prop.height += lineSpace; |
692 | prop.height += lineSpace; |
|
|
693 | prop.width += letterSpace; |
712 | |
694 | |
713 | fs->set_prop (prop, false); |
695 | fs->set_prop (prop, false); |
714 | |
696 | |
715 | fwidth = prop.width; |
697 | fwidth = prop.width; |
716 | fheight = prop.height; |
698 | fheight = prop.height; |
… | |
… | |
805 | void |
787 | void |
806 | rxvt_term::set_window_color (int idx, const char *color) |
788 | rxvt_term::set_window_color (int idx, const char *color) |
807 | { |
789 | { |
808 | #ifdef XTERM_COLOR_CHANGE |
790 | #ifdef XTERM_COLOR_CHANGE |
809 | rxvt_color xcol; |
791 | rxvt_color xcol; |
810 | int i; |
|
|
811 | |
792 | |
812 | if (color == NULL || *color == '\0') |
793 | if (color == NULL || *color == '\0') |
813 | return; |
794 | return; |
814 | |
795 | |
815 | color = strdup (color); |
796 | color = strdup (color); |
… | |
… | |
817 | rs[Rs_color + idx] = color; |
798 | rs[Rs_color + idx] = color; |
818 | |
799 | |
819 | /* handle color aliases */ |
800 | /* handle color aliases */ |
820 | if (isdigit (*color)) |
801 | if (isdigit (*color)) |
821 | { |
802 | { |
822 | i = atoi (color); |
803 | int i = atoi (color); |
823 | |
804 | |
824 | if (i >= 8 && i <= 15) |
805 | if (i >= 8 && i <= 15) |
825 | { |
806 | { |
826 | /* bright colors */ |
807 | /* bright colors */ |
827 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; |
808 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; |
… | |
… | |
931 | int old_width = szHint.width; |
912 | int old_width = szHint.width; |
932 | int old_height = szHint.height; |
913 | int old_height = szHint.height; |
933 | |
914 | |
934 | window_calc (newwidth, newheight); |
915 | window_calc (newwidth, newheight); |
935 | |
916 | |
936 | 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); |
937 | XSetWMNormalHints (dpy, parent[0], &szHint); |
923 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
924 | szHint.flags |= PBaseSize | PResizeInc; |
|
|
925 | } |
938 | |
926 | |
939 | if (!ignoreparent) |
927 | if (!ignoreparent) |
940 | { |
928 | { |
941 | #ifdef SMART_RESIZE |
929 | #ifdef SMART_RESIZE |
942 | /* |
930 | /* |
… | |
… | |
982 | #else |
970 | #else |
983 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
971 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
984 | #endif |
972 | #endif |
985 | } |
973 | } |
986 | |
974 | |
|
|
975 | if (set_hint) |
|
|
976 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
977 | |
987 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
978 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
988 | |
979 | |
989 | if (fix_screen || newwidth != old_width || newheight != old_height) |
980 | if (fix_screen || newwidth != old_width || newheight != old_height) |
990 | { |
981 | { |
991 | if (scrollBar.state) |
982 | if (scrollBar.state) |
992 | { |
983 | scrollBar.resize (); |
993 | XMoveResizeWindow (dpy, scrollBar.win, |
|
|
994 | window_sb_x, 0, |
|
|
995 | scrollbar_TotalWidth (), szHint.height); |
|
|
996 | resize_scrollbar (); |
|
|
997 | } |
|
|
998 | |
984 | |
999 | XMoveResizeWindow (dpy, vt, |
985 | XMoveResizeWindow (dpy, vt, |
1000 | window_vt_x, window_vt_y, |
986 | window_vt_x, window_vt_y, |
1001 | width, height); |
987 | width, height); |
1002 | |
988 | |
1003 | #ifdef HAVE_BG_PIXMAP |
989 | #ifdef HAVE_BG_PIXMAP |
1004 | if (bgPixmap.window_size_sensitive ()) |
990 | if (bgPixmap.window_size_sensitive ()) |
1005 | update_background (); |
991 | update_background (); |
1006 | #endif |
992 | #endif |
1007 | |
|
|
1008 | scr_clear (); |
|
|
1009 | } |
993 | } |
1010 | |
994 | |
1011 | if (fix_screen || old_height == 0) |
995 | if (fix_screen || old_height == 0) |
1012 | scr_reset (); |
996 | scr_reset (); |
1013 | |
997 | |
… | |
… | |
1092 | |
1076 | |
1093 | /* Checking whether input method is running. */ |
1077 | /* Checking whether input method is running. */ |
1094 | bool |
1078 | bool |
1095 | rxvt_term::IMisRunning () |
1079 | rxvt_term::IMisRunning () |
1096 | { |
1080 | { |
1097 | char *p; |
|
|
1098 | Atom atom; |
1081 | Atom atom; |
1099 | Window win; |
1082 | Window win; |
1100 | char server[IMBUFSIZ]; |
1083 | char server[IMBUFSIZ]; |
1101 | |
1084 | |
1102 | /* get current locale modifier */ |
1085 | /* get current locale modifier */ |
1103 | if ((p = XSetLocaleModifiers (NULL)) != NULL) |
1086 | if (char *p = XSetLocaleModifiers (0)) |
1104 | { |
1087 | { |
1105 | strcpy (server, "@server="); |
1088 | strcpy (server, "@server="); |
1106 | strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ |
1089 | strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */ |
1107 | |
1090 | |
1108 | if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ |
1091 | if (p = strchr (server + 1, '@')) /* first one only */ |
1109 | *p = '\0'; |
1092 | *p = '\0'; |
1110 | |
1093 | |
1111 | atom = XInternAtom (dpy, server, False); |
1094 | atom = XInternAtom (dpy, server, False); |
1112 | win = XGetSelectionOwner (dpy, atom); |
1095 | win = XGetSelectionOwner (dpy, atom); |
1113 | |
1096 | |