… | |
… | |
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 | |
148 | const char *const def_colorName[] = |
153 | static 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 | /*----------------------------------------------------------------------*/ |
564 | const char ** |
569 | const char ** |
565 | rxvt_term::init_resources (int argc, const char *const *argv) |
570 | rxvt_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 | /*----------------------------------------------------------------------*/ |
766 | void |
751 | void |
767 | rxvt_term::init (int argc, const char *const *argv, stringvec *envv) |
752 | rxvt_term::init (int argc, const char *const *argv) |
768 | { |
753 | { |
769 | this->envv = envv; |
|
|
770 | |
|
|
771 | SET_R (this); |
754 | SET_R (this); |
772 | set_locale (""); |
755 | set_locale (""); |
773 | set_environ (envv); // a few things in X do not call setlocale :( |
756 | set_environ (envv); // a few things in X do not call setlocale :( |
774 | |
757 | |
775 | init_vars (); |
758 | init_vars (); |
… | |
… | |
789 | if (chdir (path)) |
772 | if (chdir (path)) |
790 | rxvt_fatal ("unable to change into specified shell working directory, aborting.\n"); |
773 | rxvt_fatal ("unable to change into specified shell working directory, aborting.\n"); |
791 | } |
774 | } |
792 | |
775 | |
793 | if (option (Opt_scrollBar)) |
776 | if (option (Opt_scrollBar)) |
794 | scrollBar.state = STATE_IDLE; /* set existence for size calculations */ |
777 | scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */ |
795 | |
778 | |
796 | pty = ptytty::create (); |
779 | pty = ptytty::create (); |
|
|
780 | |
|
|
781 | #ifdef HAVE_AFTERIMAGE |
|
|
782 | set_application_name ((char *)rs[Rs_name]); |
|
|
783 | set_output_threshold (OUTPUT_LEVEL_WARNING); |
|
|
784 | #endif |
|
|
785 | |
|
|
786 | // must be called before create_windows, because the latter may call set_icon |
|
|
787 | #ifdef HAVE_PIXBUF |
|
|
788 | g_type_init (); |
|
|
789 | #endif |
797 | |
790 | |
798 | create_windows (argc, argv); |
791 | create_windows (argc, argv); |
799 | |
792 | |
800 | init_xlocale (); |
793 | init_xlocale (); |
801 | |
794 | |
… | |
… | |
807 | |
800 | |
808 | if (option (Opt_scrollBar)) |
801 | if (option (Opt_scrollBar)) |
809 | scrollBar.resize (); /* create and map scrollbar */ |
802 | scrollBar.resize (); /* create and map scrollbar */ |
810 | #ifdef HAVE_BG_PIXMAP |
803 | #ifdef HAVE_BG_PIXMAP |
811 | { |
804 | { |
812 | bgPixmap.set_target (this); |
805 | bg_init (); |
813 | bgPixmap.invalidate (); |
|
|
814 | |
806 | |
815 | #ifdef ENABLE_TRANSPARENCY |
807 | #ifdef ENABLE_TRANSPARENCY |
816 | if (option (Opt_transparent)) |
808 | if (option (Opt_transparent)) |
817 | { |
809 | { |
818 | bgPixmap.set_transparent (); |
810 | bg_set_transparent (); |
819 | |
811 | |
820 | #ifdef HAVE_AFTERIMAGE |
|
|
821 | if (rs [Rs_blurradius]) |
812 | if (rs [Rs_blurradius]) |
822 | bgPixmap.set_blur_radius (rs [Rs_blurradius]); |
813 | bg_set_blur (rs [Rs_blurradius]); |
823 | #endif |
814 | |
824 | if (ISSET_PIXCOLOR (Color_tint)) |
815 | if (ISSET_PIXCOLOR (Color_tint)) |
825 | bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
816 | bg_set_tint (pix_colors_focused [Color_tint]); |
826 | |
817 | |
827 | if (rs [Rs_shade]) |
818 | if (rs [Rs_shade]) |
828 | bgPixmap.set_shade (rs [Rs_shade]); |
819 | bg_set_shade (rs [Rs_shade]); |
829 | |
820 | |
830 | bgPixmap.set_root_pixmap (); |
821 | bg_set_root_pixmap (); |
831 | XSelectInput (dpy, display->root, PropertyChangeMask); |
822 | XSelectInput (dpy, display->root, PropertyChangeMask); |
832 | rootwin_ev.start (display, display->root); |
823 | rootwin_ev.start (display, display->root); |
833 | } |
824 | } |
834 | #endif |
825 | #endif |
835 | |
826 | |
836 | #ifdef BG_IMAGE_FROM_FILE |
827 | #ifdef BG_IMAGE_FROM_FILE |
837 | if (rs[Rs_backgroundPixmap]) |
828 | if (rs[Rs_backgroundPixmap]) |
838 | { |
829 | { |
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])) |
830 | if (bg_set_file (rs[Rs_backgroundPixmap])) |
850 | if (!bgPixmap.window_position_sensitive ()) |
831 | if (!bg_window_position_sensitive ()) |
851 | update_background (); |
832 | update_background (); |
852 | } |
833 | } |
853 | #endif |
834 | #endif |
854 | } |
835 | } |
855 | #endif |
836 | #endif |
… | |
… | |
860 | |
841 | |
861 | set_colorfgbg (); |
842 | set_colorfgbg (); |
862 | |
843 | |
863 | init_command (cmd_argv); |
844 | init_command (cmd_argv); |
864 | |
845 | |
865 | free (cmd_argv); |
|
|
866 | |
|
|
867 | if (pty->pty >= 0) |
846 | if (pty->pty >= 0) |
868 | pty_ev.start (pty->pty, ev::READ); |
847 | pty_ev.start (pty->pty, ev::READ); |
869 | |
848 | |
870 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
849 | HOOK_INVOKE ((this, HOOK_START, DT_END)); |
871 | |
850 | |
872 | #if ENABLE_XEMBED |
851 | #if ENABLE_XEMBED |
873 | if (rs[Rs_embed]) |
852 | if (rs[Rs_embed]) |
874 | { |
853 | { |
875 | long info[2] = { 0, XEMBED_MAPPED }; |
854 | long info[2] = { 0, XEMBED_MAPPED }; |
876 | |
855 | |
877 | XChangeProperty (dpy, parent[0], xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], |
856 | XChangeProperty (dpy, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], |
878 | 32, PropModeReplace, (unsigned char *)&info, 2); |
857 | 32, PropModeReplace, (unsigned char *)&info, 2); |
879 | } |
858 | } |
880 | #endif |
859 | #endif |
881 | |
860 | |
|
|
861 | #if HAVE_STARTUP_NOTIFICATION |
|
|
862 | SnDisplay *snDisplay; |
|
|
863 | SnLauncheeContext *snContext; |
|
|
864 | |
|
|
865 | snDisplay = sn_display_new (dpy, NULL, NULL); |
|
|
866 | snContext = sn_launchee_context_new_from_environment (snDisplay, DefaultScreen (dpy)); |
|
|
867 | |
|
|
868 | /* Tell the window manager that this window is part of the startup context */ |
|
|
869 | if (snContext) |
|
|
870 | sn_launchee_context_setup_window (snContext, parent); |
|
|
871 | #endif |
|
|
872 | |
882 | XMapWindow (dpy, vt); |
873 | XMapWindow (dpy, vt); |
883 | XMapWindow (dpy, parent[0]); |
874 | XMapWindow (dpy, parent); |
|
|
875 | |
|
|
876 | #if HAVE_STARTUP_NOTIFICATION |
|
|
877 | if (snContext) |
|
|
878 | { |
|
|
879 | /* Mark the startup process as complete */ |
|
|
880 | sn_launchee_context_complete (snContext); |
|
|
881 | |
|
|
882 | sn_launchee_context_unref (snContext); |
|
|
883 | } |
|
|
884 | |
|
|
885 | sn_display_unref (snDisplay); |
|
|
886 | #endif |
884 | |
887 | |
885 | refresh_check (); |
888 | refresh_check (); |
886 | } |
889 | } |
887 | |
890 | |
888 | /*----------------------------------------------------------------------*/ |
891 | /*----------------------------------------------------------------------*/ |
889 | void |
892 | void |
890 | rxvt_term::init_env () |
893 | rxvt_term::init_env () |
891 | { |
894 | { |
892 | int i; |
|
|
893 | char *val; |
895 | char *val; |
894 | |
896 | |
895 | #ifdef DISPLAY_IS_IP |
897 | #ifdef DISPLAY_IS_IP |
896 | /* Fixup display_name for export over pty to any interested terminal |
898 | /* 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 |
899 | * clients via "ESC[7n" (e.g. shells). Note we use the pure IP number |
… | |
… | |
911 | val = XDisplayString (dpy); |
913 | val = XDisplayString (dpy); |
912 | |
914 | |
913 | if (rs[Rs_display_name] == NULL) |
915 | if (rs[Rs_display_name] == NULL) |
914 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
916 | rs[Rs_display_name] = val; /* use broken `:0' value */ |
915 | |
917 | |
916 | i = strlen (val); |
|
|
917 | env_display = (char *)rxvt_malloc (i + 9); |
918 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
918 | |
919 | |
919 | sprintf (env_display, "DISPLAY=%s", val); |
920 | sprintf (env_display, "DISPLAY=%s", val); |
920 | |
921 | |
921 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); |
922 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent); |
922 | |
923 | |
923 | /* add entries to the environment: |
924 | /* add entries to the environment: |
924 | * @ DISPLAY: in case we started with -display |
925 | * @ DISPLAY: in case we started with -display |
925 | * @ WINDOWID: X window id number of the window |
926 | * @ WINDOWID: X window id number of the window |
926 | * @ COLORTERM: terminal sub-name and also indicates its color |
927 | * @ COLORTERM: terminal sub-name and also indicates its color |
… | |
… | |
1279 | |
1280 | |
1280 | if (i) |
1281 | if (i) |
1281 | ModMetaMask = modmasks[i - 1]; |
1282 | ModMetaMask = modmasks[i - 1]; |
1282 | } |
1283 | } |
1283 | |
1284 | |
|
|
1285 | void |
|
|
1286 | rxvt_term::set_icon (const char *file) |
|
|
1287 | { |
|
|
1288 | #ifdef HAVE_AFTERIMAGE |
|
|
1289 | init_asv (); |
|
|
1290 | |
|
|
1291 | ASImage *im = file2ASImage (file, 0xFFFFFFFF, SCREEN_GAMMA, 0, NULL); |
|
|
1292 | if (!im) |
|
|
1293 | { |
|
|
1294 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1295 | return; |
|
|
1296 | } |
|
|
1297 | |
|
|
1298 | unsigned int w = im->width; |
|
|
1299 | unsigned int h = im->height; |
|
|
1300 | |
|
|
1301 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
|
|
1302 | { |
|
|
1303 | rxvt_warn ("Icon image too big, continuing without.\n"); |
|
|
1304 | destroy_asimage (&im); |
|
|
1305 | return; |
|
|
1306 | } |
|
|
1307 | |
|
|
1308 | ASImage *result = scale_asimage (asv, im, |
|
|
1309 | w, h, ASA_ARGB32, |
|
|
1310 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1311 | destroy_asimage (&im); |
|
|
1312 | |
|
|
1313 | if (!result) |
|
|
1314 | { |
|
|
1315 | rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n"); |
|
|
1316 | return; |
|
|
1317 | } |
|
|
1318 | |
|
|
1319 | long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)); |
|
|
1320 | if (buffer) |
|
|
1321 | { |
|
|
1322 | ARGB32 *asbuf = result->alt.argb32; |
|
|
1323 | buffer [0] = w; |
|
|
1324 | buffer [1] = h; |
|
|
1325 | |
|
|
1326 | for (unsigned int i = 0; i < w * h; ++i) |
|
|
1327 | buffer [i + 2] = asbuf [i]; |
|
|
1328 | |
|
|
1329 | XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1330 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1331 | free (buffer); |
|
|
1332 | } |
|
|
1333 | else |
|
|
1334 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1335 | |
|
|
1336 | destroy_asimage (&result); |
|
|
1337 | #endif |
|
|
1338 | |
|
|
1339 | #ifdef HAVE_PIXBUF |
|
|
1340 | GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, NULL); |
|
|
1341 | if (!pixbuf) |
|
|
1342 | { |
|
|
1343 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1344 | return; |
|
|
1345 | } |
|
|
1346 | |
|
|
1347 | unsigned int w = gdk_pixbuf_get_width (pixbuf); |
|
|
1348 | unsigned int h = gdk_pixbuf_get_height (pixbuf); |
|
|
1349 | |
|
|
1350 | if (!IN_RANGE_INC (w, 1, 16383) || !IN_RANGE_INC (h, 1, 16383)) |
|
|
1351 | { |
|
|
1352 | rxvt_warn ("Icon image too big, continuing without.\n"); |
|
|
1353 | g_object_unref (pixbuf); |
|
|
1354 | return; |
|
|
1355 | } |
|
|
1356 | |
|
|
1357 | if (long *buffer = (long *)malloc ((2 + w * h) * sizeof (long))) |
|
|
1358 | { |
|
|
1359 | int rowstride = gdk_pixbuf_get_rowstride (pixbuf); |
|
|
1360 | unsigned char *row = gdk_pixbuf_get_pixels (pixbuf); |
|
|
1361 | int channels = gdk_pixbuf_get_n_channels (pixbuf); |
|
|
1362 | |
|
|
1363 | buffer [0] = w; |
|
|
1364 | buffer [1] = h; |
|
|
1365 | for (int i = 0; i < h; i++) |
|
|
1366 | { |
|
|
1367 | for (int j = 0; j < w; j++) |
|
|
1368 | { |
|
|
1369 | unsigned char *pixel = row + j * channels; |
|
|
1370 | long value; |
|
|
1371 | |
|
|
1372 | if (channels == 4) |
|
|
1373 | value = pixel[3]; |
|
|
1374 | else |
|
|
1375 | value = (unsigned char)0x00ff; |
|
|
1376 | |
|
|
1377 | value = (value << 8) + pixel[0]; |
|
|
1378 | value = (value << 8) + pixel[1]; |
|
|
1379 | value = (value << 8) + pixel[2]; |
|
|
1380 | buffer[(i * w + j) + 2] = value; |
|
|
1381 | } |
|
|
1382 | |
|
|
1383 | row += rowstride; |
|
|
1384 | } |
|
|
1385 | |
|
|
1386 | XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1387 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1388 | free (buffer); |
|
|
1389 | } |
|
|
1390 | else |
|
|
1391 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1392 | |
|
|
1393 | g_object_unref (pixbuf); |
|
|
1394 | #endif |
|
|
1395 | } |
|
|
1396 | |
1284 | /*----------------------------------------------------------------------*/ |
1397 | /*----------------------------------------------------------------------*/ |
1285 | /* rxvt_Create_Windows () - Open and map the window */ |
1398 | /* Open and map the window */ |
1286 | void |
1399 | void |
1287 | rxvt_term::create_windows (int argc, const char *const *argv) |
1400 | rxvt_term::create_windows (int argc, const char *const *argv) |
1288 | { |
1401 | { |
1289 | XClassHint classHint; |
1402 | XClassHint classHint; |
1290 | XWMHints wmHint; |
1403 | XWMHints wmHint; |
… | |
… | |
1336 | } |
1449 | } |
1337 | #endif |
1450 | #endif |
1338 | |
1451 | |
1339 | window_calc (0, 0); |
1452 | window_calc (0, 0); |
1340 | |
1453 | |
1341 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
1454 | /* sub-window placement & size in rxvt_term::resize_all_windows () */ |
1342 | attributes.background_pixel = pix_colors_focused [Color_border]; |
1455 | attributes.background_pixel = pix_colors_focused [Color_border]; |
1343 | attributes.border_pixel = pix_colors_focused [Color_border]; |
1456 | attributes.border_pixel = pix_colors_focused [Color_border]; |
1344 | attributes.colormap = cmap; |
1457 | attributes.colormap = cmap; |
1345 | |
1458 | |
1346 | top = XCreateWindow (dpy, parent, |
1459 | top = XCreateWindow (dpy, parent, |
… | |
… | |
1349 | ext_bwidth, |
1462 | ext_bwidth, |
1350 | depth, InputOutput, visual, |
1463 | depth, InputOutput, visual, |
1351 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1464 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1352 | &attributes); |
1465 | &attributes); |
1353 | |
1466 | |
1354 | this->parent[0] = top; |
1467 | this->parent = top; |
1355 | |
1468 | |
1356 | old_width = szHint.width; |
1469 | old_width = szHint.width; |
1357 | old_height = szHint.height; |
1470 | old_height = szHint.height; |
1358 | |
1471 | |
1359 | set_title (rs [Rs_title]); |
1472 | set_title (rs [Rs_title]); |
… | |
… | |
1368 | wmHint.window_group = top; |
1481 | wmHint.window_group = top; |
1369 | |
1482 | |
1370 | XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, |
1483 | XmbSetWMProperties (dpy, top, NULL, NULL, (char **)argv, argc, |
1371 | &szHint, &wmHint, &classHint); |
1484 | &szHint, &wmHint, &classHint); |
1372 | #if ENABLE_EWMH |
1485 | #if ENABLE_EWMH |
1373 | # ifdef HAVE_AFTERIMAGE |
|
|
1374 | /* |
1486 | /* |
1375 | * set up icon hint |
1487 | * set up icon hint |
1376 | * rs [Rs_iconfile] is path to icon |
1488 | * rs [Rs_iconfile] is path to icon |
1377 | */ |
1489 | */ |
1378 | |
1490 | |
1379 | if (rs [Rs_iconfile]) |
1491 | if (rs [Rs_iconfile]) |
1380 | { |
1492 | { |
1381 | init_asv (); |
1493 | 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 | long *buffer = (long *)malloc ((2 + w * h) * sizeof (long)); |
|
|
1389 | ASImage *result = scale_asimage (asv, im, |
|
|
1390 | w, h, ASA_ARGB32, |
|
|
1391 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1392 | destroy_asimage (&im); |
|
|
1393 | |
|
|
1394 | if (buffer && result) |
|
|
1395 | { |
|
|
1396 | ARGB32 *asbuf = result->alt.argb32; |
|
|
1397 | buffer [0] = w; |
|
|
1398 | buffer [1] = h; |
|
|
1399 | |
|
|
1400 | for (unsigned int i = 0; i < w * h; ++i) |
|
|
1401 | buffer [i + 2] = asbuf [i]; |
|
|
1402 | |
|
|
1403 | destroy_asimage (&result); |
|
|
1404 | XChangeProperty (dpy, top, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
|
|
1405 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
|
|
1406 | free (buffer); |
|
|
1407 | } |
|
|
1408 | else |
|
|
1409 | { |
|
|
1410 | if (!buffer) |
|
|
1411 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
|
|
1412 | |
|
|
1413 | if (!result) |
|
|
1414 | rxvt_warn ("Icon image transformation to ARGB failed, continuing without.\n"); |
|
|
1415 | } |
|
|
1416 | } |
|
|
1417 | else |
|
|
1418 | rxvt_warn ("Loading image icon failed, continuing without.\n"); |
|
|
1419 | } |
1494 | } |
1420 | # endif |
|
|
1421 | #endif |
1495 | #endif |
1422 | |
1496 | |
1423 | #if ENABLE_FRILLS |
1497 | #if ENABLE_FRILLS |
1424 | if (mwmhints.flags) |
1498 | if (mwmhints.flags) |
1425 | XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
1499 | XChangeProperty (dpy, top, xa[XA_MOTIF_WM_HINTS], xa[XA_MOTIF_WM_HINTS], 32, |
… | |
… | |
1431 | #if ENABLE_EWMH |
1505 | #if ENABLE_EWMH |
1432 | xa[XA_NET_WM_PING], |
1506 | xa[XA_NET_WM_PING], |
1433 | #endif |
1507 | #endif |
1434 | }; |
1508 | }; |
1435 | |
1509 | |
1436 | XSetWMProtocols (dpy, top, protocols, sizeof (protocols) / sizeof (protocols[0])); |
1510 | XSetWMProtocols (dpy, top, protocols, ecb_array_length (protocols)); |
1437 | |
1511 | |
1438 | #if ENABLE_FRILLS |
1512 | #if ENABLE_FRILLS |
1439 | if (rs[Rs_transient_for]) |
1513 | if (rs[Rs_transient_for]) |
1440 | XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
1514 | XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
1441 | #endif |
1515 | #endif |