<commit_before>#include "e.h"
#include "e_mod_main.h"

/* TODO List:
 * 
 * * bug in shadow_x < 0 and shadow_y < 0 needs to be fixed (not urgent though)
 * * bug in ecore_config ? when we change shadow darkness in examine, _ds_config_listen_shadow_darkness does not get called - only when we change other values like x, y, blur and when it gets called we are not getting the value set in examine - always getting 0.5
 * * add alpha-pixel only pixel space to image objects in evas and make use of it to save cpu and ram
 * * when blurring ALSO cut out the overlayed rect frrom the blur algorithm
 * * handle shaped windows efficiently (as possible).
 * 
 */

/* module private routines */
static Dropshadow *_ds_init(E_Module *m);
static void        _ds_shutdown(Dropshadow *ds);
static int         _ds_config_listen_shadow_x(const char *key, const Ecore_Config_Type type, const int tag, void *data);
static int         _ds_config_listen_shadow_y(const char *key, const Ecore_Config_Type type, const int tag, void *data);
static int         _ds_config_listen_blur(const char *key, const Ecore_Config_Type type, const int tag, void *data);
static int         _ds_config_listen_shadow_darkness(const char *key, const Ecore_Config_Type type, const int tag, void *data);
static E_Menu     *_ds_config_menu_new(Dropshadow *ds);
static void        _ds_menu_very_fuzzy(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_fuzzy(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_sharp(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_sharp(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_dark(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_dark(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_light(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_light(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_far(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_far(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_close(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_close(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_extremely_close(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_under(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_container_shapes_add(Dropshadow *ds, E_Container *con);
static void        _ds_shape_change(void *data, E_Container_Shape *es, E_Container_Shape_Change ch);
static Shadow     *_ds_shadow_find(Dropshadow *ds, E_Container_Shape *es);
static Shadow     *_ds_shadow_add(Dropshadow *ds, E_Container_Shape *es);
static void        _ds_shadow_obj_init(Shadow *sh);
static void        _ds_shadow_obj_shutdown(Shadow *sh);
static void        _ds_shadow_del(Shadow *sh);
static void        _ds_shadow_show(Shadow *sh);
static void        _ds_shadow_hide(Shadow *sh);
static void        _ds_shadow_move(Shadow *sh, int x, int y);
static void        _ds_shadow_resize(Shadow *sh, int w, int h);
static void        _ds_shadow_shaperects(Shadow *sh);
static int         _ds_shadow_reshape(void *data);
static void        _ds_shadow_recalc(Shadow *sh);
static void        _ds_shadow_object_pixels_set(Evas_Object *o, unsigned char *pix, int pix_w, int pix_h, int sx, int sy, int sw, int sh);
static void        _ds_config_darkness_set(Dropshadow *ds, double v);
static void        _ds_config_shadow_xy_set(Dropshadow *ds, int x, int y);
static void        _ds_config_blur_set(Dropshadow *ds, int blur);
static void        _ds_blur_init(Dropshadow *ds);
static double      _ds_gauss_int(double x);
static void        _ds_gauss_blur_h(unsigned char *pix, unsigned char *pix_dst, int pix_w, int pix_h, unsigned char *lut, int blur, int rx, int ry, int rxx, int ryy);
static void        _ds_gauss_blur_v(unsigned char *pix, unsigned char *pix_dst, int pix_w, int pix_h, unsigned char *lut, int blur, int rx, int ry, int rxx, int ryy);
static void        _ds_gauss_fill(unsigned char *pix, int pix_w, int pix_h, unsigned char v, int rx, int ry, int rxx, int ryy);
static void        _ds_gauss_copy(unsigned char *pix, unsigned char *pix_dst, int pix_w, int pix_h, int rx, int ry, int rxx, int ryy);
static void        _ds_gauss_blur(unsigned char *pix, int pix_w, int pix_h, unsigned char *lut, int blur, int sx, int sy, int sw, int sh);
    
/* public module routines. all modules must have these */
void *
init(E_Module *m)
{
   Dropshadow *ds;
   
   if (m->api->version < E_MODULE_API_VERSION)
     {
	e_error_dialog_show("Module API Error",
			    "Error initializing Module: dropshadow\n"
			    "It requires a minimum module API version of: %i.\n"
			    "The module API advertized by Enlightenment is: %i.\n"
			    "Aborting module.",
			    E_MODULE_API_VERSION,
			    m->api->version);
	return NULL;
     }
   ds = _ds_init(m);
   m->config_menu = _ds_config_menu_new(ds);
   return ds;
}

int
shutdown(E_Module *m)
{
   Dropshadow *ds;
   
   ds = m->data;
   if (ds)
     {
	if (m->config_menu)
	  {
	     e_menu_deactivate(m->config_menu);
	     e_object_del(E_OBJECT(m->config_menu));
	     m->config_menu = NULL;
	  }
	_ds_shutdown(ds);
     }
   return 1;
}

int
save(E_Module *m)
{
   Dropshadow *ds;
   
   ds = m->data;
   if (!ds) return;
   ecore_config_int_set("e.module.dropshadow.shadow.x", ds->conf.shadow_x);
   ecore_config_int_set("e.module.dropshadow.shadow.y", ds->conf.shadow_y);
   ecore_config_int_set("e.module.dropshadow.blur", ds->conf.blur_size);
   ecore_config_float_set("e.module.dropshadow.shadow.darkness", ds->conf.shadow_darkness);
   return 1;
}

int
info(E_Module *m)
{
   char buf[4096];
   
   m->label = strdup("Dropshadow");
   snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
   m->icon_file = strdup(buf);
   return 1;
}

int
about(E_Module *m)
{
   e_error_dialog_show("Enlightenment Dropshadow Module",
		       "This is the dropshadow module that allows dropshadows to be cast\n"
		       "on the desktop background - without an special X-Server extensions\n"
		       "or hardware acceleration.");
   return 1;
}

/* module private routines */
static Dropshadow *
_ds_init(E_Module *m)
{
   Dropshadow *ds;
   Evas_List *managers, *l, *l2;
   
   ds = calloc(1, sizeof(Dropshadow));
   if (!ds) return  NULL;

   ds->module = m;
   ecore_config_int_create_bound
     ("e.module.dropshadow.shadow.x",
      4, -200, 200, 1,
      0, "",
      "Dropshadow module: Shadow X offset");
   ecore_config_int_create_bound
     ("e.module.dropshadow.shadow.y",
      4, -200, 200, 1,<commit_msg>grammar<commit_after>#include "e.h"
#include "e_mod_main.h"

/* TODO List:
 * 
 * * bug in shadow_x < 0 and shadow_y < 0 needs to be fixed (not urgent though)
 * * bug in ecore_config ? when we change shadow darkness in examine, _ds_config_listen_shadow_darkness does not get called - only when we change other values like x, y, blur and when it gets called we are not getting the value set in examine - always getting 0.5
 * * add alpha-pixel only pixel space to image objects in evas and make use of it to save cpu and ram
 * * when blurring ALSO cut out the overlayed rect frrom the blur algorithm
 * * handle shaped windows efficiently (as possible).
 * 
 */

/* module private routines */
static Dropshadow *_ds_init(E_Module *m);
static void        _ds_shutdown(Dropshadow *ds);
static int         _ds_config_listen_shadow_x(const char *key, const Ecore_Config_Type type, const int tag, void *data);
static int         _ds_config_listen_shadow_y(const char *key, const Ecore_Config_Type type, const int tag, void *data);
static int         _ds_config_listen_blur(const char *key, const Ecore_Config_Type type, const int tag, void *data);
static int         _ds_config_listen_shadow_darkness(const char *key, const Ecore_Config_Type type, const int tag, void *data);
static E_Menu     *_ds_config_menu_new(Dropshadow *ds);
static void        _ds_menu_very_fuzzy(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_fuzzy(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_medium(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_sharp(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_sharp(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_dark(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_dark(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_light(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_light(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_far(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_far(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_close(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_very_close(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_extremely_close(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_menu_under(void *data, E_Menu *m, E_Menu_Item *mi);
static void        _ds_container_shapes_add(Dropshadow *ds, E_Container *con);
static void        _ds_shape_change(void *data, E_Container_Shape *es, E_Container_Shape_Change ch);
static Shadow     *_ds_shadow_find(Dropshadow *ds, E_Container_Shape *es);
static Shadow     *_ds_shadow_add(Dropshadow *ds, E_Container_Shape *es);
static void        _ds_shadow_obj_init(Shadow *sh);
static void        _ds_shadow_obj_shutdown(Shadow *sh);
static void        _ds_shadow_del(Shadow *sh);
static void        _ds_shadow_show(Shadow *sh);
static void        _ds_shadow_hide(Shadow *sh);
static void        _ds_shadow_move(Shadow *sh, int x, int y);
static void        _ds_shadow_resize(Shadow *sh, int w, int h);
static void        _ds_shadow_shaperects(Shadow *sh);
static int         _ds_shadow_reshape(void *data);
static void        _ds_shadow_recalc(Shadow *sh);
static void        _ds_shadow_object_pixels_set(Evas_Object *o, unsigned char *pix, int pix_w, int pix_h, int sx, int sy, int sw, int sh);
static void        _ds_config_darkness_set(Dropshadow *ds, double v);
static void        _ds_config_shadow_xy_set(Dropshadow *ds, int x, int y);
static void        _ds_config_blur_set(Dropshadow *ds, int blur);
static void        _ds_blur_init(Dropshadow *ds);
static double      _ds_gauss_int(double x);
static void        _ds_gauss_blur_h(unsigned char *pix, unsigned char *pix_dst, int pix_w, int pix_h, unsigned char *lut, int blur, int rx, int ry, int rxx, int ryy);
static void        _ds_gauss_blur_v(unsigned char *pix, unsigned char *pix_dst, int pix_w, int pix_h, unsigned char *lut, int blur, int rx, int ry, int rxx, int ryy);
static void        _ds_gauss_fill(unsigned char *pix, int pix_w, int pix_h, unsigned char v, int rx, int ry, int rxx, int ryy);
static void        _ds_gauss_copy(unsigned char *pix, unsigned char *pix_dst, int pix_w, int pix_h, int rx, int ry, int rxx, int ryy);
static void        _ds_gauss_blur(unsigned char *pix, int pix_w, int pix_h, unsigned char *lut, int blur, int sx, int sy, int sw, int sh);
    
/* public module routines. all modules must have these */
void *
init(E_Module *m)
{
   Dropshadow *ds;
   
   if (m->api->version < E_MODULE_API_VERSION)
     {
	e_error_dialog_show("Module API Error",
			    "Error initializing Module: dropshadow\n"
			    "It requires a minimum module API version of: %i.\n"
			    "The module API advertized by Enlightenment is: %i.\n"
			    "Aborting module.",
			    E_MODULE_API_VERSION,
			    m->api->version);
	return NULL;
     }
   ds = _ds_init(m);
   m->config_menu = _ds_config_menu_new(ds);
   return ds;
}

int
shutdown(E_Module *m)
{
   Dropshadow *ds;
   
   ds = m->data;
   if (ds)
     {
	if (m->config_menu)
	  {
	     e_menu_deactivate(m->config_menu);
	     e_object_del(E_OBJECT(m->config_menu));
	     m->config_menu = NULL;
	  }
	_ds_shutdown(ds);
     }
   return 1;
}

int
save(E_Module *m)
{
   Dropshadow *ds;
   
   ds = m->data;
   if (!ds) return;
   ecore_config_int_set("e.module.dropshadow.shadow.x", ds->conf.shadow_x);
   ecore_config_int_set("e.module.dropshadow.shadow.y", ds->conf.shadow_y);
   ecore_config_int_set("e.module.dropshadow.blur", ds->conf.blur_size);
   ecore_config_float_set("e.module.dropshadow.shadow.darkness", ds->conf.shadow_darkness);
   return 1;
}

int
info(E_Module *m)
{
   char buf[4096];
   
   m->label = strdup("Dropshadow");
   snprintf(buf, sizeof(buf), "%s/module_icon.png", e_module_dir_get(m));
   m->icon_file = strdup(buf);
   return 1;
}

int
about(E_Module *m)
{
   e_error_dialog_show("Enlightenment Dropshadow Module",
		       "This is the dropshadow module that allows dropshadows to be cast\n"
		       "on the desktop background - without special X-Server extensions\n"
		       "or hardware acceleration.");
   return 1;
}

/* module private routines */
static Dropshadow *
_ds_init(E_Module *m)
{
   Dropshadow *ds;
   Evas_List *managers, *l, *l2;
   
   ds = calloc(1, sizeof(Dropshadow));
   if (!ds) return  NULL;

   ds->module = m;
   ecore_config_int_create_bound
     ("e.module.dropshadow.shadow.x",
      4, -200, 200, 1,
      0, "",
      "Dropshadow module: Shadow X offset");
   ecore_config_int_create_bound
     ("e.module.dropshadow.shadow.y",
      4, -200, 200, 1,
{'fraction_non_alphanumeric': 0.10168235381308827, 'fraction_numerical': 0.004594975172311569, 'mean_word_length': 3.7148846960167714, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5756039', 'n_tokens_mistral': 5025, 'n_tokens_neox': 4798, 'n_words': 1390}