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.315 by root, Wed Nov 5 12:29:26 2008 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 ();
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 */
526void 509void
527rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) 510rxvt_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_TotalWidth (); 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/*
801void 786void
802rxvt_term::set_window_color (int idx, const char *color) 787rxvt_term::set_window_color (int idx, const char *color)
803{ 788{
804#ifdef XTERM_COLOR_CHANGE 789#ifdef XTERM_COLOR_CHANGE
805 rxvt_color xcol; 790 rxvt_color xcol;
806 int i;
807 791
808 if (color == NULL || *color == '\0') 792 if (color == NULL || *color == '\0')
809 return; 793 return;
810 794
811 color = strdup (color); 795 color = strdup (color);
813 rs[Rs_color + idx] = color; 797 rs[Rs_color + idx] = color;
814 798
815 /* handle color aliases */ 799 /* handle color aliases */
816 if (isdigit (*color)) 800 if (isdigit (*color))
817 { 801 {
818 i = atoi (color); 802 int i = atoi (color);
819 803
820 if (i >= 8 && i <= 15) 804 if (i >= 8 && i <= 15)
821 { 805 {
822 /* bright colors */ 806 /* bright colors */
823 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; 807 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8];
927 int old_width = szHint.width; 911 int old_width = szHint.width;
928 int old_height = szHint.height; 912 int old_height = szHint.height;
929 913
930 window_calc (newwidth, newheight); 914 window_calc (newwidth, newheight);
931 915
932 if (!HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END))) 916 bool set_hint = !HOOK_INVOKE ((this, HOOK_RESIZE_ALL_WINDOWS, DT_INT, newwidth, DT_INT, newheight, DT_END));
917
918 // to avoid races between us and the wm, we clear the incremental size hints around the xresizewindow
919 if (set_hint)
920 {
921 szHint.flags &= ~(PBaseSize | PResizeInc);
933 XSetWMNormalHints (dpy, parent[0], &szHint); 922 XSetWMNormalHints (dpy, parent[0], &szHint);
923 szHint.flags |= PBaseSize | PResizeInc;
924 }
934 925
935 if (!ignoreparent) 926 if (!ignoreparent)
936 { 927 {
937#ifdef SMART_RESIZE 928#ifdef SMART_RESIZE
938 /* 929 /*
978#else 969#else
979 XResizeWindow (dpy, parent[0], szHint.width, szHint.height); 970 XResizeWindow (dpy, parent[0], szHint.width, szHint.height);
980#endif 971#endif
981 } 972 }
982 973
974 if (set_hint)
975 XSetWMNormalHints (dpy, parent[0], &szHint);
976
983 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 977 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
984 978
985 if (fix_screen || newwidth != old_width || newheight != old_height) 979 if (fix_screen || newwidth != old_width || newheight != old_height)
986 { 980 {
987 if (scrollBar.state) 981 if (scrollBar.state)
988 { 982 scrollBar.resize ();
989 XMoveResizeWindow (dpy, scrollBar.win,
990 window_sb_x, 0,
991 scrollbar_TotalWidth (), szHint.height);
992 resize_scrollbar ();
993 }
994 983
995 XMoveResizeWindow (dpy, vt, 984 XMoveResizeWindow (dpy, vt,
996 window_vt_x, window_vt_y, 985 window_vt_x, window_vt_y,
997 width, height); 986 width, height);
998 987
999#ifdef HAVE_BG_PIXMAP 988#ifdef HAVE_BG_PIXMAP
1000 if (bgPixmap.window_size_sensitive ()) 989 if (bgPixmap.window_size_sensitive ())
1001 update_background (); 990 update_background ();
1002#endif 991#endif
1003
1004 scr_clear ();
1005 } 992 }
1006 993
1007 if (fix_screen || old_height == 0) 994 if (fix_screen || old_height == 0)
1008 scr_reset (); 995 scr_reset ();
1009 996

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines