From 6220019b6db711cafc7f0b3e87ca47e80949e6a8 Mon Sep 17 00:00:00 2001 From: Gustavo Lima Chaves Date: Fri, 25 Jan 2013 00:49:03 +0000 Subject: [PATCH] Formatting love to comp-scale. SVN revision: 83314 --- src/e_mod_main.c | 406 +++++---- src/e_mod_pager.c | 793 +++++++++--------- src/e_mod_scale.c | 1988 +++++++++++++++++++++++---------------------- 3 files changed, 1658 insertions(+), 1529 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index d72435c..3d5b75d 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -7,25 +7,48 @@ // while scale is active? // -static E_Gadcon_Client *_gc_init_scale(E_Gadcon *gc, const char *name, const char *id, const char *style); -static E_Gadcon_Client *_gc_init_scale_all(E_Gadcon *gc, const char *name, const char *id, const char *style); -static E_Gadcon_Client *_gc_init_pager(E_Gadcon *gc, const char *name, const char *id, const char *style); -static const char *_gc_label_scale(const E_Gadcon_Client_Class *client_class); -static const char *_gc_label_scale_all(const E_Gadcon_Client_Class *client_class); -static const char *_gc_label_pager(const E_Gadcon_Client_Class *client_class); -static void _gc_shutdown(E_Gadcon_Client *gcc); -static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient); -static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class); -static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas); +static E_Gadcon_Client *_gc_init_scale(E_Gadcon *gc, + const char *name, + const char *id, + const char *style); +static E_Gadcon_Client *_gc_init_scale_all(E_Gadcon *gc, + const char *name, + const char *id, + const char *style); +static E_Gadcon_Client *_gc_init_pager(E_Gadcon *gc, + const char *name, + const char *id, + const char *style); +static const char *_gc_label_scale(const E_Gadcon_Client_Class *); +static const char *_gc_label_scale_all(const E_Gadcon_Client_Class *); +static const char *_gc_label_pager(const E_Gadcon_Client_Class *); +static void _gc_shutdown(E_Gadcon_Client *gcc); +static void _gc_orient(E_Gadcon_Client *gcc, + E_Gadcon_Orient orient); +static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class); +static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, + Evas *evas); -static void _scale_conf_new(void); -static void _scale_conf_free(void); -static Config_Item *_scale_conf_item_get(const char *id); -static void _scale_gc_cb_mouse_down_scale(void *data, Evas *evas, Evas_Object *obj, void *event); -static void _scale_gc_cb_mouse_down_scale_all(void *data, Evas *evas, Evas_Object *obj, void *event); -static void _scale_gc_cb_mouse_down_pager(void *data, Evas *evas, Evas_Object *obj, void *event); -static void _scale_gc_cb_menu_post(void *data, E_Menu *menu); -static void _scale_gc_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi); +static void _scale_conf_new(void); +static void _scale_conf_free(void); +static Config_Item *_scale_conf_item_get(const char *id); +static void _scale_gc_cb_mouse_down_scale(void *data, + Evas *evas, + Evas_Object *obj, + void *event); +static void _scale_gc_cb_mouse_down_scale_all(void *data, + Evas *evas, + Evas_Object *obj, + void *event); +static void _scale_gc_cb_mouse_down_pager(void *data, + Evas *evas, + Evas_Object *obj, + void *event); +static void _scale_gc_cb_menu_post(void *data, + E_Menu *menu); +static void _scale_gc_cb_menu_configure(void *data, + E_Menu *mn, + E_Menu_Item *mi); static E_Action *act = NULL; static int _hold_count = 0; @@ -36,39 +59,54 @@ e_mod_hold_modifier_check(Ecore_Event_Key *ev) { if (!_hold_mod) return EINA_TRUE; - if ((_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) && (!strcmp(ev->key, "Shift_L"))) + if ((_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) && + (!strcmp(ev->key, "Shift_L"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) && (!strcmp(ev->key, "Shift_R"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) && + (!strcmp(ev->key, "Shift_R"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_CTRL) && (!strcmp(ev->key, "Control_L"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_CTRL) && + (!strcmp(ev->key, "Control_L"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_CTRL) && (!strcmp(ev->key, "Control_R"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_CTRL) && + (!strcmp(ev->key, "Control_R"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Alt_L"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && + (!strcmp(ev->key, "Alt_L"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Alt_R"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && + (!strcmp(ev->key, "Alt_R"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Meta_L"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && + (!strcmp(ev->key, "Meta_L"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Meta_R"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && + (!strcmp(ev->key, "Meta_R"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Super_L"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && + (!strcmp(ev->key, "Super_L"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && (!strcmp(ev->key, "Super_R"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_ALT) && + (!strcmp(ev->key, "Super_R"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Super_L"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && + (!strcmp(ev->key, "Super_L"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Super_R"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && + (!strcmp(ev->key, "Super_R"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Mode_switch"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && + (!strcmp(ev->key, "Mode_switch"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Meta_L"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && + (!strcmp(ev->key, "Meta_L"))) _hold_count--; - else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && (!strcmp(ev->key, "Meta_R"))) + else if ((_hold_mod & ECORE_EVENT_MODIFIER_WIN) && + (!strcmp(ev->key, "Meta_R"))) _hold_count--; if (_hold_count <= 0) { - return EINA_FALSE; + return EINA_FALSE; } return EINA_TRUE; } @@ -87,28 +125,27 @@ e_mod_border_ignore(E_Border *bd) return EINA_TRUE; if (bd->client.icccm.class) { - if (!strncmp(bd->client.icccm.class, "Illume-", 7)) - return EINA_TRUE; + if (!strncmp(bd->client.icccm.class, "Illume-", 7)) + return EINA_TRUE; - if (!strcmp(bd->client.icccm.class, "Virtual-Keyboard")) - return EINA_TRUE; + if (!strcmp(bd->client.icccm.class, "Virtual-Keyboard")) + return EINA_TRUE; - if (!strcmp(bd->client.icccm.class, "everything-window")) - return EINA_TRUE; + if (!strcmp(bd->client.icccm.class, "everything-window")) + return EINA_TRUE; } if (bd->client.icccm.name) { - /* legacy code from illume 1 */ - if (((!strcmp(bd->client.icccm.name, "multitap-pad"))) && - (bd->client.netwm.state.skip_taskbar) && - (bd->client.netwm.state.skip_pager)) - return EINA_TRUE; + /* legacy code from illume 1 */ + if (((!strcmp(bd->client.icccm.name, "multitap-pad"))) && + (bd->client.netwm.state.skip_taskbar) && + (bd->client.netwm.state.skip_pager)) + return EINA_TRUE; } return EINA_FALSE; } - static void _e_mod_action(const char *params, int modifiers, int method) { @@ -127,25 +164,25 @@ _e_mod_action(const char *params, int modifiers, int method) if (!strncmp(params, "go_pager", 8)) { - active = pager_run(man, params, method); + active = pager_run(man, params, method); } else if (!strncmp(params, "go_scale", 8)) { - active = scale_run(man, params, method); + active = scale_run(man, params, method); } if (active) { - _hold_mod = modifiers & - (ECORE_EVENT_MODIFIER_SHIFT | - ECORE_EVENT_MODIFIER_CTRL | - ECORE_EVENT_MODIFIER_ALT | - ECORE_EVENT_MODIFIER_WIN); - _hold_count = 0; - if (_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) _hold_count++; - if (_hold_mod & ECORE_EVENT_MODIFIER_CTRL) _hold_count++; - if (_hold_mod & ECORE_EVENT_MODIFIER_ALT) _hold_count++; - if (_hold_mod & ECORE_EVENT_MODIFIER_WIN) _hold_count++; + _hold_mod = modifiers & + (ECORE_EVENT_MODIFIER_SHIFT | + ECORE_EVENT_MODIFIER_CTRL | + ECORE_EVENT_MODIFIER_ALT | + ECORE_EVENT_MODIFIER_WIN); + _hold_count = 0; + if (_hold_mod & ECORE_EVENT_MODIFIER_SHIFT) _hold_count++; + if (_hold_mod & ECORE_EVENT_MODIFIER_CTRL) _hold_count++; + if (_hold_mod & ECORE_EVENT_MODIFIER_ALT) _hold_count++; + if (_hold_mod & ECORE_EVENT_MODIFIER_WIN) _hold_count++; } } @@ -164,26 +201,31 @@ _e_mod_action_cb(E_Object *obj EINA_UNUSED, const char *params) } static void -_e_mod_action_cb_key(E_Object *obj EINA_UNUSED, const char *params, Ecore_Event_Key *ev) +_e_mod_action_cb_key(E_Object *obj EINA_UNUSED, + const char *params, + Ecore_Event_Key *ev) { _e_mod_action(params, ev->modifiers, GO_KEY); } static void -_e_mod_action_cb_mouse(E_Object *obj EINA_UNUSED, const char *params, Ecore_Event_Mouse_Button *ev EINA_UNUSED) +_e_mod_action_cb_mouse(E_Object *obj EINA_UNUSED, + const char *params, + Ecore_Event_Mouse_Button *ev EINA_UNUSED) { _e_mod_action(params, 0, GO_MOUSE); } + /* Module and Gadcon stuff */ typedef struct _Instance Instance; struct _Instance { - E_Gadcon_Client *gcc; - Evas_Object *o_scale; - E_Menu *menu; - Config_Item *conf_item; + E_Gadcon_Client *gcc; + Evas_Object *o_scale; + E_Menu *menu; + Config_Item *conf_item; }; static Eina_List *instances = NULL; @@ -192,28 +234,28 @@ static E_Config_DD *conf_item_edd = NULL; Config *scale_conf = NULL; static const E_Gadcon_Client_Class _gc_class_scale = - { - GADCON_CLIENT_CLASS_VERSION, "scale", - {_gc_init_scale, _gc_shutdown, _gc_orient, _gc_label_scale, _gc_icon, - _gc_id_new, NULL, NULL}, - E_GADCON_CLIENT_STYLE_PLAIN - }; +{ + GADCON_CLIENT_CLASS_VERSION, "scale", + {_gc_init_scale, _gc_shutdown, _gc_orient, _gc_label_scale, _gc_icon, + _gc_id_new, NULL, NULL}, + E_GADCON_CLIENT_STYLE_PLAIN +}; static const E_Gadcon_Client_Class _gc_class_scale_all = - { - GADCON_CLIENT_CLASS_VERSION, "scale-all", - {_gc_init_scale_all, _gc_shutdown, _gc_orient, _gc_label_scale_all, _gc_icon, - _gc_id_new, NULL, NULL}, - E_GADCON_CLIENT_STYLE_PLAIN - }; +{ + GADCON_CLIENT_CLASS_VERSION, "scale-all", + {_gc_init_scale_all, _gc_shutdown, _gc_orient, _gc_label_scale_all, + _gc_icon, _gc_id_new, NULL, NULL}, + E_GADCON_CLIENT_STYLE_PLAIN +}; static const E_Gadcon_Client_Class _gc_class_pager = - { - GADCON_CLIENT_CLASS_VERSION, "scale-pager", - {_gc_init_pager, _gc_shutdown, _gc_orient, _gc_label_pager, _gc_icon, - _gc_id_new, NULL, NULL}, - E_GADCON_CLIENT_STYLE_PLAIN - }; +{ + GADCON_CLIENT_CLASS_VERSION, "scale-pager", + {_gc_init_pager, _gc_shutdown, _gc_orient, _gc_label_pager, _gc_icon, + _gc_id_new, NULL, NULL}, + E_GADCON_CLIENT_STYLE_PLAIN +}; EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Scale"}; @@ -230,7 +272,8 @@ e_modapi_init(E_Module *m) e_configure_registry_category_add("appearance", 80, D_("Look"), NULL, "preferences-look"); - e_configure_registry_item_add("appearance/comp-scale", 110, D_("Composite Scale Windows"), + e_configure_registry_item_add("appearance/comp-scale", 110, + D_("Composite Scale Windows"), NULL, buf, e_int_config_scale_module); conf_item_edd = E_CONFIG_DD_NEW("Config_Item", Config_Item); @@ -276,10 +319,10 @@ e_modapi_init(E_Module *m) scale_conf = e_config_domain_load("module.scale", conf_edd); if (scale_conf) { - if (!e_util_module_config_check(D_("Scale Windows"), - scale_conf->version, - MOD_CONFIG_FILE_VERSION)) - _scale_conf_free(); + if (!e_util_module_config_check(D_("Scale Windows"), + scale_conf->version, + MOD_CONFIG_FILE_VERSION)) + _scale_conf_free(); } if (!scale_conf) _scale_conf_new(); @@ -297,46 +340,50 @@ e_modapi_init(E_Module *m) act = e_action_add("scale-windows"); if (act) { - act->func.go = _e_mod_action_cb; - act->func.go_key = _e_mod_action_cb_key; - act->func.go_mouse = _e_mod_action_cb_mouse; - act->func.go_edge = _e_mod_action_cb_edge; + act->func.go = _e_mod_action_cb; + act->func.go_key = _e_mod_action_cb_key; + act->func.go_mouse = _e_mod_action_cb_mouse; + act->func.go_edge = _e_mod_action_cb_edge; - e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows"), - "scale-windows", "go_scale", NULL, 0); - e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows (All Desktops)"), - "scale-windows", "go_scale_all", NULL, 0); - e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows (By Class)"), - "scale-windows", NULL, "go_scale_class:E", 1); - e_action_predef_name_set(D_("Scale Windows"), D_("Select Next"), - "scale-windows", "go_scale_next", NULL, 0); - e_action_predef_name_set(D_("Scale Windows"), D_("Select Previous"), - "scale-windows", "go_scale_prev", NULL, 0); - e_action_predef_name_set(D_("Scale Windows"), D_("Select Next (All)"), - "scale-windows", "go_scale_all_next", NULL, 0); - e_action_predef_name_set(D_("Scale Windows"), D_("Select Previous (All)"), - "scale-windows", "go_scale_all_prev", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), D_("Scale Windows"), + "scale-windows", "go_scale", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), + D_("Scale Windows (All Desktops)"), + "scale-windows", "go_scale_all", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), + D_("Scale Windows (By Class)"), + "scale-windows", NULL, "go_scale_class:E", 1); + e_action_predef_name_set(D_("Scale Windows"), D_("Select Next"), + "scale-windows", "go_scale_next", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), D_("Select Previous"), + "scale-windows", "go_scale_prev", NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), D_("Select Next (All)"), + "scale-windows", "go_scale_all_next", + NULL, 0); + e_action_predef_name_set(D_("Scale Windows"), + D_("Select Previous (All)"), + "scale-windows", "go_scale_all_prev", NULL, + 0); - e_action_predef_name_set(D_("Scale Pager"), D_("Scale Pager"), - "scale-windows", "go_pager", NULL, 0); - e_action_predef_name_set(D_("Scale Pager"), D_("Select Next"), - "scale-windows", "go_pager_next", NULL, 0); - e_action_predef_name_set(D_("Scale Pager"), D_("Select Previous"), - "scale-windows", "go_pager_prev", NULL, 0); - e_action_predef_name_set(D_("Scale Pager"), D_("Select Left"), - "scale-windows", "go_pager_left", NULL, 0); - e_action_predef_name_set(D_("Scale Pager"), D_("Select Right"), - "scale-windows", "go_pager_right", NULL, 0); - e_action_predef_name_set(D_("Scale Pager"), D_("Select Up"), - "scale-windows", "go_pager_up", NULL, 0); - e_action_predef_name_set(D_("Scale Pager"), D_("Select Down"), - "scale-windows", "go_pager_down", NULL, 0); + e_action_predef_name_set(D_("Scale Pager"), D_("Scale Pager"), + "scale-windows", "go_pager", NULL, 0); + e_action_predef_name_set(D_("Scale Pager"), D_("Select Next"), + "scale-windows", "go_pager_next", NULL, 0); + e_action_predef_name_set(D_("Scale Pager"), D_("Select Previous"), + "scale-windows", "go_pager_prev", NULL, 0); + e_action_predef_name_set(D_("Scale Pager"), D_("Select Left"), + "scale-windows", "go_pager_left", NULL, 0); + e_action_predef_name_set(D_("Scale Pager"), D_("Select Right"), + "scale-windows", "go_pager_right", NULL, 0); + e_action_predef_name_set(D_("Scale Pager"), D_("Select Up"), + "scale-windows", "go_pager_up", NULL, 0); + e_action_predef_name_set(D_("Scale Pager"), D_("Select Down"), + "scale-windows", "go_pager_down", NULL, 0); } return m; } - EAPI int e_modapi_shutdown(E_Module *m EINA_UNUSED) { @@ -373,20 +420,22 @@ e_modapi_shutdown(E_Module *m EINA_UNUSED) if (act) { - e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows")); - e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows (All Desktops)")); - e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows (By Class)")); - e_action_predef_name_del(D_("Scale Windows"), D_("Select Next")); - e_action_predef_name_del(D_("Scale Windows"), D_("Select Previous")); + e_action_predef_name_del(D_("Scale Windows"), D_("Scale Windows")); + e_action_predef_name_del(D_("Scale Windows"), + D_("Scale Windows (All Desktops)")); + e_action_predef_name_del(D_("Scale Windows"), + D_("Scale Windows (By Class)")); + e_action_predef_name_del(D_("Scale Windows"), D_("Select Next")); + e_action_predef_name_del(D_("Scale Windows"), D_("Select Previous")); - e_action_predef_name_del(D_("Scale Pager"), D_("Scale Pager")); - e_action_predef_name_del(D_("Scale Pager"), D_("Select Next")); - e_action_predef_name_del(D_("Scale Pager"), D_("Select Previous")); - e_action_predef_name_del(D_("Scale Pager"), D_("Select Left")); - e_action_predef_name_del(D_("Scale Pager"), D_("Select Right")); - e_action_predef_name_del(D_("Scale Pager"), D_("Select Up")); - e_action_predef_name_del(D_("Scale Pager"), D_("Select Down")); - e_action_del("scale-windows"); + e_action_predef_name_del(D_("Scale Pager"), D_("Scale Pager")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Next")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Previous")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Left")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Right")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Up")); + e_action_predef_name_del(D_("Scale Pager"), D_("Select Down")); + e_action_del("scale-windows"); } return 1; @@ -412,14 +461,16 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style) inst->gcc = e_gadcon_client_new(gc, name, id, style, inst->o_scale); inst->gcc->data = inst; - instances = eina_list_append(instances, inst); return inst; } static E_Gadcon_Client * -_gc_init_pager(E_Gadcon *gc, const char *name, const char *id, const char *style) +_gc_init_pager(E_Gadcon *gc, + const char *name, + const char *id, + const char *style) { Instance *inst; @@ -427,7 +478,8 @@ _gc_init_pager(E_Gadcon *gc, const char *name, const char *id, const char *style if (!e_theme_edje_object_set(inst->o_scale, "base/theme/modules/scale", "modules/pager/main")) - edje_object_file_set(inst->o_scale, scale_conf->theme_path, "modules/pager/main"); + edje_object_file_set(inst->o_scale, scale_conf->theme_path, + "modules/pager/main"); evas_object_event_callback_add(inst->o_scale, EVAS_CALLBACK_MOUSE_DOWN, _scale_gc_cb_mouse_down_pager, inst); @@ -436,7 +488,10 @@ _gc_init_pager(E_Gadcon *gc, const char *name, const char *id, const char *style } static E_Gadcon_Client * -_gc_init_scale(E_Gadcon *gc, const char *name, const char *id, const char *style) +_gc_init_scale(E_Gadcon *gc, + const char *name, + const char *id, + const char *style) { Instance *inst; @@ -444,7 +499,8 @@ _gc_init_scale(E_Gadcon *gc, const char *name, const char *id, const char *style if (!e_theme_edje_object_set(inst->o_scale, "base/theme/modules/scale", "modules/scale/main")) - edje_object_file_set(inst->o_scale, scale_conf->theme_path, "modules/scale/main"); + edje_object_file_set + (inst->o_scale, scale_conf->theme_path, "modules/scale/main"); evas_object_event_callback_add(inst->o_scale, EVAS_CALLBACK_MOUSE_DOWN, _scale_gc_cb_mouse_down_scale, inst); @@ -453,7 +509,10 @@ _gc_init_scale(E_Gadcon *gc, const char *name, const char *id, const char *style } static E_Gadcon_Client * -_gc_init_scale_all(E_Gadcon *gc, const char *name, const char *id, const char *style) +_gc_init_scale_all(E_Gadcon *gc, + const char *name, + const char *id, + const char *style) { Instance *inst; @@ -461,7 +520,8 @@ _gc_init_scale_all(E_Gadcon *gc, const char *name, const char *id, const char *s if (!e_theme_edje_object_set(inst->o_scale, "base/theme/modules/scale", "modules/scale/main")) - edje_object_file_set(inst->o_scale, scale_conf->theme_path, "modules/scale/main"); + edje_object_file_set + (inst->o_scale, scale_conf->theme_path, "modules/scale/main"); evas_object_event_callback_add(inst->o_scale, EVAS_CALLBACK_MOUSE_DOWN, _scale_gc_cb_mouse_down_scale_all, inst); @@ -485,8 +545,6 @@ _gc_shutdown(E_Gadcon_Client *gcc) } if (inst->o_scale) { - /* evas_object_event_callback_del(inst->o_scale, EVAS_CALLBACK_MOUSE_DOWN, - * _scale_gc_cb_mouse_down); */ evas_object_del(inst->o_scale); } E_FREE(inst); @@ -547,28 +605,28 @@ _scale_conf_new(void) #define IFMODCFG(v) if ((scale_conf->version & 0xffff) < v) { #define IFMODCFGEND } - IFMODCFG(0x0001); - scale_conf->grow = 1; - scale_conf->tight = 1; - scale_conf->scale_duration = 0.4; - scale_conf->spacing = 10; - scale_conf->fade_windows = 1; - scale_conf->fade_popups = 0; - scale_conf->fade_desktop = 1; - scale_conf->desks_duration = 0.6; - scale_conf->desks_spacing = 44; - scale_conf->layout_mode = 0; - scale_conf->desks_layout_mode = 1; - scale_conf->pager_duration = 0.4; - scale_conf->pager_fade_popups = 1; - scale_conf->pager_fade_desktop = 0; - scale_conf->pager_fade_windows = 1; - _scale_conf_item_get(NULL); - IFMODCFGEND; + IFMODCFG(0x0001); + scale_conf->grow = 1; + scale_conf->tight = 1; + scale_conf->scale_duration = 0.4; + scale_conf->spacing = 10; + scale_conf->fade_windows = 1; + scale_conf->fade_popups = 0; + scale_conf->fade_desktop = 1; + scale_conf->desks_duration = 0.6; + scale_conf->desks_spacing = 44; + scale_conf->layout_mode = 0; + scale_conf->desks_layout_mode = 1; + scale_conf->pager_duration = 0.4; + scale_conf->pager_fade_popups = 1; + scale_conf->pager_fade_desktop = 0; + scale_conf->pager_fade_windows = 1; + _scale_conf_item_get(NULL); + IFMODCFGEND; - scale_conf->version = MOD_CONFIG_FILE_VERSION; + scale_conf->version = MOD_CONFIG_FILE_VERSION; - e_config_save_queue(); + e_config_save_queue(); } static void @@ -591,10 +649,11 @@ _scale_conf_free(void) static Config_Item * _scale_conf_item_get(const char *id) -{; +{ Config_Item *ci; - GADCON_CLIENT_CONFIG_GET(Config_Item, scale_conf->conf_items, _gc_class_scale, id); + GADCON_CLIENT_CONFIG_GET + (Config_Item, scale_conf->conf_items, _gc_class_scale, id); ci = E_NEW(Config_Item, 1); ci->id = eina_stringshare_add(id); @@ -610,7 +669,7 @@ _scale_gc_menu(Instance *inst, Evas_Event_Mouse_Down *ev) E_Menu_Item *mi; E_Zone *zone = NULL; int x, y; - + m = e_menu_new(); mi = e_menu_item_new(m); e_menu_item_label_set(mi, D_("Settings")); @@ -621,18 +680,17 @@ _scale_gc_menu(Instance *inst, Evas_Event_Mouse_Down *ev) inst->menu = m; e_menu_post_deactivate_callback_set(m, _scale_gc_cb_menu_post, inst); - + e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, - NULL, NULL); + NULL, NULL); zone = e_util_zone_current_get(e_manager_current_get()); - - e_menu_activate_mouse(m, zone, (x + ev->output.x), - (y + ev->output.y), 1, 1, - E_MENU_POP_DIRECTION_AUTO, ev->timestamp); - evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, - EVAS_BUTTON_NONE, ev->timestamp, NULL); + e_menu_activate_mouse(m, zone, (x + ev->output.x), + (y + ev->output.y), 1, 1, + E_MENU_POP_DIRECTION_AUTO, ev->timestamp); + evas_event_feed_mouse_up(inst->gcc->gadcon->evas, ev->button, + EVAS_BUTTON_NONE, ev->timestamp, NULL); } static void @@ -689,7 +747,6 @@ _scale_gc_cb_mouse_down_pager(void *data, _scale_gc_menu(inst, ev); } - static void _scale_gc_cb_menu_post(void *data, E_Menu *menu EINA_UNUSED) { @@ -710,4 +767,3 @@ _scale_gc_cb_menu_configure(void *data EINA_UNUSED, if (scale_conf->cfd) return; e_int_config_scale_module(mn->zone->container, NULL); } - diff --git a/src/e_mod_pager.c b/src/e_mod_pager.c index 2322a3c..0278a69 100644 --- a/src/e_mod_pager.c +++ b/src/e_mod_pager.c @@ -7,51 +7,73 @@ typedef struct _Item Item; struct _Item { - Evas_Object *o, *o_win; - E_Border *bd; - E_Desk *desk; - E_Comp_Win *src; - E_Manager *man; + Evas_Object *o, *o_win; + E_Border *bd; + E_Desk *desk; + E_Comp_Win *src; + E_Manager *man; - double x; - double y; - double w; - double h; + double x; + double y; + double w; + double h; - double mx; - double my; + double mx; + double my; - /* border origin (is moved when scale on another desk) */ - double bd_x; - double bd_y; + /* border origin (is moved when scale on another desk) */ + double bd_x; + double bd_y; - /* current position to draw by compositor */ - int cur_x, cur_y, cur_w, cur_h; + /* current position to draw by compositor */ + int cur_x, cur_y, cur_w, cur_h; - /* borders' desk distance to the current desk */ - int dx, dy; + /* borders' desk distance to the current desk */ + int dx, dy; - int mouse_down; - int moved; + int mouse_down; + int moved; }; static Eina_Bool _pager_cb_mouse_down(void *data, int type, void *event); static Eina_Bool _pager_cb_mouse_up(void *data, int type, void *event); static Eina_Bool _pager_cb_mouse_move(void *data, int type, void *event); -static void _pager_win_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _pager_win_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _pager_win_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _pager_win_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _pager_win_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _pager_win_cb_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _pager_win_cb_mouse_in(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _pager_win_cb_mouse_out(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _pager_win_cb_mouse_down(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _pager_win_cb_mouse_up(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _pager_win_cb_mouse_move(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _pager_win_cb_delorig(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); -static Item *_pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src); -static void _pager_win_del(Item *it); - -static void _pager_finish(); -static void _pager_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata); +static Item *_pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src); +static void _pager_win_del(Item *it); +static void _pager_finish(); +static void _pager_handler(void *data, + const char *name, + const char *info, + int val, + E_Object *obj, + void *msgdata); static Ecore_X_Window input_win = 0; static E_Msg_Handler *msg_handler = NULL; @@ -92,28 +114,28 @@ _pager_place_desks(double scale) for (y = 0; y < zone->desk_y_count; y++) { - for (x = 0; x < zone->desk_x_count; x++) - { - double x1 = (x - initial_desk->x) * zone_w; - double y1 = (y - initial_desk->y) * zone_h; - double x2 = min_x + x * desk_w; - double y2 = min_y + y * desk_h; - double cur_x = (scale * x1) + (1.0 - scale) * x2; - double cur_y = (scale * y1) + (1.0 - scale) * y2; + for (x = 0; x < zone->desk_x_count; x++) + { + double x1 = (x - initial_desk->x) * zone_w; + double y1 = (y - initial_desk->y) * zone_h; + double x2 = min_x + x * desk_w; + double y2 = min_y + y * desk_h; + double cur_x = (scale * x1) + (1.0 - scale) * x2; + double cur_y = (scale * y1) + (1.0 - scale) * y2; - Evas_Object *o = eina_list_data_get(l); + Evas_Object *o = eina_list_data_get(l); - int w = (scale * (zone->w)) + (1.0 - scale) * desk_w - OFFSET; - int h = (scale * (zone->h)) + (1.0 - scale) * desk_h - OFFSET; + int w = (scale * (zone->w)) + (1.0 - scale) * desk_w - OFFSET; + int h = (scale * (zone->h)) + (1.0 - scale) * desk_h - OFFSET; - evas_object_move(o, cur_x, cur_y); - evas_object_resize(o, w, h); + evas_object_move(o, cur_x, cur_y); + evas_object_resize(o, w, h); - if (scale_conf->pager_fade_desktop) - evas_object_color_set(o, a, a, a, a); + if (scale_conf->pager_fade_desktop) + evas_object_color_set(o, a, a, a, a); - l = eina_list_next(l); - } + l = eina_list_next(l); + } } } @@ -125,14 +147,16 @@ _pager_place_windows(double scale) EINA_LIST_FOREACH(items, l, it) { - if (!it->o) continue; - it->cur_x = it->bd_x * scale + it->x * (1.0 - scale); - it->cur_y = it->bd_y * scale + it->y * (1.0 - scale); - it->cur_w = (double)(it->bd_x + it->bd->w) * scale + (it->x + it->w) * (1.0 - scale) - it->cur_x; - it->cur_h = (double)(it->bd_y + it->bd->h) * scale + (it->y + it->h) * (1.0 - scale) - it->cur_y; + if (!it->o) continue; + it->cur_x = it->bd_x * scale + it->x * (1.0 - scale); + it->cur_y = it->bd_y * scale + it->y * (1.0 - scale); + it->cur_w = (double)(it->bd_x + it->bd->w) * + scale + (it->x + it->w) * (1.0 - scale) - it->cur_x; + it->cur_h = (double)(it->bd_y + it->bd->h) * + scale + (it->y + it->h) * (1.0 - scale) - it->cur_y; - evas_object_move(it->o, it->cur_x, it->cur_y); - evas_object_resize(it->o, it->cur_w, it->cur_h); + evas_object_move(it->o, it->cur_x, it->cur_y); + evas_object_resize(it->o, it->cur_w, it->cur_h); } } @@ -144,38 +168,37 @@ _pager_redraw(void *data EINA_UNUSED) Eina_List *l; Item *it; - if (scale_state == SCALE_STATE_HOLD) { E_Manager *man = e_manager_current_get(); e_comp_update(man->comp); - return ECORE_CALLBACK_RENEW; + return ECORE_CALLBACK_RENEW; } in = (ecore_loop_time_get() - start_time) / scale_conf->pager_duration; if (in >= 1.0) { - if (scale_state == SCALE_STATE_IN) - { - in = 0.0; - scale_state = SCALE_STATE_HOLD; - } - else - { - in = 1.0; - finish = EINA_TRUE; - } + if (scale_state == SCALE_STATE_IN) + { + in = 0.0; + scale_state = SCALE_STATE_HOLD; + } + else + { + in = 1.0; + finish = EINA_TRUE; + } } else if (scale_state) { - in = log(14) * in; - in = 1.0 / exp(in*in); + in = log(14) * in; + in = 1.0 / exp(in * in); } else { - in = log(14) * (1.0 - in); - in = 1.0 / exp(in*in); + in = log(14) * (1.0 - in); + in = 1.0 / exp(in * in); } _pager_place_desks(in); @@ -183,46 +206,46 @@ _pager_redraw(void *data EINA_UNUSED) if (scale_conf->pager_fade_windows) { - EINA_LIST_FOREACH(items, l, it) - { - double a = 255.0; + EINA_LIST_FOREACH(items, l, it) + { + double a = 255.0; - if (!it->o) continue; + if (!it->o) continue; - if ((it->desk != current_desk) && (it->desk != previous_desk)) - a = 255.0 * (1.0 - in); + if ((it->desk != current_desk) && (it->desk != previous_desk)) + a = 255.0 * (1.0 - in); - evas_object_color_set(it->o, a, a, a, a); - } + evas_object_color_set(it->o, a, a, a, a); + } } double a = 255.0 * in; if (scale_conf->pager_fade_popups) { - EINA_LIST_FOREACH(popups, l, it) - evas_object_color_set(it->o_win, a, a, a, a); + EINA_LIST_FOREACH(popups, l, it) + evas_object_color_set(it->o_win, a, a, a, a); } EINA_LIST_FOREACH(items, l, it) { - if (it->o) continue; - evas_object_color_set(it->o_win, a, a, a, a); + if (it->o) continue; + evas_object_color_set(it->o_win, a, a, a, a); } if (scale_conf->pager_fade_desktop) { - double a = (1.0 - in) * 155.0; - evas_object_color_set(bg_over, 0, 0, 0, a); + double a = (1.0 - in) * 155.0; + evas_object_color_set(bg_over, 0, 0, 0, a); } /* e_manager_comp_evas_update(e_manager_current_get()); */ if (finish) { - scale_animator = NULL; - _pager_finish(); - return ECORE_CALLBACK_CANCEL; + scale_animator = NULL; + _pager_finish(); + return ECORE_CALLBACK_CANCEL; } return ECORE_CALLBACK_RENEW; @@ -237,6 +260,7 @@ _pager_in() if (!scale_animator) scale_animator = ecore_animator_add(_pager_redraw, NULL); } + static void _pager_out() { @@ -257,10 +281,10 @@ _pager_out() EINA_LIST_FOREACH(items, l, it) { - edje_object_signal_emit(it->o, "hide", "e"); - /* edje_object_signal_emit(it->o, "mouse,in", "e"); */ - it->bd_x = it->bd->x + (it->desk->x - current_desk->x) * zone_w; - it->bd_y = it->bd->y + (it->desk->y - current_desk->y) * zone_h; + edje_object_signal_emit(it->o, "hide", "e"); + /* edje_object_signal_emit(it->o, "mouse,in", "e"); */ + it->bd_x = it->bd->x + (it->desk->x - current_desk->x) * zone_w; + it->bd_y = it->bd->y + (it->desk->y - current_desk->y) * zone_h; } initial_desk = current_desk; @@ -280,26 +304,26 @@ _pager_finish() EINA_LIST_FOREACH(items, l, it) { - if (it->desk == it->bd->desk) - continue; + if (it->desk == it->bd->desk) + continue; - /* dont hide border - hack */ - //if (it->desk == current_desk) + /* dont hide border - hack */ + //if (it->desk == current_desk) // it->bd->visible = 0; - e_border_desk_set(it->bd, it->desk); + e_border_desk_set(it->bd, it->desk); - // if (it->desk == current_desk) - // it->bd->visible = 1; + // if (it->desk == current_desk) + // it->bd->visible = 1; } if ((current_desk) && (desk != current_desk)) { - /* dont do flip animation */ - int tmp = e_config->desk_flip_animate_mode; - e_config->desk_flip_animate_mode = 0; - e_desk_show(current_desk); - e_config->desk_flip_animate_mode = tmp; + /* dont do flip animation */ + int tmp = e_config->desk_flip_animate_mode; + e_config->desk_flip_animate_mode = 0; + e_desk_show(current_desk); + e_config->desk_flip_animate_mode = tmp; } EINA_LIST_FREE(items, it) @@ -310,10 +334,10 @@ _pager_finish() EINA_LIST_FREE(desks, o) { - oo = edje_object_part_swallow_get(o, "e.swallow.desk"); - if (oo) evas_object_del(oo); + oo = edje_object_part_swallow_get(o, "e.swallow.desk"); + if (oo) evas_object_del(oo); - evas_object_del(o); + evas_object_del(o); } EINA_LIST_FREE(handlers, handler) @@ -358,8 +382,9 @@ _pager_desk_select(E_Desk *desk) if (current_desk && (desk != current_desk)) { - o_desk = eina_list_nth(desks, current_desk->y * zone->desk_x_count + current_desk->x); - edje_object_signal_emit(o_desk, "unfocused", "e"); + o_desk = eina_list_nth(desks, current_desk->y * + zone->desk_x_count + current_desk->x); + edje_object_signal_emit(o_desk, "unfocused", "e"); } previous_desk = current_desk; @@ -383,22 +408,22 @@ _pager_win_cb_mouse_down(void *data, if ((ev->button == 2) || (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)) { - selected_item = it; + selected_item = it; - if (current_desk != it->desk) - _pager_desk_select(it->desk); + if (current_desk != it->desk) + _pager_desk_select(it->desk); - _pager_out(); - return; + _pager_out(); + return; } else if (ev->button == 1) { - e_border_raise(it->bd); + e_border_raise(it->bd); - evas_object_raise(it->o); + evas_object_raise(it->o); - if (current_desk != it->desk) - _pager_desk_select(it->desk); + if (current_desk != it->desk) + _pager_desk_select(it->desk); } it->mx = ev->canvas.x; @@ -494,39 +519,39 @@ _pager_win_cb_mouse_move(void *data, if ((!it->bd->fullscreen) && (!it->bd->maximized)) { - it->x = x; - it->y = y; - it->cur_x = x; - it->cur_y = y; + it->x = x; + it->y = y; + it->cur_x = x; + it->cur_y = y; - it->bd_x = ((it->x * zoom) - min_x * zoom); - it->bd_y = ((it->y * zoom) - min_y * zoom); + it->bd_x = ((it->x * zoom) - min_x * zoom); + it->bd_y = ((it->y * zoom) - min_y * zoom); - x = (int)(it->bd_x) % (int)zone_w; - y = (int)(it->bd_y) % (int)zone_h; + x = (int)(it->bd_x) % (int)zone_w; + y = (int)(it->bd_y) % (int)zone_h; - if ((desk2 = _pager_desk_at_xy_get(it->x, it->y))) - { - x += (desk2->x - desk->x) * zone_w + zone_x; - y += (desk2->y - desk->y) * zone_h + zone_y; - } + if ((desk2 = _pager_desk_at_xy_get(it->x, it->y))) + { + x += (desk2->x - desk->x) * zone_w + zone_x; + y += (desk2->y - desk->y) * zone_h + zone_y; + } - if (current_desk != desk) - _pager_desk_select(desk); + if (current_desk != desk) + _pager_desk_select(desk); - e_border_move(it->bd, x, y); + e_border_move(it->bd, x, y); - it->desk = desk; + it->desk = desk; } else if (desk && (desk != it->desk)) { - it->desk = desk; + it->desk = desk; - _pager_desk_select(desk); - _pager_win_final_position_set(it); + _pager_desk_select(desk); + _pager_win_final_position_set(it); - it->cur_x = it->x; - it->cur_y = it->y; + it->cur_x = it->x; + it->cur_y = it->y; } evas_object_move(it->o, it->cur_x, it->cur_y); @@ -550,14 +575,14 @@ _pager_win_cb_mouse_in(void *data, if (selected_item && (it != selected_item)) { - edje_object_signal_emit(selected_item->o, "mouse,out", "e"); - selected_item = NULL; + edje_object_signal_emit(selected_item->o, "mouse,out", "e"); + selected_item = NULL; } if (it != selected_item) { - edje_object_signal_emit(it->o, "mouse,in", "e"); - selected_item = it; + edje_object_signal_emit(it->o, "mouse,in", "e"); + selected_item = it; } } @@ -574,8 +599,8 @@ _pager_win_cb_mouse_out(void *data, if (selected_item == it) { - edje_object_signal_emit(it->o, "mouse,out", "e"); - selected_item = NULL; + edje_object_signal_emit(it->o, "mouse,out", "e"); + selected_item = NULL; } } @@ -599,45 +624,44 @@ static void _pager_win_del(Item *it) { evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, - _pager_win_cb_delorig); + _pager_win_cb_delorig); if (it->bd && !it->o) { - e_comp_src_hidden_set(it->src, EINA_FALSE); + e_comp_src_hidden_set(it->src, EINA_FALSE); - e_object_unref(E_OBJECT(it->bd)); + e_object_unref(E_OBJECT(it->bd)); } else if (it->bd) { - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_IN, - _pager_win_cb_mouse_in); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_IN, + _pager_win_cb_mouse_in); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_OUT, - _pager_win_cb_mouse_out); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_OUT, + _pager_win_cb_mouse_out); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_DOWN, - _pager_win_cb_mouse_down); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_DOWN, + _pager_win_cb_mouse_down); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_UP, - _pager_win_cb_mouse_up); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_UP, + _pager_win_cb_mouse_up); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_MOVE, - _pager_win_cb_mouse_move); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_MOVE, + _pager_win_cb_mouse_move); + if ((it->bd->desk != current_desk) && (!it->bd->sticky)) + e_border_hide(it->bd, 2); - if ((it->bd->desk != current_desk) && (!it->bd->sticky)) - e_border_hide(it->bd, 2); + e_comp_src_hidden_set(it->src, EINA_FALSE); - e_comp_src_hidden_set(it->src, EINA_FALSE); + evas_object_del(it->o_win); + evas_object_del(it->o); - evas_object_del(it->o_win); - evas_object_del(it->o); - - e_object_unref(E_OBJECT(it->bd)); + e_object_unref(E_OBJECT(it->bd)); } else { - evas_object_color_set(it->o_win, 255, 255, 255, 255); + evas_object_color_set(it->o_win, 255, 255, 255, 255); } E_FREE(it); @@ -649,7 +673,7 @@ _pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src) Item *it; Evas_Object *o, *sh_obj, *obj; E_Border *bd; - + sh_obj = e_comp_src_shadow_get(src); if (!sh_obj) return NULL; @@ -657,48 +681,48 @@ _pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src) if (!obj) return NULL; bd = e_comp_src_border_get(src); - + if (!bd) { Ecore_X_Window win = e_comp_src_window_get(src); - - if (win == zone->container->bg_win) - { - smooth = evas_object_image_smooth_scale_get(obj); - o = evas_object_rectangle_add(e); - evas_object_move(o, zone->x, zone->y); - evas_object_resize(o, zone->w, zone->h); - evas_object_show(o); - bg_over = o; + if (win == zone->container->bg_win) + { + smooth = evas_object_image_smooth_scale_get(obj); - evas_object_stack_above(bg_over, sh_obj); + o = evas_object_rectangle_add(e); + evas_object_move(o, zone->x, zone->y); + evas_object_resize(o, zone->w, zone->h); + evas_object_show(o); + bg_over = o; - if (scale_conf->pager_fade_desktop) - evas_object_color_set(bg_over, 0, 0, 0, 0); - else - evas_object_color_set(bg_over, 0, 0, 0, 255); + evas_object_stack_above(bg_over, sh_obj); - return NULL; - } - else if (scale_conf->pager_fade_popups) - { + if (scale_conf->pager_fade_desktop) + evas_object_color_set(bg_over, 0, 0, 0, 0); + else + evas_object_color_set(bg_over, 0, 0, 0, 255); + + return NULL; + } + else if (scale_conf->pager_fade_popups) + { E_Popup *pop = e_comp_src_popup_get(src); - - if ((pop) && (pop->zone != zone)) - return NULL; - it = E_NEW(Item, 1); - it->man = man; - it->o_win = sh_obj; - it->src = src; - evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _pager_win_cb_delorig, it); + if ((pop) && (pop->zone != zone)) + return NULL; - popups = eina_list_append(popups, it); - return it; - } - return NULL; + it = E_NEW(Item, 1); + it->man = man; + it->o_win = sh_obj; + it->src = src; + evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, + _pager_win_cb_delorig, it); + + popups = eina_list_append(popups, it); + return it; + } + return NULL; } if (bd->zone != zone) @@ -719,9 +743,10 @@ _pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src) items = eina_list_append(items, it); evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _pager_win_cb_delorig, it); + _pager_win_cb_delorig, it); - if ((it->bd->client.netwm.state.skip_pager) || (e_mod_border_ignore(it->bd))) + if ((it->bd->client.netwm.state.skip_pager) || + (e_mod_border_ignore(it->bd))) return NULL; it->o_win = e_comp_src_image_mirror_add(src); @@ -732,9 +757,9 @@ _pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src) it->o = edje_object_add(e); if (!e_theme_edje_object_set(it->o, "base/theme/modules/scale", - "modules/scale/win")) + "modules/scale/win")) edje_object_file_set(it->o, scale_conf->theme_path, - "modules/scale/win"); + "modules/scale/win"); evas_object_stack_above(it->o, it->o_win); evas_object_show(it->o); @@ -742,19 +767,19 @@ _pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src) evas_object_clip_set(it->o, zone_clip); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_IN, - _pager_win_cb_mouse_in, it); + _pager_win_cb_mouse_in, it); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_OUT, - _pager_win_cb_mouse_out, it); + _pager_win_cb_mouse_out, it); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_DOWN, - _pager_win_cb_mouse_down, it); + _pager_win_cb_mouse_down, it); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_UP, - _pager_win_cb_mouse_up, it); + _pager_win_cb_mouse_up, it); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_MOVE, - _pager_win_cb_mouse_move, it); + _pager_win_cb_mouse_move, it); it->dx = it->desk->x - current_desk->x; it->dy = it->desk->y - current_desk->y; @@ -775,8 +800,8 @@ _pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src) _pager_win_final_position_set(it); - it->w = (double)it->bd->w / zoom - OFFSET*2.0; - it->h = (double)it->bd->h / zoom - OFFSET*2.0; + it->w = (double)it->bd->w / zoom - OFFSET * 2.0; + it->h = (double)it->bd->h / zoom - OFFSET * 2.0; edje_object_part_text_set(it->o, "e.text.label", e_border_name_get(it->bd)); edje_object_signal_emit(it->o, "show", "e"); @@ -785,8 +810,8 @@ _pager_win_new(Evas *e, E_Manager *man, E_Comp_Win *src) edje_object_signal_emit(it->o, "mouse,out", "e"); else { - edje_object_signal_emit(it->o, "mouse,in", "e"); - selected_item = it; + edje_object_signal_emit(it->o, "mouse,in", "e"); + selected_item = it; } if (scale_state) @@ -808,16 +833,16 @@ _pager_cb_mouse_move(void *data, int type EINA_UNUSED, void *event) if (mouse_x < 0) { - mouse_x = ev->x; - mouse_y = ev->y; - return ECORE_CALLBACK_PASS_ON; + mouse_x = ev->x; + mouse_y = ev->y; + return ECORE_CALLBACK_PASS_ON; } if ((mouse_x == ev->x) || (mouse_y == ev->y)) return ECORE_CALLBACK_PASS_ON; mouse_activated = 1; - evas_event_feed_mouse_move((Evas *) data, ev->x, ev->y, - ev->timestamp, NULL); + evas_event_feed_mouse_move((Evas *)data, ev->x, ev->y, + ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; } @@ -835,7 +860,7 @@ _pager_cb_mouse_up(void *data, int type EINA_UNUSED, void *event) return ECORE_CALLBACK_PASS_ON; evas_event_feed_mouse_up((Evas *)data, ev->buttons, - flags, ev->timestamp, NULL); + flags, ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; } @@ -856,28 +881,28 @@ _pager_cb_mouse_down(void *data, int type EINA_UNUSED, void *event) EINA_LIST_FOREACH(items, l, it) if (E_INTERSECTS(ev->x, ev->y, 1, 1, - it->x, it->y, it->w, it->h)) + it->x, it->y, it->w, it->h)) break; if (!it) { - if (E_INSIDE(ev->x, ev->y, min_x, min_y, - (max_x - min_x) - OFFSET*2, - (max_y - min_y) - OFFSET*2)) - { - E_Desk *desk = _pager_desk_at_xy_get(ev->x, ev->y); - if (desk) - _pager_desk_select(desk); - } + if (E_INSIDE(ev->x, ev->y, min_x, min_y, + (max_x - min_x) - OFFSET * 2, + (max_y - min_y) - OFFSET * 2)) + { + E_Desk *desk = _pager_desk_at_xy_get(ev->x, ev->y); + if (desk) + _pager_desk_select(desk); + } - _pager_out(); - return ECORE_CALLBACK_PASS_ON; + _pager_out(); + return ECORE_CALLBACK_PASS_ON; } if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK; if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK; evas_event_feed_mouse_down((Evas *)data, ev->buttons, flags, - ev->timestamp, NULL); + ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; } @@ -885,14 +910,14 @@ _pager_cb_mouse_down(void *data, int type EINA_UNUSED, void *event) static void _pager_switch(const char *params) { - int max_x,max_y, desk_x, desk_y; + int max_x, max_y, desk_x, desk_y; int x = 0, y = 0; E_Desk *desk; if (!params[0]) { - _pager_out(); - return; + _pager_out(); + return; } e_zone_desk_count_get(zone, &max_x, &max_y); @@ -907,15 +932,15 @@ _pager_switch(const char *params) y = 1; else if (!strcmp(params, "_next")) { - x = 1; - if (current_desk->x == max_x - 1) - y = 1; + x = 1; + if (current_desk->x == max_x - 1) + y = 1; } else if (!strcmp(params, "_prev")) { - x = -1; - if (current_desk->x == 0) - y = -1; + x = -1; + if (current_desk->x == 0) + y = -1; } desk_x = current_desk->x + x; @@ -940,14 +965,14 @@ _pager_switch(const char *params) * Item *it; * * EINA_LIST_FOREACH(items, l, it) - * evas_object_color_set(it->o, 255.0, 255.0, 255.0, 255.0); + * evas_object_color_set(it->o, 255.0, 255.0, 255.0, 255.0); * } */ } static Eina_Bool _pager_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { - Ecore_Event_Key *ev = event; + Ecore_Event_Key *ev = event; if (ev->window != input_win) return ECORE_CALLBACK_PASS_ON; @@ -970,43 +995,45 @@ _pager_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) _pager_out(); else if (!strcmp(ev->key, "Escape")) { - _pager_desk_select(e_desk_current_get(zone)); - _pager_out(); + _pager_desk_select(e_desk_current_get(zone)); + _pager_out(); } else { - E_Action *act; - Eina_List *l; - E_Config_Binding_Key *bind; - E_Binding_Modifier mod; + E_Action *act; + Eina_List *l; + E_Config_Binding_Key *bind; + E_Binding_Modifier mod; - for (l = e_config->key_bindings; l; l = l->next) - { - bind = l->data; - mod = 0; + for (l = e_config->key_bindings; l; l = l->next) + { + bind = l->data; + mod = 0; - if (bind->action && strcmp(bind->action, "scale-windows")) continue; - if (!bind->params || strncmp(bind->params, "go_pager", 8)) continue; + if (bind->action && strcmp(bind->action, "scale-windows")) + continue; + if (!bind->params || strncmp(bind->params, "go_pager", 8)) + continue; - if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) + if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) mod |= E_BINDING_MODIFIER_SHIFT; - if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) + if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) mod |= E_BINDING_MODIFIER_CTRL; - if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) + if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) mod |= E_BINDING_MODIFIER_ALT; - if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN) + if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN) mod |= E_BINDING_MODIFIER_WIN; - if (bind->key && (!strcmp(bind->key, ev->keyname)) && - ((bind->modifiers == mod) || (bind->any_mod))) - { - if (!(act = e_action_find(bind->action))) continue; - if (act->func.go_key) - act->func.go_key(E_OBJECT(zone), bind->params, ev); - else if (act->func.go) - act->func.go(E_OBJECT(zone), bind->params); - } - } + if (bind->key && (!strcmp(bind->key, ev->keyname)) && + ((bind->modifiers == mod) || (bind->any_mod))) + { + if (!(act = e_action_find(bind->action))) continue; + if (act->func.go_key) + act->func.go_key(E_OBJECT(zone), bind->params, ev); + else if (act->func.go) + act->func.go(E_OBJECT(zone), bind->params); + } + } } return ECORE_CALLBACK_PASS_ON; } @@ -1014,18 +1041,18 @@ _pager_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) static Eina_Bool _pager_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { - Ecore_Event_Key *ev = event; + Ecore_Event_Key *ev = event; - if (ev->window != input_win) - return ECORE_CALLBACK_PASS_ON; + if (ev->window != input_win) + return ECORE_CALLBACK_PASS_ON; - if (scale_state == SCALE_STATE_OUT) - return ECORE_CALLBACK_PASS_ON; + if (scale_state == SCALE_STATE_OUT) + return ECORE_CALLBACK_PASS_ON; - if (!e_mod_hold_modifier_check(event)) - _pager_out(); + if (!e_mod_hold_modifier_check(event)) + _pager_out(); - return ECORE_CALLBACK_PASS_ON; + return ECORE_CALLBACK_PASS_ON; } static Eina_Bool @@ -1039,7 +1066,6 @@ _pager_run(E_Manager *man) int x, y; Item *it; - mouse_activated = 0; mouse_x = -1; mouse_y = -1; @@ -1058,32 +1084,32 @@ _pager_run(E_Manager *man) return EINA_FALSE; input_win = ecore_x_window_input_new(zone->container->win, - 0, 0, 1, 1); + 0, 0, 1, 1); ecore_x_window_show(input_win); if (!e_grabinput_get(input_win, 0, input_win)) { - ecore_x_window_free(input_win); - input_win = 0; - return EINA_FALSE; + ecore_x_window_free(input_win); + input_win = 0; + return EINA_FALSE; } msg_handler = e_msg_handler_add(_pager_handler, NULL); h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, - _pager_cb_mouse_down, e); + _pager_cb_mouse_down, e); handlers = eina_list_append(handlers, h); h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, - _pager_cb_mouse_up, e); + _pager_cb_mouse_up, e); handlers = eina_list_append(handlers, h); h = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, - _pager_cb_mouse_move, e); + _pager_cb_mouse_move, e); handlers = eina_list_append(handlers, h); h = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, - _pager_cb_key_down, e); + _pager_cb_key_down, e); handlers = eina_list_append(handlers, h); h = ecore_event_handler_add(ECORE_EVENT_KEY_UP, - _pager_cb_key_up, e); + _pager_cb_key_up, e); handlers = eina_list_append(handlers, h); zoom = zone->desk_x_count; @@ -1092,19 +1118,19 @@ _pager_run(E_Manager *man) if (scale_conf->pager_keep_shelves) { - int x, y, w, h; - e_zone_useful_geometry_get(zone, &x, &y, &w, &h); - zone_w = w; - zone_h = h; - zone_x = zone->x + x; - zone_y = zone->y + y; + int x, y, w, h; + e_zone_useful_geometry_get(zone, &x, &y, &w, &h); + zone_w = w; + zone_h = h; + zone_x = zone->x + x; + zone_y = zone->y + y; } else { - zone_w = zone->w; - zone_h = zone->h; - zone_x = zone->x; - zone_y = zone->y; + zone_w = zone->w; + zone_h = zone->h; + zone_x = zone->x; + zone_y = zone->y; } desk_w = (zone_w / zoom); @@ -1128,40 +1154,42 @@ _pager_run(E_Manager *man) for (y = 0; y < zone->desk_y_count; y++) { - for (x = 0; x < zone->desk_x_count; x++) - { - Evas_Object *o, *oo; + for (x = 0; x < zone->desk_x_count; x++) + { + Evas_Object *o, *oo; - o = edje_object_add(e); + o = edje_object_add(e); - if (!e_theme_edje_object_set(o, "base/theme/modules/scale", "modules/scale/desk")) - edje_object_file_set(o, scale_conf->theme_path, "modules/scale/desk"); + if (!e_theme_edje_object_set + (o, "base/theme/modules/scale", "modules/scale/desk")) + edje_object_file_set + (o, scale_conf->theme_path, "modules/scale/desk"); - evas_object_stack_above(o, bg_over); - evas_object_show(o); + evas_object_stack_above(o, bg_over); + evas_object_show(o); - desks = eina_list_append(desks, o); + desks = eina_list_append(desks, o); - if ((x != zone->desk_x_current) || (y != zone->desk_y_current)) - edje_object_signal_emit(o, "unfocused", "e"); - evas_object_clip_set(o, zone_clip); + if ((x != zone->desk_x_current) || (y != zone->desk_y_current)) + edje_object_signal_emit(o, "unfocused", "e"); + evas_object_clip_set(o, zone_clip); - if (edje_object_part_exists(o, "e.swallow.desk")) - { - oo = edje_object_add(e); - edje_object_file_set(oo, file, group); - evas_object_resize(oo, zone->w, zone->h); - edje_extern_object_max_size_set(oo, 65536, 65536); - edje_extern_object_min_size_set(oo, 0, 0); + if (edje_object_part_exists(o, "e.swallow.desk")) + { + oo = edje_object_add(e); + edje_object_file_set(oo, file, group); + evas_object_resize(oo, zone->w, zone->h); + edje_extern_object_max_size_set(oo, 65536, 65536); + edje_extern_object_min_size_set(oo, 0, 0); - /* oo = evas_object_image_filled_add(e); - * evas_object_image_source_set(oo, bg_proxy); - * evas_object_image_smooth_scale_set(oo, smooth); */ + /* oo = evas_object_image_filled_add(e); + * evas_object_image_source_set(oo, bg_proxy); + * evas_object_image_smooth_scale_set(oo, smooth); */ - /* printf("add %p\n", oo); */ - edje_object_part_swallow(o, "e.swallow.desk", oo); - } - } + /* printf("add %p\n", oo); */ + edje_object_part_swallow(o, "e.swallow.desk", oo); + } + } } _pager_place_desks(1.0); @@ -1169,10 +1197,10 @@ _pager_run(E_Manager *man) EINA_LIST_FOREACH(items, l, it) { - evas_object_image_smooth_scale_set(it->o_win, smooth); + evas_object_image_smooth_scale_set(it->o_win, smooth); - if ((scale_conf->pager_fade_windows) && (it->bd->desk != current_desk)) - evas_object_color_set(it->o, 0, 0, 0, 0); + if ((scale_conf->pager_fade_windows) && (it->bd->desk != current_desk)) + evas_object_color_set(it->o, 0, 0, 0, 0); } evas_event_feed_mouse_in(e, ecore_x_current_time_get(), NULL); @@ -1189,28 +1217,28 @@ pager_run(E_Manager *man, const char *params, int init_method EINA_UNUSED) if (scale_state == SCALE_STATE_OUT) { - if (input_win) - return ret; + if (input_win) + return ret; - if (scale_animator) - { - ecore_animator_del(scale_animator); - scale_animator = NULL; - } + if (scale_animator) + { + ecore_animator_del(scale_animator); + scale_animator = NULL; + } - ret = _pager_run(man); + ret = _pager_run(man); - if (ret) - { - if (strlen(params) > 8) - _pager_switch(params+8); + if (ret) + { + if (strlen(params) > 8) + _pager_switch(params + 8); - _pager_in(); - } + _pager_in(); + } } else { - _pager_switch(params+8); + _pager_switch(params + 8); } return ret; @@ -1224,52 +1252,51 @@ _pager_handler(void *data EINA_UNUSED, E_Object *obj, void *msgdata) { - E_Manager *man = (E_Manager *)obj; - E_Comp_Win *src = (E_Comp_Win *)msgdata; - Evas *e; + E_Manager *man = (E_Manager *)obj; + E_Comp_Win *src = (E_Comp_Win *)msgdata; + Evas *e; - /* if (!scale_state) return; */ + /* if (!scale_state) return; */ - if (strcmp(name, "comp.manager")) return; + if (strcmp(name, "comp.manager")) return; - DBG("handler... '%s' '%s'\n", name, info); + DBG("handler... '%s' '%s'\n", name, info); - /* XXX disabled for now. */ - /* return; */ + /* XXX disabled for now. */ + /* return; */ - e = e_comp_evas_get(man->comp); - if (!strcmp(info, "change.comp")) - { - if (!e) - { - DBG("TTT: No comp manager\n"); - } - else - { - DBG("TTT: comp canvas = %p\n", e); - } - } - else if (!strcmp(info, "resize.comp")) - { - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "add.src")) - { - DBG("%s: %p | %p\n", info, man, src); - e_comp_src_hidden_set(src, EINA_TRUE); - } - else if (!strcmp(info, "del.src")) - { - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "config.src")) - { - - DBG("%s: %p | %p\n", info, man, src); - } - else if (!strcmp(info, "visibility.src")) - { - DBG("%s: %p | %p\n", info, man, src); - /* _pager_win_new(e, man, src); */ - } + e = e_comp_evas_get(man->comp); + if (!strcmp(info, "change.comp")) + { + if (!e) + { + DBG("TTT: No comp manager\n"); + } + else + { + DBG("TTT: comp canvas = %p\n", e); + } + } + else if (!strcmp(info, "resize.comp")) + { + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "add.src")) + { + DBG("%s: %p | %p\n", info, man, src); + e_comp_src_hidden_set(src, EINA_TRUE); + } + else if (!strcmp(info, "del.src")) + { + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "config.src")) + { + DBG("%s: %p | %p\n", info, man, src); + } + else if (!strcmp(info, "visibility.src")) + { + DBG("%s: %p | %p\n", info, man, src); + /* _pager_win_new(e, man, src); */ + } } diff --git a/src/e_mod_scale.c b/src/e_mod_scale.c index fe49699..8aa7707 100644 --- a/src/e_mod_scale.c +++ b/src/e_mod_scale.c @@ -1,93 +1,119 @@ #include #include "e_mod_main.h" -#define OFFSET 32 +#define OFFSET 32 #define PLACE_RUNS 10000 #define GROW_RUNS 1000 #define SHRINK_RUNS 2000 -#define GROW 6.0 +#define GROW 6.0 typedef struct _Item Item; typedef struct _Slot Slot; struct _Item { - Evas_Object *o, *o_win; - E_Border *bd; - E_Comp_Win *src; - E_Manager *man; - double scale; + Evas_Object *o, *o_win; + E_Border *bd; + E_Comp_Win *src; + E_Manager *man; + double scale; - Eina_Bool was_hidden; - Eina_Bool was_shaded; - Eina_Bool fade; + Eina_Bool was_hidden; + Eina_Bool was_shaded; + Eina_Bool fade; - double x; - double y; - double w; - double h; + double x; + double y; + double w; + double h; - double mx; - double my; + double mx; + double my; - /* border origin (is moved when scale on another desk) */ - double bd_x; - double bd_y; + /* border origin (is moved when scale on another desk) */ + double bd_x; + double bd_y; - /* current position to draw by compositor */ - int cur_x, cur_y, cur_w, cur_h; + /* current position to draw by compositor */ + int cur_x, cur_y, cur_w, cur_h; - /* borders' desk distance to the current desk */ - int dx, dy; + /* borders' desk distance to the current desk */ + int dx, dy; - Eina_Bool overlaps; + Eina_Bool overlaps; - int in_slots; - int slot_x; - int slot_y; + int in_slots; + int slot_x; + int slot_y; - Item *next; - Item *prev; + Item *next; + Item *prev; - int mouse_down; - int moved; + int mouse_down; + int moved; - double delay; + double delay; }; struct _Slot { - Eina_List *items; - int x, y, w, h; - Item *it; - double min; + Eina_List *items; + int x, y, w, h; + Item *it; + double min; }; static Eina_Bool _scale_cb_mouse_down(void *data, int type, void *event); static Eina_Bool _scale_cb_mouse_up(void *data, int type, void *event); static Eina_Bool _scale_cb_mouse_move(void *data, int type, void *event); -static void _scale_win_cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _scale_win_cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _scale_win_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _scale_win_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _scale_win_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info); -static void _scale_win_cb_delorig(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _scale_win_cb_mouse_in(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _scale_win_cb_mouse_out(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _scale_win_cb_mouse_down(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _scale_win_cb_mouse_up(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _scale_win_cb_mouse_move(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); +static void _scale_win_cb_delorig(void *data, + Evas *e, + Evas_Object *obj, + void *event_info); -static Item *_scale_win_new(Evas *e, E_Manager *man, E_Comp_Win *src, E_Desk *desk); -static void _scale_win_del(Item *it); +static Item *_scale_win_new(Evas *e, + E_Manager *man, + E_Comp_Win *src, + E_Desk *desk); +static void _scale_win_del(Item *it); -static void _scale_finish(void); -static void _scale_in(void); -static void _scale_out(int mode); -static void _scale_handler(void *data, const char *name, const char *info, int val, E_Object *obj, void *msgdata); +static void _scale_finish(void); +static void _scale_in(void); +static void _scale_out(int mode); +static void _scale_handler(void *data, + const char *name, + const char *info, + int val, + E_Object *obj, + void *msgdata); static void _scale_place_natural(); static int _scale_place_slotted(); static int _scale_grow(); static int _scale_place(int offset); static int _scale_shrink(); -static int _cb_sort_center(const void *d1, const void *d2); - +static int _cb_sort_center(const void *d1, + const void *d2); static Ecore_X_Window input_win = 0; static E_Msg_Handler *msg_handler = NULL; @@ -131,17 +157,19 @@ _scale_place_windows(double scale) EINA_LIST_FOREACH(items, l, it) { #if 0 - double scale = s * (1.0 + it->delay); - if (scale > 1.0) scale = 1.0; - if (scale < 0.0) scale = 0.0; + double scale = s * (1.0 + it->delay); + if (scale > 1.0) scale = 1.0; + if (scale < 0.0) scale = 0.0; #endif - it->cur_x = it->bd_x * scale + it->x * (1.0 - scale); - it->cur_y = it->bd_y * scale + it->y * (1.0 - scale); - it->cur_w = (double)(it->bd_x + it->bd->w) * scale + (it->x + it->w) * (1.0 - scale) - it->cur_x; - it->cur_h = (double)(it->bd_y + it->bd->h) * scale + (it->y + it->h) * (1.0 - scale) - it->cur_y; + it->cur_x = it->bd_x * scale + it->x * (1.0 - scale); + it->cur_y = it->bd_y * scale + it->y * (1.0 - scale); + it->cur_w = (double)(it->bd_x + it->bd->w) * + scale + (it->x + it->w) * (1.0 - scale) - it->cur_x; + it->cur_h = (double)(it->bd_y + it->bd->h) * + scale + (it->y + it->h) * (1.0 - scale) - it->cur_y; - evas_object_move(it->o, it->cur_x, it->cur_y); - evas_object_resize(it->o, it->cur_w, it->cur_h); + evas_object_move(it->o, it->cur_x, it->cur_y); + evas_object_resize(it->o, it->cur_w, it->cur_h); } } @@ -149,8 +177,10 @@ static void _scale_warp_to_win(Item *it, double advance) { ecore_x_pointer_warp(it->bd->zone->container->win, - (double)warp_x * (1.0 - advance) + (double)(it->x + it->w/2) * advance, - (double)warp_y * (1.0 - advance) + (double)(it->y + it->h/2) * advance + 10); + (double)warp_x * (1.0 - advance) + + (double)(it->x + it->w / 2) * advance, + (double)warp_y * (1.0 - advance) + + (double)(it->y + it->h / 2) * advance + 10); } static Eina_Bool @@ -160,11 +190,11 @@ _scale_warp_pointer(void *data EINA_UNUSED) if (it) { - double in = (ecore_loop_time_get() - warp_start) / 0.25; - if (in > 1.0) in = 1.0; - _scale_warp_to_win(it, in); - if (in < 1.0) - return ECORE_CALLBACK_RENEW; + double in = (ecore_loop_time_get() - warp_start) / 0.25; + if (in > 1.0) in = 1.0; + _scale_warp_to_win(it, in); + if (in < 1.0) + return ECORE_CALLBACK_RENEW; } warp_animator = NULL; @@ -179,7 +209,7 @@ _scale_redraw(void *data EINA_UNUSED) E_Manager *man; double adv, in, duration; Eina_Bool finish = EINA_FALSE; - + if (show_all_desks) duration = scale_conf->desks_duration; else @@ -189,14 +219,14 @@ _scale_redraw(void *data EINA_UNUSED) if (in >= 1.0) { - in = scale_state ? 0.0 : 1.0; - finish = EINA_TRUE; + in = scale_state ? 0.0 : 1.0; + finish = EINA_TRUE; } else if (scale_state) { #if 1 - in = log(14) * in; - in = 1.0 / exp(in*in); + in = log(14) * in; + in = 1.0 / exp(in * in); #else in = 1.0 - in; #endif @@ -204,41 +234,41 @@ _scale_redraw(void *data EINA_UNUSED) else { #if 1 - in = log(14) * (1.0 - in); - in = 1.0 / exp(in*in); + in = log(14) * (1.0 - in); + in = 1.0 / exp(in * in); #endif - adv = 1.0 - adv; + adv = 1.0 - adv; } _scale_place_windows(in); - + if (scale_conf->fade_windows) { - EINA_LIST_FOREACH(items, l, it) - { - double a = 255.0; + EINA_LIST_FOREACH(items, l, it) + { + double a = 255.0; - if (it->was_hidden) - continue; - - if ((it->bd->desk != current_desk) && (selected_item != it)) - a = 255.0 * sqrt(adv); + if (it->was_hidden) + continue; - evas_object_color_set(it->o, a, a, a, a); - } + if ((it->bd->desk != current_desk) && (selected_item != it)) + a = 255.0 * sqrt(adv); + + evas_object_color_set(it->o, a, a, a, a); + } } EINA_LIST_FOREACH(items, l, it) { - if (it->was_hidden) - { - double a = 255.0 * adv; + if (it->was_hidden) + { + double a = 255.0 * adv; - if ((!scale_state) && (it == selected_item)) - continue; + if ((!scale_state) && (it == selected_item)) + continue; - evas_object_color_set(it->o, a, a, a, a); - } + evas_object_color_set(it->o, a, a, a, a); + } } if (warp_pointer && selected_item) @@ -246,25 +276,25 @@ _scale_redraw(void *data EINA_UNUSED) EINA_LIST_FOREACH(items_fade, l, it) { - double a = 255.0 * in; + double a = 255.0 * in; - if ((it->bd->desk == current_desk) || (it->bd->sticky)) - evas_object_color_set(it->o, a, a, a, a); + if ((it->bd->desk == current_desk) || (it->bd->sticky)) + evas_object_color_set(it->o, a, a, a, a); } if (scale_conf->fade_popups) { - double a = 255.0 * in; + double a = 255.0 * in; - EINA_LIST_FOREACH(popups, l, it) - evas_object_color_set(it->o_win, a, a, a, a); + EINA_LIST_FOREACH(popups, l, it) + evas_object_color_set(it->o_win, a, a, a, a); } if (scale_conf->fade_desktop && background) { - double a = 255.0 * (0.5 + in/2.0); + double a = 255.0 * (0.5 + in / 2.0); - evas_object_color_set(background->o_win, a, a, a, 255); + evas_object_color_set(background->o_win, a, a, a, 255); } man = e_manager_current_get(); @@ -272,11 +302,11 @@ _scale_redraw(void *data EINA_UNUSED) if (finish) { - if (!scale_state) - _scale_finish(); + if (!scale_state) + _scale_finish(); - scale_animator = NULL; - return ECORE_CALLBACK_CANCEL; + scale_animator = NULL; + return ECORE_CALLBACK_CANCEL; } return ECORE_CALLBACK_RENEW; @@ -305,40 +335,40 @@ _scale_out(int mode) if (mode == 0) { - selected_item = NULL; + selected_item = NULL; } else if (it && (mode == 1)) { - /* goto selected windows desk */ + /* goto selected windows desk */ - current_desk = it->bd->desk; + current_desk = it->bd->desk; - EINA_LIST_FOREACH(items, l, ot) - { - if (ot->bd->desk == it->bd->desk) - { - ot->bd_x = ot->bd->x; - ot->bd_y = ot->bd->y; - } - else - { - if (ot->dx > it->dx) - ot->bd_x = ot->bd->x + zone->w; - else if (ot->dx < it->dx) - ot->bd_x = ot->bd->x - zone->w; + EINA_LIST_FOREACH(items, l, ot) + { + if (ot->bd->desk == it->bd->desk) + { + ot->bd_x = ot->bd->x; + ot->bd_y = ot->bd->y; + } + else + { + if (ot->dx > it->dx) + ot->bd_x = ot->bd->x + zone->w; + else if (ot->dx < it->dx) + ot->bd_x = ot->bd->x - zone->w; - if (ot->dy > it->dy) - ot->bd_y = ot->bd->y + zone->h; - else if (ot->dy < it->dy) - ot->bd_y = ot->bd->y - zone->h; - } - } + if (ot->dy > it->dy) + ot->bd_y = ot->bd->y + zone->h; + else if (ot->dy < it->dy) + ot->bd_y = ot->bd->y - zone->h; + } + } } else if (it && (mode == 2)) { - send_to_desk = EINA_TRUE; - it->bd_x = it->bd->x; - it->bd_y = it->bd->y; + send_to_desk = EINA_TRUE; + it->bd_x = it->bd->x; + it->bd_y = it->bd->y; } if (show_all_desks) @@ -356,29 +386,29 @@ _scale_out(int mode) if (warp_animator) { - ecore_animator_del(warp_animator); - warp_animator = NULL; + ecore_animator_del(warp_animator); + warp_animator = NULL; } if (selected_item) { - it = selected_item; + it = selected_item; - evas_object_raise(it->o); - e_border_raise(it->bd); + evas_object_raise(it->o); + e_border_raise(it->bd); - if ((!it->moved) && (init_method == GO_KEY) && - (e_config->focus_policy != E_FOCUS_CLICK)) - { - warp_pointer = 1; - warp_x = it->bd->x + it->bd->w/2; - warp_y = it->bd->y + it->bd->h/2; - e_border_focus_set(it->bd, 1, 1); - } - else - { - e_border_focus_set(it->bd, 1, 1); - } + if ((!it->moved) && (init_method == GO_KEY) && + (e_config->focus_policy != E_FOCUS_CLICK)) + { + warp_pointer = 1; + warp_x = it->bd->x + it->bd->w / 2; + warp_y = it->bd->y + it->bd->h / 2; + e_border_focus_set(it->bd, 1, 1); + } + else + { + e_border_focus_set(it->bd, 1, 1); + } } EINA_LIST_FOREACH(items, l, it) @@ -396,45 +426,44 @@ _scale_finish() if (selected_item) { - E_Desk *desk; + E_Desk *desk; - it = selected_item; - - desk = e_desk_current_get(zone); + it = selected_item; - if (it->bd->desk != desk) - { - if (send_to_desk) - { - e_border_desk_set(it->bd, desk); - } - else - { - int tmp = e_config->desk_flip_animate_mode; - desk = it->bd->desk; + desk = e_desk_current_get(zone); - e_config->desk_flip_animate_mode = 0; - e_desk_show(desk); - e_config->desk_flip_animate_mode = tmp; - current_desk = desk; - } - } + if (it->bd->desk != desk) + { + if (send_to_desk) + { + e_border_desk_set(it->bd, desk); + } + else + { + int tmp = e_config->desk_flip_animate_mode; + desk = it->bd->desk; - if (it->was_hidden) - { - it->was_hidden = EINA_FALSE; - e_border_uniconify(it->bd); - } + e_config->desk_flip_animate_mode = 0; + e_desk_show(desk); + e_config->desk_flip_animate_mode = tmp; + current_desk = desk; + } + } - it->was_shaded = EINA_FALSE; + if (it->was_hidden) + { + it->was_hidden = EINA_FALSE; + e_border_uniconify(it->bd); + } + it->was_shaded = EINA_FALSE; } EINA_LIST_FREE(items, it) { - if (it->moved) bd_move = it->bd; + if (it->moved) bd_move = it->bd; - _scale_win_del(it); + _scale_win_del(it); } EINA_LIST_FREE(items_fade, it) @@ -452,7 +481,7 @@ _scale_finish() E_Manager *man = zone->container->manager; EINA_LIST_FOREACH((Eina_List *)e_comp_src_list_get(man->comp), l, src) - e_comp_src_hidden_set(src, EINA_FALSE); + e_comp_src_hidden_set(src, EINA_FALSE); } man = e_manager_current_get(); @@ -460,12 +489,12 @@ _scale_finish() if (!bd_move) { - EINA_LIST_FREE(handlers, handler) - ecore_event_handler_del(handler); + EINA_LIST_FREE(handlers, handler) + ecore_event_handler_del(handler); - e_grabinput_release(input_win, input_win); - ecore_x_window_free(input_win); - input_win = 0; + e_grabinput_release(input_win, input_win); + ecore_x_window_free(input_win); + input_win = 0; } evas_object_del(zone_clip); @@ -509,9 +538,9 @@ _scale_win_cb_mouse_in(void *data, static void _scale_win_cb_mouse_out(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) + Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) { Item *it = data; @@ -523,17 +552,17 @@ _scale_win_cb_mouse_out(void *data, if (it == selected_item) { - edje_object_signal_emit(it->o, "mouse,out", "e"); - it->mouse_down = EINA_FALSE; - selected_item = NULL; + edje_object_signal_emit(it->o, "mouse,out", "e"); + it->mouse_down = EINA_FALSE; + selected_item = NULL; } } static void _scale_win_cb_mouse_down(void *data, - Evas *e EINA_UNUSED, - Evas_Object *obj EINA_UNUSED, - void *event_info EINA_UNUSED) + Evas *e EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) { Item *it = data; Evas_Event_Mouse_Down *ev = event_info; @@ -565,18 +594,18 @@ _scale_win_cb_mouse_up(void *data, if (it->bd->desk == e_desk_current_get(it->bd->zone)) { - selected_item = it; - _scale_out(1); + selected_item = it; + _scale_out(1); } else if (ev->button == 1) { - selected_item = it; - _scale_out(1); + selected_item = it; + _scale_out(1); } else if (ev->button == 3) { - selected_item = it; - _scale_out(2); + selected_item = it; + _scale_out(2); } } @@ -594,35 +623,36 @@ _scale_win_cb_mouse_move(void *data, if (it->moved) { - it->bd_x += (ev->cur.canvas.x - ev->prev.canvas.x); - it->bd_y += (ev->cur.canvas.y - ev->prev.canvas.y); - e_border_move(it->bd, it->bd_x, it->bd_y); + it->bd_x += (ev->cur.canvas.x - ev->prev.canvas.x); + it->bd_y += (ev->cur.canvas.y - ev->prev.canvas.y); + e_border_move(it->bd, it->bd_x, it->bd_y); - mouse_x = ev->cur.canvas.x; - mouse_y = ev->cur.canvas.y; + mouse_x = ev->cur.canvas.x; + mouse_y = ev->cur.canvas.y; } else { - if (!scale_state) - return; + if (!scale_state) + return; - if (it->bd->maximized || it->bd->fullscreen || it->bd->lock_user_location) - return; + if (it->bd->maximized || it->bd->fullscreen || + it->bd->lock_user_location) + return; - if (abs(ev->cur.canvas.x - it->mx) + - abs(ev->cur.canvas.y - it->my) < 15) - return; + if (abs(ev->cur.canvas.x - it->mx) + + abs(ev->cur.canvas.y - it->my) < 15) + return; - it->moved = EINA_TRUE; + it->moved = EINA_TRUE; - _scale_out(2); + _scale_out(2); - it->bd_x = ev->cur.canvas.x - (ev->cur.canvas.x - it->cur_x); - it->bd_y = ev->cur.canvas.y - (ev->cur.canvas.y - it->cur_y); - if (it->bd_x + it->bd->w > it->bd->zone->w) - it->bd_x = it->bd->zone->w - it->bd->w; - if (it->bd_y + it->bd->h > it->bd->zone->h) - it->bd_y = it->bd->zone->h - it->bd->h; + it->bd_x = ev->cur.canvas.x - (ev->cur.canvas.x - it->cur_x); + it->bd_y = ev->cur.canvas.y - (ev->cur.canvas.y - it->cur_y); + if (it->bd_x + it->bd->w > it->bd->zone->w) + it->bd_x = it->bd->zone->w - it->bd->w; + if (it->bd_y + it->bd->h > it->bd->zone->h) + it->bd_y = it->bd->zone->h - it->bd->h; } } @@ -636,12 +666,12 @@ _scale_win_cb_delorig(void *data, if (it->bd) { - _scale_out(0); - items = eina_list_remove(items, it); + _scale_out(0); + items = eina_list_remove(items, it); } else { - popups = eina_list_remove(popups, it); + popups = eina_list_remove(popups, it); } _scale_win_del(it); @@ -651,47 +681,47 @@ static void _scale_win_del(Item *it) { evas_object_event_callback_del(it->o_win, EVAS_CALLBACK_DEL, - _scale_win_cb_delorig); + _scale_win_cb_delorig); if (it->bd) { - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_IN, - _scale_win_cb_mouse_in); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_IN, + _scale_win_cb_mouse_in); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_OUT, - _scale_win_cb_mouse_out); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_OUT, + _scale_win_cb_mouse_out); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_DOWN, - _scale_win_cb_mouse_down); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_DOWN, + _scale_win_cb_mouse_down); - evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_UP, - _scale_win_cb_mouse_up); + evas_object_event_callback_del(it->o, EVAS_CALLBACK_MOUSE_UP, + _scale_win_cb_mouse_up); - e_comp_src_hidden_set(it->src, EINA_FALSE); + e_comp_src_hidden_set(it->src, EINA_FALSE); - if ((it->bd->desk != current_desk) && (!it->bd->sticky)) - { - e_border_hide(it->bd, 2); + if ((it->bd->desk != current_desk) && (!it->bd->sticky)) + { + e_border_hide(it->bd, 2); evas_object_hide(e_comp_src_shadow_get(it->src)); - } - else if (it->was_hidden) - { - e_border_hide(it->bd, 1); - evas_object_hide(e_comp_src_shadow_get(it->src)); - } - if (it->was_shaded) - { - e_border_shade(it->bd, E_DIRECTION_DOWN); - } - - evas_object_del(it->o_win); - evas_object_del(it->o); + } + else if (it->was_hidden) + { + e_border_hide(it->bd, 1); + evas_object_hide(e_comp_src_shadow_get(it->src)); + } + if (it->was_shaded) + { + e_border_shade(it->bd, E_DIRECTION_DOWN); + } - e_object_unref(E_OBJECT(it->bd)); + evas_object_del(it->o_win); + evas_object_del(it->o); + + e_object_unref(E_OBJECT(it->bd)); } else { - evas_object_color_set(it->o_win, 255, 255, 255, 255); + evas_object_color_set(it->o_win, 255, 255, 255, 255); } E_FREE(it); @@ -702,7 +732,7 @@ _scale_win_new(Evas *e, E_Manager *man, E_Comp_Win *src, E_Desk *desk) { Item *it; E_Border *bd; - + if (!e_comp_src_image_get(src)) return NULL; @@ -711,34 +741,34 @@ _scale_win_new(Evas *e, E_Manager *man, E_Comp_Win *src, E_Desk *desk) if (!bd) { Ecore_X_Window win = e_comp_src_window_get(src); - - if ((win == zone->container->bg_win) && - (scale_conf->fade_desktop)) - { - it = E_NEW(Item, 1); - it->man = man; - it->o_win = e_comp_src_shadow_get(src); - evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _scale_win_cb_delorig, it); - background = it; - return it; - } - else if (scale_conf->fade_popups) - { + + if ((win == zone->container->bg_win) && + (scale_conf->fade_desktop)) + { + it = E_NEW(Item, 1); + it->man = man; + it->o_win = e_comp_src_shadow_get(src); + evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, + _scale_win_cb_delorig, it); + background = it; + return it; + } + else if (scale_conf->fade_popups) + { E_Popup *pop = e_comp_src_popup_get(src); - if ((pop) && (pop->zone != zone)) - return NULL; + if ((pop) && (pop->zone != zone)) + return NULL; - it = E_NEW(Item, 1); - it->man = man; - it->o_win = e_comp_src_shadow_get(src); - evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _scale_win_cb_delorig, it); - popups = eina_list_append(popups, it); - return it; - } - return NULL; + it = E_NEW(Item, 1); + it->man = man; + it->o_win = e_comp_src_shadow_get(src); + evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, + _scale_win_cb_delorig, it); + popups = eina_list_append(popups, it); + return it; + } + return NULL; } if (bd->zone != desk->zone) @@ -749,28 +779,29 @@ _scale_win_new(Evas *e, E_Manager *man, E_Comp_Win *src, E_Desk *desk) if (bd->iconic) { - if (!show_iconified) - return NULL; - - if ((match_class) && (!e_util_glob_match(bd->client.icccm.class, match_class))) - return NULL; + if (!show_iconified) + return NULL; + + if ((match_class) && + (!e_util_glob_match(bd->client.icccm.class, match_class))) + return NULL; } if (e_mod_border_ignore(bd)) { - const char *class; - - if (!bd->visible) - return NULL; - /* fade keyboard and home, ignore other */ + const char *class; - if (!(class = bd->client.icccm.class) || - (strcmp(class, "Virtual-Keyboard") && - strcmp(class, "Illume-Home") && - strcmp(class, "everything-window"))) - return NULL; + if (!bd->visible) + return NULL; + /* fade keyboard and home, ignore other */ + + if (!(class = bd->client.icccm.class) || + (strcmp(class, "Virtual-Keyboard") && + strcmp(class, "Illume-Home") && + strcmp(class, "everything-window"))) + return NULL; } - + it = E_NEW(Item, 1); it->scale = 1.0; @@ -779,12 +810,8 @@ _scale_win_new(Evas *e, E_Manager *man, E_Comp_Win *src, E_Desk *desk) it->man = man; it->src = src; e_comp_src_hidden_set(src, EINA_TRUE); - + it->o_win = e_comp_src_image_mirror_add(src); - /* it->o_win = evas_object_image_filled_add(e); - * o = e_manager_comp_src_image_get(man, src); - * evas_object_image_source_set(it->o_win, o); - * evas_object_image_smooth_scale_set(it->o_win, evas_object_image_smooth_scale_get(o)); */ evas_object_show(it->o_win); it->o = edje_object_add(e); @@ -797,17 +824,17 @@ _scale_win_new(Evas *e, E_Manager *man, E_Comp_Win *src, E_Desk *desk) edje_object_part_swallow(it->o, "e.swallow.win", it->o_win); evas_object_event_callback_add(it->o_win, EVAS_CALLBACK_DEL, - _scale_win_cb_delorig, it); - + _scale_win_cb_delorig, it); + if (it->bd->shaded) { - /* int tmp = e_config->border_shade_animate; - * e_config->border_shade_animate = EINA_FALSE; - * - * e_border_unshade(it->bd, E_DIRECTION_DOWN); - * it->was_shaded = EINA_TRUE; - * - * e_config->border_shade_animate = tmp; */ + /* int tmp = e_config->border_shade_animate; + * e_config->border_shade_animate = EINA_FALSE; + * + * e_border_unshade(it->bd, E_DIRECTION_DOWN); + * it->was_shaded = EINA_TRUE; + * + * e_config->border_shade_animate = tmp; */ } it->dx = bd->desk->x - desk->x; @@ -831,49 +858,49 @@ _scale_win_new(Evas *e, E_Manager *man, E_Comp_Win *src, E_Desk *desk) if (it->bd->iconic) { - evas_object_color_set(it->o, 0, 0, 0, 0); - it->was_hidden = EINA_TRUE; + evas_object_color_set(it->o, 0, 0, 0, 0); + it->was_hidden = EINA_TRUE; } if ((e_mod_border_ignore(it->bd)) || - ((match_class) && (!e_util_glob_match(bd->client.icccm.class, match_class)))) + ((match_class) && + (!e_util_glob_match(bd->client.icccm.class, match_class)))) { - items_fade = eina_list_append(items_fade, it); + items_fade = eina_list_append(items_fade, it); - if (it->bd->desk != desk) - evas_object_color_set(it->o, 0, 0, 0, 0); + if (it->bd->desk != desk) + evas_object_color_set(it->o, 0, 0, 0, 0); - evas_object_move(it->o, it->bd->x, it->bd->y); - evas_object_resize(it->o, it->bd->w, it->bd->h); - evas_object_pass_events_set(it->o, 1); + evas_object_move(it->o, it->bd->x, it->bd->y); + evas_object_resize(it->o, it->bd->w, it->bd->h); + evas_object_pass_events_set(it->o, 1); - return it; + return it; } if (!it->bd->visible) e_border_show(it->bd); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_IN, - _scale_win_cb_mouse_in, it); + _scale_win_cb_mouse_in, it); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_OUT, - _scale_win_cb_mouse_out, it); + _scale_win_cb_mouse_out, it); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_DOWN, - _scale_win_cb_mouse_down, it); + _scale_win_cb_mouse_down, it); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_UP, - _scale_win_cb_mouse_up, it); + _scale_win_cb_mouse_up, it); evas_object_event_callback_add(it->o, EVAS_CALLBACK_MOUSE_MOVE, - _scale_win_cb_mouse_move, it); + _scale_win_cb_mouse_move, it); items = eina_list_append(items, it); - + return it; } - static void _scale_warp_animator_run(Item *it) { @@ -893,8 +920,8 @@ _scale_switch(const char *params) if (params[0] == 0) { - _scale_out(1); - return; + _scale_out(1); + return; } if ((!sel) || (!sel->next) || (!sel->prev)) @@ -902,62 +929,62 @@ _scale_switch(const char *params) if (!strcmp(params, "_next")) { - it = sel->next; + it = sel->next; } else if (!strcmp(params, "_prev")) { - it = sel->prev; + it = sel->prev; } else if (!strcmp(params, "_left")) { - it = sel->prev; + it = sel->prev; - if (it->slot_y != sel->slot_y) - { - it = sel; + if (it->slot_y != sel->slot_y) + { + it = sel; - while(sel->slot_y == it->next->slot_y) - { - it = it->next; - if (it == sel) break; - } - } + while (sel->slot_y == it->next->slot_y) + { + it = it->next; + if (it == sel) break; + } + } } else if (!strcmp(params, "_right")) { - it = sel->next; + it = sel->next; - if (it->slot_y != sel->slot_y) - { - it = sel; - while(sel->slot_y == it->prev->slot_y) - { - it = it->prev; - if (it == sel) break; - } - } + if (it->slot_y != sel->slot_y) + { + it = sel; + while (sel->slot_y == it->prev->slot_y) + { + it = it->prev; + if (it == sel) break; + } + } } else if (!strcmp(params, "_up")) { - it = sel; + it = sel; - while((sel->slot_y == it->slot_y) || - (sel->slot_x < it->slot_x)) - { - it = it->prev; - if (it == sel) break; - } + while ((sel->slot_y == it->slot_y) || + (sel->slot_x < it->slot_x)) + { + it = it->prev; + if (it == sel) break; + } } else if (!strcmp(params, "_down")) { - it = sel; + it = sel; - while((sel->slot_y == it->slot_y) || - (sel->slot_x > it->slot_x)) - { - it = it->next; - if (it == sel) break; - } + while ((sel->slot_y == it->slot_y) || + (sel->slot_x > it->slot_x)) + { + it = it->next; + if (it == sel) break; + } } if (it == sel) @@ -1006,43 +1033,45 @@ _scale_cb_key_down(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) _scale_out(1); else if (!strcmp(ev->key, "Escape")) { - /* TODO go to previously focused window */ - _scale_out(0); + /* TODO go to previously focused window */ + _scale_out(0); } else { - E_Action *act; - Eina_List *l; - E_Config_Binding_Key *bind; - E_Binding_Modifier mod; + E_Action *act; + Eina_List *l; + E_Config_Binding_Key *bind; + E_Binding_Modifier mod; - for (l = e_config->key_bindings; l; l = l->next) - { - bind = l->data; - mod = 0; + for (l = e_config->key_bindings; l; l = l->next) + { + bind = l->data; + mod = 0; - if (bind->action && strcmp(bind->action, "scale-windows")) continue; - if (!bind->params || strncmp(bind->params, "go_scale", 8)) continue; + if (bind->action && strcmp(bind->action, "scale-windows")) + continue; + if (!bind->params || strncmp(bind->params, "go_scale", 8)) + continue; - if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) + if (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT) mod |= E_BINDING_MODIFIER_SHIFT; - if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) + if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) mod |= E_BINDING_MODIFIER_CTRL; - if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) + if (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) mod |= E_BINDING_MODIFIER_ALT; - if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN) + if (ev->modifiers & ECORE_EVENT_MODIFIER_WIN) mod |= E_BINDING_MODIFIER_WIN; - if (bind->key && (!strcmp(bind->key, ev->keyname)) && - ((bind->modifiers == mod) || (bind->any_mod))) - { - if (!(act = e_action_find(bind->action))) continue; - if (act->func.go_key) - act->func.go_key(E_OBJECT(zone), bind->params, ev); - else if (act->func.go) - act->func.go(E_OBJECT(zone), bind->params); - } - } + if (bind->key && (!strcmp(bind->key, ev->keyname)) && + ((bind->modifiers == mod) || (bind->any_mod))) + { + if (!(act = e_action_find(bind->action))) continue; + if (act->func.go_key) + act->func.go_key(E_OBJECT(zone), bind->params, ev); + else if (act->func.go) + act->func.go(E_OBJECT(zone), bind->params); + } + } } return ECORE_CALLBACK_PASS_ON; } @@ -1070,13 +1099,17 @@ _cb_sort_dist(const void *d1, const void *d2) const Item *it1 = d1; const Item *it2 = d2; - double dx1 = ((it1->x + it1->w/2.0) - (double)(it1->bd_x + it1->bd->w/2)); - double dy1 = ((it1->y + it1->h/2.0) - (double)(it1->bd_y + it1->bd->h/2)); + double dx1 = ((it1->x + it1->w / 2.0) - + (double)(it1->bd_x + it1->bd->w / 2)); + double dy1 = ((it1->y + it1->h / 2.0) - + (double)(it1->bd_y + it1->bd->h / 2)); - double dx2 = ((it2->x + it2->w/2.0) - (double)(it2->bd_x + it2->bd->w/2)); - double dy2 = ((it2->y + it2->h/2.0) - (double)(it2->bd_y + it2->bd->h/2)); + double dx2 = ((it2->x + it2->w / 2.0) - + (double)(it2->bd_x + it2->bd->w / 2)); + double dy2 = ((it2->y + it2->h / 2.0) - + (double)(it2->bd_y + it2->bd->h / 2)); - return (sqrt(dx1*dx1 + dy1*dy1) > sqrt(dx2*dx2 + dy2*dy2)) ? -1 : 1; + return (sqrt(dx1 * dx1 + dy1 * dy1) > sqrt(dx2 * dx2 + dy2 * dy2)) ? -1 : 1; } static Eina_Bool @@ -1112,31 +1145,31 @@ _scale_run(E_Manager *man) ecore_x_window_show(input_win); if (!e_grabinput_get(input_win, 0, input_win)) { - ecore_x_window_free(input_win); - input_win = 0; - return EINA_FALSE; + ecore_x_window_free(input_win); + input_win = 0; + return EINA_FALSE; } msg_handler = e_msg_handler_add(_scale_handler, NULL); h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, - _scale_cb_mouse_down, e); + _scale_cb_mouse_down, e); handlers = eina_list_append(handlers, h); h = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, - _scale_cb_mouse_up, e); + _scale_cb_mouse_up, e); handlers = eina_list_append(handlers, h); h = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, - _scale_cb_mouse_move, e); + _scale_cb_mouse_move, e); handlers = eina_list_append(handlers, h); h = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, - _scale_cb_key_down, e); + _scale_cb_key_down, e); handlers = eina_list_append(handlers, h); h = ecore_event_handler_add(ECORE_EVENT_KEY_UP, - _scale_cb_key_up, e); + _scale_cb_key_up, e); handlers = eina_list_append(handlers, h); zone_clip = evas_object_rectangle_add(e); @@ -1146,20 +1179,20 @@ _scale_run(E_Manager *man) EINA_LIST_FOREACH((Eina_List *)e_comp_src_list_get(man->comp), l, src) { - Item *it = _scale_win_new(e, man, src, current_desk); - if (it) evas_object_clip_set(it->o, zone_clip); + Item *it = _scale_win_new(e, man, src, current_desk); + if (it) evas_object_clip_set(it->o, zone_clip); } if (eina_list_count(items) < 1) { - _scale_finish(); - return EINA_FALSE; + _scale_finish(); + return EINA_FALSE; } if ((eina_list_count(items) < 2) && (!show_all_desks)) { - _scale_finish(); - return EINA_FALSE; + _scale_finish(); + return EINA_FALSE; } if (show_all_desks) @@ -1169,18 +1202,18 @@ _scale_run(E_Manager *man) if (!scale_conf->fade_popups) { - e_zone_useful_geometry_get(zone, &use_x, &use_y, &use_w, &use_h); - use_x = use_x - zone->x + spacing; - use_y = use_y - zone->y + spacing; - use_w += use_x - spacing; - use_h += use_y - spacing; + e_zone_useful_geometry_get(zone, &use_x, &use_y, &use_w, &use_h); + use_x = use_x - zone->x + spacing; + use_y = use_y - zone->y + spacing; + use_w += use_x - spacing; + use_h += use_y - spacing; } else { - use_x = spacing; - use_y = spacing; - use_w = zone->w - spacing; - use_h = zone->h - spacing; + use_x = spacing; + use_y = spacing; + use_w = zone->w - spacing; + use_h = zone->h - spacing; } min_x = 0; @@ -1201,63 +1234,67 @@ _scale_run(E_Manager *man) /* EINA_LIST_FOREACH(items, l, it) * printf(">> %dx%d %d:%d - %s\n", - * (int)it->w, (int)it->h, - * (int)it->x, (int)it->y, - * e_border_name_get(it->bd)); */ + * (int)it->w, (int)it->h, + * (int)it->x, (int)it->y, + * e_border_name_get(it->bd)); */ if ((scale_conf->grow && !show_all_desks) || (scale_conf->desks_grow && show_all_desks)) { - if ((scale_conf->tight && !show_all_desks) || - (scale_conf->desks_tight && show_all_desks)) - spacing += 5; + if ((scale_conf->tight && !show_all_desks) || + (scale_conf->desks_tight && show_all_desks)) + spacing += 5; - i = 0; - while (i++ < GROW_RUNS && _scale_grow()); - DBG("grow %d", i); + i = 0; + while (i++ < GROW_RUNS && _scale_grow()) + ; + DBG("grow %d", i); - if ((scale_conf->tight && !show_all_desks) || - (scale_conf->desks_tight && show_all_desks)) - spacing -= 5; + if ((scale_conf->tight && !show_all_desks) || + (scale_conf->desks_tight && show_all_desks)) + spacing -= 5; } if ((scale_conf->tight && !show_all_desks) || (scale_conf->desks_tight && show_all_desks)) { - items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); - i = 0; - while (i++ < SHRINK_RUNS && _scale_shrink()); - DBG("shrunk %d", i); + items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); + i = 0; + while (i++ < SHRINK_RUNS && _scale_shrink()) + ; + DBG("shrunk %d", i); } if (show_all_desks) { - /* center and move windows near visible desk - * to make the sliding smoother */ + /* center and move windows near visible desk + * to make the sliding smoother */ - min_x = zone->w; - min_y = zone->h; - max_x = 0; - max_y = 0; + min_x = zone->w; + min_y = zone->h; + max_x = 0; + max_y = 0; - EINA_LIST_FOREACH(items, l, it) - { - if (it->x < min_x) min_x = it->x; - if (it->y < min_y) min_y = it->y; - if (it->x + it->w > max_x) max_x = it->x + it->w; - if (it->y + it->h > max_y) max_y = it->y + it->h; - } + EINA_LIST_FOREACH(items, l, it) + { + if (it->x < min_x) min_x = it->x; + if (it->y < min_y) min_y = it->y; + if (it->x + it->w > max_x) max_x = it->x + it->w; + if (it->y + it->h > max_y) max_y = it->y + it->h; + } - EINA_LIST_FOREACH(items, l, it) - { - it->x = (it->x - min_x) + use_x + ((use_w - use_x) - (max_x - min_x))/2.0; - it->y = (it->y - min_y) + use_y + ((use_h - use_y) - (max_y - min_y))/2.0; + EINA_LIST_FOREACH(items, l, it) + { + it->x = (it->x - min_x) + use_x + ((use_w - use_x) - + (max_x - min_x)) / 2.0; + it->y = (it->y - min_y) + use_y + ((use_h - use_y) - + (max_y - min_y)) / 2.0; - if (it->dx > 0) it->bd_x = zone->w; - if (it->dy > 0) it->bd_y = zone->h; - if (it->dx < 0) it->bd_x = -zone->w + (zone->w - it->bd->w); - if (it->dy < 0) it->bd_y = -zone->h + (zone->h - it->bd->h); - } + if (it->dx > 0) it->bd_x = zone->w; + if (it->dy > 0) it->bd_y = zone->h; + if (it->dx < 0) it->bd_x = -zone->w + (zone->w - it->bd->w); + if (it->dy < 0) it->bd_y = -zone->h + (zone->h - it->bd->h); + } } #if 0 @@ -1267,17 +1304,19 @@ _scale_run(E_Manager *man) EINA_LIST_FOREACH(items, l, it) { #if 0 - double dx = ((it->x + it->w/2.0) - (double)(it->bd_x + it->bd->w/2)); - double dy = ((it->y + it->h/2.0) - (double)(it->bd_y + it->bd->h/2)); + double dx = ((it->x + it->w / 2.0) - + (double)(it->bd_x + it->bd->w / 2)); + double dy = ((it->y + it->h / 2.0) - + (double)(it->bd_y + it->bd->h / 2)); #endif - it->x += zone->x; - it->y += zone->y; - it->bd_x += zone->x; - it->bd_y += zone->y; + it->x += zone->x; + it->y += zone->y; + it->bd_x += zone->x; + it->bd_y += zone->y; #if 0 - it->delay = sqrt(dx*dx + dy*dy) / 1000.0; - if (it->delay < min) min = it->delay; + it->delay = sqrt(dx * dx + dy * dy) / 1000.0; + if (it->delay < min) min = it->delay; #endif } @@ -1293,26 +1332,26 @@ _scale_run(E_Manager *man) if (init_method == GO_KEY) { - E_Border *bd2 = NULL; + E_Border *bd2 = NULL; - EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) - if ((bd != bd2) && (bd->desk == current_desk)) - { - if (!bd2) bd2 = bd; - else break; - } - if (!bd) bd = bd2; + EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) + if ((bd != bd2) && (bd->desk == current_desk)) + { + if (!bd2) bd2 = bd; + else break; + } + if (!bd) bd = bd2; } else { - EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) - if (bd->desk == current_desk) break; + EINA_LIST_FOREACH(e_border_focus_stack_get(), l, bd) + if (bd->desk == current_desk) break; } if (bd) { - EINA_LIST_FOREACH(items, l, it) - if (it->bd == bd) break; + EINA_LIST_FOREACH(items, l, it) + if (it->bd == bd) break; } if (it) @@ -1324,16 +1363,16 @@ _scale_run(E_Manager *man) EINA_LIST_FOREACH(items, l, it) { - if (it != selected_item) - edje_object_signal_emit(it->o, "mouse,out", "e"); - else - edje_object_signal_emit(it->o, "mouse,in", "e"); + if (it != selected_item) + edje_object_signal_emit(it->o, "mouse,out", "e"); + else + edje_object_signal_emit(it->o, "mouse,in", "e"); - if (scale_conf->fade_windows) - { - if (it->bd->desk != current_desk) - evas_object_color_set(it->o, 0, 0, 0, 0); - } + if (scale_conf->fade_windows) + { + if (it->bd->desk != current_desk) + evas_object_color_set(it->o, 0, 0, 0, 0); + } } _scale_in(); @@ -1348,7 +1387,6 @@ _scale_run(E_Manager *man) return EINA_TRUE; } - static Eina_Bool _scale_cb_mouse_move(void *data, int type EINA_UNUSED, void *event) { @@ -1362,13 +1400,13 @@ _scale_cb_mouse_move(void *data, int type EINA_UNUSED, void *event) if (bd_move) { - e_border_move(bd_move, - bd_move->x + (ev->x - mouse_x), - bd_move->y + (ev->y - mouse_y)); - mouse_x = ev->x; - mouse_y = ev->y; + e_border_move(bd_move, + bd_move->x + (ev->x - mouse_x), + bd_move->y + (ev->y - mouse_y)); + mouse_x = ev->x; + mouse_y = ev->y; - return ECORE_CALLBACK_PASS_ON; + return ECORE_CALLBACK_PASS_ON; } if (warp_animator) @@ -1376,16 +1414,16 @@ _scale_cb_mouse_move(void *data, int type EINA_UNUSED, void *event) if (mouse_x < 0) { - mouse_x = ev->x; - mouse_y = ev->y; - return ECORE_CALLBACK_PASS_ON; + mouse_x = ev->x; + mouse_y = ev->y; + return ECORE_CALLBACK_PASS_ON; } if ((mouse_x == ev->x) || (mouse_y == ev->y)) return ECORE_CALLBACK_PASS_ON; mouse_activated = 1; - evas_event_feed_mouse_move((Evas *) data, ev->x, ev->y, ev->timestamp, NULL); + evas_event_feed_mouse_move((Evas *)data, ev->x, ev->y, ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; } @@ -1407,13 +1445,14 @@ _scale_cb_mouse_down(void *data, int type EINA_UNUSED, void *event) if (!it) { - _scale_out(1); - return ECORE_CALLBACK_PASS_ON; + _scale_out(1); + return ECORE_CALLBACK_PASS_ON; } if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK; if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK; - evas_event_feed_mouse_down((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); + evas_event_feed_mouse_down + ((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; } @@ -1429,24 +1468,25 @@ _scale_cb_mouse_up(void *data, int type EINA_UNUSED, void *event) if (selected_item) { - selected_item->moved = EINA_FALSE; + selected_item->moved = EINA_FALSE; } if (bd_move) { - Ecore_Event_Handler *handler; - EINA_LIST_FREE(handlers, handler) - ecore_event_handler_del(handler); + Ecore_Event_Handler *handler; + EINA_LIST_FREE(handlers, handler) + ecore_event_handler_del(handler); - e_grabinput_release(input_win, input_win); - ecore_x_window_free(input_win); - input_win = 0; - bd_move = NULL; + e_grabinput_release(input_win, input_win); + ecore_x_window_free(input_win); + input_win = 0; + bd_move = NULL; - return ECORE_CALLBACK_PASS_ON; + return ECORE_CALLBACK_PASS_ON; } - evas_event_feed_mouse_up((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); + evas_event_feed_mouse_up + ((Evas *)data, ev->buttons, flags, ev->timestamp, NULL); return ECORE_CALLBACK_PASS_ON; } @@ -1459,32 +1499,32 @@ scale_run(E_Manager *man, const char *params, int _init_method) if (!strncmp(params, "go_scale_all", 12)) { - scale_layout = scale_conf->desks_layout_mode; - show_all_desks = EINA_TRUE; - show_iconified = scale_conf->desks_show_iconic; - opt = params+12; + scale_layout = scale_conf->desks_layout_mode; + show_all_desks = EINA_TRUE; + show_iconified = scale_conf->desks_show_iconic; + opt = params + 12; } else if (!strncmp(params, "go_scale_class:", 15)) { - if (scale_state) - return ret; + if (scale_state) + return ret; - scale_layout = 1; /* slotted */ - show_all_desks = EINA_TRUE; - show_iconified = EINA_TRUE; - opt = params+15; - eina_stringshare_replace(&match_class, opt); + scale_layout = 1; /* slotted */ + show_all_desks = EINA_TRUE; + show_iconified = EINA_TRUE; + opt = params + 15; + eina_stringshare_replace(&match_class, opt); } else if (!strncmp(params, "go_scale", 8)) { - scale_layout = scale_conf->layout_mode; - show_all_desks = EINA_FALSE; - show_iconified = scale_conf->show_iconic; - opt = params+8; + scale_layout = scale_conf->layout_mode; + show_all_desks = EINA_FALSE; + show_iconified = scale_conf->show_iconic; + opt = params + 8; } else { - return ret; + return ret; } init_method = _init_method; @@ -1494,27 +1534,26 @@ scale_run(E_Manager *man, const char *params, int _init_method) if (scale_state) { - if (init_method == GO_KEY) - _scale_switch(opt); + if (init_method == GO_KEY) + _scale_switch(opt); } else { - if (input_win) - return ret; + if (input_win) + return ret; - ret = _scale_run(man); + ret = _scale_run(man); } return ret; } - static void _scale_handler(void *data EINA_UNUSED, const char *name, const char *info, int val EINA_UNUSED, - E_Object *obj, void *msgdata) + E_Object *obj, void *msgdata) { E_Manager *man = (E_Manager *)obj; E_Comp_Win *src = (E_Comp_Win *)msgdata; @@ -1546,7 +1585,7 @@ _scale_handler(void *data EINA_UNUSED, else if (!strcmp(info, "add.src")) { DBG("%s: %p | %p\n", info, man, src); - e_comp_src_hidden_set(src, EINA_TRUE); + e_comp_src_hidden_set(src, EINA_TRUE); } else if (!strcmp(info, "del.src")) { @@ -1554,7 +1593,6 @@ _scale_handler(void *data EINA_UNUSED, } else if (!strcmp(info, "config.src")) { - DBG("%s: %p | %p\n", info, man, src); } else if (!strcmp(info, "visibility.src")) @@ -1576,105 +1614,108 @@ _scale_grow() double mean = 0; EINA_LIST_FOREACH(items, l, it) { - it->scale = it->w / (double)it->bd->w; - mean += it->scale; + it->scale = it->w / (double)it->bd->w; + mean += it->scale; } - mean /= (double) eina_list_count(items); + mean /= (double)eina_list_count(items); EINA_LIST_FOREACH(items, l, it) { - overlap = 0; + overlap = 0; - if (it->scale > mean) - continue; + if (it->scale > mean) + continue; - if (it->w >= it->bd->w) - continue; - if (it->h >= it->bd->h) - continue; + if (it->w >= it->bd->w) + continue; + if (it->h >= it->bd->h) + continue; - if (it->bd->w > it->bd->h) - { - grow_l = grow_r = GROW; - grow_u = grow_d = GROW * (double)it->bd->h/(double)it->bd->w; - } - else - { - grow_l = grow_r = GROW * (double)it->bd->w/(double)it->bd->h; - grow_u = grow_d = GROW; - } + if (it->bd->w > it->bd->h) + { + grow_l = grow_r = GROW; + grow_u = grow_d = GROW * (double)it->bd->h / (double)it->bd->w; + } + else + { + grow_l = grow_r = GROW * (double)it->bd->w / (double)it->bd->h; + grow_u = grow_d = GROW; + } - if (it->x - grow_l < min_x) - grow_l = 0; - if (it->y - grow_u < min_y) - grow_u = 0; - if (it->x + it->w + grow_r > max_x) - grow_r = 0; - if (it->y + it->h + grow_d > max_y) - grow_d = 0; + if (it->x - grow_l < min_x) + grow_l = 0; + if (it->y - grow_u < min_y) + grow_u = 0; + if (it->x + it->w + grow_r > max_x) + grow_r = 0; + if (it->y + it->h + grow_d > max_y) + grow_d = 0; - if ((grow_l + grow_r) == 0) - continue; - if ((grow_u + grow_d) == 0) - continue; + if ((grow_l + grow_r) == 0) + continue; + if ((grow_u + grow_d) == 0) + continue; - EINA_LIST_FOREACH(items, ll, ot) - { - if (it == ot) - continue; - if (grow_l && E_INTERSECTS(it->x - grow_l - spacing ,it->y, - it->w + spacing*2, it->h + spacing*2, - ot->x, ot->y, ot->w, ot->h)) - grow_l = 0; + EINA_LIST_FOREACH(items, ll, ot) + { + if (it == ot) + continue; + if (grow_l && E_INTERSECTS(it->x - grow_l - spacing, it->y, + it->w + spacing * 2, it->h + spacing + * 2, ot->x, ot->y, ot->w, ot->h)) + grow_l = 0; - if (grow_r && E_INTERSECTS(it->x - spacing, it->y - spacing, - it->w + grow_r + spacing*2, it->h + spacing*2, - ot->x, ot->y, ot->w, ot->h)) - grow_r = 0; + if (grow_r && E_INTERSECTS(it->x - spacing, it->y - spacing, + it->w + grow_r + spacing * 2, + it->h + spacing * 2, + ot->x, ot->y, ot->w, ot->h)) + grow_r = 0; - if ((grow_l == 0) && (grow_r == 0) && (overlap = 1)) - break; + if ((grow_l == 0) && (grow_r == 0) && (overlap = 1)) + break; - if (grow_u && E_INTERSECTS(it->x - spacing, it->y - spacing - grow_u, - it->w + spacing*2, it->h + spacing*2, - ot->x, ot->y, ot->w, ot->h)) - grow_u = 0; + if (grow_u && E_INTERSECTS(it->x - spacing, it->y - spacing - + grow_u, it->w + spacing * 2, it->h + + spacing * 2, + ot->x, ot->y, ot->w, ot->h)) + grow_u = 0; - if (grow_d && E_INTERSECTS(it->x - spacing, it->y - spacing, - it->w + spacing*2, it->h + grow_d + spacing*2, - ot->x, ot->y, ot->w, ot->h)) - grow_d = 0; + if (grow_d && E_INTERSECTS(it->x - spacing, it->y - spacing, + it->w + spacing * 2, it->h + grow_d + + spacing * 2, + ot->x, ot->y, ot->w, ot->h)) + grow_d = 0; - if ((grow_u == 0) && (grow_d == 0) && (overlap = 1)) - break; - } + if ((grow_u == 0) && (grow_d == 0) && (overlap = 1)) + break; + } - if (overlap) - continue; + if (overlap) + continue; - if (it->bd->w > it->bd->h) - { - if ((grow_u > 0) && (grow_d > 0)) - it->w += grow_l + grow_r; - else - it->w += MAX(grow_l, grow_r); + if (it->bd->w > it->bd->h) + { + if ((grow_u > 0) && (grow_d > 0)) + it->w += grow_l + grow_r; + else + it->w += MAX(grow_l, grow_r); - it->h = it->w * (double)it->bd->h / (double)it->bd->w; - } - else - { - if ((grow_r > 0) && (grow_l > 0)) - it->h += grow_u + grow_d; - else - it->h += MAX(grow_u, grow_d); + it->h = it->w * (double)it->bd->h / (double)it->bd->w; + } + else + { + if ((grow_r > 0) && (grow_l > 0)) + it->h += grow_u + grow_d; + else + it->h += MAX(grow_u, grow_d); - it->w = it->h * (double)it->bd->w / (double)it->bd->h; - } - it->x -= grow_l; - it->y -= grow_u; + it->w = it->h * (double)it->bd->w / (double)it->bd->h; + } + it->x -= grow_l; + it->y -= grow_u; - cont++; + cont++; } return cont; @@ -1690,52 +1731,52 @@ _scale_displace(Item *it, Item *ot, int disp) if (disp % 8 == 0) { - // 1. - it->y -= 1; - it->x -= 1; - // 2. - ot->x += 1; - ot->y -= 1; + // 1. + it->y -= 1; + it->x -= 1; + // 2. + ot->x += 1; + ot->y -= 1; } else if (disp % 8 == 1) { - // 3. - ot->y += 1; + // 3. + ot->y += 1; } else if (disp % 8 == 2) { - // 4. - ot->x -= 2; - ot->y += 2; + // 4. + ot->x -= 2; + ot->y += 2; } else if (disp % 8 == 3) { - // 5. - ot->x += 2; - ot->y += 2; + // 5. + ot->x += 2; + ot->y += 2; } else if (disp % 8 == 4) { - // 6. - ot->x += 1; - ot->y += 1; + // 6. + ot->x += 1; + ot->y += 1; } else if (disp % 8 == 5) { - // 7. - ot->x -= 1; - ot->y += 1; + // 7. + ot->x -= 1; + ot->y += 1; } else if (disp % 8 == 6) { - // 8. - ot->x -= 1; - ot->y -= 1; + // 8. + ot->x -= 1; + ot->y -= 1; } else if (disp % 8 == 7) { - ot->x += 1; - ot->y -= 1; + ot->x += 1; + ot->y -= 1; } } @@ -1749,110 +1790,110 @@ _scale_place(int offset) EINA_LIST_FOREACH(items, l, it) { - it->mx = it->x; - it->my = it->y; + it->mx = it->x; + it->my = it->y; } int disp = 0; EINA_LIST_FOREACH(items, l, it) { - EINA_LIST_FOREACH(items, ll, ot) - { - int w = it->w; - int h = it->h; + EINA_LIST_FOREACH(items, ll, ot) + { + int w = it->w; + int h = it->h; - if (it == ot) - continue; + if (it == ot) + continue; - if (!E_INTERSECTS(it->x - offset, it->y - offset, - it->w + offset*2, it->h + offset*2, - ot->x, ot->y, ot->w, ot->h)) - continue; + if (!E_INTERSECTS(it->x - offset, it->y - offset, + it->w + offset * 2, it->h + offset * 2, + ot->x, ot->y, ot->w, ot->h)) + continue; - overlap += 1; + overlap += 1; - it->overlaps++; + it->overlaps++; - if (it->x < ot->x) - w += it->x - ot->x; - if (w < 0) w = 0; + if (it->x < ot->x) + w += it->x - ot->x; + if (w < 0) w = 0; - if (it->x + it->w > ot->x + ot->w) - w = ot->x + ot->w - it->x; + if (it->x + it->w > ot->x + ot->w) + w = ot->x + ot->w - it->x; - if (it->y < ot->y) - h += it->y - ot->y; - if (h < 0) h = 0; + if (it->y < ot->y) + h += it->y - ot->y; + if (h < 0) h = 0; - if (it->y + it->h > ot->y + ot->h) - h = ot->y + ot->h - it->y; + if (it->y + it->h > ot->y + ot->h) + h = ot->y + ot->h - it->y; - double dist_y = (it->y + it->h/2) - (ot->y + ot->h/2); - double dist_x = (it->x + it->w/2) - (ot->x + ot->w/2); + double dist_y = (it->y + it->h / 2) - (ot->y + ot->h / 2); + double dist_x = (it->x + it->w / 2) - (ot->x + ot->w / 2); - if (dist_x == 0 && dist_y == 0) - { - _scale_displace(it, ot, disp); - disp++; - } - else if (w > h) - { - if (dist_y) - { - dist_y = (dist_y > 0 ? 2 : -2); - it->my += dist_y; - } - if (dist_x) - { - dist_x = (dist_x > 0 ? 1 : -1); - it->mx += dist_x; - } - } - else //if (w < h) - { - if (dist_y) - { - dist_y = (dist_y > 0 ? 1 : -1); - it->my += dist_y; - } - if (dist_x) - { - dist_x = (dist_x > 0 ? 2 : -2); - it->mx += dist_x; - } - } - } + if (dist_x == 0 && dist_y == 0) + { + _scale_displace(it, ot, disp); + disp++; + } + else if (w > h) + { + if (dist_y) + { + dist_y = (dist_y > 0 ? 2 : -2); + it->my += dist_y; + } + if (dist_x) + { + dist_x = (dist_x > 0 ? 1 : -1); + it->mx += dist_x; + } + } + else //if (w < h) + { + if (dist_y) + { + dist_y = (dist_y > 0 ? 1 : -1); + it->my += dist_y; + } + if (dist_x) + { + dist_x = (dist_x > 0 ? 2 : -2); + it->mx += dist_x; + } + } + } } EINA_LIST_FOREACH(items, l, it) { - it->x = it->mx; - it->y = it->my; + it->x = it->mx; + it->y = it->my; - if (it->x < min_x) - { - outside = 1; - it->x = min_x; - } + if (it->x < min_x) + { + outside = 1; + it->x = min_x; + } - if (it->y < min_y) - { - outside = 1; - it->y = min_y; - } + if (it->y < min_y) + { + outside = 1; + it->y = min_y; + } - if (it->x + it->w > max_x) - { - outside = 1; - it->x = max_x - it->w; - } + if (it->x + it->w > max_x) + { + outside = 1; + it->x = max_x - it->w; + } - if (it->y + it->h > max_y) - { - outside = 1; - it->y = max_y - it->h; - } + if (it->y + it->h > max_y) + { + outside = 1; + it->y = max_y - it->h; + } } if (!(overlap || outside)) @@ -1860,30 +1901,30 @@ _scale_place(int offset) if (outside && (step_count++ > 50)) { - double zone_diag = sqrt(zone->w * zone->h); - double sw, sh; - step_count = 0; - EINA_LIST_FOREACH(items, l, it) - { - if (!it->overlaps) - continue; + double zone_diag = sqrt(zone->w * zone->h); + double sw, sh; + step_count = 0; + EINA_LIST_FOREACH(items, l, it) + { + if (!it->overlaps) + continue; - if (it->scale <= 0.005) - continue; + if (it->scale <= 0.005) + continue; - it->scale -= it->scale * - (0.001 + (sqrt(it->bd->w * it->bd->h) / zone_diag) / 50.0); + it->scale -= it->scale * + (0.001 + (sqrt(it->bd->w * it->bd->h) / zone_diag) / 50.0); - sw = (double)it->bd->w * it->scale; - sh = (double)it->bd->h * it->scale; - it->x += (it->w - sw)/2.0; - it->y += (it->h - sh)/2.0; - it->w = sw; - it->h = sh; + sw = (double)it->bd->w * it->scale; + sh = (double)it->bd->h * it->scale; + it->x += (it->w - sw) / 2.0; + it->y += (it->h - sh) / 2.0; + it->w = sw; + it->h = sh; - it->overlaps = 0; - } - return 1; + it->overlaps = 0; + } + return 1; } return overlap || outside; @@ -1895,13 +1936,13 @@ _cb_sort_center(const void *d1, const void *d2) const Item *it1 = d1; const Item *it2 = d2; - double dx1 = ((it1->x + it1->w/2.0) - (double)(max_width/2)); - double dy1 = ((it1->y + it1->h/2.0) - (double)(max_height/2)); + double dx1 = ((it1->x + it1->w / 2.0) - (double)(max_width / 2)); + double dy1 = ((it1->y + it1->h / 2.0) - (double)(max_height / 2)); - double dx2 = ((it2->x + it2->w/2.0) - (double)(max_width/2)); - double dy2 = ((it2->y + it2->h/2.0) - (double)(max_height/2)); + double dx2 = ((it2->x + it2->w / 2.0) - (double)(max_width / 2)); + double dy2 = ((it2->y + it2->h / 2.0) - (double)(max_height / 2)); - return (sqrt(dx1*dx1 + dy1*dy1) > sqrt(dx2*dx2 + dy2*dy2)) ? -1 : 1; + return (sqrt(dx1 * dx1 + dy1 * dy1) > sqrt(dx2 * dx2 + dy2 * dy2)) ? -1 : 1; } static void @@ -1911,18 +1952,18 @@ _scale_place_natural() int offset, i = 0; Item *it; - max_width = zone->w; + max_width = zone->w; max_height = zone->h; if (show_all_desks) { - max_width = zone->h * zone->desk_x_count; - max_height = zone->w * zone->desk_y_count; + max_width = zone->h * zone->desk_x_count; + max_height = zone->w * zone->desk_y_count; - min_x = zone->w * -zone->desk_x_current; - min_y = zone->h * -zone->desk_y_current; - max_x = zone->w * (zone->desk_x_count - zone->desk_x_current); - max_y = zone->h * (zone->desk_y_count - zone->desk_y_current); + min_x = zone->w * -zone->desk_x_current; + min_y = zone->h * -zone->desk_y_current; + max_x = zone->w * (zone->desk_x_count - zone->desk_x_current); + max_y = zone->h * (zone->desk_y_count - zone->desk_y_current); } items = eina_list_sort(items, eina_list_count(items), _cb_sort_center); @@ -1937,35 +1978,37 @@ _scale_place_natural() step_count = 0; while ((i++ < PLACE_RUNS) && - (_scale_place(offset) || - (min_x < use_x) || - (min_y < use_y) || - (max_x > use_w) || - (max_y > use_h))) + (_scale_place(offset) || + (min_x < use_x) || + (min_y < use_y) || + (max_x > use_w) || + (max_y > use_h))) { - /* shrink region to visible region */ - if (min_x < use_x) min_x += 2; - if (min_y < use_y) min_y += 2; - if (min_x > use_x) min_x = use_x; - if (min_y > use_y) min_y = use_y; + /* shrink region to visible region */ + if (min_x < use_x) min_x += 2; + if (min_y < use_y) min_y += 2; + if (min_x > use_x) min_x = use_x; + if (min_y > use_y) min_y = use_y; - if (max_x > use_w) max_x -= 2; - if (max_y > use_h) max_y -= 2; - if (max_x < use_w) max_x = use_w; - if (max_y < use_h) max_y = use_h; + if (max_x > use_w) max_x -= 2; + if (max_y > use_h) max_y -= 2; + if (max_x < use_w) max_x = use_w; + if (max_y < use_h) max_y = use_h; - if (!show_all_desks) - continue; + if (!show_all_desks) + continue; - /* move other desks windows into visible region */ - EINA_LIST_FOREACH(items, l, it) - { - if ((min_x < use_x) && (it->dx < 0) && it->x < 0) it->x += 4.0; - if ((min_y < use_y) && (it->dy < 0) && it->y < 0) it->y += 4.0; + /* move other desks windows into visible region */ + EINA_LIST_FOREACH(items, l, it) + { + if ((min_x < use_x) && (it->dx < 0) && it->x < 0) it->x += 4.0; + if ((min_y < use_y) && (it->dy < 0) && it->y < 0) it->y += 4.0; - if ((max_x > use_w) && (it->dx > 0) && it->x > zone->w) it->x -= 4.0; - if ((max_y > use_h) && (it->dy > 0) && it->y > zone->h) it->y -= 4.0; - } + if ((max_x > use_w) && (it->dx > 0) && it->x > zone->w) + it->x -= 4.0; + if ((max_y > use_h) && (it->dy > 0) && it->y > zone->h) + it->y -= 4.0; + } } } @@ -1978,54 +2021,55 @@ _scale_shrink() double move_x; double move_y; int x, y, w, h; - + EINA_LIST_REVERSE_FOREACH(items, l, it) { - if (show_all_desks) - { - move_x = ((it->x + it->w/2.0) - zone->w/2.0) / 5.0; - move_y = ((it->y + it->h/2.0) - zone->h/2.0) / 5.0; - } - else - { - move_x = ((it->x + it->w/2.0) - - (double)(it->bd_x + it->bd->w/2.0)) / 10.0; - move_y = ((it->y + it->h/2.0) - - (double)(it->bd_y + it->bd->h/2.0)) / 10.0; - } + if (show_all_desks) + { + move_x = ((it->x + it->w / 2.0) - zone->w / 2.0) / 5.0; + move_y = ((it->y + it->h / 2.0) - zone->h / 2.0) / 5.0; + } + else + { + move_x = ((it->x + it->w / 2.0) - + (double)(it->bd_x + it->bd->w / 2.0)) / 10.0; + move_y = ((it->y + it->h / 2.0) - + (double)(it->bd_y + it->bd->h / 2.0)) / 10.0; + } - if (!(move_y || move_x)) - continue; + if (!(move_y || move_x)) + continue; - x = it->x - spacing; - y = it->y - spacing; - w = it->w + spacing*2; - h = it->h + spacing*2; + x = it->x - spacing; + y = it->y - spacing; + w = it->w + spacing * 2; + h = it->h + spacing * 2; - EINA_LIST_FOREACH(items, ll, ot) - { - if (it == ot) continue; + EINA_LIST_FOREACH(items, ll, ot) + { + if (it == ot) continue; - while ((move_x) && (E_INTERSECTS(x - move_x, y, w, h, ot->x, ot->y, ot->w, ot->h))) - move_x = move_x / 2.0; + while ((move_x) && (E_INTERSECTS(x - move_x, y, w, + h, ot->x, ot->y, ot->w, ot->h))) + move_x = move_x / 2.0; - while ((move_y) && (E_INTERSECTS(x, y - move_y, w, h, ot->x, ot->y, ot->w, ot->h))) - move_y = move_y / 2.0; + while ((move_y) && (E_INTERSECTS(x, y - move_y, w, + h, ot->x, ot->y, ot->w, ot->h))) + move_y = move_y / 2.0; - if (!(move_y || move_x)) break; - } + if (!(move_y || move_x)) break; + } - it->x -= move_x; - it->y -= move_y; + it->x -= move_x; + it->y -= move_y; - if (move_y > 1 || move_x > 1) - shrunk++; + if (move_y > 1 || move_x > 1) + shrunk++; } return shrunk; } - /* TODO add slot item an calc distance only once */ static Slot *cur_slot = NULL; @@ -2037,7 +2081,7 @@ _slot_dist(const Item *it, const Slot *slot) double dw = (it->x + it->w) - (slot->x + slot->w); double dh = (it->y + it->h) - (slot->y + slot->h); - return (sqrt(dx*dx + dy*dy + dw*dw + dh*dh)); + return sqrt(dx * dx + dy * dy + dw * dw + dh * dh); } static int @@ -2063,30 +2107,30 @@ _scale_place_slotted() cnt = eina_list_count(items); rows = sqrt(cnt); - cols = cnt/rows; + cols = cnt / rows; - if (cols*rows < cnt) + if (cols * rows < cnt) cols += 1; if (cnt <= 2) { - cols = 2; - rows = 1; + cols = 2; + rows = 1; } else if (cnt <= 4) { - cols = 2; - rows = 2; + cols = 2; + rows = 2; } else if (cnt <= 6) { - cols = 3; - rows = 2; + cols = 3; + rows = 2; } else if (cnt <= 8) { - cols = 3; - rows = 3; + cols = 3; + rows = 3; } DBG("%d rows, %d cols -- cnt %d\n", rows, cols, cnt); @@ -2096,20 +2140,20 @@ _scale_place_slotted() EINA_LIST_FOREACH(items, l, it) { - if (it->x < min_x) min_x = it->x; - if (it->y < min_y) min_y = it->y; - if (it->x + it->w > max_x) max_x = it->x + it->w; - if (it->y + it->h > max_y) max_y = it->y + it->h; + if (it->x < min_x) min_x = it->x; + if (it->y < min_y) min_y = it->y; + if (it->x + it->w > max_x) max_x = it->x + it->w; + if (it->y + it->h > max_y) max_y = it->y + it->h; - EINA_LIST_FOREACH(l->next, ll, it2) - { - if ((it->x + it->w/2 == it2->x + it2->w/2) && - (it->y + it->h/2 == it2->y + it2->h/2)) - { - it2->x += 1; - it2->y += 1; - } - } + EINA_LIST_FOREACH(l->next, ll, it2) + { + if ((it->x + it->w / 2 == it2->x + it2->w / 2) && + (it->y + it->h / 2 == it2->y + it2->h / 2)) + { + it2->x += 1; + it2->y += 1; + } + } } w = (max_x - min_x) / cols; @@ -2118,89 +2162,89 @@ _scale_place_slotted() for (y = 0; y < rows; y++) { - for (x = 0; x < cols; x++) - { - if (fast && !l) break; + for (x = 0; x < cols; x++) + { + if (fast && !l) break; - slot = E_NEW(Slot, 1); - slot->x = min_x + x * w; - slot->y = min_y + y * h; - slot->w = w; - slot->h = h; + slot = E_NEW(Slot, 1); + slot->x = min_x + x * w; + slot->y = min_y + y * h; + slot->w = w; + slot->h = h; - if (fast) - { - slot->it = eina_list_data_get(l); - if (l) l = l->next; - } - else - { - cur_slot = slot; - slot->items = eina_list_clone(items); - slot->items = eina_list_sort(slot->items, cnt, - _cb_sort_nearest); - slot->it = eina_list_data_get(slot->items); - slot->items = eina_list_remove_list(slot->items, - slot->items); - slot->min = _slot_dist(slot->it, slot); - } + if (fast) + { + slot->it = eina_list_data_get(l); + if (l) l = l->next; + } + else + { + cur_slot = slot; + slot->items = eina_list_clone(items); + slot->items = eina_list_sort(slot->items, cnt, + _cb_sort_nearest); + slot->it = eina_list_data_get(slot->items); + slot->items = eina_list_remove_list(slot->items, + slot->items); + slot->min = _slot_dist(slot->it, slot); + } - slots = eina_list_append(slots, slot); + slots = eina_list_append(slots, slot); - DBG("add slot: %dx%d, \t%f -> %d:%d\n", - slot->x, slot->y, slot->min, - (int)(slot->it->x), (int)(slot->it->y)); - } + DBG("add slot: %dx%d, \t%f -> %d:%d\n", + slot->x, slot->y, slot->min, + (int)(slot->it->x), (int)(slot->it->y)); + } } if (!fast) { - cont = 1; - EINA_LIST_FOREACH(items, l, it) - it->in_slots = cols * rows; + cont = 1; + EINA_LIST_FOREACH(items, l, it) + it->in_slots = cols * rows; } for (i = 0; (i < PLACE_RUNS) && cont; i++) { - cont = 0; - EINA_LIST_FOREACH(slots, l, slot) - { - EINA_LIST_FOREACH(slots, ll, slot2) - { - if (slot == slot2) - continue; + cont = 0; + EINA_LIST_FOREACH(slots, l, slot) + { + EINA_LIST_FOREACH(slots, ll, slot2) + { + if (slot == slot2) + continue; - if (slot->it != slot2->it) - continue; + if (slot->it != slot2->it) + continue; - Item *it1 = eina_list_data_get(slot->items); - Item *it2 = eina_list_data_get(slot2->items); - if (!it1 || !it2) - continue; + Item *it1 = eina_list_data_get(slot->items); + Item *it2 = eina_list_data_get(slot2->items); + if (!it1 || !it2) + continue; - double d1 = _slot_dist(it1, slot); - double d2 = _slot_dist(it2, slot2); + double d1 = _slot_dist(it1, slot); + double d2 = _slot_dist(it2, slot2); - cont = 1; + cont = 1; - DBG("%dx%d - compare:\n\ts1: %dx%d (%dx%d:%f)," - "\n\ts2 %dx%d (%dx%d:%f)\n", - (int)slot->it->x, (int)slot->it->y, - slot->x, slot->y, (int)it1->x, (int)it1->y, d1, - slot2->x, slot2->y, (int)it2->x, (int)it2->y, d2); + DBG("%dx%d - compare:\n\ts1: %dx%d (%dx%d:%f)," + "\n\ts2 %dx%d (%dx%d:%f)\n", + (int)slot->it->x, (int)slot->it->y, + slot->x, slot->y, (int)it1->x, (int)it1->y, d1, + slot2->x, slot2->y, (int)it2->x, (int)it2->y, d2); - if ((slot->it->in_slots > 1) && - (slot->min + d1 >= slot2->min + d2)) - { - slot->it->in_slots--; - slot->it = it1; - slot->min = d1; - slot->items = eina_list_remove_list(slot->items, - slot->items); - break; - } - } - } + if ((slot->it->in_slots > 1) && + (slot->min + d1 >= slot2->min + d2)) + { + slot->it->in_slots--; + slot->it = it1; + slot->min = d1; + slot->items = eina_list_remove_list(slot->items, + slot->items); + break; + } + } + } } cont = 1; @@ -2208,49 +2252,51 @@ _scale_place_slotted() for (i = 0; (i < PLACE_RUNS) && cont; i++) { cont = 0; - EINA_LIST_FOREACH(slots, l, slot) - { - EINA_LIST_FOREACH(l->next, ll, slot2) - { - double d1, d2; + EINA_LIST_FOREACH(slots, l, slot) + { + EINA_LIST_FOREACH(l->next, ll, slot2) + { + double d1, d2; - d1 = _slot_dist(slot->it, slot) + _slot_dist(slot2->it, slot2); - d2 = _slot_dist(slot->it, slot2) + _slot_dist(slot2->it, slot); - if (d1 > d2) - { - it = slot->it; - slot->it = slot2->it; - slot2->it = it; - cont = 1; - } - } - } + d1 = _slot_dist(slot->it, slot) + + _slot_dist(slot2->it, slot2); + d2 = _slot_dist(slot->it, slot2) + + _slot_dist(slot2->it, slot); + if (d1 > d2) + { + it = slot->it; + slot->it = slot2->it; + slot2->it = it; + cont = 1; + } + } + } } EINA_LIST_FOREACH(slots, l, slot) { - if (!slot->it) - continue; + if (!slot->it) + continue; - EINA_LIST_FOREACH(slots, ll, slot2) - { - if (!slot2->it) - continue; + EINA_LIST_FOREACH(slots, ll, slot2) + { + if (!slot2->it) + continue; - if (slot == slot2) - continue; + if (slot == slot2) + continue; - if (slot->it != slot2->it) - continue; + if (slot->it != slot2->it) + continue; - if (_slot_dist(slot->it, slot) > _slot_dist(slot2->it, slot2)) - { - slot->it = NULL; - break; - } - else - slot2->it = NULL; - } + if (_slot_dist(slot->it, slot) > _slot_dist(slot2->it, slot2)) + { + slot->it = NULL; + break; + } + else + slot2->it = NULL; + } } h = (zone->h - spacing) / rows; @@ -2258,71 +2304,71 @@ _scale_place_slotted() for (y = 0, l = slots; l && (y < rows); y++) { - ll = l; - for (x = 0, cnt = 0; l && x < cols; x++, l = eina_list_next(l)) - { - slot = eina_list_data_get(l); - if (slot->it) cnt++; - } + ll = l; + for (x = 0, cnt = 0; l && x < cols; x++, l = eina_list_next(l)) + { + slot = eina_list_data_get(l); + if (slot->it) cnt++; + } - if (cnt < cols) - start = (w * (cols - cnt))/2.0; - else - start = spacing/2.0; + if (cnt < cols) + start = (w * (cols - cnt)) / 2.0; + else + start = spacing / 2.0; - for (x = 0; ll && x < cnt; ll = eina_list_next(ll)) - { - slot = eina_list_data_get(ll); - if (!slot->it) continue; + for (x = 0; ll && x < cnt; ll = eina_list_next(ll)) + { + slot = eina_list_data_get(ll); + if (!slot->it) continue; - slot->x = start + x * w; - slot->y = y * h; - slot->w = w; - slot->h = h; - x++; - } + slot->x = start + x * w; + slot->y = y * h; + slot->w = w; + slot->h = h; + x++; + } } Item *prev = NULL; Item *first = NULL; EINA_LIST_FOREACH(slots, l, slot) { - if (slot->it) - { - it = slot->it; + if (slot->it) + { + it = slot->it; - it->prev = prev; - prev = it; + it->prev = prev; + prev = it; - if (it->prev) - it->prev->next = it; + if (it->prev) + it->prev->next = it; - if (!first) - first = it; + if (!first) + first = it; - it->slot_x = slot->x; - it->slot_y = slot->y; + it->slot_x = slot->x; + it->slot_y = slot->y; - if (it->w > slot->w - spacing) - { - it->w = slot->w - spacing; - it->h = it->w * (double)it->bd->h / (double)it->bd->w; - } - if (it->h > slot->h - spacing) - { - it->h = slot->h - spacing; - it->w = it->h * (double)it->bd->w / (double)it->bd->h; - } - it->x = slot->x + (slot->w - it->w)/2.0; - it->y = slot->y + (slot->h - it->h)/2.0; + if (it->w > slot->w - spacing) + { + it->w = slot->w - spacing; + it->h = it->w * (double)it->bd->h / (double)it->bd->w; + } + if (it->h > slot->h - spacing) + { + it->h = slot->h - spacing; + it->w = it->h * (double)it->bd->w / (double)it->bd->h; + } + it->x = slot->x + (slot->w - it->w) / 2.0; + it->y = slot->y + (slot->h - it->h) / 2.0; - DBG("place: %d:%d %dx%d -> %d:%d %dx%d\n", - (int)it->bd_x, (int)it->bd_y, (int)it->bd->w, (int)it->bd->h, - (int)it->x, (int)it->y, (int)it->w, (int)it->h); - } + DBG("place: %d:%d %dx%d -> %d:%d %dx%d\n", + (int)it->bd_x, (int)it->bd_y, (int)it->bd->w, (int)it->bd->h, + (int)it->x, (int)it->y, (int)it->w, (int)it->h); + } - EINA_LIST_FREE(slot->items, it); - E_FREE(slot); + EINA_LIST_FREE(slot->items, it) ; + E_FREE(slot); } first->prev = prev;