2013-10-03 06:34:52 -07:00
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
|
|
|
EAPI E_Module_Api e_modapi = {E_MODULE_API_VERSION, "Desksanity"};
|
|
|
|
static E_Config_DD *conf_edd = NULL;
|
|
|
|
|
|
|
|
EINTERN Mod *mod = NULL;
|
|
|
|
EINTERN Config *ds_config = NULL;
|
|
|
|
|
2014-08-19 03:43:53 -07:00
|
|
|
static Evas_Object *fade_obj = NULL;
|
|
|
|
|
2015-11-09 11:41:48 -08:00
|
|
|
static E_Action *act;
|
|
|
|
static Eina_List *urgent;
|
|
|
|
static Eina_List *focus_list;
|
|
|
|
|
|
|
|
static Eina_List *handlers;
|
|
|
|
|
2014-08-19 03:43:53 -07:00
|
|
|
static void
|
|
|
|
_ds_fade_end(Ecore_Cb cb, Efx_Map_Data *emd EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
|
|
|
|
{
|
|
|
|
E_FREE_FUNC(fade_obj, evas_object_del);
|
|
|
|
if (cb)
|
|
|
|
cb(NULL);
|
|
|
|
}
|
|
|
|
|
2013-10-03 06:34:52 -07:00
|
|
|
static void
|
2013-10-10 05:14:08 -07:00
|
|
|
_e_mod_ds_config_load(void)
|
2013-10-03 06:34:52 -07:00
|
|
|
{
|
|
|
|
#undef T
|
|
|
|
#undef D
|
|
|
|
conf_edd = E_CONFIG_DD_NEW("Config", Config);
|
|
|
|
#define T Config
|
|
|
|
#define D conf_edd
|
|
|
|
E_CONFIG_VAL(D, T, config_version, UINT);
|
2014-07-30 09:27:56 -07:00
|
|
|
E_CONFIG_VAL(D, T, disable_ruler, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, disable_maximize, UCHAR);
|
2014-07-30 10:00:22 -07:00
|
|
|
E_CONFIG_VAL(D, T, disable_transitions, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, disabled_transition_count, UINT);
|
|
|
|
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_PAN, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_FADE_OUT, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_FADE_IN, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_BATMAN, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_ZOOM_IN, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_ZOOM_OUT, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_GROW, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_ROTATE_OUT, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_ROTATE_IN, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_SLIDE_SPLIT, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_QUAD_SPLIT, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_QUAD_MERGE, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_BLINK, UCHAR);
|
|
|
|
E_CONFIG_VAL(D, T, types.disable_VIEWPORT, UCHAR);
|
2013-10-03 06:34:52 -07:00
|
|
|
|
2014-07-30 09:27:56 -07:00
|
|
|
ds_config = e_config_domain_load("module.desksanity", conf_edd);
|
2013-10-03 06:34:52 -07:00
|
|
|
if (ds_config)
|
|
|
|
{
|
|
|
|
if (!e_util_module_config_check("Desksanity", ds_config->config_version, MOD_CONFIG_FILE_VERSION))
|
2014-07-30 09:27:56 -07:00
|
|
|
E_FREE(ds_config);
|
2013-10-03 06:34:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ds_config)
|
2014-07-30 09:27:56 -07:00
|
|
|
ds_config = E_NEW(Config, 1);
|
|
|
|
ds_config->config_version = MOD_CONFIG_FILE_VERSION;
|
2013-10-03 06:34:52 -07:00
|
|
|
}
|
|
|
|
|
2015-11-09 11:41:48 -08:00
|
|
|
static E_Client *
|
|
|
|
ds_client_urgent_pop(E_Client *ec)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
if (!urgent) return NULL;
|
|
|
|
l = eina_list_data_find_list(urgent, ec);
|
|
|
|
if (!l) return NULL;
|
|
|
|
urgent = eina_list_remove_list(urgent, l);
|
|
|
|
return !!e_object_unref(E_OBJECT(ec)) ? ec : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ds_key_focus(void)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
E_Client *ec;
|
|
|
|
E_Zone *focus_zone = NULL;
|
|
|
|
|
|
|
|
if (!focus_list)
|
|
|
|
focus_zone = e_zone_current_get();
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(focus_list ?: e_client_focus_stack_get(), l, ec)
|
|
|
|
if ((!ec->iconic) && (!ec->focused) &&
|
|
|
|
((!focus_zone) || ((ec->zone == focus_zone) && (!ec->desk->visible))))
|
|
|
|
{
|
|
|
|
e_client_activate(ec, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
focus_list = eina_list_free(focus_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ds_key(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
|
|
|
|
{
|
|
|
|
E_Client *ec = NULL;
|
|
|
|
|
|
|
|
if (!urgent)
|
|
|
|
{
|
|
|
|
ds_key_focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!ec)
|
|
|
|
ec = ds_client_urgent_pop(eina_list_data_get(urgent));
|
|
|
|
if (ec)
|
|
|
|
{
|
|
|
|
eina_list_free(focus_list);
|
|
|
|
focus_list = eina_list_clone(e_client_focus_stack_get());
|
|
|
|
e_client_activate(ec, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ds_key_focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
ds_client_remove(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client *ev)
|
|
|
|
{
|
|
|
|
ds_client_urgent_pop(ev->ec);
|
|
|
|
if (focus_list)
|
|
|
|
focus_list = eina_list_remove(focus_list, ev->ec);
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
ds_client_urgent(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Client_Property *ev)
|
|
|
|
{
|
|
|
|
if (!(ev->property & E_CLIENT_PROPERTY_URGENCY)) return ECORE_CALLBACK_RENEW;
|
|
|
|
|
|
|
|
if (ev->ec->urgent)
|
|
|
|
{
|
|
|
|
e_object_ref(E_OBJECT(ev->ec));
|
|
|
|
urgent = eina_list_append(urgent, ev->ec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ds_client_urgent_pop(ev->ec);
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2013-10-03 06:34:52 -07:00
|
|
|
EAPI void *
|
|
|
|
e_modapi_init(E_Module *m)
|
|
|
|
{
|
2014-07-30 09:27:56 -07:00
|
|
|
char buf[PATH_MAX];
|
2013-10-03 06:34:52 -07:00
|
|
|
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
bind_textdomain_codeset(PACKAGE, "UTF-8");
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/e-module-desksanity.edj", m->dir);
|
2014-02-11 16:31:02 -08:00
|
|
|
elm_theme_overlay_add(NULL, buf);
|
2013-10-03 06:34:52 -07:00
|
|
|
|
|
|
|
efx_init();
|
2014-07-30 09:27:56 -07:00
|
|
|
_e_mod_ds_config_load();
|
2013-10-03 06:34:52 -07:00
|
|
|
|
|
|
|
mod = E_NEW(Mod, 1);
|
|
|
|
mod->module = m;
|
2013-10-15 07:37:39 -07:00
|
|
|
mod->edje_file = eina_stringshare_add(buf);
|
2013-10-03 06:34:52 -07:00
|
|
|
|
2014-07-30 09:27:56 -07:00
|
|
|
ds_config_init();
|
2014-07-30 10:00:22 -07:00
|
|
|
if (!ds_config->disable_transitions)
|
|
|
|
ds_init();
|
2014-07-30 09:27:56 -07:00
|
|
|
if (!ds_config->disable_ruler)
|
|
|
|
mr_init();
|
|
|
|
if (!ds_config->disable_maximize)
|
|
|
|
maximize_init();
|
2013-10-03 06:34:52 -07:00
|
|
|
|
2014-07-30 12:43:27 -07:00
|
|
|
pip_init();
|
2014-08-19 16:02:57 -07:00
|
|
|
zoom_init();
|
2014-08-22 15:14:21 -07:00
|
|
|
mag_init();
|
2014-07-30 12:43:27 -07:00
|
|
|
|
2015-11-09 11:41:48 -08:00
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_PROPERTY, ds_client_urgent, NULL);
|
|
|
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_CLIENT_REMOVE, ds_client_remove, NULL);
|
|
|
|
|
|
|
|
act = e_action_add("ds_key");
|
|
|
|
e_action_predef_name_set(D_("Desksanity"), D_("Manage Window Focus For Me"), "ds_key", NULL, NULL, 0);
|
|
|
|
act->func.go = ds_key;
|
|
|
|
|
2013-10-03 06:34:52 -07:00
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
e_modapi_shutdown(E_Module *m EINA_UNUSED)
|
|
|
|
{
|
2014-08-22 15:14:21 -07:00
|
|
|
mag_shutdown();
|
2014-08-19 16:02:57 -07:00
|
|
|
zoom_shutdown();
|
2014-07-30 12:43:27 -07:00
|
|
|
pip_shutdown();
|
2014-07-30 09:27:56 -07:00
|
|
|
if (!ds_config->disable_maximize)
|
|
|
|
maximize_shutdown();
|
|
|
|
if (!ds_config->disable_ruler)
|
|
|
|
mr_shutdown();
|
2014-07-30 10:00:22 -07:00
|
|
|
if (!ds_config->disable_transitions)
|
|
|
|
ds_shutdown();
|
2014-07-30 09:27:56 -07:00
|
|
|
ds_config_shutdown();
|
|
|
|
e_config_domain_save("module.desksanity", conf_edd, ds_config);
|
|
|
|
E_FREE(ds_config);
|
2013-10-03 06:34:52 -07:00
|
|
|
E_CONFIG_DD_FREE(conf_edd);
|
2014-07-30 09:01:25 -07:00
|
|
|
eina_stringshare_del(mod->edje_file);
|
2013-10-03 06:34:52 -07:00
|
|
|
E_FREE(mod);
|
2015-11-09 11:41:48 -08:00
|
|
|
E_FREE_FUNC(act, e_action_del);
|
|
|
|
e_action_predef_name_del(D_("Desksanity"), "ds_key");
|
|
|
|
E_FREE_LIST(handlers, ecore_event_handler_del);
|
|
|
|
E_FREE_LIST(urgent, e_object_unref);
|
|
|
|
focus_list = eina_list_free(focus_list);
|
2014-02-12 17:38:51 -08:00
|
|
|
//efx_shutdown(); broken...
|
2013-10-03 06:34:52 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI int
|
|
|
|
e_modapi_save(E_Module *m EINA_UNUSED)
|
|
|
|
{
|
2014-07-30 09:27:56 -07:00
|
|
|
e_config_domain_save("module.desksanity", conf_edd, ds_config);
|
2013-10-03 06:34:52 -07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-08-19 03:43:53 -07:00
|
|
|
EINTERN void
|
2015-03-13 17:02:46 -07:00
|
|
|
ds_fade_setup(Evas_Object_Event_Cb click_cb)
|
2014-08-19 03:43:53 -07:00
|
|
|
{
|
|
|
|
if (fade_obj) return;
|
2015-03-13 17:02:46 -07:00
|
|
|
fade_obj = evas_object_rectangle_add(e_comp->evas);
|
2014-08-22 07:32:10 -07:00
|
|
|
if (click_cb)
|
|
|
|
evas_object_event_callback_add(fade_obj, EVAS_CALLBACK_MOUSE_DOWN, click_cb, NULL);
|
2014-08-19 03:43:53 -07:00
|
|
|
evas_object_name_set(fade_obj, "fade_obj");
|
2015-03-19 14:17:25 -07:00
|
|
|
evas_object_geometry_set(fade_obj, 0, 0, e_comp->w, e_comp->h);
|
2014-08-19 03:43:53 -07:00
|
|
|
evas_object_layer_set(fade_obj, E_LAYER_MENU + 1);
|
|
|
|
evas_object_show(fade_obj);
|
|
|
|
efx_fade(fade_obj, EFX_EFFECT_SPEED_LINEAR, EFX_COLOR(0, 0, 0), 0, 0.0, NULL, NULL);
|
|
|
|
efx_fade(fade_obj, EFX_EFFECT_SPEED_LINEAR, EFX_COLOR(0, 0, 0), 192, 0.3, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
EINTERN void
|
2014-08-22 07:32:10 -07:00
|
|
|
ds_fade_end(Ecore_Cb end_cb, Evas_Object_Event_Cb click_cb)
|
2014-08-19 03:43:53 -07:00
|
|
|
{
|
2014-08-22 15:22:38 -07:00
|
|
|
evas_object_pass_events_set(fade_obj, 1);
|
2014-08-19 03:43:53 -07:00
|
|
|
efx_fade(fade_obj, EFX_EFFECT_SPEED_DECELERATE, EFX_COLOR(0, 0, 0), 0, 0.3, (Efx_End_Cb)_ds_fade_end, end_cb);
|
2014-08-22 07:32:10 -07:00
|
|
|
if (click_cb)
|
|
|
|
evas_object_event_callback_del(fade_obj, EVAS_CALLBACK_MOUSE_DOWN, click_cb);
|
2014-08-19 03:43:53 -07:00
|
|
|
}
|