ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/main.C
(Generate patch)

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.303 by ayin, Sun Jan 27 22:48:33 2008 UTC vs.
Revision 1.324 by sf-exg, Wed Mar 31 13:14:50 2010 UTC

101 { 101 {
102 if (cc->c2 == c2) return c1; 102 if (cc->c2 == c2) return c1;
103 cc = (*this)[cc->c1]; 103 cc = (*this)[cc->c1];
104 } 104 }
105 105
106 // check to see wether this combination already exists otherwise 106 // check to see whether this combination already exists otherwise
107 for (cc = v.end (); cc-- > v.begin (); ) 107 for (cc = v.end (); cc-- > v.begin (); )
108 { 108 {
109 if (cc->c1 == c1 && cc->c2 == c2) 109 if (cc->c1 == c1 && cc->c2 == c2)
110 return COMPOSE_LO + (cc - v.begin ()); 110 return COMPOSE_LO + (cc - v.begin ());
111 } 111 }
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 */
526void 511void
527rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) 512rxvt_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_TotalWidth (); 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;
801void 789void
802rxvt_term::set_window_color (int idx, const char *color) 790rxvt_term::set_window_color (int idx, const char *color)
803{ 791{
804#ifdef XTERM_COLOR_CHANGE 792#ifdef XTERM_COLOR_CHANGE
805 rxvt_color xcol; 793 rxvt_color xcol;
806 int i;
807 794
808 if (color == NULL || *color == '\0') 795 if (color == NULL || *color == '\0')
809 return; 796 return;
810 797
811 color = strdup (color); 798 color = strdup (color);
813 rs[Rs_color + idx] = color; 800 rs[Rs_color + idx] = color;
814 801
815 /* handle color aliases */ 802 /* handle color aliases */
816 if (isdigit (*color)) 803 if (isdigit (*color))
817 { 804 {
818 i = atoi (color); 805 int i = atoi (color);
819 806
820 if (i >= 8 && i <= 15) 807 if (i >= 8 && i <= 15)
821 { 808 {
822 /* bright colors */ 809 /* bright colors */
823 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; 810 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8];
927 int old_width = szHint.width; 914 int old_width = szHint.width;
928 int old_height = szHint.height; 915 int old_height = szHint.height;
929 916
930 window_calc (newwidth, newheight); 917 window_calc (newwidth, newheight);
931 918
932 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);
933 XSetWMNormalHints (dpy, parent[0], &szHint); 925 XSetWMNormalHints (dpy, parent[0], &szHint);
926 szHint.flags |= PBaseSize | PResizeInc;
927 }
934 928
935 if (!ignoreparent) 929 if (!ignoreparent)
936 { 930 {
937#ifdef SMART_RESIZE 931#ifdef SMART_RESIZE
938 /* 932 /*
978#else 972#else
979 XResizeWindow (dpy, parent[0], szHint.width, szHint.height); 973 XResizeWindow (dpy, parent[0], szHint.width, szHint.height);
980#endif 974#endif
981 } 975 }
982 976
977 if (set_hint)
978 XSetWMNormalHints (dpy, parent[0], &szHint);
979
983 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 980 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
984 981
985 if (fix_screen || newwidth != old_width || newheight != old_height) 982 if (fix_screen || newwidth != old_width || newheight != old_height)
986 { 983 {
987 if (scrollBar.state) 984 if (scrollBar.state)
988 { 985 scrollBar.resize ();
989 XMoveResizeWindow (dpy, scrollBar.win,
990 window_sb_x, 0,
991 scrollbar_TotalWidth (), szHint.height);
992 resize_scrollbar ();
993 }
994 986
995 XMoveResizeWindow (dpy, vt, 987 XMoveResizeWindow (dpy, vt,
996 window_vt_x, window_vt_y, 988 window_vt_x, window_vt_y,
997 width, height); 989 width, height);
998 990
999#ifdef HAVE_BG_PIXMAP 991#ifdef HAVE_BG_PIXMAP
1000 if (bgPixmap.window_size_sensitive ()) 992 if (bgPixmap.window_size_sensitive ())
1001 update_background (); 993 update_background ();
1002#endif 994#endif
1003
1004 scr_clear ();
1005 } 995 }
1006 996
1007 if (fix_screen || old_height == 0) 997 if (fix_screen || old_height == 0)
1008 scr_reset (); 998 scr_reset ();
1009
1010 // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version
1011 //scr_touch (false);
1012 999
1013#ifdef HAVE_BG_PIXMAP 1000#ifdef HAVE_BG_PIXMAP
1014// 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 ?
1015// if (bgPixmap.pixmap) 1002// if (bgPixmap.pixmap)
1016// scr_touch (false); 1003// scr_touch (false);
1088 1075
1089/* Checking whether input method is running. */ 1076/* Checking whether input method is running. */
1090bool 1077bool
1091rxvt_term::IMisRunning () 1078rxvt_term::IMisRunning ()
1092{ 1079{
1093 char *p;
1094 Atom atom; 1080 Atom atom;
1095 Window win; 1081 Window win;
1096 char server[IMBUFSIZ]; 1082 char server[IMBUFSIZ];
1097 1083
1098 /* get current locale modifier */ 1084 /* get current locale modifier */
1099 if ((p = XSetLocaleModifiers (NULL)) != NULL) 1085 if (char *p = XSetLocaleModifiers (0))
1100 { 1086 {
1101 strcpy (server, "@server="); 1087 strcpy (server, "@server=");
1102 strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ 1088 strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */
1103 1089
1104 if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ 1090 if (p = strchr (server + 1, '@')) /* first one only */
1105 *p = '\0'; 1091 *p = '\0';
1106 1092
1107 atom = XInternAtom (dpy, server, False); 1093 atom = XInternAtom (dpy, server, False);
1108 win = XGetSelectionOwner (dpy, atom); 1094 win = XGetSelectionOwner (dpy, atom);
1109 1095
1176 1162
1177 term->make_current (); 1163 term->make_current ();
1178 1164
1179 if (text) 1165 if (text)
1180 { 1166 {
1181 void *str; 1167 wchar_t *str;
1182 1168
1183 if (!text->encoding_is_wchar && text->string.multi_byte) 1169 if (!text->encoding_is_wchar && text->string.multi_byte)
1184 { 1170 {
1185 // of course, X makes it ugly again 1171 // of course, X makes it ugly again
1186 if (term->rs[Rs_imLocale]) 1172 if (term->rs[Rs_imLocale])
1187 SET_LOCALE (term->rs[Rs_imLocale]); 1173 SET_LOCALE (term->rs[Rs_imLocale]);
1188 1174
1189 str = rxvt_temp_buf ((text->length + 1) * sizeof (wchar_t)); 1175 str = rxvt_temp_buf<wchar_t> (text->length + 1);
1190 mbstowcs ((wchar_t *)str, text->string.multi_byte, text->length + 1); 1176 mbstowcs (str, text->string.multi_byte, text->length + 1);
1191 1177
1192 if (term->rs[Rs_imLocale]) 1178 if (term->rs[Rs_imLocale])
1193 SET_LOCALE (term->locale); 1179 SET_LOCALE (term->locale);
1194 } 1180 }
1195 else 1181 else
1196 str = (void *)text->string.wide_char; 1182 str = text->string.wide_char;
1197 1183
1198 HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, 1184 HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW,
1199 DT_INT, call_data->caret, 1185 DT_INT, call_data->caret,
1200 DT_INT, call_data->chg_first, 1186 DT_INT, call_data->chg_first,
1201 DT_INT, call_data->chg_length, 1187 DT_INT, call_data->chg_length,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines