From f4a7b6512ab3e2ebbf17f2496a958f02b3b2605c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 10 Feb 2014 09:27:57 +0000 Subject: [PATCH] Tiling2: Fixed formattign, again. Fixes T919. --- src/modules/tiling/e_mod_config.c | 209 +++---- src/modules/tiling/e_mod_tiling.c | 901 ++++++++++++++++-------------- src/modules/tiling/e_mod_tiling.h | 60 +- src/modules/tiling/window_tree.c | 532 +++++++++--------- src/modules/tiling/window_tree.h | 38 +- 5 files changed, 897 insertions(+), 843 deletions(-) diff --git a/src/modules/tiling/e_mod_config.c b/src/modules/tiling/e_mod_config.c index 9fc7eeeb1..9a20076ae 100644 --- a/src/modules/tiling/e_mod_config.c +++ b/src/modules/tiling/e_mod_config.c @@ -6,9 +6,9 @@ typedef struct _E_Widget_Smart_Data E_Widget_Smart_Data; struct _E_Widget_Smart_Data { Evas_Object *parent_obj; - Evas_Coord x, y, w, h; - Evas_Coord minw, minh; - Eina_List *subobjs; + Evas_Coord x, y, w, h; + Evas_Coord minw, minh; + Eina_List *subobjs; }; static void @@ -33,20 +33,20 @@ _open_browser_help_cb(void *data EINA_UNUSED, void *obj EINA_UNUSED) e_widget_list_object_append(list, object, 1, 1, 0.5) struct _Config_vdesk * -get_vdesk(Eina_List * vdesks, int x, int y, unsigned int zone_num) +get_vdesk(Eina_List *vdesks, int x, int y, unsigned int zone_num) { Eina_List *l; for (l = vdesks; l; l = l->next) { - struct _Config_vdesk *vd = l->data; + struct _Config_vdesk *vd = l->data; - if (!vd) - continue; - if (vd->nb_stacks < 0 || vd->nb_stacks > 1) - vd->nb_stacks = 0; - if (vd->x == x && vd->y == y && vd->zone_num == zone_num) - return vd; + if (!vd) + continue; + if (vd->nb_stacks < 0 || vd->nb_stacks > 1) + vd->nb_stacks = 0; + if (vd->x == x && vd->y == y && vd->zone_num == zone_num) + return vd; } return NULL; @@ -57,7 +57,7 @@ get_vdesk(Eina_List * vdesks, int x, int y, unsigned int zone_num) * */ static void * -_create_data(E_Config_Dialog * cfd EINA_UNUSED) +_create_data(E_Config_Dialog *cfd EINA_UNUSED) { E_Config_Dialog_Data *cfdata; Eina_List *l; @@ -73,33 +73,33 @@ _create_data(E_Config_Dialog * cfd EINA_UNUSED) for (l = tiling_g.config->vdesks; l; l = l->next) { - struct _Config_vdesk *vd = l->data, *newvd; + struct _Config_vdesk *vd = l->data, *newvd; - if (!vd) - continue; + if (!vd) + continue; - newvd = E_NEW(struct _Config_vdesk, 1); + newvd = E_NEW(struct _Config_vdesk, 1); - newvd->x = vd->x; - newvd->y = vd->y; - newvd->zone_num = vd->zone_num; - newvd->nb_stacks = vd->nb_stacks; + newvd->x = vd->x; + newvd->y = vd->y; + newvd->zone_num = vd->zone_num; + newvd->nb_stacks = vd->nb_stacks; - EINA_LIST_APPEND(cfdata->config.vdesks, newvd); + EINA_LIST_APPEND(cfdata->config.vdesks, newvd); } return cfdata; } static void -_free_data(E_Config_Dialog * cfd EINA_UNUSED, E_Config_Dialog_Data * cfdata) +_free_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata) { eina_list_free(cfdata->config.vdesks); free(cfdata); } static void -_fill_zone_config(E_Zone * zone, E_Config_Dialog_Data * cfdata) +_fill_zone_config(E_Zone *zone, E_Config_Dialog_Data *cfdata) { Evas *evas; int i; @@ -113,33 +113,33 @@ _fill_zone_config(E_Zone * zone, E_Config_Dialog_Data * cfdata) for (i = 0; i < zone->desk_y_count * zone->desk_x_count; i++) { - E_Desk *desk = zone->desks[i]; - struct _Config_vdesk *vd; - Evas_Object *list, *checkbox; + E_Desk *desk = zone->desks[i]; + struct _Config_vdesk *vd; + Evas_Object *list, *checkbox; - if (!desk) - continue; + if (!desk) + continue; - vd = get_vdesk(cfdata->config.vdesks, desk->x, desk->y, zone->num); - if (!vd) - { - vd = E_NEW(struct _Config_vdesk, 1); + vd = get_vdesk(cfdata->config.vdesks, desk->x, desk->y, zone->num); + if (!vd) + { + vd = E_NEW(struct _Config_vdesk, 1); - vd->x = desk->x; - vd->y = desk->y; - vd->zone_num = zone->num; - vd->nb_stacks = 0; + vd->x = desk->x; + vd->y = desk->y; + vd->zone_num = zone->num; + vd->nb_stacks = 0; - EINA_LIST_APPEND(cfdata->config.vdesks, vd); - } + EINA_LIST_APPEND(cfdata->config.vdesks, vd); + } - list = e_widget_list_add(evas, false, true); + list = e_widget_list_add(evas, false, true); - LIST_ADD(list, e_widget_label_add(evas, desk->name)); - checkbox = e_widget_check_add(evas, "", &vd->nb_stacks); - LIST_ADD(list, checkbox); + LIST_ADD(list, e_widget_label_add(evas, desk->name)); + checkbox = e_widget_check_add(evas, "", &vd->nb_stacks); + LIST_ADD(list, checkbox); - LIST_ADD(cfdata->o_desklist, list); + LIST_ADD(cfdata->o_desklist, list); } /* Get the correct sizes of desklist and scrollframe */ @@ -147,25 +147,25 @@ _fill_zone_config(E_Zone * zone, E_Config_Dialog_Data * cfdata) } static void -_cb_zone_change(void *data, Evas_Object * obj EINA_UNUSED) +_cb_zone_change(void *data, Evas_Object *obj EINA_UNUSED) { int n; E_Config_Dialog_Data *cfdata = data; E_Zone *zone; if (!cfdata || !cfdata->o_zonelist) - return; + return; n = e_widget_ilist_selected_get(cfdata->o_zonelist); zone = e_widget_ilist_nth_data_get(cfdata->o_zonelist, n); if (!zone) - return; + return; _fill_zone_config(zone, cfdata); } static Evas_Object * -_basic_create_widgets(E_Config_Dialog * cfd EINA_UNUSED, Evas * evas, - E_Config_Dialog_Data * cfdata) +_basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, + E_Config_Dialog_Data *cfdata) { Evas_Object *o, *oc, *of, *slider; E_Comp *comp; @@ -179,11 +179,11 @@ _basic_create_widgets(E_Config_Dialog * cfd EINA_UNUSED, Evas * evas, /* General settings */ of = e_widget_framelist_add(evas, _("General"), 0); e_widget_framelist_object_append(of, e_widget_check_add(evas, - _("Show window titles"), &cfdata->config.show_titles)); + _("Show window titles"), &cfdata->config.show_titles)); e_widget_framelist_object_append(of, e_widget_check_add(evas, - _("Tile dialog windows"), &cfdata->config.tile_dialogs)); + _("Tile dialog windows"), &cfdata->config.tile_dialogs)); e_widget_framelist_object_append(of, e_widget_check_add(evas, - _("Enable floating split-mode"), &cfdata->config.have_floating_mode)); + _("Enable floating split-mode"), &cfdata->config.have_floating_mode)); LIST_ADD(o, of); @@ -200,10 +200,10 @@ _basic_create_widgets(E_Config_Dialog * cfd EINA_UNUSED, Evas * evas, e_widget_on_change_hook_set(cfdata->o_zonelist, _cb_zone_change, cfdata); for (l = comp->zones; l; l = l->next) { - if (!(zone = l->data)) - continue; - e_widget_ilist_append(cfdata->o_zonelist, NULL, zone->name, NULL, zone, - NULL); + if (!(zone = l->data)) + continue; + e_widget_ilist_append(cfdata->o_zonelist, NULL, zone->name, NULL, zone, + NULL); } e_widget_ilist_go(cfdata->o_zonelist); e_widget_ilist_thaw(cfdata->o_zonelist); @@ -222,21 +222,21 @@ _basic_create_widgets(E_Config_Dialog * cfd EINA_UNUSED, Evas * evas, LIST_ADD(o, of); of = e_widget_label_add(evas, _("Padding between windows")); - LIST_ADD(o,of); - slider = e_widget_slider_add(evas, 1,0, ("%1.0f px"), 0.0, TILING_MAX_PADDING, + LIST_ADD(o, of); + slider = e_widget_slider_add(evas, 1, 0, ("%1.0f px"), 0.0, TILING_MAX_PADDING, 1.0, 0, NULL, &cfdata->config.window_padding, 150); LIST_ADD(o, slider); oc = e_widget_button_add(evas, _("Help"), "help", _open_browser_help_cb, - NULL, NULL); + NULL, NULL); LIST_ADD(o, oc); return o; } static int -_basic_apply_data(E_Config_Dialog * cfd EINA_UNUSED, - E_Config_Dialog_Data * cfdata) +_basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, + E_Config_Dialog_Data *cfdata) { struct _Config_vdesk *vd; Eina_List *l; @@ -249,64 +249,64 @@ _basic_apply_data(E_Config_Dialog * cfd EINA_UNUSED, /* Check if the layout for one of the vdesks has changed */ for (l = tiling_g.config->vdesks; l; l = l->next) { - struct _Config_vdesk *newvd; + struct _Config_vdesk *newvd; - vd = l->data; + vd = l->data; - if (!vd) - continue; - if (!(newvd = - get_vdesk(cfdata->config.vdesks, vd->x, vd->y, vd->zone_num))) - { - change_desk_conf(vd); - continue; - } + if (!vd) + continue; + if (!(newvd = + get_vdesk(cfdata->config.vdesks, vd->x, vd->y, vd->zone_num))) + { + change_desk_conf(vd); + continue; + } - if (newvd->nb_stacks != vd->nb_stacks) - { - DBG("number of columns for (%d, %d, %d) changed from %d" " to %d", - vd->x, vd->y, vd->zone_num, vd->nb_stacks, newvd->nb_stacks); - change_desk_conf(newvd); - free(vd); - l->data = NULL; - } + if (newvd->nb_stacks != vd->nb_stacks) + { + DBG("number of columns for (%d, %d, %d) changed from %d" " to %d", + vd->x, vd->y, vd->zone_num, vd->nb_stacks, newvd->nb_stacks); + change_desk_conf(newvd); + free(vd); + l->data = NULL; + } } for (l = cfdata->config.vdesks; l; l = l->next) { - vd = l->data; + vd = l->data; - if (!vd) - continue; - if (!get_vdesk(tiling_g.config->vdesks, vd->x, vd->y, vd->zone_num)) - { - change_desk_conf(vd); - continue; - } + if (!vd) + continue; + if (!get_vdesk(tiling_g.config->vdesks, vd->x, vd->y, vd->zone_num)) + { + change_desk_conf(vd); + continue; + } } EINA_LIST_FREE(tiling_g.config->vdesks, vd) - { - free(vd); - } + { + free(vd); + } tiling_g.config->vdesks = NULL; for (l = cfdata->config.vdesks; l; l = l->next) { - struct _Config_vdesk *newvd; + struct _Config_vdesk *newvd; - vd = l->data; - if (!vd) - continue; + vd = l->data; + if (!vd) + continue; - newvd = E_NEW(struct _Config_vdesk, 1); + newvd = E_NEW(struct _Config_vdesk, 1); - newvd->x = vd->x; - newvd->y = vd->y; - newvd->zone_num = vd->zone_num; - newvd->nb_stacks = vd->nb_stacks; + newvd->x = vd->x; + newvd->y = vd->y; + newvd->zone_num = vd->zone_num; + newvd->nb_stacks = vd->nb_stacks; - EINA_LIST_APPEND(tiling_g.config->vdesks, newvd); + EINA_LIST_APPEND(tiling_g.config->vdesks, newvd); } e_tiling_update_conf(); @@ -317,14 +317,14 @@ _basic_apply_data(E_Config_Dialog * cfd EINA_UNUSED, } E_Config_Dialog * -e_int_config_tiling_module(E_Comp * comp, const char *params EINA_UNUSED) +e_int_config_tiling_module(E_Comp *comp, const char *params EINA_UNUSED) { E_Config_Dialog *cfd; E_Config_Dialog_View *v; char buf[PATH_MAX]; if (e_config_dialog_find("E", "windows/tiling")) - return NULL; + return NULL; v = E_NEW(E_Config_Dialog_View, 1); @@ -334,9 +334,10 @@ e_int_config_tiling_module(E_Comp * comp, const char *params EINA_UNUSED) v->basic.create_widgets = _basic_create_widgets; snprintf(buf, sizeof(buf), "%s/e-module-tiling.edj", - e_module_dir_get(tiling_g.module)); + e_module_dir_get(tiling_g.module)); cfd = - e_config_dialog_new(comp, _("Tiling Configuration"), "E", - "windows/tiling", buf, 0, v, NULL); + e_config_dialog_new(comp, _("Tiling Configuration"), "E", + "windows/tiling", buf, 0, v, NULL); return cfd; } + diff --git a/src/modules/tiling/e_mod_tiling.c b/src/modules/tiling/e_mod_tiling.c index ec47f554f..75b6d4698 100644 --- a/src/modules/tiling/e_mod_tiling.c +++ b/src/modules/tiling/e_mod_tiling.c @@ -3,8 +3,8 @@ /* types {{{ */ #define TILING_OVERLAY_TIMEOUT 5.0 -#define TILING_RESIZE_STEP 5 -#define TILING_WRAP_SPEED 0.1 +#define TILING_RESIZE_STEP 5 +#define TILING_WRAP_SPEED 0.1 typedef struct geom_t { @@ -14,25 +14,25 @@ typedef struct geom_t typedef struct Client_Extra { E_Client *client; - geom_t expected; + geom_t expected; struct { - geom_t geom; - E_Maximize maximized; + geom_t geom; + E_Maximize maximized; const char *bordername; } orig; - int last_frame_adjustment; // FIXME: Hack for frame resize bug. - Eina_Bool floating:1; - Eina_Bool tiled:1; + int last_frame_adjustment; // FIXME: Hack for frame resize bug. + Eina_Bool floating : 1; + Eina_Bool tiled : 1; } Client_Extra; typedef struct _Instance { - E_Gadcon_Client *gcc; - Evas_Object *gadget; + E_Gadcon_Client *gcc; + Evas_Object *gadget; Eina_Stringshare *gad_id; - E_Menu *lmenu; + E_Menu *lmenu; } Instance; struct tiling_g tiling_g = { @@ -41,59 +41,61 @@ struct tiling_g tiling_g = { .log_domain = -1, }; -static void _add_client(E_Client * ec); -static void _remove_client(E_Client * ec); -static void _foreach_desk(void (*func) (E_Desk * desk)); +static void _add_client(E_Client *ec); +static void _remove_client(E_Client *ec); +static void _foreach_desk(void (*func)(E_Desk *desk)); /* Func Proto Requirements for Gadcon */ static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style); -static void _gc_shutdown(E_Gadcon_Client *gcc); -static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient); +static void _gc_shutdown(E_Gadcon_Client *gcc); +static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient); static void _tiling_cb_menu_configure(void *data EINA_UNUSED, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED) { // FIXME here need to be some checks and return ? e_int_config_tiling_module(NULL, NULL); } -static const char *_gc_label(const E_Gadcon_Client_Class *client_class EINA_UNUSED); -static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas); -static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED); -static void _gadget_icon_set(Instance *inst); +static const char *_gc_label(const E_Gadcon_Client_Class *client_class EINA_UNUSED); +static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas); +static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED); + +static void _gadget_icon_set(Instance *inst); /* }}} */ /* Globals {{{ */ static struct tiling_mod_main_g { - char edj_path[PATH_MAX]; - E_Config_DD *config_edd, *vdesk_edd; - int currently_switching_desktop; + char edj_path[PATH_MAX]; + E_Config_DD *config_edd, *vdesk_edd; + int currently_switching_desktop; Ecore_Event_Handler *handler_client_resize, *handler_client_move, - *handler_client_add, *handler_client_remove, *handler_client_iconify, - *handler_client_uniconify, *handler_client_stick, - *handler_client_unstick, *handler_desk_show, *handler_desk_before_show, - *handler_desk_set, *handler_compositor_resize; - E_Client_Menu_Hook *client_menu_hook; + *handler_client_add, *handler_client_remove, *handler_client_iconify, + *handler_client_uniconify, *handler_client_stick, + *handler_client_unstick, *handler_desk_show, *handler_desk_before_show, + *handler_desk_set, *handler_compositor_resize; + E_Client_Menu_Hook *client_menu_hook; - Tiling_Info *tinfo; - Eina_Hash *info_hash; - Eina_Hash *client_extras; + Tiling_Info *tinfo; + Eina_Hash *info_hash; + Eina_Hash *client_extras; - E_Action *act_togglefloat, *act_move_up, *act_move_down, *act_move_left, - *act_move_right, *act_toggle_split_mode, *act_swap_window; + E_Action *act_togglefloat, *act_move_up, *act_move_down, *act_move_left, + *act_move_right, *act_toggle_split_mode, *act_swap_window; - Tiling_Split_Type split_type; + Tiling_Split_Type split_type; } _G = { -.split_type = TILING_SPLIT_HORIZONTAL,}; + .split_type = TILING_SPLIT_HORIZONTAL, +}; /* Define the class and gadcon functions this module provides */ static const E_Gadcon_Client_Class _gc_class = { GADCON_CLIENT_CLASS_VERSION, "tiling", { _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, - NULL, NULL }, + NULL, NULL }, E_GADCON_CLIENT_STYLE_PLAIN }; @@ -112,7 +114,7 @@ get_current_desk(void) } static Tiling_Info * -_initialize_tinfo(const E_Desk * desk) +_initialize_tinfo(const E_Desk *desk) { Tiling_Info *tinfo; @@ -121,76 +123,76 @@ _initialize_tinfo(const E_Desk * desk) eina_hash_direct_add(_G.info_hash, &tinfo->desk, tinfo); tinfo->conf = - get_vdesk(tiling_g.config->vdesks, desk->x, desk->y, desk->zone->num); + get_vdesk(tiling_g.config->vdesks, desk->x, desk->y, desk->zone->num); return tinfo; } static void -check_tinfo(const E_Desk * desk) +check_tinfo(const E_Desk *desk) { if (!_G.tinfo || _G.tinfo->desk != desk) { - _G.tinfo = eina_hash_find(_G.info_hash, &desk); - if (!_G.tinfo) - { - /* lazy init */ - _G.tinfo = _initialize_tinfo(desk); - } - if (!_G.tinfo->conf) - { - _G.tinfo->conf = - get_vdesk(tiling_g.config->vdesks, desk->x, desk->y, - desk->zone->num); - } + _G.tinfo = eina_hash_find(_G.info_hash, &desk); + if (!_G.tinfo) + { + /* lazy init */ + _G.tinfo = _initialize_tinfo(desk); + } + if (!_G.tinfo->conf) + { + _G.tinfo->conf = + get_vdesk(tiling_g.config->vdesks, desk->x, desk->y, + desk->zone->num); + } } } static Eina_Bool -desk_should_tile_check(const E_Desk * desk) +desk_should_tile_check(const E_Desk *desk) { check_tinfo(desk); - return (_G.tinfo && _G.tinfo->conf && _G.tinfo->conf->nb_stacks); + return _G.tinfo && _G.tinfo->conf && _G.tinfo->conf->nb_stacks; } static int -is_ignored_window(const Client_Extra * extra) +is_ignored_window(const Client_Extra *extra) { if (extra->client->sticky || extra->floating) - return true; + return true; return false; } static int -is_tilable(const E_Client * ec) +is_tilable(const E_Client *ec) { if (ec->icccm.min_h == ec->icccm.max_h && ec->icccm.max_h > 0) - return false; + return false; if (ec->icccm.gravity == ECORE_X_GRAVITY_STATIC) - return false; + return false; if (ec->e.state.centered) - return false; + return false; if (!tiling_g.config->tile_dialogs && ((ec->icccm.transient_for != 0) || - (ec->netwm.type == E_WINDOW_TYPE_DIALOG))) - return false; + (ec->netwm.type == E_WINDOW_TYPE_DIALOG))) + return false; if (ec->fullscreen) { - return false; + return false; } if (e_client_util_ignored_get(ec)) - return false; + return false; return true; } static void -change_window_border(E_Client * ec, const char *bordername) +change_window_border(E_Client *ec, const char *bordername) { eina_stringshare_replace(&ec->bordername, bordername); ec->border.changed = true; @@ -201,19 +203,20 @@ change_window_border(E_Client * ec, const char *bordername) } static Eina_Bool -_info_hash_update(const Eina_Hash * hash EINA_UNUSED, - const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED) +_info_hash_update(const Eina_Hash *hash EINA_UNUSED, + const void *key EINA_UNUSED, void *data, void *fdata EINA_UNUSED) { Tiling_Info *tinfo = data; if (tinfo->desk) { - tinfo->conf = - get_vdesk(tiling_g.config->vdesks, tinfo->desk->x, tinfo->desk->y, - tinfo->desk->zone->num); - } else + tinfo->conf = + get_vdesk(tiling_g.config->vdesks, tinfo->desk->x, tinfo->desk->y, + tinfo->desk->zone->num); + } + else { - tinfo->conf = NULL; + tinfo->conf = NULL; } return true; @@ -226,25 +229,25 @@ e_tiling_update_conf(void) } static void -_e_client_move_resize(E_Client * ec, int x, int y, int w, int h) +_e_client_move_resize(E_Client *ec, int x, int y, int w, int h) { Client_Extra *extra; extra = eina_hash_find(_G.client_extras, &ec); if (!extra) { - ERR("No extra for %p", ec); - return; + ERR("No extra for %p", ec); + return; } extra->last_frame_adjustment = - MAX(ec->h - ec->client.h, ec->w - ec->client.w); + MAX(ec->h - ec->client.h, ec->w - ec->client.w); DBG("%p -> %dx%d+%d+%d", ec, w, h, x, y); evas_object_geometry_set(ec->frame, x, y, w, h); } static void -_e_client_unmaximize(E_Client * ec, E_Maximize max) +_e_client_unmaximize(E_Client *ec, E_Maximize max) { DBG("%p -> %s", ec, (max & E_MAXIMIZE_DIRECTION) == @@ -255,99 +258,109 @@ _e_client_unmaximize(E_Client * ec, E_Maximize max) } static void -_restore_client(E_Client * ec) +_restore_client(E_Client *ec) { Client_Extra *extra; extra = eina_hash_find(_G.client_extras, &ec); if (!extra) { - ERR("No extra for %p", ec); - return; + ERR("No extra for %p", ec); + return; } _e_client_move_resize(ec, extra->orig.geom.x, extra->orig.geom.y, - extra->orig.geom.w, extra->orig.geom.h); + extra->orig.geom.w, extra->orig.geom.h); if (extra->orig.maximized) { - e_client_maximize(ec, extra->orig.maximized); - ec->maximized = extra->orig.maximized; + e_client_maximize(ec, extra->orig.maximized); + ec->maximized = extra->orig.maximized; } DBG("Change window border back to %s for %p", extra->orig.bordername, ec); change_window_border(ec, - (extra->orig.bordername) ? extra->orig.bordername : "default"); + (extra->orig.bordername) ? extra->orig.bordername : "default"); } static Client_Extra * -_get_or_create_client_extra(E_Client * ec) +_get_or_create_client_extra(E_Client *ec) { Client_Extra *extra; extra = eina_hash_find(_G.client_extras, &ec); if (!extra) { - extra = E_NEW(Client_Extra, 1); - *extra = (Client_Extra) - { - .client = ec,.expected = - { - .x = ec->x,.y = ec->y,.w = ec->w,.h = ec->h,} - ,.orig = - { - .geom = - { - .x = ec->x,.y = ec->y,.w = ec->w,.h = ec->h,} - ,.maximized = ec->maximized,.bordername = - eina_stringshare_add(ec->bordername),} - ,}; - eina_hash_direct_add(_G.client_extras, &extra->client, extra); - } else + extra = E_NEW(Client_Extra, 1); + *extra = (Client_Extra) + { + .client = ec, .expected = + { + .x = ec->x, .y = ec->y, .w = ec->w, .h = ec->h, + } + + , .orig = + { + .geom = + { + .x = ec->x, .y = ec->y, .w = ec->w, .h = ec->h, + } + + , .maximized = ec->maximized, .bordername = + eina_stringshare_add(ec->bordername), + } + + , + }; + eina_hash_direct_add(_G.client_extras, &extra->client, extra); + } + else { - extra->expected = (geom_t) - { - .x = ec->x,.y = ec->y,.w = ec->w,.h = ec->h,}; - extra->orig.geom = extra->expected; - extra->orig.maximized = ec->maximized; - eina_stringshare_replace(&extra->orig.bordername, ec->bordername); + extra->expected = (geom_t) + { + .x = ec->x, .y = ec->y, .w = ec->w, .h = ec->h, + }; + extra->orig.geom = extra->expected; + extra->orig.maximized = ec->maximized; + eina_stringshare_replace(&extra->orig.bordername, ec->bordername); } return extra; } void -tiling_e_client_move_resize_extra(E_Client * ec, int x, int y, int w, int h) +tiling_e_client_move_resize_extra(E_Client *ec, int x, int y, int w, int h) { Client_Extra *extra = eina_hash_find(_G.client_extras, &ec); if (!extra) { - ERR("No extra for %p", ec); - return; + ERR("No extra for %p", ec); + return; } extra->expected = (geom_t) { - .x = x,.y = y,.w = w,.h = h,}; + .x = x, .y = y, .w = w, .h = h, + }; _e_client_move_resize(ec, x, y, w, h); } static Client_Extra * -tiling_entry_func(E_Client * ec) +tiling_entry_func(E_Client *ec) { if (!ec) - return NULL; + return NULL; if (!is_tilable(ec)) - return NULL; + return NULL; if (!desk_should_tile_check(ec->desk)) - return NULL; + return NULL; Client_Extra *extra = eina_hash_find(_G.client_extras, &ec); if (!extra) - ERR("No extra for %p", ec); + ERR("No extra for %p", ec); return extra; } @@ -362,10 +375,10 @@ _reapply_tree(void) if (_G.tinfo->tree) { - e_zone_useful_geometry_get(_G.tinfo->desk->zone, &zx, &zy, &zw, &zh); + e_zone_useful_geometry_get(_G.tinfo->desk->zone, &zx, &zy, &zw, &zh); - tiling_window_tree_apply(_G.tinfo->tree, zx, zy, zw, zh, - tiling_g.config->window_padding); + tiling_window_tree_apply(_G.tinfo->tree, zx, zy, zw, zh, + tiling_g.config->window_padding); } } @@ -376,7 +389,7 @@ _restore_free_client(void *_item) if (item->client) { - _restore_client(item->client); + _restore_client(item->client); } free(item); } @@ -392,34 +405,35 @@ change_desk_conf(struct _Config_vdesk *newconf) m = e_manager_current_get(); if (!m) - return; + return; c = m->comp; z = e_comp_zone_number_get(c, newconf->zone_num); if (!z) - return; + return; d = e_desk_at_xy_get(z, newconf->x, newconf->y); if (!d) - return; + return; check_tinfo(d); if (_G.tinfo->conf) { - old_nb_stacks = _G.tinfo->conf->nb_stacks; - } else + old_nb_stacks = _G.tinfo->conf->nb_stacks; + } + else { - newconf->nb_stacks = 0; + newconf->nb_stacks = 0; } _G.tinfo->conf = newconf; _G.tinfo->conf->nb_stacks = old_nb_stacks; if (new_nb_stacks == old_nb_stacks) - return; + return; if (new_nb_stacks == 0) { - tiling_window_tree_walk(_G.tinfo->tree, _restore_free_client); - _G.tinfo->tree = NULL; - e_place_zone_region_smart_cleanup(z); + tiling_window_tree_walk(_G.tinfo->tree, _restore_free_client); + _G.tinfo->tree = NULL; + e_place_zone_region_smart_cleanup(z); } _G.tinfo->conf->nb_stacks = new_nb_stacks; } @@ -428,45 +442,45 @@ change_desk_conf(struct _Config_vdesk *newconf) /* Reorganize windows {{{ */ static void -_add_client(E_Client * ec) +_add_client(E_Client *ec) { /* Should I need to check that the client is not already added? */ if (!ec) { - return; + return; } if (!is_tilable(ec)) { - return; + return; } if (!desk_should_tile_check(ec->desk)) - return; + return; Client_Extra *extra = _get_or_create_client_extra(ec); if (is_ignored_window(extra)) - return; + return; if (_G.split_type == TILING_SPLIT_FLOAT) { - extra->floating = EINA_TRUE; - return; + extra->floating = EINA_TRUE; + return; } if (extra->tiled) - return; + return; extra->tiled = EINA_TRUE; DBG("adding %p", ec); if (ec->maximized) - _e_client_unmaximize(ec, E_MAXIMIZE_BOTH); + _e_client_unmaximize(ec, E_MAXIMIZE_BOTH); if (!tiling_g.config->show_titles && (!ec->bordername || - strcmp(ec->bordername, "pixel"))) - change_window_border(ec, "pixel"); + strcmp(ec->bordername, "pixel"))) + change_window_border(ec, "pixel"); /* Window tree updating. */ { @@ -474,31 +488,31 @@ _add_client(E_Client * ec) /* If focused is NULL, it should return the root. */ Window_Tree *parent = tiling_window_tree_client_find(_G.tinfo->tree, - ec_focused); + ec_focused); if (!parent && (ec_focused != ec)) - { - Client_Extra *extra_focused = - eina_hash_find(_G.client_extras, &ec_focused); - if (_G.tinfo->tree && extra_focused && - !is_ignored_window(extra_focused)) - { - ERR("Couldn't find tree item for focused client %p. Using root..", e_client_focused_get()); - } - } + { + Client_Extra *extra_focused = + eina_hash_find(_G.client_extras, &ec_focused); + if (_G.tinfo->tree && extra_focused && + !is_ignored_window(extra_focused)) + { + ERR("Couldn't find tree item for focused client %p. Using root..", e_client_focused_get()); + } + } _G.tinfo->tree = - tiling_window_tree_add(_G.tinfo->tree, parent, ec, _G.split_type); + tiling_window_tree_add(_G.tinfo->tree, parent, ec, _G.split_type); } _reapply_tree(); } static void -_remove_client(E_Client * ec) +_remove_client(E_Client *ec) { if (!ec) - return; + return; DBG("removing %p", ec); @@ -506,15 +520,15 @@ _remove_client(E_Client * ec) if (!extra) { - if (is_tilable(ec)) - { - ERR("No extra for %p", ec); - } - return; + if (is_tilable(ec)) + { + ERR("No extra for %p", ec); + } + return; } if (!extra->tiled) - return; + return; extra->tiled = EINA_FALSE; @@ -524,10 +538,10 @@ _remove_client(E_Client * ec) Window_Tree *item = tiling_window_tree_client_find(_G.tinfo->tree, ec); if (!item) - { - ERR("Couldn't find tree item for client %p!", ec); - return; - } + { + ERR("Couldn't find tree item for client %p!", ec); + return; + } _G.tinfo->tree = tiling_window_tree_remove(_G.tinfo->tree, item); } @@ -539,13 +553,13 @@ _remove_client(E_Client * ec) /* Toggle Floating {{{ */ static void -toggle_floating(E_Client * ec) +toggle_floating(E_Client *ec) { Client_Extra *extra = tiling_entry_func(ec); if (!extra) { - return; + return; } extra->floating = !extra->floating; @@ -553,17 +567,18 @@ toggle_floating(E_Client * ec) /* This is the new state, act accordingly. */ if (extra->floating) { - _restore_client(ec); - _remove_client(ec); - } else + _restore_client(ec); + _remove_client(ec); + } + else { - _add_client(ec); + _add_client(ec); } } static void -_e_mod_action_toggle_floating_cb(E_Object * obj EINA_UNUSED, - const char *params EINA_UNUSED) +_e_mod_action_toggle_floating_cb(E_Object *obj EINA_UNUSED, + const char *params EINA_UNUSED) { toggle_floating(e_client_focused_get()); } @@ -571,27 +586,27 @@ _e_mod_action_toggle_floating_cb(E_Object * obj EINA_UNUSED, static E_Client *_go_mouse_client = NULL; static void -_e_mod_action_swap_window_go_mouse(E_Object * obj EINA_UNUSED, - const char *params EINA_UNUSED, - E_Binding_Event_Mouse_Button * ev EINA_UNUSED) +_e_mod_action_swap_window_go_mouse(E_Object *obj EINA_UNUSED, + const char *params EINA_UNUSED, + E_Binding_Event_Mouse_Button *ev EINA_UNUSED) { E_Client *ec = e_client_under_pointer_get(get_current_desk(), NULL); Client_Extra *extra = tiling_entry_func(ec); if (!extra) - return; + return; if (is_ignored_window(extra)) - return; + return; _go_mouse_client = ec; } static void -_e_mod_action_swap_window_end_mouse(E_Object * obj EINA_UNUSED, - const char *params EINA_UNUSED, - E_Binding_Event_Mouse_Button * ev EINA_UNUSED) +_e_mod_action_swap_window_end_mouse(E_Object *obj EINA_UNUSED, + const char *params EINA_UNUSED, + E_Binding_Event_Mouse_Button *ev EINA_UNUSED) { E_Client *ec = e_client_under_pointer_get(get_current_desk(), NULL); E_Client *first_ec = _go_mouse_client; @@ -599,31 +614,31 @@ _e_mod_action_swap_window_end_mouse(E_Object * obj EINA_UNUSED, _go_mouse_client = NULL; if (!first_ec) - return; + return; Client_Extra *extra = tiling_entry_func(ec); if (!extra) - return; + return; if (is_ignored_window(extra)) - return; + return; /* XXX: Only support swap on the first desk for now. */ if (ec->desk != first_ec->desk) - return; + return; Window_Tree *item, *first_item; item = tiling_window_tree_client_find(_G.tinfo->tree, ec); if (!item) - return; + return; first_item = tiling_window_tree_client_find(_G.tinfo->tree, first_ec); if (!first_item) - return; + return; item->client = first_ec; first_item->client = ec; @@ -632,8 +647,8 @@ _e_mod_action_swap_window_end_mouse(E_Object * obj EINA_UNUSED, } static void -_e_mod_menu_border_cb(void *data, E_Menu * m EINA_UNUSED, - E_Menu_Item * mi EINA_UNUSED) +_e_mod_menu_border_cb(void *data, E_Menu *m EINA_UNUSED, + E_Menu_Item *mi EINA_UNUSED) { E_Client *ec = data; @@ -651,50 +666,50 @@ _action_swap(int cross_edge) desk = get_current_desk(); if (!desk) - return; + return; focused_ec = e_client_focused_get(); if (!focused_ec || focused_ec->desk != desk) - return; + return; if (!desk_should_tile_check(desk)) - return; + return; Window_Tree *item = - tiling_window_tree_client_find(_G.tinfo->tree, focused_ec); + tiling_window_tree_client_find(_G.tinfo->tree, focused_ec); if (item) { - tiling_window_tree_node_move(item, cross_edge); + tiling_window_tree_node_move(item, cross_edge); - _reapply_tree(); + _reapply_tree(); } } static void -_e_mod_action_move_left_cb(E_Object * obj EINA_UNUSED, - const char *params EINA_UNUSED) +_e_mod_action_move_left_cb(E_Object *obj EINA_UNUSED, + const char *params EINA_UNUSED) { _action_swap(TILING_WINDOW_TREE_EDGE_LEFT); } static void -_e_mod_action_move_right_cb(E_Object * obj EINA_UNUSED, - const char *params EINA_UNUSED) +_e_mod_action_move_right_cb(E_Object *obj EINA_UNUSED, + const char *params EINA_UNUSED) { _action_swap(TILING_WINDOW_TREE_EDGE_RIGHT); } static void -_e_mod_action_move_up_cb(E_Object * obj EINA_UNUSED, - const char *params EINA_UNUSED) +_e_mod_action_move_up_cb(E_Object *obj EINA_UNUSED, + const char *params EINA_UNUSED) { _action_swap(TILING_WINDOW_TREE_EDGE_TOP); } static void -_e_mod_action_move_down_cb(E_Object * obj EINA_UNUSED, - const char *params EINA_UNUSED) +_e_mod_action_move_down_cb(E_Object *obj EINA_UNUSED, + const char *params EINA_UNUSED) { _action_swap(TILING_WINDOW_TREE_EDGE_BOTTOM); } @@ -711,7 +726,7 @@ _tiling_split_type_next(void) /* If we don't allow floating, skip it. */ if (!tiling_g.config->have_floating_mode && - (_G.split_type == TILING_SPLIT_FLOAT)) + (_G.split_type == TILING_SPLIT_FLOAT)) { _G.split_type = (_G.split_type + 1) % TILING_SPLIT_LAST; } @@ -723,17 +738,17 @@ _tiling_split_type_next(void) } static void -_e_mod_action_toggle_split_mode(E_Object * obj EINA_UNUSED, - const char *params EINA_UNUSED) +_e_mod_action_toggle_split_mode(E_Object *obj EINA_UNUSED, + const char *params EINA_UNUSED) { E_Desk *desk; desk = get_current_desk(); if (!desk) - return; + return; if (!desk_should_tile_check(desk)) - return; + return; _tiling_split_type_next(); } @@ -742,39 +757,38 @@ _e_mod_action_toggle_split_mode(E_Object * obj EINA_UNUSED, /* Hooks {{{ */ static void -_move_or_resize(E_Client * ec) +_move_or_resize(E_Client *ec) { Client_Extra *extra = tiling_entry_func(ec); if (!extra) { - return; + return; } if (is_ignored_window(extra)) - return; + return; if ((ec->x == extra->expected.x) && (ec->y == extra->expected.y) && (ec->w == extra->expected.w) && (ec->h == extra->expected.h)) { - - return; + return; } if (!extra->last_frame_adjustment) { - printf - ("This is probably because of the frame adjustment bug. Return\n"); - _reapply_tree(); - return; + printf + ("This is probably because of the frame adjustment bug. Return\n"); + _reapply_tree(); + return; } Window_Tree *item = tiling_window_tree_client_find(_G.tinfo->tree, ec); if (!item) { - ERR("Couldn't find tree item for resized client %p!", ec); - return; + ERR("Couldn't find tree item for resized client %p!", ec); + return; } { @@ -782,142 +796,157 @@ _move_or_resize(E_Client * ec) double w_diff = 1.0, h_diff = 1.0; if (abs(extra->expected.w - ec->w) >= 1) - { - w_diff = ((double) ec->w) / extra->expected.w; - } + { + w_diff = ((double)ec->w) / extra->expected.w; + } if (abs(extra->expected.h - ec->h) >= 1) - { - h_diff = ((double) ec->h) / extra->expected.h; - } + { + h_diff = ((double)ec->h) / extra->expected.h; + } switch (ec->resize_mode) - { - case E_POINTER_RESIZE_L: - case E_POINTER_RESIZE_BL: - w_dir = -1; - break; - case E_POINTER_RESIZE_T: - case E_POINTER_RESIZE_TR: - h_dir = -1; - break; - case E_POINTER_RESIZE_TL: - w_dir = -1; - h_dir = -1; - break; - default: - break; - } + { + case E_POINTER_RESIZE_L: + case E_POINTER_RESIZE_BL: + w_dir = -1; + break; + + case E_POINTER_RESIZE_T: + case E_POINTER_RESIZE_TR: + h_dir = -1; + break; + + case E_POINTER_RESIZE_TL: + w_dir = -1; + h_dir = -1; + break; + + default: + break; + } if ((w_diff != 1.0) || (h_diff != 1.0)) - { - if (!tiling_window_tree_node_resize(item, w_dir, w_diff, h_dir, - h_diff)) - { - /* FIXME: Do something? */ - } - } + { + if (!tiling_window_tree_node_resize(item, w_dir, w_diff, h_dir, + h_diff)) + { + /* FIXME: Do something? */ + } + } } _reapply_tree(); } static void -_resize_begin_hook(void *data EINA_UNUSED, E_Client * ec) +_resize_begin_hook(void *data EINA_UNUSED, E_Client *ec) { Client_Extra *extra = tiling_entry_func(ec); if (!extra) { - return; + return; } if (is_ignored_window(extra)) - return; + return; Window_Tree *item = tiling_window_tree_client_find(_G.tinfo->tree, ec); if (!item) { - ERR("Couldn't find tree item for resized client %p!", ec); - return; + ERR("Couldn't find tree item for resized client %p!", ec); + return; } int edges = tiling_window_tree_edges_get(item); if (edges & TILING_WINDOW_TREE_EDGE_LEFT) { - switch (ec->resize_mode) - { - case E_POINTER_RESIZE_L: - ec->resize_mode = E_POINTER_RESIZE_NONE; - break; - case E_POINTER_RESIZE_TL: - ec->resize_mode = E_POINTER_RESIZE_T; - break; - case E_POINTER_RESIZE_BL: - ec->resize_mode = E_POINTER_RESIZE_B; - break; - default: - break; - } + switch (ec->resize_mode) + { + case E_POINTER_RESIZE_L: + ec->resize_mode = E_POINTER_RESIZE_NONE; + break; + + case E_POINTER_RESIZE_TL: + ec->resize_mode = E_POINTER_RESIZE_T; + break; + + case E_POINTER_RESIZE_BL: + ec->resize_mode = E_POINTER_RESIZE_B; + break; + + default: + break; + } } if (edges & TILING_WINDOW_TREE_EDGE_RIGHT) { - switch (ec->resize_mode) - { - case E_POINTER_RESIZE_R: - ec->resize_mode = E_POINTER_RESIZE_NONE; - break; - case E_POINTER_RESIZE_TR: - ec->resize_mode = E_POINTER_RESIZE_T; - break; - case E_POINTER_RESIZE_BR: - ec->resize_mode = E_POINTER_RESIZE_B; - break; - default: - break; - } + switch (ec->resize_mode) + { + case E_POINTER_RESIZE_R: + ec->resize_mode = E_POINTER_RESIZE_NONE; + break; + + case E_POINTER_RESIZE_TR: + ec->resize_mode = E_POINTER_RESIZE_T; + break; + + case E_POINTER_RESIZE_BR: + ec->resize_mode = E_POINTER_RESIZE_B; + break; + + default: + break; + } } if (edges & TILING_WINDOW_TREE_EDGE_TOP) { - switch (ec->resize_mode) - { - case E_POINTER_RESIZE_T: - ec->resize_mode = E_POINTER_RESIZE_NONE; - break; - case E_POINTER_RESIZE_TL: - ec->resize_mode = E_POINTER_RESIZE_L; - break; - case E_POINTER_RESIZE_TR: - ec->resize_mode = E_POINTER_RESIZE_R; - break; - default: - break; - } + switch (ec->resize_mode) + { + case E_POINTER_RESIZE_T: + ec->resize_mode = E_POINTER_RESIZE_NONE; + break; + + case E_POINTER_RESIZE_TL: + ec->resize_mode = E_POINTER_RESIZE_L; + break; + + case E_POINTER_RESIZE_TR: + ec->resize_mode = E_POINTER_RESIZE_R; + break; + + default: + break; + } } if (edges & TILING_WINDOW_TREE_EDGE_BOTTOM) { - switch (ec->resize_mode) - { - case E_POINTER_RESIZE_B: - ec->resize_mode = E_POINTER_RESIZE_NONE; - break; - case E_POINTER_RESIZE_BL: - ec->resize_mode = E_POINTER_RESIZE_L; - break; - case E_POINTER_RESIZE_BR: - ec->resize_mode = E_POINTER_RESIZE_R; - break; - default: - break; - } + switch (ec->resize_mode) + { + case E_POINTER_RESIZE_B: + ec->resize_mode = E_POINTER_RESIZE_NONE; + break; + + case E_POINTER_RESIZE_BL: + ec->resize_mode = E_POINTER_RESIZE_L; + break; + + case E_POINTER_RESIZE_BR: + ec->resize_mode = E_POINTER_RESIZE_R; + break; + + default: + break; + } } if (!e_client_util_resizing_get(ec)) - e_client_resize_cancel(); + e_client_resize_cancel(); } static Eina_Bool _resize_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client * event) + E_Event_Client *event) { E_Client *ec = event->ec; @@ -927,18 +956,18 @@ _resize_hook(void *data EINA_UNUSED, int type EINA_UNUSED, } static Eina_Bool -_move_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client * event) +_move_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client *event) { E_Client *ec = event->ec; Client_Extra *extra = tiling_entry_func(ec); if (!extra) { - return true; + return true; } if (is_ignored_window(extra)) - return true; + return true; e_client_act_move_end(event->ec, NULL); @@ -948,7 +977,7 @@ _move_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client * event) } static Eina_Bool -_add_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client * event) +_add_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client *event) { E_Client *ec = event->ec; @@ -959,18 +988,18 @@ _add_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client * event) static Eina_Bool _remove_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client * event) + E_Event_Client *event) { E_Client *ec = event->ec; if (e_client_util_ignored_get(ec)) - return ECORE_CALLBACK_RENEW; + return ECORE_CALLBACK_RENEW; if (_G.currently_switching_desktop) - return true; + return true; if (!desk_should_tile_check(ec->desk)) - return true; + return true; _remove_client(ec); @@ -981,14 +1010,14 @@ _remove_hook(void *data EINA_UNUSED, int type EINA_UNUSED, static bool _iconify_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client * event) + E_Event_Client *event) { E_Client *ec = event->ec; DBG("iconify hook: %p", ec); if (ec->deskshow) - return true; + return true; _remove_client(ec); @@ -997,12 +1026,12 @@ _iconify_hook(void *data EINA_UNUSED, int type EINA_UNUSED, static bool _uniconify_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client * event) + E_Event_Client *event) { E_Client *ec = event->ec; if (ec->deskshow) - return true; + return true; _add_client(ec); @@ -1010,29 +1039,30 @@ _uniconify_hook(void *data EINA_UNUSED, int type EINA_UNUSED, } static void -toggle_sticky(E_Client * ec) +toggle_sticky(E_Client *ec) { Client_Extra *extra = tiling_entry_func(ec); if (!extra) { - return; + return; } /* This is the new state, act accordingly. */ if (ec->sticky) { - _restore_client(ec); - _remove_client(ec); - } else + _restore_client(ec); + _remove_client(ec); + } + else { - _add_client(ec); + _add_client(ec); } } static Eina_Bool _stick_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client * event) + E_Event_Client *event) { toggle_sticky(event->ec); return true; @@ -1040,7 +1070,7 @@ _stick_hook(void *data EINA_UNUSED, int type EINA_UNUSED, static Eina_Bool _unstick_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client * event) + E_Event_Client *event) { toggle_sticky(event->ec); return true; @@ -1048,7 +1078,7 @@ _unstick_hook(void *data EINA_UNUSED, int type EINA_UNUSED, static Eina_Bool _desk_show_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - void *event EINA_UNUSED) + void *event EINA_UNUSED) { _G.currently_switching_desktop = 0; @@ -1057,7 +1087,7 @@ _desk_show_hook(void *data EINA_UNUSED, int type EINA_UNUSED, static Eina_Bool _desk_before_show_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - void *event EINA_UNUSED) + void *event EINA_UNUSED) { _G.currently_switching_desktop = 1; @@ -1066,22 +1096,22 @@ _desk_before_show_hook(void *data EINA_UNUSED, int type EINA_UNUSED, static bool _desk_set_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client_Desk_Set * ev) + E_Event_Client_Desk_Set *ev) { DBG("%p: from (%d,%d) to (%d,%d)", ev->ec, ev->desk->x, ev->desk->y, ev->ec->desk->x, ev->ec->desk->y); if (desk_should_tile_check(ev->desk)) { - if (tiling_window_tree_client_find(_G.tinfo->tree, ev->ec)) - { - _restore_client(ev->ec); - _remove_client(ev->ec); - } + if (tiling_window_tree_client_find(_G.tinfo->tree, ev->ec)) + { + _restore_client(ev->ec); + _remove_client(ev->ec); + } } if (!desk_should_tile_check(ev->ec->desk)) - return true; + return true; _add_client(ev->ec); @@ -1089,18 +1119,18 @@ _desk_set_hook(void *data EINA_UNUSED, int type EINA_UNUSED, } static void -_compositor_resize_hook_desk_reapply(E_Desk * desk) +_compositor_resize_hook_desk_reapply(E_Desk *desk) { check_tinfo(desk); if (!desk_should_tile_check(desk)) - return; + return; _reapply_tree(); } static bool _compositor_resize_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Compositor_Resize * ev EINA_UNUSED) + E_Event_Compositor_Resize *ev EINA_UNUSED) { _foreach_desk(_compositor_resize_hook_desk_reapply); @@ -1108,32 +1138,33 @@ _compositor_resize_hook(void *data EINA_UNUSED, int type EINA_UNUSED, } static void -_bd_hook(void *d EINA_UNUSED, E_Client * ec) +_bd_hook(void *d EINA_UNUSED, E_Client *ec) { E_Menu_Item *mi; E_Menu *m; Eina_List *l; if (!ec->border_menu) - return; + return; m = ec->border_menu; Client_Extra *extra = eina_hash_find(_G.client_extras, &ec); if (!extra) { - return; + return; } /* position menu item just before the last separator */ - EINA_LIST_REVERSE_FOREACH(m->items, l, mi) if (mi->separator) - break; + EINA_LIST_REVERSE_FOREACH(m->items, l, mi) + if (mi->separator) + break; if ((!mi) || (!mi->separator)) - return; + return; l = eina_list_prev(l); mi = eina_list_data_get(l); if (!mi) - return; + return; mi = e_menu_item_new_relative(m, mi); e_menu_item_label_set(mi, _("Floating")); @@ -1171,7 +1202,7 @@ EAPI E_Module_Api e_modapi = { }; EAPI void * -e_modapi_init(E_Module * m) +e_modapi_init(E_Module *m) { E_Desk *desk; Eina_List *l; @@ -1180,20 +1211,20 @@ e_modapi_init(E_Module * m) if (tiling_g.log_domain < 0) { - tiling_g.log_domain = eina_log_domain_register("tiling", NULL); - if (tiling_g.log_domain < 0) - { - EINA_LOG_CRIT("could not register log domain 'tiling'"); - } + tiling_g.log_domain = eina_log_domain_register("tiling", NULL); + if (tiling_g.log_domain < 0) + { + EINA_LOG_CRIT("could not register log domain 'tiling'"); + } } _G.info_hash = eina_hash_pointer_new(_clear_info_hash); _G.client_extras = eina_hash_pointer_new(_clear_border_extras); -#define HANDLER(_h, _e, _f) \ - _h = ecore_event_handler_add(E_EVENT_##_e, \ - (Ecore_Event_Handler_Cb) _f, \ - NULL); +#define HANDLER(_h, _e, _f) \ + _h = ecore_event_handler_add(E_EVENT_##_e, \ + (Ecore_Event_Handler_Cb)_f, \ + NULL); e_client_hook_add(E_CLIENT_HOOK_RESIZE_BEGIN, _resize_begin_hook, NULL); HANDLER(_G.handler_client_resize, CLIENT_RESIZE, _resize_hook); @@ -1208,40 +1239,40 @@ e_modapi_init(E_Module * m) HANDLER(_G.handler_desk_show, DESK_SHOW, _desk_show_hook); HANDLER(_G.handler_desk_before_show, DESK_BEFORE_SHOW, - _desk_before_show_hook); + _desk_before_show_hook); HANDLER(_G.handler_desk_set, CLIENT_DESK_SET, _desk_set_hook); HANDLER(_G.handler_compositor_resize, COMPOSITOR_RESIZE, - _compositor_resize_hook); + _compositor_resize_hook); #undef HANDLER -#define ACTION_ADD(_action, _cb, _title, _value, _params, _example, _editable) \ - { \ - const char *_name = _value; \ - if ((_action = e_action_add(_name))) { \ - _action->func.go = _cb; \ - e_action_predef_name_set(N_("Tiling"), _title, _name, \ - _params, _example, _editable); \ - } \ - } +#define ACTION_ADD(_action, _cb, _title, _value, _params, _example, _editable) \ + { \ + const char *_name = _value; \ + if ((_action = e_action_add(_name))) { \ + _action->func.go = _cb; \ + e_action_predef_name_set(N_("Tiling"), _title, _name, \ + _params, _example, _editable); \ + } \ + } /* Module's actions */ ACTION_ADD(_G.act_togglefloat, _e_mod_action_toggle_floating_cb, - N_("Toggle floating"), "toggle_floating", NULL, NULL, 0); + N_("Toggle floating"), "toggle_floating", NULL, NULL, 0); ACTION_ADD(_G.act_move_up, _e_mod_action_move_up_cb, - N_("Move the focused window up"), "move_up", NULL, NULL, 0); + N_("Move the focused window up"), "move_up", NULL, NULL, 0); ACTION_ADD(_G.act_move_down, _e_mod_action_move_down_cb, - N_("Move the focused window down"), "move_down", NULL, NULL, 0); + N_("Move the focused window down"), "move_down", NULL, NULL, 0); ACTION_ADD(_G.act_move_left, _e_mod_action_move_left_cb, - N_("Move the focused window left"), "move_left", NULL, NULL, 0); + N_("Move the focused window left"), "move_left", NULL, NULL, 0); ACTION_ADD(_G.act_move_right, _e_mod_action_move_right_cb, - N_("Move the focused window right"), "move_right", NULL, NULL, 0); + N_("Move the focused window right"), "move_right", NULL, 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); + N_("Toggle split mode"), "toggle_split_mode", NULL, NULL, 0); ACTION_ADD(_G.act_swap_window, NULL, N_("Swap window"), "swap_window", NULL, - NULL, 0); + NULL, 0); _G.act_swap_window->func.go_mouse = _e_mod_action_swap_window_go_mouse; _G.act_swap_window->func.end_mouse = _e_mod_action_swap_window_end_mouse; @@ -1249,11 +1280,11 @@ e_modapi_init(E_Module * m) /* Configuration entries */ snprintf(_G.edj_path, sizeof(_G.edj_path), "%s/e-module-tiling.edj", - e_module_dir_get(m)); + e_module_dir_get(m)); e_configure_registry_category_add("windows", 50, _("Windows"), NULL, - "preferences-system-windows"); + "preferences-system-windows"); e_configure_registry_item_add("windows/tiling", 150, _("Tiling"), NULL, - _G.edj_path, e_int_config_tiling_module); + _G.edj_path, e_int_config_tiling_module); /* Configuration itself */ _G.config_edd = E_CONFIG_DD_NEW("Tiling_Config", Config); @@ -1273,9 +1304,9 @@ e_modapi_init(E_Module * m) tiling_g.config = e_config_domain_load("module.tiling", _G.config_edd); if (!tiling_g.config) { - tiling_g.config = E_NEW(Config, 1); - tiling_g.config->tile_dialogs = 1; - tiling_g.config->show_titles = 1; + tiling_g.config = E_NEW(Config, 1); + tiling_g.config->tile_dialogs = 1; + tiling_g.config->show_titles = 1; tiling_g.config->have_floating_mode = 1; tiling_g.config->window_padding = 0; } @@ -1287,11 +1318,11 @@ e_modapi_init(E_Module * m) for (l = tiling_g.config->vdesks; l; l = l->next) { - struct _Config_vdesk *vd; + struct _Config_vdesk *vd; - vd = l->data; + vd = l->data; - E_CONFIG_LIMIT(vd->nb_stacks, 0, 1); + E_CONFIG_LIMIT(vd->nb_stacks, 0, 1); } _G.client_menu_hook = e_int_client_menu_hook_add(_bd_hook, NULL); @@ -1307,7 +1338,7 @@ e_modapi_init(E_Module * m) E_CLIENT_FOREACH(e_comp_get(NULL), ec) { - _add_client(ec); + _add_client(ec); } } @@ -1317,11 +1348,11 @@ e_modapi_init(E_Module * m) } static void -_disable_desk(E_Desk * desk) +_disable_desk(E_Desk *desk) { check_tinfo(desk); if (!_G.tinfo->conf) - return; + return; tiling_window_tree_walk(_G.tinfo->tree, _restore_free_client); _G.tinfo->tree = NULL; @@ -1337,16 +1368,16 @@ _disable_all_tiling(void) _foreach_desk(_disable_desk); EINA_LIST_FOREACH(e_comp_list(), l, comp) - { - EINA_LIST_FOREACH(comp->zones, ll, zone) - { - e_place_zone_region_smart_cleanup(zone); - } - } + { + EINA_LIST_FOREACH(comp->zones, ll, zone) + { + e_place_zone_region_smart_cleanup(zone); + } + } } static void -_foreach_desk(void (*func) (E_Desk * desk)) +_foreach_desk(void (*func)(E_Desk *desk)) { const Eina_List *l, *ll; E_Comp *comp; @@ -1355,24 +1386,24 @@ _foreach_desk(void (*func) (E_Desk * desk)) int x, y; EINA_LIST_FOREACH(e_comp_list(), l, comp) - { - EINA_LIST_FOREACH(comp->zones, ll, zone) - { - for (x = 0; x < zone->desk_x_count; x++) - { - for (y = 0; y < zone->desk_y_count; y++) - { - desk = zone->desks[x + (y * zone->desk_x_count)]; + { + EINA_LIST_FOREACH(comp->zones, ll, zone) + { + for (x = 0; x < zone->desk_x_count; x++) + { + for (y = 0; y < zone->desk_y_count; y++) + { + desk = zone->desks[x + (y * zone->desk_x_count)]; - func(desk); - } - } - } - } + func(desk); + } + } + } + } } EAPI int -e_modapi_shutdown(E_Module * m EINA_UNUSED) +e_modapi_shutdown(E_Module *m EINA_UNUSED) { e_gadcon_provider_unregister(&_gc_class); @@ -1382,13 +1413,13 @@ e_modapi_shutdown(E_Module * m EINA_UNUSED) if (tiling_g.log_domain >= 0) { - eina_log_domain_unregister(tiling_g.log_domain); - tiling_g.log_domain = -1; + eina_log_domain_unregister(tiling_g.log_domain); + tiling_g.log_domain = -1; } -#define FREE_HANDLER(x) \ - if (x) { \ - ecore_event_handler_del(x); \ - x = NULL; \ +#define FREE_HANDLER(x) \ + if (x) { \ + ecore_event_handler_del(x); \ + x = NULL; \ } FREE_HANDLER(_G.handler_client_resize); FREE_HANDLER(_G.handler_client_move); @@ -1405,11 +1436,11 @@ e_modapi_shutdown(E_Module * m EINA_UNUSED) FREE_HANDLER(_G.handler_desk_set); #undef FREE_HANDLER -#define ACTION_DEL(act, title, value) \ - if (act) { \ - e_action_predef_name_del("Tiling", title); \ - e_action_del(value); \ - act = NULL; \ +#define ACTION_DEL(act, title, value) \ + if (act) { \ + e_action_predef_name_del("Tiling", title); \ + e_action_del(value); \ + act = NULL; \ } ACTION_DEL(_G.act_togglefloat, "Toggle floating", "toggle_floating"); ACTION_DEL(_G.act_move_up, "Move the focused window up", "move_up"); @@ -1418,7 +1449,7 @@ e_modapi_shutdown(E_Module * m EINA_UNUSED) ACTION_DEL(_G.act_move_right, "Move the focused window right", "move_right"); ACTION_DEL(_G.act_toggle_split_mode, "Toggle split mode", - "toggle_split_mode"); + "toggle_split_mode"); ACTION_DEL(_G.act_swap_window, "Swap window", "swap_window"); #undef ACTION_DEL @@ -1443,7 +1474,7 @@ e_modapi_shutdown(E_Module * m EINA_UNUSED) } EAPI int -e_modapi_save(E_Module * m EINA_UNUSED) +e_modapi_save(E_Module *m EINA_UNUSED) { e_config_domain_save("module.tiling", _G.config_edd, tiling_g.config); @@ -1461,16 +1492,19 @@ _gadget_icon_set(Instance *inst) switch (_G.split_type) { case TILING_SPLIT_HORIZONTAL: - edje_object_signal_emit(inst->gadget, "tiling,mode,horizontal", "e"); - break; + edje_object_signal_emit(inst->gadget, "tiling,mode,horizontal", "e"); + break; + case TILING_SPLIT_VERTICAL: - edje_object_signal_emit(inst->gadget, "tiling,mode,vertical", "e"); - break; + edje_object_signal_emit(inst->gadget, "tiling,mode,vertical", "e"); + break; + case TILING_SPLIT_FLOAT: - edje_object_signal_emit(inst->gadget, "tiling,mode,floating", "e"); - break; + edje_object_signal_emit(inst->gadget, "tiling,mode,floating", "e"); + break; + default: - ERR("Unknown split type."); + ERR("Unknown split type."); } } @@ -1521,7 +1555,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) o = edje_object_add(gc->evas); if (!e_theme_edje_object_set(o, "base/theme/modules/tiling", "modules/tiling/main")) - edje_object_file_set(o, _G.edj_path, "modules/tiling/main"); + edje_object_file_set(o, _G.edj_path, "modules/tiling/main"); evas_object_show(o); gcc = e_gadcon_client_new(gc, name, id, style, o); @@ -1553,10 +1587,10 @@ _gc_shutdown(E_Gadcon_Client *gcc) o = inst->gadget; evas_object_event_callback_del_full(o, EVAS_CALLBACK_MOUSE_DOWN, - _gadget_mouse_down_cb, inst); + _gadget_mouse_down_cb, inst); if (inst->gadget) - evas_object_del(inst->gadget); + evas_object_del(inst->gadget); tiling_g.gadget_instances = eina_list_remove(tiling_g.gadget_instances, inst); @@ -1583,7 +1617,7 @@ _gc_icon(const E_Gadcon_Client_Class *client_class EINA_UNUSED, Evas *evas) { Evas_Object *o; - o = edje_object_add (evas); + o = edje_object_add(evas); edje_object_file_set(o, _G.edj_path, "icon"); return o; } @@ -1600,5 +1634,4 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED) return _current_gad_id = eina_stringshare_add(buf); } - /* }}} */ diff --git a/src/modules/tiling/e_mod_tiling.h b/src/modules/tiling/e_mod_tiling.h index 3881f6a5a..6e315597d 100644 --- a/src/modules/tiling/e_mod_tiling.h +++ b/src/modules/tiling/e_mod_tiling.h @@ -9,17 +9,17 @@ # include "window_tree.h" -typedef struct _Config Config; +typedef struct _Config Config; typedef struct _Tiling_Info Tiling_Info; struct tiling_g { - E_Module *module; - Config *config; - int log_domain; + E_Module *module; + Config *config; + int log_domain; Eina_List *gadget_instances; - int gadget_number; + int gadget_number; }; extern struct tiling_g tiling_g; @@ -32,17 +32,17 @@ extern struct tiling_g tiling_g; struct _Config_vdesk { - int x, y; + int x, y; unsigned int zone_num; - int nb_stacks; + int nb_stacks; }; struct _Config { - int window_padding; - int tile_dialogs; - int show_titles; - int have_floating_mode; + int window_padding; + int tile_dialogs; + int show_titles; + int have_floating_mode; Eina_List *vdesks; }; @@ -51,45 +51,45 @@ struct _Tiling_Info /* The desk for which this _Tiling_Info is used. Needed because (for * example) on e restart all desks are shown on all zones but no change * events are triggered */ - const E_Desk *desk; + const E_Desk *desk; struct _Config_vdesk *conf; - Window_Tree *tree; + Window_Tree *tree; }; struct _E_Config_Dialog_Data { struct _Config config; - Evas_Object *o_zonelist; - Evas_Object *o_desklist; - Evas_Object *osf; - Evas *evas; + Evas_Object *o_zonelist; + Evas_Object *o_desklist; + Evas_Object *osf; + Evas *evas; }; -E_Config_Dialog *e_int_config_tiling_module(E_Comp * comp, const char *params); +E_Config_Dialog *e_int_config_tiling_module(E_Comp *comp, const char *params); EAPI extern E_Module_Api e_modapi; -EAPI void *e_modapi_init(E_Module * m); -EAPI int e_modapi_shutdown(E_Module * m); -EAPI int e_modapi_save(E_Module * m); +EAPI void *e_modapi_init(E_Module *m); +EAPI int e_modapi_shutdown(E_Module *m); +EAPI int e_modapi_save(E_Module *m); -void change_desk_conf(struct _Config_vdesk *newconf); +void change_desk_conf(struct _Config_vdesk *newconf); -void e_tiling_update_conf(void); +void e_tiling_update_conf(void); -struct _Config_vdesk *get_vdesk(Eina_List * vdesks, int x, int y, - unsigned int zone_num); +struct _Config_vdesk *get_vdesk(Eina_List *vdesks, int x, int y, + unsigned int zone_num); -void tiling_e_client_move_resize_extra(E_Client * ec, int x, int y, int w, - int h); +void tiling_e_client_move_resize_extra(E_Client *ec, int x, int y, int w, + int h); # define EINA_LIST_IS_IN(_list, _el) \ - (eina_list_data_find(_list, _el) == _el) + (eina_list_data_find(_list, _el) == _el) # define EINA_LIST_APPEND(_list, _el) \ - _list = eina_list_append(_list, _el) + _list = eina_list_append(_list, _el) # define EINA_LIST_REMOVE(_list, _el) \ - _list = eina_list_remove(_list, _el) + _list = eina_list_remove(_list, _el) # define _TILE_MIN(a, b) (((a) < (b)) ? (a) : (b)) # define _TILE_MAX(a, b) (((a) > (b)) ? (a) : (b)) diff --git a/src/modules/tiling/window_tree.c b/src/modules/tiling/window_tree.c index a81509ef8..ddabe0bed 100644 --- a/src/modules/tiling/window_tree.c +++ b/src/modules/tiling/window_tree.c @@ -4,29 +4,29 @@ #include "e_mod_tiling.h" void -tiling_window_tree_walk(Window_Tree * root, void (*func) (void *)) +tiling_window_tree_walk(Window_Tree *root, void (*func)(void *)) { Eina_Inlist *itr_safe; Window_Tree *itr; if (!root) - return; + return; EINA_INLIST_FOREACH_SAFE(root->children, itr_safe, itr) - { - tiling_window_tree_walk(itr, func); - } + { + tiling_window_tree_walk(itr, func); + } func(root); } void -tiling_window_tree_free(Window_Tree * root) +tiling_window_tree_free(Window_Tree *root) { tiling_window_tree_walk(root, free); } static void -_tiling_window_tree_split_add(Window_Tree * parent, Window_Tree * new_node) +_tiling_window_tree_split_add(Window_Tree *parent, Window_Tree *new_node) { /* Make a new node for the parent client and split the weights in half. */ Window_Tree *new_parent_client = calloc(1, sizeof(*new_node)); @@ -39,13 +39,13 @@ _tiling_window_tree_split_add(Window_Tree * parent, Window_Tree * new_node) new_node->weight = 0.5; parent->children = - eina_inlist_append(parent->children, EINA_INLIST_GET(new_parent_client)); + eina_inlist_append(parent->children, EINA_INLIST_GET(new_parent_client)); parent->children = - eina_inlist_append(parent->children, EINA_INLIST_GET(new_node)); + eina_inlist_append(parent->children, EINA_INLIST_GET(new_node)); } static void -_tiling_window_tree_parent_add(Window_Tree * parent, Window_Tree * new_node) +_tiling_window_tree_parent_add(Window_Tree *parent, Window_Tree *new_node) { /* Adjust existing children's weights */ Window_Tree *itr; @@ -57,31 +57,31 @@ _tiling_window_tree_parent_add(Window_Tree * parent, Window_Tree * new_node) weight *= children_count; EINA_INLIST_FOREACH(parent->children, itr) - { - itr->weight *= weight; - } + { + itr->weight *= weight; + } parent->children = - eina_inlist_append(parent->children, EINA_INLIST_GET(new_node)); + eina_inlist_append(parent->children, EINA_INLIST_GET(new_node)); } static int -_tiling_window_tree_split_type_get(Window_Tree * node) +_tiling_window_tree_split_type_get(Window_Tree *node) { int ret = 0; while (node->parent) { - ret++; - node = node->parent; + ret++; + node = node->parent; } return ret % 2; } Window_Tree * -tiling_window_tree_add(Window_Tree * root, Window_Tree * parent, - E_Client * client, Tiling_Split_Type split_type) +tiling_window_tree_add(Window_Tree *root, Window_Tree *parent, + E_Client *client, Tiling_Split_Type split_type) { Window_Tree *new_node = calloc(1, sizeof(*new_node)); @@ -90,64 +90,70 @@ tiling_window_tree_add(Window_Tree * root, Window_Tree * parent, if (split_type > TILING_SPLIT_VERTICAL) { - return root; - } else if (!root) + return root; + } + else if (!root) { - new_node->weight = 1.0; - return new_node; - } else if (!parent) + new_node->weight = 1.0; + return new_node; + } + else if (!parent) { - parent = root; - parent_split_type = _tiling_window_tree_split_type_get(parent); - if ((parent_split_type != split_type) && (parent->children)) - { - parent = (Window_Tree *) parent->children; - } + parent = root; + parent_split_type = _tiling_window_tree_split_type_get(parent); + if ((parent_split_type != split_type) && (parent->children)) + { + parent = (Window_Tree *)parent->children; + } } parent_split_type = _tiling_window_tree_split_type_get(parent); if (parent_split_type == split_type) { - if (parent->children) - { - _tiling_window_tree_parent_add(parent, new_node); - } else - { - _tiling_window_tree_split_add(parent, new_node); - } - } else + if (parent->children) + { + _tiling_window_tree_parent_add(parent, new_node); + } + else + { + _tiling_window_tree_split_add(parent, new_node); + } + } + else { - Window_Tree *grand_parent = parent->parent; + Window_Tree *grand_parent = parent->parent; - if (grand_parent && grand_parent->children) - { - _tiling_window_tree_parent_add(grand_parent, new_node); - } else - { - root = calloc(1, sizeof(*root)); - _tiling_window_tree_split_add(parent, new_node); - root->weight = 1.0; - root->children = - eina_inlist_append(root->children, EINA_INLIST_GET(parent)); - parent->parent = root; - } + if (grand_parent && grand_parent->children) + { + _tiling_window_tree_parent_add(grand_parent, new_node); + } + else + { + root = calloc(1, sizeof(*root)); + _tiling_window_tree_split_add(parent, new_node); + root->weight = 1.0; + root->children = + eina_inlist_append(root->children, EINA_INLIST_GET(parent)); + parent->parent = root; + } } return root; } Window_Tree * -tiling_window_tree_remove(Window_Tree * root, Window_Tree * item) +tiling_window_tree_remove(Window_Tree *root, Window_Tree *item) { if (root == item) { - free(item); - return NULL; - } else if (!item->client) + free(item); + return NULL; + } + else if (!item->client) { - ERR("Tried deleting node %p that doesn't have a client.", item); - return root; + ERR("Tried deleting node %p that doesn't have a client.", item); + return root; } Window_Tree *parent = item->parent; @@ -155,76 +161,80 @@ tiling_window_tree_remove(Window_Tree * root, Window_Tree * item) if (children_count <= 2) { - Window_Tree *grand_parent = parent->parent; - Window_Tree *item_keep = NULL; + Window_Tree *grand_parent = parent->parent; + Window_Tree *item_keep = NULL; - /* Adjust existing children's weights */ - EINA_INLIST_FOREACH(parent->children, item_keep) - { - if (item_keep != item) - break; - } + /* Adjust existing children's weights */ + EINA_INLIST_FOREACH(parent->children, item_keep) + { + if (item_keep != item) + break; + } - if (!item_keep) - { - /* Special case of deleting the last vertical split item. */ - free(item); - free(root); - return NULL; - } else if (!item_keep->children) - { - parent->client = item_keep->client; - parent->children = NULL; + if (!item_keep) + { + /* Special case of deleting the last vertical split item. */ + free(item); + free(root); + return NULL; + } + else if (!item_keep->children) + { + parent->client = item_keep->client; + parent->children = NULL; - free(item_keep); - } else - { - if (grand_parent) - { - /* Update the children's parent. */ - { - Eina_Inlist *itr_safe; - Window_Tree *itr; + free(item_keep); + } + else + { + if (grand_parent) + { + /* Update the children's parent. */ + { + Eina_Inlist *itr_safe; + Window_Tree *itr; - EINA_INLIST_FOREACH_SAFE(item_keep->children, itr_safe, - itr) - { - /* We are prepending to double-reverse the order. */ - grand_parent->children = - eina_inlist_prepend_relative(grand_parent->children, - EINA_INLIST_GET(itr), EINA_INLIST_GET(parent)); - itr->weight *= parent->weight; - itr->parent = grand_parent; - } + EINA_INLIST_FOREACH_SAFE(item_keep->children, itr_safe, + itr) + { + /* We are prepending to double-reverse the order. */ + grand_parent->children = + eina_inlist_prepend_relative(grand_parent->children, + EINA_INLIST_GET(itr), EINA_INLIST_GET(parent)); + itr->weight *= parent->weight; + itr->parent = grand_parent; + } - grand_parent->children = - eina_inlist_remove(grand_parent->children, - EINA_INLIST_GET(parent)); - free(parent); - } - } else - { - /* This is fine, as this is a child of the root so we allow - * two levels. */ - item_keep->weight = 1.0; - } + grand_parent->children = + eina_inlist_remove(grand_parent->children, + EINA_INLIST_GET(parent)); + free(parent); + } + } + else + { + /* This is fine, as this is a child of the root so we allow + * two levels. */ + item_keep->weight = 1.0; + } - parent->children = - eina_inlist_remove(parent->children, EINA_INLIST_GET(item)); - } - } else + parent->children = + eina_inlist_remove(parent->children, EINA_INLIST_GET(item)); + } + } + else { - Window_Tree *itr; - float weight = 1.0 - item->weight; + Window_Tree *itr; + float weight = 1.0 - item->weight; - parent->children = - eina_inlist_remove(parent->children, EINA_INLIST_GET(item)); + parent->children = + eina_inlist_remove(parent->children, EINA_INLIST_GET(item)); - /* Adjust existing children's weights */ - EINA_INLIST_FOREACH(parent->children, itr) - { - itr->weight /= weight; - } + /* Adjust existing children's weights */ + EINA_INLIST_FOREACH(parent->children, itr) + { + itr->weight /= weight; + } } free(item); @@ -232,31 +242,31 @@ tiling_window_tree_remove(Window_Tree * root, Window_Tree * item) } Window_Tree * -tiling_window_tree_client_find(Window_Tree * root, E_Client * client) +tiling_window_tree_client_find(Window_Tree *root, E_Client *client) { Window_Tree *itr; if (!client) - return NULL; + return NULL; if (!root || (root->client == client)) - return root; + return root; EINA_INLIST_FOREACH(root->children, itr) - { - Window_Tree *ret; + { + Window_Tree *ret; - ret = tiling_window_tree_client_find(itr, client); - if (ret) - return ret; - } + ret = tiling_window_tree_client_find(itr, client); + if (ret) + return ret; + } return NULL; } void -_tiling_window_tree_level_apply(Window_Tree * root, Evas_Coord x, Evas_Coord y, - Evas_Coord w, Evas_Coord h, int level, Evas_Coord padding) +_tiling_window_tree_level_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y, + Evas_Coord w, Evas_Coord h, int level, Evas_Coord padding) { Window_Tree *itr; Tiling_Split_Type split_type = level % 2; @@ -264,95 +274,97 @@ _tiling_window_tree_level_apply(Window_Tree * root, Evas_Coord x, Evas_Coord y, if (root->client) { - tiling_e_client_move_resize_extra(root->client, x, y, - w - padding, h - padding); - return; + tiling_e_client_move_resize_extra(root->client, x, y, + w - padding, h - padding); + return; } if (split_type == TILING_SPLIT_HORIZONTAL) { - EINA_INLIST_FOREACH(root->children, itr) - { - Evas_Coord itw = w * itr->weight; + EINA_INLIST_FOREACH(root->children, itr) + { + Evas_Coord itw = w * itr->weight; - total_weight += itr->weight; - _tiling_window_tree_level_apply(itr, x, y, itw, h, level + 1, padding); - x += itw; - } - } else if (split_type == TILING_SPLIT_VERTICAL) + total_weight += itr->weight; + _tiling_window_tree_level_apply(itr, x, y, itw, h, level + 1, padding); + x += itw; + } + } + else if (split_type == TILING_SPLIT_VERTICAL) { - EINA_INLIST_FOREACH(root->children, itr) - { - Evas_Coord ith = h * itr->weight; + EINA_INLIST_FOREACH(root->children, itr) + { + Evas_Coord ith = h * itr->weight; - total_weight += itr->weight; - _tiling_window_tree_level_apply(itr, x, y, w, ith, level + 1, padding); - y += ith; - } + total_weight += itr->weight; + _tiling_window_tree_level_apply(itr, x, y, w, ith, level + 1, padding); + y += ith; + } } /* Adjust the last item's weight in case weight < 1.0 */ - ((Window_Tree *) root->children->last)->weight += 1.0 - total_weight; + ((Window_Tree *)root->children->last)->weight += 1.0 - total_weight; } void -tiling_window_tree_apply(Window_Tree * root, Evas_Coord x, Evas_Coord y, - Evas_Coord w, Evas_Coord h, Evas_Coord padding) +tiling_window_tree_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y, + Evas_Coord w, Evas_Coord h, Evas_Coord padding) { _tiling_window_tree_level_apply(root, x + padding, y + padding, - w - padding, h - padding, 0, padding); + w - padding, h - padding, 0, padding); } static Window_Tree * -_inlist_next(Window_Tree * it) +_inlist_next(Window_Tree *it) { - return (Window_Tree *) EINA_INLIST_GET(it)->next; + return (Window_Tree *)EINA_INLIST_GET(it)->next; } static Window_Tree * -_inlist_prev(Window_Tree * it) +_inlist_prev(Window_Tree *it) { - return (Window_Tree *) EINA_INLIST_GET(it)->prev; + return (Window_Tree *)EINA_INLIST_GET(it)->prev; } static Eina_Bool -_tiling_window_tree_node_resize_direction(Window_Tree * node, - Window_Tree * parent, double dir_diff, int dir) +_tiling_window_tree_node_resize_direction(Window_Tree *node, + Window_Tree *parent, double dir_diff, int dir) { double weight = 0.0; double weight_diff; Window_Tree *children_start; Window_Tree *itr; - Window_Tree *(*itr_func) (Window_Tree *); + Window_Tree *(*itr_func)(Window_Tree *); if (dir > 0) { - itr_func = _inlist_prev; - children_start = (Window_Tree *) parent->children->last; - } else + itr_func = _inlist_prev; + children_start = (Window_Tree *)parent->children->last; + } + else { - itr_func = _inlist_next; - children_start = (Window_Tree *) parent->children; + itr_func = _inlist_next; + children_start = (Window_Tree *)parent->children; } - itr = (Window_Tree *) children_start; + itr = (Window_Tree *)children_start; while (itr != node) { - weight += itr->weight; + weight += itr->weight; - itr = itr_func(itr); + itr = itr_func(itr); } /* If it's at the edge, try the grandpa of the parent. */ if (weight == 0.0) { - if (parent->parent && parent->parent->parent) - { - return _tiling_window_tree_node_resize_direction(parent->parent, - parent->parent->parent, 1.0 + ((dir_diff - 1.) * node->weight), - dir); - } - return EINA_FALSE; + if (parent->parent && parent->parent->parent) + { + return _tiling_window_tree_node_resize_direction(parent->parent, + parent->parent->parent, 1.0 + ((dir_diff - 1.) * node->weight), + dir); + } + return EINA_FALSE; } weight_diff = itr->weight; @@ -362,15 +374,15 @@ _tiling_window_tree_node_resize_direction(Window_Tree * node, for (itr = children_start; itr != node; itr = itr_func(itr)) { - itr->weight += itr->weight * weight_diff; + itr->weight += itr->weight * weight_diff; } return EINA_TRUE; } Eina_Bool -tiling_window_tree_node_resize(Window_Tree * node, int w_dir, double w_diff, - int h_dir, double h_diff) +tiling_window_tree_node_resize(Window_Tree *node, int w_dir, double w_diff, + int h_dir, double h_diff) { Window_Tree *parent = node->parent; Window_Tree *w_parent, *h_parent; @@ -378,95 +390,98 @@ tiling_window_tree_node_resize(Window_Tree * node, int w_dir, double w_diff, /* If we have no parent, means we need to be full screen anyway. */ if (!parent) - return EINA_FALSE; + return EINA_FALSE; Window_Tree *grand_parent = parent->parent; Tiling_Split_Type parent_split_type = - _tiling_window_tree_split_type_get(parent); + _tiling_window_tree_split_type_get(parent); /* w_diff related changes. */ if (parent_split_type == TILING_SPLIT_HORIZONTAL) { - w_parent = parent; - h_parent = grand_parent; - } else + w_parent = parent; + h_parent = grand_parent; + } + else { - w_parent = grand_parent; - h_parent = parent; + w_parent = grand_parent; + h_parent = parent; } if ((h_diff != 1.0) && h_parent) { - Window_Tree *tmp_node = (h_parent == parent) ? node : parent; + Window_Tree *tmp_node = (h_parent == parent) ? node : parent; - ret = ret || - _tiling_window_tree_node_resize_direction(tmp_node, h_parent, - h_diff, h_dir); + ret = ret || + _tiling_window_tree_node_resize_direction(tmp_node, h_parent, + h_diff, h_dir); } if ((w_diff != 1.0) && w_parent) { - Window_Tree *tmp_node = (w_parent == parent) ? node : parent; + Window_Tree *tmp_node = (w_parent == parent) ? node : parent; - ret = ret || - _tiling_window_tree_node_resize_direction(tmp_node, w_parent, - w_diff, w_dir); + ret = ret || + _tiling_window_tree_node_resize_direction(tmp_node, w_parent, + w_diff, w_dir); } return ret; } int -_tiling_window_tree_edges_get_helper(Window_Tree * node, - Tiling_Split_Type split_type, Eina_Bool gave_up_this, - Eina_Bool gave_up_parent) +_tiling_window_tree_edges_get_helper(Window_Tree *node, + Tiling_Split_Type split_type, Eina_Bool gave_up_this, + Eina_Bool gave_up_parent) { int ret = - TILING_WINDOW_TREE_EDGE_LEFT | TILING_WINDOW_TREE_EDGE_RIGHT | - TILING_WINDOW_TREE_EDGE_TOP | TILING_WINDOW_TREE_EDGE_BOTTOM; + TILING_WINDOW_TREE_EDGE_LEFT | TILING_WINDOW_TREE_EDGE_RIGHT | + TILING_WINDOW_TREE_EDGE_TOP | TILING_WINDOW_TREE_EDGE_BOTTOM; if (!node->parent) { - return ret; - } else if (gave_up_this && gave_up_parent) + return ret; + } + else if (gave_up_this && gave_up_parent) { - return 0; - } else if (gave_up_this) + return 0; + } + else if (gave_up_this) { - /* Mixed the gave_up vals on purpose, we do it on every call. */ - return _tiling_window_tree_edges_get_helper(node->parent, !split_type, - gave_up_parent, gave_up_this); + /* Mixed the gave_up vals on purpose, we do it on every call. */ + return _tiling_window_tree_edges_get_helper(node->parent, !split_type, + gave_up_parent, gave_up_this); } if (EINA_INLIST_GET(node)->prev) { - gave_up_this = EINA_TRUE; - ret ^= - (split_type == - TILING_SPLIT_HORIZONTAL) ? TILING_WINDOW_TREE_EDGE_LEFT : - TILING_WINDOW_TREE_EDGE_TOP; + gave_up_this = EINA_TRUE; + ret ^= + (split_type == + TILING_SPLIT_HORIZONTAL) ? TILING_WINDOW_TREE_EDGE_LEFT : + TILING_WINDOW_TREE_EDGE_TOP; } if (EINA_INLIST_GET(node)->next) { - gave_up_this = EINA_TRUE; - ret ^= - (split_type == - TILING_SPLIT_HORIZONTAL) ? TILING_WINDOW_TREE_EDGE_RIGHT : - TILING_WINDOW_TREE_EDGE_BOTTOM; + gave_up_this = EINA_TRUE; + ret ^= + (split_type == + TILING_SPLIT_HORIZONTAL) ? TILING_WINDOW_TREE_EDGE_RIGHT : + TILING_WINDOW_TREE_EDGE_BOTTOM; } /* Mixed the gave_up vals on purpose, we do it on every call. */ return ret & _tiling_window_tree_edges_get_helper(node->parent, !split_type, - gave_up_parent, gave_up_this); + gave_up_parent, gave_up_this); } int -tiling_window_tree_edges_get(Window_Tree * node) +tiling_window_tree_edges_get(Window_Tree *node) { Tiling_Split_Type split_type = _tiling_window_tree_split_type_get(node); return _tiling_window_tree_edges_get_helper(node, !split_type, EINA_FALSE, - EINA_FALSE); + EINA_FALSE); } /* Node move */ @@ -474,20 +489,20 @@ static struct _Node_Move_Context { Window_Tree *node; Window_Tree *ret; - int cross_edge; - int best_match; + int cross_edge; + int best_match; } _node_move_ctx; #define CNODE (_node_move_ctx.node) #define IF_MATCH_SET_LR(node) _tiling_window_tree_node_move_if_match_set(node, \ - CNODE->client->y, CNODE->client->h, node->client->y, node->client->h) + CNODE->client->y, CNODE->client->h, node->client->y, node->client->h) #define IF_MATCH_SET_TB(node) _tiling_window_tree_node_move_if_match_set(node, \ - CNODE->client->x, CNODE->client->w, node->client->x, node->client->w) + CNODE->client->x, CNODE->client->w, node->client->x, node->client->w) static void -_tiling_window_tree_node_move_if_match_set(Window_Tree * node, Evas_Coord cx, - Evas_Coord cw, Evas_Coord ox, Evas_Coord ow) +_tiling_window_tree_node_move_if_match_set(Window_Tree *node, Evas_Coord cx, + Evas_Coord cw, Evas_Coord ox, Evas_Coord ow) { Evas_Coord leftx, rightx; int match; @@ -498,8 +513,8 @@ _tiling_window_tree_node_move_if_match_set(Window_Tree * node, Evas_Coord cx, if (match > _node_move_ctx.best_match) { - _node_move_ctx.best_match = match; - _node_move_ctx.ret = node; + _node_move_ctx.best_match = match; + _node_move_ctx.ret = node; } } @@ -510,28 +525,32 @@ _tiling_window_tree_node_move_walker(void *_node) /* We are only interested in nodes with clients. */ if (!node->client) - return; + return; switch (_node_move_ctx.cross_edge) { - case TILING_WINDOW_TREE_EDGE_LEFT: - if ((node->client->x + node->client->w) == CNODE->client->x) - IF_MATCH_SET_LR(node); - break; - case TILING_WINDOW_TREE_EDGE_RIGHT: - if (node->client->x == (CNODE->client->x + CNODE->client->w)) - IF_MATCH_SET_LR(node); - break; - case TILING_WINDOW_TREE_EDGE_TOP: - if ((node->client->y + node->client->h) == CNODE->client->y) - IF_MATCH_SET_TB(node); - break; - case TILING_WINDOW_TREE_EDGE_BOTTOM: - if (node->client->y == (CNODE->client->y + CNODE->client->h)) - IF_MATCH_SET_TB(node); - break; - default: - break; + case TILING_WINDOW_TREE_EDGE_LEFT: + if ((node->client->x + node->client->w) == CNODE->client->x) + IF_MATCH_SET_LR(node); + break; + + case TILING_WINDOW_TREE_EDGE_RIGHT: + if (node->client->x == (CNODE->client->x + CNODE->client->w)) + IF_MATCH_SET_LR(node); + break; + + case TILING_WINDOW_TREE_EDGE_TOP: + if ((node->client->y + node->client->h) == CNODE->client->y) + IF_MATCH_SET_TB(node); + break; + + case TILING_WINDOW_TREE_EDGE_BOTTOM: + if (node->client->y == (CNODE->client->y + CNODE->client->h)) + IF_MATCH_SET_TB(node); + break; + + default: + break; } } @@ -540,7 +559,7 @@ _tiling_window_tree_node_move_walker(void *_node) #undef IF_MATCH_SET_TB void -tiling_window_tree_node_move(Window_Tree * node, int cross_edge) +tiling_window_tree_node_move(Window_Tree *node, int cross_edge) { Window_Tree *root = node; @@ -548,7 +567,7 @@ tiling_window_tree_node_move(Window_Tree * node, int cross_edge) * is very easy to implement. */ while (root->parent) - root = root->parent; + root = root->parent; _node_move_ctx.node = node; _node_move_ctx.cross_edge = cross_edge; @@ -559,37 +578,38 @@ tiling_window_tree_node_move(Window_Tree * node, int cross_edge) if (_node_move_ctx.ret) { - E_Client *ec = node->client; + E_Client *ec = node->client; - node->client = _node_move_ctx.ret->client; - _node_move_ctx.ret->client = ec; + node->client = _node_move_ctx.ret->client; + _node_move_ctx.ret->client = ec; } } /* End Node move. */ void -tiling_window_tree_dump(Window_Tree * root, int level) +tiling_window_tree_dump(Window_Tree *root, int level) { int i; if (!root) - return; + return; for (i = 0; i < level; i++) - printf(" "); + printf(" "); if (root->children) - printf("\\-"); + printf("\\-"); else - printf("|-"); + printf("|-"); printf("%f (%p)\n", root->weight, root->client); Window_Tree *itr; EINA_INLIST_FOREACH(root->children, itr) - { - tiling_window_tree_dump(itr, level + 1); - } + { + tiling_window_tree_dump(itr, level + 1); + } } + diff --git a/src/modules/tiling/window_tree.h b/src/modules/tiling/window_tree.h index b83ac5281..df5034bf7 100644 --- a/src/modules/tiling/window_tree.h +++ b/src/modules/tiling/window_tree.h @@ -19,35 +19,35 @@ struct _Window_Tree EINA_INLIST; Window_Tree *parent; /* FIXME: client is falid iff children is null. Sholud enforce it. */ - Eina_Inlist *children; /* Window_Tree * type */ - E_Client *client; - double weight; + Eina_Inlist *children; /* Window_Tree * type */ + E_Client *client; + double weight; }; -# define TILING_WINDOW_TREE_EDGE_LEFT (1 << 0) -# define TILING_WINDOW_TREE_EDGE_RIGHT (1 << 1) -# define TILING_WINDOW_TREE_EDGE_TOP (1 << 2) +# define TILING_WINDOW_TREE_EDGE_LEFT (1 << 0) +# define TILING_WINDOW_TREE_EDGE_RIGHT (1 << 1) +# define TILING_WINDOW_TREE_EDGE_TOP (1 << 2) # define TILING_WINDOW_TREE_EDGE_BOTTOM (1 << 3) -int tiling_window_tree_edges_get(Window_Tree * node); +int tiling_window_tree_edges_get(Window_Tree *node); -void tiling_window_tree_free(Window_Tree * root); -void tiling_window_tree_walk(Window_Tree * root, void (*func) (void *)); +void tiling_window_tree_free(Window_Tree *root); +void tiling_window_tree_walk(Window_Tree *root, void (*func)(void *)); -Window_Tree *tiling_window_tree_add(Window_Tree * root, Window_Tree * parent, - E_Client * client, Tiling_Split_Type split_type); +Window_Tree *tiling_window_tree_add(Window_Tree *root, Window_Tree *parent, + E_Client *client, Tiling_Split_Type split_type); -Window_Tree *tiling_window_tree_remove(Window_Tree * root, Window_Tree * item); +Window_Tree *tiling_window_tree_remove(Window_Tree *root, Window_Tree *item); -Window_Tree *tiling_window_tree_client_find(Window_Tree * root, - E_Client * client); +Window_Tree *tiling_window_tree_client_find(Window_Tree *root, + E_Client *client); -void tiling_window_tree_apply(Window_Tree * root, Evas_Coord x, Evas_Coord y, - Evas_Coord w, Evas_Coord h, Evas_Coord padding); +void tiling_window_tree_apply(Window_Tree *root, Evas_Coord x, Evas_Coord y, + Evas_Coord w, Evas_Coord h, Evas_Coord padding); -Eina_Bool tiling_window_tree_node_resize(Window_Tree * node, int w_dir, - double w_diff, int h_dir, double h_diff); +Eina_Bool tiling_window_tree_node_resize(Window_Tree *node, int w_dir, + double w_diff, int h_dir, double h_diff); -void tiling_window_tree_node_move(Window_Tree * node, int cross_edge); +void tiling_window_tree_node_move(Window_Tree *node, int cross_edge); #endif