… | |
… | |
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 (); |
|
|
242 | selection_clear (true); |
236 | |
243 | |
237 | #ifdef USE_XIM |
244 | #ifdef USE_XIM |
238 | im_destroy (); |
245 | im_destroy (); |
239 | #endif |
246 | #endif |
240 | #ifdef XTERM_SCROLLBAR |
247 | 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); |
248 | if (gc) XFreeGC (dpy, gc); |
265 | |
249 | |
266 | delete drawable; |
250 | delete drawable; |
267 | // destroy all windows |
251 | // destroy all windows |
268 | if (parent[0]) |
252 | if (parent[0]) |
… | |
… | |
288 | /* clear all resources */ |
272 | /* clear all resources */ |
289 | for (int i = 0; i < allocated.size (); i++) |
273 | for (int i = 0; i < allocated.size (); i++) |
290 | free (allocated [i]); |
274 | free (allocated [i]); |
291 | |
275 | |
292 | free (selection.text); |
276 | free (selection.text); |
|
|
277 | free (selection.clip_text); |
293 | // TODO: manage env vars in child only(!) |
278 | // TODO: manage env vars in child only(!) |
294 | free (env_display); |
279 | free (env_display); |
295 | free (env_term); |
280 | free (env_term); |
296 | free (locale); |
281 | free (locale); |
297 | free (v_buffer); |
282 | free (v_buffer); |
… | |
… | |
525 | */ |
510 | */ |
526 | void |
511 | void |
527 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
512 | rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) |
528 | { |
513 | { |
529 | short recalc_x, recalc_y; |
514 | short recalc_x, recalc_y; |
530 | int x, y, sb_w, flags; |
515 | int x, y, flags; |
531 | unsigned int w, h; |
516 | unsigned int w, h; |
532 | unsigned int max_width, max_height; |
517 | unsigned int max_width, max_height; |
533 | |
518 | |
534 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
519 | szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; |
535 | szHint.win_gravity = NorthWestGravity; |
520 | szHint.win_gravity = NorthWestGravity; |
… | |
… | |
545 | if (rs[Rs_geometry]) |
530 | if (rs[Rs_geometry]) |
546 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
531 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
547 | |
532 | |
548 | if (flags & WidthValue) |
533 | if (flags & WidthValue) |
549 | { |
534 | { |
|
|
535 | if (!w) |
|
|
536 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
537 | |
550 | ncol = clamp (w, 0, std::numeric_limits<int16_t>::max ()); |
538 | ncol = clamp (w, 1, std::numeric_limits<int16_t>::max ()); |
551 | szHint.flags |= USSize; |
539 | szHint.flags |= USSize; |
552 | } |
540 | } |
553 | |
541 | |
554 | if (flags & HeightValue) |
542 | if (flags & HeightValue) |
555 | { |
543 | { |
|
|
544 | if (!h) |
|
|
545 | rxvt_fatal ("illegal window geometry (width and height must be non-zero), aborting.\n"); |
|
|
546 | |
556 | nrow = clamp (h, 0, std::numeric_limits<int16_t>::max ()); |
547 | nrow = clamp (h, 1, std::numeric_limits<int16_t>::max ()); |
557 | szHint.flags |= USSize; |
548 | szHint.flags |= USSize; |
558 | } |
549 | } |
559 | |
550 | |
560 | if (flags & XValue) |
551 | if (flags & XValue) |
561 | { |
552 | { |
… | |
… | |
592 | max_width = MAX_COLS * fwidth; |
583 | max_width = MAX_COLS * fwidth; |
593 | max_height = MAX_ROWS * fheight; |
584 | max_height = MAX_ROWS * fheight; |
594 | |
585 | |
595 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
586 | szHint.base_width = szHint.base_height = 2 * int_bwidth; |
596 | |
587 | |
597 | sb_w = 0; |
|
|
598 | window_vt_x = window_vt_y = int_bwidth; |
588 | window_vt_x = window_vt_y = int_bwidth; |
599 | |
589 | |
600 | if (scrollBar.state) |
590 | if (scrollBar.state) |
601 | { |
591 | { |
602 | sb_w = scrollBar.total_width (); |
592 | int sb_w = scrollBar.total_width (); |
603 | szHint.base_width += sb_w; |
593 | szHint.base_width += sb_w; |
604 | |
594 | |
605 | if (!option (Opt_scrollBar_right)) |
595 | if (!option (Opt_scrollBar_right)) |
606 | window_vt_x += sb_w; |
596 | window_vt_x += sb_w; |
607 | } |
597 | } |
… | |
… | |
631 | { |
621 | { |
632 | min_it (height, max_height); |
622 | min_it (height, max_height); |
633 | szHint.height = szHint.base_height + height; |
623 | szHint.height = szHint.base_height + height; |
634 | } |
624 | } |
635 | |
625 | |
636 | if (scrollBar.state && option (Opt_scrollBar_right)) |
|
|
637 | window_sb_x = szHint.width - sb_w; |
|
|
638 | |
|
|
639 | if (recalc_x) |
626 | if (recalc_x) |
640 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
627 | szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; |
641 | |
628 | |
642 | if (recalc_y) |
629 | if (recalc_y) |
643 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
630 | szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; |
644 | |
631 | |
645 | ncol = width / fwidth; |
632 | ncol = width / fwidth; |
646 | nrow = height / fheight; |
633 | nrow = height / fheight; |
647 | } |
634 | } |
648 | |
635 | |
649 | /*----------------------------------------------------------------------*/ |
636 | /*----------------------------------------------------------------------*/ |
650 | /* |
637 | /* |
… | |
… | |
661 | |
648 | |
662 | ws.ws_col = ncol; |
649 | ws.ws_col = ncol; |
663 | ws.ws_row = nrow; |
650 | ws.ws_row = nrow; |
664 | ws.ws_xpixel = width; |
651 | ws.ws_xpixel = width; |
665 | ws.ws_ypixel = height; |
652 | ws.ws_ypixel = height; |
666 | (void)ioctl (pty->pty, TIOCSWINSZ, &ws); |
653 | ioctl (pty->pty, TIOCSWINSZ, &ws); |
667 | |
654 | |
668 | #if 0 |
655 | #if 0 |
669 | // TIOCSWINSZ is supposed to do this automatically and correctly |
656 | // TIOCSWINSZ is supposed to do this automatically and correctly |
670 | if (cmd_pid) /* force through to the command */ |
657 | if (cmd_pid) /* force through to the command */ |
671 | kill (-cmd_pid, SIGWINCH); |
658 | kill (-cmd_pid, SIGWINCH); |
… | |
… | |
703 | delete fontset[0]; |
690 | delete fontset[0]; |
704 | fontset[0] = fs; |
691 | fontset[0] = fs; |
705 | |
692 | |
706 | prop = (*fs)[1]->properties (); |
693 | prop = (*fs)[1]->properties (); |
707 | prop.height += lineSpace; |
694 | prop.height += lineSpace; |
|
|
695 | prop.width += letterSpace; |
708 | |
696 | |
709 | fs->set_prop (prop, false); |
697 | fs->set_prop (prop, false); |
710 | |
698 | |
711 | fwidth = prop.width; |
699 | fwidth = prop.width; |
712 | fheight = prop.height; |
700 | fheight = prop.height; |
… | |
… | |
926 | int old_width = szHint.width; |
914 | int old_width = szHint.width; |
927 | int old_height = szHint.height; |
915 | int old_height = szHint.height; |
928 | |
916 | |
929 | window_calc (newwidth, newheight); |
917 | window_calc (newwidth, newheight); |
930 | |
918 | |
931 | if (!HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END))) |
919 | bool set_hint = !HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
|
|
920 | |
|
|
921 | // to avoid races between us and the wm, we clear the incremental size hints around the xresizewindow |
|
|
922 | if (set_hint) |
|
|
923 | { |
|
|
924 | szHint.flags &= ~(PBaseSize | PResizeInc); |
932 | XSetWMNormalHints (dpy, parent[0], &szHint); |
925 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
926 | szHint.flags |= PBaseSize | PResizeInc; |
|
|
927 | } |
933 | |
928 | |
934 | if (!ignoreparent) |
929 | if (!ignoreparent) |
935 | { |
930 | { |
936 | #ifdef SMART_RESIZE |
931 | #ifdef SMART_RESIZE |
937 | /* |
932 | /* |
… | |
… | |
977 | #else |
972 | #else |
978 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
973 | XResizeWindow (dpy, parent[0], szHint.width, szHint.height); |
979 | #endif |
974 | #endif |
980 | } |
975 | } |
981 | |
976 | |
|
|
977 | if (set_hint) |
|
|
978 | XSetWMNormalHints (dpy, parent[0], &szHint); |
|
|
979 | |
982 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
980 | fix_screen = ncol != prev_ncol || nrow != prev_nrow; |
983 | |
981 | |
984 | if (fix_screen || newwidth != old_width || newheight != old_height) |
982 | if (fix_screen || newwidth != old_width || newheight != old_height) |
985 | { |
983 | { |
986 | if (scrollBar.state) |
984 | if (scrollBar.state) |
987 | { |
985 | scrollBar.resize (); |
988 | XMoveResizeWindow (dpy, scrollBar.win, |
|
|
989 | window_sb_x, 0, |
|
|
990 | scrollBar.total_width (), szHint.height); |
|
|
991 | resize_scrollbar (); |
|
|
992 | } |
|
|
993 | |
986 | |
994 | XMoveResizeWindow (dpy, vt, |
987 | XMoveResizeWindow (dpy, vt, |
995 | window_vt_x, window_vt_y, |
988 | window_vt_x, window_vt_y, |
996 | width, height); |
989 | width, height); |
997 | |
990 | |
998 | #ifdef HAVE_BG_PIXMAP |
991 | #ifdef HAVE_BG_PIXMAP |
999 | if (bgPixmap.window_size_sensitive ()) |
992 | if (bgPixmap.window_size_sensitive ()) |
1000 | update_background (); |
993 | update_background (); |
1001 | #endif |
994 | #endif |
1002 | |
|
|
1003 | scr_clear (); |
|
|
1004 | } |
995 | } |
1005 | |
996 | |
1006 | if (fix_screen || old_height == 0) |
997 | if (fix_screen || old_height == 0) |
1007 | scr_reset (); |
998 | scr_reset (); |
1008 | |
|
|
1009 | // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version |
|
|
1010 | //scr_touch (false); |
|
|
1011 | |
999 | |
1012 | #ifdef HAVE_BG_PIXMAP |
1000 | #ifdef HAVE_BG_PIXMAP |
1013 | // TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? |
1001 | // TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? |
1014 | // if (bgPixmap.pixmap) |
1002 | // if (bgPixmap.pixmap) |
1015 | // scr_touch (false); |
1003 | // scr_touch (false); |
… | |
… | |
1087 | |
1075 | |
1088 | /* Checking whether input method is running. */ |
1076 | /* Checking whether input method is running. */ |
1089 | bool |
1077 | bool |
1090 | rxvt_term::IMisRunning () |
1078 | rxvt_term::IMisRunning () |
1091 | { |
1079 | { |
1092 | char *p; |
|
|
1093 | Atom atom; |
1080 | Atom atom; |
1094 | Window win; |
1081 | Window win; |
1095 | char server[IMBUFSIZ]; |
1082 | char server[IMBUFSIZ]; |
1096 | |
1083 | |
1097 | /* get current locale modifier */ |
1084 | /* get current locale modifier */ |
1098 | if ((p = XSetLocaleModifiers (NULL)) != NULL) |
1085 | if (char *p = XSetLocaleModifiers (0)) |
1099 | { |
1086 | { |
1100 | strcpy (server, "@server="); |
1087 | strcpy (server, "@server="); |
1101 | strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ |
1088 | strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */ |
1102 | |
1089 | |
1103 | if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ |
1090 | if (p = strchr (server + 1, '@')) /* first one only */ |
1104 | *p = '\0'; |
1091 | *p = '\0'; |
1105 | |
1092 | |
1106 | atom = XInternAtom (dpy, server, False); |
1093 | atom = XInternAtom (dpy, server, False); |
1107 | win = XGetSelectionOwner (dpy, atom); |
1094 | win = XGetSelectionOwner (dpy, atom); |
1108 | |
1095 | |
… | |
… | |
1175 | |
1162 | |
1176 | term->make_current (); |
1163 | term->make_current (); |
1177 | |
1164 | |
1178 | if (text) |
1165 | if (text) |
1179 | { |
1166 | { |
1180 | void *str; |
1167 | wchar_t *str; |
1181 | |
1168 | |
1182 | if (!text->encoding_is_wchar && text->string.multi_byte) |
1169 | if (!text->encoding_is_wchar && text->string.multi_byte) |
1183 | { |
1170 | { |
1184 | // of course, X makes it ugly again |
1171 | // of course, X makes it ugly again |
1185 | if (term->rs[Rs_imLocale]) |
1172 | if (term->rs[Rs_imLocale]) |
1186 | SET_LOCALE (term->rs[Rs_imLocale]); |
1173 | SET_LOCALE (term->rs[Rs_imLocale]); |
1187 | |
1174 | |
1188 | str = rxvt_temp_buf ((text->length + 1) * sizeof (wchar_t)); |
1175 | str = rxvt_temp_buf<wchar_t> (text->length + 1); |
1189 | mbstowcs ((wchar_t *)str, text->string.multi_byte, text->length + 1); |
1176 | mbstowcs (str, text->string.multi_byte, text->length + 1); |
1190 | |
1177 | |
1191 | if (term->rs[Rs_imLocale]) |
1178 | if (term->rs[Rs_imLocale]) |
1192 | SET_LOCALE (term->locale); |
1179 | SET_LOCALE (term->locale); |
1193 | } |
1180 | } |
1194 | else |
1181 | else |
1195 | str = (void *)text->string.wide_char; |
1182 | str = text->string.wide_char; |
1196 | |
1183 | |
1197 | HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, |
1184 | HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, |
1198 | DT_INT, call_data->caret, |
1185 | DT_INT, call_data->caret, |
1199 | DT_INT, call_data->chg_first, |
1186 | DT_INT, call_data->chg_first, |
1200 | DT_INT, call_data->chg_length, |
1187 | DT_INT, call_data->chg_length, |