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.307 by ayin, Tue Feb 19 10:47:03 2008 UTC vs.
Revision 1.322 by root, Tue Mar 30 23:00:35 2010 UTC

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);
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 {
636 szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; 627 szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth;
637 628
638 if (recalc_y) 629 if (recalc_y)
639 szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth; 630 szHint.y += DisplayHeight (dpy, display->screen) - szHint.height - 2 * ext_bwidth;
640 631
641 ncol = width / fwidth; 632 ncol = width / fwidth;
642 nrow = height / fheight; 633 nrow = height / fheight;
643} 634}
644 635
645/*----------------------------------------------------------------------*/ 636/*----------------------------------------------------------------------*/
646/* 637/*
657 648
658 ws.ws_col = ncol; 649 ws.ws_col = ncol;
659 ws.ws_row = nrow; 650 ws.ws_row = nrow;
660 ws.ws_xpixel = width; 651 ws.ws_xpixel = width;
661 ws.ws_ypixel = height; 652 ws.ws_ypixel = height;
662 (void)ioctl (pty->pty, TIOCSWINSZ, &ws); 653 ioctl (pty->pty, TIOCSWINSZ, &ws);
663 654
664#if 0 655#if 0
665 // TIOCSWINSZ is supposed to do this automatically and correctly 656 // TIOCSWINSZ is supposed to do this automatically and correctly
666 if (cmd_pid) /* force through to the command */ 657 if (cmd_pid) /* force through to the command */
667 kill (-cmd_pid, SIGWINCH); 658 kill (-cmd_pid, SIGWINCH);
697#endif 688#endif
698 689
699 delete fontset[0]; 690 delete fontset[0];
700 fontset[0] = fs; 691 fontset[0] = fs;
701 692
702 prop = (*fs)[1]->properties (); 693 prop = fs->get (0, 1)->properties ();
703 prop.height += lineSpace; 694 prop.height += lineSpace;
695 prop.width += letterSpace;
704 696
705 fs->set_prop (prop, false); 697 fs->set_prop (prop, false);
706 698
707 fwidth = prop.width; 699 fwidth = prop.width;
708 fheight = prop.height; 700 fheight = prop.height;
922 int old_width = szHint.width; 914 int old_width = szHint.width;
923 int old_height = szHint.height; 915 int old_height = szHint.height;
924 916
925 window_calc (newwidth, newheight); 917 window_calc (newwidth, newheight);
926 918
927 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);
928 XSetWMNormalHints (dpy, parent[0], &szHint); 925 XSetWMNormalHints (dpy, parent[0], &szHint);
926 szHint.flags |= PBaseSize | PResizeInc;
927 }
929 928
930 if (!ignoreparent) 929 if (!ignoreparent)
931 { 930 {
932#ifdef SMART_RESIZE 931#ifdef SMART_RESIZE
933 /* 932 /*
973#else 972#else
974 XResizeWindow (dpy, parent[0], szHint.width, szHint.height); 973 XResizeWindow (dpy, parent[0], szHint.width, szHint.height);
975#endif 974#endif
976 } 975 }
977 976
977 if (set_hint)
978 XSetWMNormalHints (dpy, parent[0], &szHint);
979
978 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 980 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
979 981
980 if (fix_screen || newwidth != old_width || newheight != old_height) 982 if (fix_screen || newwidth != old_width || newheight != old_height)
981 { 983 {
982 if (scrollBar.state) 984 if (scrollBar.state)
988 990
989#ifdef HAVE_BG_PIXMAP 991#ifdef HAVE_BG_PIXMAP
990 if (bgPixmap.window_size_sensitive ()) 992 if (bgPixmap.window_size_sensitive ())
991 update_background (); 993 update_background ();
992#endif 994#endif
993
994 scr_clear ();
995 } 995 }
996 996
997 if (fix_screen || old_height == 0) 997 if (fix_screen || old_height == 0)
998 scr_reset (); 998 scr_reset ();
999
1000 // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version
1001 //scr_touch (false);
1002 999
1003#ifdef HAVE_BG_PIXMAP 1000#ifdef HAVE_BG_PIXMAP
1004// 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 ?
1005// if (bgPixmap.pixmap) 1002// if (bgPixmap.pixmap)
1006// scr_touch (false); 1003// scr_touch (false);
1078 1075
1079/* Checking whether input method is running. */ 1076/* Checking whether input method is running. */
1080bool 1077bool
1081rxvt_term::IMisRunning () 1078rxvt_term::IMisRunning ()
1082{ 1079{
1083 char *p;
1084 Atom atom; 1080 Atom atom;
1085 Window win; 1081 Window win;
1086 char server[IMBUFSIZ]; 1082 char server[IMBUFSIZ];
1087 1083
1088 /* get current locale modifier */ 1084 /* get current locale modifier */
1089 if ((p = XSetLocaleModifiers (NULL)) != NULL) 1085 if (char *p = XSetLocaleModifiers (0))
1090 { 1086 {
1091 strcpy (server, "@server="); 1087 strcpy (server, "@server=");
1092 strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ 1088 strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */
1093 1089
1094 if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ 1090 if (p = strchr (server + 1, '@')) /* first one only */
1095 *p = '\0'; 1091 *p = '\0';
1096 1092
1097 atom = XInternAtom (dpy, server, False); 1093 atom = XInternAtom (dpy, server, False);
1098 win = XGetSelectionOwner (dpy, atom); 1094 win = XGetSelectionOwner (dpy, atom);
1099 1095
1166 1162
1167 term->make_current (); 1163 term->make_current ();
1168 1164
1169 if (text) 1165 if (text)
1170 { 1166 {
1171 void *str; 1167 wchar_t *str;
1172 1168
1173 if (!text->encoding_is_wchar && text->string.multi_byte) 1169 if (!text->encoding_is_wchar && text->string.multi_byte)
1174 { 1170 {
1175 // of course, X makes it ugly again 1171 // of course, X makes it ugly again
1176 if (term->rs[Rs_imLocale]) 1172 if (term->rs[Rs_imLocale])
1177 SET_LOCALE (term->rs[Rs_imLocale]); 1173 SET_LOCALE (term->rs[Rs_imLocale]);
1178 1174
1179 str = rxvt_temp_buf ((text->length + 1) * sizeof (wchar_t)); 1175 str = rxvt_temp_buf<wchar_t> (text->length + 1);
1180 mbstowcs ((wchar_t *)str, text->string.multi_byte, text->length + 1); 1176 mbstowcs (str, text->string.multi_byte, text->length + 1);
1181 1177
1182 if (term->rs[Rs_imLocale]) 1178 if (term->rs[Rs_imLocale])
1183 SET_LOCALE (term->locale); 1179 SET_LOCALE (term->locale);
1184 } 1180 }
1185 else 1181 else
1186 str = (void *)text->string.wide_char; 1182 str = text->string.wide_char;
1187 1183
1188 HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW, 1184 HOOK_INVOKE ((term, HOOK_XIM_PREEDIT_DRAW,
1189 DT_INT, call_data->caret, 1185 DT_INT, call_data->caret,
1190 DT_INT, call_data->chg_first, 1186 DT_INT, call_data->chg_first,
1191 DT_INT, call_data->chg_length, 1187 DT_INT, call_data->chg_length,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines