summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2015-08-06 21:50:58 +0200
committerBoris Faure <billiob@gmail.com>2015-08-06 21:50:58 +0200
commitfc79e3857532f314ba8a26453b4582c767eddbdf (patch)
tree966e67bdf0f0446c2257dfbab5de2e41e29685c2 /src
parent41579e92e84402b14da4f1be9fa7923d66590969 (diff)
rewrite whether a term container is splittable. CID1315267 and CID1315268
Diffstat (limited to 'src')
-rw-r--r--src/bin/win.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/bin/win.c b/src/bin/win.c
index 35a3887..9293f5b 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -911,20 +911,25 @@ _win_set_title(Term_Container *tc, Term_Container *child EINA_UNUSED,
911} 911}
912 912
913Eina_Bool 913Eina_Bool
914_win_term_is_splittable(Term *tm, Eina_Bool is_horizontal) 914_term_container_is_splittable(Term_Container *tc, Eina_Bool is_horizontal)
915{ 915{
916 int grid_w = 0, grid_h = 0, c_w = 0, c_h = 0; 916 int w = 0, h = 0, c_w = 0, c_h = 0;
917 evas_object_geometry_get(tm->bg, NULL, NULL, &grid_w, &grid_h); 917 Term *tm;
918 Evas_Object *o;
919
920 o = tc->get_evas_object(tc);
921 evas_object_geometry_get(o, NULL, NULL, &w, &h);
922 tm = tc->term_first(tc);
918 evas_object_textgrid_cell_size_get(termio_textgrid_get(tm->termio), 923 evas_object_textgrid_cell_size_get(termio_textgrid_get(tm->termio),
919 &c_w, &c_h); 924 &c_w, &c_h);
920 if (is_horizontal) 925 if (is_horizontal)
921 { 926 {
922 if (c_h * 2 > grid_h) 927 if (c_h * 2 > h)
923 return EINA_FALSE; 928 return EINA_FALSE;
924 } 929 }
925 else 930 else
926 { 931 {
927 if (c_w * 2 > grid_w) 932 if (c_w * 2 > w)
928 return EINA_FALSE; 933 return EINA_FALSE;
929 } 934 }
930 return EINA_TRUE; 935 return EINA_TRUE;
@@ -934,20 +939,21 @@ static void
934_win_split(Term_Container *tc, Term_Container *child, const char *cmd, 939_win_split(Term_Container *tc, Term_Container *child, const char *cmd,
935 Eina_Bool is_horizontal) 940 Eina_Bool is_horizontal)
936{ 941{
937 Term *tm_new, *tm;
938 Term_Container *tc_split, *tc_solo_new;
939 Win *wn; 942 Win *wn;
940 char buf[PATH_MAX], *wdir = NULL;
941 Evas_Object *base;
942 Evas_Object *o;
943 943
944 assert (tc->type == TERM_CONTAINER_TYPE_WIN); 944 assert (tc->type == TERM_CONTAINER_TYPE_WIN);
945 wn = (Win*) tc; 945 wn = (Win*) tc;
946 946
947 tm = tc->focused_term_get(tc); 947 if (_term_container_is_splittable(tc, is_horizontal))
948 if (_win_term_is_splittable(tm, is_horizontal))
949 { 948 {
950 if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) 949 Term *tm_new, *tm;
950 Term_Container *tc_split, *tc_solo_new;
951 char buf[PATH_MAX], *wdir = NULL;
952 Evas_Object *base;
953 Evas_Object *o;
954
955 tm = tc->focused_term_get(tc);
956 if (termio_cwd_get(tm->termio, buf, sizeof(buf)))
951 wdir = buf; 957 wdir = buf;
952 tm_new = term_new(wn, wn->config, 958 tm_new = term_new(wn, wn->config,
953 cmd, wn->config->login_shell, wdir, 959 cmd, wn->config->login_shell, wdir,
@@ -1410,21 +1416,22 @@ static void
1410_split_split(Term_Container *tc, Term_Container *child, 1416_split_split(Term_Container *tc, Term_Container *child,
1411 const char *cmd, Eina_Bool is_horizontal) 1417 const char *cmd, Eina_Bool is_horizontal)
1412{ 1418{
1413 Term *tm_new, *tm;
1414 Term_Container *tc_split, *tc_solo_new;
1415 Split *split; 1419 Split *split;
1416 Win *wn; 1420 Win *wn;
1417 Evas_Object *obj_split;
1418 char buf[PATH_MAX], *wdir = NULL;
1419 1421
1420 assert (tc->type == TERM_CONTAINER_TYPE_SPLIT); 1422 assert (tc->type == TERM_CONTAINER_TYPE_SPLIT);
1421 split = (Split *)tc; 1423 split = (Split *)tc;
1422 wn = tc->wn; 1424 wn = tc->wn;
1423 1425
1424 tm = child->focused_term_get(child); 1426 if (_term_container_is_splittable(tc, is_horizontal))
1425 if (_win_term_is_splittable(tm, is_horizontal))
1426 { 1427 {
1427 if (tm && termio_cwd_get(tm->termio, buf, sizeof(buf))) 1428 Term *tm_new, *tm;
1429 char buf[PATH_MAX], *wdir = NULL;
1430 Term_Container *tc_split, *tc_solo_new;
1431 Evas_Object *obj_split;
1432
1433 tm = child->focused_term_get(child);
1434 if (termio_cwd_get(tm->termio, buf, sizeof(buf)))
1428 wdir = buf; 1435 wdir = buf;
1429 tm_new = term_new(wn, wn->config, 1436 tm_new = term_new(wn, wn->config,
1430 cmd, wn->config->login_shell, wdir, 1437 cmd, wn->config->login_shell, wdir,