win: move saved position of tab when other tab is closed

This commit is contained in:
Boris Faure 2020-03-14 18:43:16 +01:00
parent 0fc86663a4
commit 413e6eb2a2
Signed by untrusted user who does not match committer: borisfaure
GPG Key ID: 35C0410516166BE8
1 changed files with 30 additions and 8 deletions

View File

@ -4273,15 +4273,22 @@ _tabs_size_eval(Term_Container *container, Sizeinfo *info)
} }
static Eina_List * static Eina_List *
_tab_item_find(const Tabs *tabs, const Term_Container *child) _tab_item_find(const Tabs *tabs, const Term_Container *child,
int *pos)
{ {
Eina_List *l; Eina_List *l;
Tab_Item *tab_item; Tab_Item *tab_item;
int i = 0;
EINA_LIST_FOREACH(tabs->tabs, l, tab_item) EINA_LIST_FOREACH(tabs->tabs, l, tab_item)
{ {
if (tab_item->tc == child) if (tab_item->tc == child)
return l; {
if (pos)
*pos = i;
return l;
}
i++;
} }
return NULL; return NULL;
} }
@ -4297,6 +4304,7 @@ _tabs_close(Term_Container *tc, Term_Container *child)
Term_Container *next_child, *tc_parent; Term_Container *next_child, *tc_parent;
Term *term; Term *term;
Solo *solo; Solo *solo;
int pos = 0;
/* TODO: figure out whether to move position if tab_drag */ /* TODO: figure out whether to move position if tab_drag */
@ -4305,7 +4313,7 @@ _tabs_close(Term_Container *tc, Term_Container *child)
tc_parent = tc->parent; tc_parent = tc->parent;
l = _tab_item_find(tabs, child); l = _tab_item_find(tabs, child, &pos);
item = l->data; item = l->data;
next = eina_list_next(l); next = eina_list_next(l);
@ -4359,12 +4367,26 @@ _tabs_close(Term_Container *tc, Term_Container *child)
if (tc->is_focused) if (tc->is_focused)
next_child->focus(next_child, tc); next_child->focus(next_child, tc);
if ((_tab_drag) && (_tab_drag->parent_type == TERM_CONTAINER_TYPE_TABS)
&& (_tab_drag->tabs_child == tc))
{
_tab_drag->tabs_child = next_child;
}
_tab_item_free(item); _tab_item_free(item);
_tab_item_free(next_item); _tab_item_free(next_item);
free(tc); free(tc);
return; return;
} }
if ((_tab_drag) && (_tab_drag->parent_type == TERM_CONTAINER_TYPE_TABS)
&& (_tab_drag->tabs_child == tc))
{
if (pos < _tab_drag->previous_position)
_tab_drag->previous_position--;
}
if (item->tc->selector_img) if (item->tc->selector_img)
{ {
Evas_Object *o; Evas_Object *o;
@ -4408,7 +4430,7 @@ _tabs_term_next(const Term_Container *tc, const Term_Container *child)
assert (tc->type == TERM_CONTAINER_TYPE_TABS); assert (tc->type == TERM_CONTAINER_TYPE_TABS);
tabs = (Tabs*)tc; tabs = (Tabs*)tc;
l = _tab_item_find(tabs, child); l = _tab_item_find(tabs, child, NULL);
l = eina_list_next(l); l = eina_list_next(l);
if (l) if (l)
{ {
@ -4431,7 +4453,7 @@ _tabs_term_prev(const Term_Container *tc, const Term_Container *child)
assert (tc->type == TERM_CONTAINER_TYPE_TABS); assert (tc->type == TERM_CONTAINER_TYPE_TABS);
tabs = (Tabs*)tc; tabs = (Tabs*)tc;
l = _tab_item_find(tabs, child); l = _tab_item_find(tabs, child, NULL);
l = eina_list_prev(l); l = eina_list_prev(l);
if (l) if (l)
{ {
@ -4587,7 +4609,7 @@ _tabs_swallow(Term_Container *tc, Term_Container *orig,
assert (tc->type == TERM_CONTAINER_TYPE_TABS); assert (tc->type == TERM_CONTAINER_TYPE_TABS);
tabs = (Tabs*) tc; tabs = (Tabs*) tc;
l = _tab_item_find(tabs, new_child); l = _tab_item_find(tabs, new_child, NULL);
tab_item = l->data; tab_item = l->data;
if (tabs->selector) if (tabs->selector)
@ -4738,7 +4760,7 @@ _tabs_focus(Term_Container *tc, Term_Container *relative)
Eina_List *l; Eina_List *l;
Tab_Item *tab_item; Tab_Item *tab_item;
l = _tab_item_find(tabs, relative); l = _tab_item_find(tabs, relative, NULL);
if (!l) if (!l)
return; return;
@ -4863,7 +4885,7 @@ _tabs_set_title(Term_Container *tc, Term_Container *child,
assert (tc->type == TERM_CONTAINER_TYPE_TABS); assert (tc->type == TERM_CONTAINER_TYPE_TABS);
tabs = (Tabs*) tc; tabs = (Tabs*) tc;
l = _tab_item_find(tabs, child); l = _tab_item_find(tabs, child, NULL);
if (!l) if (!l)
return; return;
tab_item = l->data; tab_item = l->data;