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.300 by root, Sat Jan 19 00:24:53 2008 UTC vs.
Revision 1.309 by root, Wed Feb 27 01:02:33 2008 UTC

11 * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> 11 * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA>
12 * - extensive modifications 12 * - extensive modifications
13 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> 13 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
14 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> 14 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
15 * - extensive modifications 15 * - extensive modifications
16 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com> 16 * Copyright (c) 2003-2008 Marc Lehmann <pcg@goof.com>
17 * 17 *
18 * This program is free software; you can redistribute it and/or modify 18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by 19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or 20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version. 21 * (at your option) any later version.
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);
237 selection_clear (); 235 selection_clear ();
238 236
239#ifdef USE_XIM 237#ifdef USE_XIM
240 im_destroy (); 238 im_destroy ();
241#endif 239#endif
242#ifdef XTERM_SCROLLBAR 240 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); 241 if (gc) XFreeGC (dpy, gc);
267 242
268 delete drawable; 243 delete drawable;
269 // destroy all windows 244 // destroy all windows
270 if (parent[0]) 245 if (parent[0])
337 if (display) 312 if (display)
338 { 313 {
339#if USE_XIM 314#if USE_XIM
340 im_ev.stop (display); 315 im_ev.stop (display);
341#endif 316#endif
342#if HAVE_SCROLLBARS
343 scrollbar_ev.stop (display); 317 scrollbar_ev.stop (display);
344#endif
345#if ENABLE_TRANSPARENCY || ENABLE_PERL 318#if ENABLE_TRANSPARENCY || ENABLE_PERL
346 rootwin_ev.stop (display); 319 rootwin_ev.stop (display);
347#endif 320#endif
348 incr_ev.stop (); 321 incr_ev.stop ();
349 termwin_ev.stop (display); 322 termwin_ev.stop (display);
468 DisplayString (display)); 441 DisplayString (display));
469 rxvt_emergency_cleanup (); 442 rxvt_emergency_cleanup ();
470 _exit (EXIT_FAILURE); 443 _exit (EXIT_FAILURE);
471} 444}
472 445
473/*----------------------------------------------------------------------*/
474void
475rxvt_term::init (int argc, const char *const *argv, stringvec *envv)
476{
477 this->envv = envv;
478
479 SET_R (this);
480 set_locale ("");
481 set_environ (envv); // few things in X do not call setlocale :(
482
483 init_vars ();
484
485 init_secondary ();
486
487 const char **cmd_argv = init_resources (argc, argv);
488
489#ifdef KEYSYM_RESOURCE
490 keyboard->register_done ();
491#endif
492
493#ifdef HAVE_SCROLLBARS
494 if (option (Opt_scrollBar))
495 scrollBar.setIdle (); /* set existence for size calculations */
496#endif
497
498 pty = ptytty::create ();
499
500 create_windows (argc, argv);
501
502 init_xlocale ();
503
504 scr_reset (); // initialize screen
505
506#if 0
507 XSynchronize (dpy, True);
508#endif
509
510#ifdef HAVE_SCROLLBARS
511 if (option (Opt_scrollBar))
512 resize_scrollbar (); /* create and map scrollbar */
513#endif
514#ifdef HAVE_BG_PIXMAP
515 {
516 bgPixmap.set_target (this);
517 bgPixmap.invalidate ();
518
519#ifdef ENABLE_TRANSPARENCY
520 if (option (Opt_transparent))
521 {
522 bgPixmap.set_transparent ();
523
524#ifdef HAVE_AFTERIMAGE
525 if (rs [Rs_blurradius])
526 bgPixmap.set_blur_radius (rs [Rs_blurradius]);
527#endif
528 if (ISSET_PIXCOLOR (Color_tint))
529 bgPixmap.set_tint (pix_colors_focused [Color_tint]);
530
531 if (rs [Rs_shade])
532 bgPixmap.set_shade (rs [Rs_shade]);
533
534 bgPixmap.set_root_pixmap ();
535 XSelectInput (dpy, display->root, PropertyChangeMask);
536 rootwin_ev.start (display, display->root);
537 }
538#endif
539
540#ifdef BG_IMAGE_FROM_FILE
541 if (rs[Rs_backgroundPixmap])
542 {
543 const char *p = rs[Rs_backgroundPixmap];
544
545 if ((p = strchr (p, ';')) != 0)
546 {
547 p++;
548 bgPixmap.set_geometry (p);
549 }
550 else
551 bgPixmap.set_defaultGeometry ();
552
553 if (bgPixmap.set_file (rs[Rs_backgroundPixmap]))
554 if (!bgPixmap.window_position_sensitive ())
555 update_background ();
556 }
557#endif
558 }
559#endif
560
561#if ENABLE_PERL
562 rootwin_ev.start (display, display->root);
563#endif
564
565 set_colorfgbg ();
566
567 init_command (cmd_argv);
568
569 free (cmd_argv);
570
571 if (pty->pty >= 0)
572 pty_ev.start (pty->pty, ev::READ);
573
574 HOOK_INVOKE ((this, HOOK_START, DT_END));
575
576#if ENABLE_XEMBED
577 if (rs[Rs_embed])
578 {
579 long info[2] = { 0, XEMBED_MAPPED };
580
581 XChangeProperty (dpy, parent[0], xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO],
582 32, PropModeReplace, (unsigned char *)&info, 2);
583 }
584#endif
585
586 XMapWindow (dpy, vt);
587 XMapWindow (dpy, parent[0]);
588
589 refresh_check ();
590}
591
592static struct sig_handlers 446static struct sig_handlers
593{ 447{
594 ev::sig sw_term, sw_int; 448 ev::sig sw_term, sw_int;
595 449
596 /* 450 /*
648 */ 502 */
649void 503void
650rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight) 504rxvt_term::window_calc (unsigned int newwidth, unsigned int newheight)
651{ 505{
652 short recalc_x, recalc_y; 506 short recalc_x, recalc_y;
653 int x, y, sb_w, flags; 507 int x, y, flags;
654 unsigned int w, h; 508 unsigned int w, h;
655 unsigned int max_width, max_height; 509 unsigned int max_width, max_height;
656 510
657 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; 511 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
658 szHint.win_gravity = NorthWestGravity; 512 szHint.win_gravity = NorthWestGravity;
705 szHint.win_gravity = SouthEastGravity; 559 szHint.win_gravity = SouthEastGravity;
706 else 560 else
707 szHint.win_gravity = SouthWestGravity; 561 szHint.win_gravity = SouthWestGravity;
708 } 562 }
709 } 563 }
564
565 if (!szHint.width || !szHint.height)
566 rxvt_fatal ("window width or height must not be zero, aborting.\n");
710 } 567 }
711 568
712 /* TODO: BOUNDS */ 569 /* TODO: BOUNDS */
713 width = ncol * fwidth; 570 width = ncol * fwidth;
714 height = nrow * fheight; 571 height = nrow * fheight;
715 max_width = MAX_COLS * fwidth; 572 max_width = MAX_COLS * fwidth;
716 max_height = MAX_ROWS * fheight; 573 max_height = MAX_ROWS * fheight;
717 574
718 szHint.base_width = szHint.base_height = 2 * int_bwidth; 575 szHint.base_width = szHint.base_height = 2 * int_bwidth;
719 576
720 sb_w = 0;
721 window_vt_x = window_vt_y = int_bwidth; 577 window_vt_x = window_vt_y = int_bwidth;
722 578
723 if (scrollBar.state) 579 if (scrollBar.state)
724 { 580 {
725 sb_w = scrollbar_TotalWidth (); 581 int sb_w = scrollBar.total_width ();
726 szHint.base_width += sb_w; 582 szHint.base_width += sb_w;
727 583
728 if (!option (Opt_scrollBar_right)) 584 if (!option (Opt_scrollBar_right))
729 window_vt_x += sb_w; 585 window_vt_x += sb_w;
730 } 586 }
753 else 609 else
754 { 610 {
755 min_it (height, max_height); 611 min_it (height, max_height);
756 szHint.height = szHint.base_height + height; 612 szHint.height = szHint.base_height + height;
757 } 613 }
758
759 if (scrollBar.state && option (Opt_scrollBar_right))
760 window_sb_x = szHint.width - sb_w;
761 614
762 if (recalc_x) 615 if (recalc_x)
763 szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth; 616 szHint.x += DisplayWidth (dpy, display->screen) - szHint.width - 2 * ext_bwidth;
764 617
765 if (recalc_y) 618 if (recalc_y)
924void 777void
925rxvt_term::set_window_color (int idx, const char *color) 778rxvt_term::set_window_color (int idx, const char *color)
926{ 779{
927#ifdef XTERM_COLOR_CHANGE 780#ifdef XTERM_COLOR_CHANGE
928 rxvt_color xcol; 781 rxvt_color xcol;
929 int i;
930 782
931 if (color == NULL || *color == '\0') 783 if (color == NULL || *color == '\0')
932 return; 784 return;
933 785
934 color = strdup (color); 786 color = strdup (color);
936 rs[Rs_color + idx] = color; 788 rs[Rs_color + idx] = color;
937 789
938 /* handle color aliases */ 790 /* handle color aliases */
939 if (isdigit (*color)) 791 if (isdigit (*color))
940 { 792 {
941 i = atoi (color); 793 int i = atoi (color);
942 794
943 if (i >= 8 && i <= 15) 795 if (i >= 8 && i <= 15)
944 { 796 {
945 /* bright colors */ 797 /* bright colors */
946 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; 798 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8];
1106 fix_screen = ncol != prev_ncol || nrow != prev_nrow; 958 fix_screen = ncol != prev_ncol || nrow != prev_nrow;
1107 959
1108 if (fix_screen || newwidth != old_width || newheight != old_height) 960 if (fix_screen || newwidth != old_width || newheight != old_height)
1109 { 961 {
1110 if (scrollBar.state) 962 if (scrollBar.state)
1111 { 963 scrollBar.resize ();
1112 XMoveResizeWindow (dpy, scrollBar.win,
1113 window_sb_x, 0,
1114 scrollbar_TotalWidth (), szHint.height);
1115 resize_scrollbar ();
1116 }
1117 964
1118 XMoveResizeWindow (dpy, vt, 965 XMoveResizeWindow (dpy, vt,
1119 window_vt_x, window_vt_y, 966 window_vt_x, window_vt_y,
1120 width, height); 967 width, height);
1121 968

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines