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.277 by sf-exg, Sat Aug 28 18:20:41 2010 UTC vs.
Revision 1.307 by root, Sat Dec 17 23:17:33 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++)
577 if (r_argc == argc) 582 if (r_argc == argc)
578 cmd_argv = NULL; 583 cmd_argv = NULL;
579 else if (!argv[r_argc + 1]) 584 else if (!argv[r_argc + 1])
580 rxvt_fatal ("option '-e' requires an argument, aborting.\n"); 585 rxvt_fatal ("option '-e' requires an argument, aborting.\n");
581 else 586 else
582 {
583 cmd_argv = (const char **)rxvt_malloc (sizeof (char *) * (argc - r_argc));
584
585 for (i = 0; i < argc - r_argc - 1; i++)
586 cmd_argv[i] = (const char *)argv[i + r_argc + 1]; 587 cmd_argv = (const char **)argv + r_argc + 1;
587
588 cmd_argv[i] = NULL;
589 }
590
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 588
598 rs[Rs_name] = rxvt_basename (argv[0]); 589 rs[Rs_name] = rxvt_basename (argv[0]);
599 590
600 /* 591 /*
601 * Open display, get options/resources and create the window 592 * Open display, get options/resources and create the window
602 */ 593 */
603 594
604 if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL) 595 if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL)
605 rs[Rs_display_name] = ":0"; 596 rs[Rs_display_name] = ":0";
606 597
607 get_options (r_argc, r_argv); 598 get_options (r_argc, argv);
608 599
609 if (!(display = displays.get (rs[Rs_display_name]))) 600 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]); 601 rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
613 }
614 602
615 // using a local pointer decreases code size a lot 603 // using a local pointer decreases code size a lot
616 xa = display->xa; 604 xa = display->xa;
617 605
618 set (display); 606 set (display);
621#if XFT 609#if XFT
622 if (rs[Rs_depth]) 610 if (rs[Rs_depth])
623 select_visual (strtol (rs[Rs_depth], 0, 0)); 611 select_visual (strtol (rs[Rs_depth], 0, 0));
624#endif 612#endif
625 613
626 free (r_argv);
627
628 for (int i = NUM_RESOURCES; i--; ) 614 for (int i = NUM_RESOURCES; i--; )
629 if (rs [i] == resval_undef) 615 if (rs [i] == resval_undef)
630 rs [i] = 0; 616 rs [i] = 0;
631 617
632#ifdef HAVE_AFTERIMAGE
633 set_application_name ((char *)rs[Rs_name]);
634 set_output_threshold (OUTPUT_LEVEL_WARNING);
635#endif
636
637#if ENABLE_PERL 618#if ENABLE_PERL
638 if (!rs[Rs_perl_ext_1]) 619 if (!rs[Rs_perl_ext_1])
639 rs[Rs_perl_ext_1] = "default"; 620 rs[Rs_perl_ext_1] = "default";
640 621
641 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) 622 if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1])
644 { 625 {
645 rxvt_perl.init (this); 626 rxvt_perl.init (this);
646 HOOK_INVOKE ((this, HOOK_INIT, DT_END)); 627 HOOK_INVOKE ((this, HOOK_INIT, DT_END));
647 } 628 }
648#endif 629#endif
630
631 // must be called after initialising the perl interpreter as it
632 // may invoke the `on_register_command' hook
633 extract_keysym_resources ();
649 634
650 /* 635 /*
651 * set any defaults not already set 636 * set any defaults not already set
652 */ 637 */
653 if (cmd_argv && cmd_argv[0]) 638 if (cmd_argv && cmd_argv[0])
762 return cmd_argv; 747 return cmd_argv;
763} 748}
764 749
765/*----------------------------------------------------------------------*/ 750/*----------------------------------------------------------------------*/
766void 751void
767rxvt_term::init (int argc, const char *const *argv, stringvec *envv) 752rxvt_term::init (stringvec *argv, stringvec *envv)
768{ 753{
754 argv->push_back (0);
755 envv->push_back (0);
756
757 this->argv = argv;
769 this->envv = envv; 758 this->envv = envv;
770 759
760 init2 (argv->size () - 1, argv->begin ());
761}
762
763void
764rxvt_term::init (int argc, const char *const *argv, const char *const *envv)
765{
766#if ENABLE_PERL
767 // perl might want to access the stringvecs later, so we need to copy them
768 stringvec *args = new stringvec;
769 for (int i = 0; i < argc; i++)
770 args->push_back (strdup (argv [i]));
771
772 stringvec *envs = new stringvec;
773 for (const char *const *var = envv; *var; var++)
774 envs->push_back (strdup (*var));
775
776 init (args, envs);
777#else
778 init2 (argc, argv);
779#endif
780}
781
782void
783rxvt_term::init2 (int argc, const char *const *argv)
784{
771 SET_R (this); 785 SET_R (this);
772 set_locale (""); 786 set_locale ("");
773 set_environ (envv); // a few things in X do not call setlocale :( 787 set_environ (envv); // a few things in X do not call setlocale :(
774 788
775 init_vars (); 789 init_vars ();
789 if (chdir (path)) 803 if (chdir (path))
790 rxvt_fatal ("unable to change into specified shell working directory, aborting.\n"); 804 rxvt_fatal ("unable to change into specified shell working directory, aborting.\n");
791 } 805 }
792 806
793 if (option (Opt_scrollBar)) 807 if (option (Opt_scrollBar))
794 scrollBar.state = STATE_IDLE; /* set existence for size calculations */ 808 scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */
795 809
796 pty = ptytty::create (); 810 pty = ptytty::create ();
811
812#ifdef HAVE_AFTERIMAGE
813 set_application_name ((char *)rs[Rs_name]);
814 set_output_threshold (OUTPUT_LEVEL_WARNING);
815#endif
816
817 // must be called before create_windows, because the latter may call set_icon
818#ifdef HAVE_PIXBUF
819 g_type_init ();
820#endif
797 821
798 create_windows (argc, argv); 822 create_windows (argc, argv);
799 823
800 init_xlocale (); 824 init_xlocale ();
801 825
807 831
808 if (option (Opt_scrollBar)) 832 if (option (Opt_scrollBar))
809 scrollBar.resize (); /* create and map scrollbar */ 833 scrollBar.resize (); /* create and map scrollbar */
810#ifdef HAVE_BG_PIXMAP 834#ifdef HAVE_BG_PIXMAP
811 { 835 {
812 bgPixmap.set_target (this); 836 bg_init ();
813 bgPixmap.invalidate ();
814 837
815#ifdef ENABLE_TRANSPARENCY 838#ifdef ENABLE_TRANSPARENCY
816 if (option (Opt_transparent)) 839 if (option (Opt_transparent))
817 { 840 {
818 bgPixmap.set_transparent (); 841 bg_set_transparent ();
819 842
820#ifdef HAVE_AFTERIMAGE
821 if (rs [Rs_blurradius]) 843 if (rs [Rs_blurradius])
822 bgPixmap.set_blur_radius (rs [Rs_blurradius]); 844 bg_set_blur (rs [Rs_blurradius]);
823#endif 845
824 if (ISSET_PIXCOLOR (Color_tint)) 846 if (ISSET_PIXCOLOR (Color_tint))
825 bgPixmap.set_tint (pix_colors_focused [Color_tint]); 847 bg_set_tint (pix_colors_focused [Color_tint]);
826 848
827 if (rs [Rs_shade]) 849 if (rs [Rs_shade])
828 bgPixmap.set_shade (rs [Rs_shade]); 850 bg_set_shade (rs [Rs_shade]);
829 851
830 bgPixmap.set_root_pixmap (); 852 bg_set_root_pixmap ();
831 XSelectInput (dpy, display->root, PropertyChangeMask); 853 XSelectInput (dpy, display->root, PropertyChangeMask);
832 rootwin_ev.start (display, display->root); 854 rootwin_ev.start (display, display->root);
833 } 855 }
834#endif 856#endif
835 857
836#ifdef BG_IMAGE_FROM_FILE 858#ifdef BG_IMAGE_FROM_FILE
837 if (rs[Rs_backgroundPixmap]) 859 if (rs[Rs_backgroundPixmap])
838 {
839 const char *p = rs[Rs_backgroundPixmap];
840
841 if ((p = strchr (p, ';')) != 0)
842 {
843 p++;
844 bgPixmap.set_geometry (p);
845 }
846 else
847 bgPixmap.set_defaultGeometry ();
848
849 if (bgPixmap.set_file (rs[Rs_backgroundPixmap])) 860 if (bg_set_file (rs[Rs_backgroundPixmap]))
850 if (!bgPixmap.window_position_sensitive ()) 861 if (!bg_window_position_sensitive ())
851 update_background (); 862 update_background ();
852 }
853#endif 863#endif
854 } 864 }
855#endif 865#endif
856 866
857#if ENABLE_PERL 867#if ENABLE_PERL
860 870
861 set_colorfgbg (); 871 set_colorfgbg ();
862 872
863 init_command (cmd_argv); 873 init_command (cmd_argv);
864 874
865 free (cmd_argv);
866
867 if (pty->pty >= 0) 875 if (pty->pty >= 0)
868 pty_ev.start (pty->pty, ev::READ); 876 pty_ev.start (pty->pty, ev::READ);
869 877
870 HOOK_INVOKE ((this, HOOK_START, DT_END)); 878 HOOK_INVOKE ((this, HOOK_START, DT_END));
871 879
872#if ENABLE_XEMBED 880#if ENABLE_XEMBED
873 if (rs[Rs_embed]) 881 if (rs[Rs_embed])
874 { 882 {
875 long info[2] = { 0, XEMBED_MAPPED }; 883 long info[2] = { 0, XEMBED_MAPPED };
876 884
877 XChangeProperty (dpy, parent[0], xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], 885 XChangeProperty (dpy, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO],
878 32, PropModeReplace, (unsigned char *)&info, 2); 886 32, PropModeReplace, (unsigned char *)&info, 2);
879 } 887 }
880#endif 888#endif
881 889
890#if HAVE_STARTUP_NOTIFICATION
891 SnDisplay *snDisplay;
892 SnLauncheeContext *snContext;
893
894 snDisplay = sn_display_new (dpy, NULL, NULL);
895 snContext = sn_launchee_context_new_from_environment (snDisplay, DefaultScreen (dpy));
896
897 /* Tell the window manager that this window is part of the startup context */
898 if (snContext)
899 sn_launchee_context_setup_window (snContext, parent);
900#endif
901
882 XMapWindow (dpy, vt); 902 XMapWindow (dpy, vt);
883 XMapWindow (dpy, parent[0]); 903 XMapWindow (dpy, parent);
904
905#if HAVE_STARTUP_NOTIFICATION
906 if (snContext)
907 {
908 /* Mark the startup process as complete */
909 sn_launchee_context_complete (snContext);
910
911 sn_launchee_context_unref (snContext);
912 }
913
914 sn_display_unref (snDisplay);
915#endif
884 916
885 refresh_check (); 917 refresh_check ();
886} 918}
887 919
888/*----------------------------------------------------------------------*/ 920/*----------------------------------------------------------------------*/
889void 921void
890rxvt_term::init_env () 922rxvt_term::init_env ()
891{ 923{
892 int i;
893 char *val; 924 char *val;
894 925
895#ifdef DISPLAY_IS_IP 926#ifdef DISPLAY_IS_IP
896 /* Fixup display_name for export over pty to any interested terminal 927 /* Fixup display_name for export over pty to any interested terminal
897 * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number 928 * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number
911 val = XDisplayString (dpy); 942 val = XDisplayString (dpy);
912 943
913 if (rs[Rs_display_name] == NULL) 944 if (rs[Rs_display_name] == NULL)
914 rs[Rs_display_name] = val; /* use broken `:0' value */ 945 rs[Rs_display_name] = val; /* use broken `:0' value */
915 946
916 i = strlen (val);
917 env_display = (char *)rxvt_malloc (i + 9); 947 env_display = (char *)rxvt_malloc (strlen (val) + 9);
918 948
919 sprintf (env_display, "DISPLAY=%s", val); 949 sprintf (env_display, "DISPLAY=%s", val);
920 950
921 sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); 951 sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent);
922 952
923 /* add entries to the environment: 953 /* add entries to the environment:
924 * @ DISPLAY: in case we started with -display 954 * @ DISPLAY: in case we started with -display
925 * @ WINDOWID: X window id number of the window 955 * @ WINDOWID: X window id number of the window
926 * @ COLORTERM: terminal sub-name and also indicates its color 956 * @ COLORTERM: terminal sub-name and also indicates its color
959 unsetenv ("TERMCAP"); /* terminfo should be okay */ 989 unsetenv ("TERMCAP"); /* terminfo should be okay */
960#endif /* HAVE_UNSETENV */ 990#endif /* HAVE_UNSETENV */
961} 991}
962 992
963/*----------------------------------------------------------------------*/ 993/*----------------------------------------------------------------------*/
964/*
965 * This is more or less stolen straight from XFree86 xterm.
966 * This should support all European type languages.
967 */
968void 994void
969rxvt_term::set_locale (const char *locale) 995rxvt_term::set_locale (const char *locale)
970{ 996{
971 set_environ (envv); 997 set_environ (envv);
972 998
992 SET_LOCALE (this->locale); 1018 SET_LOCALE (this->locale);
993 mbstate.reset (); 1019 mbstate.reset ();
994#endif 1020#endif
995 1021
996#if HAVE_NL_LANGINFO 1022#if HAVE_NL_LANGINFO
997 char *codeset = strdup (nl_langinfo (CODESET)); 1023 char *codeset = nl_langinfo (CODESET);
998 // /^UTF.?8/i 1024 // /^UTF.?8/i
999 enc_utf8 = (codeset[0] == 'U' || codeset[0] == 'u') 1025 enc_utf8 = (codeset[0] == 'U' || codeset[0] == 'u')
1000 && (codeset[1] == 'T' || codeset[1] == 't') 1026 && (codeset[1] == 'T' || codeset[1] == 't')
1001 && (codeset[2] == 'F' || codeset[2] == 'f') 1027 && (codeset[2] == 'F' || codeset[2] == 'f')
1002 && (codeset[3] == '8' || codeset[4] == '8'); 1028 && (codeset[3] == '8' || codeset[4] == '8');
1003 free (codeset);
1004#else 1029#else
1005 enc_utf8 = 0; 1030 enc_utf8 = 0;
1006#endif 1031#endif
1007} 1032}
1008 1033
1011{ 1036{
1012 set_environ (envv); 1037 set_environ (envv);
1013 1038
1014#ifdef USE_XIM 1039#ifdef USE_XIM
1015 if (!locale) 1040 if (!locale)
1016 rxvt_warn ("setting locale failed, working without locale support.\n"); 1041 rxvt_warn ("setting locale failed, continuing without locale support.\n");
1017 else 1042 else
1018 { 1043 {
1019 set_string_property (xa[XA_WM_LOCALE_NAME], locale); 1044 set_string_property (xa[XA_WM_LOCALE_NAME], locale);
1020 1045
1021 if (!XSupportsLocale ()) 1046 if (!XSupportsLocale ())
1022 { 1047 {
1023 rxvt_warn ("the locale is not supported by Xlib, working without locale support.\n"); 1048 rxvt_warn ("the locale is not supported by Xlib, continuing without locale support.\n");
1024 return; 1049 return;
1025 } 1050 }
1026 1051
1027 im_ev.start (display); 1052 im_ev.start (display);
1028 1053
1279 1304
1280 if (i) 1305 if (i)
1281 ModMetaMask = modmasks[i - 1]; 1306 ModMetaMask = modmasks[i - 1];
1282} 1307}
1283 1308
1309void
1310rxvt_term::set_icon (const char *file)
1311{
1312#ifdef HAVE_AFTERIMAGE
1313 init_asv ();
1314
1315 ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
1316 if (!im)
1317 {
1318 rxvt_warn ("Loading image icon failed, continuing without.\n");
1319 return;
1320 }
1321
1322 unsigned int w = im->width;
1323 unsigned int h = im->height;
1324
1325 if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383))
1326 {
1327 rxvt_warn ("Icon image too big, continuing without.\n");
1328 destroy_asimage (&im);
1329 return;
1330 }
1331
1332 ASImage *result = scale_asimage (asv, im,
1333 w, h, ASA_ARGB32,
1334 100, ASIMAGE_QUALITY_DEFAULT);
1335 destroy_asimage (&im);
1336
1337 if (!result)
1338 {
1339 rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n");
1340 return;
1341 }
1342
1343 long *buffer = (long *)malloc ((2 + w * h) * sizeof (long));
1344 if (buffer)
1345 {
1346 ARGB32 *asbuf = result->alt.argb32;
1347 buffer [0] = w;
1348 buffer [1] = h;
1349
1350 for (unsigned int i = 0; i < w * h; ++i)
1351 buffer [i + 2] = asbuf [i];
1352
1353 XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1354 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1355 free (buffer);
1356 }
1357 else
1358 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1359
1360 destroy_asimage (&result);
1361#endif
1362
1363#ifdef HAVE_PIXBUF
1364 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL);
1365 if (!pixbuf)
1366 {
1367 rxvt_warn ("Loading image icon failed, continuing without.\n");
1368 return;
1369 }
1370
1371 unsigned int w = gdk_pixbuf_get_width (pixbuf);
1372 unsigned int h = gdk_pixbuf_get_height (pixbuf);
1373
1374 if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383))
1375 {
1376 rxvt_warn ("Icon image too big, continuing without.\n");
1377 g_object_unref (pixbuf);
1378 return;
1379 }
1380
1381 if (long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)))
1382 {
1383 int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
1384 unsigned char *row = gdk_pixbuf_get_pixels (pixbuf);
1385 int channels = gdk_pixbuf_get_n_channels (pixbuf);
1386
1387 buffer [0] = w;
1388 buffer [1] = h;
1389 for (int i = 0; i < h; i++)
1390 {
1391 for (int j = 0; j < w; j++)
1392 {
1393 unsigned char *pixel = row + j * channels;
1394 long value;
1395
1396 if (channels == 4)
1397 value = pixel[3];
1398 else
1399 value = (unsigned char)0x00ff;
1400
1401 value = (value << 8) + pixel[0];
1402 value = (value << 8) + pixel[1];
1403 value = (value << 8) + pixel[2];
1404 buffer[(i * w + j) + 2] = value;
1405 }
1406
1407 row += rowstride;
1408 }
1409
1410 XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1411 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1412 free (buffer);
1413 }
1414 else
1415 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1416
1417 g_object_unref (pixbuf);
1418#endif
1419}
1420
1284/*----------------------------------------------------------------------*/ 1421/*----------------------------------------------------------------------*/
1285/* rxvt_Create_Windows () - Open and map the window */ 1422/* Open and map the window */
1286void 1423void
1287rxvt_term::create_windows (int argc, const char *const *argv) 1424rxvt_term::create_windows (int argc, const char *const *argv)
1288{ 1425{
1289 XClassHint classHint; 1426 XClassHint classHint;
1290 XWMHints wmHint; 1427 XWMHints wmHint;
1336 } 1473 }
1337#endif 1474#endif
1338 1475
1339 window_calc (0, 0); 1476 window_calc (0, 0);
1340 1477
1341 /* sub-window placement & size in rxvt_resize_subwindows () */ 1478 /* sub-window placement & size in rxvt_term::resize_all_windows () */
1342 attributes.background_pixel = pix_colors_focused [Color_border]; 1479 attributes.background_pixel = pix_colors_focused [Color_border];
1343 attributes.border_pixel = pix_colors_focused [Color_border]; 1480 attributes.border_pixel = pix_colors_focused [Color_border];
1344 attributes.colormap = cmap; 1481 attributes.colormap = cmap;
1345 1482
1346 top = XCreateWindow (dpy, parent, 1483 top = XCreateWindow (dpy, parent,
1349 ext_bwidth, 1486 ext_bwidth,
1350 depth, InputOutput, visual, 1487 depth, InputOutput, visual,
1351 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, 1488 CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect,
1352 &attributes); 1489 &attributes);
1353 1490
1354 this->parent[0] = top; 1491 this->parent = top;
1355 1492
1356 old_width = szHint.width; 1493 old_width = szHint.width;
1357 old_height = szHint.height; 1494 old_height = szHint.height;
1358 1495
1359 set_title (rs [Rs_title]); 1496 set_title (rs [Rs_title]);
1368 wmHint.window_group = top; 1505 wmHint.window_group = top;
1369 1506
1370 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, 1507 XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc,
1371 &szHint, &wmHint, &classHint); 1508 &szHint, &wmHint, &classHint);
1372#if ENABLE_EWMH 1509#if ENABLE_EWMH
1373# ifdef HAVE_AFTERIMAGE
1374 /* 1510 /*
1375 * set up icon hint 1511 * set up icon hint
1376 * rs [Rs_iconfile] is path to icon 1512 * rs [Rs_iconfile] is path to icon
1377 */ 1513 */
1378 1514
1379 if (rs [Rs_iconfile]) 1515 if (rs [Rs_iconfile])
1380 { 1516 {
1381 init_asv (); 1517 set_icon (rs [Rs_iconfile]);
1382
1383 ASImage *im = file2ASImage (rs [Rs_iconfile], 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL);
1384 if (im)
1385 {
1386 int w = im->width;
1387 int h = im->height;
1388 ASImage *result = scale_asimage (asv, im,
1389 w, h, ASA_ARGB32,
1390 100, ASIMAGE_QUALITY_DEFAULT);
1391 destroy_asimage (&im);
1392
1393 if (result)
1394 {
1395 long *buffer = (long *)malloc ((2 + w * h) * sizeof (long));
1396 if (buffer)
1397 {
1398 ARGB32 *asbuf = result->alt.argb32;
1399 buffer [0] = w;
1400 buffer [1] = h;
1401
1402 for (unsigned int i = 0; i < w * h; ++i)
1403 buffer [i + 2] = asbuf [i];
1404
1405 XChangeProperty (dpy, top, xa[XA_NET_WM_ICON], XA_CARDINAL, 32,
1406 PropModeReplace, (const unsigned char *) buffer, 2 + w * h);
1407 free (buffer);
1408 }
1409 else
1410 rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n");
1411
1412 destroy_asimage (&result);
1413 }
1414 else
1415 rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n");
1416 }
1417 else
1418 rxvt_warn ("Loading image icon failed, continuing without.\n");
1419 } 1518 }
1420# endif
1421#endif 1519#endif
1422 1520
1423#if ENABLE_FRILLS 1521#if ENABLE_FRILLS
1424 if (mwmhints.flags) 1522 if (mwmhints.flags)
1425 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, 1523 XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32,
1431#if ENABLE_EWMH 1529#if ENABLE_EWMH
1432 xa[XA_NET_WM_PING], 1530 xa[XA_NET_WM_PING],
1433#endif 1531#endif
1434 }; 1532 };
1435 1533
1436 XSetWMProtocols (dpy, top, protocols, sizeof (protocols) / sizeof (protocols[0])); 1534 XSetWMProtocols (dpy, top, protocols, ecb_array_length (protocols));
1437 1535
1438#if ENABLE_FRILLS 1536#if ENABLE_FRILLS
1439 if (rs[Rs_transient_for]) 1537 if (rs[Rs_transient_for])
1440 XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); 1538 XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0));
1441#endif 1539#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines