summaryrefslogtreecommitdiff
path: root/src/bin/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/main.c')
-rw-r--r--src/bin/main.c620
1 files changed, 354 insertions, 266 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index b50dbbe..57e5454 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -468,65 +468,279 @@ _log_void(const Eina_Log_Domain *_d EINA_UNUSED,
468} 468}
469#endif 469#endif
470 470
471static void
472_start(Ipc_Instance *instance)
473{
474 Win *wn;
475 Evas_Object *win;
476 Term *term;
477 Config *config;
478
479 wn = win_new(instance->name, instance->role, instance->title,
480 instance->icon_name, instance->config,
481 instance->fullscreen, instance->iconic, instance->borderless,
482 instance->override, instance->maximized);
483 // set an env so terminal apps can detect they are in terminology :)
484 putenv("TERMINOLOGY=1");
485 unsetenv("DESKTOP_STARTUP_ID");
486
487 config_del(instance->config);
488 config = NULL;
489 if (!wn)
490 {
491 CRITICAL(_("Could not create window."));
492 goto exit;
493 }
494
495 config = win_config_get(wn);
496
497 term = term_new(wn, config, instance->cmd, instance->login_shell,
498 instance->cd,
499 instance->w, instance->h, instance->hold, instance->title);
500 if (!term)
501 {
502 CRITICAL(_("Could not create terminal widget."));
503 config = NULL;
504 goto exit;
505 }
506
507 if (win_term_set(wn, term) < 0)
508 {
509 goto exit;
510 }
511
512 main_trans_update(config);
513 main_media_update(config);
514 win_sizing_handle(wn);
515 win = win_evas_object_get(wn);
516 evas_object_show(win);
517 if (instance->startup_split)
518 {
519 unsigned int i = 0;
520 Eina_List *cmds_list = NULL;
521 Term *next = term;
522
523 for (i = 0; i < strlen(instance->startup_split); i++)
524 {
525 char *cmd = NULL;
526
527 if (instance->startup_split[i] == 'v')
528 {
529 cmd = cmds_list ? cmds_list->data : NULL;
530 split_vertically(win_evas_object_get(term_win_get(next)),
531 term_termio_get(next), cmd);
532 cmds_list = eina_list_remove_list(cmds_list, cmds_list);
533 }
534 else if (instance->startup_split[i] == 'h')
535 {
536 cmd = cmds_list ? cmds_list->data : NULL;
537 split_horizontally(win_evas_object_get(term_win_get(next)),
538 term_termio_get(next), cmd);
539 cmds_list = eina_list_remove_list(cmds_list, cmds_list);
540 }
541 else if (instance->startup_split[i] == '-')
542 next = term_next_get(next);
543 else
544 {
545 CRITICAL(_("invalid argument found for option -S/--split."
546 " See --help."));
547 goto end;
548 }
549 }
550 if (cmds_list)
551 eina_list_free(cmds_list);
552 }
553 if (instance->pos)
554 {
555 int screen_w, screen_h;
556
557 elm_win_screen_size_get(win, NULL, NULL, &screen_w, &screen_h);
558 if (instance->x < 0) instance->x = screen_w + instance->x;
559 if (instance->y < 0) instance->y = screen_h + instance->y;
560 evas_object_move(win, instance->x, instance->y);
561 }
562 if (instance->nowm)
563 ecore_evas_focus_set(ecore_evas_ecore_evas_get(
564 evas_object_evas_get(win)), 1);
565
566 controls_init();
567
568 win_scale_wizard(win, term);
569
570 terminology_starting_up = EINA_FALSE;
571
572
573end:
574 return;
575exit:
576 ecore_main_loop_quit();
577}
578
579struct Instance_Add {
580 Ipc_Instance *instance;
581 char **argv;
582 Eina_Bool result;
583 Eina_Bool timedout;
584 Eina_Bool done;
585 pthread_mutex_t lock;
586};
587
588static void
589_instance_add_free(struct Instance_Add *add)
590{
591 if (!add)
592 return;
593
594 pthread_mutex_destroy(&add->lock);
595 free(add);
596}
597
598
599static void *
600_instance_sleep(void *data)
601{
602 struct Instance_Add *add = data;
603 Eina_Bool timedout = EINA_FALSE;
604
605 sleep(2);
606 pthread_mutex_lock(&add->lock);
607 if (!add->done)
608 timedout = add->timedout = EINA_TRUE;
609 pthread_mutex_unlock(&add->lock);
610 if (timedout)
611 {
612 /* ok, we waited 2 seconds without any answer,
613 * remove the unix socket and restart terminology from scratch in a
614 * better state */
615 ipc_instance_conn_free();
616 execv(add->argv[0], add->argv + 1);
617 }
618 else
619 {
620 _instance_add_free(add);
621 }
622
623 return NULL;
624}
625
626static Eina_Bool
627_instance_add_waiter(Ipc_Instance *instance,
628 char **argv)
629{
630 struct Instance_Add *add;
631 Eina_Bool timedout = EINA_FALSE;
632 Eina_Bool result = EINA_TRUE;
633 pthread_t thr;
634
635 add = calloc(1, sizeof(*add));
636 if (!add)
637 return EINA_FALSE;
638
639 add->instance = instance;
640 add->argv = argv;
641 pthread_mutex_init(&add->lock, NULL);
642
643 pthread_create(&thr, NULL, &_instance_sleep, add);
644
645 /* If the unix socket is stalled, this might block */
646 result = ipc_instance_add(add->instance);
647 pthread_mutex_lock(&add->lock);
648 /* Hoora, it did not block! */
649 add->done = EINA_TRUE;
650 if (add->timedout)
651 {
652 timedout = add->timedout = EINA_TRUE;
653 result = EINA_FALSE;
654 }
655 pthread_mutex_unlock(&add->lock);
656 if (timedout)
657 _instance_add_free(add);
658
659 return result;
660}
661
662static Eina_Bool
663_start_multi(Ipc_Instance *instance,
664 char **argv)
665{
666 int remote_try = 0;
667 do
668 {
669 if (_instance_add_waiter(instance, argv))
670 {
671 goto exit;
672 }
673 /* Could not start a new window remotely,
674 * let's start our own server */
675 ipc_instance_new_func_set(main_ipc_new);
676 if (ipc_serve())
677 {
678 goto normal_start;
679 }
680 else
681 {
682 DBG("IPC server: failure");
683 }
684 remote_try++;
685 }
686 while (remote_try <= 1);
687
688normal_start:
689 _start(instance);
690 return EINA_FALSE;
691
692exit:
693 return EINA_TRUE;
694}
695
471EAPI_MAIN int 696EAPI_MAIN int
472elm_main(int argc, char **argv) 697elm_main(int argc, char **argv)
473{ 698{
474 char *cmd = NULL;
475 char *cd = NULL;
476 char *theme = NULL; 699 char *theme = NULL;
477 char *background = NULL;
478 char *geometry = NULL; 700 char *geometry = NULL;
479 char *name = NULL;
480 char *role = NULL;
481 char *title = NULL;
482 char *icon_name = NULL;
483 char *font = NULL;
484 char *startup_split = NULL;
485 char *video_module = NULL; 701 char *video_module = NULL;
486 Eina_Bool login_shell = 0xff; /* unset */
487 Eina_Bool video_mute = 0xff; /* unset */ 702 Eina_Bool video_mute = 0xff; /* unset */
488 Eina_Bool cursor_blink = 0xff; /* unset */ 703 Eina_Bool cursor_blink = 0xff; /* unset */
489 Eina_Bool visual_bell = 0xff; /* unset */ 704 Eina_Bool visual_bell = 0xff; /* unset */
490 Eina_Bool active_links = 0xff; /* unset */
491 Eina_Bool fullscreen = EINA_FALSE;
492 Eina_Bool iconic = EINA_FALSE;
493 Eina_Bool borderless = EINA_FALSE;
494 Eina_Bool override = EINA_FALSE;
495 Eina_Bool maximized = EINA_FALSE;
496 Eina_Bool nowm = EINA_FALSE;
497 Eina_Bool quit_option = EINA_FALSE; 705 Eina_Bool quit_option = EINA_FALSE;
498 Eina_Bool hold = EINA_FALSE;
499 Eina_Bool single = EINA_FALSE; 706 Eina_Bool single = EINA_FALSE;
500 Eina_Bool cmd_options = EINA_FALSE; 707 Eina_Bool cmd_options = EINA_FALSE;
501 Eina_Bool xterm_256color = EINA_FALSE; 708 Eina_Bool xterm_256color = EINA_FALSE;
709 Ipc_Instance instance = {
710 .login_shell = 0xff, /* unset */
711 .active_links = 0xff, /* unset */
712 .startup_id = getenv("DESKTOP_STARTUP_ID"),
713 .w = 1,
714 .h = 1,
715 };
502 Ecore_Getopt_Value values[] = { 716 Ecore_Getopt_Value values[] = {
503 ECORE_GETOPT_VALUE_BOOL(cmd_options), 717 ECORE_GETOPT_VALUE_BOOL(cmd_options),
504 ECORE_GETOPT_VALUE_STR(cd), 718 ECORE_GETOPT_VALUE_STR(instance.cd),
505 ECORE_GETOPT_VALUE_STR(theme), 719 ECORE_GETOPT_VALUE_STR(theme),
506 ECORE_GETOPT_VALUE_STR(background), 720 ECORE_GETOPT_VALUE_STR(instance.background),
507 ECORE_GETOPT_VALUE_STR(geometry), 721 ECORE_GETOPT_VALUE_STR(geometry),
508 ECORE_GETOPT_VALUE_STR(name), 722 ECORE_GETOPT_VALUE_STR(instance.name),
509 ECORE_GETOPT_VALUE_STR(role), 723 ECORE_GETOPT_VALUE_STR(instance.role),
510 ECORE_GETOPT_VALUE_STR(title), 724 ECORE_GETOPT_VALUE_STR(instance.title),
511 ECORE_GETOPT_VALUE_STR(icon_name), 725 ECORE_GETOPT_VALUE_STR(instance.icon_name),
512 ECORE_GETOPT_VALUE_STR(font), 726 ECORE_GETOPT_VALUE_STR(instance.font),
513 ECORE_GETOPT_VALUE_STR(startup_split), 727 ECORE_GETOPT_VALUE_STR(instance.startup_split),
514 ECORE_GETOPT_VALUE_STR(video_module), 728 ECORE_GETOPT_VALUE_STR(video_module),
515 729
516 ECORE_GETOPT_VALUE_BOOL(login_shell), 730 ECORE_GETOPT_VALUE_BOOL(instance.login_shell),
517 ECORE_GETOPT_VALUE_BOOL(video_mute), 731 ECORE_GETOPT_VALUE_BOOL(video_mute),
518 ECORE_GETOPT_VALUE_BOOL(cursor_blink), 732 ECORE_GETOPT_VALUE_BOOL(cursor_blink),
519 ECORE_GETOPT_VALUE_BOOL(visual_bell), 733 ECORE_GETOPT_VALUE_BOOL(visual_bell),
520 ECORE_GETOPT_VALUE_BOOL(fullscreen), 734 ECORE_GETOPT_VALUE_BOOL(instance.fullscreen),
521 ECORE_GETOPT_VALUE_BOOL(iconic), 735 ECORE_GETOPT_VALUE_BOOL(instance.iconic),
522 ECORE_GETOPT_VALUE_BOOL(borderless), 736 ECORE_GETOPT_VALUE_BOOL(instance.borderless),
523 ECORE_GETOPT_VALUE_BOOL(override), 737 ECORE_GETOPT_VALUE_BOOL(instance.override),
524 ECORE_GETOPT_VALUE_BOOL(maximized), 738 ECORE_GETOPT_VALUE_BOOL(instance.maximized),
525 ECORE_GETOPT_VALUE_BOOL(nowm), 739 ECORE_GETOPT_VALUE_BOOL(instance.nowm),
526 ECORE_GETOPT_VALUE_BOOL(hold), 740 ECORE_GETOPT_VALUE_BOOL(instance.hold),
527 ECORE_GETOPT_VALUE_BOOL(single), 741 ECORE_GETOPT_VALUE_BOOL(single),
528 ECORE_GETOPT_VALUE_BOOL(xterm_256color), 742 ECORE_GETOPT_VALUE_BOOL(xterm_256color),
529 ECORE_GETOPT_VALUE_BOOL(active_links), 743 ECORE_GETOPT_VALUE_BOOL(instance.active_links),
530 744
531 ECORE_GETOPT_VALUE_BOOL(quit_option), 745 ECORE_GETOPT_VALUE_BOOL(quit_option),
532 ECORE_GETOPT_VALUE_BOOL(quit_option), 746 ECORE_GETOPT_VALUE_BOOL(quit_option),
@@ -535,16 +749,8 @@ elm_main(int argc, char **argv)
535 749
536 ECORE_GETOPT_VALUE_NONE 750 ECORE_GETOPT_VALUE_NONE
537 }; 751 };
538 Win *wn;
539 Term *term;
540 Config *config = NULL;
541 Evas_Object *win;
542 int args, retval = EXIT_SUCCESS; 752 int args, retval = EXIT_SUCCESS;
543 int remote_try = 0; 753 Eina_Bool size_set = EINA_FALSE;
544 int pos_set = 0, size_set = 0;
545 int pos_x = 0, pos_y = 0;
546 int size_w = 1, size_h = 1;
547 Eina_List *cmds_list = NULL;
548 754
549 terminology_starting_up = EINA_TRUE; 755 terminology_starting_up = EINA_TRUE;
550 756
@@ -590,9 +796,12 @@ elm_main(int argc, char **argv)
590 goto end; 796 goto end;
591 } 797 }
592 798
799 ecore_con_init();
800 ecore_con_url_init();
801
593 ipc_init(); 802 ipc_init();
594 803
595 config = config_fork(_main_config); 804 instance.config = config_fork(_main_config);
596 805
597 args = ecore_getopt_parse(&options, values, argc, argv); 806 args = ecore_getopt_parse(&options, values, argc, argv);
598 if (args < 0) 807 if (args < 0)
@@ -606,6 +815,7 @@ elm_main(int argc, char **argv)
606 815
607 if (cmd_options) 816 if (cmd_options)
608 { 817 {
818 Eina_List *cmds_list = NULL;
609 int i; 819 int i;
610 820
611 if (args == argc) 821 if (args == argc)
@@ -615,11 +825,11 @@ elm_main(int argc, char **argv)
615 goto end; 825 goto end;
616 } 826 }
617 827
618 if (startup_split) 828 if (instance.startup_split)
619 { 829 {
620 for(i = args+1; i < argc; i++) 830 for(i = args+1; i < argc; i++)
621 cmds_list = eina_list_append(cmds_list, argv[i]); 831 cmds_list = eina_list_append(cmds_list, argv[i]);
622 cmd = argv[args]; 832 instance.cmd = argv[args];
623 } 833 }
624 else 834 else
625 { 835 {
@@ -631,7 +841,7 @@ elm_main(int argc, char **argv)
631 eina_strbuf_append_char(strb, ' '); 841 eina_strbuf_append_char(strb, ' ');
632 eina_strbuf_append(strb, argv[i]); 842 eina_strbuf_append(strb, argv[i]);
633 } 843 }
634 cmd = eina_strbuf_string_steal(strb); 844 instance.cmd = eina_strbuf_string_steal(strb);
635 eina_strbuf_free(strb); 845 eina_strbuf_free(strb);
636 } 846 }
637 } 847 }
@@ -654,37 +864,39 @@ elm_main(int argc, char **argv)
654 else 864 else
655 theme_path = theme_path_get(theme_name); 865 theme_path = theme_path_get(theme_name);
656 866
657 eina_stringshare_replace(&(config->theme), theme_path); 867 eina_stringshare_replace(&(instance.config->theme), theme_path);
658 config->temporary = EINA_TRUE; 868 instance.config->temporary = EINA_TRUE;
659 } 869 }
660 870
661 if (background) 871 if (instance.background)
662 { 872 {
663 eina_stringshare_replace(&(config->background), background); 873 eina_stringshare_replace(&(instance.config->background),
664 config->temporary = EINA_TRUE; 874 instance.background);
875 instance.config->temporary = EINA_TRUE;
665 } 876 }
666 877
667 if (font) 878 if (instance.font)
668 { 879 {
669 char *p = strchr(font, '/'); 880 char *p = strchr(instance.font, '/');
670 if (p) 881 if (p)
671 { 882 {
672 int sz; 883 int sz;
673 char *fname = alloca(p - font + 1); 884 char *fname = alloca(p - instance.font + 1);
674 885
675 strncpy(fname, font, p - font); 886 strncpy(fname, instance.font, p - instance.font);
676 fname[p - font] = '\0'; 887 fname[p - instance.font] = '\0';
677 sz = atoi(p+1); 888 sz = atoi(p+1);
678 if (sz > 0) config->font.size = sz; 889 if (sz > 0)
679 eina_stringshare_replace(&(config->font.name), fname); 890 instance.config->font.size = sz;
680 config->font.bitmap = 0; 891 eina_stringshare_replace(&(instance.config->font.name), fname);
681 config->font_set = 1; 892 instance.config->font.bitmap = 0;
893 instance.config->font_set = 1;
682 } 894 }
683 else 895 else
684 { 896 {
685 char buf[4096], *file; 897 char buf[4096], *file;
686 Eina_List *files; 898 Eina_List *files;
687 int n = strlen(font); 899 int n = strlen(instance.font);
688 Eina_Bool found = EINA_FALSE; 900 Eina_Bool found = EINA_FALSE;
689 901
690 snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get()); 902 snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get());
@@ -693,12 +905,12 @@ elm_main(int argc, char **argv)
693 { 905 {
694 if (n > 0) 906 if (n > 0)
695 { 907 {
696 if (!strncasecmp(file, font, n)) 908 if (!strncasecmp(file, instance.font, n))
697 { 909 {
698 n = -1; 910 n = -1;
699 eina_stringshare_replace(&(config->font.name), file); 911 eina_stringshare_replace(&(instance.config->font.name), file);
700 config->font.bitmap = 1; 912 instance.config->font.bitmap = 1;
701 config->font_set = 1; 913 instance.config->font_set = 1;
702 found = EINA_TRUE; 914 found = EINA_TRUE;
703 } 915 }
704 } 916 }
@@ -706,10 +918,10 @@ elm_main(int argc, char **argv)
706 } 918 }
707 if (!found) 919 if (!found)
708 { 920 {
709 ERR("font '%s' not found in %s", font, buf); 921 ERR("font '%s' not found in %s", instance.font, buf);
710 } 922 }
711 } 923 }
712 config->temporary = EINA_TRUE; 924 instance.config->temporary = EINA_TRUE;
713 } 925 }
714 926
715 if (video_module) 927 if (video_module)
@@ -723,270 +935,146 @@ elm_main(int argc, char **argv)
723 935
724 if (i == EINA_C_ARRAY_LENGTH(emotion_choices)) 936 if (i == EINA_C_ARRAY_LENGTH(emotion_choices))
725 i = 0; /* ecore getopt shouldn't let this happen, but... */ 937 i = 0; /* ecore getopt shouldn't let this happen, but... */
726 config->vidmod = i; 938 instance.config->vidmod = i;
727 config->temporary = EINA_TRUE; 939 instance.config->temporary = EINA_TRUE;
728 } 940 }
729 941
730 if (video_mute != 0xff) 942 if (video_mute != 0xff)
731 { 943 {
732 config->mute = video_mute; 944 instance.config->mute = video_mute;
733 config->temporary = EINA_TRUE; 945 instance.config->temporary = EINA_TRUE;
734 } 946 }
735 if (cursor_blink != 0xff) 947 if (cursor_blink != 0xff)
736 { 948 {
737 config->disable_cursor_blink = !cursor_blink; 949 instance.config->disable_cursor_blink = !cursor_blink;
738 config->temporary = EINA_TRUE; 950 instance.config->temporary = EINA_TRUE;
739 } 951 }
740 if (visual_bell != 0xff) 952 if (visual_bell != 0xff)
741 { 953 {
742 config->disable_visual_bell = !visual_bell; 954 instance.config->disable_visual_bell = !visual_bell;
743 config->temporary = EINA_TRUE; 955 instance.config->temporary = EINA_TRUE;
744 } 956 }
745 if (active_links != 0xff) 957 if (instance.active_links != 0xff)
746 { 958 {
747 config->active_links = !!active_links; 959 instance.config->active_links = !!instance.active_links;
748 config->active_links_email = config->active_links; 960 instance.config->active_links_email = instance.config->active_links;
749 config->active_links_file = config->active_links; 961 instance.config->active_links_file = instance.config->active_links;
750 config->active_links_url = config->active_links; 962 instance.config->active_links_url = instance.config->active_links;
751 config->active_links_escape = config->active_links; 963 instance.config->active_links_escape = instance.config->active_links;
752 config->temporary = EINA_TRUE; 964 instance.config->temporary = EINA_TRUE;
753 } 965 }
754 966
755 if (xterm_256color) 967 if (xterm_256color)
756 { 968 {
757 config->xterm_256color = EINA_TRUE; 969 instance.config->xterm_256color = EINA_TRUE;
758 config->temporary = EINA_TRUE; 970 instance.config->temporary = EINA_TRUE;
759 } 971 }
760 972
761 if (geometry) 973 if (geometry)
762 { 974 {
763 if (sscanf(geometry,"%ix%i+%i+%i", &size_w, &size_h, &pos_x, &pos_y) == 4) 975 if (sscanf(geometry,"%ix%i+%i+%i", &instance.w, &instance.h,
976 &instance.x, &instance.y) == 4)
764 { 977 {
765 pos_set = 1; 978 instance.pos = EINA_TRUE;
766 size_set = 1; 979 size_set = EINA_TRUE;
767 } 980 }
768 else if (sscanf(geometry,"%ix%i-%i+%i", &size_w, &size_h, &pos_x, &pos_y) == 4) 981 else if (sscanf(geometry,"%ix%i-%i+%i", &instance.w, &instance.h,
982 &instance.x, &instance.y) == 4)
769 { 983 {
770 pos_x = -pos_x; 984 instance.x = -instance.x;
771 pos_set = 1; 985 instance.pos = EINA_TRUE;
772 size_set = 1; 986 size_set = EINA_TRUE;
773 } 987 }
774 else if (sscanf(geometry,"%ix%i-%i-%i", &size_w, &size_h, &pos_x, &pos_y) == 4) 988 else if (sscanf(geometry,"%ix%i-%i-%i", &instance.w, &instance.h,
989 &instance.x, &instance.y) == 4)
775 { 990 {
776 pos_x = -pos_x; 991 instance.x = -instance.x;
777 pos_y = -pos_y; 992 instance.y = -instance.y;
778 pos_set = 1; 993 instance.pos = EINA_TRUE;
779 size_set = 1; 994 size_set = EINA_TRUE;
780 } 995 }
781 else if (sscanf(geometry,"%ix%i+%i-%i", &size_w, &size_h, &pos_x, &pos_y) == 4) 996 else if (sscanf(geometry,"%ix%i+%i-%i", &instance.w, &instance.h,
997 &instance.x, &instance.y) == 4)
782 { 998 {
783 pos_y = -pos_y; 999 instance.y = -instance.y;
784 pos_set = 1; 1000 instance.pos = EINA_TRUE;
785 size_set = 1; 1001 size_set = EINA_TRUE;
786 } 1002 }
787 else if (sscanf(geometry,"%ix%i", &size_w, &size_h) == 2) 1003 else if (sscanf(geometry,"%ix%i", &instance.w, &instance.h) == 2)
788 { 1004 {
789 size_set = 1; 1005 size_set = EINA_TRUE;
790 } 1006 }
791 else if (sscanf(geometry,"+%i+%i", &pos_x, &pos_y) == 2) 1007 else if (sscanf(geometry,"+%i+%i", &instance.x, &instance.y) == 2)
792 { 1008 {
793 pos_set = 1; 1009 instance.pos = EINA_TRUE;
794 } 1010 }
795 else if (sscanf(geometry,"-%i+%i", &pos_x, &pos_y) == 2) 1011 else if (sscanf(geometry,"-%i+%i", &instance.x, &instance.y) == 2)
796 { 1012 {
797 pos_x = -pos_x; 1013 instance.x = -instance.x;
798 pos_set = 1; 1014 instance.pos = EINA_TRUE;
799 } 1015 }
800 else if (sscanf(geometry,"+%i-%i", &pos_x, &pos_y) == 2) 1016 else if (sscanf(geometry,"+%i-%i", &instance.x, &instance.y) == 2)
801 { 1017 {
802 pos_y = -pos_y; 1018 instance.y = -instance.y;
803 pos_set = 1; 1019 instance.pos = EINA_TRUE;
804 } 1020 }
805 else if (sscanf(geometry,"-%i-%i", &pos_x, &pos_y) == 2) 1021 else if (sscanf(geometry,"-%i-%i", &instance.x, &instance.y) == 2)
806 { 1022 {
807 pos_x = -pos_x; 1023 instance.x = -instance.x;
808 pos_y = -pos_y; 1024 instance.y = -instance.y;
809 pos_set = 1; 1025 instance.pos = EINA_TRUE;
810 } 1026 }
811 } 1027 }
812 1028
813 if (!size_set) 1029 if (!size_set)
814 { 1030 {
815 if (config->custom_geometry) 1031 if (instance.config->custom_geometry)
816 { 1032 {
817 size_w = config->cg_width; 1033 instance.w = instance.config->cg_width;
818 size_h = config->cg_height; 1034 instance.h = instance.config->cg_height;
819 } 1035 }
820 else 1036 else
821 { 1037 {
822 size_w = 80; 1038 instance.w = 80;
823 size_h = 24; 1039 instance.h = 24;
824 } 1040 }
825 } 1041 }
826 1042
827 if (login_shell != 0xff) 1043 if (instance.login_shell != 0xff)
828 { 1044 {
829 config->login_shell = login_shell; 1045 instance.config->login_shell = instance.login_shell;
830 config->temporary = EINA_TRUE; 1046 instance.config->temporary = EINA_TRUE;
831 } 1047 }
832 login_shell = config->login_shell; 1048 instance.login_shell = instance.config->login_shell;
833 1049
834 elm_theme_overlay_add(NULL, config_theme_path_default_get(config)); 1050 elm_theme_overlay_add(NULL,
835 elm_theme_overlay_add(NULL, config_theme_path_get(config)); 1051 config_theme_path_default_get(instance.config));
1052 elm_theme_overlay_add(NULL, config_theme_path_get(instance.config));
836 1053
837remote: 1054 if ((!single) && (instance.config->multi_instance))
838 if ((!single) && (config->multi_instance))
839 { 1055 {
840 Ipc_Instance inst;
841 char cwdbuf[4096]; 1056 char cwdbuf[4096];
842 1057
843 memset(&inst, 0, sizeof(Ipc_Instance)); 1058 if (!instance.cd)
844 1059 instance.cd = getcwd(cwdbuf, sizeof(cwdbuf));
845 inst.cmd = cmd; 1060 if (_start_multi(&instance, argv))
846 if (cd) inst.cd = cd;
847 else inst.cd = getcwd(cwdbuf, sizeof(cwdbuf));
848 inst.background = background;
849 inst.name = name;
850 inst.role = role;
851 inst.title = title;
852 inst.icon_name = icon_name;
853 inst.font = font;
854 inst.startup_id = getenv("DESKTOP_STARTUP_ID");
855 inst.x = pos_x;
856 inst.y = pos_y;
857 inst.w = size_w;
858 inst.h = size_h;
859 inst.pos = pos_set;
860 inst.login_shell = login_shell;
861 inst.fullscreen = fullscreen;
862 inst.iconic = iconic;
863 inst.borderless = borderless;
864 inst.override = override;
865 inst.maximized = maximized;
866 inst.hold = hold;
867 inst.nowm = nowm;
868 inst.startup_split = startup_split;
869 if (ipc_instance_add(&inst))
870 goto end; 1061 goto end;
871 } 1062 }
872 if ((!single) && (config->multi_instance)) 1063 else
873 {
874 ipc_instance_new_func_set(main_ipc_new);
875 if (!ipc_serve())
876 {
877 if (remote_try < 1)
878 {
879 remote_try++;
880 goto remote;
881 }
882 }
883 }
884
885 wn = win_new(name, role, title, icon_name, config,
886 fullscreen, iconic, borderless, override, maximized);
887 // set an env so terminal apps can detect they are in terminology :)
888 putenv("TERMINOLOGY=1");
889 unsetenv("DESKTOP_STARTUP_ID");
890
891 config_del(config);
892 config = NULL;
893 if (!wn)
894 {
895 CRITICAL(_("Could not create window."));
896 retval = EXIT_FAILURE;
897 goto end;
898 }
899
900 config = win_config_get(wn);
901
902 term = term_new(wn, config, cmd, login_shell, cd,
903 size_w, size_h, hold, title);
904 if (!term)
905 { 1064 {
906 CRITICAL(_("Could not create terminal widget.")); 1065 _start(&instance);
907 config = NULL;
908 retval = EXIT_FAILURE;
909 goto end;
910 } 1066 }
911
912 if (win_term_set(wn, term) < 0)
913 {
914 retval = EXIT_FAILURE;
915 goto end;
916 }
917
918 main_trans_update(config);
919 main_media_update(config);
920 win_sizing_handle(wn);
921 win = win_evas_object_get(wn);
922 evas_object_show(win);
923 if (startup_split)
924 {
925 unsigned int i = 0;
926 Term *next = term;
927
928 for (i = 0; i < strlen(startup_split); i++)
929 {
930 if (startup_split[i] == 'v')
931 {
932 cmd = cmds_list ? cmds_list->data : NULL;
933 split_vertically(win_evas_object_get(term_win_get(next)),
934 term_termio_get(next), cmd);
935 cmds_list = eina_list_remove_list(cmds_list, cmds_list);
936 }
937 else if (startup_split[i] == 'h')
938 {
939 cmd = cmds_list ? cmds_list->data : NULL;
940 split_horizontally(win_evas_object_get(term_win_get(next)),
941 term_termio_get(next), cmd);
942 cmds_list = eina_list_remove_list(cmds_list, cmds_list);
943 }
944 else if (startup_split[i] == '-')
945 next = term_next_get(next);
946 else
947 {
948 CRITICAL(_("invalid argument found for option -S/--split."
949 " See --help."));
950 goto end;
951 }
952 }
953 if (cmds_list)
954 eina_list_free(cmds_list);
955 }
956 if (pos_set)
957 {
958 int screen_w, screen_h;
959
960 elm_win_screen_size_get(win, NULL, NULL, &screen_w, &screen_h);
961 if (pos_x < 0) pos_x = screen_w + pos_x;
962 if (pos_y < 0) pos_y = screen_h + pos_y;
963 evas_object_move(win, pos_x, pos_y);
964 }
965 if (nowm)
966 ecore_evas_focus_set(ecore_evas_ecore_evas_get(
967 evas_object_evas_get(win)), 1);
968
969 ecore_con_init();
970 ecore_con_url_init();
971
972 controls_init();
973
974 win_scale_wizard(win, term);
975
976 terminology_starting_up = EINA_FALSE;
977
978 elm_run(); 1067 elm_run();
979 1068
980 ecore_con_url_shutdown(); 1069 ecore_con_url_shutdown();
981 ecore_con_shutdown(); 1070 ecore_con_shutdown();
982 1071
983 config = NULL; 1072 instance.config = NULL;
984 end: 1073 end:
985 if (!startup_split) free(cmd); 1074 if (instance.config)
986 if (config)
987 { 1075 {
988 config_del(config); 1076 config_del(instance.config);
989 config = NULL; 1077 instance.config = NULL;
990 } 1078 }
991 1079
992 ipc_shutdown(); 1080 ipc_shutdown();