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.282 by sf-exg, Thu Sep 2 15:48:11 2010 UTC vs.
Revision 1.303 by sf-exg, Sat Dec 3 11:47:31 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)
605 rs[Rs_display_name] = ":0"; 610 rs[Rs_display_name] = ":0";
606 611
607 get_options (r_argc, r_argv); 612 get_options (r_argc, r_argv);
608 613
609 if (!(display = displays.get (rs[Rs_display_name]))) 614 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]); 615 rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
613 }
614 616
615 // using a local pointer decreases code size a lot 617 // using a local pointer decreases code size a lot
616 xa = display->xa; 618 xa = display->xa;
617 619
618 set (display); 620 set (display);
627 629
628 for (int i = NUM_RESOURCES; i--; ) 630 for (int i = NUM_RESOURCES; i--; )
629 if (rs [i] == resval_undef) 631 if (rs [i] == resval_undef)
630 rs [i] = 0; 632 rs [i] = 0;
631 633
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 634#if ENABLE_PERL
643 if (!rs[Rs_perl_ext_1]) 635 if (!rs[Rs_perl_ext_1])
644 rs[Rs_perl_ext_1] = "default"; 636 rs[Rs_perl_ext_1] = "default";
645 637
646 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) 638 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
649 { 641 {
650 rxvt_perl.init (this); 642 rxvt_perl.init (this);
651 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 643 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
652 } 644 }
653#endif 645#endif
646
647 // must be called after initialising the perl interpreter as it
648 // may invoke the `on_register_command' hook
649 extract_keysym_resources ();
654 650
655 /* 651 /*
656 * set any defaults not already set 652 * set any defaults not already set
657 */ 653 */
658 if (cmd_argv && cmd_argv[0]) 654 if (cmd_argv && cmd_argv[0])
794 if (chdir (path)) 790 if (chdir (path))
795 rxvt_fatal ("unable to change into specified shell working directory, aborting.\n"); 791 rxvt_fatal ("unable to change into specified shell working directory, aborting.\n");
796 } 792 }
797 793
798 if (option (Opt_scrollBar)) 794 if (option (Opt_scrollBar))
799 scrollBar.state = STATE_IDLE; /* set existence for size calculations */ 795 scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */
800 796
801 pty = ptytty::create (); 797 pty = ptytty::create ();
798
799#ifdef HAVE_AFTERIMAGE
800 set_application_name ((char *)rs[Rs_name]);
801 set_output_threshold (OUTPUT_LEVEL_WARNING);
802#endif
803
804 // must be called before create_windows, because the latter may call set_icon
805#ifdef HAVE_PIXBUF
806 g_type_init ();
807#endif
802 808
803 create_windows (argc, argv); 809 create_windows (argc, argv);
804 810
805 init_xlocale (); 811 init_xlocale ();
806 812
812 818
813 if (option (Opt_scrollBar)) 819 if (option (Opt_scrollBar))
814 scrollBar.resize (); /* create and map scrollbar */ 820 scrollBar.resize (); /* create and map scrollbar */
815#ifdef HAVE_BG_PIXMAP 821#ifdef HAVE_BG_PIXMAP
816 { 822 {
817 bgPixmap.set_target (this); 823 bg_init ();
818 bgPixmap.invalidate ();
819 824
820#ifdef ENABLE_TRANSPARENCY 825#ifdef ENABLE_TRANSPARENCY
821 if (option (Opt_transparent)) 826 if (option (Opt_transparent))
822 { 827 {
823 bgPixmap.set_transparent (); 828 bg_set_transparent ();
824 829
825#ifdef HAVE_AFTERIMAGE
826 if (rs [Rs_blurradius]) 830 if (rs [Rs_blurradius])
827 bgPixmap.set_blur_radius (rs [Rs_blurradius]); 831 bg_set_blur (rs [Rs_blurradius]);
828#endif 832
829 if (ISSET_PIXCOLOR (Color_tint)) 833 if (ISSET_PIXCOLOR (Color_tint))
830 bgPixmap.set_tint (pix_colors_focused [Color_tint]); 834 bg_set_tint (pix_colors_focused [Color_tint]);
831 835
832 if (rs [Rs_shade]) 836 if (rs [Rs_shade])
833 bgPixmap.set_shade (rs [Rs_shade]); 837 bg_set_shade (rs [Rs_shade]);
834 838
835 bgPixmap.set_root_pixmap (); 839 bg_set_root_pixmap ();
836 XSelectInput (dpy, display->root, PropertyChangeMask); 840 XSelectInput (dpy, display->root, PropertyChangeMask);
837 rootwin_ev.start (display, display->root); 841 rootwin_ev.start (display, display->root);
838 } 842 }
839#endif 843#endif
840 844
841#ifdef BG_IMAGE_FROM_FILE 845#ifdef BG_IMAGE_FROM_FILE
842 if (rs[Rs_backgroundPixmap]) 846 if (rs[Rs_backgroundPixmap])
843 { 847 {
844 const char *p = rs[Rs_backgroundPixmap];
845
846 if ((p = strchr (p, ';')) != 0)
847 {
848 p++;
849 bgPixmap.set_geometry (p);
850 }
851 else
852 bgPixmap.set_defaultGeometry ();
853
854 if (bgPixmap.set_file (rs[Rs_backgroundPixmap])) 848 if (bg_set_file (rs[Rs_backgroundPixmap]))
855 if (!bgPixmap.window_position_sensitive ()) 849 if (!bg_window_position_sensitive ())
856 update_background (); 850 update_background ();
857 } 851 }
858#endif 852#endif
859 } 853 }
860#endif 854#endif
877#if ENABLE_XEMBED 871#if ENABLE_XEMBED
878 if (rs[Rs_embed]) 872 if (rs[Rs_embed])
879 { 873 {
880 long info[2] = { 0, XEMBED_MAPPED }; 874 long info[2] = { 0, XEMBED_MAPPED };
881 875
882 XChangeProperty (dpy, parent[0], xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], 876 XChangeProperty (dpy, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO],
883 32, PropModeReplace, (unsigned char *)&info, 2); 877 32, PropModeReplace, (unsigned char *)&info, 2);
884 } 878 }
885#endif 879#endif
886 880
881#if HAVE_STARTUP_NOTIFICATION
882 SnDisplay *snDisplay;
883 SnLauncheeContext *snContext;
884
885 snDisplay = sn_display_new (dpy, NULL, NULL);
886 snContext = sn_launchee_context_new_from_environment (snDisplay, DefaultScreen (dpy));
887
888 /* Tell the window manager that this window is part of the startup context */
889 if (snContext)
890 sn_launchee_context_setup_window (snContext, parent);
891#endif
892
887 XMapWindow (dpy, vt); 893 XMapWindow (dpy, vt);
888 XMapWindow (dpy, parent[0]); 894 XMapWindow (dpy, parent);
895
896#if HAVE_STARTUP_NOTIFICATION
897 if (snContext)
898 {
899 /* Mark the startup process as complete */
900 sn_launchee_context_complete (snContext);
901
902 sn_launchee_context_unref (snContext);
903 }
904
905 sn_display_unref (snDisplay);
906#endif
889 907
890 refresh_check (); 908 refresh_check ();
891} 909}
892 910
893/*----------------------------------------------------------------------*/ 911/*----------------------------------------------------------------------*/
894void 912void
895rxvt_term::init_env () 913rxvt_term::init_env ()
896{ 914{
897 int i;
898 char *val; 915 char *val;
899 916
900#ifdef DISPLAY_IS_IP 917#ifdef DISPLAY_IS_IP
901 /* Fixup display_name for export over pty to any interested terminal 918 /* Fixup display_name for export over pty to any interested terminal
902 * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number 919 * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number
916 val = XDisplayString (dpy); 933 val = XDisplayString (dpy);
917 934
918 if (rs[Rs_display_name] == NULL) 935 if (rs[Rs_display_name] == NULL)
919 rs[Rs_display_name] = val; /* use broken `:0' value */ 936 rs[Rs_display_name] = val; /* use broken `:0' value */
920 937
921 i = strlen (val);
922 env_display = (char *)rxvt_malloc (i + 9); 938 env_display = (char *)rxvt_malloc (strlen (val) + 9);
923 939
924 sprintf (env_display, "DISPLAY=%s", val); 940 sprintf (env_display, "DISPLAY=%s", val);
925 941
926 sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); 942 sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent);
927 943
928 /* add entries to the environment: 944 /* add entries to the environment:
929 * @ DISPLAY: in case we started with -display 945 * @ DISPLAY: in case we started with -display
930 * @ WINDOWID: X window id number of the window 946 * @ WINDOWID: X window id number of the window
931 * @ COLORTERM: terminal sub-name and also indicates its color 947 * @ COLORTERM: terminal sub-name and also indicates its color
1328 buffer [1] = h; 1344 buffer [1] = h;
1329 1345
1330 for (unsigned int i = 0; i < w * h; ++i) 1346 for (unsigned int i = 0; i < w * h; ++i)
1331 buffer [i + 2] = asbuf [i]; 1347 buffer [i + 2] = asbuf [i];
1332 1348
1333 XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, 1349 XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1334 PropModeReplace, (const unsigned char *) buffer, 2 + w * h); 1350 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1335 free (buffer); 1351 free (buffer);
1336 } 1352 }
1337 else 1353 else
1338 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); 1354 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1385 } 1401 }
1386 1402
1387 row += rowstride; 1403 row += rowstride;
1388 } 1404 }
1389 1405
1390 XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, 1406 XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1391 PropModeReplace, (const unsigned char *) buffer, 2 + w * h); 1407 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1392 free (buffer); 1408 free (buffer);
1393 } 1409 }
1394 else 1410 else
1395 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); 1411 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1397 g_object_unref (pixbuf); 1413 g_object_unref (pixbuf);
1398#endif 1414#endif
1399} 1415}
1400 1416
1401/*----------------------------------------------------------------------*/ 1417/*----------------------------------------------------------------------*/
1402/* rxvt_Create_Windows () - Open and map the window */ 1418/* Open and map the window */
1403void 1419void
1404rxvt_term::create_windows (int argc, const char *const *argv) 1420rxvt_term::create_windows (int argc, const char *const *argv)
1405{ 1421{
1406 XClassHint classHint; 1422 XClassHint classHint;
1407 XWMHints wmHint; 1423 XWMHints wmHint;
1453 } 1469 }
1454#endif 1470#endif
1455 1471
1456 window_calc (0, 0); 1472 window_calc (0, 0);
1457 1473
1458 /* sub-window placement & size in rxvt_resize_subwindows () */ 1474 /* sub-window placement & size in rxvt_term::resize_all_windows () */
1459 attributes.background_pixel = pix_colors_focused [Color_border]; 1475 attributes.background_pixel = pix_colors_focused [Color_border];
1460 attributes.border_pixel = pix_colors_focused [Color_border]; 1476 attributes.border_pixel = pix_colors_focused [Color_border];
1461 attributes.colormap = cmap; 1477 attributes.colormap = cmap;
1462 1478
1463 top = XCreateWindow (dpy, parent, 1479 top = XCreateWindow (dpy, parent,
1466 ext_bwidth, 1482 ext_bwidth,
1467 depth, InputOutput, visual, 1483 depth, InputOutput, visual,
1468 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, 1484 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect,
1469 &attributes); 1485 &attributes);
1470 1486
1471 this->parent[0] = top; 1487 this->parent = top;
1472 1488
1473 old_width = szHint.width; 1489 old_width = szHint.width;
1474 old_height = szHint.height; 1490 old_height = szHint.height;
1475 1491
1476 set_title (rs [Rs_title]); 1492 set_title (rs [Rs_title]);
1509#if ENABLE_EWMH 1525#if ENABLE_EWMH
1510 xa[XA_NET_WM_PING], 1526 xa[XA_NET_WM_PING],
1511#endif 1527#endif
1512 }; 1528 };
1513 1529
1514 XSetWMProtocols (dpy, top, protocols, sizeof (protocols) / sizeof (protocols[0])); 1530 XSetWMProtocols (dpy, top, protocols, ecb_array_length (protocols));
1515 1531
1516#if ENABLE_FRILLS 1532#if ENABLE_FRILLS
1517 if (rs[Rs_transient_for]) 1533 if (rs[Rs_transient_for])
1518 XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); 1534 XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0));
1519#endif 1535#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines