… | |
… | |
53 | # endif |
53 | # endif |
54 | #endif |
54 | #endif |
55 | |
55 | |
56 | #ifdef HAVE_NL_LANGINFO |
56 | #ifdef HAVE_NL_LANGINFO |
57 | # include <langinfo.h> |
57 | # include <langinfo.h> |
|
|
58 | #endif |
|
|
59 | |
|
|
60 | #ifdef HAVE_STARTUP_NOTIFICATION |
|
|
61 | # define SN_API_NOT_YET_FROZEN |
|
|
62 | # include <libsn/sn-launchee.h> |
58 | #endif |
63 | #endif |
59 | |
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> |
… | |
… | |
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++) |
… | |
… | |
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 | #endif |
|
|
640 | |
|
|
641 | #if ENABLE_PERL |
625 | #if ENABLE_PERL |
642 | if (!rs[Rs_perl_ext_1]) |
626 | if (!rs[Rs_perl_ext_1]) |
643 | rs[Rs_perl_ext_1] = "default"; |
627 | rs[Rs_perl_ext_1] = "default"; |
644 | |
628 | |
645 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
629 | if ((rs[Rs_perl_ext_1] && *rs[Rs_perl_ext_1]) |
… | |
… | |
648 | { |
632 | { |
649 | rxvt_perl.init (this); |
633 | rxvt_perl.init (this); |
650 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
634 | HOOK_INVOKE ((this, HOOK_INIT, DT_END)); |
651 | } |
635 | } |
652 | #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 (); |
653 | |
641 | |
654 | /* |
642 | /* |
655 | * set any defaults not already set |
643 | * set any defaults not already set |
656 | */ |
644 | */ |
657 | if (cmd_argv && cmd_argv[0]) |
645 | if (cmd_argv && cmd_argv[0]) |
… | |
… | |
766 | return cmd_argv; |
754 | return cmd_argv; |
767 | } |
755 | } |
768 | |
756 | |
769 | /*----------------------------------------------------------------------*/ |
757 | /*----------------------------------------------------------------------*/ |
770 | void |
758 | void |
771 | rxvt_term::init (int argc, const char *const *argv, stringvec *envv) |
759 | rxvt_term::init (int argc, const char *const *argv) |
772 | { |
760 | { |
773 | this->envv = envv; |
|
|
774 | |
|
|
775 | SET_R (this); |
761 | SET_R (this); |
776 | set_locale (""); |
762 | set_locale (""); |
777 | set_environ (envv); // a few things in X do not call setlocale :( |
763 | set_environ (envv); // a few things in X do not call setlocale :( |
778 | |
764 | |
779 | init_vars (); |
765 | init_vars (); |
… | |
… | |
793 | if (chdir (path)) |
779 | if (chdir (path)) |
794 | rxvt_fatal ("unable to change into specified shell working directory, aborting.\n"); |
780 | rxvt_fatal ("unable to change into specified shell working directory, aborting.\n"); |
795 | } |
781 | } |
796 | |
782 | |
797 | if (option (Opt_scrollBar)) |
783 | if (option (Opt_scrollBar)) |
798 | scrollBar.state = STATE_IDLE; /* set existence for size calculations */ |
784 | scrollBar.state = SB_STATE_IDLE; /* set existence for size calculations */ |
799 | |
785 | |
800 | pty = ptytty::create (); |
786 | pty = ptytty::create (); |
|
|
787 | |
|
|
788 | #ifdef HAVE_AFTERIMAGE |
|
|
789 | set_application_name ((char *)rs[Rs_name]); |
|
|
790 | set_output_threshold (OUTPUT_LEVEL_WARNING); |
|
|
791 | #endif |
|
|
792 | |
|
|
793 | // must be called before create_windows, because the latter may call set_icon |
|
|
794 | #ifdef HAVE_PIXBUF |
|
|
795 | g_type_init (); |
|
|
796 | #endif |
801 | |
797 | |
802 | create_windows (argc, argv); |
798 | create_windows (argc, argv); |
803 | |
799 | |
804 | init_xlocale (); |
800 | init_xlocale (); |
805 | |
801 | |
… | |
… | |
836 | #endif |
832 | #endif |
837 | |
833 | |
838 | #ifdef BG_IMAGE_FROM_FILE |
834 | #ifdef BG_IMAGE_FROM_FILE |
839 | if (rs[Rs_backgroundPixmap]) |
835 | if (rs[Rs_backgroundPixmap]) |
840 | { |
836 | { |
841 | const char *p = rs[Rs_backgroundPixmap]; |
|
|
842 | |
|
|
843 | if ((p = strchr (p, ';')) != 0) |
|
|
844 | { |
|
|
845 | p++; |
|
|
846 | bg_set_geometry (p); |
|
|
847 | } |
|
|
848 | else |
|
|
849 | bg_set_default_geometry (); |
|
|
850 | |
|
|
851 | if (bg_set_file (rs[Rs_backgroundPixmap])) |
837 | if (bg_set_file (rs[Rs_backgroundPixmap])) |
852 | if (!bg_window_position_sensitive ()) |
838 | if (!bg_window_position_sensitive ()) |
853 | update_background (); |
839 | update_background (); |
854 | } |
840 | } |
855 | #endif |
841 | #endif |
… | |
… | |
874 | #if ENABLE_XEMBED |
860 | #if ENABLE_XEMBED |
875 | if (rs[Rs_embed]) |
861 | if (rs[Rs_embed]) |
876 | { |
862 | { |
877 | long info[2] = { 0, XEMBED_MAPPED }; |
863 | long info[2] = { 0, XEMBED_MAPPED }; |
878 | |
864 | |
879 | XChangeProperty (dpy, parent[0], xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], |
865 | XChangeProperty (dpy, parent, xa[XA_XEMBED_INFO], xa[XA_XEMBED_INFO], |
880 | 32, PropModeReplace, (unsigned char *)&info, 2); |
866 | 32, PropModeReplace, (unsigned char *)&info, 2); |
881 | } |
867 | } |
882 | #endif |
868 | #endif |
883 | |
869 | |
|
|
870 | #if HAVE_STARTUP_NOTIFICATION |
|
|
871 | SnDisplay *snDisplay; |
|
|
872 | SnLauncheeContext *snContext; |
|
|
873 | |
|
|
874 | snDisplay = sn_display_new (dpy, NULL, NULL); |
|
|
875 | snContext = sn_launchee_context_new_from_environment (snDisplay, DefaultScreen (dpy)); |
|
|
876 | |
|
|
877 | /* Tell the window manager that this window is part of the startup context */ |
|
|
878 | if (snContext) |
|
|
879 | sn_launchee_context_setup_window (snContext, parent); |
|
|
880 | #endif |
|
|
881 | |
884 | XMapWindow (dpy, vt); |
882 | XMapWindow (dpy, vt); |
885 | XMapWindow (dpy, parent[0]); |
883 | XMapWindow (dpy, parent); |
|
|
884 | |
|
|
885 | #if HAVE_STARTUP_NOTIFICATION |
|
|
886 | if (snContext) |
|
|
887 | { |
|
|
888 | /* Mark the startup process as complete */ |
|
|
889 | sn_launchee_context_complete (snContext); |
|
|
890 | |
|
|
891 | sn_launchee_context_unref (snContext); |
|
|
892 | } |
|
|
893 | |
|
|
894 | sn_display_unref (snDisplay); |
|
|
895 | #endif |
886 | |
896 | |
887 | refresh_check (); |
897 | refresh_check (); |
888 | } |
898 | } |
889 | |
899 | |
890 | /*----------------------------------------------------------------------*/ |
900 | /*----------------------------------------------------------------------*/ |
… | |
… | |
916 | |
926 | |
917 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
927 | env_display = (char *)rxvt_malloc (strlen (val) + 9); |
918 | |
928 | |
919 | sprintf (env_display, "DISPLAY=%s", val); |
929 | sprintf (env_display, "DISPLAY=%s", val); |
920 | |
930 | |
921 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent[0]); |
931 | sprintf (env_windowid, "WINDOWID=%lu", (unsigned long)parent); |
922 | |
932 | |
923 | /* add entries to the environment: |
933 | /* add entries to the environment: |
924 | * @ DISPLAY: in case we started with -display |
934 | * @ DISPLAY: in case we started with -display |
925 | * @ WINDOWID: X window id number of the window |
935 | * @ WINDOWID: X window id number of the window |
926 | * @ COLORTERM: terminal sub-name and also indicates its color |
936 | * @ COLORTERM: terminal sub-name and also indicates its color |
… | |
… | |
1323 | buffer [1] = h; |
1333 | buffer [1] = h; |
1324 | |
1334 | |
1325 | for (unsigned int i = 0; i < w * h; ++i) |
1335 | for (unsigned int i = 0; i < w * h; ++i) |
1326 | buffer [i + 2] = asbuf [i]; |
1336 | buffer [i + 2] = asbuf [i]; |
1327 | |
1337 | |
1328 | XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
1338 | XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
1329 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
1339 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
1330 | free (buffer); |
1340 | free (buffer); |
1331 | } |
1341 | } |
1332 | else |
1342 | else |
1333 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
1343 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
… | |
… | |
1380 | } |
1390 | } |
1381 | |
1391 | |
1382 | row += rowstride; |
1392 | row += rowstride; |
1383 | } |
1393 | } |
1384 | |
1394 | |
1385 | XChangeProperty (dpy, parent[0], xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
1395 | XChangeProperty (dpy, parent, xa[XA_NET_WM_ICON], XA_CARDINAL, 32, |
1386 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
1396 | PropModeReplace, (const unsigned char *) buffer, 2 + w * h); |
1387 | free (buffer); |
1397 | free (buffer); |
1388 | } |
1398 | } |
1389 | else |
1399 | else |
1390 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
1400 | rxvt_warn ("Memory allocation for icon hint failed, continuing without.\n"); |
… | |
… | |
1392 | g_object_unref (pixbuf); |
1402 | g_object_unref (pixbuf); |
1393 | #endif |
1403 | #endif |
1394 | } |
1404 | } |
1395 | |
1405 | |
1396 | /*----------------------------------------------------------------------*/ |
1406 | /*----------------------------------------------------------------------*/ |
1397 | /* rxvt_Create_Windows () - Open and map the window */ |
1407 | /* Open and map the window */ |
1398 | void |
1408 | void |
1399 | rxvt_term::create_windows (int argc, const char *const *argv) |
1409 | rxvt_term::create_windows (int argc, const char *const *argv) |
1400 | { |
1410 | { |
1401 | XClassHint classHint; |
1411 | XClassHint classHint; |
1402 | XWMHints wmHint; |
1412 | XWMHints wmHint; |
… | |
… | |
1448 | } |
1458 | } |
1449 | #endif |
1459 | #endif |
1450 | |
1460 | |
1451 | window_calc (0, 0); |
1461 | window_calc (0, 0); |
1452 | |
1462 | |
1453 | /* sub-window placement & size in rxvt_resize_subwindows () */ |
1463 | /* sub-window placement & size in rxvt_term::resize_all_windows () */ |
1454 | attributes.background_pixel = pix_colors_focused [Color_border]; |
1464 | attributes.background_pixel = pix_colors_focused [Color_border]; |
1455 | attributes.border_pixel = pix_colors_focused [Color_border]; |
1465 | attributes.border_pixel = pix_colors_focused [Color_border]; |
1456 | attributes.colormap = cmap; |
1466 | attributes.colormap = cmap; |
1457 | |
1467 | |
1458 | top = XCreateWindow (dpy, parent, |
1468 | top = XCreateWindow (dpy, parent, |
… | |
… | |
1461 | ext_bwidth, |
1471 | ext_bwidth, |
1462 | depth, InputOutput, visual, |
1472 | depth, InputOutput, visual, |
1463 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1473 | CWColormap | CWBackPixel | CWBorderPixel | CWOverrideRedirect, |
1464 | &attributes); |
1474 | &attributes); |
1465 | |
1475 | |
1466 | this->parent[0] = top; |
1476 | this->parent = top; |
1467 | |
1477 | |
1468 | old_width = szHint.width; |
1478 | old_width = szHint.width; |
1469 | old_height = szHint.height; |
1479 | old_height = szHint.height; |
1470 | |
1480 | |
1471 | set_title (rs [Rs_title]); |
1481 | set_title (rs [Rs_title]); |
… | |
… | |
1504 | #if ENABLE_EWMH |
1514 | #if ENABLE_EWMH |
1505 | xa[XA_NET_WM_PING], |
1515 | xa[XA_NET_WM_PING], |
1506 | #endif |
1516 | #endif |
1507 | }; |
1517 | }; |
1508 | |
1518 | |
1509 | XSetWMProtocols (dpy, top, protocols, ARRAY_LENGTH(protocols)); |
1519 | XSetWMProtocols (dpy, top, protocols, ecb_array_length (protocols)); |
1510 | |
1520 | |
1511 | #if ENABLE_FRILLS |
1521 | #if ENABLE_FRILLS |
1512 | if (rs[Rs_transient_for]) |
1522 | if (rs[Rs_transient_for]) |
1513 | XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
1523 | XSetTransientForHint (dpy, top, (Window)strtol (rs[Rs_transient_for], 0, 0)); |
1514 | #endif |
1524 | #endif |