summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/ipc.c21
-rw-r--r--src/bin/ipc.h44
-rw-r--r--src/bin/main.c620
3 files changed, 288 insertions, 397 deletions
diff --git a/src/bin/ipc.c b/src/bin/ipc.c
index 83b265c..c9b9ee7 100644
--- a/src/bin/ipc.c
+++ b/src/bin/ipc.c
@@ -1,7 +1,6 @@
1#include "private.h" 1#include "private.h"
2 2
3#include <Ecore.h> 3#include <Ecore.h>
4#include <Ecore_Con.h>
5#include <Ecore_Ipc.h> 4#include <Ecore_Ipc.h>
6#include <Eet.h> 5#include <Eet.h>
7#include "ipc.h" 6#include "ipc.h"
@@ -172,19 +171,6 @@ ipc_instance_new_func_set(void (*func) (Ipc_Instance *inst))
172 func_new_inst = func; 171 func_new_inst = func;
173} 172}
174 173
175void
176ipc_instance_conn_free(void)
177{
178 char *hash = _ipc_hash_get();
179 char *address = ecore_con_local_path_new(EINA_FALSE,
180 hash,
181 0);
182 errno = 0;
183 unlink(address);
184 ERR("unlinking: '%s': %s", address, strerror(errno));
185 free(address);
186}
187
188Eina_Bool 174Eina_Bool
189ipc_instance_add(Ipc_Instance *inst) 175ipc_instance_add(Ipc_Instance *inst)
190{ 176{
@@ -192,7 +178,7 @@ ipc_instance_add(Ipc_Instance *inst)
192 void *data; 178 void *data;
193 char *hash = _ipc_hash_get(); 179 char *hash = _ipc_hash_get();
194 Ecore_Ipc_Server *ipcsrv; 180 Ecore_Ipc_Server *ipcsrv;
195 181
196 if (!hash) return EINA_FALSE; 182 if (!hash) return EINA_FALSE;
197 data = eet_data_descriptor_encode(new_inst_edd, inst, &size); 183 data = eet_data_descriptor_encode(new_inst_edd, inst, &size);
198 if (!data) 184 if (!data)
@@ -200,7 +186,6 @@ ipc_instance_add(Ipc_Instance *inst)
200 free(hash); 186 free(hash);
201 return EINA_FALSE; 187 return EINA_FALSE;
202 } 188 }
203
204 ipcsrv = ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, hash, 0, NULL); 189 ipcsrv = ecore_ipc_server_connect(ECORE_IPC_LOCAL_USER, hash, 0, NULL);
205 if (ipcsrv) 190 if (ipcsrv)
206 { 191 {
@@ -211,10 +196,6 @@ ipc_instance_add(Ipc_Instance *inst)
211 ecore_ipc_server_del(ipcsrv); 196 ecore_ipc_server_del(ipcsrv);
212 return EINA_TRUE; 197 return EINA_TRUE;
213 } 198 }
214 else
215 {
216 DBG("connect failed");
217 }
218 free(data); 199 free(data);
219 free(hash); 200 free(hash);
220 return EINA_FALSE; 201 return EINA_FALSE;
diff --git a/src/bin/ipc.h b/src/bin/ipc.h
index 419f389..4ade907 100644
--- a/src/bin/ipc.h
+++ b/src/bin/ipc.h
@@ -7,29 +7,28 @@ typedef struct _Ipc_Instance Ipc_Instance;
7 7
8struct _Ipc_Instance 8struct _Ipc_Instance
9{ 9{
10 char *cmd; 10 const char *cmd;
11 char *cd; 11 const char *cd;
12 char *background; 12 const char *background;
13 char *name; 13 const char *name;
14 char *role; 14 const char *role;
15 char *title; 15 const char *title;
16 char *icon_name; 16 const char *icon_name;
17 char *font; 17 const char *font;
18 char *startup_id; 18 const char *startup_id;
19 char *startup_split; 19 const char *startup_split;
20 int x, y, w, h; 20 int x, y, w, h;
21 Eina_Bool pos; 21 int pos;
22 Eina_Bool login_shell; 22 int login_shell;
23 Eina_Bool fullscreen; 23 int fullscreen;
24 Eina_Bool iconic; 24 int iconic;
25 Eina_Bool borderless; 25 int borderless;
26 Eina_Bool override; 26 int override;
27 Eina_Bool maximized; 27 int maximized;
28 Eina_Bool hold; 28 int hold;
29 Eina_Bool nowm; 29 int nowm;
30 Eina_Bool xterm_256color; 30 int xterm_256color;
31 Eina_Bool active_links; 31 int active_links;
32 Config *config;
33}; 32};
34 33
35void ipc_init(void); 34void ipc_init(void);
@@ -37,6 +36,5 @@ void ipc_shutdown(void);
37Eina_Bool ipc_serve(void); 36Eina_Bool ipc_serve(void);
38void ipc_instance_new_func_set(void (*func) (Ipc_Instance *inst)); 37void ipc_instance_new_func_set(void (*func) (Ipc_Instance *inst));
39Eina_Bool ipc_instance_add(Ipc_Instance *inst); 38Eina_Bool ipc_instance_add(Ipc_Instance *inst);
40void ipc_instance_conn_free(void);
41 39
42#endif 40#endif
diff --git a/src/bin/main.c b/src/bin/main.c
index 57e5454..b50dbbe 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -468,279 +468,65 @@ _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
696EAPI_MAIN int 471EAPI_MAIN int
697elm_main(int argc, char **argv) 472elm_main(int argc, char **argv)
698{ 473{
474 char *cmd = NULL;
475 char *cd = NULL;
699 char *theme = NULL; 476 char *theme = NULL;
477 char *background = NULL;
700 char *geometry = NULL; 478 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;
701 char *video_module = NULL; 485 char *video_module = NULL;
486 Eina_Bool login_shell = 0xff; /* unset */
702 Eina_Bool video_mute = 0xff; /* unset */ 487 Eina_Bool video_mute = 0xff; /* unset */
703 Eina_Bool cursor_blink = 0xff; /* unset */ 488 Eina_Bool cursor_blink = 0xff; /* unset */
704 Eina_Bool visual_bell = 0xff; /* unset */ 489 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;
705 Eina_Bool quit_option = EINA_FALSE; 497 Eina_Bool quit_option = EINA_FALSE;
498 Eina_Bool hold = EINA_FALSE;
706 Eina_Bool single = EINA_FALSE; 499 Eina_Bool single = EINA_FALSE;
707 Eina_Bool cmd_options = EINA_FALSE; 500 Eina_Bool cmd_options = EINA_FALSE;
708 Eina_Bool xterm_256color = EINA_FALSE; 501 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 };
716 Ecore_Getopt_Value values[] = { 502 Ecore_Getopt_Value values[] = {
717 ECORE_GETOPT_VALUE_BOOL(cmd_options), 503 ECORE_GETOPT_VALUE_BOOL(cmd_options),
718 ECORE_GETOPT_VALUE_STR(instance.cd), 504 ECORE_GETOPT_VALUE_STR(cd),
719 ECORE_GETOPT_VALUE_STR(theme), 505 ECORE_GETOPT_VALUE_STR(theme),
720 ECORE_GETOPT_VALUE_STR(instance.background), 506 ECORE_GETOPT_VALUE_STR(background),
721 ECORE_GETOPT_VALUE_STR(geometry), 507 ECORE_GETOPT_VALUE_STR(geometry),
722 ECORE_GETOPT_VALUE_STR(instance.name), 508 ECORE_GETOPT_VALUE_STR(name),
723 ECORE_GETOPT_VALUE_STR(instance.role), 509 ECORE_GETOPT_VALUE_STR(role),
724 ECORE_GETOPT_VALUE_STR(instance.title), 510 ECORE_GETOPT_VALUE_STR(title),
725 ECORE_GETOPT_VALUE_STR(instance.icon_name), 511 ECORE_GETOPT_VALUE_STR(icon_name),
726 ECORE_GETOPT_VALUE_STR(instance.font), 512 ECORE_GETOPT_VALUE_STR(font),
727 ECORE_GETOPT_VALUE_STR(instance.startup_split), 513 ECORE_GETOPT_VALUE_STR(startup_split),
728 ECORE_GETOPT_VALUE_STR(video_module), 514 ECORE_GETOPT_VALUE_STR(video_module),
729 515
730 ECORE_GETOPT_VALUE_BOOL(instance.login_shell), 516 ECORE_GETOPT_VALUE_BOOL(login_shell),
731 ECORE_GETOPT_VALUE_BOOL(video_mute), 517 ECORE_GETOPT_VALUE_BOOL(video_mute),
732 ECORE_GETOPT_VALUE_BOOL(cursor_blink), 518 ECORE_GETOPT_VALUE_BOOL(cursor_blink),
733 ECORE_GETOPT_VALUE_BOOL(visual_bell), 519 ECORE_GETOPT_VALUE_BOOL(visual_bell),
734 ECORE_GETOPT_VALUE_BOOL(instance.fullscreen), 520 ECORE_GETOPT_VALUE_BOOL(fullscreen),
735 ECORE_GETOPT_VALUE_BOOL(instance.iconic), 521 ECORE_GETOPT_VALUE_BOOL(iconic),
736 ECORE_GETOPT_VALUE_BOOL(instance.borderless), 522 ECORE_GETOPT_VALUE_BOOL(borderless),
737 ECORE_GETOPT_VALUE_BOOL(instance.override), 523 ECORE_GETOPT_VALUE_BOOL(override),
738 ECORE_GETOPT_VALUE_BOOL(instance.maximized), 524 ECORE_GETOPT_VALUE_BOOL(maximized),
739 ECORE_GETOPT_VALUE_BOOL(instance.nowm), 525 ECORE_GETOPT_VALUE_BOOL(nowm),
740 ECORE_GETOPT_VALUE_BOOL(instance.hold), 526 ECORE_GETOPT_VALUE_BOOL(hold),
741 ECORE_GETOPT_VALUE_BOOL(single), 527 ECORE_GETOPT_VALUE_BOOL(single),
742 ECORE_GETOPT_VALUE_BOOL(xterm_256color), 528 ECORE_GETOPT_VALUE_BOOL(xterm_256color),
743 ECORE_GETOPT_VALUE_BOOL(instance.active_links), 529 ECORE_GETOPT_VALUE_BOOL(active_links),
744 530
745 ECORE_GETOPT_VALUE_BOOL(quit_option), 531 ECORE_GETOPT_VALUE_BOOL(quit_option),
746 ECORE_GETOPT_VALUE_BOOL(quit_option), 532 ECORE_GETOPT_VALUE_BOOL(quit_option),
@@ -749,8 +535,16 @@ elm_main(int argc, char **argv)
749 535
750 ECORE_GETOPT_VALUE_NONE 536 ECORE_GETOPT_VALUE_NONE
751 }; 537 };
538 Win *wn;
539 Term *term;
540 Config *config = NULL;
541 Evas_Object *win;
752 int args, retval = EXIT_SUCCESS; 542 int args, retval = EXIT_SUCCESS;
753 Eina_Bool size_set = EINA_FALSE; 543 int remote_try = 0;
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;
754 548
755 terminology_starting_up = EINA_TRUE; 549 terminology_starting_up = EINA_TRUE;
756 550
@@ -796,12 +590,9 @@ elm_main(int argc, char **argv)
796 goto end; 590 goto end;
797 } 591 }
798 592
799 ecore_con_init();
800 ecore_con_url_init();
801
802 ipc_init(); 593 ipc_init();
803 594
804 instance.config = config_fork(_main_config); 595 config = config_fork(_main_config);
805 596
806 args = ecore_getopt_parse(&options, values, argc, argv); 597 args = ecore_getopt_parse(&options, values, argc, argv);
807 if (args < 0) 598 if (args < 0)
@@ -815,7 +606,6 @@ elm_main(int argc, char **argv)
815 606
816 if (cmd_options) 607 if (cmd_options)
817 { 608 {
818 Eina_List *cmds_list = NULL;
819 int i; 609 int i;
820 610
821 if (args == argc) 611 if (args == argc)
@@ -825,11 +615,11 @@ elm_main(int argc, char **argv)
825 goto end; 615 goto end;
826 } 616 }
827 617
828 if (instance.startup_split) 618 if (startup_split)
829 { 619 {
830 for(i = args+1; i < argc; i++) 620 for(i = args+1; i < argc; i++)
831 cmds_list = eina_list_append(cmds_list, argv[i]); 621 cmds_list = eina_list_append(cmds_list, argv[i]);
832 instance.cmd = argv[args]; 622 cmd = argv[args];
833 } 623 }
834 else 624 else
835 { 625 {
@@ -841,7 +631,7 @@ elm_main(int argc, char **argv)
841 eina_strbuf_append_char(strb, ' '); 631 eina_strbuf_append_char(strb, ' ');
842 eina_strbuf_append(strb, argv[i]); 632 eina_strbuf_append(strb, argv[i]);
843 } 633 }
844 instance.cmd = eina_strbuf_string_steal(strb); 634 cmd = eina_strbuf_string_steal(strb);
845 eina_strbuf_free(strb); 635 eina_strbuf_free(strb);
846 } 636 }
847 } 637 }
@@ -864,39 +654,37 @@ elm_main(int argc, char **argv)
864 else 654 else
865 theme_path = theme_path_get(theme_name); 655 theme_path = theme_path_get(theme_name);
866 656
867 eina_stringshare_replace(&(instance.config->theme), theme_path); 657 eina_stringshare_replace(&(config->theme), theme_path);
868 instance.config->temporary = EINA_TRUE; 658 config->temporary = EINA_TRUE;
869 } 659 }
870 660
871 if (instance.background) 661 if (background)
872 { 662 {
873 eina_stringshare_replace(&(instance.config->background), 663 eina_stringshare_replace(&(config->background), background);
874 instance.background); 664 config->temporary = EINA_TRUE;
875 instance.config->temporary = EINA_TRUE;
876 } 665 }
877 666
878 if (instance.font) 667 if (font)
879 { 668 {
880 char *p = strchr(instance.font, '/'); 669 char *p = strchr(font, '/');
881 if (p) 670 if (p)
882 { 671 {
883 int sz; 672 int sz;
884 char *fname = alloca(p - instance.font + 1); 673 char *fname = alloca(p - font + 1);
885 674
886 strncpy(fname, instance.font, p - instance.font); 675 strncpy(fname, font, p - font);
887 fname[p - instance.font] = '\0'; 676 fname[p - font] = '\0';
888 sz = atoi(p+1); 677 sz = atoi(p+1);
889 if (sz > 0) 678 if (sz > 0) config->font.size = sz;
890 instance.config->font.size = sz; 679 eina_stringshare_replace(&(config->font.name), fname);
891 eina_stringshare_replace(&(instance.config->font.name), fname); 680 config->font.bitmap = 0;
892 instance.config->font.bitmap = 0; 681 config->font_set = 1;
893 instance.config->font_set = 1;
894 } 682 }
895 else 683 else
896 { 684 {
897 char buf[4096], *file; 685 char buf[4096], *file;
898 Eina_List *files; 686 Eina_List *files;
899 int n = strlen(instance.font); 687 int n = strlen(font);
900 Eina_Bool found = EINA_FALSE; 688 Eina_Bool found = EINA_FALSE;
901 689
902 snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get()); 690 snprintf(buf, sizeof(buf), "%s/fonts", elm_app_data_dir_get());
@@ -905,12 +693,12 @@ elm_main(int argc, char **argv)
905 { 693 {
906 if (n > 0) 694 if (n > 0)
907 { 695 {
908 if (!strncasecmp(file, instance.font, n)) 696 if (!strncasecmp(file, font, n))
909 { 697 {
910 n = -1; 698 n = -1;
911 eina_stringshare_replace(&(instance.config->font.name), file); 699 eina_stringshare_replace(&(config->font.name), file);
912 instance.config->font.bitmap = 1; 700 config->font.bitmap = 1;
913 instance.config->font_set = 1; 701 config->font_set = 1;
914 found = EINA_TRUE; 702 found = EINA_TRUE;
915 } 703 }
916 } 704 }
@@ -918,10 +706,10 @@ elm_main(int argc, char **argv)
918 } 706 }
919 if (!found) 707 if (!found)
920 { 708 {
921 ERR("font '%s' not found in %s", instance.font, buf); 709 ERR("font '%s' not found in %s", font, buf);
922 } 710 }
923 } 711 }
924 instance.config->temporary = EINA_TRUE; 712 config->temporary = EINA_TRUE;
925 } 713 }
926 714
927 if (video_module) 715 if (video_module)
@@ -935,146 +723,270 @@ elm_main(int argc, char **argv)
935 723
936 if (i == EINA_C_ARRAY_LENGTH(emotion_choices)) 724 if (i == EINA_C_ARRAY_LENGTH(emotion_choices))
937 i = 0; /* ecore getopt shouldn't let this happen, but... */ 725 i = 0; /* ecore getopt shouldn't let this happen, but... */
938 instance.config->vidmod = i; 726 config->vidmod = i;
939 instance.config->temporary = EINA_TRUE; 727 config->temporary = EINA_TRUE;
940 } 728 }
941 729
942 if (video_mute != 0xff) 730 if (video_mute != 0xff)
943 { 731 {
944 instance.config->mute = video_mute; 732 config->mute = video_mute;
945 instance.config->temporary = EINA_TRUE; 733 config->temporary = EINA_TRUE;
946 } 734 }
947 if (cursor_blink != 0xff) 735 if (cursor_blink != 0xff)
948 { 736 {
949 instance.config->disable_cursor_blink = !cursor_blink; 737 config->disable_cursor_blink = !cursor_blink;
950 instance.config->temporary = EINA_TRUE; 738 config->temporary = EINA_TRUE;
951 } 739 }
952 if (visual_bell != 0xff) 740 if (visual_bell != 0xff)
953 { 741 {
954 instance.config->disable_visual_bell = !visual_bell; 742 config->disable_visual_bell = !visual_bell;
955 instance.config->temporary = EINA_TRUE; 743 config->temporary = EINA_TRUE;
956 } 744 }
957 if (instance.active_links != 0xff) 745 if (active_links != 0xff)
958 { 746 {
959 instance.config->active_links = !!instance.active_links; 747 config->active_links = !!active_links;
960 instance.config->active_links_email = instance.config->active_links; 748 config->active_links_email = config->active_links;
961 instance.config->active_links_file = instance.config->active_links; 749 config->active_links_file = config->active_links;
962 instance.config->active_links_url = instance.config->active_links; 750 config->active_links_url = config->active_links;
963 instance.config->active_links_escape = instance.config->active_links; 751 config->active_links_escape = config->active_links;
964 instance.config->temporary = EINA_TRUE; 752 config->temporary = EINA_TRUE;
965 } 753 }
966 754
967 if (xterm_256color) 755 if (xterm_256color)
968 { 756 {
969 instance.config->xterm_256color = EINA_TRUE; 757 config->xterm_256color = EINA_TRUE;
970 instance.config->temporary = EINA_TRUE; 758 config->temporary = EINA_TRUE;
971 } 759 }
972 760
973 if (geometry) 761 if (geometry)
974 { 762 {
975 if (sscanf(geometry,"%ix%i+%i+%i", &instance.w, &instance.h, 763 if (sscanf(geometry,"%ix%i+%i+%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
976 &instance.x, &instance.y) == 4)
977 { 764 {
978 instance.pos = EINA_TRUE; 765 pos_set = 1;
979 size_set = EINA_TRUE; 766 size_set = 1;
980 } 767 }
981 else if (sscanf(geometry,"%ix%i-%i+%i", &instance.w, &instance.h, 768 else if (sscanf(geometry,"%ix%i-%i+%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
982 &instance.x, &instance.y) == 4)
983 { 769 {
984 instance.x = -instance.x; 770 pos_x = -pos_x;
985 instance.pos = EINA_TRUE; 771 pos_set = 1;
986 size_set = EINA_TRUE; 772 size_set = 1;
987 } 773 }
988 else if (sscanf(geometry,"%ix%i-%i-%i", &instance.w, &instance.h, 774 else if (sscanf(geometry,"%ix%i-%i-%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
989 &instance.x, &instance.y) == 4)
990 { 775 {
991 instance.x = -instance.x; 776 pos_x = -pos_x;
992 instance.y = -instance.y; 777 pos_y = -pos_y;
993 instance.pos = EINA_TRUE; 778 pos_set = 1;
994 size_set = EINA_TRUE; 779 size_set = 1;
995 } 780 }
996 else if (sscanf(geometry,"%ix%i+%i-%i", &instance.w, &instance.h, 781 else if (sscanf(geometry,"%ix%i+%i-%i", &size_w, &size_h, &pos_x, &pos_y) == 4)
997 &instance.x, &instance.y) == 4)
998 { 782 {
999 instance.y = -instance.y; 783 pos_y = -pos_y;
1000 instance.pos = EINA_TRUE; 784 pos_set = 1;
1001 size_set = EINA_TRUE; 785 size_set = 1;
1002 } 786 }
1003 else if (sscanf(geometry,"%ix%i", &instance.w, &instance.h) == 2) 787 else if (sscanf(geometry,"%ix%i", &size_w, &size_h) == 2)
1004 { 788 {
1005 size_set = EINA_TRUE; 789 size_set = 1;
1006 } 790 }
1007 else if (sscanf(geometry,"+%i+%i", &instance.x, &instance.y) == 2) 791 else if (sscanf(geometry,"+%i+%i", &pos_x, &pos_y) == 2)
1008 { 792 {
1009 instance.pos = EINA_TRUE; 793 pos_set = 1;
1010 } 794 }
1011 else if (sscanf(geometry,"-%i+%i", &instance.x, &instance.y) == 2) 795 else if (sscanf(geometry,"-%i+%i", &pos_x, &pos_y) == 2)
1012 { 796 {
1013 instance.x = -instance.x; 797 pos_x = -pos_x;
1014 instance.pos = EINA_TRUE; 798 pos_set = 1;
1015 } 799 }
1016 else if (sscanf(geometry,"+%i-%i", &instance.x, &instance.y) == 2) 800 else if (sscanf(geometry,"+%i-%i", &pos_x, &pos_y) == 2)
1017 { 801 {
1018 instance.y = -instance.y; 802 pos_y = -pos_y;
1019 instance.pos = EINA_TRUE; 803 pos_set = 1;
1020 } 804 }
1021 else if (sscanf(geometry,"-%i-%i", &instance.x, &instance.y) == 2) 805 else if (sscanf(geometry,"-%i-%i", &pos_x, &pos_y) == 2)
1022 { 806 {
1023 instance.x = -instance.x; 807 pos_x = -pos_x;
1024 instance.y = -instance.y; 808 pos_y = -pos_y;
1025 instance.pos = EINA_TRUE; 809 pos_set = 1;
1026 } 810 }
1027 } 811 }
1028 812
1029 if (!size_set) 813 if (!size_set)
1030 { 814 {
1031 if (instance.config->custom_geometry) 815 if (config->custom_geometry)
1032 { 816 {
1033 instance.w = instance.config->cg_width; 817 size_w = config->cg_width;
1034 instance.h = instance.config->cg_height; 818 size_h = config->cg_height;
1035 } 819 }
1036 else 820 else
1037 { 821 {
1038 instance.w = 80; 822 size_w = 80;
1039 instance.h = 24; 823 size_h = 24;
1040 } 824 }
1041 } 825 }
1042 826
1043 if (instance.login_shell != 0xff) 827 if (login_shell != 0xff)
1044 { 828 {
1045 instance.config->login_shell = instance.login_shell; 829 config->login_shell = login_shell;
1046 instance.config->temporary = EINA_TRUE; 830 config->temporary = EINA_TRUE;
1047 } 831 }
1048 instance.login_shell = instance.config->login_shell; 832 login_shell = config->login_shell;
1049 833
1050 elm_theme_overlay_add(NULL, 834 elm_theme_overlay_add(NULL, config_theme_path_default_get(config));
1051 config_theme_path_default_get(instance.config)); 835 elm_theme_overlay_add(NULL, config_theme_path_get(config));
1052 elm_theme_overlay_add(NULL, config_theme_path_get(instance.config));
1053 836
1054 if ((!single) && (instance.config->multi_instance)) 837remote:
838 if ((!single) && (config->multi_instance))
1055 { 839 {
840 Ipc_Instance inst;
1056 char cwdbuf[4096]; 841 char cwdbuf[4096];
1057 842
1058 if (!instance.cd) 843 memset(&inst, 0, sizeof(Ipc_Instance));
1059 instance.cd = getcwd(cwdbuf, sizeof(cwdbuf)); 844
1060 if (_start_multi(&instance, argv)) 845 inst.cmd = cmd;
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))
1061 goto end; 870 goto end;
1062 } 871 }
1063 else 872 if ((!single) && (config->multi_instance))
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)
1064 { 905 {
1065 _start(&instance); 906 CRITICAL(_("Could not create terminal widget."));
907 config = NULL;
908 retval = EXIT_FAILURE;
909 goto end;
1066 } 910 }
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
1067 elm_run(); 978 elm_run();
1068 979
1069 ecore_con_url_shutdown(); 980 ecore_con_url_shutdown();
1070 ecore_con_shutdown(); 981 ecore_con_shutdown();
1071 982
1072 instance.config = NULL; 983 config = NULL;
1073 end: 984 end:
1074 if (instance.config) 985 if (!startup_split) free(cmd);
986 if (config)
1075 { 987 {
1076 config_del(instance.config); 988 config_del(config);
1077 instance.config = NULL; 989 config = NULL;
1078 } 990 }
1079 991
1080 ipc_shutdown(); 992 ipc_shutdown();