diff --git a/src/modules/tiling/e_mod_tiling.c b/src/modules/tiling/e_mod_tiling.c index 8089e4f9e..d6c7a70d7 100644 --- a/src/modules/tiling/e_mod_tiling.c +++ b/src/modules/tiling/e_mod_tiling.c @@ -252,22 +252,6 @@ get_window_count(void) return res; } -static int -get_transition_count(void) -{ - int res = 0; - int i; - - for (i = 0; i < TILING_MAX_STACKS; i++) { - if (!_G.tinfo->stacks[i]) - break; - res += eina_list_count(_G.tinfo->stacks[i]); - } - if (_G.tinfo->stacks[0]) - res--; - return res; -} - static void _theme_edje_object_set_aux(Evas_Object *obj, const char *group) { @@ -838,41 +822,6 @@ _reorganize_stack(int stack) } } -static void -_move_resize_stack(int stack, int delta_pos, int delta_size) -{ - Eina_List *list = _G.tinfo->stacks[stack]; - Eina_List *l; - - for (l = list; 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; - } - - if (_G.tinfo->conf->use_rows) { - extra->expected.y += delta_pos; - extra->expected.h += delta_size; - } else { - extra->expected.x += delta_pos; - extra->expected.w += delta_size; - } - - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - } - - _G.tinfo->pos[stack] += delta_pos; - _G.tinfo->size[stack] += delta_size; -} - static void _set_stack_geometry(int stack, int pos, int size) { @@ -1900,564 +1849,7 @@ _e_mod_action_move_cb(E_Object *obj __UNUSED__, } /* }}} */ -/* Adjust Transitions {{{ */ - -static void -_transition_overlays_free_cb(void *data) -{ - transition_overlay_t *trov = data; - - if (trov->overlay.popup) { - evas_object_hide(trov->overlay.popup); - evas_object_del(trov->overlay.popup); - trov->overlay.popup = NULL; - } - if (trov != _G.transition_overlay) { - E_FREE(trov); - } -} - -static void -_transition_move_cols(tiling_move_t direction) -{ - int delta = TILING_RESIZE_STEP; - int stack; - Evas_Object *popup = NULL; - - if (!_G.transition_overlay) - return; - - stack = _G.transition_overlay->stack; - - if (_G.transition_overlay->ec) { - Eina_List *l = NULL; - E_Client *ec = _G.transition_overlay->ec, - *nextec = NULL; - Client_Extra *extra = NULL, - *nextextra = NULL; - int min_height = 0; - int x, y; - - l = eina_list_data_find_list(_G.tinfo->stacks[stack], ec); - if (!l) { - ERR("unable to ec %p in stack %d", ec, stack); - return; - } - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - return; - } - nextec = l->next->data; - nextextra = eina_hash_find(_G.client_extras, &nextec); - if (!nextextra) { - ERR("No extra for %p", nextec); - return; - } - - if (direction == MOVE_UP) { - delta *= -1; - } - - nextec = l->next->data; - min_height = MAX(nextec->icccm.base_h, 1); - - if (nextextra->expected.h - delta < min_height) - delta = nextextra->expected.h - min_height; - - nextextra->expected.y += delta; - nextextra->expected.h -= delta; - _e_client_move_resize(nextec, - nextextra->expected.x, - nextextra->expected.y, - nextextra->expected.w, - nextextra->expected.h); - - extra->expected.h += delta; - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - - popup = _G.transition_overlay->overlay.popup; - evas_object_geometry_get(popup, &x, &y, NULL, NULL); - evas_object_move(popup, x, y + delta); - } else { - int x, y; - - if (stack == TILING_MAX_STACKS || !_G.tinfo->stacks[stack + 1]) { - return; - } - if (direction == MOVE_LEFT) { - delta *= -1; - } - - if (delta + 1 > _G.tinfo->size[stack + 1]) - delta = _G.tinfo->size[stack + 1] - 1; - - _move_resize_stack(stack, 0, delta); - _move_resize_stack(stack+1, delta, -delta); - - popup = _G.transition_overlay->overlay.popup; - evas_object_geometry_get(popup, &x, &y, NULL, NULL); - evas_object_move(popup, x + delta, y); - } -} - -static void -_transition_move_rows(tiling_move_t direction) -{ - int delta = TILING_RESIZE_STEP; - int stack; - int x, y; - Evas_Object *popup = NULL; - - if (!_G.transition_overlay) - return; - - stack = _G.transition_overlay->stack; - - if (_G.transition_overlay->ec) { - Eina_List *l = NULL; - E_Client *ec = _G.transition_overlay->ec, - *nextec = NULL; - Client_Extra *extra = NULL, - *nextextra = NULL; - int min_width = 0; - - l = eina_list_data_find_list(_G.tinfo->stacks[stack], ec); - if (!l) { - ERR("unable to ec %p in stack %d", ec, stack); - return; - } - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - return; - } - nextec = l->next->data; - nextextra = eina_hash_find(_G.client_extras, &nextec); - if (!nextextra) { - ERR("No extra for %p", nextec); - return; - } - - if (direction == MOVE_LEFT) { - delta *= -1; - } - - nextec = l->next->data; - min_width = MAX(nextec->icccm.base_w, 1); - - if (nextextra->expected.w - delta < min_width) - delta = nextextra->expected.w - min_width; - - nextextra->expected.x += delta; - nextextra->expected.w -= delta; - _e_client_move_resize(nextec, - nextextra->expected.x, - nextextra->expected.y, - nextextra->expected.w, - nextextra->expected.h); - - extra->expected.w += delta; - _e_client_move_resize(ec, - extra->expected.x, - extra->expected.y, - extra->expected.w, - extra->expected.h); - - popup = _G.transition_overlay->overlay.popup; - evas_object_geometry_get(popup, &x, &y, NULL, NULL); - evas_object_move(popup, x + delta, y); - } else { - - if (stack == TILING_MAX_STACKS || !_G.tinfo->stacks[stack + 1]) { - return; - } - if (direction == MOVE_UP) { - delta *= -1; - } - - if (delta + 1 > _G.tinfo->size[stack + 1]) - delta = _G.tinfo->size[stack + 1] - 1; - - _move_resize_stack(stack, 0, delta); - _move_resize_stack(stack+1, delta, -delta); - - popup = _G.transition_overlay->overlay.popup; - evas_object_geometry_get(popup, &x, &y, NULL, NULL); - evas_object_move(popup, x, y + delta); - } -} - -static Eina_Bool -_transition_overlay_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; - - if (strcmp(ev->key, "Return") == 0) - goto stop; - if (strcmp(ev->key, "Escape") == 0) - goto stop; - - /* reset timer */ - ecore_timer_delay(_G.action_timer, TILING_OVERLAY_TIMEOUT - - ecore_timer_pending_get(_G.action_timer)); - - if (_G.transition_overlay) { - DBG("ev->key='%s'; %p %d", ev->key, - _G.transition_overlay->ec, _G.tinfo->conf->use_rows); - if ((strcmp(ev->key, "Up") == 0) - || (strcmp(ev->key, "k") == 0)) - { - if (_G.transition_overlay->ec && !_G.tinfo->conf->use_rows) { - _transition_move_cols(MOVE_UP); - return ECORE_CALLBACK_PASS_ON; - } else - if (!_G.transition_overlay->ec && _G.tinfo->conf->use_rows) { - _transition_move_rows(MOVE_UP); - return ECORE_CALLBACK_PASS_ON; - } - } else - if ((strcmp(ev->key, "Down") == 0) - || (strcmp(ev->key, "j") == 0)) - { - if (_G.transition_overlay->ec && !_G.tinfo->conf->use_rows) { - _transition_move_cols(MOVE_DOWN); - return ECORE_CALLBACK_PASS_ON; - } else - if (!_G.transition_overlay->ec && _G.tinfo->conf->use_rows) { - _transition_move_rows(MOVE_DOWN); - return ECORE_CALLBACK_PASS_ON; - } - } else - if ((strcmp(ev->key, "Left") == 0) - || (strcmp(ev->key, "h") == 0)) - { - if (!_G.transition_overlay->ec && !_G.tinfo->conf->use_rows) { - _transition_move_cols(MOVE_LEFT); - return ECORE_CALLBACK_PASS_ON; - } else - if (_G.transition_overlay->ec && _G.tinfo->conf->use_rows) { - _transition_move_rows(MOVE_LEFT); - return ECORE_CALLBACK_PASS_ON; - } - } else - if ((strcmp(ev->key, "Right") == 0) - || (strcmp(ev->key, "l") == 0)) - { - if (!_G.transition_overlay->ec && !_G.tinfo->conf->use_rows) { - _transition_move_cols(MOVE_RIGHT); - return ECORE_CALLBACK_PASS_ON; - } else - if (_G.transition_overlay->ec && _G.tinfo->conf->use_rows) { - _transition_move_rows(MOVE_RIGHT); - return ECORE_CALLBACK_PASS_ON; - } - } - - return ECORE_CALLBACK_RENEW; - } else { - if (strcmp(ev->key, "Backspace") == 0) { - char *key = _G.keys; - - while (*key) - key++; - *key = '\0'; - return ECORE_CALLBACK_RENEW; - } - if (ev->key[0] && !ev->key[1] && strchr(tiling_g.config->keyhints, - ev->key[1])) - { - transition_overlay_t *trov = NULL; - E_Client *ec = NULL; - Client_Extra *extra = NULL; - Evas_Coord ew, eh; - char *key = _G.keys; - - while (*key) - key++; - *key++ = ev->key[0]; - *key = '\0'; - - trov = eina_hash_find(_G.overlays, _G.keys); - if (!trov) { - return ECORE_CALLBACK_RENEW; - } - ec = trov->ec; - - _G.transition_overlay = trov; - eina_hash_free(_G.overlays); - _G.overlays = NULL; - - if (ec) { - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - goto stop; - } - } - if (!trov->overlay.obj) { - trov->overlay.obj = - edje_object_add(e_comp_get(_G.tinfo->desk)->evas); - } - if (!trov->overlay.popup) { - trov->overlay.popup = e_comp_object_util_add(trov->overlay.obj, E_COMP_OBJECT_TYPE_POPUP); - evas_object_layer_set(trov->overlay.popup, E_LAYER_CLIENT_NORMAL); - } - if ((ec && !_G.tinfo->conf->use_rows) - || (!ec && _G.tinfo->conf->use_rows)) { - _theme_edje_object_set(trov->overlay.obj, - "modules/tiling/transition/horizontal"); - } else { - _theme_edje_object_set(trov->overlay.obj, - "modules/tiling/transition/vertical"); - } - - edje_object_size_min_calc(trov->overlay.obj, &ew, &eh); - if (ec) { - if (_G.tinfo->conf->use_rows) { - evas_object_geometry_set(trov->overlay.popup, - (extra->expected.x - trov->ec->zone->x + - extra->expected.w - (ew / 2)), - (extra->expected.y - trov->ec->zone->y + - ((extra->expected.h - eh) / 2)), - ew, eh); - } else { - evas_object_geometry_set(trov->overlay.popup, - (extra->expected.x - trov->ec->zone->x + - ((extra->expected.w - ew) / 2)), - (extra->expected.y - trov->ec->zone->y + - extra->expected.h - (eh / 2)), - ew, eh); - } - } else { - if (_G.tinfo->conf->use_rows) { - evas_object_geometry_set(trov->overlay.popup, - (trov->ec->zone->w/2 - ew/2), - (_G.tinfo->pos[trov->stack] - + _G.tinfo->size[trov->stack] - - trov->ec->zone->y - eh/2), - ew, eh); - } else { - evas_object_geometry_set(trov->overlay.popup, - (_G.tinfo->pos[trov->stack] - + _G.tinfo->size[trov->stack] - - trov->ec->zone->x - ew/2), - (trov->ec->zone->h/2 - eh/2), - ew, eh); - } - } - evas_object_show(trov->overlay.popup); - - return ECORE_CALLBACK_RENEW; - } - } - -stop: - end_special_input(); - return ECORE_CALLBACK_DONE; -} - -static void -_do_transition_overlay(void) -{ - int nb_transitions; - Ecore_X_Window parent; - int hints_len; - int key_len; - int n = 0; - int nmax; - int i; - - end_special_input(); - - nb_transitions = get_transition_count(); - if (nb_transitions < 1) { - return; - } - - _G.input_mode = INPUT_MODE_TRANSITION; - - _G.overlays = eina_hash_string_small_new(_transition_overlays_free_cb); - hints_len = strlen(tiling_g.config->keyhints); - key_len = 1; - nmax = hints_len; - if (hints_len < nb_transitions) { - key_len = 2; - nmax *= hints_len; - if (hints_len * hints_len < nb_transitions) { - key_len = 3; - nmax *= hints_len; - } - } - - - for (i = 0; i < TILING_MAX_STACKS; i++) { - Eina_List *l; - E_Client *ec; - - if (!_G.tinfo->stacks[i]) - break; - EINA_LIST_FOREACH(_G.tinfo->stacks[i], l, ec) { - if (l->next && n < nmax) { - Client_Extra *extra; - Evas_Coord ew, eh; - transition_overlay_t *trov; - - extra = eina_hash_find(_G.client_extras, &ec); - if (!extra) { - ERR("No extra for %p", ec); - continue; - } - - trov = E_NEW(transition_overlay_t, 1); - - trov->overlay.obj = edje_object_add(ec->comp->evas); - trov->overlay.popup = e_comp_object_util_add(trov->overlay.obj, E_COMP_OBJECT_TYPE_POPUP); - evas_object_layer_set(trov->overlay.popup, E_LAYER_CLIENT_NORMAL); - e_theme_edje_object_set(trov->overlay.obj, - "base/theme/borders", - "e/widgets/border/default/resize"); - - switch (key_len) { - case 1: - trov->key[0] = tiling_g.config->keyhints[n]; - trov->key[1] = '\0'; - break; - case 2: - trov->key[0] = tiling_g.config->keyhints[n / hints_len]; - trov->key[1] = tiling_g.config->keyhints[n % hints_len]; - trov->key[2] = '\0'; - break; - case 3: - trov->key[0] = tiling_g.config->keyhints[n / hints_len / hints_len]; - trov->key[0] = tiling_g.config->keyhints[n / hints_len]; - trov->key[1] = tiling_g.config->keyhints[n % hints_len]; - trov->key[2] = '\0'; - break; - } - n++; - trov->stack = i; - trov->ec = ec; - - eina_hash_add(_G.overlays, trov->key, trov); - edje_object_part_text_set(trov->overlay.obj, - "e.text.label", - trov->key); - edje_object_size_min_calc(trov->overlay.obj, &ew, &eh); - - if (_G.tinfo->conf->use_rows) { - evas_object_geometry_set(trov->overlay.popup, - (extra->expected.x - trov->ec->zone->x + - extra->expected.w - (ew / 2)), - (extra->expected.y - trov->ec->zone->y + - ((extra->expected.h - eh) / 2)), - ew, eh); - } else { - evas_object_geometry_set(trov->overlay.popup, - (extra->expected.x - trov->ec->zone->x + - ((extra->expected.w - ew) / 2)), - (extra->expected.y - trov->ec->zone->y + - extra->expected.h - (eh / 2)), - ew, eh); - } - - evas_object_show(trov->overlay.popup); - } - } - if (i != (TILING_MAX_STACKS - 1) && - _G.tinfo->stacks[i+1] && n < nmax) - { - Evas_Coord ew, eh; - transition_overlay_t *trov; - - trov = E_NEW(transition_overlay_t, 1); - - trov->overlay.obj = edje_object_add(e_comp_get(_G.tinfo->desk)->evas); - trov->overlay.popup = e_comp_object_util_add(trov->overlay.obj, E_COMP_OBJECT_TYPE_POPUP); - evas_object_layer_set(trov->overlay.popup, E_LAYER_CLIENT_NORMAL); - e_theme_edje_object_set(trov->overlay.obj, - "base/theme/borders", - "e/widgets/border/default/resize"); - - switch (key_len) { - case 1: - trov->key[0] = tiling_g.config->keyhints[n]; - trov->key[1] = '\0'; - break; - case 2: - trov->key[0] = tiling_g.config->keyhints[n / hints_len]; - trov->key[1] = tiling_g.config->keyhints[n % hints_len]; - trov->key[2] = '\0'; - break; - case 3: - trov->key[0] = tiling_g.config->keyhints[n / hints_len / hints_len]; - trov->key[0] = tiling_g.config->keyhints[n / hints_len]; - trov->key[1] = tiling_g.config->keyhints[n % hints_len]; - trov->key[2] = '\0'; - break; - } - n++; - trov->stack = i; - trov->ec = NULL; - - eina_hash_add(_G.overlays, trov->key, trov); - edje_object_part_text_set(trov->overlay.obj, - "e.text.label", - trov->key); - edje_object_size_min_calc(trov->overlay.obj, &ew, &eh); - - if (_G.tinfo->conf->use_rows) { - evas_object_geometry_set(trov->overlay.popup, - (trov->ec->zone->w/2 - ew/2), - (_G.tinfo->pos[trov->stack] - + _G.tinfo->size[trov->stack] - - trov->ec->zone->y - eh/2), - ew, eh); - } else { - evas_object_geometry_set(trov->overlay.popup, - (_G.tinfo->pos[trov->stack] - + _G.tinfo->size[trov->stack] - - trov->ec->zone->x - ew/2), - (trov->ec->zone->h/2 - eh/2), - ew, eh); - } - - evas_object_show(trov->overlay.popup); - } - } - - /* Get input */ - parent = _G.tinfo->desk->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.keys[0] = '\0'; - _G.handler_key = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, - _transition_overlay_key_down, - NULL); -} +/* Toggle split mode {{{ */ static void _e_mod_action_toggle_split_mode(E_Object *obj __UNUSED__,