From ea19439b72526593797f0f9118bb9270eb44fd2c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 13 Jan 2014 16:57:17 +0000 Subject: [PATCH] Tiling2: Removed more redundant code. --- src/modules/tiling/e_mod_tiling.c | 985 +----------------------------- 1 file changed, 5 insertions(+), 980 deletions(-) diff --git a/src/modules/tiling/e_mod_tiling.c b/src/modules/tiling/e_mod_tiling.c index 1f2d41f28..b942d8afd 100644 --- a/src/modules/tiling/e_mod_tiling.c +++ b/src/modules/tiling/e_mod_tiling.c @@ -218,28 +218,6 @@ change_window_border(E_Client *ec, DBG("%p -> border %s", ec, bordername); } -static int -get_stack(const E_Client *ec) -{ - int i; - for (i = 0; i < TILING_MAX_STACKS; i++) { - if (EINA_LIST_IS_IN(_G.tinfo->stacks[i], ec)) - return i; - } - return -1; -} - -static int -get_stack_count(void) -{ - int i; - for (i = 0; i < TILING_MAX_STACKS; i++) { - if (!_G.tinfo->stacks[i]) - return i; - } - return TILING_MAX_STACKS; -} - static int get_window_count(void) { @@ -254,20 +232,6 @@ get_window_count(void) return res; } -static void -_theme_edje_object_set_aux(Evas_Object *obj, const char *group) -{ - if (!e_theme_edje_object_set(obj, "base/theme/modules/tiling", - group)) { - edje_object_file_set(obj, _G.edj_path, group); - } -} -#define _theme_edje_object_set(_obj, _group) \ - if (!e_config->use_shaped_win) \ - _theme_edje_object_set_aux(_obj, _group"/composite"); \ - else \ - _theme_edje_object_set_aux(_obj, _group); - static Eina_Bool _info_hash_update(const Eina_Hash *hash __UNUSED__, const void *key __UNUSED__, void *data, void *fdata __UNUSED__) @@ -302,15 +266,6 @@ _e_client_move_resize(E_Client *ec, evas_object_geometry_set(ec->frame, x, y, w, h); } -static void -_e_client_move(E_Client *ec, - int x, - int y) -{ - DBG("%p -> +%d+%d", ec, x, y); - evas_object_move(ec->frame, x, y); -} - static void _e_client_maximize(E_Client *ec, E_Maximize max) { @@ -683,199 +638,6 @@ _reapply_tree(void) } } -static void -_reorganize_stack(int stack) -{ - Eina_List *l; - - if (stack < 0 || stack >= TILING_MAX_STACKS - || !_G.tinfo->stacks[stack]) - return; - - if (_G.tinfo->stacks[stack]->next) { - int zx, zy, zw, zh, i = 0, count; - - e_zone_useful_geometry_get(_G.tinfo->desk->zone, &zx, &zy, &zw, &zh); - - count = eina_list_count(_G.tinfo->stacks[stack]); - - if (_G.tinfo->conf->use_rows) { - int y, w, h, cw; - - y = _G.tinfo->pos[stack]; - cw = 0; - w = zw / count; - h = _G.tinfo->size[stack]; - - for (l = _G.tinfo->stacks[stack]; l; l = l->next, i++) { - E_Client *ec = l->data; - Client_Extra *extra; - int d = (i * 2 * zw) % count - - (2 * cw) % count; - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - continue; - } - - if ((ec->maximized & E_MAXIMIZE_HORIZONTAL) && count != 1) { - _e_client_unmaximize(ec, E_MAXIMIZE_HORIZONTAL); - } - /* let's use a bresenham here */ - - extra->expected.x = cw + zx; - extra->expected.y = y; - extra->expected.w = w + d; - extra->expected.h = h; - cw += extra->expected.w; - - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - } - } else { - int x, w, h, ch; - - x = _G.tinfo->pos[stack]; - ch = 0; - w = _G.tinfo->size[stack]; - h = zh / count; - - for (l = _G.tinfo->stacks[stack]; l; l = l->next, i++) { - E_Client *ec = l->data; - Client_Extra *extra; - int d = (i * 2 * zh) % count - - (2 * ch) % count; - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - continue; - } - - if ((ec->maximized & E_MAXIMIZE_VERTICAL) && count != 1) { - _e_client_unmaximize(ec, E_MAXIMIZE_VERTICAL); - } - /* let's use a bresenham here */ - - extra->expected.x = x; - extra->expected.y = ch + zy; - extra->expected.w = w; - extra->expected.h = h + d; - ch += extra->expected.h; - - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - } - } - } else { - Client_Extra *extra; - E_Client *ec = _G.tinfo->stacks[stack]->data; - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - return; - } - - if (_G.tinfo->conf->use_rows) { - int x, w; - - e_zone_useful_geometry_get(_G.tinfo->desk->zone, - &x, NULL, &w, NULL); - - extra->expected.x = x; - extra->expected.y = _G.tinfo->pos[stack]; - extra->expected.w = w; - extra->expected.h = _G.tinfo->size[stack]; - - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - - _e_client_maximize(ec, E_MAXIMIZE_EXPAND | E_MAXIMIZE_HORIZONTAL); - } else { - int y, h; - - e_zone_useful_geometry_get(_G.tinfo->desk->zone, - NULL, &y, NULL, &h); - - extra->expected.x = _G.tinfo->pos[stack]; - extra->expected.y = y; - extra->expected.w = _G.tinfo->size[stack]; - extra->expected.h = h; - - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - - _e_client_maximize(ec, E_MAXIMIZE_EXPAND | E_MAXIMIZE_VERTICAL); - } - } -} - -static void -_set_stack_geometry(int stack, int pos, int size) -{ - Eina_List *l; - for (l = _G.tinfo->stacks[stack]; l; l = l->next) { - E_Client *ec = l->data; - Client_Extra *extra; - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - continue; - } - DBG("expected: %dx%d+%d+%d (%p)", - extra->expected.w, - extra->expected.h, - extra->expected.x, - extra->expected.y, - ec); - - if (_G.tinfo->conf->use_rows) { - extra->expected.y = pos; - extra->expected.h = size; - - if (ec->maximized) { - if (l->next && (ec->maximized & E_MAXIMIZE_HORIZONTAL)) - _e_client_unmaximize(ec, E_MAXIMIZE_HORIZONTAL); - if (_G.tinfo->stacks[1] && (ec->maximized & E_MAXIMIZE_VERTICAL)) - _e_client_unmaximize(ec, E_MAXIMIZE_VERTICAL); - } - } else { - extra->expected.x = pos; - extra->expected.w = size; - - if (ec->maximized) { - if (l->next && (ec->maximized & E_MAXIMIZE_VERTICAL)) - _e_client_unmaximize(ec, E_MAXIMIZE_VERTICAL); - if (_G.tinfo->stacks[1] && (ec->maximized & E_MAXIMIZE_HORIZONTAL)) - _e_client_unmaximize(ec, E_MAXIMIZE_HORIZONTAL); - } - } - - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - } - _G.tinfo->pos[stack] = pos; - _G.tinfo->size[stack] = size; -} - void change_desk_conf(struct _Config_vdesk *newconf) { @@ -1125,731 +887,6 @@ _e_mod_action_swap_cb(E_Object *obj __UNUSED__, _do_overlay(focused_ec, _action_swap, INPUT_MODE_SWAPPING); } -/* }}} */ -/* Move {{{*/ - -static void -_check_moving_anims(const E_Client *ec, const Client_Extra *extra, int stack) -{ - Eina_List *l = NULL; - overlay_t *overlay; - int nb_stacks = get_stack_count(); - - if (stack < 0) { - stack = get_stack(ec); - if (stack < 0) - return; - } - if (!extra) { - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - return; - } - } - l = eina_list_data_find_list(_G.tinfo->stacks[stack], ec); - if (!l) - return; - - /* move left */ - overlay = &_G.move_overlays[MOVE_LEFT]; - if ((_G.tinfo->conf->use_rows && l->prev) - || (!_G.tinfo->conf->use_rows && !_G.tinfo->stacks[TILING_MAX_STACKS -1] - && (ec != _G.tinfo->stacks[0]->data || _G.tinfo->stacks[0]->next))) - { - if (overlay->popup) { - Evas_Coord ew, eh; - - edje_object_size_min_calc(overlay->obj, &ew, &eh); - evas_object_move(_G.move_overlays[MOVE_LEFT].popup, - extra->expected.x - ew/2, - extra->expected.y + extra->expected.h/2 - eh/2); - } else { - Evas_Coord ew, eh; - - overlay->obj = edje_object_add(ec->comp->evas); - _theme_edje_object_set(overlay->obj, - "modules/tiling/move/left"); - edje_object_size_min_calc(overlay->obj, &ew, &eh); - overlay->popup = e_comp_object_util_add(overlay->obj, E_COMP_OBJECT_TYPE_POPUP); - evas_object_layer_set(overlay->popup, E_LAYER_CLIENT_NORMAL); - evas_object_show(overlay->obj); - evas_object_geometry_set(overlay->popup, - extra->expected.x - ew/2 - - ec->zone->x, - extra->expected.y + extra->expected.h/2 - - eh/2 - - ec->zone->y, - ew, - eh); - - evas_object_show(overlay->popup); - } - } else if (overlay->popup) { - if (overlay->popup) { - evas_object_hide(overlay->popup); - evas_object_del(overlay->popup); - overlay->popup = NULL; - } - } - - /* move right */ - overlay = &_G.move_overlays[MOVE_RIGHT]; - if ((_G.tinfo->conf->use_rows && l->next) - || (!_G.tinfo->conf->use_rows && ( - stack != TILING_MAX_STACKS - 1 - && ((stack == nb_stacks - 1 && _G.tinfo->stacks[stack]->next) - || (stack != nb_stacks - 1))))) { - if (overlay->popup) { - Evas_Coord ew, eh; - - edje_object_size_min_calc(overlay->obj, &ew, &eh); - evas_object_move(_G.move_overlays[MOVE_RIGHT].popup, - extra->expected.x + extra->expected.w - ew/2, - extra->expected.y + extra->expected.h/2 - eh/2); - } else { - Evas_Coord ew, eh; - - overlay->obj = edje_object_add(ec->comp->evas); - overlay->popup = e_comp_object_util_add(overlay->obj, E_COMP_OBJECT_TYPE_POPUP); - evas_object_layer_set(overlay->popup, E_LAYER_CLIENT_NORMAL); - _theme_edje_object_set(overlay->obj, - "modules/tiling/move/right"); - edje_object_size_min_calc(overlay->obj, &ew, &eh); - evas_object_geometry_set(overlay->popup, - extra->expected.x + extra->expected.w - ew/2 - - ec->zone->x, - extra->expected.y + extra->expected.h/2 - - eh/2 - - ec->zone->y, - ew, - eh); - evas_object_show(overlay->popup); - } - } else if (overlay->popup) { - if (overlay->popup) { - evas_object_hide(overlay->popup); - evas_object_del(overlay->popup); - overlay->popup = NULL; - } - } - - /* move up */ - overlay = &_G.move_overlays[MOVE_UP]; - if ((!_G.tinfo->conf->use_rows && l->prev) - || (_G.tinfo->conf->use_rows && !_G.tinfo->stacks[TILING_MAX_STACKS -1] - && (ec != _G.tinfo->stacks[0]->data || _G.tinfo->stacks[0]->next))) - { - if (overlay->popup) { - Evas_Coord ew, eh; - - edje_object_size_min_calc(overlay->obj, &ew, &eh); - evas_object_move(_G.move_overlays[MOVE_UP].popup, - extra->expected.x + extra->expected.w/2 - ew/2, - extra->expected.y - eh/2); - } else { - Evas_Coord ew, eh; - - overlay->obj = edje_object_add(ec->comp->evas); - overlay->popup = e_comp_object_util_add(overlay->obj, E_COMP_OBJECT_TYPE_POPUP); - evas_object_layer_set(overlay->popup, E_LAYER_CLIENT_NORMAL); - _theme_edje_object_set(overlay->obj, "modules/tiling/move/up"); - edje_object_size_min_calc(overlay->obj, &ew, &eh); - evas_object_geometry_set(overlay->popup, - extra->expected.x + extra->expected.w/2 - - ew/2 - - ec->zone->x, - extra->expected.y - eh/2 - - ec->zone->y, - ew, - eh); - - evas_object_show(overlay->popup); - } - } else if (overlay->popup) { - if (overlay->popup) { - evas_object_hide(overlay->popup); - evas_object_del(overlay->popup); - overlay->popup = NULL; - } - } - - /* move down */ - overlay = &_G.move_overlays[MOVE_DOWN]; - if ((!_G.tinfo->conf->use_rows && l->next) - || (_G.tinfo->conf->use_rows && ( - stack != TILING_MAX_STACKS - 1 - && ((stack == nb_stacks - 1 && _G.tinfo->stacks[stack]->next) - || (stack != nb_stacks - 1))))) { - if (overlay->popup) { - Evas_Coord ew, eh; - - edje_object_size_min_calc(overlay->obj, &ew, &eh); - evas_object_move(_G.move_overlays[MOVE_DOWN].popup, - extra->expected.x + extra->expected.w/2 - ew/2, - extra->expected.y + extra->expected.h - eh/2); - } else { - Evas_Coord ew, eh; - - overlay->obj = edje_object_add(ec->comp->evas); - overlay->popup = e_comp_object_util_add(overlay->obj, E_COMP_OBJECT_TYPE_POPUP); - evas_object_layer_set(overlay->popup, E_LAYER_CLIENT_NORMAL); - _theme_edje_object_set(overlay->obj, - "modules/tiling/move/down"); - edje_object_size_min_calc(overlay->obj, &ew, &eh); - evas_object_geometry_set(overlay->popup, - extra->expected.x + extra->expected.w/2 - - ew/2 - - ec->zone->x, - extra->expected.y + extra->expected.h - eh/2 - - ec->zone->y, - ew, - eh); - evas_object_show(overlay->popup); - } - } else if (overlay->popup) { - if (overlay->popup) { - evas_object_hide(overlay->popup); - evas_object_del(overlay->popup); - overlay->popup = NULL; - } - } -} - -static void -_move_right_rows_or_down_cols(E_Client *ec, Eina_Bool check_moving_anims) -{ - E_Client *ec_1 = ec, - *ec_2 = NULL; - Client_Extra *extra_1 = NULL, - *extra_2 = NULL; - Eina_List *l_1 = NULL, - *l_2 = NULL; - int stack; - - stack = get_stack(ec); - if (stack < 0) - return; - - l_1 = eina_list_data_find_list(_G.tinfo->stacks[stack], ec_1); - if (!l_1 || !l_1->next) - return; - l_2 = l_1->next; - ec_2 = l_2->data; - - extra_1 = eina_hash_find(_G.client_extras, &ec_1); - if (!extra_1) { - ERR("No extra for %p", ec_1); - return; - } - extra_2 = eina_hash_find(_G.client_extras, &ec_2); - if (!extra_2) { - ERR("No extra for %p", ec_2); - return; - } - - l_1->data = ec_2; - l_2->data = ec_1; - - if (_G.tinfo->conf->use_rows) { - extra_2->expected.x = extra_1->expected.x; - extra_1->expected.x += extra_2->expected.w; - } else { - extra_2->expected.y = extra_1->expected.y; - extra_1->expected.y += extra_2->expected.h; - } - - _e_client_move(ec_1, - extra_1->expected.x, - extra_1->expected.y); - _e_client_move(ec_2, - extra_2->expected.x, - extra_2->expected.y); - - if (check_moving_anims) - _check_moving_anims(ec_1, extra_1, stack); - - ecore_evas_pointer_warp(_G.tinfo->desk->zone->comp->ee, - extra_1->expected.x + extra_1->expected.w/2, - extra_1->expected.y + extra_1->expected.h/2); -} - -static void -_move_left_rows_or_up_cols(E_Client *ec, Eina_Bool check_moving_anims) -{ - E_Client *ec_1 = ec, - *ec_2 = NULL; - Client_Extra *extra_1 = NULL, - *extra_2 = NULL; - Eina_List *l_1 = NULL, - *l_2 = NULL; - int stack; - - stack = get_stack(ec); - assert(stack >= 0); - - if (_G.tinfo->stacks[stack]->data == ec) - return; - - l_1 = eina_list_data_find_list(_G.tinfo->stacks[stack], ec_1); - if (!l_1 || !l_1->prev) - return; - l_2 = l_1->prev; - ec_2 = l_2->data; - - extra_1 = eina_hash_find(_G.client_extras, &ec_1); - if (!extra_1) { - ERR("No extra for %p", ec_1); - return; - } - extra_2 = eina_hash_find(_G.client_extras, &ec_2); - if (!extra_2) { - ERR("No extra for %p", ec_2); - return; - } - - l_1->data = ec_2; - l_2->data = ec_1; - - if (_G.tinfo->conf->use_rows) { - extra_1->expected.x = extra_2->expected.x; - extra_2->expected.x += extra_1->expected.w; - } else { - extra_1->expected.y = extra_2->expected.y; - extra_2->expected.y += extra_1->expected.h; - } - - _e_client_move(ec_1, - extra_1->expected.x, - extra_1->expected.y); - _e_client_move(ec_2, - extra_2->expected.x, - extra_2->expected.y); - - if (check_moving_anims) - _check_moving_anims(ec_1, extra_1, stack); - - ecore_evas_pointer_warp(_G.tinfo->desk->zone->comp->ee, - extra_1->expected.x + extra_1->expected.w/2, - extra_1->expected.y + extra_1->expected.h/2); -} - -static void -_move_up_rows_or_left_cols(E_Client *ec, Eina_Bool check_moving_anims) -{ - Client_Extra *extra; - int stack; - int i; - int nb_stacks; - - stack = get_stack(ec); - assert(stack >= 0); - - nb_stacks = get_stack_count(); - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - return; - } - - if (stack == 0) { - int x, y, w, h, s; - int size = 0, pos; - - if (nb_stacks >= TILING_MAX_STACKS) - return; - if (_G.tinfo->stacks[0]->data == ec && !_G.tinfo->stacks[0]->next) - return; - - EINA_LIST_REMOVE(_G.tinfo->stacks[0], ec); - for (i = TILING_MAX_STACKS - 1; i > 0; i--) { - _G.tinfo->stacks[i] = _G.tinfo->stacks[i-1]; - } - _G.tinfo->stacks[0] = NULL; - EINA_LIST_APPEND(_G.tinfo->stacks[0], ec); - - e_zone_useful_geometry_get(ec->zone, &x, &y, &w, &h); - - extra->expected.x = x; - extra->expected.y = y; - if (_G.tinfo->conf->use_rows) { - s = h; - pos = x; - size = s / (nb_stacks + 1); - extra->expected.w = w; - extra->expected.h = size; - } else { - s = w; - pos = y; - size = s / (nb_stacks + 1); - extra->expected.w = size; - extra->expected.h = h; - } - _G.tinfo->pos[0] = pos; - _G.tinfo->size[0] = size; - - s -= size; - pos += size; - - for (i = 1; i <= nb_stacks; i++) { - size = s / (nb_stacks + 1 - i); - - _set_stack_geometry(i, pos, size); - - s -= size; - pos += size; - } - _reorganize_stack(1); - - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - _e_client_maximize(ec, E_MAXIMIZE_EXPAND | E_MAXIMIZE_VERTICAL); - - if (nb_stacks + 1 > _G.tinfo->conf->nb_stacks) { - _G.tinfo->conf->nb_stacks = nb_stacks + 1; - e_config_save_queue(); - } - if (check_moving_anims) - _check_moving_anims(ec, extra, 0); - ecore_evas_pointer_warp(_G.tinfo->desk->zone->comp->ee, - extra->expected.x + extra->expected.w/2, - extra->expected.y + extra->expected.h/2); - return; - } - - EINA_LIST_REMOVE(_G.tinfo->stacks[stack], ec); - EINA_LIST_APPEND(_G.tinfo->stacks[stack - 1], ec); - - if (!_G.tinfo->stacks[stack]) { - int pos, s; - - /* Remove stack */ - if (_G.tinfo->conf->use_rows) { - e_zone_useful_geometry_get(ec->zone, - NULL, &pos, NULL, &s); - } else { - e_zone_useful_geometry_get(ec->zone, - &pos, NULL, &s, NULL); - } - - nb_stacks--; - - assert((0 <= nb_stacks) && (nb_stacks < TILING_MAX_STACKS - 1)); - for (i = stack; i < nb_stacks; i++) { - _G.tinfo->stacks[i] = _G.tinfo->stacks[i+1]; - } - _G.tinfo->stacks[nb_stacks] = NULL; - for (i = 0; i < nb_stacks; i++) { - int size; - - size = s / (nb_stacks - i); - - _set_stack_geometry(i, pos, size); - - s -= size; - pos += size; - } - _reorganize_stack(stack - 1); - } else { - _reorganize_stack(stack); - _reorganize_stack(stack - 1); - } - - if (check_moving_anims) - _check_moving_anims(ec, extra, stack - 1); - - ecore_evas_pointer_warp(_G.tinfo->desk->zone->comp->ee, - extra->expected.x + extra->expected.w/2, - extra->expected.y + extra->expected.h/2); -} - -static void -_move_down_rows_or_right_cols(E_Client *ec, Eina_Bool check_moving_anims) -{ - int stack; - int nb_stacks; - Client_Extra *extra; - int i; - - stack = get_stack(ec); - assert(stack >= 0); - if (stack == TILING_MAX_STACKS - 1) - return; - - nb_stacks = get_stack_count(); - assert((0 < nb_stacks) && (nb_stacks < TILING_MAX_STACKS)); - if (stack == nb_stacks - 1 && !_G.tinfo->stacks[stack]->next) - return; - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - return; - } - - EINA_LIST_REMOVE(_G.tinfo->stacks[stack], ec); - EINA_LIST_APPEND(_G.tinfo->stacks[stack + 1], ec); - - if (_G.tinfo->stacks[stack] && _G.tinfo->stacks[stack + 1]->next) { - _reorganize_stack(stack); - _reorganize_stack(stack + 1); - if (check_moving_anims) - _check_moving_anims(ec, extra, stack + 1); - } else - if (_G.tinfo->stacks[stack]) { - /* Add stack */ - int x, y, w, h, s; - int size = 0, pos; - - assert(nb_stacks < TILING_MAX_STACKS); - - _reorganize_stack(stack); - - e_zone_useful_geometry_get(ec->zone, &x, &y, &w, &h); - - if (_G.tinfo->conf->use_rows) { - pos = y; - s = h; - } else { - pos = x; - s = w; - } - - for (i = 0; i < nb_stacks; i++) { - size = s / (nb_stacks + 1 - i); - - _set_stack_geometry(i, pos, size); - - s -= size; - pos += size; - } - - _G.tinfo->pos[nb_stacks] = pos; - _G.tinfo->size[nb_stacks] = size; - if (_G.tinfo->conf->use_rows) { - extra->expected.x = x; - extra->expected.y = pos; - extra->expected.w = w; - extra->expected.h = size; - } else { - extra->expected.x = pos; - extra->expected.y = y; - extra->expected.w = size; - extra->expected.h = h; - } - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - _e_client_maximize(ec, E_MAXIMIZE_EXPAND | E_MAXIMIZE_HORIZONTAL); - - if (nb_stacks + 1 > _G.tinfo->conf->nb_stacks) { - _G.tinfo->conf->nb_stacks = nb_stacks + 1; - e_config_save_queue(); - } - if (check_moving_anims) - _check_moving_anims(ec, extra, stack + 1); - } else { - int x, y, w, h, s, pos; - - /* Remove stack */ - e_zone_useful_geometry_get(ec->zone, &x, &y, &w, &h); - - nb_stacks--; - - assert((0 <= nb_stacks) && (nb_stacks < TILING_MAX_STACKS - 1)); - for (i = stack; i < nb_stacks; i++) { - _G.tinfo->stacks[i] = _G.tinfo->stacks[i + 1]; - } - - if (_G.tinfo->conf->use_rows) { - pos = y; - s = h; - } else { - pos = x; - s = w; - } - - for (i = 0; i < nb_stacks; i++) { - int size; - - size = s / (nb_stacks - i); - - _set_stack_geometry(i, pos, size); - - s -= size; - pos += size; - } - _G.tinfo->stacks[nb_stacks] = NULL; - _G.tinfo->pos[nb_stacks] = 0; - _G.tinfo->size[nb_stacks] = 0; - _reorganize_stack(stack); - if (check_moving_anims) - _check_moving_anims(ec, extra, stack); - } - - ecore_evas_pointer_warp(_G.tinfo->desk->zone->comp->ee, - extra->expected.x + extra->expected.w/2, - extra->expected.y + extra->expected.h/2); -} - -static Eina_Bool -move_key_down(void *data __UNUSED__, - int type __UNUSED__, - void *event) -{ - Ecore_Event_Key *ev = event; - - if (ev->event_window != _G.action_input_win) - return ECORE_CALLBACK_PASS_ON; - - /* reset timer */ - ecore_timer_delay(_G.action_timer, TILING_OVERLAY_TIMEOUT - - ecore_timer_pending_get(_G.action_timer)); - - if ((strcmp(ev->key, "Up") == 0) - || (strcmp(ev->key, "k") == 0)) - { - if (_G.tinfo->conf->use_rows) - _move_up_rows_or_left_cols(_G.focused_ec, true); - else - _move_left_rows_or_up_cols(_G.focused_ec, true); - return ECORE_CALLBACK_PASS_ON; - } else if ((strcmp(ev->key, "Down") == 0) - || (strcmp(ev->key, "j") == 0)) - { - if (_G.tinfo->conf->use_rows) - _move_down_rows_or_right_cols(_G.focused_ec, true); - else - _move_right_rows_or_down_cols(_G.focused_ec, true); - return ECORE_CALLBACK_PASS_ON; - } else if ((strcmp(ev->key, "Left") == 0) - || (strcmp(ev->key, "h") == 0)) - { - if (_G.tinfo->conf->use_rows) - _move_left_rows_or_up_cols(_G.focused_ec, true); - else - _move_up_rows_or_left_cols(_G.focused_ec, true); - return ECORE_CALLBACK_PASS_ON; - } else if ((strcmp(ev->key, "Right") == 0) - || (strcmp(ev->key, "l") == 0)) - { - if (_G.tinfo->conf->use_rows) - _move_right_rows_or_down_cols(_G.focused_ec, true); - else - _move_down_rows_or_right_cols(_G.focused_ec, true); - return ECORE_CALLBACK_PASS_ON; - } - - if (strcmp(ev->key, "Return") == 0) - goto stop; - if (strcmp(ev->key, "Escape") == 0) - goto stop; /* TODO: fallback */ - - return ECORE_CALLBACK_PASS_ON; -stop: - end_special_input(); - return ECORE_CALLBACK_DONE; -} - -static void -_e_mod_action_move_direct_cb(E_Object *obj __UNUSED__, - const char *params) -{ - E_Desk *desk; - E_Client *focused_ec; - - desk = get_current_desk(); - if (!desk) - return; - - focused_ec = e_client_focused_get(); - if (!focused_ec || focused_ec->desk != desk) - return; - - if (!desk_should_tile_check(desk)) - return; - - - assert(params != NULL); - - switch (params[0]) { - case 'l': /* left */ - if (_G.tinfo->conf->use_rows) - _move_left_rows_or_up_cols(focused_ec, false); - else - _move_up_rows_or_left_cols(focused_ec, false); - break; - case 'r': /* right */ - if (_G.tinfo->conf->use_rows) - _move_right_rows_or_down_cols(focused_ec, false); - else - _move_down_rows_or_right_cols(focused_ec, false); - break; - case 'u': /* up */ - if (_G.tinfo->conf->use_rows) - _move_up_rows_or_left_cols(focused_ec, false); - else - _move_left_rows_or_up_cols(focused_ec, false); - break; - case 'd': /* down */ - if (_G.tinfo->conf->use_rows) - _move_down_rows_or_right_cols(focused_ec, false); - else - _move_right_rows_or_down_cols(focused_ec, false); - break; - } -} - -static void -_e_mod_action_move_cb(E_Object *obj __UNUSED__, - const char *params __UNUSED__) -{ - E_Desk *desk; - E_Client *focused_ec; - Ecore_X_Window parent; - - desk = get_current_desk(); - if (!desk) - return; - - focused_ec = e_client_focused_get(); - if (!focused_ec || focused_ec->desk != desk) - return; - - if (!desk_should_tile_check(desk)) - return; - - _G.focused_ec = focused_ec; - - _G.input_mode = INPUT_MODE_MOVING; - - /* Get input */ - parent = focused_ec->zone->comp->win; - _G.action_input_win = ecore_x_window_input_new(parent, 0, 0, 1, 1); - if (!_G.action_input_win) { - end_special_input(); - return; - } - - ecore_x_window_show(_G.action_input_win); - if (!e_grabinput_get(_G.action_input_win, 0, _G.action_input_win)) { - end_special_input(); - return; - } - _G.action_timer = ecore_timer_add(TILING_OVERLAY_TIMEOUT, - _timeout_cb, NULL); - - _G.handler_key = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, - move_key_down, NULL); - _check_moving_anims(focused_ec, NULL, -1); -} - /* }}} */ /* Toggle split mode {{{ */ @@ -2103,6 +1140,7 @@ _desk_before_show_hook(void *data __UNUSED__, int type __UNUSED__, void *event _ static bool _desk_set_hook(void *data __UNUSED__, int type __UNUSED__, E_Event_Client_Desk_Set *ev) { + // FIXME: Fix this function DBG("%p: from (%d,%d) to (%d,%d)", ev->ec, ev->desk->x, ev->desk->y, ev->ec->desk->x, ev->ec->desk->y); @@ -2115,18 +1153,21 @@ _desk_set_hook(void *data __UNUSED__, int type __UNUSED__, E_Event_Client_Desk_S if (is_floating_window(ev->ec)) { EINA_LIST_REMOVE(_G.tinfo->floating_windows, ev->ec); } else { +#if 0 if (get_stack(ev->ec) >= 0) { _remove_client(ev->ec); _restore_client(ev->ec); } +#endif } if (!desk_should_tile_check(ev->ec->desk)) return true; - // FIXME: Fix this. +#if 0 if (get_stack(ev->ec) < 0) _add_client(ev->ec); +#endif return true; } @@ -2262,22 +1303,6 @@ e_modapi_init(E_Module *m) N_("Swap a window with an other"), "swap", NULL, NULL, 0); - ACTION_ADD(_G.act_move, _e_mod_action_move_cb, - N_("Move window"), "move", - NULL, NULL, 0); - ACTION_ADD(_G.act_move_left, _e_mod_action_move_direct_cb, - N_("Move window to the left"), "move_left", - "left", NULL, 0); - ACTION_ADD(_G.act_move_right, _e_mod_action_move_direct_cb, - N_("Move window to the right"), "move_right", - "right", NULL, 0); - ACTION_ADD(_G.act_move_up, _e_mod_action_move_direct_cb, - N_("Move window up"), "move_up", - "up", NULL, 0); - ACTION_ADD(_G.act_move_down, _e_mod_action_move_direct_cb, - N_("Move window down"), "move_down", - "down", NULL, 0); - ACTION_ADD(_G.act_toggle_split_mode, _e_mod_action_toggle_split_mode, N_("Toggle split mode"), "toggle_split_mode", NULL, NULL, 0);