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

Comparing rxvt-unicode/src/init.C (file contents):
Revision 1.283 by sf-exg, Wed Oct 13 23:04:57 2010 UTC vs.
Revision 1.304 by sf-exg, Tue Dec 6 10:27:15 2011 UTC

10 * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM> 10 * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM>
11 * Copyright (c) 1997 mj olesen <olesen@me.queensu.ca> 11 * Copyright (c) 1997 mj olesen <olesen@me.queensu.ca>
12 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> 12 * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de>
13 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> 13 * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com>
14 * - extensive modifications 14 * - extensive modifications
15 * Copyright (c) 2003-2008 Marc Lehmann <pcg@goof.com> 15 * Copyright (c) 2003-2008 Marc Lehmann <schmorp@schmorp.de>
16 * 16 *
17 * This program is free software; you can redistribute it and/or modify 17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by 18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or 19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version. 20 * (at your option) any later version.
55 55
56#ifdef HAVE_NL_LANGINFO 56#ifdef HAVE_NL_LANGINFO
57# include <langinfo.h> 57# include <langinfo.h>
58#endif 58#endif
59 59
60#ifdef HAVE_STARTUP_NOTIFICATION
61# define SN_API_NOT_YET_FROZEN
62# include <libsn/sn-launchee.h>
63#endif
64
60#ifdef DISPLAY_IS_IP 65#ifdef DISPLAY_IS_IP
61/* On Solaris link with -lsocket and -lnsl */ 66/* On Solaris link with -lsocket and -lnsl */
62#include <sys/types.h> 67#include <sys/types.h>
63#include <sys/socket.h> 68#include <sys/socket.h>
64 69
143 148
144 return rval; 149 return rval;
145} 150}
146#endif 151#endif
147 152
148const char *const def_colorName[] = 153static const char *const def_colorName[] =
149 { 154 {
150 COLOR_FOREGROUND, 155 COLOR_FOREGROUND,
151 COLOR_BACKGROUND, 156 COLOR_BACKGROUND,
152 /* low-intensity colors */ 157 /* low-intensity colors */
153 "rgb:00/00/00", // 0: black (Black) 158 "rgb:00/00/00", // 0: black (Black)
563/*----------------------------------------------------------------------*/ 568/*----------------------------------------------------------------------*/
564const char ** 569const char **
565rxvt_term::init_resources (int argc, const char *const *argv) 570rxvt_term::init_resources (int argc, const char *const *argv)
566{ 571{
567 int i, r_argc; 572 int i, r_argc;
568 const char **cmd_argv, **r_argv; 573 const char **cmd_argv;
569 574
570 /* 575 /*
571 * Look for -e option. Find => split and make cmd_argv[] of command args 576 * Look for -e option. Find => split and make cmd_argv[] of command args
572 */ 577 */
573 for (r_argc = 0; r_argc < argc; r_argc++) 578 for (r_argc = 0; r_argc < argc; r_argc++)
586 cmd_argv[i] = (const char *)argv[i + r_argc + 1]; 591 cmd_argv[i] = (const char *)argv[i + r_argc + 1];
587 592
588 cmd_argv[i] = NULL; 593 cmd_argv[i] = NULL;
589 } 594 }
590 595
591 r_argv = (const char **)rxvt_malloc (sizeof (char *) * (r_argc + 1));
592
593 for (i = 0; i < r_argc; i++)
594 r_argv[i] = (const char *)argv[i];
595
596 r_argv[i] = NULL;
597
598 rs[Rs_name] = rxvt_basename (argv[0]); 596 rs[Rs_name] = rxvt_basename (argv[0]);
599 597
600 /* 598 /*
601 * Open display, get options/resources and create the window 599 * Open display, get options/resources and create the window
602 */ 600 */
603 601
604 if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) 602 if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL)
605 rs[Rs_display_name] = ":0"; 603 rs[Rs_display_name] = ":0";
606 604
607 get_options (r_argc, r_argv); 605 get_options (r_argc, argv);
608 606
609 if (!(display = displays.get (rs[Rs_display_name]))) 607 if (!(display = displays.get (rs[Rs_display_name])))
610 {
611 free (r_argv);
612 rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]); 608 rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
613 }
614 609
615 // using a local pointer decreases code size a lot 610 // using a local pointer decreases code size a lot
616 xa = display->xa; 611 xa = display->xa;
617 612
618 set (display); 613 set (display);
621#if XFT 616#if XFT
622 if (rs[Rs_depth]) 617 if (rs[Rs_depth])
623 select_visual (strtol (rs[Rs_depth], 0, 0)); 618 select_visual (strtol (rs[Rs_depth], 0, 0));
624#endif 619#endif
625 620
626 free (r_argv);
627
628 for (int i = NUM_RESOURCES; i--; ) 621 for (int i = NUM_RESOURCES; i--; )
629 if (rs [i] == resval_undef) 622 if (rs [i] == resval_undef)
630 rs [i] = 0; 623 rs [i] = 0;
631 624
632#ifdef HAVE_AFTERIMAGE
633 set_application_name ((char *)rs[Rs_name]);
634 set_output_threshold (OUTPUT_LEVEL_WARNING);
635#endif
636
637#ifdef HAVE_PIXBUF
638 g_type_init ();
639 gdk_pixbuf_xlib_init (dpy, display->screen);
640#endif
641
642#if ENABLE_PERL 625#if ENABLE_PERL
643 if (!rs[Rs_perl_ext_1]) 626 if (!rs[Rs_perl_ext_1])
644 rs[Rs_perl_ext_1] = "default"; 627 rs[Rs_perl_ext_1] = "default";
645 628
646 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) 629 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
649 { 632 {
650 rxvt_perl.init (this); 633 rxvt_perl.init (this);
651 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 634 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
652 } 635 }
653#endif 636#endif
637
638 // must be called after initialising the perl interpreter as it
639 // may invoke the `on_register_command' hook
640 extract_keysym_resources ();
654 641
655 /* 642 /*
656 * set any defaults not already set 643 * set any defaults not already set
657 */ 644 */
658 if (cmd_argv && cmd_argv[0]) 645 if (cmd_argv && cmd_argv[0])
794 if (chdir (path)) 781 if (chdir (path))
795 rxvt_fatal ("unable to change into specified shell working directory, aborting.\n"); 782 rxvt_fatal ("unable to change into specified shell working directory, aborting.\n");
796 } 783 }
797 784
798 if (option (Opt_scrollBar)) 785 if (option (Opt_scrollBar))
799 scrollBar.state = STATE_IDLE; /* set existence for size calculations */ 786 scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */
800 787
801 pty = ptytty::create (); 788 pty = ptytty::create ();
789
790#ifdef HAVE_AFTERIMAGE
791 set_application_name ((char *)rs[Rs_name]);
792 set_output_threshold (OUTPUT_LEVEL_WARNING);
793#endif
794
795 // must be called before create_windows, because the latter may call set_icon
796#ifdef HAVE_PIXBUF
797 g_type_init ();
798#endif
802 799
803 create_windows (argc, argv); 800 create_windows (argc, argv);
804 801
805 init_xlocale (); 802 init_xlocale ();
806 803
812 809
813 if (option (Opt_scrollBar)) 810 if (option (Opt_scrollBar))
814 scrollBar.resize (); /* create and map scrollbar */ 811 scrollBar.resize (); /* create and map scrollbar */
815#ifdef HAVE_BG_PIXMAP 812#ifdef HAVE_BG_PIXMAP
816 { 813 {
817 bgPixmap.set_target (this); 814 bg_init ();
818 bgPixmap.invalidate ();
819 815
820#ifdef ENABLE_TRANSPARENCY 816#ifdef ENABLE_TRANSPARENCY
821 if (option (Opt_transparent)) 817 if (option (Opt_transparent))
822 { 818 {
823 bgPixmap.set_transparent (); 819 bg_set_transparent ();
824 820
825 if (rs [Rs_blurradius]) 821 if (rs [Rs_blurradius])
826 bgPixmap.set_blur_radius (rs [Rs_blurradius]); 822 bg_set_blur (rs [Rs_blurradius]);
827 823
828 if (ISSET_PIXCOLOR (Color_tint)) 824 if (ISSET_PIXCOLOR (Color_tint))
829 bgPixmap.set_tint (pix_colors_focused [Color_tint]); 825 bg_set_tint (pix_colors_focused [Color_tint]);
830 826
831 if (rs [Rs_shade]) 827 if (rs [Rs_shade])
832 bgPixmap.set_shade (rs [Rs_shade]); 828 bg_set_shade (rs [Rs_shade]);
833 829
834 bgPixmap.set_root_pixmap (); 830 bg_set_root_pixmap ();
835 XSelectInput (dpy, display->root, PropertyChangeMask); 831 XSelectInput (dpy, display->root, PropertyChangeMask);
836 rootwin_ev.start (display, display->root); 832 rootwin_ev.start (display, display->root);
837 } 833 }
838#endif 834#endif
839 835
840#ifdef BG_IMAGE_FROM_FILE 836#ifdef BG_IMAGE_FROM_FILE
841 if (rs[Rs_backgroundPixmap]) 837 if (rs[Rs_backgroundPixmap])
842 { 838 {
843 const char *p = rs[Rs_backgroundPixmap];
844
845 if ((p = strchr (p, ';')) != 0)
846 {
847 p++;
848 bgPixmap.set_geometry (p);
849 }
850 else
851 bgPixmap.set_defaultGeometry ();
852
853 if (bgPixmap.set_file (rs[Rs_backgroundPixmap])) 839 if (bg_set_file (rs[Rs_backgroundPixmap]))
854 if (!bgPixmap.window_position_sensitive ()) 840 if (!bg_window_position_sensitive ())
855 update_background (); 841 update_background ();
856 } 842 }
857#endif 843#endif
858 } 844 }
859#endif 845#endif
876#if ENABLE_XEMBED 862#if ENABLE_XEMBED
877 if (rs[Rs_embed]) 863 if (rs[Rs_embed])
878 { 864 {
879 long info[2] = { 0, XEMBED_MAPPED }; 865 long info[2] = { 0, XEMBED_MAPPED };
880 866
881 XChangeProperty (dpy, parent[0], xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], 867 XChangeProperty (dpy, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO],
882 32, PropModeReplace, (unsigned char *)&info, 2); 868 32, PropModeReplace, (unsigned char *)&info, 2);
883 } 869 }
884#endif 870#endif
885 871
872#if HAVE_STARTUP_NOTIFICATION
873 SnDisplay *snDisplay;
874 SnLauncheeContext *snContext;
875
876 snDisplay = sn_display_new (dpy, NULL, NULL);
877 snContext = sn_launchee_context_new_from_environment (snDisplay, DefaultScreen (dpy));
878
879 /* Tell the window manager that this window is part of the startup context */
880 if (snContext)
881 sn_launchee_context_setup_window (snContext, parent);
882#endif
883
886 XMapWindow (dpy, vt); 884 XMapWindow (dpy, vt);
887 XMapWindow (dpy, parent[0]); 885 XMapWindow (dpy, parent);
886
887#if HAVE_STARTUP_NOTIFICATION
888 if (snContext)
889 {
890 /* Mark the startup process as complete */
891 sn_launchee_context_complete (snContext);
892
893 sn_launchee_context_unref (snContext);
894 }
895
896 sn_display_unref (snDisplay);
897#endif
888 898
889 refresh_check (); 899 refresh_check ();
890} 900}
891 901
892/*----------------------------------------------------------------------*/ 902/*----------------------------------------------------------------------*/
893void 903void
894rxvt_term::init_env () 904rxvt_term::init_env ()
895{ 905{
896 int i;
897 char *val; 906 char *val;
898 907
899#ifdef DISPLAY_IS_IP 908#ifdef DISPLAY_IS_IP
900 /* Fixup display_name for export over pty to any interested terminal 909 /* Fixup display_name for export over pty to any interested terminal
901 * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number 910 * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number
915 val = XDisplayString (dpy); 924 val = XDisplayString (dpy);
916 925
917 if (rs[Rs_display_name] == NULL) 926 if (rs[Rs_display_name] == NULL)
918 rs[Rs_display_name] = val; /* use broken `:0' value */ 927 rs[Rs_display_name] = val; /* use broken `:0' value */
919 928
920 i = strlen (val);
921 env_display = (char *)rxvt_malloc (i + 9); 929 env_display = (char *)rxvt_malloc (strlen (val) + 9);
922 930
923 sprintf (env_display, "DISPLAY=%s", val); 931 sprintf (env_display, "DISPLAY=%s", val);
924 932
925 sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); 933 sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent);
926 934
927 /* add entries to the environment: 935 /* add entries to the environment:
928 * @ DISPLAY: in case we started with -display 936 * @ DISPLAY: in case we started with -display
929 * @ WINDOWID: X window id number of the window 937 * @ WINDOWID: X window id number of the window
930 * @ COLORTERM: terminal sub-name and also indicates its color 938 * @ COLORTERM: terminal sub-name and also indicates its color
1327 buffer [1] = h; 1335 buffer [1] = h;
1328 1336
1329 for (unsigned int i = 0; i < w * h; ++i) 1337 for (unsigned int i = 0; i < w * h; ++i)
1330 buffer [i + 2] = asbuf [i]; 1338 buffer [i + 2] = asbuf [i];
1331 1339
1332 XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, 1340 XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1333 PropModeReplace, (const unsigned char *) buffer, 2 + w * h); 1341 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1334 free (buffer); 1342 free (buffer);
1335 } 1343 }
1336 else 1344 else
1337 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); 1345 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1384 } 1392 }
1385 1393
1386 row += rowstride; 1394 row += rowstride;
1387 } 1395 }
1388 1396
1389 XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, 1397 XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1390 PropModeReplace, (const unsigned char *) buffer, 2 + w * h); 1398 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1391 free (buffer); 1399 free (buffer);
1392 } 1400 }
1393 else 1401 else
1394 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); 1402 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1396 g_object_unref (pixbuf); 1404 g_object_unref (pixbuf);
1397#endif 1405#endif
1398} 1406}
1399 1407
1400/*----------------------------------------------------------------------*/ 1408/*----------------------------------------------------------------------*/
1401/* rxvt_Create_Windows () - Open and map the window */ 1409/* Open and map the window */
1402void 1410void
1403rxvt_term::create_windows (int argc, const char *const *argv) 1411rxvt_term::create_windows (int argc, const char *const *argv)
1404{ 1412{
1405 XClassHint classHint; 1413 XClassHint classHint;
1406 XWMHints wmHint; 1414 XWMHints wmHint;
1452 } 1460 }
1453#endif 1461#endif
1454 1462
1455 window_calc (0, 0); 1463 window_calc (0, 0);
1456 1464
1457 /* sub-window placement & size in rxvt_resize_subwindows () */ 1465 /* sub-window placement & size in rxvt_term::resize_all_windows () */
1458 attributes.background_pixel = pix_colors_focused [Color_border]; 1466 attributes.background_pixel = pix_colors_focused [Color_border];
1459 attributes.border_pixel = pix_colors_focused [Color_border]; 1467 attributes.border_pixel = pix_colors_focused [Color_border];
1460 attributes.colormap = cmap; 1468 attributes.colormap = cmap;
1461 1469
1462 top = XCreateWindow (dpy, parent, 1470 top = XCreateWindow (dpy, parent,
1465 ext_bwidth, 1473 ext_bwidth,
1466 depth, InputOutput, visual, 1474 depth, InputOutput, visual,
1467 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, 1475 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect,
1468 &attributes); 1476 &attributes);
1469 1477
1470 this->parent[0] = top; 1478 this->parent = top;
1471 1479
1472 old_width = szHint.width; 1480 old_width = szHint.width;
1473 old_height = szHint.height; 1481 old_height = szHint.height;
1474 1482
1475 set_title (rs [Rs_title]); 1483 set_title (rs [Rs_title]);
1508#if ENABLE_EWMH 1516#if ENABLE_EWMH
1509 xa[XA_NET_WM_PING], 1517 xa[XA_NET_WM_PING],
1510#endif 1518#endif
1511 }; 1519 };
1512 1520
1513 XSetWMProtocols (dpy, top, protocols, sizeof (protocols) / sizeof (protocols[0])); 1521 XSetWMProtocols (dpy, top, protocols, ecb_array_length (protocols));
1514 1522
1515#if ENABLE_FRILLS 1523#if ENABLE_FRILLS
1516 if (rs[Rs_transient_for]) 1524 if (rs[Rs_transient_for])
1517 XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); 1525 XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0));
1518#endif 1526#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines