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.302 by root, Fri Jan 25 16:04:57 2008 UTC vs.
Revision 1.317 by root, Tue May 12 08:21:56 2009 UTC

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 */
530void 509void
531rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) 510rxvt_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);
805void 786void
806rxvt_term::set_window_color (int idx, const char *color) 787rxvt_term::set_window_color (int idx, const char *color)
807{ 788{
808#ifdef XTERM_COLOR_CHANGE 789#ifdef XTERM_COLOR_CHANGE
809 rxvt_color xcol; 790 rxvt_color xcol;
810 int i;
811 791
812 if (color == NULL || *color == '\0') 792 if (color == NULL || *color == '\0')
813 return; 793 return;
814 794
815 color = strdup (color); 795 color = strdup (color);
817 rs[Rs_color + idx] = color; 797 rs[Rs_color + idx] = color;
818 798
819 /* handle color aliases */ 799 /* handle color aliases */
820 if (isdigit (*color)) 800 if (isdigit (*color))
821 { 801 {
822 i = atoi (color); 802 int i = atoi (color);
823 803
824 if (i >= 8 && i <= 15) 804 if (i >= 8 && i <= 15)
825 { 805 {
826 /* bright colors */ 806 /* bright colors */
827 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; 807 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8];
931 int old_width = szHint.width; 911 int old_width = szHint.width;
932 int old_height = szHint.height; 912 int old_height = szHint.height;
933 913
934 window_calc (newwidth, newheight); 914 window_calc (newwidth, newheight);
935 915
936 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);
937 XSetWMNormalHints (dpy, parent[0], &szHint); 922 XSetWMNormalHints (dpy, parent[0], &szHint);
923 szHint.flags |= PBaseSize | PResizeInc;
924 }
938 925
939 if (!ignoreparent) 926 if (!ignoreparent)
940 { 927 {
941#ifdef SMART_RESIZE 928#ifdef SMART_RESIZE
942 /* 929 /*
982#else 969#else
983 XResizeWindow (dpy, parent[0], szHint.width, szHint.height); 970 XResizeWindow (dpy, parent[0], szHint.width, szHint.height);
984#endif 971#endif
985 } 972 }
986 973
974 if (set_hint)
975 XSetWMNormalHints (dpy, parent[0], &szHint);
976
987 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 977 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
988 978
989 if (fix_screen || newwidth != old_width || newheight != old_height) 979 if (fix_screen || newwidth != old_width || newheight != old_height)
990 { 980 {
991 if (scrollBar.state) 981 if (scrollBar.state)
992 { 982 scrollBar.resize ();
993 XMoveResizeWindow (dpy, scrollBar.win,
994 window_sb_x, 0,
995 scrollbar_TotalWidth (), szHint.height);
996 resize_scrollbar ();
997 }
998 983
999 XMoveResizeWindow (dpy, vt, 984 XMoveResizeWindow (dpy, vt,
1000 window_vt_x, window_vt_y, 985 window_vt_x, window_vt_y,
1001 width, height); 986 width, height);
1002 987
1003#ifdef HAVE_BG_PIXMAP 988#ifdef HAVE_BG_PIXMAP
1004 if (bgPixmap.window_size_sensitive ()) 989 if (bgPixmap.window_size_sensitive ())
1005 update_background (); 990 update_background ();
1006#endif 991#endif
1007
1008 scr_clear ();
1009 } 992 }
1010 993
1011 if (fix_screen || old_height == 0) 994 if (fix_screen || old_height == 0)
1012 scr_reset (); 995 scr_reset ();
1013 996
1092 1075
1093/* Checking whether input method is running. */ 1076/* Checking whether input method is running. */
1094bool 1077bool
1095rxvt_term::IMisRunning () 1078rxvt_term::IMisRunning ()
1096{ 1079{
1097 char *p;
1098 Atom atom; 1080 Atom atom;
1099 Window win; 1081 Window win;
1100 char server[IMBUFSIZ]; 1082 char server[IMBUFSIZ];
1101 1083
1102 /* get current locale modifier */ 1084 /* get current locale modifier */
1103 if ((p = XSetLocaleModifiers (NULL)) != NULL) 1085 if (char *p = XSetLocaleModifiers (0))
1104 { 1086 {
1105 strcpy (server, "@server="); 1087 strcpy (server, "@server=");
1106 strncat (server, & (p[4]), IMBUFSIZ - 9); /* skip "@im=" */ 1088 strncat (server, p + 4, IMBUFSIZ - 9); /* skip "@im=" */
1107 1089
1108 if ((p = strchr (server + 1, '@')) != NULL) /* first one only */ 1090 if (p = strchr (server + 1, '@')) /* first one only */
1109 *p = '\0'; 1091 *p = '\0';
1110 1092
1111 atom = XInternAtom (dpy, server, False); 1093 atom = XInternAtom (dpy, server, False);
1112 win = XGetSelectionOwner (dpy, atom); 1094 win = XGetSelectionOwner (dpy, atom);
1113 1095

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines