diff --git a/src/.indent.pro b/src/.indent.pro new file mode 100644 index 000000000..f3a18c4e9 --- /dev/null +++ b/src/.indent.pro @@ -0,0 +1,14 @@ +-i3 +-bl +-bad +-nbap +-sob +-ncdb +-di20 +-nbc +-lp +-nce +-npcs +-sc +-ncs +-l80 diff --git a/src/actions.c b/src/actions.c index 80611afa0..7abb8e8c7 100644 --- a/src/actions.c +++ b/src/actions.c @@ -13,125 +13,140 @@ #include "bordermenu.h" #include "block.h" -static Evas_List action_impls = NULL; -static Evas_List current_actions = NULL; -static Evas_List current_timers = NULL; +static Evas_List action_impls = NULL; +static Evas_List current_actions = NULL; +static Evas_List current_timers = NULL; -static void e_action_find(char *action, E_Action_Type act, int button, char *key, - Ecore_Event_Key_Modifiers mods, E_Object *object); -static void e_action_cleanup(E_Action *a); +static void e_action_find(char *action, E_Action_Type act, int button, + char *key, Ecore_Event_Key_Modifiers mods, + E_Object * object); +static void e_action_cleanup(E_Action * a); -static void e_act_move_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_move_stop (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_move_cont (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry, int dx, int dy); - -static void e_act_resize_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_resize_stop (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_resize_cont (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry, int dx, int dy); - -static void e_act_resize_h_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_resize_h_stop (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_resize_h_cont (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry, int dx, int dy); - -static void e_act_resize_v_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_resize_v_stop (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_resize_v_cont (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry, int dx, int dy); - -static void e_act_close_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_kill_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_shade_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_raise_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_lower_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_raise_lower_start (E_Object *object, E_Action *a, +static void e_act_move_start(E_Object * object, E_Action * a, void *data, int x, int y, int rx, int ry); -static void e_act_exec_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_menu_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_exit_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_restart_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_stick_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_sound_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_iconify_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_max_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_snap_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_zoom_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_desk_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); - -static void e_act_raise_next_start (E_Object *object, E_Action *a, void *data, +static void e_act_move_stop(E_Object * object, E_Action * a, void *data, int x, int y, int rx, int ry); -static void e_act_desk_rel_start (E_Object *object, E_Action *a, void *data, - int x, int y, int rx, int ry); +static void e_act_move_cont(E_Object * object, E_Action * a, void *data, + int x, int y, int rx, int ry, int dx, + int dy); +static void e_act_resize_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_resize_stop(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_resize_cont(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry, + int dx, int dy); + +static void e_act_resize_h_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_resize_h_stop(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_resize_h_cont(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry, int dx, int dy); + +static void e_act_resize_v_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_resize_v_stop(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_resize_v_cont(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry, int dx, int dy); + +static void e_act_close_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_kill_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_shade_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_raise_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_lower_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_raise_lower_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_exec_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_menu_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_exit_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_restart_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_stick_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_sound_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_iconify_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_max_start(E_Object * object, E_Action * a, void *data, + int x, int y, int rx, int ry); + +static void e_act_snap_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_zoom_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_desk_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, int ry); + +static void e_act_raise_next_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); + +static void e_act_desk_rel_start(E_Object * object, E_Action * a, + void *data, int x, int y, int rx, + int ry); static void e_action_find(char *action, E_Action_Type act, int button, - char *key, Ecore_Event_Key_Modifiers mods, E_Object *object) + char *key, Ecore_Event_Key_Modifiers mods, E_Object * object) { - char *actions_db; - E_DB_File *db; - int i, num; - char *a_name = NULL; - char *a_action = NULL; - char *a_params = NULL; - int a_event = 0; - int a_button = 0; - char *a_key = NULL; - int a_modifiers = 0; - Evas_List l; - E_Action *a; - static Evas_List actions = NULL; + char *actions_db; + E_DB_File *db; + int i, num; + char *a_name = NULL; + char *a_action = NULL; + char *a_params = NULL; + int a_event = 0; + int a_button = 0; + char *a_key = NULL; + int a_modifiers = 0; + Evas_List l; + E_Action *a; + static Evas_List actions = NULL; + E_CFG_FILE(cfg_actions, "actions"); D_ENTER; @@ -141,28 +156,31 @@ e_action_find(char *action, E_Action_Type act, int button, /* if we had a previous list - nuke it */ /* FIXME: this has potential to segfault if reference - counting is actually used and those actions are - referenced in more than one place --cK. - */ + * counting is actually used and those actions are + * referenced in more than one place --cK. + */ if (actions) { for (l = actions; l; l = l->next) { a = l->data; - if (a) e_action_cleanup(a); + if (a) + e_action_cleanup(a); } actions = evas_list_free(actions); } /* now build the list again */ actions_db = e_config_get("actions"); db = e_db_open_read(actions_db); - if (!db) D_RETURN; - if (!e_db_int_get(db, "/actions/count", &num)) goto error; + if (!db) + D_RETURN; + if (!e_db_int_get(db, "/actions/count", &num)) + goto error; for (i = 0; i < num; i++) { - char buf[PATH_MAX]; - + char buf[PATH_MAX]; + snprintf(buf, PATH_MAX, "/actions/%i/name", i); a_name = e_db_str_get(db, buf); snprintf(buf, PATH_MAX, "/actions/%i/action", i); @@ -177,12 +195,12 @@ e_action_find(char *action, E_Action_Type act, int button, a_key = e_db_str_get(db, buf); snprintf(buf, PATH_MAX, "/actions/%i/modifiers", i); e_db_int_get(db, buf, &a_modifiers); - + a = NEW(E_Action, 1); ZERO(a, E_Action, 1); - + e_object_init(E_OBJECT(a), (E_Cleanup_Func) e_action_cleanup); - + a->name = a_name; a->action = a_action; a->params = a_params; @@ -198,52 +216,54 @@ e_action_find(char *action, E_Action_Type act, int button, if ((a->key) && (strlen(a->key) > 0)) { if (a->modifiers == -1) - e_keys_grab(a->key, ECORE_EVENT_KEY_MODIFIER_NONE, 1); + e_keys_grab(a->key, ECORE_EVENT_KEY_MODIFIER_NONE, 1); else - e_keys_grab(a->key, (Ecore_Event_Key_Modifiers)a->modifiers, 0); + e_keys_grab(a->key, (Ecore_Event_Key_Modifiers) a->modifiers, + 0); a->grabbed = 1; } } - error: + error: e_db_close(db); E_CONFIG_CHECK_VALIDITY_END; /* run thru our actions list and match event, state and stuff with an */ /* and action for it */ for (l = actions; l; l = l->next) { - Evas_List ll; - + Evas_List ll; + a = l->data; - if (act != a->event) goto next; - if (!((a->name) && - (action) && - (!strcmp(a->name, action)))) goto next; - if ((act >= ACT_MOUSE_CLICK) && - (act <= ACT_MOUSE_CLICKED) && - (!((a->button == -1) || - (a->button == button)))) goto next; - if ((act >= ACT_KEY_DOWN) && + if (act != a->event) + goto next; + if (!((a->name) && (action) && (!strcmp(a->name, action)))) + goto next; + if ((act >= ACT_MOUSE_CLICK) && + (act <= ACT_MOUSE_CLICKED) && + (!((a->button == -1) || (a->button == button)))) + goto next; + if ((act >= ACT_KEY_DOWN) && (act <= ACT_KEY_UP) && - (!((a->key) && (key) && - (!strcmp(a->key, key))))) goto next; + (!((a->key) && (key) && (!strcmp(a->key, key))))) + goto next; if ((act >= ACT_MOUSE_CLICK) && (act <= ACT_KEY_UP) && - (!((a->modifiers == -1) || - (a->modifiers == (int)mods)))) goto next; + (!((a->modifiers == -1) || (a->modifiers == (int)mods)))) + goto next; for (ll = action_impls; ll; ll = ll->next) { - E_Action_Impl *ap; - + E_Action_Impl *ap; + ap = ll->data; if (!strcmp(ap->action, a->action)) { - E_Action *aa; - + E_Action *aa; + aa = NEW(E_Action, 1); ZERO(aa, E_Action, 1); - - e_object_init(E_OBJECT(aa), (E_Cleanup_Func) e_action_cleanup); - + + e_object_init(E_OBJECT(aa), + (E_Cleanup_Func) e_action_cleanup); + e_strdup(aa->name, a->name); e_strdup(aa->action, a->action); e_strdup(aa->params, a->params); @@ -262,14 +282,14 @@ e_action_find(char *action, E_Action_Type act, int button, current_actions = evas_list_append(current_actions, aa); } } - next: + next: } D_RETURN; } static void -e_action_cleanup(E_Action *a) +e_action_cleanup(E_Action * a) { D_ENTER; @@ -277,9 +297,9 @@ e_action_cleanup(E_Action *a) if ((a->key) && (strlen(a->key) > 0) && (a->grabbed)) { if (a->modifiers == -1) - e_keys_ungrab(a->key, ECORE_EVENT_KEY_MODIFIER_NONE, 1); + e_keys_ungrab(a->key, ECORE_EVENT_KEY_MODIFIER_NONE, 1); else - e_keys_ungrab(a->key, (Ecore_Event_Key_Modifiers)a->modifiers, 0); + e_keys_ungrab(a->key, (Ecore_Event_Key_Modifiers) a->modifiers, 0); } /* Clean up the strings by simply freeing them ... */ @@ -289,19 +309,19 @@ e_action_cleanup(E_Action *a) IF_FREE(a->key); /* Cleanup action implementations and objects. These - we don't free directly, but just decrement their use counts. - */ + * we don't free directly, but just decrement their use counts. + */ if (a->action_impl) { - e_object_unref(E_OBJECT(a->action_impl)); - a->action_impl = NULL; + e_object_unref(E_OBJECT(a->action_impl)); + a->action_impl = NULL; } if (a->object) { - e_object_unref(a->object); - a->object = NULL; + e_object_unref(a->object); + a->object = NULL; } /* Cleanup superclass. */ @@ -313,19 +333,19 @@ e_action_cleanup(E_Action *a) int e_action_start(char *action, E_Action_Type act, int button, char *key, Ecore_Event_Key_Modifiers mods, - E_Object *object, void *data, int x, int y, int rx, int ry) + E_Object * object, void *data, int x, int y, int rx, int ry) { - Evas_List l; - int started_long_action = 0; - + Evas_List l; + int started_long_action = 0; + D_ENTER; e_action_find(action, act, button, key, mods, object); - again: + again: for (l = current_actions; l; l = l->next) { - E_Action *a; - + E_Action *a; + a = l->data; if (!a->started) { @@ -352,49 +372,44 @@ e_action_start(char *action, E_Action_Type act, int button, void e_action_stop(char *action, E_Action_Type act, int button, - char *key, Ecore_Event_Key_Modifiers mods, E_Object *object, + char *key, Ecore_Event_Key_Modifiers mods, E_Object * object, void *data, int x, int y, int rx, int ry) { - Evas_List l; + Evas_List l; D_ENTER; - again: + again: for (l = current_actions; l; l = l->next) { - E_Action *a; - + E_Action *a; + a = l->data; if ((a->started) && (a->action_impl->func_stop)) { - int ok = 0; - - if ((a->event == ACT_MOUSE_IN) && - (act == ACT_MOUSE_OUT)) - ok = 1; - if ((a->event == ACT_MOUSE_OUT) && - (act == ACT_MOUSE_IN)) - ok = 1; - if ((a->event >= ACT_MOUSE_CLICK) && + int ok = 0; + + if ((a->event == ACT_MOUSE_IN) && (act == ACT_MOUSE_OUT)) + ok = 1; + if ((a->event == ACT_MOUSE_OUT) && (act == ACT_MOUSE_IN)) + ok = 1; + if ((a->event >= ACT_MOUSE_CLICK) && (a->event <= ACT_MOUSE_TRIPLE) && (act >= ACT_MOUSE_UP) && - (act <= ACT_MOUSE_CLICKED) && - (a->button == button)) - ok = 1; - if ((a->event == ACT_MOUSE_MOVE) && + (act <= ACT_MOUSE_CLICKED) && (a->button == button)) + ok = 1; + if ((a->event == ACT_MOUSE_MOVE) && ((act == ACT_MOUSE_OUT) || (act == ACT_MOUSE_IN) || ((act >= ACT_MOUSE_CLICK) && - (act <= ACT_MOUSE_TRIPLE)) || - (act >= ACT_MOUSE_UP))) - ok = 1; - if ((a->event == ACT_KEY_DOWN) && + (act <= ACT_MOUSE_TRIPLE)) || (act >= ACT_MOUSE_UP))) + ok = 1; + if ((a->event == ACT_KEY_DOWN) && (act == ACT_KEY_UP) && (key) && (a->key) && (!strcmp(key, a->key))) - ok = 1; - if ((a->event == ACT_KEY_UP) && - (act == ACT_KEY_DOWN)) - ok = 1; + ok = 1; + if ((a->event == ACT_KEY_UP) && (act == ACT_KEY_DOWN)) + ok = 1; if (ok) { a->action_impl->func_stop(a->object, a, data, x, y, rx, ry); @@ -403,7 +418,7 @@ e_action_stop(char *action, E_Action_Type act, int button, } if (!a->started) { - current_actions = evas_list_remove(current_actions, a); + current_actions = evas_list_remove(current_actions, a); e_object_unref(E_OBJECT(a)); goto again; } @@ -417,20 +432,20 @@ e_action_stop(char *action, E_Action_Type act, int button, void e_action_cont(char *action, E_Action_Type act, int button, char *key, - Ecore_Event_Key_Modifiers mods, E_Object *object, void *data, + Ecore_Event_Key_Modifiers mods, E_Object * object, void *data, int x, int y, int rx, int ry, int dx, int dy) { - Evas_List l; + Evas_List l; D_ENTER; for (l = current_actions; l; l = l->next) { - E_Action *a; - + E_Action *a; + a = l->data; if ((a->started) && (a->action_impl->func_cont)) - a->action_impl->func_cont(a->object, a, data, x, y, rx, ry, dx, dy); + a->action_impl->func_cont(a->object, a, data, x, y, rx, ry, dx, dy); } D_RETURN; @@ -443,24 +458,25 @@ e_action_cont(char *action, E_Action_Type act, int button, char *key, } void -e_action_stop_by_object(E_Object *object, void *data, int x, int y, int rx, int ry) +e_action_stop_by_object(E_Object * object, void *data, int x, int y, int rx, + int ry) { - Evas_List l; + Evas_List l; D_ENTER; e_action_del_timer_object(object); - again: + again: for (l = current_actions; l; l = l->next) { - E_Action *a; - + E_Action *a; + a = l->data; if ((a->started) && (object == a->object)) { if (a->action_impl->func_stop) - a->action_impl->func_stop(a->object, a, data, x, y, rx, ry); + a->action_impl->func_stop(a->object, a, data, x, y, rx, ry); a->started = 0; @@ -477,16 +493,16 @@ e_action_stop_by_object(E_Object *object, void *data, int x, int y, int rx, int void e_action_stop_by_type(char *action) { - Evas_List l; + Evas_List l; D_ENTER; for (l = current_actions; l; l = l->next) { - E_Action *a; - + E_Action *a; + a = l->data; - if ((a->started) && (a->action_impl->func_stop) && + if ((a->started) && (a->action_impl->func_stop) && (action) && (!strcmp(action, a->name))) { a->action_impl->func_stop(a->object, a, NULL, 0, 0, 0, 0); @@ -497,9 +513,8 @@ e_action_stop_by_type(char *action) D_RETURN; } - static void -e_action_impl_cleanup(E_Action_Impl *eai) +e_action_impl_cleanup(E_Action_Impl * eai) { D_ENTER; @@ -508,20 +523,19 @@ e_action_impl_cleanup(E_Action_Impl *eai) D_RETURN; } - void -e_action_add_impl(char *action, E_Action_Start_Func func_start, +e_action_add_impl(char *action, E_Action_Start_Func func_start, E_Action_Cont_Func func_cont, E_Action_Stop_Func func_stop) { - E_Action_Impl *ap; - + E_Action_Impl *ap; + D_ENTER; ap = NEW(E_Action_Impl, 1); - ZERO(ap, E_Action_Impl, 1); + ZERO(ap, E_Action_Impl, 1); e_object_init(E_OBJECT(ap), (E_Cleanup_Func) e_action_impl_cleanup); - + e_strdup(ap->action, action); ap->func_start = func_start; ap->func_cont = func_cont; @@ -531,24 +545,21 @@ e_action_add_impl(char *action, E_Action_Start_Func func_start, D_RETURN; } - void -e_action_del_timer(E_Object *object, char *name) +e_action_del_timer(E_Object * object, char *name) { - Evas_List l; + Evas_List l; D_ENTER; - - again: + + again: for (l = current_timers; l; l = l->next) { E_Active_Action_Timer *at; - + at = l->data; - if ((at->object == object) && - (name) && - (at->name) && - (!strcmp(at->name, name))) + if ((at->object == object) && + (name) && (at->name) && (!strcmp(at->name, name))) { e_object_unref(at->object); ecore_del_event_timer(at->name); @@ -563,10 +574,10 @@ e_action_del_timer(E_Object *object, char *name) } void -e_action_add_timer(E_Object *object, char *name) +e_action_add_timer(E_Object * object, char *name) { E_Active_Action_Timer *at; - + D_ENTER; at = NEW(E_Active_Action_Timer, 1); @@ -579,17 +590,17 @@ e_action_add_timer(E_Object *object, char *name) } void -e_action_del_timer_object(E_Object *object) +e_action_del_timer_object(E_Object * object) { - Evas_List l; - + Evas_List l; + D_ENTER; - again: + again: for (l = current_timers; l; l = l->next) { E_Active_Action_Timer *at; - + at = l->data; if (at->object == object) { @@ -601,7 +612,7 @@ e_action_del_timer_object(E_Object *object) goto again; } } - + D_RETURN; } @@ -610,10 +621,14 @@ e_action_init(void) { D_ENTER; - e_action_add_impl("Window_Move", e_act_move_start, e_act_move_cont, e_act_move_stop); - e_action_add_impl("Window_Resize", e_act_resize_start, e_act_resize_cont, e_act_resize_stop); - e_action_add_impl("Window_Resize_Horizontal", e_act_resize_h_start, e_act_resize_h_cont, e_act_resize_h_stop); - e_action_add_impl("Window_Resize_Vertical", e_act_resize_v_start, e_act_resize_v_cont, e_act_resize_v_stop); + e_action_add_impl("Window_Move", e_act_move_start, e_act_move_cont, + e_act_move_stop); + e_action_add_impl("Window_Resize", e_act_resize_start, e_act_resize_cont, + e_act_resize_stop); + e_action_add_impl("Window_Resize_Horizontal", e_act_resize_h_start, + e_act_resize_h_cont, e_act_resize_h_stop); + e_action_add_impl("Window_Resize_Vertical", e_act_resize_v_start, + e_act_resize_v_cont, e_act_resize_v_stop); e_action_add_impl("Window_Close", e_act_close_start, NULL, NULL); e_action_add_impl("Window_Kill", e_act_kill_start, NULL, NULL); e_action_add_impl("Window_Shade", e_act_shade_start, NULL, NULL); @@ -637,7 +652,6 @@ e_action_init(void) D_RETURN; } - /* FIXME: these REALLY need to go into other file(s) but it's not worht it */ /* yet at this point. it can be done later */ @@ -653,21 +667,26 @@ e_action_init(void) /* probably moving these includes above the init and having hooks into the */ /* init func */ -static void -e_act_move_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_move_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - E_Guides_Mode move_mode = E_GUIDES_BOX; - double align_x = 0.5; - double align_y = 0.5; - E_Guides_Location display_loc = E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE; - E_CFG_INT(cfg_window_move_mode, "settings", "/window/move/mode", E_GUIDES_BOX); + E_Border *b; + E_Guides_Mode move_mode = E_GUIDES_BOX; + double align_x = 0.5; + double align_y = 0.5; + E_Guides_Location display_loc = E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE; + + E_CFG_INT(cfg_window_move_mode, "settings", "/window/move/mode", + E_GUIDES_BOX); E_CFG_FLOAT(cfg_guides_display_x, "settings", "/guides/display/x", 0.5); E_CFG_FLOAT(cfg_guides_display_y, "settings", "/guides/display/y", 0.5); - E_CFG_INT(cfg_guides_display_location, "settings", "/guides/display/location", E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE); - + E_CFG_INT(cfg_guides_display_location, "settings", + "/guides/display/location", + E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE); + D_ENTER; - + e_block_start("menus"); E_CONFIG_INT_GET(cfg_window_move_mode, move_mode); @@ -675,39 +694,40 @@ e_act_move_start (E_Object *object, E_Action *a, void *data, int x, int y, int r E_CONFIG_FLOAT_GET(cfg_guides_display_y, align_y); E_CONFIG_INT_GET(cfg_guides_display_location, display_loc); - b = (E_Border*) object; + b = (E_Border *) object; if (!b) - b = e_border_current_focused(); + b = e_border_current_focused(); if (!b) - D_RETURN; + D_RETURN; if (b->client.fixed) - D_RETURN; + D_RETURN; if (move_mode >= E_GUIDES_BOX) - b->hold_changes = 1; /* if non opaque */ + b->hold_changes = 1; /* if non opaque */ b->mode.move = 1; b->current.requested.dx = 0; b->current.requested.dy = 0; b->previous.requested.dx = 0; b->previous.requested.dy = 0; - { - char buf[PATH_MAX]; - - e_border_print_pos(buf, b); - e_guides_set_display_alignment(align_x, align_y); - e_guides_set_mode(move_mode); - e_guides_set_display_location(display_loc); - e_guides_display_text(buf); - snprintf(buf, PATH_MAX, "%s/%s", e_config_get("images"), "win_shadow_icon.png"); - e_guides_display_icon(buf); - e_guides_move(b->current.x, b->current.y); - e_guides_resize(b->current.w, b->current.h); - e_guides_show(); - } + { + char buf[PATH_MAX]; + + e_border_print_pos(buf, b); + e_guides_set_display_alignment(align_x, align_y); + e_guides_set_mode(move_mode); + e_guides_set_display_location(display_loc); + e_guides_display_text(buf); + snprintf(buf, PATH_MAX, "%s/%s", e_config_get("images"), + "win_shadow_icon.png"); + e_guides_display_icon(buf); + e_guides_move(b->current.x, b->current.y); + e_guides_resize(b->current.w, b->current.h); + e_guides_show(); + } D_RETURN; UN(a); @@ -719,26 +739,27 @@ e_act_move_start (E_Object *object, E_Action *a, void *data, int x, int y, int r } static void -e_act_move_stop (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +e_act_move_stop(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; + E_Border *b; D_ENTER; - b = (E_Border*) object; + b = (E_Border *) object; e_block_stop("menus"); - - if (!b) - b = e_border_current_focused(); if (!b) - D_RETURN; + b = e_border_current_focused(); + + if (!b) + D_RETURN; if (b->client.fixed) - D_RETURN; + D_RETURN; - b->hold_changes = 0; /* if non opaque */ + b->hold_changes = 0; /* if non opaque */ b->current.requested.x = b->current.x; b->current.requested.y = b->current.y; b->changed = 1; @@ -764,37 +785,40 @@ e_act_move_stop (E_Object *object, E_Action *a, void *data, int x, int y, int r } static void -e_act_move_cont (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy) +e_act_move_cont(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry, int dx, int dy) { - E_Border *b; + E_Border *b; D_ENTER; - - b = (E_Border*) object; + + b = (E_Border *) object; if (!b) - b = e_border_current_focused(); + b = e_border_current_focused(); if (!b) - D_RETURN; + D_RETURN; if (b->client.fixed) - D_RETURN; + D_RETURN; b->current.requested.x += dx; b->current.requested.y += dy; - if (dx != 0) b->current.requested.dx = dx; - if (dy != 0) b->current.requested.dy = dy; + if (dx != 0) + b->current.requested.dx = dx; + if (dy != 0) + b->current.requested.dy = dy; b->changed = 1; e_border_adjust_limits(b); - { - char buf[1024]; - - e_border_print_pos(buf, b); - e_guides_move(b->current.x, b->current.y); - e_guides_resize(b->current.w, b->current.h); - e_guides_display_text(buf); - } + { + char buf[1024]; + + e_border_print_pos(buf, b); + e_guides_move(b->current.x, b->current.y); + e_guides_resize(b->current.w, b->current.h); + e_guides_display_text(buf); + } D_RETURN; UN(a); @@ -805,36 +829,45 @@ e_act_move_cont (E_Object *object, E_Action *a, void *data, int x, int y, int r UN(ry); } - -static void -e_act_resize_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_resize_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - E_Guides_Mode resize_mode = E_GUIDES_BOX; - double align_x = 0.5; - double align_y = 0.5; - E_Guides_Location display_loc = E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE; - E_CFG_INT(cfg_window_resize_mode, "settings", "/window/resize/mode", E_GUIDES_BOX); + E_Border *b; + E_Guides_Mode resize_mode = E_GUIDES_BOX; + double align_x = 0.5; + double align_y = 0.5; + E_Guides_Location display_loc = E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE; + + E_CFG_INT(cfg_window_resize_mode, "settings", "/window/resize/mode", + E_GUIDES_BOX); E_CFG_FLOAT(cfg_guides_display_x, "settings", "/guides/display/x", 0.5); E_CFG_FLOAT(cfg_guides_display_y, "settings", "/guides/display/y", 0.5); - E_CFG_INT(cfg_guides_display_location, "settings", "/guides/display/location", E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE); + E_CFG_INT(cfg_guides_display_location, "settings", + "/guides/display/location", + E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE); D_ENTER; e_block_start("menus"); - + E_CONFIG_INT_GET(cfg_window_resize_mode, resize_mode); E_CONFIG_FLOAT_GET(cfg_guides_display_x, align_x); - E_CONFIG_FLOAT_GET(cfg_guides_display_y, align_y); + E_CONFIG_FLOAT_GET(cfg_guides_display_y, align_y); E_CONFIG_INT_GET(cfg_guides_display_location, display_loc); - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.w == b->client.max.w) D_RETURN; - if (b->client.min.h == b->client.max.h) D_RETURN; - if (b->current.shaded != 0) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.w == b->client.max.w) + D_RETURN; + if (b->client.min.h == b->client.max.h) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; if (resize_mode >= E_GUIDES_BOX) - b->hold_changes = 1; /* if non opaque */ + b->hold_changes = 1; /* if non opaque */ ecore_window_gravity_set(b->win.client, StaticGravity); ecore_window_gravity_set(b->win.l, NorthWestGravity); ecore_window_gravity_set(b->win.r, SouthEastGravity); @@ -845,50 +878,51 @@ e_act_resize_start (E_Object *object, E_Action *a, void *data, int x, int y, int /* 1 | 2 */ /* --+-- */ /* 3 | 4 */ - if (x > (b->current.w / 2)) + if (x > (b->current.w / 2)) { - if (y > (b->current.h / 2)) + if (y > (b->current.h / 2)) { b->mode.resize = 4; - /* e_border_set_gravity(b, NorthWestGravity); */ - /* ecore_window_gravity_set(b->win.container, SouthEastGravity);*/ + /* e_border_set_gravity(b, NorthWestGravity); */ + /* ecore_window_gravity_set(b->win.container, SouthEastGravity); */ } - else + else { b->mode.resize = 2; - /* e_border_set_gravity(b, SouthWestGravity);*/ - /* ecore_window_gravity_set(b->win.container, NorthEastGravity);*/ + /* e_border_set_gravity(b, SouthWestGravity); */ + /* ecore_window_gravity_set(b->win.container, NorthEastGravity); */ } } else { - if (y > (b->current.h / 2)) + if (y > (b->current.h / 2)) { b->mode.resize = 3; /* e_border_set_gravity(b, NorthEastGravity);*/ /* ecore_window_gravity_set(b->win.container, SouthWestGravity);*/ } - else + else { b->mode.resize = 1; /* e_border_set_gravity(b, SouthEastGravity);*/ /* ecore_window_gravity_set(b->win.container, NorthWestGravity); */ } } - { - char buf[PATH_MAX]; - - e_border_print_size(buf, b); - e_guides_set_display_alignment(align_x, align_y); - e_guides_set_mode(resize_mode); - e_guides_set_display_location(display_loc); - e_guides_display_text(buf); - snprintf(buf, PATH_MAX, "%s/%s", e_config_get("images"), "win_shadow_icon.png"); - e_guides_display_icon(buf); - e_guides_move(b->current.x, b->current.y); - e_guides_resize(b->current.w, b->current.h); - e_guides_show(); - } + { + char buf[PATH_MAX]; + + e_border_print_size(buf, b); + e_guides_set_display_alignment(align_x, align_y); + e_guides_set_mode(resize_mode); + e_guides_set_display_location(display_loc); + e_guides_display_text(buf); + snprintf(buf, PATH_MAX, "%s/%s", e_config_get("images"), + "win_shadow_icon.png"); + e_guides_display_icon(buf); + e_guides_move(b->current.x, b->current.y); + e_guides_resize(b->current.w, b->current.h); + e_guides_show(); + } D_RETURN; UN(a); @@ -898,21 +932,27 @@ e_act_resize_start (E_Object *object, E_Action *a, void *data, int x, int y, int } static void -e_act_resize_stop (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +e_act_resize_stop(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; e_block_stop("menus"); - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.w == b->client.max.w) D_RETURN; - if (b->client.min.h == b->client.max.h) D_RETURN; - if (b->current.shaded != 0) D_RETURN; - b->hold_changes = 0; /* if non opaque */ + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.w == b->client.max.w) + D_RETURN; + if (b->client.min.h == b->client.max.h) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; + b->hold_changes = 0; /* if non opaque */ b->current.requested.x = b->current.x; b->current.requested.y = b->current.y; b->current.requested.w = b->current.w; @@ -934,18 +974,24 @@ e_act_resize_stop (E_Object *object, E_Action *a, void *data, int x, int y, int } static void -e_act_resize_cont (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy) +e_act_resize_cont(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry, int dx, int dy) { - E_Border *b; + E_Border *b; D_ENTER; - - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.w == b->client.max.w) D_RETURN; - if (b->client.min.h == b->client.max.h) D_RETURN; - if (b->current.shaded != 0) D_RETURN; + + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.w == b->client.max.w) + D_RETURN; + if (b->client.min.h == b->client.max.h) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; if (b->mode.resize == 1) { b->current.requested.w -= dx; @@ -972,14 +1018,14 @@ e_act_resize_cont (E_Object *object, E_Action *a, void *data, int x, int y, int } b->changed = 1; e_border_adjust_limits(b); - { - char buf[1024]; - - e_border_print_size(buf, b); - e_guides_move(b->current.x, b->current.y); - e_guides_resize(b->current.w, b->current.h); - e_guides_display_text(buf); - } + { + char buf[1024]; + + e_border_print_size(buf, b); + e_guides_move(b->current.x, b->current.y); + e_guides_resize(b->current.w, b->current.h); + e_guides_display_text(buf); + } D_RETURN; UN(a); @@ -990,35 +1036,43 @@ e_act_resize_cont (E_Object *object, E_Action *a, void *data, int x, int y, int UN(ry); } - -static void -e_act_resize_h_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_resize_h_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - E_Guides_Mode resize_mode = E_GUIDES_BOX; - double align_x = 0.5; - double align_y = 0.5; - E_Guides_Location display_loc = E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE; - E_CFG_INT(cfg_window_resize_mode, "settings", "/window/resize/mode", E_GUIDES_BOX); + E_Border *b; + E_Guides_Mode resize_mode = E_GUIDES_BOX; + double align_x = 0.5; + double align_y = 0.5; + E_Guides_Location display_loc = E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE; + + E_CFG_INT(cfg_window_resize_mode, "settings", "/window/resize/mode", + E_GUIDES_BOX); E_CFG_FLOAT(cfg_guides_display_x, "settings", "/guides/display/x", 0.5); E_CFG_FLOAT(cfg_guides_display_y, "settings", "/guides/display/y", 0.5); - E_CFG_INT(cfg_guides_display_location, "settings", "/guides/display/location", E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE); + E_CFG_INT(cfg_guides_display_location, "settings", + "/guides/display/location", + E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE); D_ENTER; e_block_start("menus"); - + E_CONFIG_INT_GET(cfg_window_resize_mode, resize_mode); E_CONFIG_FLOAT_GET(cfg_guides_display_x, align_x); - E_CONFIG_FLOAT_GET(cfg_guides_display_y, align_y); + E_CONFIG_FLOAT_GET(cfg_guides_display_y, align_y); E_CONFIG_INT_GET(cfg_guides_display_location, display_loc); - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.w == b->client.max.w) D_RETURN; - if (b->current.shaded != 0) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.w == b->client.max.w) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; if (resize_mode >= E_GUIDES_BOX) - b->hold_changes = 1; /* if non opaque */ + b->hold_changes = 1; /* if non opaque */ ecore_window_gravity_set(b->win.client, StaticGravity); ecore_window_gravity_set(b->win.l, NorthWestGravity); ecore_window_gravity_set(b->win.r, SouthEastGravity); @@ -1027,30 +1081,31 @@ e_act_resize_h_start (E_Object *object, E_Action *a, void *data, int x, int y, i ecore_window_gravity_set(b->win.input, NorthWestGravity); ecore_window_gravity_set(b->win.container, NorthWestGravity); /* 5 | 6 */ - if (x > (b->current.w / 2)) + if (x > (b->current.w / 2)) { b->mode.resize = 6; /* e_border_set_gravity(b, NorthWestGravity);*/ } - else + else { b->mode.resize = 5; /* e_border_set_gravity(b, NorthEastGravity);*/ } - { - char buf[PATH_MAX]; - - e_border_print_size(buf, b); - e_guides_set_display_alignment(align_x, align_y); - e_guides_set_mode(resize_mode); - e_guides_set_display_location(display_loc); - e_guides_display_text(buf); - snprintf(buf, PATH_MAX, "%s/%s", e_config_get("images"), "win_shadow_icon.png"); - e_guides_display_icon(buf); - e_guides_move(b->current.x, b->current.y); - e_guides_resize(b->current.w, b->current.h); - e_guides_show(); - } + { + char buf[PATH_MAX]; + + e_border_print_size(buf, b); + e_guides_set_display_alignment(align_x, align_y); + e_guides_set_mode(resize_mode); + e_guides_set_display_location(display_loc); + e_guides_display_text(buf); + snprintf(buf, PATH_MAX, "%s/%s", e_config_get("images"), + "win_shadow_icon.png"); + e_guides_display_icon(buf); + e_guides_move(b->current.x, b->current.y); + e_guides_resize(b->current.w, b->current.h); + e_guides_show(); + } D_RETURN; UN(a); @@ -1061,20 +1116,25 @@ e_act_resize_h_start (E_Object *object, E_Action *a, void *data, int x, int y, i } static void -e_act_resize_h_stop (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +e_act_resize_h_stop(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; + E_Border *b; D_ENTER; e_block_stop("menus"); - - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.w == b->client.max.w) D_RETURN; - if (b->current.shaded != 0) D_RETURN; - b->hold_changes = 0; /* if non opaque */ + + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.w == b->client.max.w) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; + b->hold_changes = 0; /* if non opaque */ b->current.requested.x = b->current.x; b->current.requested.y = b->current.y; b->current.requested.w = b->current.w; @@ -1096,17 +1156,22 @@ e_act_resize_h_stop (E_Object *object, E_Action *a, void *data, int x, int y, i } static void -e_act_resize_h_cont (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy) +e_act_resize_h_cont(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry, int dx, int dy) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.w == b->client.max.w) D_RETURN; - if (b->current.shaded != 0) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.w == b->client.max.w) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; if (b->mode.resize == 5) { b->current.requested.w -= dx; @@ -1118,14 +1183,14 @@ e_act_resize_h_cont (E_Object *object, E_Action *a, void *data, int x, int y, i } b->changed = 1; e_border_adjust_limits(b); - { - char buf[1024]; - - e_border_print_size(buf, b); - e_guides_move(b->current.x, b->current.y); - e_guides_resize(b->current.w, b->current.h); - e_guides_display_text(buf); - } + { + char buf[1024]; + + e_border_print_size(buf, b); + e_guides_move(b->current.x, b->current.y); + e_guides_resize(b->current.w, b->current.h); + e_guides_display_text(buf); + } D_RETURN; UN(a); UN(data); @@ -1136,35 +1201,43 @@ e_act_resize_h_cont (E_Object *object, E_Action *a, void *data, int x, int y, i UN(dy); } - -static void -e_act_resize_v_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_resize_v_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - E_Guides_Mode resize_mode = E_GUIDES_BOX; - double align_x = 0.5; - double align_y = 0.5; - E_Guides_Location display_loc = E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE; - E_CFG_INT(cfg_window_resize_mode, "settings", "/window/resize/mode", E_GUIDES_BOX); + E_Border *b; + E_Guides_Mode resize_mode = E_GUIDES_BOX; + double align_x = 0.5; + double align_y = 0.5; + E_Guides_Location display_loc = E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE; + + E_CFG_INT(cfg_window_resize_mode, "settings", "/window/resize/mode", + E_GUIDES_BOX); E_CFG_FLOAT(cfg_guides_display_x, "settings", "/guides/display/x", 0.5); E_CFG_FLOAT(cfg_guides_display_y, "settings", "/guides/display/y", 0.5); - E_CFG_INT(cfg_guides_display_location, "settings", "/guides/display/location", E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE); - + E_CFG_INT(cfg_guides_display_location, "settings", + "/guides/display/location", + E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE); + D_ENTER; - + e_block_start("menus"); - + E_CONFIG_INT_GET(cfg_window_resize_mode, resize_mode); E_CONFIG_FLOAT_GET(cfg_guides_display_x, align_x); - E_CONFIG_FLOAT_GET(cfg_guides_display_y, align_y); + E_CONFIG_FLOAT_GET(cfg_guides_display_y, align_y); E_CONFIG_INT_GET(cfg_guides_display_location, display_loc); - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.h == b->client.max.h) D_RETURN; - if (b->current.shaded != 0) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.h == b->client.max.h) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; if (resize_mode >= E_GUIDES_BOX) - b->hold_changes = 1; /* if non opaque */ + b->hold_changes = 1; /* if non opaque */ ecore_window_gravity_set(b->win.client, StaticGravity); ecore_window_gravity_set(b->win.l, NorthWestGravity); ecore_window_gravity_set(b->win.r, SouthEastGravity); @@ -1175,30 +1248,31 @@ e_act_resize_v_start (E_Object *object, E_Action *a, void *data, int x, int y, i /* 7 */ /* - */ /* 8 */ - if (y > (b->current.h / 2)) + if (y > (b->current.h / 2)) { b->mode.resize = 8; /* e_border_set_gravity(b, NorthWestGravity);*/ } - else + else { b->mode.resize = 7; /* e_border_set_gravity(b, SouthWestGravity);*/ } - { - char buf[PATH_MAX]; - - e_border_print_size(buf, b); - e_guides_set_display_alignment(align_x, align_y); - e_guides_set_mode(resize_mode); - e_guides_set_display_location(display_loc); - e_guides_display_text(buf); - snprintf(buf, PATH_MAX, "%s/%s", e_config_get("images"), "win_shadow_icon.png"); - e_guides_display_icon(buf); - e_guides_move(b->current.x, b->current.y); - e_guides_resize(b->current.w, b->current.h); - e_guides_show(); - } + { + char buf[PATH_MAX]; + + e_border_print_size(buf, b); + e_guides_set_display_alignment(align_x, align_y); + e_guides_set_mode(resize_mode); + e_guides_set_display_location(display_loc); + e_guides_display_text(buf); + snprintf(buf, PATH_MAX, "%s/%s", e_config_get("images"), + "win_shadow_icon.png"); + e_guides_display_icon(buf); + e_guides_move(b->current.x, b->current.y); + e_guides_resize(b->current.w, b->current.h); + e_guides_show(); + } D_RETURN; UN(a); UN(data); @@ -1208,20 +1282,25 @@ e_act_resize_v_start (E_Object *object, E_Action *a, void *data, int x, int y, i } static void -e_act_resize_v_stop (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +e_act_resize_v_stop(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; e_block_stop("menus"); - - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.h == b->client.max.h) D_RETURN; - if (b->current.shaded != 0) D_RETURN; - b->hold_changes = 0; /* if non opaque */ + + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.h == b->client.max.h) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; + b->hold_changes = 0; /* if non opaque */ b->current.requested.x = b->current.x; b->current.requested.y = b->current.y; b->current.requested.w = b->current.w; @@ -1242,17 +1321,22 @@ e_act_resize_v_stop (E_Object *object, E_Action *a, void *data, int x, int y, i } static void -e_act_resize_v_cont (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry, int dx, int dy) +e_act_resize_v_cont(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry, int dx, int dy) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.min.h == b->client.max.h) D_RETURN; - if (b->current.shaded != 0) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.min.h == b->client.max.h) + D_RETURN; + if (b->current.shaded != 0) + D_RETURN; if (b->mode.resize == 7) { b->current.requested.h -= dy; @@ -1264,14 +1348,14 @@ e_act_resize_v_cont (E_Object *object, E_Action *a, void *data, int x, int y, i } e_border_adjust_limits(b); b->changed = 1; - { - char buf[1024]; - - e_border_print_size(buf, b); - e_guides_move(b->current.x, b->current.y); - e_guides_resize(b->current.w, b->current.h); - e_guides_display_text(buf); - } + { + char buf[1024]; + + e_border_print_size(buf, b); + e_guides_move(b->current.x, b->current.y); + e_guides_resize(b->current.w, b->current.h); + e_guides_display_text(buf); + } D_RETURN; UN(a); UN(data); @@ -1282,20 +1366,23 @@ e_act_resize_v_cont (E_Object *object, E_Action *a, void *data, int x, int y, i UN(dx); } - -static void -e_act_close_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_close_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; - if (b->win.client) e_icccm_delete(b->win.client); + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; + if (b->win.client) + e_icccm_delete(b->win.client); D_RETURN; UN(a); @@ -1306,19 +1393,23 @@ e_act_close_start (E_Object *object, E_Action *a, void *data, int x, int y, int UN(ry); } - -static void -e_act_kill_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_kill_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; - if (b->win.client) ecore_window_kill_client(b->win.client); + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; + if (b->win.client) + ecore_window_kill_client(b->win.client); D_RETURN; UN(a); @@ -1329,42 +1420,45 @@ e_act_kill_start (E_Object *object, E_Action *a, void *data, int x, int y, int r UN(ry); } -static void e_act_cb_shade(int val, void *data); +static void e_act_cb_shade(int val, void *data); static void e_act_cb_shade(int val, void *data) { - E_Border *b; - static double t = 0.0; - double dif; - int si; - int pix_per_sec = 3200; - + E_Border *b; + static double t = 0.0; + double dif; + int si; + int pix_per_sec = 3200; + D_ENTER; b = data; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; if (b->client.is_desktop) - D_RETURN; + D_RETURN; - if (val == 0) + if (val == 0) { t = ecore_get_time(); ecore_window_gravity_set(b->win.client, SouthWestGravity); e_action_del_timer(E_OBJECT(b), "shader"); e_action_add_timer(E_OBJECT(b), "shader"); } - - dif = ecore_get_time() - t; - + + dif = ecore_get_time() - t; + si = (int)(dif * (double)pix_per_sec); - if (si > b->client.h) si = b->client.h; + if (si > b->client.h) + si = b->client.h; b->current.shaded = si; b->changed = 1; e_border_adjust_limits(b); e_border_apply_border(b); - if (si < b->client.h) - ecore_add_event_timer("shader", 0.01, e_act_cb_shade, 1, data); + if (si < b->client.h) + ecore_add_event_timer("shader", 0.01, e_act_cb_shade, 1, data); else { e_action_del_timer(E_OBJECT(b), "shader"); @@ -1374,41 +1468,45 @@ e_act_cb_shade(int val, void *data) D_RETURN; } -static void e_act_cb_unshade(int val, void *data); +static void e_act_cb_unshade(int val, void *data); static void e_act_cb_unshade(int val, void *data) { - E_Border *b; - static double t = 0.0; - double dif; - int si; - int pix_per_sec = 3200; - + E_Border *b; + static double t = 0.0; + double dif; + int si; + int pix_per_sec = 3200; + D_ENTER; b = data; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; - if (val == 0) + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; + if (val == 0) { t = ecore_get_time(); ecore_window_gravity_set(b->win.client, SouthWestGravity); e_action_del_timer(E_OBJECT(b), "shader"); e_action_add_timer(E_OBJECT(b), "shader"); } - - dif = ecore_get_time() - t; - + + dif = ecore_get_time() - t; + si = b->client.h - (int)(dif * (double)pix_per_sec); - if (si < 0) si = 0; + if (si < 0) + si = 0; b->current.shaded = si; b->changed = 1; e_border_adjust_limits(b); e_border_apply_border(b); - if (si > 0) - ecore_add_event_timer("shader", 0.01, e_act_cb_unshade, 1, data); + if (si > 0) + ecore_add_event_timer("shader", 0.01, e_act_cb_unshade, 1, data); else { e_action_del_timer(E_OBJECT(b), "shader"); @@ -1418,24 +1516,27 @@ e_act_cb_unshade(int val, void *data) D_RETURN; } -static void -e_act_shade_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_shade_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; if (b->client.is_desktop) - D_RETURN; + D_RETURN; if (b->current.shaded == 0) - e_act_cb_shade(0, b); + e_act_cb_shade(0, b); else - e_act_cb_unshade(0, b); + e_act_cb_unshade(0, b); D_RETURN; UN(a); @@ -1446,18 +1547,21 @@ e_act_shade_start (E_Object *object, E_Action *a, void *data, int x, int y, int UN(ry); } - -static void -e_act_raise_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_raise_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; e_border_raise(b); D_RETURN; @@ -1469,18 +1573,21 @@ e_act_raise_start (E_Object *object, E_Action *a, void *data, int x, int y, int UN(ry); } - -static void -e_act_lower_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_lower_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; e_border_lower(b); D_RETURN; @@ -1492,18 +1599,21 @@ e_act_lower_start (E_Object *object, E_Action *a, void *data, int x, int y, int UN(ry); } - -static void -e_act_raise_lower_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_raise_lower_start(E_Object * object, E_Action * a, void *data, int x, + int y, int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; D_RETURN; UN(a); @@ -1514,16 +1624,17 @@ e_act_raise_lower_start (E_Object *object, E_Action *a, void *data, int x, int y UN(ry); } - -static void -e_act_exec_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_exec_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - char *exe; - + char *exe; + D_ENTER; - exe = (char *) a->params; - if(!exe) D_RETURN; + exe = (char *)a->params; + if (!exe) + D_RETURN; e_exec_run(exe); D_RETURN; @@ -1536,19 +1647,23 @@ e_act_exec_start (E_Object *object, E_Action *a, void *data, int x, int y, int r UN(object); } - -static void -e_act_menu_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_menu_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - if (e_block_is_active("menus")) D_RETURN; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; + if (e_block_is_active("menus")) + D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; e_bordermenu_do(b); @@ -1561,14 +1676,14 @@ e_act_menu_start (E_Object *object, E_Action *a, void *data, int x, int y, int r UN(ry); } - -static void -e_act_exit_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_exit_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { D_ENTER; e_view_machine_close_all_views(); - + ecore_focus_mode_reset(); ecore_sync(); @@ -1586,19 +1701,19 @@ e_act_exit_start (E_Object *object, E_Action *a, void *data, int x, int y, int r UN(ry); } - -static void -e_act_restart_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_restart_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { D_ENTER; e_view_machine_close_all_views(); - + ecore_focus_mode_reset(); ecore_sync(); e_db_runtime_flush(); - + e_exec_restart(); D_RETURN; @@ -1611,20 +1726,25 @@ e_act_restart_start (E_Object *object, E_Action *a, void *data, int x, int y, in UN(ry); } - -static void -e_act_stick_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_stick_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; - if (b->client.sticky) b->client.sticky = 0; - else b->client.sticky = 1; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; + if (b->client.sticky) + b->client.sticky = 0; + else + b->client.sticky = 1; b->changed = 1; D_RETURN; @@ -1636,9 +1756,9 @@ e_act_stick_start (E_Object *object, E_Action *a, void *data, int x, int y, int UN(ry); } - -static void -e_act_sound_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_sound_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { D_ENTER; @@ -1652,23 +1772,26 @@ e_act_sound_start (E_Object *object, E_Action *a, void *data, int x, int y, int UN(ry); } - -static void -e_act_iconify_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_iconify_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; #if 1 - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; D("iconify action start\n"); e_border_iconify(b); #endif - + D_RETURN; UN(object); UN(a); @@ -1679,20 +1802,25 @@ e_act_iconify_start (E_Object *object, E_Action *a, void *data, int x, int y, in UN(ry); } - -static void -e_act_max_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_max_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; - if (!b) b = e_border_current_focused(); - if (!b) D_RETURN; - if (b->client.is_desktop) D_RETURN; - if (b->current.shaded > 0) D_RETURN; - if ((b->mode.move) || (b->mode.resize)) D_RETURN; + b = (E_Border *) object; + if (!b) + b = e_border_current_focused(); + if (!b) + D_RETURN; + if (b->client.is_desktop) + D_RETURN; + if (b->current.shaded > 0) + D_RETURN; + if ((b->mode.move) || (b->mode.resize)) + D_RETURN; b->mode.move = 0; b->mode.resize = 0; if (b->max.is) @@ -1728,7 +1856,7 @@ e_act_max_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx b->current.requested.y = b->current.y; b->current.requested.w = b->current.w; b->current.requested.h = b->current.h; - + e_observee_notify_observers(E_OBSERVEE(b), E_EVENT_BORDER_MAXIMIZE); } @@ -1741,20 +1869,20 @@ e_act_max_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx UN(ry); } - -static void -e_act_snap_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +static void +e_act_snap_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - E_Border *b; - + E_Border *b; + D_ENTER; - b = (E_Border*) object; + b = (E_Border *) object; if (!b) - b = e_border_current_focused(); + b = e_border_current_focused(); if (!b) - D_RETURN; + D_RETURN; D_RETURN; UN(a); @@ -1765,70 +1893,41 @@ e_act_snap_start (E_Object *object, E_Action *a, void *data, int x, int y, int r UN(ry); } - -static void -e_act_zoom_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) -{ - E_Border *b; - - D_ENTER; - - b = (E_Border*) object; - - if (!b) - b = e_border_current_focused(); - - if (!b) - D_RETURN; - - D_RETURN; - UN(a); - UN(data); - UN(x); - UN(y); - UN(rx); - UN(ry); -} - - -static void -e_act_desk_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) -{ - int desk = 0; - - D_ENTER; - - if (a->params) - desk = atoi(a->params); - - e_desktops_goto_desk(desk); - - D_RETURN; - UN(object); - UN(a); - UN(data); - UN(x); - UN(y); - UN(rx); - UN(ry); -} - - static void -e_act_desk_rel_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) +e_act_zoom_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) { - int desk = 0; - int desk_max = e_desktops_get_num () - 1; + E_Border *b; D_ENTER; - - if (a->params) - desk = atoi(a->params) + e_desktops_get_current(); - if (desk < 0) - desk = desk_max; - else if (desk > desk_max) - desk = 0; + b = (E_Border *) object; + + if (!b) + b = e_border_current_focused(); + + if (!b) + D_RETURN; + + D_RETURN; + UN(a); + UN(data); + UN(x); + UN(y); + UN(rx); + UN(ry); +} + +static void +e_act_desk_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) +{ + int desk = 0; + + D_ENTER; + + if (a->params) + desk = atoi(a->params); e_desktops_goto_desk(desk); @@ -1842,9 +1941,38 @@ e_act_desk_rel_start (E_Object *object, E_Action *a, void *data, int x, int y, i UN(ry); } +static void +e_act_desk_rel_start(E_Object * object, E_Action * a, void *data, int x, int y, + int rx, int ry) +{ + int desk = 0; + int desk_max = e_desktops_get_num() - 1; -static void -e_act_raise_next_start (E_Object *object, E_Action *a, void *data, int x, int y, int rx, int ry) + D_ENTER; + + if (a->params) + desk = atoi(a->params) + e_desktops_get_current(); + + if (desk < 0) + desk = desk_max; + else if (desk > desk_max) + desk = 0; + + e_desktops_goto_desk(desk); + + D_RETURN; + UN(object); + UN(a); + UN(data); + UN(x); + UN(y); + UN(rx); + UN(ry); +} + +static void +e_act_raise_next_start(E_Object * object, E_Action * a, void *data, int x, + int y, int rx, int ry) { D_ENTER; diff --git a/src/actions.h b/src/actions.h index 29a25db97..9ba2833e7 100644 --- a/src/actions.h +++ b/src/actions.h @@ -3,65 +3,68 @@ #include "object.h" -typedef struct _E_Action E_Action; -typedef struct _E_Action_Impl E_Action_Impl; +typedef struct _E_Action E_Action; +typedef struct _E_Action_Impl E_Action_Impl; typedef struct _E_Active_Action_Timer E_Active_Action_Timer; typedef enum e_action_type { - ACT_MOUSE_IN, - ACT_MOUSE_OUT, - ACT_MOUSE_CLICK, - ACT_MOUSE_DOUBLE, - ACT_MOUSE_TRIPLE, - ACT_MOUSE_UP, - ACT_MOUSE_CLICKED, - ACT_MOUSE_MOVE, - ACT_KEY_DOWN, - ACT_KEY_UP -} E_Action_Type; + ACT_MOUSE_IN, + ACT_MOUSE_OUT, + ACT_MOUSE_CLICK, + ACT_MOUSE_DOUBLE, + ACT_MOUSE_TRIPLE, + ACT_MOUSE_UP, + ACT_MOUSE_CLICKED, + ACT_MOUSE_MOVE, + ACT_KEY_DOWN, + ACT_KEY_UP +} +E_Action_Type; struct _E_Active_Action_Timer { - void *object; - char *name; + void *object; + char *name; }; struct _E_Action { - E_Object o; - - char *name; - char *action; - char *params; - E_Action_Type event; - int button; - char *key; - int modifiers; - E_Action_Impl *action_impl; - E_Object *object; - int started; - int grabbed; + E_Object o; + + char *name; + char *action; + char *params; + E_Action_Type event; + int button; + char *key; + int modifiers; + E_Action_Impl *action_impl; + E_Object *object; + int started; + int grabbed; }; -typedef void (*E_Action_Start_Func)(E_Object *o, E_Action *a, - void *data, int x, int y, int rx, int ry); -typedef void (*E_Action_Cont_Func) (E_Object *o, E_Action *a, - void *data, int x, int y, int rx, int ry, int dx, int dy); -typedef void (*E_Action_Stop_Func) (E_Object *o, E_Action *a, - void *data, int x, int y, int rx, int ry); - +typedef void (*E_Action_Start_Func) (E_Object * o, E_Action * a, + void *data, int x, int y, int rx, + int ry); +typedef void (*E_Action_Cont_Func) (E_Object * o, E_Action * a, + void *data, int x, int y, int rx, + int ry, int dx, int dy); +typedef void (*E_Action_Stop_Func) (E_Object * o, E_Action * a, + void *data, int x, int y, int rx, + int ry); + struct _E_Action_Impl { - E_Object o; - - char *action; - + E_Object o; + + char *action; + E_Action_Start_Func func_start; E_Action_Cont_Func func_cont; E_Action_Stop_Func func_stop; }; - /** * e_action_init - Actions implementation initializer @@ -69,23 +72,29 @@ struct _E_Action_Impl * This function registers the various action implementations, * i.e. the way E performs actions. */ -void e_action_init(void); +void e_action_init(void); -int e_action_start(char *action, E_Action_Type act, int button, char *key, - Ecore_Event_Key_Modifiers mods, E_Object *o, void *data, - int x, int y, int rx, int ry); -void e_action_stop(char *action, E_Action_Type act, int button, char *key, - Ecore_Event_Key_Modifiers mods, E_Object *o, void *data, - int x, int y, int rx, int ry); -void e_action_cont(char *action, E_Action_Type act, int button, char *key, - Ecore_Event_Key_Modifiers mods, E_Object *o, void *data, - int x, int y, int rx, int ry, int dx, int dy); -void e_action_stop_by_object(E_Object *o, void *data, int x, int y, int rx, int ry); -void e_action_stop_by_type(char *action); -void e_action_add_impl(char *action, E_Action_Start_Func func_start, - E_Action_Cont_Func func_cont, E_Action_Stop_Func func_stop); -void e_action_del_timer(E_Object *object, char *name); -void e_action_add_timer(E_Object *object, char *name); -void e_action_del_timer_object(E_Object *object); +int e_action_start(char *action, E_Action_Type act, int button, + char *key, Ecore_Event_Key_Modifiers mods, + E_Object * o, void *data, int x, int y, + int rx, int ry); +void e_action_stop(char *action, E_Action_Type act, int button, + char *key, Ecore_Event_Key_Modifiers mods, + E_Object * o, void *data, int x, int y, + int rx, int ry); +void e_action_cont(char *action, E_Action_Type act, int button, + char *key, Ecore_Event_Key_Modifiers mods, + E_Object * o, void *data, int x, int y, + int rx, int ry, int dx, int dy); +void e_action_stop_by_object(E_Object * o, void *data, int x, + int y, int rx, int ry); +void e_action_stop_by_type(char *action); +void e_action_add_impl(char *action, + E_Action_Start_Func func_start, + E_Action_Cont_Func func_cont, + E_Action_Stop_Func func_stop); +void e_action_del_timer(E_Object * object, char *name); +void e_action_add_timer(E_Object * object, char *name); +void e_action_del_timer_object(E_Object * object); #endif diff --git a/src/background.c b/src/background.c index 45e760e73..dca848fa0 100644 --- a/src/background.c +++ b/src/background.c @@ -4,9 +4,9 @@ #include "util.h" static void -e_background_cleanup(E_Background *bg) +e_background_cleanup(E_Background * bg) { - Evas_List l; + Evas_List l; D_ENTER; @@ -15,49 +15,55 @@ e_background_cleanup(E_Background *bg) for (l = bg->layers; l; l = l->next) { E_Background_Layer *bl; - + bl = l->data; - if (bl->color_class) FREE(bl->color_class); - if (bl->file) FREE(bl->file); - if (bl->obj) evas_del_object(bg->evas, bl->obj); + if (bl->color_class) + FREE(bl->color_class); + if (bl->file) + FREE(bl->file); + if (bl->obj) + evas_del_object(bg->evas, bl->obj); FREE(bl); } evas_list_free(bg->layers); } - if (bg->file) FREE (bg->file); - if (bg->base_obj) evas_del_object(bg->evas, bg->base_obj); + if (bg->file) + FREE(bg->file); + if (bg->base_obj) + evas_del_object(bg->evas, bg->base_obj); e_object_cleanup(E_OBJECT(bg)); D_RETURN; } -E_Background * +E_Background * e_background_new(void) { - E_Background *bg; - + E_Background *bg; + D_ENTER; bg = NEW(E_Background, 1); ZERO(bg, E_Background, 1); e_object_init(E_OBJECT(bg), (E_Cleanup_Func) e_background_cleanup); - + D_RETURN_(bg); } -E_Background * +E_Background * e_background_load(char *file) { - E_Background *bg; - E_DB_File *db; - int i, num; - + E_Background *bg; + E_DB_File *db; + int i, num; + D_ENTER; db = e_db_open_read(file); - if (!db) D_RETURN_(NULL); + if (!db) + D_RETURN_(NULL); num = 0; e_db_int_get(db, "/type/bg", &num); if (num != 1) @@ -67,77 +73,105 @@ e_background_load(char *file) D_RETURN_(NULL); } e_db_int_get(db, "/layers/count", &num); - + bg = e_background_new(); e_strdup(bg->file, file); for (i = 0; i < num; i++) { E_Background_Layer *bl; - char buf[PATH_MAX]; - + char buf[PATH_MAX]; + bl = NEW(E_Background_Layer, 1); ZERO(bl, E_Background_Layer, 1); bg->layers = evas_list_append(bg->layers, bl); - - snprintf(buf, PATH_MAX, "/layers/%i/type", i); e_db_int_get(db, buf, (int*)&(bl->type)); - snprintf(buf, PATH_MAX, "/layers/%i/inlined", i); e_db_int_get(db, buf, &(bl->inlined)); - snprintf(buf, PATH_MAX, "/layers/%i/color_class", i); bl->color_class = e_db_str_get(db, buf); + + snprintf(buf, PATH_MAX, "/layers/%i/type", i); + e_db_int_get(db, buf, (int *)&(bl->type)); + snprintf(buf, PATH_MAX, "/layers/%i/inlined", i); + e_db_int_get(db, buf, &(bl->inlined)); + snprintf(buf, PATH_MAX, "/layers/%i/color_class", i); + bl->color_class = e_db_str_get(db, buf); if (bl->inlined) { - snprintf(buf, PATH_MAX, "%s:/layers/%i/image", file, i); e_strdup(bl->file, buf); + snprintf(buf, PATH_MAX, "%s:/layers/%i/image", file, i); + e_strdup(bl->file, buf); } else { - snprintf(buf, PATH_MAX, "/layers/%i/file", i); bl->file = e_db_str_get(db, buf); + snprintf(buf, PATH_MAX, "/layers/%i/file", i); + bl->file = e_db_str_get(db, buf); } - snprintf(buf, PATH_MAX, "/layers/%i/scroll.x", i); e_db_float_get(db, buf, &(bl->scroll.x)); - snprintf(buf, PATH_MAX, "/layers/%i/scroll.y", i); e_db_float_get(db, buf, &(bl->scroll.y)); - snprintf(buf, PATH_MAX, "/layers/%i/pos.x", i); e_db_float_get(db, buf, &(bl->pos.x)); - snprintf(buf, PATH_MAX, "/layers/%i/pos.y", i); e_db_float_get(db, buf, &(bl->pos.y)); - snprintf(buf, PATH_MAX, "/layers/%i/size.w", i); e_db_float_get(db, buf, &(bl->size.w)); - snprintf(buf, PATH_MAX, "/layers/%i/size.h", i); e_db_float_get(db, buf, &(bl->size.h)); - snprintf(buf, PATH_MAX, "/layers/%i/size.orig.w", i); e_db_int_get(db, buf, &(bl->size.orig.w)); - snprintf(buf, PATH_MAX, "/layers/%i/size.orig.h", i); e_db_int_get(db, buf, &(bl->size.orig.h)); - snprintf(buf, PATH_MAX, "/layers/%i/fill.w", i); e_db_float_get(db, buf, &(bl->fill.w)); - snprintf(buf, PATH_MAX, "/layers/%i/fill.h", i); e_db_float_get(db, buf, &(bl->fill.h)); - snprintf(buf, PATH_MAX, "/layers/%i/fill.orig.w", i); e_db_int_get(db, buf, &(bl->fill.orig.w)); - snprintf(buf, PATH_MAX, "/layers/%i/fill.orig.h", i); e_db_int_get(db, buf, &(bl->fill.orig.h)); - snprintf(buf, PATH_MAX, "/layers/%i/angle", i); e_db_float_get(db, buf, (float*)&(bl->angle)); - snprintf(buf, PATH_MAX, "/layers/%i/fg.r", i); e_db_int_get(db, buf, &(bl->fg.r)); - snprintf(buf, PATH_MAX, "/layers/%i/fg.g", i); e_db_int_get(db, buf, &(bl->fg.g)); - snprintf(buf, PATH_MAX, "/layers/%i/fg.b", i); e_db_int_get(db, buf, &(bl->fg.b)); - snprintf(buf, PATH_MAX, "/layers/%i/fg.a", i); e_db_int_get(db, buf, &(bl->fg.a)); - snprintf(buf, PATH_MAX, "/layers/%i/bg.r", i); e_db_int_get(db, buf, &(bl->bg.r)); - snprintf(buf, PATH_MAX, "/layers/%i/bg.g", i); e_db_int_get(db, buf, &(bl->bg.g)); - snprintf(buf, PATH_MAX, "/layers/%i/bg.b", i); e_db_int_get(db, buf, &(bl->bg.b)); - snprintf(buf, PATH_MAX, "/layers/%i/bg.a", i); e_db_int_get(db, buf, &(bl->bg.a)); + snprintf(buf, PATH_MAX, "/layers/%i/scroll.x", i); + e_db_float_get(db, buf, &(bl->scroll.x)); + snprintf(buf, PATH_MAX, "/layers/%i/scroll.y", i); + e_db_float_get(db, buf, &(bl->scroll.y)); + snprintf(buf, PATH_MAX, "/layers/%i/pos.x", i); + e_db_float_get(db, buf, &(bl->pos.x)); + snprintf(buf, PATH_MAX, "/layers/%i/pos.y", i); + e_db_float_get(db, buf, &(bl->pos.y)); + snprintf(buf, PATH_MAX, "/layers/%i/size.w", i); + e_db_float_get(db, buf, &(bl->size.w)); + snprintf(buf, PATH_MAX, "/layers/%i/size.h", i); + e_db_float_get(db, buf, &(bl->size.h)); + snprintf(buf, PATH_MAX, "/layers/%i/size.orig.w", i); + e_db_int_get(db, buf, &(bl->size.orig.w)); + snprintf(buf, PATH_MAX, "/layers/%i/size.orig.h", i); + e_db_int_get(db, buf, &(bl->size.orig.h)); + snprintf(buf, PATH_MAX, "/layers/%i/fill.w", i); + e_db_float_get(db, buf, &(bl->fill.w)); + snprintf(buf, PATH_MAX, "/layers/%i/fill.h", i); + e_db_float_get(db, buf, &(bl->fill.h)); + snprintf(buf, PATH_MAX, "/layers/%i/fill.orig.w", i); + e_db_int_get(db, buf, &(bl->fill.orig.w)); + snprintf(buf, PATH_MAX, "/layers/%i/fill.orig.h", i); + e_db_int_get(db, buf, &(bl->fill.orig.h)); + snprintf(buf, PATH_MAX, "/layers/%i/angle", i); + e_db_float_get(db, buf, (float *)&(bl->angle)); + snprintf(buf, PATH_MAX, "/layers/%i/fg.r", i); + e_db_int_get(db, buf, &(bl->fg.r)); + snprintf(buf, PATH_MAX, "/layers/%i/fg.g", i); + e_db_int_get(db, buf, &(bl->fg.g)); + snprintf(buf, PATH_MAX, "/layers/%i/fg.b", i); + e_db_int_get(db, buf, &(bl->fg.b)); + snprintf(buf, PATH_MAX, "/layers/%i/fg.a", i); + e_db_int_get(db, buf, &(bl->fg.a)); + snprintf(buf, PATH_MAX, "/layers/%i/bg.r", i); + e_db_int_get(db, buf, &(bl->bg.r)); + snprintf(buf, PATH_MAX, "/layers/%i/bg.g", i); + e_db_int_get(db, buf, &(bl->bg.g)); + snprintf(buf, PATH_MAX, "/layers/%i/bg.b", i); + e_db_int_get(db, buf, &(bl->bg.b)); + snprintf(buf, PATH_MAX, "/layers/%i/bg.a", i); + e_db_int_get(db, buf, &(bl->bg.a)); } e_db_close(db); D_RETURN_(bg); } void -e_background_realize(E_Background *bg, Evas evas) +e_background_realize(E_Background * bg, Evas evas) { - Evas_List l; - int ww, hh, count; + Evas_List l; + int ww, hh, count; D_ENTER; - if (bg->evas) D_RETURN; + if (bg->evas) + D_RETURN; bg->evas = evas; - if (!bg->evas) D_RETURN; + if (!bg->evas) + D_RETURN; for (count = 0, l = bg->layers; l; l = l->next, count++) { E_Background_Layer *bl; - + bl = l->data; if (bl->type == E_BACKGROUND_TYPE_IMAGE) { bl->obj = evas_add_image_from_file(bg->evas, bl->file); evas_set_layer(bg->evas, bl->obj, 0); evas_show(bg->evas, bl->obj); -#if 0 /* dont need this... do we? */ +#if 0 /* dont need this... do we? */ if (evas_get_image_alpha(bg->evas, bl->obj)) { D("Adding rectangle to bg!\n"); @@ -167,25 +201,27 @@ e_background_realize(E_Background *bg, Evas evas) } void -e_background_set_scroll(E_Background *bg, int sx, int sy) +e_background_set_scroll(E_Background * bg, int sx, int sy) { - Evas_List l; - + Evas_List l; + D_ENTER; - if ((bg->geom.sx == sx) && (bg->geom.sy == sy)) D_RETURN; + if ((bg->geom.sx == sx) && (bg->geom.sy == sy)) + D_RETURN; bg->geom.sx = sx; bg->geom.sy = sy; - if (!bg->evas) D_RETURN; + if (!bg->evas) + D_RETURN; for (l = bg->layers; l; l = l->next) { E_Background_Layer *bl; - + bl = l->data; if (bl->type == E_BACKGROUND_TYPE_IMAGE) { - evas_set_image_fill(bg->evas, bl->obj, - (double)bg->geom.sx * bl->scroll.x, + evas_set_image_fill(bg->evas, bl->obj, + (double)bg->geom.sx * bl->scroll.x, (double)bg->geom.sy * bl->scroll.y, bl->fw, bl->fh); } @@ -194,33 +230,43 @@ e_background_set_scroll(E_Background *bg, int sx, int sy) } void -e_background_set_size(E_Background *bg, int w, int h) +e_background_set_size(E_Background * bg, int w, int h) { - Evas_List l; - + Evas_List l; + D_ENTER; - if ((bg->geom.w == w) && (bg->geom.h == h)) D_RETURN; + if ((bg->geom.w == w) && (bg->geom.h == h)) + D_RETURN; bg->geom.w = w; bg->geom.h = h; for (l = bg->layers; l; l = l->next) { E_Background_Layer *bl; - double x, y, w, h, fw, fh; - int iw, ih; - + double x, y, w, h, fw, fh; + int iw, ih; + bl = l->data; iw = 0; ih = 0; - if (bg->evas) evas_get_image_size(bg->evas, bl->obj, &iw, &ih); + if (bg->evas) + evas_get_image_size(bg->evas, bl->obj, &iw, &ih); w = bl->size.w * (double)bg->geom.w; h = bl->size.h * (double)bg->geom.h; - if (bl->size.orig.w) w = (double)iw * bl->size.w; - if (bl->size.orig.h) h = (double)ih * bl->size.h; + if (bl->size.orig.w) + w = (double)iw *bl->size.w; + + if (bl->size.orig.h) + h = (double)ih *bl->size.h; + fw = bl->fill.w * w; fh = bl->fill.h * h; - if (bl->fill.orig.w) fw = (double)iw * bl->fill.w; - if (bl->fill.orig.h) fh = (double)ih * bl->fill.h; + if (bl->fill.orig.w) + fw = (double)iw *bl->fill.w; + + if (bl->fill.orig.h) + fh = (double)ih *bl->fill.h; + x = ((double)bg->geom.w - w + 1) * bl->pos.x; y = ((double)bg->geom.h - h + 1) * bl->pos.y; bl->x = x; @@ -253,25 +299,26 @@ e_background_set_size(E_Background *bg, int w, int h) } void -e_background_set_color_class(E_Background *bg, char *cc, int r, int g, int b, int a) +e_background_set_color_class(E_Background * bg, char *cc, int r, int g, int b, + int a) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = bg->layers; l; l = l->next) { E_Background_Layer *bl; - + bl = l->data; if ((bl->color_class) && (cc) && (!strcmp(bl->color_class, cc))) { if (bg->evas) { if ((l == bg->layers) && (bg->base_obj)) - evas_set_color(bg->evas, bl->obj, r, g, b, 255); + evas_set_color(bg->evas, bl->obj, r, g, b, 255); else - evas_set_color(bg->evas, bl->obj, r, g, b, a); + evas_set_color(bg->evas, bl->obj, r, g, b, a); } } } diff --git a/src/background.h b/src/background.h index a034c0eaf..3b38e1d3b 100644 --- a/src/background.h +++ b/src/background.h @@ -3,70 +3,81 @@ #include "object.h" -typedef struct _E_Background E_Background; -typedef struct _E_Background_Layer E_Background_Layer; +typedef struct _E_Background E_Background; +typedef struct _E_Background_Layer E_Background_Layer; typedef enum { - E_BACKGROUND_TYPE_IMAGE = 0, - E_BACKGROUND_TYPE_GRADIENT = 1, - E_BACKGROUND_TYPE_SOLID = 2 + E_BACKGROUND_TYPE_IMAGE = 0, + E_BACKGROUND_TYPE_GRADIENT = 1, + E_BACKGROUND_TYPE_SOLID = 2 } E_Background_Type; struct _E_Background { - E_Object o; - - Evas evas; - char *file; - - struct { - int sx, sy; - int w, h; - } geom; - - Evas_List layers; - - Evas_Object base_obj; -}; + E_Object o; + Evas evas; + char *file; + + struct + { + int sx, sy; + int w, h; + } + geom; + + Evas_List layers; + + Evas_Object base_obj; +}; struct _E_Background_Layer { - E_Background_Type type; - int inlined; - struct { - float x, y; - } scroll; - struct { - float x, y; - } pos; - struct { - float w, h; - struct { - int w, h; - } orig; - } size, fill; - char *color_class; - char *file; - double angle; - struct { - int r, g, b, a; - } fg, bg; - - double x, y, w, h, fw, fh; - - Evas_Object obj; + E_Background_Type type; + int inlined; + struct + { + float x, y; + } + scroll; + struct + { + float x, y; + } + pos; + struct + { + float w, h; + struct + { + int w, h; + } + orig; + } + size , fill; + char *color_class; + char *file; + double angle; + struct + { + int r, g, b, a; + } + fg , bg; + + double x, y, w, h, fw, fh; + + Evas_Object obj; }; +E_Background *e_background_new(void); +E_Background *e_background_load(char *file); -E_Background *e_background_new(void); -E_Background *e_background_load(char *file); +void e_background_realize(E_Background * bg, Evas evas); +void e_background_set_scroll(E_Background * bg, int sx, int sy); +void e_background_set_size(E_Background * bg, int w, int h); +void e_background_set_color_class(E_Background * bg, char *cc, + int r, int g, int b, int a); -void e_background_realize(E_Background *bg, Evas evas); -void e_background_set_scroll(E_Background *bg, int sx, int sy); -void e_background_set_size(E_Background *bg, int w, int h); -void e_background_set_color_class(E_Background *bg, char *cc, int r, int g, int b, int a); - -#endif +#endif diff --git a/src/block.c b/src/block.c index 50e866f03..f5aac9e48 100644 --- a/src/block.c +++ b/src/block.c @@ -6,24 +6,24 @@ typedef struct _e_block E_Block; struct _e_block { - char *name; - int refs; + char *name; + int refs; }; -static Evas_List blocks = NULL; +static Evas_List blocks = NULL; -static E_Block *e_block_find(char *name); +static E_Block *e_block_find(char *name); -static E_Block * +static E_Block * e_block_find(char *name) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = blocks; l; l = l->next) { - E_Block *b; - + E_Block *b; + b = l->data; if (!strcmp(b->name, name)) { @@ -38,8 +38,8 @@ e_block_find(char *name) void e_block_start(char *name) { - E_Block *b; - + E_Block *b; + D_ENTER; b = e_block_find(name); if (b) @@ -58,8 +58,8 @@ e_block_start(char *name) void e_block_stop(char *name) { - E_Block *b; - + E_Block *b; + D_ENTER; b = e_block_find(name); if (b) @@ -69,7 +69,7 @@ e_block_stop(char *name) { blocks = evas_list_remove(blocks, b); IF_FREE(b->name); - FREE(b); + FREE(b); } } D_RETURN; @@ -78,8 +78,8 @@ e_block_stop(char *name) int e_block_is_active(char *name) { - E_Block *b; - + E_Block *b; + D_ENTER; b = e_block_find(name); if (b) diff --git a/src/block.h b/src/block.h index bc73532b4..f34aadd3d 100644 --- a/src/block.h +++ b/src/block.h @@ -3,9 +3,8 @@ #include "e.h" -void e_block_start(char *name); -void e_block_stop(char *name); -int e_block_is_active(char *name); +void e_block_start(char *name); +void e_block_stop(char *name); +int e_block_is_active(char *name); #endif - diff --git a/src/border.c b/src/border.c index 21186cf96..df556677a 100644 --- a/src/border.c +++ b/src/border.c @@ -18,77 +18,84 @@ /* Window border rendering, querying, setting & modification code */ /* globals local to window borders */ -static Evas_List evases = NULL; -static Evas_List borders = NULL; +static Evas_List evases = NULL; +static Evas_List borders = NULL; -static int mouse_x, mouse_y, mouse_win_x, mouse_win_y; -static int mouse_buttons = 0; +static int mouse_x, mouse_y, mouse_win_x, mouse_win_y; +static int mouse_buttons = 0; -static int border_mouse_x = 0; -static int border_mouse_y = 0; -static int border_mouse_buttons = 0; +static int border_mouse_x = 0; +static int border_mouse_y = 0; +static int border_mouse_buttons = 0; static Ecore_Event *current_ev = NULL; /* Global delayed window raise action */ -E_Delayed_Action *delayed_window_raise = NULL; +E_Delayed_Action *delayed_window_raise = NULL; -static void e_idle(void *data); -static void e_map_request(Ecore_Event * ev); -static void e_configure_request(Ecore_Event * ev); -static void e_property(Ecore_Event * ev); -static void e_unmap(Ecore_Event * ev); -static void e_destroy(Ecore_Event * ev); -static void e_circulate_request(Ecore_Event * ev); -static void e_reparent(Ecore_Event * ev); -static void e_shape(Ecore_Event * ev); -static void e_focus_in(Ecore_Event * ev); -static void e_focus_out(Ecore_Event * ev); -static void e_colormap(Ecore_Event * ev); -static void e_mouse_down(Ecore_Event * ev); -static void e_mouse_up(Ecore_Event * ev); -static void e_mouse_in(Ecore_Event * ev); -static void e_mouse_out(Ecore_Event * ev); -static void e_window_expose(Ecore_Event * ev); +static void e_idle(void *data); +static void e_map_request(Ecore_Event * ev); +static void e_configure_request(Ecore_Event * ev); +static void e_property(Ecore_Event * ev); +static void e_unmap(Ecore_Event * ev); +static void e_destroy(Ecore_Event * ev); +static void e_circulate_request(Ecore_Event * ev); +static void e_reparent(Ecore_Event * ev); +static void e_shape(Ecore_Event * ev); +static void e_focus_in(Ecore_Event * ev); +static void e_focus_out(Ecore_Event * ev); +static void e_colormap(Ecore_Event * ev); +static void e_mouse_down(Ecore_Event * ev); +static void e_mouse_up(Ecore_Event * ev); +static void e_mouse_in(Ecore_Event * ev); +static void e_mouse_out(Ecore_Event * ev); +static void e_window_expose(Ecore_Event * ev); -static void e_cb_mouse_in(void *data, Ebits_Object o, char *class, int bt, - int x, int y, int ox, int oy, int ow, int oh); -static void e_cb_mouse_out(void *data, Ebits_Object o, char *class, int bt, - int x, int y, int ox, int oy, int ow, int oh); -static void e_cb_mouse_down(void *data, Ebits_Object o, char *class, int bt, - int x, int y, int ox, int oy, int ow, int oh); -static void e_cb_mouse_up(void *data, Ebits_Object o, char *class, int bt, - int x, int y, int ox, int oy, int ow, int oh); -static void e_cb_mouse_move(void *data, Ebits_Object o, char *class, int bt, - int x, int y, int ox, int oy, int ow, int oh); +static void e_cb_mouse_in(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, int ow, + int oh); +static void e_cb_mouse_out(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, int ow, + int oh); +static void e_cb_mouse_down(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, + int ow, int oh); +static void e_cb_mouse_up(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, int ow, + int oh); +static void e_cb_mouse_move(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, + int ow, int oh); -static void e_cb_border_mouse_in(E_Border *b, Ecore_Event *e); -static void e_cb_border_mouse_out(E_Border *b, Ecore_Event *e); -static void e_cb_border_mouse_down(E_Border *b, Ecore_Event *e); -static void e_cb_border_mouse_up(E_Border *b, Ecore_Event *e); -static void e_cb_border_mouse_move(E_Border *b, Ecore_Event *e); -static void e_cb_border_move_resize(E_Border *b); -static void e_cb_border_visibility(E_Border *b); +static void e_cb_border_mouse_in(E_Border * b, Ecore_Event * e); +static void e_cb_border_mouse_out(E_Border * b, Ecore_Event * e); +static void e_cb_border_mouse_down(E_Border * b, Ecore_Event * e); +static void e_cb_border_mouse_up(E_Border * b, Ecore_Event * e); +static void e_cb_border_mouse_move(E_Border * b, Ecore_Event * e); +static void e_cb_border_move_resize(E_Border * b); +static void e_cb_border_visibility(E_Border * b); -static void e_border_poll(int val, void *data); -static void e_border_cleanup(E_Border *b); +static void e_border_poll(int val, void *data); +static void e_border_cleanup(E_Border * b); -static int e_border_replay_query(Ecore_Event_Mouse_Down *ev) +static int +e_border_replay_query(Ecore_Event_Mouse_Down * ev) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = e_border_find_by_window(ev->win); if (b) { - int focus_mode; + int focus_mode; + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); - + E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); if ((focus_mode == 2) && (ev->mods == ECORE_EVENT_KEY_MODIFIER_NONE)) - /* FIXME: also if pass click always set */ - D_RETURN_(1); + /* FIXME: also if pass click always set */ + D_RETURN_(1); } D_RETURN_(0); @@ -99,21 +106,21 @@ static int e_border_replay_query(Ecore_Event_Mouse_Down *ev) void e_border_update_borders(void) { - Evas_List l; + Evas_List l; D_ENTER; for (l = borders; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; e_border_update(b); } for (l = borders; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; if (b->first_expose) { @@ -143,22 +150,22 @@ e_idle(void *data) static void e_map_request(Ecore_Event * ev) { - Ecore_Event_Window_Map_Request *e; - + Ecore_Event_Window_Map_Request *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if (!b) - { - if (ecore_window_exists(e->win)) - b = e_border_adopt(e->win, 0); - } - } + { + E_Border *b; + + b = e_border_find_by_window(e->win); + if (!b) + { + if (ecore_window_exists(e->win)) + b = e_border_adopt(e->win, 0); + } + } current_ev = NULL; D_RETURN; @@ -168,86 +175,99 @@ e_map_request(Ecore_Event * ev) static void e_configure_request(Ecore_Event * ev) { - Ecore_Event_Window_Configure_Request *e; - + Ecore_Event_Window_Configure_Request *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if (b) - { - int pl, pr, pt, pb; - - pl = pr = pt = pb = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); - if (e->mask & ECORE_EVENT_VALUE_X) - b->current.requested.x = e->x; - if (e->mask & ECORE_EVENT_VALUE_Y) - b->current.requested.y = e->y; - if ((e->mask & ECORE_EVENT_VALUE_W) || (e->mask & ECORE_EVENT_VALUE_H)) - { - if (b->current.shaded == b->client.h) - { - b->current.shaded = e->h; - } - else if (b->current.shaded != 0) - { - b->current.shaded += b->client.h - e->h; - if (b->current.shaded > b->client.h) - b->current.shaded = b->client.h; - if (b->current.shaded < 1) - b->current.shaded = 1; - } - b->current.requested.w = e->w + pl + pr; - b->current.requested.h = e->h + pt + pb; - } - if ((e->mask & ECORE_EVENT_VALUE_SIBLING) && (e->mask & ECORE_EVENT_VALUE_STACKING)) - { - E_Border *b_rel; - - b_rel = e_border_find_by_window(e->stack_win); - if (b_rel) - { - if (e->detail == ECORE_EVENT_STACK_ABOVE) e_border_raise_above(b, b_rel); - else if (e->detail == ECORE_EVENT_STACK_BELOW) e_border_lower_below(b, b_rel); - /* FIXME: need to handle & fix - * ECORE_EVENT_STACK_TOP_IF - * ECORE_EVENT_STACK_BOTTOM_IF - * ECORE_EVENT_STACK_OPPOSITE - */ - else if (e->detail == ECORE_EVENT_STACK_TOP_IF) e_border_raise(b); - else if (e->detail == ECORE_EVENT_STACK_BOTTOM_IF) e_border_lower(b); - } - } - else if (e->mask & ECORE_EVENT_VALUE_STACKING) - { - if (e->detail == ECORE_EVENT_STACK_ABOVE) e_border_raise(b); - else if (e->detail == ECORE_EVENT_STACK_BELOW) e_border_lower(b); - /* FIXME: need to handle & fix - * ECORE_EVENT_STACK_TOP_IF - * ECORE_EVENT_STACK_BOTTOM_IF - * ECORE_EVENT_STACK_OPPOSITE - */ - else if (e->detail == ECORE_EVENT_STACK_TOP_IF) e_border_raise(b); - else if (e->detail == ECORE_EVENT_STACK_BOTTOM_IF) e_border_lower(b); - } - b->changed = 1; - e_border_adjust_limits(b); - } - else - { - if ((e->mask & ECORE_EVENT_VALUE_X) && (e->mask & ECORE_EVENT_VALUE_W)) - ecore_window_move_resize(e->win, e->x, e->y, e->w, e->h); - else if ((e->mask & ECORE_EVENT_VALUE_W) || (e->mask & ECORE_EVENT_VALUE_H)) - ecore_window_resize(e->win, e->w, e->h); - else if ((e->mask & ECORE_EVENT_VALUE_X)) - ecore_window_move(e->win, e->x, e->y); - } - } + { + E_Border *b; + + b = e_border_find_by_window(e->win); + if (b) + { + int pl, pr, pt, pb; + + pl = pr = pt = pb = 0; + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + if (e->mask & ECORE_EVENT_VALUE_X) + b->current.requested.x = e->x; + if (e->mask & ECORE_EVENT_VALUE_Y) + b->current.requested.y = e->y; + if ((e->mask & ECORE_EVENT_VALUE_W) + || (e->mask & ECORE_EVENT_VALUE_H)) + { + if (b->current.shaded == b->client.h) + { + b->current.shaded = e->h; + } + else if (b->current.shaded != 0) + { + b->current.shaded += b->client.h - e->h; + if (b->current.shaded > b->client.h) + b->current.shaded = b->client.h; + if (b->current.shaded < 1) + b->current.shaded = 1; + } + b->current.requested.w = e->w + pl + pr; + b->current.requested.h = e->h + pt + pb; + } + if ((e->mask & ECORE_EVENT_VALUE_SIBLING) + && (e->mask & ECORE_EVENT_VALUE_STACKING)) + { + E_Border *b_rel; + + b_rel = e_border_find_by_window(e->stack_win); + if (b_rel) + { + if (e->detail == ECORE_EVENT_STACK_ABOVE) + e_border_raise_above(b, b_rel); + else if (e->detail == ECORE_EVENT_STACK_BELOW) + e_border_lower_below(b, b_rel); + /* FIXME: need to handle & fix + * ECORE_EVENT_STACK_TOP_IF + * ECORE_EVENT_STACK_BOTTOM_IF + * ECORE_EVENT_STACK_OPPOSITE + */ + else if (e->detail == ECORE_EVENT_STACK_TOP_IF) + e_border_raise(b); + else if (e->detail == ECORE_EVENT_STACK_BOTTOM_IF) + e_border_lower(b); + } + } + else if (e->mask & ECORE_EVENT_VALUE_STACKING) + { + if (e->detail == ECORE_EVENT_STACK_ABOVE) + e_border_raise(b); + else if (e->detail == ECORE_EVENT_STACK_BELOW) + e_border_lower(b); + /* FIXME: need to handle & fix + * ECORE_EVENT_STACK_TOP_IF + * ECORE_EVENT_STACK_BOTTOM_IF + * ECORE_EVENT_STACK_OPPOSITE + */ + else if (e->detail == ECORE_EVENT_STACK_TOP_IF) + e_border_raise(b); + else if (e->detail == ECORE_EVENT_STACK_BOTTOM_IF) + e_border_lower(b); + } + b->changed = 1; + e_border_adjust_limits(b); + } + else + { + if ((e->mask & ECORE_EVENT_VALUE_X) + && (e->mask & ECORE_EVENT_VALUE_W)) + ecore_window_move_resize(e->win, e->x, e->y, e->w, e->h); + else if ((e->mask & ECORE_EVENT_VALUE_W) + || (e->mask & ECORE_EVENT_VALUE_H)) + ecore_window_resize(e->win, e->w, e->h); + else if ((e->mask & ECORE_EVENT_VALUE_X)) + ecore_window_move(e->win, e->x, e->y); + } + } current_ev = NULL; D_RETURN; @@ -257,22 +277,22 @@ e_configure_request(Ecore_Event * ev) static void e_property(Ecore_Event * ev) { - Ecore_Event_Window_Property *e; - + Ecore_Event_Window_Property *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if (b) - { - e_icccm_handle_property_change(e->atom, b); - e_border_apply_border(b); - } - } + { + E_Border *b; + + b = e_border_find_by_window(e->win); + if (b) + { + e_icccm_handle_property_change(e->atom, b); + e_border_apply_border(b); + } + } current_ev = NULL; D_RETURN; @@ -282,13 +302,13 @@ e_property(Ecore_Event * ev) static void e_client_message(Ecore_Event * ev) { - Ecore_Event_Message *e; - + Ecore_Event_Message *e; + D_ENTER; current_ev = ev; e = ev->event; - + e_icccm_handle_client_message(e); current_ev = NULL; @@ -300,34 +320,35 @@ e_client_message(Ecore_Event * ev) static void e_unmap(Ecore_Event * ev) { - Ecore_Event_Window_Unmap *e; - + Ecore_Event_Window_Unmap *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if (b) - { - if (b->win.client == e->win) - { - if (b->ignore_unmap > 0) b->ignore_unmap--; - else - { - e_action_stop_by_object(E_OBJECT(b), NULL, - mouse_win_x, mouse_win_y, - border_mouse_x, border_mouse_y); + { + E_Border *b; - if (e_object_get_usecount(E_OBJECT(b)) == 1) - e_border_release(b); - e_object_unref(E_OBJECT(b)); - } - } - } - } + b = e_border_find_by_window(e->win); + if (b) + { + if (b->win.client == e->win) + { + if (b->ignore_unmap > 0) + b->ignore_unmap--; + else + { + e_action_stop_by_object(E_OBJECT(b), NULL, + mouse_win_x, mouse_win_y, + border_mouse_x, border_mouse_y); + + if (e_object_get_usecount(E_OBJECT(b)) == 1) + e_border_release(b); + e_object_unref(E_OBJECT(b)); + } + } + } + } current_ev = NULL; D_RETURN; @@ -337,30 +358,30 @@ e_unmap(Ecore_Event * ev) static void e_destroy(Ecore_Event * ev) { - Ecore_Event_Window_Destroy *e; - + Ecore_Event_Window_Destroy *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if (b) - { - if (b->win.client == e->win) - { - e_action_stop_by_object(E_OBJECT(b), NULL, - mouse_win_x, mouse_win_y, - border_mouse_x, border_mouse_y); + { + E_Border *b; - if (e_object_get_usecount(E_OBJECT(b)) == 1) - e_border_release(b); - e_object_unref(E_OBJECT(b)); - } - } - } + b = e_border_find_by_window(e->win); + if (b) + { + if (b->win.client == e->win) + { + e_action_stop_by_object(E_OBJECT(b), NULL, + mouse_win_x, mouse_win_y, + border_mouse_x, border_mouse_y); + + if (e_object_get_usecount(E_OBJECT(b)) == 1) + e_border_release(b); + e_object_unref(E_OBJECT(b)); + } + } + } current_ev = NULL; D_RETURN; @@ -370,22 +391,24 @@ e_destroy(Ecore_Event * ev) static void e_circulate_request(Ecore_Event * ev) { - Ecore_Event_Window_Circulate_Request *e; - + Ecore_Event_Window_Circulate_Request *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if (b) - { - if (e->lower) e_border_lower(b); - else e_border_raise(b); - } - } + { + E_Border *b; + + b = e_border_find_by_window(e->win); + if (b) + { + if (e->lower) + e_border_lower(b); + else + e_border_raise(b); + } + } current_ev = NULL; D_RETURN; @@ -395,8 +418,8 @@ e_circulate_request(Ecore_Event * ev) static void e_reparent(Ecore_Event * ev) { - Ecore_Event_Window_Reparent *e; - + Ecore_Event_Window_Reparent *e; + D_ENTER; current_ev = ev; @@ -410,23 +433,23 @@ e_reparent(Ecore_Event * ev) static void e_shape(Ecore_Event * ev) { - Ecore_Event_Window_Shape *e; - + Ecore_Event_Window_Shape *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if ((b) && (e->win == b->win.client)) - { - b->current.shaped_client = e_icccm_is_shaped(e->win); - b->changed = 1; - b->shape_changed = 1; - } - } + { + E_Border *b; + + b = e_border_find_by_window(e->win); + if ((b) && (e->win == b->win.client)) + { + b->current.shaped_client = e_icccm_is_shaped(e->win); + b->changed = 1; + b->shape_changed = 1; + } + } current_ev = NULL; D_RETURN; @@ -436,33 +459,34 @@ e_shape(Ecore_Event * ev) static void e_focus_in(Ecore_Event * ev) { - Ecore_Event_Window_Focus_In *e; - + Ecore_Event_Window_Focus_In *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if ((b) && (b->win.client == e->win)) - { - E_Grab *g; - - e_border_focus_grab_ended(); - b->current.selected = 1; - b->changed = 1; - e_observee_notify_observers(E_OBSERVEE(b), E_EVENT_BORDER_FOCUS_IN); - g = b->click_grab; - if (g) - { - ecore_button_ungrab(b->win.container, g->button, g->mods, g->any_mod); - free(g); - b->click_grab = NULL; - } - } - } + { + E_Border *b; + + b = e_border_find_by_window(e->win); + if ((b) && (b->win.client == e->win)) + { + E_Grab *g; + + e_border_focus_grab_ended(); + b->current.selected = 1; + b->changed = 1; + e_observee_notify_observers(E_OBSERVEE(b), E_EVENT_BORDER_FOCUS_IN); + g = b->click_grab; + if (g) + { + ecore_button_ungrab(b->win.container, g->button, g->mods, + g->any_mod); + free(g); + b->click_grab = NULL; + } + } + } current_ev = NULL; D_RETURN; @@ -472,44 +496,47 @@ e_focus_in(Ecore_Event * ev) static void e_focus_out(Ecore_Event * ev) { - Ecore_Event_Window_Focus_Out *e; - + Ecore_Event_Window_Focus_Out *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if ((b) && (b->win.client == e->win)) - { - int focus_mode; - E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); - - E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); - b->current.selected = 0; - if (e->key_grab) b->current.select_lost_from_grab = 1; - /* settings - click to focus would affect grabs */ - if ((!b->client.internal) && - (focus_mode == 2)) - { - E_Grab *g; - - g = NEW(E_Grab, 1); - ZERO(g, E_Grab, 1); - g->button = 1; - g->mods = ECORE_EVENT_KEY_MODIFIER_NONE; - g->any_mod = 0; - g->remove_after = 0; - ecore_button_grab(b->win.container, g->button, XEV_BUTTON_PRESS, g->mods, g->any_mod); - ecore_window_button_grab_auto_replay_set(b->win.container, e_border_replay_query); - b->click_grab = g; - } - b->changed = 1; - } - e_delayed_action_cancel(delayed_window_raise); - } + { + E_Border *b; + + b = e_border_find_by_window(e->win); + if ((b) && (b->win.client == e->win)) + { + int focus_mode; + + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); + + E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); + b->current.selected = 0; + if (e->key_grab) + b->current.select_lost_from_grab = 1; + /* settings - click to focus would affect grabs */ + if ((!b->client.internal) && (focus_mode == 2)) + { + E_Grab *g; + + g = NEW(E_Grab, 1); + ZERO(g, E_Grab, 1); + g->button = 1; + g->mods = ECORE_EVENT_KEY_MODIFIER_NONE; + g->any_mod = 0; + g->remove_after = 0; + ecore_button_grab(b->win.container, g->button, XEV_BUTTON_PRESS, + g->mods, g->any_mod); + ecore_window_button_grab_auto_replay_set(b->win.container, + e_border_replay_query); + b->click_grab = g; + } + b->changed = 1; + } + e_delayed_action_cancel(delayed_window_raise); + } current_ev = NULL; D_RETURN; @@ -519,20 +546,20 @@ e_focus_out(Ecore_Event * ev) static void e_colormap(Ecore_Event * ev) { - Ecore_Event_Colormap *e; - + Ecore_Event_Colormap *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; + { + E_Border *b; - b = e_border_find_by_window(e->win); - if (b) - { - } - } + b = e_border_find_by_window(e->win); + if (b) + { + } + } current_ev = NULL; D_RETURN; @@ -542,65 +569,67 @@ e_colormap(Ecore_Event * ev) static void e_mouse_down(Ecore_Event * ev) { - Ecore_Event_Mouse_Down *e; - + Ecore_Event_Mouse_Down *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - mouse_win_x = e->x; - mouse_win_y = e->y; - mouse_x = e->rx; - mouse_y = e->ry; - mouse_buttons |= (1 << e->button); - b = e_border_find_by_window(e->win); - if (b) - { - int focus_mode; - E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); - - E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); - if (focus_mode == 2) - { - e_focus_set_focus(b); - /* FIXME: if (raise on click to focus) ... */ - e_border_raise(b); - } - if (e->win == b->win.main) e_cb_border_mouse_down(b, ev); - else - { - Evas evas; - int x, y; - - evas = b->evas.l; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_button_down(evas, x, y, e->button); - evas = b->evas.r; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_button_down(evas, x, y, e->button); - evas = b->evas.t; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_button_down(evas, x, y, e->button); - evas = b->evas.b; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_button_down(evas, x, y, e->button); - } - } - } + { + E_Border *b; + + mouse_win_x = e->x; + mouse_win_y = e->y; + mouse_x = e->rx; + mouse_y = e->ry; + mouse_buttons |= (1 << e->button); + b = e_border_find_by_window(e->win); + if (b) + { + int focus_mode; + + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); + + E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); + if (focus_mode == 2) + { + e_focus_set_focus(b); + /* FIXME: if (raise on click to focus) ... */ + e_border_raise(b); + } + if (e->win == b->win.main) + e_cb_border_mouse_down(b, ev); + else + { + Evas evas; + int x, y; + + evas = b->evas.l; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_button_down(evas, x, y, e->button); + evas = b->evas.r; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_button_down(evas, x, y, e->button); + evas = b->evas.t; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_button_down(evas, x, y, e->button); + evas = b->evas.b; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_button_down(evas, x, y, e->button); + } + } + } current_ev = NULL; D_RETURN; @@ -610,56 +639,57 @@ e_mouse_down(Ecore_Event * ev) static void e_mouse_up(Ecore_Event * ev) { - Ecore_Event_Mouse_Up *e; - + Ecore_Event_Mouse_Up *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - mouse_win_x = e->x; - mouse_win_y = e->y; - mouse_x = e->rx; - mouse_y = e->ry; - mouse_buttons &= ~(1 << e->button); - b = e_border_find_by_window(e->win); - if (b) - { - if (e->win == b->win.main) e_cb_border_mouse_up(b, ev); - else - { - Evas evas; - int x, y; - - evas = b->evas.l; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_button_up(evas, x, y, e->button); - evas = b->evas.r; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_button_up(evas, x, y, e->button); - evas = b->evas.t; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_button_up(evas, x, y, e->button); - evas = b->evas.b; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_button_up(evas, x, y, e->button); - } - } - } + { + E_Border *b; + + mouse_win_x = e->x; + mouse_win_y = e->y; + mouse_x = e->rx; + mouse_y = e->ry; + mouse_buttons &= ~(1 << e->button); + b = e_border_find_by_window(e->win); + if (b) + { + if (e->win == b->win.main) + e_cb_border_mouse_up(b, ev); + else + { + Evas evas; + int x, y; + + evas = b->evas.l; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_button_up(evas, x, y, e->button); + evas = b->evas.r; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_button_up(evas, x, y, e->button); + evas = b->evas.t; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_button_up(evas, x, y, e->button); + evas = b->evas.b; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_button_up(evas, x, y, e->button); + } + } + } current_ev = NULL; D_RETURN; @@ -669,56 +699,57 @@ e_mouse_up(Ecore_Event * ev) static void e_mouse_move(Ecore_Event * ev) { - Ecore_Event_Mouse_Move *e; + Ecore_Event_Mouse_Move *e; D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - mouse_win_x = e->x; - mouse_win_y = e->y; - mouse_x = e->rx; - mouse_y = e->ry; - b = e_border_find_by_window(e->win); + { + E_Border *b; + + mouse_win_x = e->x; + mouse_win_y = e->y; + mouse_x = e->rx; + mouse_y = e->ry; + b = e_border_find_by_window(e->win); /* D("motion... %3.8f\n", ecore_get_time());*/ - if (b) - { - if (e->win == b->win.main) e_cb_border_mouse_move(b, ev); - else - { - Evas evas; - int x, y; - - evas = b->evas.l; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_move(evas, x, y); - evas = b->evas.r; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_move(evas, x, y); - evas = b->evas.t; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_move(evas, x, y); - evas = b->evas.b; - ecore_window_get_root_relative_location(evas_get_window(evas), - &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_move(evas, x, y); - } - } - } + if (b) + { + if (e->win == b->win.main) + e_cb_border_mouse_move(b, ev); + else + { + Evas evas; + int x, y; + + evas = b->evas.l; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_move(evas, x, y); + evas = b->evas.r; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_move(evas, x, y); + evas = b->evas.t; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_move(evas, x, y); + evas = b->evas.b; + ecore_window_get_root_relative_location(evas_get_window(evas), + &x, &y); + x = e->rx - x; + y = e->ry - y; + evas_event_move(evas, x, y); + } + } + } current_ev = NULL; D_RETURN; @@ -728,50 +759,54 @@ e_mouse_move(Ecore_Event * ev) static void e_mouse_in(Ecore_Event * ev) { - Ecore_Event_Window_Enter *e; - E_Border *b; + Ecore_Event_Window_Enter *e; + E_Border *b; D_ENTER; current_ev = ev; e = ev->event; - if ( (b = e_border_find_by_window(e->win)) ) - { - if (e->win == b->win.main) - e_cb_border_mouse_in(b, ev); - else if (e->win == b->win.input) - { - int x, y; - Evas evas; + if ((b = e_border_find_by_window(e->win))) + { + if (e->win == b->win.main) + e_cb_border_mouse_in(b, ev); + else if (e->win == b->win.input) + { + int x, y; + Evas evas; - evas = b->evas.l; - ecore_window_get_root_relative_location(evas_get_window(evas), &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_move(evas, x, y); - evas_event_enter(evas); + evas = b->evas.l; + ecore_window_get_root_relative_location(evas_get_window(evas), &x, + &y); + x = e->rx - x; + y = e->ry - y; + evas_event_move(evas, x, y); + evas_event_enter(evas); - evas = b->evas.r; - ecore_window_get_root_relative_location(evas_get_window(evas), &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_move(evas, x, y); - evas_event_enter(evas); + evas = b->evas.r; + ecore_window_get_root_relative_location(evas_get_window(evas), &x, + &y); + x = e->rx - x; + y = e->ry - y; + evas_event_move(evas, x, y); + evas_event_enter(evas); - evas = b->evas.t; - ecore_window_get_root_relative_location(evas_get_window(evas), &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_move(evas, x, y); - evas_event_enter(evas); + evas = b->evas.t; + ecore_window_get_root_relative_location(evas_get_window(evas), &x, + &y); + x = e->rx - x; + y = e->ry - y; + evas_event_move(evas, x, y); + evas_event_enter(evas); - evas = b->evas.b; - ecore_window_get_root_relative_location(evas_get_window(evas), &x, &y); - x = e->rx - x; - y = e->ry - y; - evas_event_move(evas, x, y); - evas_event_enter(evas); - } - } + evas = b->evas.b; + ecore_window_get_root_relative_location(evas_get_window(evas), &x, + &y); + x = e->rx - x; + y = e->ry - y; + evas_event_move(evas, x, y); + evas_event_enter(evas); + } + } current_ev = NULL; D_RETURN; } @@ -780,28 +815,29 @@ e_mouse_in(Ecore_Event * ev) static void e_mouse_out(Ecore_Event * ev) { - Ecore_Event_Window_Leave *e; - + Ecore_Event_Window_Leave *e; + D_ENTER; current_ev = ev; e = ev->event; - { - E_Border *b; - - b = e_border_find_by_window(e->win); - if (b) - { - if (e->win == b->win.main) e_cb_border_mouse_out(b, ev); - if (e->win == b->win.input) - { - evas_event_leave(b->evas.l); - evas_event_leave(b->evas.r); - evas_event_leave(b->evas.t); - evas_event_leave(b->evas.b); - } - } - } + { + E_Border *b; + + b = e_border_find_by_window(e->win); + if (b) + { + if (e->win == b->win.main) + e_cb_border_mouse_out(b, ev); + if (e->win == b->win.input) + { + evas_event_leave(b->evas.l); + evas_event_leave(b->evas.r); + evas_event_leave(b->evas.t); + evas_event_leave(b->evas.b); + } + } + } current_ev = NULL; D_RETURN; @@ -811,26 +847,28 @@ e_mouse_out(Ecore_Event * ev) static void e_window_expose(Ecore_Event * ev) { - Ecore_Event_Window_Expose *e; - + Ecore_Event_Window_Expose *e; + D_ENTER; current_ev = ev; e = ev->event; - { - Evas_List l; - E_Border *b; - for (l = evases; l; l = l->next) - { - Evas evas; + { + Evas_List l; + E_Border *b; - evas = l->data; - if (evas_get_window(evas) == e->win) - evas_update_rect(evas, e->x, e->y, e->w, e->h); - } - b = e_border_find_by_window(e->win); - if (b) b->first_expose = 1; - } + for (l = evases; l; l = l->next) + { + Evas evas; + + evas = l->data; + if (evas_get_window(evas) == e->win) + evas_update_rect(evas, e->x, e->y, e->w, e->h); + } + b = e_border_find_by_window(e->win); + if (b) + b->first_expose = 1; + } current_ev = NULL; D_RETURN; @@ -842,17 +880,21 @@ static void e_cb_mouse_in(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) { - E_Border *b; - + E_Border *b; + D_ENTER; b = data; - if (border_mouse_buttons) D_RETURN; + if (border_mouse_buttons) + D_RETURN; border_mouse_x = mouse_x; border_mouse_y = mouse_y; - if (class) e_cursors_display_in_window(b->win.main, class); - else e_cursors_display_in_window(b->win.main, "Default"); - if (!current_ev) D_RETURN; + if (class) + e_cursors_display_in_window(b->win.main, class); + else + e_cursors_display_in_window(b->win.main, "Default"); + if (!current_ev) + D_RETURN; e_action_stop(class, ACT_MOUSE_IN, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE, E_OBJECT(b), NULL, x, y, border_mouse_x, border_mouse_y); @@ -872,15 +914,17 @@ static void e_cb_mouse_out(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) { - E_Border *b; - + E_Border *b; + D_ENTER; b = data; - if (border_mouse_buttons) D_RETURN; + if (border_mouse_buttons) + D_RETURN; border_mouse_x = mouse_x; border_mouse_y = mouse_y; - if (!current_ev) D_RETURN; + if (!current_ev) + D_RETURN; e_cursors_display_in_window(b->win.main, "Default"); e_action_stop(class, ACT_MOUSE_OUT, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE, E_OBJECT(b), NULL, x, y, border_mouse_x, border_mouse_y); @@ -899,32 +943,33 @@ static void e_cb_mouse_down(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) { - E_Border *b; - + E_Border *b; + D_ENTER; b = data; border_mouse_x = mouse_x; border_mouse_y = mouse_y; border_mouse_buttons = mouse_buttons; - if (!current_ev) D_RETURN; - { - E_Action_Type act; - Ecore_Event_Key_Modifiers mods; - - mods = ((Ecore_Event_Mouse_Down *)(current_ev->event))->mods; - act = ACT_MOUSE_CLICK; + if (!current_ev) + D_RETURN; + { + E_Action_Type act; + Ecore_Event_Key_Modifiers mods; - if (((Ecore_Event_Mouse_Down *)(current_ev->event))->double_click) - act = ACT_MOUSE_DOUBLE; - else if (((Ecore_Event_Mouse_Down *)(current_ev->event))->triple_click) - act = ACT_MOUSE_TRIPLE; + mods = ((Ecore_Event_Mouse_Down *) (current_ev->event))->mods; + act = ACT_MOUSE_CLICK; - e_action_stop(class, act, bt, NULL, mods, E_OBJECT(b), - NULL, x, y, border_mouse_x, border_mouse_y); - e_action_start(class, act, bt, NULL, mods, E_OBJECT(b), - NULL, x, y, border_mouse_x, border_mouse_y); - } + if (((Ecore_Event_Mouse_Down *) (current_ev->event))->double_click) + act = ACT_MOUSE_DOUBLE; + else if (((Ecore_Event_Mouse_Down *) (current_ev->event))->triple_click) + act = ACT_MOUSE_TRIPLE; + + e_action_stop(class, act, bt, NULL, mods, E_OBJECT(b), + NULL, x, y, border_mouse_x, border_mouse_y); + e_action_start(class, act, bt, NULL, mods, E_OBJECT(b), + NULL, x, y, border_mouse_x, border_mouse_y); + } D_RETURN; UN(o); UN(ox); @@ -937,30 +982,31 @@ static void e_cb_mouse_up(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) { - E_Border *b; - + E_Border *b; + D_ENTER; b = data; border_mouse_x = mouse_x; border_mouse_y = mouse_y; border_mouse_buttons = mouse_buttons; - if (!current_ev) D_RETURN; - { - E_Action_Type act; - Ecore_Event_Key_Modifiers mods; - - mods = ((Ecore_Event_Mouse_Up *)(current_ev->event))->mods; - act = ACT_MOUSE_UP; + if (!current_ev) + D_RETURN; + { + E_Action_Type act; + Ecore_Event_Key_Modifiers mods; - if ((x >= ox) && (x < (ox + ow)) && (y >= oy) && (y < (oy + oh))) - act = ACT_MOUSE_CLICKED; + mods = ((Ecore_Event_Mouse_Up *) (current_ev->event))->mods; + act = ACT_MOUSE_UP; - e_action_stop(class, act, bt, NULL, mods, E_OBJECT(b), - NULL, x, y, border_mouse_x, border_mouse_y); - e_action_start(class, act, bt, NULL, mods, E_OBJECT(b), - NULL, x, y, border_mouse_x, border_mouse_y); - } + if ((x >= ox) && (x < (ox + ow)) && (y >= oy) && (y < (oy + oh))) + act = ACT_MOUSE_CLICKED; + + e_action_stop(class, act, bt, NULL, mods, E_OBJECT(b), + NULL, x, y, border_mouse_x, border_mouse_y); + e_action_start(class, act, bt, NULL, mods, E_OBJECT(b), + NULL, x, y, border_mouse_x, border_mouse_y); + } D_RETURN; UN(o); } @@ -969,9 +1015,9 @@ static void e_cb_mouse_move(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) { - E_Border *b; - int dx, dy; - + E_Border *b; + int dx, dy; + D_ENTER; b = data; @@ -981,10 +1027,11 @@ e_cb_mouse_move(void *data, Ebits_Object o, char *class, border_mouse_y = mouse_y; if (!current_ev) - D_RETURN; + D_RETURN; e_action_cont(class, ACT_MOUSE_MOVE, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE, - E_OBJECT(b), NULL, x, y, border_mouse_x, border_mouse_y, dx, dy); + E_OBJECT(b), NULL, x, y, border_mouse_x, border_mouse_y, dx, + dy); D_RETURN; UN(o); @@ -997,25 +1044,27 @@ e_cb_mouse_move(void *data, Ebits_Object o, char *class, /* callbacks for certain things */ static void -e_cb_border_mouse_in(E_Border *b, Ecore_Event *e) +e_cb_border_mouse_in(E_Border * b, Ecore_Event * e) { - int x, y; - char *class = "Window_Grab"; - int focus_mode; + int x, y; + char *class = "Window_Grab"; + int focus_mode; + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); - + D_ENTER; - E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); + E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); /* pointer focus stuff */ if (focus_mode == 0) - e_focus_set_focus(b); + e_focus_set_focus(b); border_mouse_x = mouse_x; border_mouse_y = mouse_y; - if (!current_ev) D_RETURN; + if (!current_ev) + D_RETURN; - x = ((Ecore_Event_Window_Enter *)(e->event))->x; - y = ((Ecore_Event_Window_Enter *)(e->event))->y; + x = ((Ecore_Event_Window_Enter *) (e->event))->x; + y = ((Ecore_Event_Window_Enter *) (e->event))->y; e_action_stop(class, ACT_MOUSE_IN, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE, E_OBJECT(b), NULL, x, y, border_mouse_x, border_mouse_y); @@ -1026,18 +1075,19 @@ e_cb_border_mouse_in(E_Border *b, Ecore_Event *e) } static void -e_cb_border_mouse_out(E_Border *b, Ecore_Event *e) +e_cb_border_mouse_out(E_Border * b, Ecore_Event * e) { - int x, y; - char *class = "Window_Grab"; - + int x, y; + char *class = "Window_Grab"; + D_ENTER; - + x = mouse_x; y = mouse_y; border_mouse_x = mouse_x; - border_mouse_y = mouse_y; - if (!current_ev) D_RETURN; + border_mouse_y = mouse_y; + if (!current_ev) + D_RETURN; e_action_stop(class, ACT_MOUSE_OUT, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE, E_OBJECT(b), NULL, x, y, border_mouse_x, border_mouse_y); @@ -1048,135 +1098,145 @@ e_cb_border_mouse_out(E_Border *b, Ecore_Event *e) } static void -e_cb_border_mouse_down(E_Border *b, Ecore_Event *e) +e_cb_border_mouse_down(E_Border * b, Ecore_Event * e) { - int x, y, bt; - char *class = "Window_Grab"; - int focus_mode; + int x, y, bt; + char *class = "Window_Grab"; + int focus_mode; + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); - + D_ENTER; E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); - ecore_pointer_grab(((Ecore_Event_Mouse_Down *)(e->event))->win, CurrentTime); + ecore_pointer_grab(((Ecore_Event_Mouse_Down *) (e->event))->win, + CurrentTime); border_mouse_x = mouse_x; border_mouse_y = mouse_y; - if (!current_ev) D_RETURN; - - x = ((Ecore_Event_Mouse_Down *)(e->event))->x; - y = ((Ecore_Event_Mouse_Down *)(e->event))->y; - bt = ((Ecore_Event_Mouse_Down *)(e->event))->button; - { - Evas_List l; - - again: - for (l = b->grabs; l; l = l->next) - { - E_Grab *g; - - g = l->data; - /* find a grab that triggered this */ - if (((((Ecore_Event_Mouse_Down *)(e->event))->button == g->button) || - (g->button == 0)) && - ((g->any_mod) || - (((Ecore_Event_Mouse_Down *)(e->event))->mods == g->mods))) - { - if (g->remove_after) - { - ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); - ecore_window_button_grab_auto_replay_set(b->win.main, NULL); - free(g); - b->grabs = evas_list_remove(b->grabs, g); - goto again; - } - } - } - } - { - E_Action_Type act; - Ecore_Event_Key_Modifiers mods; - - mods = ((Ecore_Event_Mouse_Down *)(current_ev->event))->mods; - act = ACT_MOUSE_CLICK; + if (!current_ev) + D_RETURN; - if (((Ecore_Event_Mouse_Down *)(current_ev->event))->double_click) - act = ACT_MOUSE_DOUBLE; - else if (((Ecore_Event_Mouse_Down *)(current_ev->event))->triple_click) - act = ACT_MOUSE_TRIPLE; + x = ((Ecore_Event_Mouse_Down *) (e->event))->x; + y = ((Ecore_Event_Mouse_Down *) (e->event))->y; + bt = ((Ecore_Event_Mouse_Down *) (e->event))->button; + { + Evas_List l; - e_action_stop(class, act, bt, NULL, mods, E_OBJECT(b), NULL, - x, y, border_mouse_x, border_mouse_y); - if (!e_action_start(class, act, bt, NULL, mods, E_OBJECT(b), NULL, - x, y, border_mouse_x, border_mouse_y)) - { - ecore_pointer_ungrab(((Ecore_Event_Mouse_Down *)(e->event))->time); - } - else - { - ecore_pointer_grab(((Ecore_Event_Mouse_Down *)(e->event))->win, - ((Ecore_Event_Mouse_Down *)(e->event))->time); - } - } + again: + for (l = b->grabs; l; l = l->next) + { + E_Grab *g; + + g = l->data; + /* find a grab that triggered this */ + if (((((Ecore_Event_Mouse_Down *) (e->event))->button == g->button) + || (g->button == 0)) && ((g->any_mod) + || + (((Ecore_Event_Mouse_Down *) (e-> + event))-> + mods == g->mods))) + { + if (g->remove_after) + { + ecore_button_ungrab(b->win.main, g->button, g->mods, + g->any_mod); + ecore_window_button_grab_auto_replay_set(b->win.main, + NULL); + free(g); + b->grabs = evas_list_remove(b->grabs, g); + goto again; + } + } + } + } + { + E_Action_Type act; + Ecore_Event_Key_Modifiers mods; + + mods = ((Ecore_Event_Mouse_Down *) (current_ev->event))->mods; + act = ACT_MOUSE_CLICK; + + if (((Ecore_Event_Mouse_Down *) (current_ev->event))->double_click) + act = ACT_MOUSE_DOUBLE; + else if (((Ecore_Event_Mouse_Down *) (current_ev->event))->triple_click) + act = ACT_MOUSE_TRIPLE; + + e_action_stop(class, act, bt, NULL, mods, E_OBJECT(b), NULL, + x, y, border_mouse_x, border_mouse_y); + if (!e_action_start(class, act, bt, NULL, mods, E_OBJECT(b), NULL, + x, y, border_mouse_x, border_mouse_y)) + { + ecore_pointer_ungrab(((Ecore_Event_Mouse_Down *) (e->event))->time); + } + else + { + ecore_pointer_grab(((Ecore_Event_Mouse_Down *) (e->event))->win, + ((Ecore_Event_Mouse_Down *) (e->event))->time); + } + } D_RETURN; } static void -e_cb_border_mouse_up(E_Border *b, Ecore_Event *e) +e_cb_border_mouse_up(E_Border * b, Ecore_Event * e) { - int x, y, bt; - char *class = "Window_Grab"; - + int x, y, bt; + char *class = "Window_Grab"; + D_ENTER; border_mouse_x = mouse_x; border_mouse_y = mouse_y; - - if (!current_ev) D_RETURN; - ecore_pointer_ungrab(((Ecore_Event_Mouse_Up *)(e->event))->time); - - x = ((Ecore_Event_Mouse_Up *)(e->event))->x; - y = ((Ecore_Event_Mouse_Up *)(e->event))->y; - bt = ((Ecore_Event_Mouse_Up *)(e->event))->button; - { - E_Action_Type act; - Ecore_Event_Key_Modifiers mods; - - mods = ((Ecore_Event_Mouse_Up *)(current_ev->event))->mods; - act = ACT_MOUSE_UP; - e_action_stop(class, act, bt, NULL, mods, E_OBJECT(b), - NULL, x, y, border_mouse_x, border_mouse_y); - e_action_start(class, act, bt, NULL, mods, E_OBJECT(b), - NULL, x, y, border_mouse_x, border_mouse_y); - } + + if (!current_ev) + D_RETURN; + ecore_pointer_ungrab(((Ecore_Event_Mouse_Up *) (e->event))->time); + + x = ((Ecore_Event_Mouse_Up *) (e->event))->x; + y = ((Ecore_Event_Mouse_Up *) (e->event))->y; + bt = ((Ecore_Event_Mouse_Up *) (e->event))->button; + { + E_Action_Type act; + Ecore_Event_Key_Modifiers mods; + + mods = ((Ecore_Event_Mouse_Up *) (current_ev->event))->mods; + act = ACT_MOUSE_UP; + e_action_stop(class, act, bt, NULL, mods, E_OBJECT(b), + NULL, x, y, border_mouse_x, border_mouse_y); + e_action_start(class, act, bt, NULL, mods, E_OBJECT(b), + NULL, x, y, border_mouse_x, border_mouse_y); + } D_RETURN; } static void -e_cb_border_mouse_move(E_Border *b, Ecore_Event *e) +e_cb_border_mouse_move(E_Border * b, Ecore_Event * e) { - int dx, dy; - int x, y; - char *class = "Window_Grab"; - + int dx, dy; + int x, y; + char *class = "Window_Grab"; + D_ENTER; dx = mouse_x - border_mouse_x; dy = mouse_y - border_mouse_y; border_mouse_x = mouse_x; border_mouse_y = mouse_y; - if (!current_ev) D_RETURN; - x = ((Ecore_Event_Mouse_Move *)(e->event))->x; - y = ((Ecore_Event_Mouse_Move *)(e->event))->y; + if (!current_ev) + D_RETURN; + x = ((Ecore_Event_Mouse_Move *) (e->event))->x; + y = ((Ecore_Event_Mouse_Move *) (e->event))->y; e_action_cont(class, ACT_MOUSE_MOVE, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE, - E_OBJECT(b), NULL, x, y, border_mouse_x, border_mouse_y, dx, dy); + E_OBJECT(b), NULL, x, y, border_mouse_x, border_mouse_y, dx, + dy); D_RETURN; } static void -e_cb_border_move_resize(E_Border *b) +e_cb_border_move_resize(E_Border * b) { D_ENTER; @@ -1185,7 +1245,7 @@ e_cb_border_move_resize(E_Border *b) } static void -e_cb_border_visibility(E_Border *b) +e_cb_border_visibility(E_Border * b) { D_ENTER; @@ -1204,36 +1264,44 @@ e_border_poll(int val, void *data) } static void -e_border_cleanup(E_Border *b) +e_border_cleanup(E_Border * b) { - Evas_List l; + Evas_List l; D_ENTER; e_match_save_props(b); - D("before notify\n"); + D("before notify\n"); e_observee_notify_observers(E_OBSERVEE(b), E_EVENT_BORDER_DELETE); D("after notify\n"); while (b->menus) { - E_Menu *m; - + E_Menu *m; + m = b->menus->data; e_menu_hide(m); e_object_unref(E_OBJECT(m)); b->menus = evas_list_remove(b->menus, m); } e_desktops_del_border(b->desk, b); - if (b->bits.l) ebits_free(b->bits.l); - if (b->bits.r) ebits_free(b->bits.r); - if (b->bits.t) ebits_free(b->bits.t); - if (b->bits.b) ebits_free(b->bits.b); - - if (b->obj.title.l) e_text_free(b->obj.title.l); - if (b->obj.title.r) e_text_free(b->obj.title.r); - if (b->obj.title.t) e_text_free(b->obj.title.t); - if (b->obj.title.b) e_text_free(b->obj.title.b); - + if (b->bits.l) + ebits_free(b->bits.l); + if (b->bits.r) + ebits_free(b->bits.r); + if (b->bits.t) + ebits_free(b->bits.t); + if (b->bits.b) + ebits_free(b->bits.b); + + if (b->obj.title.l) + e_text_free(b->obj.title.l); + if (b->obj.title.r) + e_text_free(b->obj.title.r); + if (b->obj.title.t) + e_text_free(b->obj.title.t); + if (b->obj.title.b) + e_text_free(b->obj.title.b); + evases = evas_list_remove(evases, b->evas.l); evases = evas_list_remove(evases, b->evas.r); evases = evas_list_remove(evases, b->evas.t); @@ -1246,7 +1314,7 @@ e_border_cleanup(E_Border *b) ecore_window_destroy(b->win.input); ecore_window_destroy(b->win.main); borders = evas_list_remove(borders, b); - + IF_FREE(b->client.title); IF_FREE(b->client.name); IF_FREE(b->client.class); @@ -1264,72 +1332,78 @@ e_border_cleanup(E_Border *b) } evas_list_free(b->grabs); } - + /* Cleanup superclass. */ e_object_cleanup(E_OBJECT(b)); D_RETURN; } - /* border creation, deletion, modification and general queries */ void -e_border_apply_border(E_Border *b) +e_border_apply_border(E_Border * b) { - int pl, pr, pt, pb; - char *borders, buf[PATH_MAX], border[PATH_MAX], *style = NULL; - int prop_selected = 0, prop_sticky = 0, prop_shaded = 0; - + int pl, pr, pt, pb; + char *borders, buf[PATH_MAX], border[PATH_MAX], *style = NULL; + int prop_selected = 0, prop_sticky = 0, prop_shaded = 0; + D_ENTER; - style = "default"; - if ((!b->client.titlebar) && (!b->client.border)) style = "borderless"; - if (b->border_style) style = b->border_style; - - if (b->current.selected) prop_selected = 1; - if ((b->current.shaded > 0) && - (b->current.shaded == b->client.h)) prop_shaded = 1; - if (b->client.sticky) prop_sticky = 1; - - snprintf(border, PATH_MAX, "selected-%i.sticky-%i.shaded-%i.bits.db", - prop_selected, prop_sticky, prop_shaded); + style = "default"; + if ((!b->client.titlebar) && (!b->client.border)) + style = "borderless"; + if (b->border_style) + style = b->border_style; + + if (b->current.selected) + prop_selected = 1; + if ((b->current.shaded > 0) && (b->current.shaded == b->client.h)) + prop_shaded = 1; + if (b->client.sticky) + prop_sticky = 1; + + snprintf(border, PATH_MAX, "selected-%i.sticky-%i.shaded-%i.bits.db", + prop_selected, prop_sticky, prop_shaded); borders = e_config_get("borders"); snprintf(buf, PATH_MAX, "%s%s/%s", borders, style, border); - + /* if it's not changed - abort and dont do anything */ - if ((b->border_file) && (!strcmp(buf, b->border_file))) D_RETURN; - + if ((b->border_file) && (!strcmp(buf, b->border_file))) + D_RETURN; + IF_FREE(b->border_file); e_strdup(b->border_file, buf); - + e_border_set_bits(b, buf); - + pl = pr = pt = pb = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); e_icccm_set_frame_size(b->win.client, pl, pr, pt, pb); D_RETURN; } void -e_border_reshape(E_Border *b) +e_border_reshape(E_Border * b) { - static Window shape_win = 0; - int pl, pr, pt, pb; - + static Window shape_win = 0; + int pl, pr, pt, pb; + D_ENTER; if ((b->current.shaped_client == b->previous.shaped_client) && (b->current.shape_changes == b->previous.shape_changes) && - (b->current.has_shape == b->previous.has_shape) && - (!b->shape_changed)) - D_RETURN; + (b->current.has_shape == b->previous.has_shape) && (!b->shape_changed)) + D_RETURN; - if (!shape_win) shape_win = ecore_window_override_new(0, 0, 0, 1, 1); + if (!shape_win) + shape_win = ecore_window_override_new(0, 0, 0, 1, 1); pl = pr = pt = pb = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); b->shape_changed = 0; if ((!b->current.shaped_client) && (!b->current.has_shape)) @@ -1340,21 +1414,31 @@ e_border_reshape(E_Border *b) if ((b->current.shaped_client) && (!b->current.has_shape)) { - XRectangle rects[4]; - - rects[0].x = 0; rects[0].y = 0; - rects[0].width = b->current.w; rects[0].height = pt; - rects[1].x = 0; rects[1].y = pt; - rects[1].width = pl; rects[1].height = b->current.h - pt - pb; - rects[2].x = b->current.w - pr; rects[2].y = pt; - rects[2].width = pr; rects[2].height = b->current.h - pt - pb; - rects[3].x = 0; rects[3].y = b->current.h - pb; - rects[3].width = b->current.w; rects[3].height = pb; - - ecore_window_resize(shape_win, b->current.w, b->current.h); - ecore_window_set_shape_window(shape_win, b->win.client, pl, pt - b->current.shaded); + XRectangle rects[4]; + + rects[0].x = 0; + rects[0].y = 0; + rects[0].width = b->current.w; + rects[0].height = pt; + rects[1].x = 0; + rects[1].y = pt; + rects[1].width = pl; + rects[1].height = b->current.h - pt - pb; + rects[2].x = b->current.w - pr; + rects[2].y = pt; + rects[2].width = pr; + rects[2].height = b->current.h - pt - pb; + rects[3].x = 0; + rects[3].y = b->current.h - pb; + rects[3].width = b->current.w; + rects[3].height = pb; + + ecore_window_resize(shape_win, b->current.w, b->current.h); + ecore_window_set_shape_window(shape_win, b->win.client, pl, + pt - b->current.shaded); ecore_window_clip_shape_by_rectangle(shape_win, pl, pt, - b->current.w - pl - pr, b->current.h - pt - pb); + b->current.w - pl - pr, + b->current.h - pt - pb); ecore_window_add_shape_rectangles(shape_win, rects, 4); ecore_window_set_shape_window(b->win.main, shape_win, 0, 0); @@ -1363,48 +1447,67 @@ e_border_reshape(E_Border *b) if ((!b->current.shaped_client) && (b->current.has_shape)) { - ecore_window_resize(shape_win, b->current.w, b->current.h); + ecore_window_resize(shape_win, b->current.w, b->current.h); ecore_window_set_shape_rectangle(shape_win, pl, pt - b->current.shaded, - b->current.w - pl - pr, b->current.h - pt - pb); + b->current.w - pl - pr, + b->current.h - pt - pb); /* FIXME: later when i actually generate shape masks for borders */ - { - XRectangle rects[4]; - - rects[0].x = 0; rects[0].y = 0; - rects[0].width = b->current.w; rects[0].height = pt; - rects[1].x = 0; rects[1].y = pt; - rects[1].width = pl; rects[1].height = b->current.h - pt - pb; - rects[2].x = b->current.w - pr; rects[2].y = pt; - rects[2].width = pr; rects[2].height = b->current.h - pt - pb; - rects[3].x = 0; rects[3].y = b->current.h - pb; - rects[3].width = b->current.w; rects[3].height = pb; - ecore_window_add_shape_rectangles(shape_win, rects, 4); - } + { + XRectangle rects[4]; + + rects[0].x = 0; + rects[0].y = 0; + rects[0].width = b->current.w; + rects[0].height = pt; + rects[1].x = 0; + rects[1].y = pt; + rects[1].width = pl; + rects[1].height = b->current.h - pt - pb; + rects[2].x = b->current.w - pr; + rects[2].y = pt; + rects[2].width = pr; + rects[2].height = b->current.h - pt - pb; + rects[3].x = 0; + rects[3].y = b->current.h - pb; + rects[3].width = b->current.w; + rects[3].height = pb; + ecore_window_add_shape_rectangles(shape_win, rects, 4); + } ecore_window_set_shape_window(b->win.main, shape_win, 0, 0); D_RETURN; } if ((b->current.shaped_client) && (b->current.has_shape)) { - ecore_window_resize(shape_win, b->current.w, b->current.h); - ecore_window_set_shape_window(shape_win, b->win.client, pl, pt - b->current.shaded); + ecore_window_resize(shape_win, b->current.w, b->current.h); + ecore_window_set_shape_window(shape_win, b->win.client, pl, + pt - b->current.shaded); ecore_window_clip_shape_by_rectangle(shape_win, pl, pt, - b->current.w - pl - pr, b->current.h - pt - pb); + b->current.w - pl - pr, + b->current.h - pt - pb); /* FIXME: later when i actually generate shape masks for borders */ - { - XRectangle rects[4]; - - rects[0].x = 0; rects[0].y = 0; - rects[0].width = b->current.w; rects[0].height = pt; - rects[1].x = 0; rects[1].y = pt; - rects[1].width = pl; rects[1].height = b->current.h - pt - pb; - rects[2].x = b->current.w - pr; rects[2].y = pt; - rects[2].width = pr; rects[2].height = b->current.h - pt - pb; - rects[3].x = 0; rects[3].y = b->current.h - pb; - rects[3].width = b->current.w; rects[3].height = pb; - ecore_window_add_shape_rectangles(shape_win, rects, 4); - } + { + XRectangle rects[4]; + + rects[0].x = 0; + rects[0].y = 0; + rects[0].width = b->current.w; + rects[0].height = pt; + rects[1].x = 0; + rects[1].y = pt; + rects[1].width = pl; + rects[1].height = b->current.h - pt - pb; + rects[2].x = b->current.w - pr; + rects[2].y = pt; + rects[2].width = pr; + rects[2].height = b->current.h - pt - pb; + rects[3].x = 0; + rects[3].y = b->current.h - pb; + rects[3].width = b->current.w; + rects[3].height = pb; + ecore_window_add_shape_rectangles(shape_win, rects, 4); + } ecore_window_set_shape_window(b->win.main, shape_win, 0, 0); D_RETURN; @@ -1414,43 +1517,43 @@ e_border_reshape(E_Border *b) } void -e_border_release(E_Border *b) +e_border_release(E_Border * b) { - int pl, pr, pt, pb; - + int pl, pr, pt, pb; + D_ENTER; pl = pr = pt = pb = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); - ecore_window_reparent(b->win.client, 0, b->current.x + pl, b->current.y + pt); - e_icccm_release(b->win.client); + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + ecore_window_reparent(b->win.client, 0, b->current.x + pl, + b->current.y + pt); + e_icccm_release(b->win.client); D_RETURN; } - -E_Border * +E_Border * e_border_adopt(Window win, int use_client_pos) { - E_Border *b; - int bw; - int show = 1; - + E_Border *b; + int bw; + int show = 1; + D_ENTER; /* create the struct */ b = e_border_new(); /* set the right event on the client */ - ecore_window_set_events(win, - XEV_VISIBILITY | - ResizeRedirectMask | - XEV_CONFIGURE | - XEV_FOCUS | - XEV_PROPERTY | - XEV_COLORMAP); + ecore_window_set_events(win, + XEV_VISIBILITY | + ResizeRedirectMask | + XEV_CONFIGURE | + XEV_FOCUS | XEV_PROPERTY | XEV_COLORMAP); ecore_window_select_shape_events(win); /* parent of the client window listens for these */ - ecore_window_set_events(b->win.container, XEV_CHILD_CHANGE | XEV_CHILD_REDIRECT); + ecore_window_set_events(b->win.container, + XEV_CHILD_CHANGE | XEV_CHILD_REDIRECT); /* add to save set & border of 0 */ e_icccm_adopt(win); bw = ecore_window_get_border_width(win); @@ -1460,16 +1563,16 @@ e_border_adopt(Window win, int use_client_pos) /* get hints */ e_icccm_get_size_info(win, b); e_icccm_get_pos_info(win, b); - { - int x, y, w, h; - - ecore_window_get_geometry(win, &x, &y, &w, &h); - b->current.requested.x = x; - b->current.requested.y = y; - b->current.requested.w = w; - b->current.requested.h = h; - } - + { + int x, y, w, h; + + ecore_window_get_geometry(win, &x, &y, &w, &h); + b->current.requested.x = x; + b->current.requested.y = y; + b->current.requested.w = w; + b->current.requested.h = h; + } + e_icccm_get_mwm_hints(win, b); e_icccm_get_layer(win, b); e_icccm_get_title(win, b); @@ -1485,8 +1588,8 @@ e_border_adopt(Window win, int use_client_pos) /* desk area */ if (use_client_pos) { - int x, y; - + int x, y; + ecore_window_get_geometry(win, &x, &y, NULL, NULL); b->current.requested.x = x; b->current.requested.y = y; @@ -1499,73 +1602,75 @@ e_border_adopt(Window win, int use_client_pos) e_icccm_set_desk(win, b->client.desk); /* figure what border to use */ e_border_apply_border(b); - { - int pl, pr, pt, pb; - - pl = pr = pt = pb = 0; - if (b->bits.l) ebits_get_insets(b->bits.l, &pl, &pr, &pt, &pb); - b->current.requested.x += pl; - b->current.requested.y += pt; - b->changed = 1; - } + { + int pl, pr, pt, pb; + + pl = pr = pt = pb = 0; + if (b->bits.l) + ebits_get_insets(b->bits.l, &pl, &pr, &pt, &pb); + b->current.requested.x += pl; + b->current.requested.y += pt; + b->changed = 1; + } if (!use_client_pos) { - int x, y; - int pl, pr, pt, pb; - + int x, y; + int pl, pr, pt, pb; + pl = pr = pt = pb = 0; x = y = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); bw *= 2; if (b->client.pos.requested) { switch (b->client.pos.gravity) { - case NorthWestGravity: + case NorthWestGravity: x = b->client.pos.x + pl; y = b->client.pos.y + pt; break; - case NorthGravity: + case NorthGravity: x = b->client.pos.x + (bw / 2); y = b->client.pos.y + pt; break; - case NorthEastGravity: + case NorthEastGravity: x = b->client.pos.x - pr + bw; y = b->client.pos.y + pt; break; - case EastGravity: + case EastGravity: x = b->client.pos.x - pr + bw; y = b->client.pos.y + (bw / 2); break; - case SouthEastGravity: + case SouthEastGravity: x = b->client.pos.x - pr + bw; y = b->client.pos.y - pb + bw; break; - case SouthGravity: + case SouthGravity: x = b->client.pos.x + (bw / 2); y = b->client.pos.y - pb; break; - case SouthWestGravity: + case SouthWestGravity: x = b->client.pos.x + pl; y = b->client.pos.y - pb + bw; break; - case WestGravity: + case WestGravity: x = b->client.pos.x + pl; y = b->client.pos.y + (bw / 2); break; - case CenterGravity: + case CenterGravity: x = b->client.pos.x; y = b->client.pos.y; break; - case StaticGravity: + case StaticGravity: x = b->client.pos.x; y = b->client.pos.y; break; - case ForgetGravity: + case ForgetGravity: x = b->client.pos.x; y = b->client.pos.y; break; - default: + default: x = b->client.pos.x + pl; y = b->client.pos.y + pt; break; @@ -1592,22 +1697,22 @@ e_border_adopt(Window win, int use_client_pos) ecore_window_show(win); if (b->client.e.launch_id) - e_exec_broadcast_e_hack_found(b->win.client); - + e_exec_broadcast_e_hack_found(b->win.client); + D_RETURN_(b); } -E_Border * +E_Border * e_border_new(void) { /* FIXME: need to set an upper limit on the frame size */ - E_Border *b; - int max_colors = 216; - int font_cache = 1024 * 1024; - int image_cache = 8192 * 1024; - char *font_dir; - E_Desktop *desk; - + E_Border *b; + int max_colors = 216; + int font_cache = 1024 * 1024; + int image_cache = 8192 * 1024; + char *font_dir; + E_Desktop *desk; + D_ENTER; font_dir = e_config_get("fonts"); @@ -1617,7 +1722,7 @@ e_border_new(void) e_observee_init(E_OBSERVEE(b), (E_Cleanup_Func) e_border_cleanup); e_observer_register_observee(E_OBSERVER(delayed_window_raise), E_OBSERVEE(b)); - + D("BORDER CREATED AT %p\n", b); b->current.requested.w = 1; @@ -1635,7 +1740,7 @@ e_border_new(void) b->client.handles = 1; b->client.titlebar = 1; b->client.takes_focus = 1; - + desk = e_desktops_get(0); e_desktops_add_border(desk, b); b->win.main = ecore_window_override_new(desk->win.container, 0, 0, 1, 1); @@ -1653,38 +1758,26 @@ e_border_new(void) b->win.main, 0, 0, 1, 1, RENDER_METHOD_ALPHA_SOFTWARE, - max_colors, - font_cache, - image_cache, - font_dir); + max_colors, font_cache, image_cache, font_dir); b->win.l = evas_get_window(b->evas.l); b->evas.r = evas_new_all(ecore_display_get(), b->win.main, 0, 0, 1, 1, RENDER_METHOD_ALPHA_SOFTWARE, - max_colors, - font_cache, - image_cache, - font_dir); + max_colors, font_cache, image_cache, font_dir); b->win.r = evas_get_window(b->evas.r); b->evas.t = evas_new_all(ecore_display_get(), b->win.main, 0, 0, 1, 1, RENDER_METHOD_ALPHA_SOFTWARE, - max_colors, - font_cache, - image_cache, - font_dir); + max_colors, font_cache, image_cache, font_dir); b->win.t = evas_get_window(b->evas.t); b->evas.b = evas_new_all(ecore_display_get(), b->win.main, 0, 0, 1, 1, RENDER_METHOD_ALPHA_SOFTWARE, - max_colors, - font_cache, - image_cache, - font_dir); - b->win.b = evas_get_window(b->evas.b); + max_colors, font_cache, image_cache, font_dir); + b->win.b = evas_get_window(b->evas.b); e_cursors_display_in_window(b->win.l, "Default"); e_cursors_display_in_window(b->win.r, "Default"); e_cursors_display_in_window(b->win.t, "Default"); @@ -1694,7 +1787,7 @@ e_border_new(void) b->obj.title.r = e_text_new(b->evas.r, "", "title"); b->obj.title.t = e_text_new(b->evas.t, "", "title"); b->obj.title.b = e_text_new(b->evas.b, "", "title"); - + b->obj.title_clip.l = evas_add_rectangle(b->evas.l); b->obj.title_clip.r = evas_add_rectangle(b->evas.r); b->obj.title_clip.t = evas_add_rectangle(b->evas.t); @@ -1714,12 +1807,12 @@ e_border_new(void) evas_show(b->evas.r, b->obj.title_clip.r); evas_show(b->evas.t, b->obj.title_clip.t); evas_show(b->evas.b, b->obj.title_clip.b); - + e_text_set_clip(b->obj.title.l, b->obj.title_clip.l); e_text_set_clip(b->obj.title.r, b->obj.title_clip.r); e_text_set_clip(b->obj.title.t, b->obj.title_clip.t); e_text_set_clip(b->obj.title.b, b->obj.title_clip.b); - + ecore_window_raise(b->win.input); ecore_window_raise(b->win.container); @@ -1727,28 +1820,28 @@ e_border_new(void) evases = evas_list_append(evases, b->evas.r); evases = evas_list_append(evases, b->evas.t); evases = evas_list_append(evases, b->evas.b); - + ecore_window_set_events(b->win.l, XEV_EXPOSE); ecore_window_set_events(b->win.r, XEV_EXPOSE); ecore_window_set_events(b->win.t, XEV_EXPOSE); ecore_window_set_events(b->win.b, XEV_EXPOSE); - + ecore_window_show(b->win.l); ecore_window_show(b->win.r); ecore_window_show(b->win.t); ecore_window_show(b->win.b); - + e_border_attach_mouse_grabs(b); borders = evas_list_prepend(borders, b); e_observee_notify_all_observers(E_OBSERVEE(b), E_EVENT_BORDER_NEW); - + D_RETURN_(b); } void -e_border_iconify(E_Border *b) +e_border_iconify(E_Border * b) { D_ENTER; b->client.iconified = 1; @@ -1757,12 +1850,12 @@ e_border_iconify(E_Border *b) b->changed = 1; e_border_update(b); e_observee_notify_observers(E_OBSERVEE(b), E_EVENT_BORDER_ICONIFY); - + D_RETURN; } void -e_border_uniconify(E_Border *b) +e_border_uniconify(E_Border * b) { b->client.iconified = 0; b->current.requested.visible = 1; @@ -1772,22 +1865,22 @@ e_border_uniconify(E_Border *b) e_border_update(b); e_border_raise(b); - e_observee_notify_observers(E_OBSERVEE(b), E_EVENT_BORDER_UNICONIFY); + e_observee_notify_observers(E_OBSERVEE(b), E_EVENT_BORDER_UNICONIFY); } void -e_border_remove_mouse_grabs(E_Border *b) +e_border_remove_mouse_grabs(E_Border * b) { - Evas_List l; - + Evas_List l; + D_ENTER; if (b->grabs) { for (l = b->grabs; l; l = l->next) { - E_Grab *g; - + E_Grab *g; + g = l->data; ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); FREE(g); @@ -1801,14 +1894,14 @@ e_border_remove_mouse_grabs(E_Border *b) } void -e_border_remove_click_grab(E_Border *b) +e_border_remove_click_grab(E_Border * b) { D_ENTER; if (b->click_grab) { - E_Grab *g; - + E_Grab *g; + g = b->click_grab; ecore_button_ungrab(b->win.container, g->button, g->mods, g->any_mod); ecore_window_button_grab_auto_replay_set(b->win.container, NULL); @@ -1820,42 +1913,44 @@ e_border_remove_click_grab(E_Border *b) } void -e_border_attach_mouse_grabs(E_Border *b) +e_border_attach_mouse_grabs(E_Border * b) { - char *grabs_db; - E_DB_File *db; - int focus_mode; - char buf[PATH_MAX]; + char *grabs_db; + E_DB_File *db; + int focus_mode; + char buf[PATH_MAX]; + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); - + D_ENTER; E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); - + grabs_db = e_config_get("grabs"); /* settings - click to focus would affect grabs */ - if ((!b->current.selected) && - (focus_mode == 2)) + if ((!b->current.selected) && (focus_mode == 2)) { - E_Grab *g; - + E_Grab *g; + g = NEW(E_Grab, 1); ZERO(g, E_Grab, 1); g->button = 1; g->mods = ECORE_EVENT_KEY_MODIFIER_NONE; g->any_mod = 0; g->remove_after = 0; - ecore_button_grab(b->win.container, g->button, XEV_BUTTON_PRESS, g->mods, g->any_mod); - ecore_window_button_grab_auto_replay_set(b->win.container, e_border_replay_query); + ecore_button_grab(b->win.container, g->button, XEV_BUTTON_PRESS, + g->mods, g->any_mod); + ecore_window_button_grab_auto_replay_set(b->win.container, + e_border_replay_query); b->click_grab = g; } - + /* other grabs - liek alt+left to move */ db = e_db_open_read(grabs_db); if (db) { - int i, num; - + int i, num; + snprintf(buf, PATH_MAX, "/grabs/count"); if (!e_db_int_get(db, buf, &num)) { @@ -1864,23 +1959,26 @@ e_border_attach_mouse_grabs(E_Border *b) } for (i = 0; i < num; i++) { - int button, any_mod, mod; + int button, any_mod, mod; Ecore_Event_Key_Modifiers mods; button = -1; mods = ECORE_EVENT_KEY_MODIFIER_NONE; any_mod = 0; snprintf(buf, PATH_MAX, "/grabs/%i/button", i); - if (!e_db_int_get(db, buf, &button)) continue; + if (!e_db_int_get(db, buf, &button)) + continue; snprintf(buf, PATH_MAX, "/grabs/%i/modifiers", i); - if (!e_db_int_get(db, buf, &mod)) continue; - if (mod == -1) any_mod = 1; - mods = (Ecore_Event_Key_Modifiers)mod; - + if (!e_db_int_get(db, buf, &mod)) + continue; + if (mod == -1) + any_mod = 1; + mods = (Ecore_Event_Key_Modifiers) mod; + if (button >= 0) { - E_Grab *g; - + E_Grab *g; + g = NEW(E_Grab, 1); ZERO(g, E_Grab, 1); g->button = button; @@ -1888,7 +1986,8 @@ e_border_attach_mouse_grabs(E_Border *b) g->any_mod = any_mod; g->remove_after = 0; b->grabs = evas_list_append(b->grabs, g); - ecore_button_grab(b->win.main, button, XEV_BUTTON_PRESS, mods, 0); + ecore_button_grab(b->win.main, button, XEV_BUTTON_PRESS, mods, + 0); } } e_db_close(db); @@ -1900,12 +1999,12 @@ e_border_attach_mouse_grabs(E_Border *b) void e_border_remove_all_mouse_grabs(void) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = borders; l; l = l->next) - e_border_remove_mouse_grabs((E_Border *)l->data); + e_border_remove_mouse_grabs((E_Border *) l->data); D_RETURN; } @@ -1913,45 +2012,48 @@ e_border_remove_all_mouse_grabs(void) void e_border_attach_all_mouse_grabs(void) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = borders; l; l = l->next) - e_border_attach_mouse_grabs((E_Border *)l->data); + e_border_attach_mouse_grabs((E_Border *) l->data); D_RETURN; } void e_border_redo_grabs(void) -{ - char *grabs_db; - char *settings_db; - static time_t mod_date_grabs = 0; - static time_t mod_date_settings = 0; - time_t mod; - int changed = 0; - Evas_List l; - +{ + char *grabs_db; + char *settings_db; + static time_t mod_date_grabs = 0; + static time_t mod_date_settings = 0; + time_t mod; + int changed = 0; + Evas_List l; + D_ENTER; grabs_db = e_config_get("grabs"); settings_db = e_config_get("settings"); mod = e_file_mod_time(grabs_db); - if (mod != mod_date_grabs) changed = 1; + if (mod != mod_date_grabs) + changed = 1; mod_date_grabs = mod; if (!changed) { mod = e_file_mod_time(settings_db); - if (mod != mod_date_settings) changed = 1; + if (mod != mod_date_settings) + changed = 1; mod_date_settings = mod; } - if (!changed) D_RETURN; + if (!changed) + D_RETURN; for (l = borders; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; e_border_remove_mouse_grabs(b); e_border_attach_mouse_grabs(b); @@ -1960,49 +2062,52 @@ e_border_redo_grabs(void) D_RETURN; } -E_Border * +E_Border * e_border_find_by_window(Window win) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = borders; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; - - if ((win == b->win.main) || + + if ((win == b->win.main) || (win == b->win.client) || (win == b->win.container) || (win == b->win.input) || (win == b->win.l) || - (win == b->win.r) || - (win == b->win.t) || - (win == b->win.b)) - D_RETURN_(b); + (win == b->win.r) || (win == b->win.t) || (win == b->win.b)) + D_RETURN_(b); } D_RETURN_(NULL); } void -e_border_set_bits(E_Border *b, char *file) +e_border_set_bits(E_Border * b, char *file) { - int pl, pr, pt, pb, ppl, ppr, ppt, ppb; - + int pl, pr, pt, pb, ppl, ppr, ppt, ppb; + D_ENTER; pl = pr = pt = pb = 0; ppl = ppr = ppt = ppb = 0; - - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); - - if (b->bits.l) ebits_free(b->bits.l); - if (b->bits.r) ebits_free(b->bits.r); - if (b->bits.t) ebits_free(b->bits.t); - if (b->bits.b) ebits_free(b->bits.b); + + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + + if (b->bits.l) + ebits_free(b->bits.l); + if (b->bits.r) + ebits_free(b->bits.r); + if (b->bits.t) + ebits_free(b->bits.t); + if (b->bits.b) + ebits_free(b->bits.b); b->bits.l = ebits_load(file); b->bits.r = ebits_load(file); @@ -2011,12 +2116,13 @@ e_border_set_bits(E_Border *b, char *file) b->bits.new = 1; b->changed = 1; - if (b->bits.t) ebits_get_insets(b->bits.t, &ppl, &ppr, &ppt, &ppb); + if (b->bits.t) + ebits_get_insets(b->bits.t, &ppl, &ppr, &ppt, &ppb); b->current.requested.w -= (pl + pr) - (ppl + ppr); b->current.requested.h -= (pt + pb) - (ppt + ppb); b->current.requested.x += (pl - ppl); b->current.requested.y += (pt - ppt); - + if (b->bits.t) { ebits_add_to_evas(b->bits.l, b->evas.l); @@ -2034,7 +2140,7 @@ e_border_set_bits(E_Border *b, char *file) ebits_add_to_evas(b->bits.b, b->evas.b); ebits_move(b->bits.b, 0, 0); ebits_show(b->bits.b); - + e_border_set_color_class(b, "Title BG", 100, 200, 255, 255); #define HOOK_CB(_class) \ @@ -2051,7 +2157,7 @@ ebits_set_classed_bit_callback(b->bits.t, _class, CALLBACK_MOUSE_MOVE, e_cb_mous HOOK_CB("Iconify"); HOOK_CB("Max_Size"); HOOK_CB("Menu"); - + e_border_adjust_limits(b); } @@ -2059,7 +2165,8 @@ ebits_set_classed_bit_callback(b->bits.t, _class, CALLBACK_MOUSE_MOVE, e_cb_mous } void -e_border_set_color_class(E_Border *b, char *class, int rr, int gg, int bb, int aa) +e_border_set_color_class(E_Border * b, char *class, int rr, int gg, int bb, + int aa) { D_ENTER; @@ -2072,82 +2179,97 @@ e_border_set_color_class(E_Border *b, char *class, int rr, int gg, int bb, int a } void -e_border_adjust_limits(E_Border *b) +e_border_adjust_limits(E_Border * b) { - int w, h, pl, pr, pt, pb, mx, my; + int w, h, pl, pr, pt, pb, mx, my; D_ENTER; - if (b->mode.move) + if (b->mode.move) { e_resist_border(b); } else { - b->current.x = b->current.requested.x; + b->current.x = b->current.requested.x; b->current.y = b->current.requested.y; } - + b->current.w = b->current.requested.w; b->current.h = b->current.requested.h - b->current.shaded; - + if ((!b->current.shaded) && (!b->mode.move)) - { - if (b->current.w < 1) b->current.w = 1; - if (b->current.h < 1) b->current.h = 1; - + { + if (b->current.w < 1) + b->current.w = 1; + if (b->current.h < 1) + b->current.h = 1; + pl = pr = pt = pb = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); - - if (b->current.w < (pl + pr + 1)) b->current.w = pl + pr + 1; - if (b->current.h < (pt + pb + 1)) b->current.h = pt + pb + 1; - + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + + if (b->current.w < (pl + pr + 1)) + b->current.w = pl + pr + 1; + if (b->current.h < (pt + pb + 1)) + b->current.h = pt + pb + 1; + w = b->current.w - pl - pr; h = b->current.h - pt - pb + b->current.shaded; mx = my = 1; - if (b->bits.t) ebits_get_min_size(b->bits.t, &mx, &my); - if (b->current.w < mx) b->current.w = mx; - if (b->current.h < my) b->current.h = my; + if (b->bits.t) + ebits_get_min_size(b->bits.t, &mx, &my); + if (b->current.w < mx) + b->current.w = mx; + if (b->current.h < my) + b->current.h = my; mx = my = 999999; - if (b->bits.t) ebits_get_max_size(b->bits.t, &mx, &my); - if (b->current.w > mx) b->current.w = mx; - if (b->current.h > my) b->current.h = my; - - if (w < b->client.min.w) w = b->client.min.w; - if (h < b->client.min.h) h = b->client.min.h; - if (w > b->client.max.w) w = b->client.max.w; - if (h > b->client.max.h) h = b->client.max.h; + if (b->bits.t) + ebits_get_max_size(b->bits.t, &mx, &my); + if (b->current.w > mx) + b->current.w = mx; + if (b->current.h > my) + b->current.h = my; + + if (w < b->client.min.w) + w = b->client.min.w; + if (h < b->client.min.h) + h = b->client.min.h; + if (w > b->client.max.w) + w = b->client.max.w; + if (h > b->client.max.h) + h = b->client.max.h; if ((w > 0) && (h > 0)) { w -= b->client.base.w; h -= b->client.base.h; if ((w > 0) && (h > 0)) { - int i, j; - double aspect; - + int i, j; + double aspect; + aspect = ((double)w) / ((double)h); if ((b->mode.resize == 4) || (b->mode.resize == 5)) { if (aspect < b->client.min.aspect) - h = (int)((double)w / b->client.min.aspect); + h = (int)((double)w / b->client.min.aspect); if (aspect > b->client.max.aspect) - h = (int)((double)w / b->client.max.aspect); + h = (int)((double)w / b->client.max.aspect); } else if ((b->mode.resize == 6) || (b->mode.resize == 7)) { if (aspect < b->client.min.aspect) - w = (int)((double)h * b->client.min.aspect); + w = (int)((double)h * b->client.min.aspect); if (aspect > b->client.max.aspect) - w = (int)((double)h * b->client.max.aspect); + w = (int)((double)h * b->client.max.aspect); } else { if (aspect < b->client.min.aspect) - w = (int)((double)h * b->client.min.aspect); + w = (int)((double)h * b->client.min.aspect); if (aspect > b->client.max.aspect) - h = (int)((double)w / b->client.max.aspect); + h = (int)((double)w / b->client.max.aspect); } i = w / b->client.step.w; j = h / b->client.step.h; @@ -2165,7 +2287,8 @@ e_border_adjust_limits(E_Border *b) if (b->current.shaded == 0) { - if ((b->mode.resize == 4) || (b->mode.resize == 6) || (b->mode.resize == 8)) + if ((b->mode.resize == 4) || (b->mode.resize == 6) + || (b->mode.resize == 8)) { } else if ((b->mode.resize == 1) || (b->mode.resize == 5)) @@ -2187,28 +2310,30 @@ e_border_adjust_limits(E_Border *b) } void -e_border_update(E_Border *b) +e_border_update(E_Border * b) { - int location_changed = 0; - int size_changed = 0; - int shape_changed = 0; - int border_changed = 0; - int visibility_changed = 0; - int state_changed = 0; - + int location_changed = 0; + int size_changed = 0; + int shape_changed = 0; + int border_changed = 0; + int visibility_changed = 0; + int state_changed = 0; + D_ENTER; - if (b->hold_changes) D_RETURN; - if (!b->changed) D_RETURN; - + if (b->hold_changes) + D_RETURN; + if (!b->changed) + D_RETURN; + b->current.visible = b->current.requested.visible; - + if ((b->current.x != b->previous.x) || (b->current.y != b->previous.y)) - location_changed = 1; + location_changed = 1; if ((b->current.w != b->previous.w) || (b->current.h != b->previous.h)) - size_changed = 1; + size_changed = 1; if ((size_changed) && (b->current.has_shape)) - shape_changed = 1; + shape_changed = 1; if (b->current.selected != b->previous.selected) state_changed = 1; if (state_changed) @@ -2227,102 +2352,103 @@ e_border_update(E_Border *b) border_changed = 1; } if ((border_changed) && (b->current.has_shape)) - shape_changed = 1; + shape_changed = 1; if (b->current.visible != b->previous.visible) - visibility_changed = 1; - + visibility_changed = 1; + if ((location_changed) && (!size_changed)) { - int pl, pr, pt, pb; - + int pl, pr, pt, pb; + ecore_window_move(b->win.main, b->current.x, b->current.y); pl = pr = pt = pb = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); - e_icccm_move_resize(b->win.client, - b->current.x + pl, - b->current.y + pt, - b->client.w, - b->client.h); + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + e_icccm_move_resize(b->win.client, + b->current.x + pl, + b->current.y + pt, b->client.w, b->client.h); e_cb_border_move_resize(b); } else if (size_changed) { - int pl, pr, pt, pb, x, y, w, h; - int smaller; - + int pl, pr, pt, pb, x, y, w, h; + int smaller; + if ((b->current.shaped_client) || (b->previous.shaped_client) || (b->current.shape_changes) || (b->previous.shape_changes) || (b->current.has_shape) || (b->previous.has_shape)) - b->shape_changed = 1; + b->shape_changed = 1; smaller = 0; if ((b->current.w < b->previous.w) || (b->current.h < b->previous.h)) smaller = 1; pl = pr = pt = pb = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); - ecore_window_move_resize(b->win.input, - 0, 0, b->current.w, b->current.h); + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + ecore_window_move_resize(b->win.input, + 0, 0, b->current.w, b->current.h); if (smaller) { if (b->current.shaded == b->client.h) { - ecore_window_move_resize(b->win.client, - 0, - b->current.shaded, - b->client.w, - b->client.h); + ecore_window_move_resize(b->win.client, + 0, -b->current.shaded, + b->client.w, b->client.h); ecore_window_move_resize(b->win.container, - b->current.w + 1, - b->current.h + 1, - 320, - 320); + b->current.w + 1, + b->current.h + 1, 320, 320); } else { - ecore_window_move_resize(b->win.client, - 0, - b->current.shaded, - b->client.w, - b->client.h); - ecore_window_move_resize(b->win.container, - pl, - pt, - b->current.w - pl - pr, - b->current.h - pt - pb); + ecore_window_move_resize(b->win.client, + 0, -b->current.shaded, + b->client.w, b->client.h); + ecore_window_move_resize(b->win.container, + pl, + pt, + b->current.w - pl - pr, + b->current.h - pt - pb); } - ecore_window_move_resize(b->win.main, - b->current.x, b->current.y, - b->current.w, b->current.h); + ecore_window_move_resize(b->win.main, + b->current.x, b->current.y, + b->current.w, b->current.h); x = 0, y = pt, w = pl, h = (b->current.h - pt - pb); - if ((w <1) || (h < 1)) ecore_window_hide(b->win.l); - else + if ((w < 1) || (h < 1)) + ecore_window_hide(b->win.l); + else { ecore_window_show(b->win.l); ecore_window_move_resize(b->win.l, x, y, w, h); evas_set_output_size(b->evas.l, w, h); evas_set_output_viewport(b->evas.l, x, y, w, h); } - + x = 0, y = 0, w = b->current.w, h = pt; - if ((w <1) || (h < 1)) ecore_window_hide(b->win.t); - else + if ((w < 1) || (h < 1)) + ecore_window_hide(b->win.t); + else { ecore_window_show(b->win.t); ecore_window_move_resize(b->win.t, x, y, w, h); evas_set_output_size(b->evas.t, w, h); evas_set_output_viewport(b->evas.t, x, y, w, h); } - - x = b->current.w - pr, y = pt, w = pr, h = (b->current.h - pt - pb); - if ((w <1) || (h < 1)) ecore_window_hide(b->win.r); - else + + x = b->current.w - pr, y = pt, w = pr, h = + (b->current.h - pt - pb); + if ((w < 1) || (h < 1)) + ecore_window_hide(b->win.r); + else { ecore_window_show(b->win.r); ecore_window_move_resize(b->win.r, x, y, w, h); evas_set_output_size(b->evas.r, w, h); evas_set_output_viewport(b->evas.r, x, y, w, h); } - + x = 0, y = b->current.h - pb, w = b->current.w, h = pb; - if ((w <1) || (h < 1)) ecore_window_hide(b->win.b); - else + if ((w < 1) || (h < 1)) + ecore_window_hide(b->win.b); + else { ecore_window_show(b->win.b); ecore_window_move_resize(b->win.b, x, y, w, h); @@ -2332,42 +2458,47 @@ e_border_update(E_Border *b) } else { - ecore_window_move_resize(b->win.main, - b->current.x, b->current.y, - b->current.w, b->current.h); + ecore_window_move_resize(b->win.main, + b->current.x, b->current.y, + b->current.w, b->current.h); x = 0, y = pt, w = pl, h = (b->current.h - pt - pb); - if ((w <1) || (h < 1)) ecore_window_hide(b->win.l); - else + if ((w < 1) || (h < 1)) + ecore_window_hide(b->win.l); + else { ecore_window_show(b->win.l); ecore_window_move_resize(b->win.l, x, y, w, h); evas_set_output_size(b->evas.l, w, h); evas_set_output_viewport(b->evas.l, x, y, w, h); } - + x = 0, y = 0, w = b->current.w, h = pt; - if ((w <1) || (h < 1)) ecore_window_hide(b->win.t); - else + if ((w < 1) || (h < 1)) + ecore_window_hide(b->win.t); + else { ecore_window_show(b->win.t); ecore_window_move_resize(b->win.t, x, y, w, h); evas_set_output_size(b->evas.t, w, h); evas_set_output_viewport(b->evas.t, x, y, w, h); } - - x = b->current.w - pr, y = pt, w = pr, h = (b->current.h - pt - pb); - if ((w <1) || (h < 1)) ecore_window_hide(b->win.r); - else + + x = b->current.w - pr, y = pt, w = pr, h = + (b->current.h - pt - pb); + if ((w < 1) || (h < 1)) + ecore_window_hide(b->win.r); + else { ecore_window_show(b->win.r); ecore_window_move_resize(b->win.r, x, y, w, h); evas_set_output_size(b->evas.r, w, h); evas_set_output_viewport(b->evas.r, x, y, w, h); } - + x = 0, y = b->current.h - pb, w = b->current.w, h = pb; - if ((w <1) || (h < 1)) ecore_window_hide(b->win.b); - else + if ((w < 1) || (h < 1)) + ecore_window_hide(b->win.b); + else { ecore_window_show(b->win.b); ecore_window_move_resize(b->win.b, x, y, w, h); @@ -2377,135 +2508,143 @@ e_border_update(E_Border *b) if (b->current.shaded == b->client.h) { ecore_window_move_resize(b->win.container, - b->current.w + 1, - b->current.h + 1, - 320, - 320); - ecore_window_move_resize(b->win.client, - 0, - b->current.shaded, - b->client.w, - b->client.h); + b->current.w + 1, + b->current.h + 1, 320, 320); + ecore_window_move_resize(b->win.client, + 0, -b->current.shaded, + b->client.w, b->client.h); } else { - ecore_window_move_resize(b->win.container, - pl, - pt, - b->current.w - pl - pr, - b->current.h - pt - pb); - ecore_window_move_resize(b->win.client, - 0, - b->current.shaded, - b->client.w, - b->client.h); + ecore_window_move_resize(b->win.container, + pl, + pt, + b->current.w - pl - pr, + b->current.h - pt - pb); + ecore_window_move_resize(b->win.client, + 0, -b->current.shaded, + b->client.w, b->client.h); } } - - if (b->bits.l) ebits_resize(b->bits.l, b->current.w, b->current.h); - if (b->bits.r) ebits_resize(b->bits.r, b->current.w, b->current.h); - if (b->bits.t) ebits_resize(b->bits.t, b->current.w, b->current.h); - if (b->bits.b) ebits_resize(b->bits.b, b->current.w, b->current.h); - e_icccm_move_resize(b->win.client, - b->current.x + pl, b->current.y + pt - b->current.shaded, - b->client.w, b->client.h); + if (b->bits.l) + ebits_resize(b->bits.l, b->current.w, b->current.h); + if (b->bits.r) + ebits_resize(b->bits.r, b->current.w, b->current.h); + if (b->bits.t) + ebits_resize(b->bits.t, b->current.w, b->current.h); + if (b->bits.b) + ebits_resize(b->bits.b, b->current.w, b->current.h); + + e_icccm_move_resize(b->win.client, + b->current.x + pl, + b->current.y + pt - b->current.shaded, b->client.w, + b->client.h); e_cb_border_move_resize(b); } if ((b->client.title) && (b->bits.t)) { - double tx, ty, tw, th; - - ebits_get_named_bit_geometry(b->bits.l, "Title_Area", &tx, &ty, &tw, &th); + double tx, ty, tw, th; + + ebits_get_named_bit_geometry(b->bits.l, "Title_Area", &tx, &ty, &tw, + &th); if (b->obj.title.l) { e_text_set_text(b->obj.title.l, b->client.title); e_text_move(b->obj.title.l, tx, ty); if (b->current.selected) - e_text_set_state(b->obj.title.l, "selected"); + e_text_set_state(b->obj.title.l, "selected"); else - e_text_set_state(b->obj.title.l, "normal"); + e_text_set_state(b->obj.title.l, "normal"); } evas_move(b->evas.l, b->obj.title_clip.l, tx, ty); evas_resize(b->evas.l, b->obj.title_clip.l, tw, th); - - ebits_get_named_bit_geometry(b->bits.r, "Title_Area", &tx, &ty, &tw, &th); + + ebits_get_named_bit_geometry(b->bits.r, "Title_Area", &tx, &ty, &tw, + &th); if (b->obj.title.r) { e_text_set_text(b->obj.title.r, b->client.title); e_text_move(b->obj.title.r, tx, ty); if (b->current.selected) - e_text_set_state(b->obj.title.r, "selected"); + e_text_set_state(b->obj.title.r, "selected"); else - e_text_set_state(b->obj.title.r, "normal"); + e_text_set_state(b->obj.title.r, "normal"); } evas_move(b->evas.r, b->obj.title_clip.r, tx, ty); evas_resize(b->evas.r, b->obj.title_clip.r, tw, th); - - ebits_get_named_bit_geometry(b->bits.t, "Title_Area", &tx, &ty, &tw, &th); + + ebits_get_named_bit_geometry(b->bits.t, "Title_Area", &tx, &ty, &tw, + &th); if (b->obj.title.t) { e_text_set_text(b->obj.title.t, b->client.title); e_text_move(b->obj.title.t, tx, ty); if (b->current.selected) - e_text_set_state(b->obj.title.t, "selected"); + e_text_set_state(b->obj.title.t, "selected"); else - e_text_set_state(b->obj.title.t, "normal"); + e_text_set_state(b->obj.title.t, "normal"); } evas_move(b->evas.t, b->obj.title_clip.t, tx, ty); evas_resize(b->evas.t, b->obj.title_clip.t, tw, th); - - ebits_get_named_bit_geometry(b->bits.b, "Title_Area", &tx, &ty, &tw, &th); + + ebits_get_named_bit_geometry(b->bits.b, "Title_Area", &tx, &ty, &tw, + &th); if (b->obj.title.b) { e_text_set_text(b->obj.title.b, b->client.title); e_text_move(b->obj.title.b, tx, ty); if (b->current.selected) - e_text_set_state(b->obj.title.b, "selected"); + e_text_set_state(b->obj.title.b, "selected"); else - e_text_set_state(b->obj.title.b, "normal"); + e_text_set_state(b->obj.title.b, "normal"); } evas_move(b->evas.b, b->obj.title_clip.b, tx, ty); evas_resize(b->evas.b, b->obj.title_clip.b, tw, th); if (b->obj.title.l) - e_text_set_layer(b->obj.title.l, 1); + e_text_set_layer(b->obj.title.l, 1); if (b->obj.title.r) - e_text_set_layer(b->obj.title.r, 1); + e_text_set_layer(b->obj.title.r, 1); if (b->obj.title.t) - e_text_set_layer(b->obj.title.t, 1); + e_text_set_layer(b->obj.title.t, 1); if (b->obj.title.b) - e_text_set_layer(b->obj.title.b, 1); + e_text_set_layer(b->obj.title.b, 1); } e_border_reshape(b); if (visibility_changed) { if (b->current.visible) - ecore_window_show(b->win.main); + ecore_window_show(b->win.main); else - ecore_window_hide(b->win.main); + ecore_window_hide(b->win.main); e_cb_border_visibility(b); } if (border_changed) - ecore_window_gravity_set(b->win.container, NorthWestGravity); - b->bits.new = 0; - b->previous = b->current; + ecore_window_gravity_set(b->win.container, NorthWestGravity); + b->bits.new = 0; + b->previous = b->current; b->changed = 0; D_RETURN; } void -e_border_set_layer(E_Border *b, int layer) +e_border_set_layer(E_Border * b, int layer) { - int dl; - + int dl; + D_ENTER; - if (b->client.layer == layer) D_RETURN; + if (b->client.layer == layer) + D_RETURN; dl = layer - b->client.layer; b->client.layer = layer; - if (dl > 0) e_border_lower(b); - else e_border_raise(b); + if (dl > 0) + e_border_lower(b); + else + e_border_raise(b); D_RETURN; } @@ -2513,25 +2652,26 @@ e_border_set_layer(E_Border *b, int layer) static void e_border_raise_delayed(int val, void *b) { - int auto_raise = 0; + int auto_raise = 0; + E_CFG_INT(cfg_auto_raise, "settings", "/window/raise/auto", 0); - + D_ENTER; E_CONFIG_INT_GET(cfg_auto_raise, auto_raise); if (auto_raise) - e_border_raise((E_Border *)b); + e_border_raise((E_Border *) b); D_RETURN; UN(val); } void -e_border_raise(E_Border *b) +e_border_raise(E_Border * b) { - Evas_List l; - E_Border *rel; - + Evas_List l; + E_Border *rel; + D_ENTER; if (!b->desk->windows) @@ -2547,7 +2687,8 @@ e_border_raise(E_Border *b) if (rel->client.layer > b->client.layer) { b->desk->windows = evas_list_remove(b->desk->windows, b); - b->desk->windows = evas_list_prepend_relative(b->desk->windows, b, rel); + b->desk->windows = + evas_list_prepend_relative(b->desk->windows, b, rel); b->desk->changed = 1; ecore_window_stack_below(b->win.main, rel->win.main); D_RETURN; @@ -2566,11 +2707,11 @@ e_border_raise(E_Border *b) } void -e_border_lower(E_Border *b) +e_border_lower(E_Border * b) { - Evas_List l; - E_Border *rel; - + Evas_List l; + E_Border *rel; + D_ENTER; if (!b->desk->windows) @@ -2585,9 +2726,11 @@ e_border_lower(E_Border *b) rel = l->data; if (rel->client.layer == b->client.layer) { - if (b == rel) D_RETURN; + if (b == rel) + D_RETURN; b->desk->windows = evas_list_remove(b->desk->windows, b); - b->desk->windows = evas_list_prepend_relative(b->desk->windows, b, rel); + b->desk->windows = + evas_list_prepend_relative(b->desk->windows, b, rel); b->desk->changed = 1; ecore_window_stack_below(b->win.main, rel->win.main); D_RETURN; @@ -2598,7 +2741,7 @@ e_border_lower(E_Border *b) } void -e_border_raise_above(E_Border *b, E_Border *above) +e_border_raise_above(E_Border * b, E_Border * above) { D_ENTER; @@ -2609,8 +2752,10 @@ e_border_raise_above(E_Border *b, E_Border *above) ecore_window_raise(b->win.main); D_RETURN; } - if (!evas_list_find(b->desk->windows, above)) D_RETURN; - if (b->client.layer < above->client.layer) b->client.layer = above->client.layer; + if (!evas_list_find(b->desk->windows, above)) + D_RETURN; + if (b->client.layer < above->client.layer) + b->client.layer = above->client.layer; b->desk->windows = evas_list_remove(b->desk->windows, b); b->desk->windows = evas_list_append_relative(b->desk->windows, b, above); b->desk->changed = 1; @@ -2620,7 +2765,7 @@ e_border_raise_above(E_Border *b, E_Border *above) } void -e_border_lower_below(E_Border *b, E_Border *below) +e_border_lower_below(E_Border * b, E_Border * below) { D_ENTER; @@ -2630,8 +2775,10 @@ e_border_lower_below(E_Border *b, E_Border *below) b->desk->changed = 1; D_RETURN; } - if (!evas_list_find(b->desk->windows, below)) D_RETURN; - if (b->client.layer > below->client.layer) b->client.layer = below->client.layer; + if (!evas_list_find(b->desk->windows, below)) + D_RETURN; + if (b->client.layer > below->client.layer) + b->client.layer = below->client.layer; b->desk->windows = evas_list_remove(b->desk->windows, b); b->desk->windows = evas_list_prepend_relative(b->desk->windows, b, below); b->desk->changed = 1; @@ -2643,37 +2790,41 @@ e_border_lower_below(E_Border *b, E_Border *below) void e_border_init(void) { - double raise_delay = 0.5; + double raise_delay = 0.5; + E_CFG_FLOAT(cfg_raise_delay, "settings", "/window/raise/delay", 0.5); - + D_ENTER; E_CONFIG_FLOAT_GET(cfg_raise_delay, raise_delay); - - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, e_mouse_down); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, e_mouse_up); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, e_mouse_move); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_IN, e_mouse_in); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_OUT, e_mouse_out); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_EXPOSE, e_window_expose); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_MAP_REQUEST, e_map_request); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_CONFIGURE_REQUEST, e_configure_request); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_PROPERTY, e_property); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_UNMAP, e_unmap); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_DESTROY, e_destroy); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_CIRCULATE_REQUEST, e_circulate_request); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_REPARENT, e_reparent); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_SHAPE, e_shape); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_FOCUS_IN, e_focus_in); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_FOCUS_OUT, e_focus_out); - ecore_event_filter_handler_add(ECORE_EVENT_MESSAGE, e_client_message); - ecore_event_filter_handler_add(ECORE_EVENT_COLORMAP, e_colormap); + + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, e_mouse_down); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, e_mouse_up); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, e_mouse_move); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_IN, e_mouse_in); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_OUT, e_mouse_out); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_EXPOSE, e_window_expose); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_MAP_REQUEST, + e_map_request); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_CONFIGURE_REQUEST, + e_configure_request); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_PROPERTY, e_property); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_UNMAP, e_unmap); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_DESTROY, e_destroy); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_CIRCULATE_REQUEST, + e_circulate_request); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_REPARENT, e_reparent); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_SHAPE, e_shape); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_FOCUS_IN, e_focus_in); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_FOCUS_OUT, e_focus_out); + ecore_event_filter_handler_add(ECORE_EVENT_MESSAGE, e_client_message); + ecore_event_filter_handler_add(ECORE_EVENT_COLORMAP, e_colormap); ecore_event_filter_idle_handler_add(e_idle, NULL); delayed_window_raise = - e_delayed_action_new(E_EVENT_BORDER_FOCUS_IN, - raise_delay, e_border_raise_delayed); - + e_delayed_action_new(E_EVENT_BORDER_FOCUS_IN, + raise_delay, e_border_raise_delayed); + ecore_add_event_timer("e_border_poll()", 1.00, e_border_poll, 0, NULL); D_RETURN; @@ -2682,8 +2833,8 @@ e_border_init(void) void e_border_adopt_children(Window win) { - Window *wins; - int i, num; + Window *wins; + int i, num; D_ENTER; @@ -2692,21 +2843,22 @@ e_border_adopt_children(Window win) { for (i = 0; i < num; i++) { - if (ecore_window_is_manageable(wins[i])) + if (ecore_window_is_manageable(wins[i])) { - E_Border *b; - + E_Border *b; + b = e_border_adopt(wins[i], 1); - { - int pl, pr, pt, pb; - - pl = pr = pt = pb = 0; - if (b->bits.l) ebits_get_insets(b->bits.l, &pl, &pr, &pt, &pb); - b->current.requested.x -= pl; - b->current.requested.y -= pt; - b->changed = 1; - e_border_adjust_limits(b); - } + { + int pl, pr, pt, pb; + + pl = pr = pt = pb = 0; + if (b->bits.l) + ebits_get_insets(b->bits.l, &pl, &pr, &pt, &pb); + b->current.requested.x -= pl; + b->current.requested.y -= pt; + b->changed = 1; + e_border_adjust_limits(b); + } b->ignore_unmap = 2; } } @@ -2716,25 +2868,27 @@ e_border_adopt_children(Window win) D_RETURN; } -E_Border * +E_Border * e_border_current_focused(void) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = borders; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; - if (b->current.selected) D_RETURN_(b); + if (b->current.selected) + D_RETURN_(b); } for (l = borders; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; - if (b->current.select_lost_from_grab) D_RETURN_(b); + if (b->current.select_lost_from_grab) + D_RETURN_(b); } D_RETURN_(NULL); @@ -2743,14 +2897,14 @@ e_border_current_focused(void) void e_border_focus_grab_ended(void) { - Evas_List l; + Evas_List l; D_ENTER; for (l = borders; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; b->current.select_lost_from_grab = 0; b->current.selected = 0; @@ -2761,37 +2915,38 @@ e_border_focus_grab_ended(void) } int -e_border_viewable(E_Border *b) +e_border_viewable(E_Border * b) { D_ENTER; if (b->desk != e_desktops_get(0)) - D_RETURN_(0); + D_RETURN_(0); if (b->current.x + b->current.w <= 0) - D_RETURN_(0); + D_RETURN_(0); if (b->current.x >= b->desk->real.w) - D_RETURN_(0); + D_RETURN_(0); if (b->current.y + b->current.h <= 0) - D_RETURN_(0); + D_RETURN_(0); if (b->current.y >= b->desk->real.h) - D_RETURN_(0); - + D_RETURN_(0); + if (!b->current.visible) - D_RETURN_(0); + D_RETURN_(0); D_RETURN_(1); } void -e_border_send_pointer(E_Border *b) +e_border_send_pointer(E_Border * b) { D_ENTER; - XWarpPointer(ecore_display_get(), None, b->win.main, 0, 0, 0, 0, b->current.w / 2, b->current.h / 2); + XWarpPointer(ecore_display_get(), None, b->win.main, 0, 0, 0, 0, + b->current.w / 2, b->current.h / 2); D_RETURN; } @@ -2799,13 +2954,13 @@ e_border_send_pointer(E_Border *b) void e_border_raise_next(void) { - Evas_List next; - E_Border *current; + Evas_List next; + E_Border *current; D_ENTER; if (!borders) - D_RETURN; + D_RETURN; current = e_border_current_focused(); @@ -2814,19 +2969,19 @@ e_border_raise_next(void) /* Step to the next border, wrap around the queue if the end is reached */ if (next && next->next) - next = next->next; + next = next->next; else - next = borders; + next = borders; /* Now find the next viewable border on the same desktop */ - current = (E_Border *)next->data; + current = (E_Border *) next->data; while (next && (!e_border_viewable(current) || current->client.is_desktop)) { next = next->next; if (!next) - next = borders; + next = borders; - current = (E_Border *)next->data; + current = (E_Border *) next->data; } e_border_raise(current); @@ -2836,45 +2991,41 @@ e_border_raise_next(void) } void -e_border_print_pos(char *buf, E_Border *b) +e_border_print_pos(char *buf, E_Border * b) { D_ENTER; - snprintf(buf, PATH_MAX, "%i, %i", - b->current.x, b->current.y); + snprintf(buf, PATH_MAX, "%i, %i", b->current.x, b->current.y); D_RETURN; } void -e_border_print_size(char *buf, E_Border *b) +e_border_print_size(char *buf, E_Border * b) { D_ENTER; if ((b->client.step.w > 1) || (b->client.step.h > 1)) { snprintf(buf, PATH_MAX, "%i x %i", - (b->client.w - b->client.base.w) / b->client.step.w, - (b->client.h - b->client.base.h) / b->client.step.h); + (b->client.w - b->client.base.w) / b->client.step.w, + (b->client.h - b->client.base.h) / b->client.step.h); } else { - snprintf(buf, PATH_MAX, "%i x %i", - b->client.w, - b->client.h); + snprintf(buf, PATH_MAX, "%i x %i", b->client.w, b->client.h); } D_RETURN; } - -void -e_border_set_gravity(E_Border *b, int gravity) +void +e_border_set_gravity(E_Border * b, int gravity) { D_ENTER; if (!b) - D_RETURN; + D_RETURN; ecore_window_gravity_set(b->win.container, gravity); ecore_window_gravity_set(b->win.input, gravity); diff --git a/src/border.h b/src/border.h index b06a46d7a..08944f52a 100644 --- a/src/border.h +++ b/src/border.h @@ -8,175 +8,225 @@ #ifndef E_DESKTOPS_TYPEDEF #define E_DESKTOPS_TYPEDEF -typedef struct _E_Desktop E_Desktop; +typedef struct _E_Desktop E_Desktop; #endif -typedef struct _E_Grab E_Grab; -typedef struct _E_Border E_Border; +typedef struct _E_Grab E_Grab; +typedef struct _E_Border E_Border; struct _E_Grab { - int button; + int button; Ecore_Event_Key_Modifiers mods; - int any_mod; - int remove_after; - int allow; + int any_mod; + int remove_after; + int allow; }; struct _E_Border { - E_Observee obs; + E_Observee obs; - struct { - Window main; - Window l, r, t, b; - Window input; - Window container; - Window client; - } win; - struct { - Evas l, r, t, b; - } evas; - struct { - struct { - E_Text *l, *r, *t, *b; - } title; - struct { - Evas_Object l, r, t, b; - } title_clip; - } obj; - struct { - Pixmap l, r, t, b; - } pixmap; - struct { - int new; - Ebits_Object l, r, t, b; - } bits; - - struct { - struct { - int x, y, w, h; - int visible; - int dx, dy; - } requested; - int x, y, w, h; - int visible; - int selected; - int select_lost_from_grab; - int shaded; - int has_shape; - int shape_changes; - int shaped_client; - } current, previous; - - struct { - struct { - int w, h; - double aspect; - } base, min, max, step; - int layer; - char *title; - char *name; - char *class; - char *command; - char *machine; - char *icon_name; - int pid; - Window group; - int takes_focus; - int sticky; - Colormap colormap; - int fixed; - int arrange_ignore; - int hidden; - int iconified; - int titlebar; - int border; - int handles; - int initial_state; - int is_desktop; - int w, h; - int no_place; - struct { - int launch_id; - pid_t pid; - pid_t ppid; - uid_t user; - } e; - struct { - int requested; - int x, y; - int gravity; - } pos; - int desk; - struct { - int x, y; - } area; - int internal; - struct { - int matched; - struct { - int matched; - int ignore; - } prog_location; - struct { - int matched; - char *style; - } border; - struct { - int matched; - int x, y; - } location; - struct { - int matched; - int x, y; - } desk_area; - struct { - int matched; - int w, h; - } size; - struct { - int matched; - int desk; - } desktop; - struct { - int matched; - int sticky; - } sticky; - struct { - int matched; - int layer; - } layer; - } matched; - } client; - - struct { - int move, resize; - } mode; - - struct { - int x, y, w, h; - int is; - } max; - - int ignore_unmap; - int shape_changed; - int placed; - - Evas_List grabs; - E_Grab *click_grab; - E_Desktop *desk; - - char *border_style; - char *border_file; + struct + { + Window main; + Window l, r, t, b; + Window input; + Window container; + Window client; + } + win; + struct + { + Evas l, r, t, b; + } + evas; + struct + { + struct + { + E_Text *l, *r, *t, *b; + } + title; + struct + { + Evas_Object l, r, t, b; + } + title_clip; + } + obj; + struct + { + Pixmap l, r, t, b; + } + pixmap; + struct + { + int new; + Ebits_Object l, r, t, b; + } + bits; - int first_expose; - - int hold_changes; - - Evas_List menus; - - int changed; + struct + { + struct + { + int x, y, w, h; + int visible; + int dx, dy; + } + requested; + int x, y, w, h; + int visible; + int selected; + int select_lost_from_grab; + int shaded; + int has_shape; + int shape_changes; + int shaped_client; + } + current , previous; + + struct + { + struct + { + int w, h; + double aspect; + } + base , min, max, step; + int layer; + char *title; + char *name; + char *class; + char *command; + char *machine; + char *icon_name; + int pid; + Window group; + int takes_focus; + int sticky; + Colormap colormap; + int fixed; + int arrange_ignore; + int hidden; + int iconified; + int titlebar; + int border; + int handles; + int initial_state; + int is_desktop; + int w, h; + int no_place; + struct + { + int launch_id; + pid_t pid; + pid_t ppid; + uid_t user; + } + e; + struct + { + int requested; + int x, y; + int gravity; + } + pos; + int desk; + struct + { + int x, y; + } + area; + int internal; + struct + { + int matched; + struct + { + int matched; + int ignore; + } + prog_location; + struct + { + int matched; + char *style; + } + border; + struct + { + int matched; + int x, y; + } + location; + struct + { + int matched; + int x, y; + } + desk_area; + struct + { + int matched; + int w, h; + } + size; + struct + { + int matched; + int desk; + } + desktop; + struct + { + int matched; + int sticky; + } + sticky; + struct + { + int matched; + int layer; + } + layer; + } + matched; + } + client; + + struct + { + int move, resize; + } + mode; + + struct + { + int x, y, w, h; + int is; + } + max; + + int ignore_unmap; + int shape_changed; + int placed; + + Evas_List grabs; + E_Grab *click_grab; + E_Desktop *desk; + + char *border_style; + char *border_file; + + int first_expose; + + int hold_changes; + + Evas_List menus; + + int changed; }; /** @@ -185,41 +235,42 @@ struct _E_Border * This function registers the border event handlers * against ecore. */ -void e_border_init(void); +void e_border_init(void); -E_Border *e_border_new(void); +E_Border *e_border_new(void); -void e_border_update_borders(void); -void e_border_apply_border(E_Border *b); -void e_border_reshape(E_Border *b); -void e_border_release(E_Border *b); -E_Border *e_border_adopt(Window win, int use_client_pos); -void e_border_adopt_children(Window win); -void e_border_remove_mouse_grabs(E_Border *b); -void e_border_remove_click_grab(E_Border *b); -void e_border_attach_mouse_grabs(E_Border *b); -void e_border_remove_all_mouse_grabs(void); -void e_border_attach_all_mouse_grabs(void); -void e_border_redo_grabs(void); -E_Border *e_border_find_by_window(Window win); -void e_border_set_bits(E_Border *b, char *file); -void e_border_set_color_class(E_Border *b, char *class, int rr, int gg, int bb, int aa); -void e_border_adjust_limits(E_Border *b); -void e_border_update(E_Border *b); -void e_border_set_layer(E_Border *b, int layer); -void e_border_raise(E_Border *b); -void e_border_lower(E_Border *b); -void e_border_iconify(E_Border *b); -void e_border_uniconify(E_Border *b); -void e_border_raise_above(E_Border *b, E_Border *above); -void e_border_lower_below(E_Border *b, E_Border *below); -E_Border *e_border_current_focused(void); -void e_border_focus_grab_ended(void); -void e_border_raise_next(void); -void e_border_send_pointer(E_Border *b); -int e_border_viewable(E_Border *b); -void e_border_print_pos(char *buf, E_Border *b); -void e_border_print_size(char *buf, E_Border *b); -void e_border_set_gravity(E_Border *b, int gravity); -Evas_List e_border_get_borders_list(); +void e_border_update_borders(void); +void e_border_apply_border(E_Border * b); +void e_border_reshape(E_Border * b); +void e_border_release(E_Border * b); +E_Border *e_border_adopt(Window win, int use_client_pos); +void e_border_adopt_children(Window win); +void e_border_remove_mouse_grabs(E_Border * b); +void e_border_remove_click_grab(E_Border * b); +void e_border_attach_mouse_grabs(E_Border * b); +void e_border_remove_all_mouse_grabs(void); +void e_border_attach_all_mouse_grabs(void); +void e_border_redo_grabs(void); +E_Border *e_border_find_by_window(Window win); +void e_border_set_bits(E_Border * b, char *file); +void e_border_set_color_class(E_Border * b, char *class, int rr, + int gg, int bb, int aa); +void e_border_adjust_limits(E_Border * b); +void e_border_update(E_Border * b); +void e_border_set_layer(E_Border * b, int layer); +void e_border_raise(E_Border * b); +void e_border_lower(E_Border * b); +void e_border_iconify(E_Border * b); +void e_border_uniconify(E_Border * b); +void e_border_raise_above(E_Border * b, E_Border * above); +void e_border_lower_below(E_Border * b, E_Border * below); +E_Border *e_border_current_focused(void); +void e_border_focus_grab_ended(void); +void e_border_raise_next(void); +void e_border_send_pointer(E_Border * b); +int e_border_viewable(E_Border * b); +void e_border_print_pos(char *buf, E_Border * b); +void e_border_print_size(char *buf, E_Border * b); +void e_border_set_gravity(E_Border * b, int gravity); +Evas_List e_border_get_borders_list(); #endif diff --git a/src/bordermenu.c b/src/bordermenu.c index 51a5fa923..caa176c9d 100644 --- a/src/bordermenu.c +++ b/src/bordermenu.c @@ -6,139 +6,166 @@ #include "icccm.h" #include "bordermenu.h" -static void e_bordermenu_cb_close(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_kill(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_raise(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_lower(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_sticky(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_iconify(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_max(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_zoom(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_remember_location(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_remember_size(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_remember_desktop(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_remember_sticky(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_remember_prog_location_ignore(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_bordermenu_cb_menu_hide(E_Menu *m, void *data); +static void e_bordermenu_cb_close(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_kill(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_raise(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_lower(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_sticky(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_iconify(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_max(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_zoom(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_remember_location(E_Menu * m, + E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_remember_size(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_remember_desktop(E_Menu * m, + E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_remember_sticky(E_Menu * m, + E_Menu_Item * mi, + void *data); +static void e_bordermenu_cb_remember_prog_location_ignore(E_Menu * m, + E_Menu_Item * + mi, + void *data); +static void e_bordermenu_cb_menu_hide(E_Menu * m, void *data); static void -e_bordermenu_cb_close(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_close(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - if (b->win.client) e_icccm_delete(b->win.client); - + if (b->win.client) + e_icccm_delete(b->win.client); + D_RETURN; UN(m); UN(mi); } static void -e_bordermenu_cb_kill(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_kill(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - if (b->win.client) ecore_window_kill_client(b->win.client); - + if (b->win.client) + ecore_window_kill_client(b->win.client); + D_RETURN; UN(m); UN(mi); } static void -e_bordermenu_cb_raise(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_raise(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - e_border_raise(b); - + e_border_raise(b); + D_RETURN; UN(m); UN(mi); } static void -e_bordermenu_cb_lower(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_lower(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - - e_border_lower(b); - + + e_border_lower(b); + D_RETURN; UN(m); UN(mi); } static void -e_bordermenu_cb_sticky(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_sticky(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - if (mi->on) e_menu_item_set_state(mi, 0); - else e_menu_item_set_state(mi, 1); + if (mi->on) + e_menu_item_set_state(mi, 0); + else + e_menu_item_set_state(mi, 1); e_menu_set_state(m, mi); - + b->client.sticky = mi->on; b->changed = 1; - + D_RETURN; UN(m); UN(mi); } static void -e_bordermenu_cb_iconify(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_iconify(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - + D_RETURN; UN(m); UN(mi); } static void -e_bordermenu_cb_max(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_max(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - if (b->client.is_desktop) D_RETURN; - if (b->current.shaded > 0) D_RETURN; - if ((b->mode.move) || (b->mode.resize)) D_RETURN; + if (b->client.is_desktop) + D_RETURN; + if (b->current.shaded > 0) + D_RETURN; + if ((b->mode.move) || (b->mode.resize)) + D_RETURN; b->mode.move = 0; b->mode.resize = 0; - if (mi->on) e_menu_item_set_state(mi, 0); - else e_menu_item_set_state(mi, 1); + if (mi->on) + e_menu_item_set_state(mi, 0); + else + e_menu_item_set_state(mi, 1); e_menu_set_state(m, mi); - + if (mi->on) { b->max.x = b->current.x; @@ -171,134 +198,145 @@ e_bordermenu_cb_max(E_Menu *m, E_Menu_Item *mi, void *data) b->current.requested.w = b->current.w; b->current.requested.h = b->current.h; } - + D_RETURN; UN(m); UN(mi); } static void -e_bordermenu_cb_zoom(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_zoom(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - + D_RETURN; UN(m); UN(mi); } static void -e_bordermenu_cb_remember_location(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_remember_location(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - - if (mi->on) e_menu_item_set_state(mi, 0); - else e_menu_item_set_state(mi, 1); + + if (mi->on) + e_menu_item_set_state(mi, 0); + else + e_menu_item_set_state(mi, 1); e_menu_set_state(m, mi); b->client.matched.matched = 1; b->client.matched.location.matched = mi->on; - + D_RETURN; UN(m); } static void -e_bordermenu_cb_remember_size(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_remember_size(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - - if (mi->on) e_menu_item_set_state(mi, 0); - else e_menu_item_set_state(mi, 1); + + if (mi->on) + e_menu_item_set_state(mi, 0); + else + e_menu_item_set_state(mi, 1); e_menu_set_state(m, mi); b->client.matched.matched = 1; b->client.matched.size.matched = mi->on; - + D_RETURN; UN(m); } static void -e_bordermenu_cb_remember_desktop(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_remember_desktop(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - - if (mi->on) e_menu_item_set_state(mi, 0); - else e_menu_item_set_state(mi, 1); + + if (mi->on) + e_menu_item_set_state(mi, 0); + else + e_menu_item_set_state(mi, 1); e_menu_set_state(m, mi); b->client.matched.matched = 1; b->client.matched.desktop.matched = mi->on; - + D_RETURN; UN(m); } static void -e_bordermenu_cb_remember_sticky(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_remember_sticky(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - - if (mi->on) e_menu_item_set_state(mi, 0); - else e_menu_item_set_state(mi, 1); + + if (mi->on) + e_menu_item_set_state(mi, 0); + else + e_menu_item_set_state(mi, 1); e_menu_set_state(m, mi); b->client.matched.matched = 1; b->client.matched.sticky.matched = mi->on; - + D_RETURN; UN(m); } static void -e_bordermenu_cb_remember_prog_location_ignore(E_Menu *m, E_Menu_Item *mi, void *data) +e_bordermenu_cb_remember_prog_location_ignore(E_Menu * m, E_Menu_Item * mi, + void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; - - if (mi->on) e_menu_item_set_state(mi, 0); - else e_menu_item_set_state(mi, 1); + + if (mi->on) + e_menu_item_set_state(mi, 0); + else + e_menu_item_set_state(mi, 1); e_menu_set_state(m, mi); b->client.matched.matched = 1; b->client.matched.prog_location.matched = mi->on; b->client.matched.prog_location.ignore = 1; - + D_RETURN; UN(m); } static void -e_bordermenu_cb_menu_hide(E_Menu *m, void *data) +e_bordermenu_cb_menu_hide(E_Menu * m, void *data) { - E_Border *b; - + E_Border *b; + D_ENTER; - + b = data; while (b->menus) @@ -307,19 +345,19 @@ e_bordermenu_cb_menu_hide(E_Menu *m, void *data) m->delete_me = 1; b->menus = evas_list_remove(b->menus, m); } - - D_RETURN; + + D_RETURN; UN(m); } void -e_bordermenu_do(E_Border *b) +e_bordermenu_do(E_Border * b) { - E_Menu *menu; - E_Menu_Item *menuitem; - + E_Menu *menu; + E_Menu_Item *menuitem; + D_ENTER; - + if (!b->menus) { menu = e_menu_new(); @@ -327,11 +365,11 @@ e_bordermenu_do(E_Border *b) e_menu_set_padding_icon(menu, 2); e_menu_set_padding_state(menu, 2); e_menu_hide_callback(menu, e_bordermenu_cb_menu_hide, b); - + menuitem = e_menu_item_new("Close"); /* e_menu_item_set_icon(menuitem, icon); */ - /* e_menu_item_set_scale_icon(menuitem, 1);*/ - /* e_menu_item_set_separator(menuitem, 1);*/ + /* e_menu_item_set_scale_icon(menuitem, 1); */ + /* e_menu_item_set_separator(menuitem, 1); */ e_menu_item_set_callback(menuitem, e_bordermenu_cb_close, b); e_menu_add_item(menu, menuitem); @@ -342,43 +380,44 @@ e_bordermenu_do(E_Border *b) menuitem = e_menu_item_new("Lower"); e_menu_item_set_callback(menuitem, e_bordermenu_cb_lower, b); e_menu_add_item(menu, menuitem); - + menuitem = e_menu_item_new("Iconify"); e_menu_item_set_callback(menuitem, e_bordermenu_cb_iconify, b); e_menu_add_item(menu, menuitem); - + menuitem = e_menu_item_new("Zoom"); e_menu_item_set_callback(menuitem, e_bordermenu_cb_zoom, b); e_menu_add_item(menu, menuitem); - + menuitem = e_menu_item_new("Maximise"); e_menu_item_set_check(menuitem, 1); e_menu_item_set_state(menuitem, b->max.is); e_menu_item_set_callback(menuitem, e_bordermenu_cb_max, b); e_menu_add_item(menu, menuitem); - + menuitem = e_menu_item_new("Sticky"); e_menu_item_set_check(menuitem, 1); e_menu_item_set_state(menuitem, b->client.sticky); e_menu_item_set_callback(menuitem, e_bordermenu_cb_sticky, b); e_menu_add_item(menu, menuitem); - + menuitem = e_menu_item_new(""); e_menu_item_set_separator(menuitem, 1); e_menu_add_item(menu, menuitem); - + menuitem = e_menu_item_new("Kill"); e_menu_item_set_callback(menuitem, e_bordermenu_cb_kill, b); e_menu_add_item(menu, menuitem); - + menuitem = e_menu_item_new(""); e_menu_item_set_separator(menuitem, 1); e_menu_add_item(menu, menuitem); - + menuitem = e_menu_item_new("Remember Location"); e_menu_item_set_check(menuitem, 1); e_menu_item_set_state(menuitem, b->client.matched.location.matched); - e_menu_item_set_callback(menuitem, e_bordermenu_cb_remember_location, b); + e_menu_item_set_callback(menuitem, e_bordermenu_cb_remember_location, + b); e_menu_add_item(menu, menuitem); e_menu_set_state(menu, menuitem); @@ -405,31 +444,39 @@ e_bordermenu_do(E_Border *b) menuitem = e_menu_item_new("Ignore Program Specified Position"); e_menu_item_set_check(menuitem, 1); - e_menu_item_set_state(menuitem, b->client.matched.prog_location.matched); - e_menu_item_set_callback(menuitem, e_bordermenu_cb_remember_prog_location_ignore, b); + e_menu_item_set_state(menuitem, + b->client.matched.prog_location.matched); + e_menu_item_set_callback(menuitem, + e_bordermenu_cb_remember_prog_location_ignore, + b); e_menu_add_item(menu, menuitem); e_menu_set_state(menu, menuitem); } - { - int pl, pr, pt, pb; - int crx, cry, crw, crh; - int mx, my; - - menu = b->menus->data; - pl = pr = pt = pb = 0; - if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); - crx = b->current.x + pl; - cry = b->current.y + pt; - crw = b->client.w; - crh = b->client.h; - ecore_pointer_xy_get(&mx, &my); - if (mx + menu->current.w > crx + crw) mx = crx + crw - menu->current.w; - if (my + menu->current.h > cry + crh) my = cry + crh - menu->current.h; - if (mx < crx) mx = crx; - if (my < cry) my = cry; - e_menu_show_at_mouse(menu, mx, my, CurrentTime); - } - + { + int pl, pr, pt, pb; + int crx, cry, crw, crh; + int mx, my; + + menu = b->menus->data; + pl = pr = pt = pb = 0; + if (b->bits.t) + ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + crx = b->current.x + pl; + cry = b->current.y + pt; + crw = b->client.w; + crh = b->client.h; + ecore_pointer_xy_get(&mx, &my); + if (mx + menu->current.w > crx + crw) + mx = crx + crw - menu->current.w; + if (my + menu->current.h > cry + crh) + my = cry + crh - menu->current.h; + if (mx < crx) + mx = crx; + if (my < cry) + my = cry; + e_menu_show_at_mouse(menu, mx, my, CurrentTime); + } + D_RETURN; } diff --git a/src/bordermenu.h b/src/bordermenu.h index 7976dc38a..fb864db6c 100644 --- a/src/bordermenu.h +++ b/src/bordermenu.h @@ -3,7 +3,6 @@ #include "e.h" -void e_bordermenu_do(E_Border *b); +void e_bordermenu_do(E_Border * b); #endif - diff --git a/src/config.c b/src/config.c index 404828a47..d8fa313a1 100644 --- a/src/config.c +++ b/src/config.c @@ -3,27 +3,27 @@ #include "file.h" #include "util.h" -static char cfg_root[] = ""; +static char cfg_root[] = ""; -static char cfg_grabs_db[PATH_MAX] = ""; -static char cfg_settings_db[PATH_MAX] = ""; -static char cfg_actions_db[PATH_MAX] = ""; -static char cfg_borders_db[PATH_MAX] = ""; -static char cfg_apps_menu_db[PATH_MAX] = ""; -static char cfg_match_db[PATH_MAX] = ""; -static char cfg_menus_dir[PATH_MAX] = ""; -static char cfg_entries_dir[PATH_MAX] = ""; -static char cfg_selections_dir[PATH_MAX] = ""; -static char cfg_scrollbars_dir[PATH_MAX] = ""; -static char cfg_guides_dir[PATH_MAX] = ""; -static char cfg_user_dir[PATH_MAX] = ""; -static char cfg_images_dir[PATH_MAX] = ""; -static char cfg_cursors_dir[PATH_MAX] = ""; -static char cfg_backgrounds_dir[PATH_MAX] = ""; -static char cfg_fonts_dir[PATH_MAX] = ""; -static char cfg_epplets_dir[PATH_MAX] = ""; +static char cfg_grabs_db[PATH_MAX] = ""; +static char cfg_settings_db[PATH_MAX] = ""; +static char cfg_actions_db[PATH_MAX] = ""; +static char cfg_borders_db[PATH_MAX] = ""; +static char cfg_apps_menu_db[PATH_MAX] = ""; +static char cfg_match_db[PATH_MAX] = ""; +static char cfg_menus_dir[PATH_MAX] = ""; +static char cfg_entries_dir[PATH_MAX] = ""; +static char cfg_selections_dir[PATH_MAX] = ""; +static char cfg_scrollbars_dir[PATH_MAX] = ""; +static char cfg_guides_dir[PATH_MAX] = ""; +static char cfg_user_dir[PATH_MAX] = ""; +static char cfg_images_dir[PATH_MAX] = ""; +static char cfg_cursors_dir[PATH_MAX] = ""; +static char cfg_backgrounds_dir[PATH_MAX] = ""; +static char cfg_fonts_dir[PATH_MAX] = ""; +static char cfg_epplets_dir[PATH_MAX] = ""; -char * +char * e_config_get(char *type) { D_ENTER; @@ -40,7 +40,7 @@ e_config_get(char *type) /* Later when things are a bit mroe stabilised these will look */ /* something like: */ /* E_CONF("grabs", cfg_grabs_db, */ - /* "%sbehavior/default/grabs.db", e_config_user_dir()); */ + /* "%sbehavior/default/grabs.db", e_config_user_dir()); */ /* notice it would use the user config location instead */ /* but for now i'm keeping it as is for development "ease" */ @@ -54,39 +54,28 @@ e_config_get(char *type) } \ } - E_CONF("grabs", cfg_grabs_db, - "%s/behavior/grabs.db", e_config_user_dir()); + E_CONF("grabs", cfg_grabs_db, "%s/behavior/grabs.db", e_config_user_dir()); E_CONF("settings", cfg_settings_db, "%s/behavior/settings.db", e_config_user_dir()); E_CONF("actions", cfg_actions_db, "%s/behavior/actions.db", e_config_user_dir()); E_CONF("apps_menu", cfg_apps_menu_db, "%s/behavior/apps_menu.db", e_config_user_dir()); - E_CONF("match", cfg_match_db, - "%s/behavior/match.db", e_config_user_dir()); - E_CONF("borders", cfg_borders_db, - PACKAGE_DATA_DIR"/data/borders/"); - E_CONF("menus", cfg_menus_dir, - PACKAGE_DATA_DIR"/data/menus/"); - E_CONF("entries", cfg_entries_dir, - PACKAGE_DATA_DIR"/data/entries/"); + E_CONF("match", cfg_match_db, "%s/behavior/match.db", e_config_user_dir()); + E_CONF("borders", cfg_borders_db, PACKAGE_DATA_DIR "/data/borders/"); + E_CONF("menus", cfg_menus_dir, PACKAGE_DATA_DIR "/data/menus/"); + E_CONF("entries", cfg_entries_dir, PACKAGE_DATA_DIR "/data/entries/"); E_CONF("selections", cfg_selections_dir, - PACKAGE_DATA_DIR"/data/selections/"); + PACKAGE_DATA_DIR "/data/selections/"); E_CONF("scrollbars", cfg_scrollbars_dir, - PACKAGE_DATA_DIR"/data/scrollbars/"); - E_CONF("guides", cfg_guides_dir, - PACKAGE_DATA_DIR"/data/guides/"); - E_CONF("images", cfg_images_dir, - PACKAGE_DATA_DIR"/data/images/"); - E_CONF("cursors", cfg_cursors_dir, - PACKAGE_DATA_DIR"/data/cursors/"); + PACKAGE_DATA_DIR "/data/scrollbars/"); + E_CONF("guides", cfg_guides_dir, PACKAGE_DATA_DIR "/data/guides/"); + E_CONF("images", cfg_images_dir, PACKAGE_DATA_DIR "/data/images/"); + E_CONF("cursors", cfg_cursors_dir, PACKAGE_DATA_DIR "/data/cursors/"); E_CONF("backgrounds", cfg_backgrounds_dir, - PACKAGE_DATA_DIR"/data/backgrounds/"); - E_CONF("fonts", cfg_fonts_dir, - PACKAGE_DATA_DIR"/data/fonts/"); - E_CONF("epplets", cfg_epplets_dir, - PACKAGE_DATA_DIR"/data/epplets/"); - + PACKAGE_DATA_DIR "/data/backgrounds/"); + E_CONF("fonts", cfg_fonts_dir, PACKAGE_DATA_DIR "/data/fonts/"); + E_CONF("epplets", cfg_epplets_dir, PACKAGE_DATA_DIR "/data/epplets/"); D_RETURN_(""); } @@ -94,33 +83,41 @@ e_config_get(char *type) void e_config_init(void) { - char buf[PATH_MAX]; + char buf[PATH_MAX]; D_ENTER; -#if 1 /* for now don't do this. i think a cp -r will be needed later anyway */ - if (!e_file_is_dir(e_config_user_dir())) e_file_mkdir(e_config_user_dir()); - snprintf(buf, PATH_MAX, "%sappearance", e_config_user_dir()); - if (!e_file_is_dir(buf)) e_file_mkdir(buf); - snprintf(buf, PATH_MAX, "%sappearance/borders", e_config_user_dir()); - if (!e_file_is_dir(buf)) e_file_mkdir(buf); - snprintf(buf, PATH_MAX, "%sbehavior", e_config_user_dir()); - if (!e_file_is_dir(buf)) e_file_mkdir(buf); - snprintf(buf, PATH_MAX, "%sbehavior/grabs.db", e_config_user_dir()); +#if 1 /* for now don't do this. i think a cp -r will be needed later anyway */ + if (!e_file_is_dir(e_config_user_dir())) + e_file_mkdir(e_config_user_dir()); + snprintf(buf, PATH_MAX, "%sappearance", e_config_user_dir()); + if (!e_file_is_dir(buf)) + e_file_mkdir(buf); + snprintf(buf, PATH_MAX, "%sappearance/borders", e_config_user_dir()); + if (!e_file_is_dir(buf)) + e_file_mkdir(buf); + snprintf(buf, PATH_MAX, "%sbehavior", e_config_user_dir()); + if (!e_file_is_dir(buf)) + e_file_mkdir(buf); + snprintf(buf, PATH_MAX, "%sbehavior/grabs.db", e_config_user_dir()); if (!e_file_exists(buf)) - e_file_cp(PACKAGE_DATA_DIR"/data/config/behavior/default/grabs.db", buf); + e_file_cp(PACKAGE_DATA_DIR "/data/config/behavior/default/grabs.db", buf); snprintf(buf, PATH_MAX, "%sbehavior/settings.db", e_config_user_dir()); if (!e_file_exists(buf)) - e_file_cp(PACKAGE_DATA_DIR"/data/config/behavior/default/settings.db", buf); - snprintf(buf, PATH_MAX, "%sbehavior/actions.db", e_config_user_dir()); + e_file_cp(PACKAGE_DATA_DIR "/data/config/behavior/default/settings.db", + buf); + snprintf(buf, PATH_MAX, "%sbehavior/actions.db", e_config_user_dir()); if (!e_file_exists(buf)) - e_file_cp(PACKAGE_DATA_DIR"/data/config/behavior/default/actions.db", buf); - snprintf(buf, PATH_MAX, "%sbehavior/apps_menu.db", e_config_user_dir()); + e_file_cp(PACKAGE_DATA_DIR "/data/config/behavior/default/actions.db", + buf); + snprintf(buf, PATH_MAX, "%sbehavior/apps_menu.db", e_config_user_dir()); if (!e_file_exists(buf)) - e_file_cp(PACKAGE_DATA_DIR"/data/config/behavior/default/apps_menu.db", buf); - snprintf(buf, PATH_MAX, "%sappearance/borders/border.bits.db", e_config_user_dir()); + e_file_cp(PACKAGE_DATA_DIR "/data/config/behavior/default/apps_menu.db", + buf); + snprintf(buf, PATH_MAX, "%sappearance/borders/border.bits.db", + e_config_user_dir()); #endif -#if 0 +#if 0 ts(); #endif @@ -134,40 +131,42 @@ e_config_set_user_dir(char *dir) strcpy(cfg_root, dir); /* reset the cached dir paths */ - cfg_grabs_db[0] = 0; + cfg_grabs_db[0] = 0; cfg_settings_db[0] = 0; - cfg_actions_db[0] = 0; - cfg_borders_db[0] = 0; - cfg_apps_menu_db[0]= 0; - cfg_match_db[0]= 0; - cfg_menus_dir[0] = 0; + cfg_actions_db[0] = 0; + cfg_borders_db[0] = 0; + cfg_apps_menu_db[0] = 0; + cfg_match_db[0] = 0; + cfg_menus_dir[0] = 0; cfg_entries_dir[0] = 0; cfg_selections_dir[0] = 0; cfg_scrollbars_dir[0] = 0; cfg_guides_dir[0] = 0; - cfg_user_dir[0] = 0; - cfg_images_dir[0] = 0; + cfg_user_dir[0] = 0; + cfg_images_dir[0] = 0; cfg_cursors_dir[0] = 0; - cfg_backgrounds_dir[0] = 0; - cfg_fonts_dir[0] = 0; + cfg_backgrounds_dir[0] = 0; + cfg_fonts_dir[0] = 0; /* init again - if the user hasnt got all the data */ e_config_init(); D_RETURN; } -char * +char * e_config_user_dir(void) { D_ENTER; - if (cfg_user_dir[0]) D_RETURN_(cfg_user_dir); - if (cfg_root[0]) D_RETURN_(cfg_root); -#if 1 /* disabled for now - use system ones only */ + if (cfg_user_dir[0]) + D_RETURN_(cfg_user_dir); + if (cfg_root[0]) + D_RETURN_(cfg_root); +#if 1 /* disabled for now - use system ones only */ snprintf(cfg_user_dir, PATH_MAX, "%s/.e/", e_util_get_user_home()); -#else - snprintf(cfg_user_dir, PATH_MAX, PACKAGE_DATA_DIR"/data/config/"); -#endif +#else + snprintf(cfg_user_dir, PATH_MAX, PACKAGE_DATA_DIR "/data/config/"); +#endif D_RETURN_(cfg_user_dir); } @@ -176,12 +175,14 @@ typedef struct _e_config_file_entry E_Config_File_Entry; struct _e_config_file_entry { - char *name; - struct { - char *path; - time_t last_mod; - } user, system; - Evas_List hash[256]; + char *name; + struct + { + char *path; + time_t last_mod; + } + user , system; + Evas_List hash[256]; }; void @@ -204,41 +205,35 @@ e_config_val_float_get(char *file, char *key, float def) { } -char * +char * e_config_val_str_get(char *file, char *key, char *def) { } -char * +char * e_config_val_key_get(char *file, char *key, char *def) { } - - - void -e_config_type_add_node(E_Config_Base_Type *base, char *prefix, - E_Config_Datatype type, E_Config_Base_Type *list_type, - int offset, - int def_int, - float def_float, - char *def_str) +e_config_type_add_node(E_Config_Base_Type * base, char *prefix, + E_Config_Datatype type, E_Config_Base_Type * list_type, + int offset, int def_int, float def_float, char *def_str) { - E_Config_Node *cfg_node; - + E_Config_Node *cfg_node; + D_ENTER; cfg_node = NEW(E_Config_Node, 1); ZERO(cfg_node, E_Config_Node, 1); - - cfg_node->prefix = strdup(prefix); - cfg_node->type = type; - cfg_node->sub_type = list_type; - cfg_node->offset = offset; - cfg_node->def_int = def_int; + + cfg_node->prefix = strdup(prefix); + cfg_node->type = type; + cfg_node->sub_type = list_type; + cfg_node->offset = offset; + cfg_node->def_int = def_int; cfg_node->def_float = def_float; - if (cfg_node->def_str) + if (cfg_node->def_str) { e_strdup(cfg_node->def_str, def_str); } @@ -251,7 +246,7 @@ E_Config_Base_Type * e_config_type_new(void) { E_Config_Base_Type *t; - + D_ENTER; t = NEW(E_Config_Base_Type, 1); @@ -260,94 +255,98 @@ e_config_type_new(void) D_RETURN_(t); } -void * -e_config_load(char *file, char *prefix, E_Config_Base_Type *type) +void * +e_config_load(char *file, char *prefix, E_Config_Base_Type * type) { - E_DB_File *db; - char buf[PATH_MAX]; - Evas_List l; - char *data; - + E_DB_File *db; + char buf[PATH_MAX]; + Evas_List l; + char *data; + D_ENTER; - if (!e_file_exists(file)) D_RETURN_(NULL); + if (!e_file_exists(file)) + D_RETURN_(NULL); db = e_db_open_read(file); if (!db) - D_RETURN_(NULL); + D_RETURN_(NULL); data = NEW(char, type->size); - ZERO(data, char , type->size); + ZERO(data, char, type->size); + for (l = type->nodes; l; l = l->next) { - E_Config_Node *node; + E_Config_Node *node; node = l->data; - + switch (node->type) { - case E_CFG_TYPE_INT: - { - int val; - - val = 0; - snprintf(buf, PATH_MAX, "%s/%s", prefix, node->prefix); - if (e_db_int_get(db, buf, &val)) - (*((int *)(&(data[node->offset])))) = val; - else - (*((int *)(&(data[node->offset])))) = node->def_int; - } + case E_CFG_TYPE_INT: + { + int val; + + val = 0; + snprintf(buf, PATH_MAX, "%s/%s", prefix, node->prefix); + if (e_db_int_get(db, buf, &val)) + (*((int *)(&(data[node->offset])))) = val; + else + (*((int *)(&(data[node->offset])))) = node->def_int; + } break; - case E_CFG_TYPE_STR: - { - char *val; - - snprintf(buf, PATH_MAX, "%s/%s", prefix, node->prefix); - if ((val = e_db_str_get(db, buf))) - (*((char **)(&(data[node->offset])))) = val; - else - e_strdup((*((char **)(&(data[node->offset])))), node->def_str); - } + case E_CFG_TYPE_STR: + { + char *val; + + snprintf(buf, PATH_MAX, "%s/%s", prefix, node->prefix); + if ((val = e_db_str_get(db, buf))) + (*((char **)(&(data[node->offset])))) = val; + else + e_strdup((*((char **)(&(data[node->offset])))), + node->def_str); + } break; - case E_CFG_TYPE_FLOAT: - { - float val; - - val = 0; - snprintf(buf, PATH_MAX, "%s/%s", prefix, node->prefix); - if (e_db_float_get(db, buf, &val)) - (*((float *)(&(data[node->offset])))) = val; - else - (*((float *)(&(data[node->offset])))) = node->def_float; - } + case E_CFG_TYPE_FLOAT: + { + float val; + + val = 0; + snprintf(buf, PATH_MAX, "%s/%s", prefix, node->prefix); + if (e_db_float_get(db, buf, &val)) + (*((float *)(&(data[node->offset])))) = val; + else + (*((float *)(&(data[node->offset])))) = node->def_float; + } break; - case E_CFG_TYPE_LIST: - { - Evas_List l2; - int i, count; - - l2 = NULL; - snprintf(buf, PATH_MAX, "%s/%s/count", prefix, node->prefix); - count = 0; - e_db_int_get(db, buf, &count); - for (i = 0; i < count; i++) - { - void *data2; - - snprintf(buf, PATH_MAX, "%s/%s/%i", prefix, node->prefix, i); - data2 = e_config_load(file, buf, node->sub_type); - l2 = evas_list_append(l2, data2); - } - (*((Evas_List *)(&(data[node->offset])))) = l2; - } + case E_CFG_TYPE_LIST: + { + Evas_List l2; + int i, count; + + l2 = NULL; + snprintf(buf, PATH_MAX, "%s/%s/count", prefix, node->prefix); + count = 0; + e_db_int_get(db, buf, &count); + for (i = 0; i < count; i++) + { + void *data2; + + snprintf(buf, PATH_MAX, "%s/%s/%i", prefix, node->prefix, + i); + data2 = e_config_load(file, buf, node->sub_type); + l2 = evas_list_append(l2, data2); + } + (*((Evas_List *) (&(data[node->offset])))) = l2; + } break; - case E_CFG_TYPE_KEY: - { - snprintf(buf, PATH_MAX, "%s/%s", prefix, node->prefix); - (*((char **)(&(data[node->offset])))) = strdup(buf); - } + case E_CFG_TYPE_KEY: + { + snprintf(buf, PATH_MAX, "%s/%s", prefix, node->prefix); + (*((char **)(&(data[node->offset])))) = strdup(buf); + } break; - default: + default: break; } } @@ -356,69 +355,73 @@ e_config_load(char *file, char *prefix, E_Config_Base_Type *type) D_RETURN_(data); } - #if 0 typedef struct _list_base List_Base; typedef struct _list_element List_Element; struct _list_base { - Evas_List elements; + Evas_List elements; }; struct _list_element { - char *name; - int size; - float perc; + char *name; + int size; + float perc; }; /* eg: */ -void ts(void) +void +ts(void) { /* define the different config types and structs to the config engine */ E_Config_Base_Type *cf_list; E_Config_Base_Type *cf_element; - + D_ENTER; cf_element = e_config_type_new(); - E_CONFIG_NODE(cf_element, "name", E_CFG_TYPE_STR, NULL, List_Element, name, 0, 0, "DEFAULT_NAME"); - E_CONFIG_NODE(cf_element, "size", E_CFG_TYPE_INT, NULL, List_Element, size, 777, 0, NULL); - E_CONFIG_NODE(cf_element, "perc", E_CFG_TYPE_FLOAT, NULL, List_Element, perc, 0, 3.1415, NULL); - + E_CONFIG_NODE(cf_element, "name", E_CFG_TYPE_STR, NULL, List_Element, name, + 0, 0, "DEFAULT_NAME"); + E_CONFIG_NODE(cf_element, "size", E_CFG_TYPE_INT, NULL, List_Element, size, + 777, 0, NULL); + E_CONFIG_NODE(cf_element, "perc", E_CFG_TYPE_FLOAT, NULL, List_Element, perc, + 0, 3.1415, NULL); + cf_list = e_config_type_new(); - E_CONFIG_NODE(cf_list, "list", E_CFG_TYPE_LIST, cf_element, List_Base, elements, 0, 0, NULL); + E_CONFIG_NODE(cf_list, "list", E_CFG_TYPE_LIST, cf_element, List_Base, + elements, 0, 0, NULL); /* now test it */ - { - List_Base *cfg_data; - - /* load the base data type from the base of the test db file */ - cfg_data = e_config_load("test.db", "", cf_list); - /* no data file? */ - if (!cfg_data) - { - D("no load!\n"); - } - /* got data */ - else - { - Evas_List l; - - for (l = cfg_data->elements; l; l = l->next) - { - List_Element *cfg_element; - - D("element\n"); - cfg_element = l->data; - D("... name %s\n", cfg_element->name); - D("... size %i\n", cfg_element->size); - D("... perc %3.3f\n", cfg_element->perc); - } - } - exit(0); - } + { + List_Base *cfg_data; + + /* load the base data type from the base of the test db file */ + cfg_data = e_config_load("test.db", "", cf_list); + /* no data file? */ + if (!cfg_data) + { + D("no load!\n"); + } + /* got data */ + else + { + Evas_List l; + + for (l = cfg_data->elements; l; l = l->next) + { + List_Element *cfg_element; + + D("element\n"); + cfg_element = l->data; + D("... name %s\n", cfg_element->name); + D("... size %i\n", cfg_element->size); + D("... perc %3.3f\n", cfg_element->perc); + } + } + exit(0); + } D_RETURN; } diff --git a/src/config.h b/src/config.h index a1f9214cf..f2a166fed 100644 --- a/src/config.h +++ b/src/config.h @@ -3,8 +3,8 @@ #include "e.h" -typedef struct _E_Config_File E_Config_File; -typedef struct _E_Config_Element E_Config_Element; +typedef struct _E_Config_File E_Config_File; +typedef struct _E_Config_Element E_Config_Element; /* something to check validity of config files where we get data from */ /* for now its just a 5 second timout so it will only invalidate */ @@ -12,26 +12,26 @@ typedef struct _E_Config_Element E_Config_Element; /* we should use that to tell us when its invalid */ struct _E_Config_File { - char *src; - double last_fetch; + char *src; + double last_fetch; }; -struct _E_Config_Element +struct _E_Config_Element { - char *src; - char *key; - double last_fetch; - int type; - int def_int_val; - float def_float_val; - char *def_str_val; - void *def_data_val; - int def_data_val_size; - int cur_int_val; - float cur_float_val; - char *cur_str_val; - void *cur_data_val; - int cur_data_val_size; + char *src; + char *key; + double last_fetch; + int type; + int def_int_val; + float def_float_val; + char *def_str_val; + void *def_data_val; + int def_data_val_size; + int cur_int_val; + float cur_float_val; + char *cur_str_val; + void *cur_data_val; + int cur_data_val_size; }; #define E_CFG_FILE(_var, _src) \ @@ -47,12 +47,12 @@ _var.last_fetch = __time; } typedef enum e_config_type - { - E_CFG_INT_T, - E_CFG_FLOAT_T, - E_CFG_STR_T, - E_CFG_DATA_T, - } +{ + E_CFG_INT_T, + E_CFG_FLOAT_T, + E_CFG_STR_T, + E_CFG_DATA_T, +} E_Config_Type; #define E_CFG_INT(_var, _src, _key, _default) \ @@ -146,16 +146,15 @@ E_CFG_END_VALIDITY_CHECK \ _val = _var.cur_data_val; \ _size = _var.cur_data_size;} - -char *e_config_get(char *type); -void e_config_init(void); -void e_config_set_user_dir(char *dir); -char *e_config_user_dir(void); +char *e_config_get(char *type); +void e_config_init(void); +void e_config_set_user_dir(char *dir); +char *e_config_user_dir(void); typedef struct _e_config_base_type E_Config_Base_Type; -typedef struct _e_config_node E_Config_Node; -typedef struct _e_config_value E_Config_Value; -typedef enum _e_config_datatype E_Config_Datatype; +typedef struct _e_config_node E_Config_Node; +typedef struct _e_config_value E_Config_Value; +typedef enum _e_config_datatype E_Config_Datatype; enum _e_config_datatype { @@ -168,8 +167,8 @@ enum _e_config_datatype struct _e_config_base_type { - int size; - Evas_List nodes; + int size; + Evas_List nodes; }; struct _e_config_node @@ -197,26 +196,25 @@ struct _e_config_node var->size = sizeof(struct_type); \ } -E_Config_Value *e_config_value_get_int(E_Config_Value *handle, char *file, - char *prefix, char *key, - int *val_ret, int default_val); -E_Config_Value *e_config_value_get_str(E_Config_Value *handle, char *file, - char *prefix, char *key, - char **val_ret, char *default_val); -E_Config_Value *e_config_value_get_float(E_Config_Value *handle, char *file, - char *prefix, char *key, - float *val_ret, float default_val); +E_Config_Value *e_config_value_get_int(E_Config_Value * handle, char *file, + char *prefix, char *key, + int *val_ret, int default_val); +E_Config_Value *e_config_value_get_str(E_Config_Value * handle, char *file, + char *prefix, char *key, + char **val_ret, char *default_val); +E_Config_Value *e_config_value_get_float(E_Config_Value * handle, + char *file, char *prefix, + char *key, float *val_ret, + float default_val); E_Config_Base_Type *e_config_type_new(void); -void e_config_type_add_node(E_Config_Base_Type *base, +void e_config_type_add_node(E_Config_Base_Type * base, char *prefix, - E_Config_Datatype type, - E_Config_Base_Type *list_type, + E_Config_Datatype type, + E_Config_Base_Type * list_type, int offset, int def_int, - float def_float, - char *def_str); -void *e_config_load(char *file, - char *prefix, - E_Config_Base_Type *type); + float def_float, char *def_str); +void *e_config_load(char *file, + char *prefix, E_Config_Base_Type * type); #endif diff --git a/src/cursors.c b/src/cursors.c index b80d0677a..af10d8f18 100644 --- a/src/cursors.c +++ b/src/cursors.c @@ -8,35 +8,37 @@ typedef struct _e_cursor E_Cursor; struct _e_cursor { - char *type; - Cursor cursor; - time_t mod; + char *type; + Cursor cursor; + time_t mod; }; -static int cursor_change = 0; -static char *cur_cursor = NULL; -static char *prev_cursor = NULL; -static Evas_List cursors = NULL; +static int cursor_change = 0; +static char *cur_cursor = NULL; +static char *prev_cursor = NULL; +static Evas_List cursors = NULL; -static void e_cursors_idle(void *data); -static void e_cursors_set(char *type); -static E_Cursor * e_cursors_find(char *type); +static void e_cursors_idle(void *data); +static void e_cursors_set(char *type); +static E_Cursor *e_cursors_find(char *type); static void e_cursors_idle(void *data) { - int change = 0; + int change = 0; D_ENTER; - - if (!cursor_change) D_RETURN; + + if (!cursor_change) + D_RETURN; if ((prev_cursor) && (cur_cursor) && (strcmp(prev_cursor, cur_cursor))) - change = 1; + change = 1; if ((prev_cursor) && (!cur_cursor)) - change = 1; + change = 1; if ((!prev_cursor) && (cur_cursor)) - change = 1; - if (change) e_cursors_set(cur_cursor); + change = 1; + if (change) + e_cursors_set(cur_cursor); IF_FREE(prev_cursor); e_strdup(prev_cursor, cur_cursor); IF_FREE(cur_cursor); @@ -57,22 +59,22 @@ e_cursors_set(char *type) D_RETURN; } -static E_Cursor * +static E_Cursor * e_cursors_find(char *type) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = cursors; l; l = l->next) { - E_Cursor *c; - + E_Cursor *c; + c = l->data; - if (!strcmp(c->type, type)) + if (!strcmp(c->type, type)) { - char buf[PATH_MAX]; - + char buf[PATH_MAX]; + snprintf(buf, PATH_MAX, "%s/%s.db", e_config_get("cursors"), type); if (e_file_mod_time(buf) > c->mod) { @@ -91,63 +93,66 @@ e_cursors_find(char *type) void e_cursors_display_in_window(Window win, char *type) { - E_Cursor *c; + E_Cursor *c; D_ENTER; - if (!type) type = "Default"; + if (!type) + type = "Default"; c = e_cursors_find(type); if (!c) { - Pixmap pmap, mask; - int hx = 0, hy = 0; - int fr = 255, fg = 255, fb = 255; - int br = 0, bg = 0, bb = 0; - int w = 32, h = 32; - int ok; - char buf[PATH_MAX]; - Imlib_Image im; - + Pixmap pmap, mask; + int hx = 0, hy = 0; + int fr = 255, fg = 255, fb = 255; + int br = 0, bg = 0, bb = 0; + int w = 32, h = 32; + int ok; + char buf[PATH_MAX]; + Imlib_Image im; + c = NEW(E_Cursor, 1); ZERO(c, E_Cursor, 1); - + e_strdup(c->type, type); - + snprintf(buf, PATH_MAX, "%s/%s.db", e_config_get("cursors"), type); c->mod = e_file_mod_time(buf); E_DB_INT_GET(buf, "/cursor/x", hx, ok); E_DB_INT_GET(buf, "/cursor/y", hy, ok); - snprintf(buf, PATH_MAX, "%s/%s.db:/cursor/image", e_config_get("cursors"), type); + snprintf(buf, PATH_MAX, "%s/%s.db:/cursor/image", + e_config_get("cursors"), type); im = imlib_load_image(buf); if (im) { - DATA32 *data; - int x, y; - GC gcf, gcb; - int have_bg = 0, have_fg = 0; - + DATA32 *data; + int x, y; + GC gcf, gcb; + int have_bg = 0, have_fg = 0; + imlib_context_set_image(im); w = imlib_image_get_width(); h = imlib_image_get_height(); pmap = ecore_pixmap_new(0, w, h, 1); mask = ecore_pixmap_new(0, w, h, 1); data = imlib_image_get_data_for_reading_only(); - + /* figure out fg & bg */ - if (!data) goto done; + if (!data) + goto done; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { - int r, g, b, a; - DATA32 pix; - + int r, g, b, a; + DATA32 pix; + pix = data[(y * w) + x]; r = (pix >> 16) & 0xff; - g = (pix >> 8 ) & 0xff; - b = (pix ) & 0xff; + g = (pix >> 8) & 0xff; + b = (pix) & 0xff; a = (pix >> 24) & 0xff; - + if (a > 127) { if (!have_bg) @@ -159,7 +164,7 @@ e_cursors_display_in_window(Window win, char *type) } if (!have_fg) { - if ((have_bg) && + if ((have_bg) && ((br != r) || (bg != g) || (bb != b))) { fr = r; @@ -172,47 +177,48 @@ e_cursors_display_in_window(Window win, char *type) } } } - done: - + done: + /* FIXME: inefficient - using pixmaps and draw point... should */ /* use XImages & XShm */ - + /* get some gc's set up */ gcb = ecore_gc_new(pmap); gcf = ecore_gc_new(pmap); ecore_gc_set_fg(gcb, 0); ecore_gc_set_fg(gcf, 1); - + /* fill out cursor pixmap with 0's (bg) */ ecore_fill_rectangle(pmap, gcb, 0, 0, w, h); ecore_fill_rectangle(mask, gcb, 0, 0, w, h); - if (!data) goto done2; + if (!data) + goto done2; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { - int r, g, b, a; - DATA32 pix; - + int r, g, b, a; + DATA32 pix; + pix = data[(y * w) + x]; r = (pix >> 16) & 0xff; - g = (pix >> 8 ) & 0xff; - b = (pix ) & 0xff; + g = (pix >> 8) & 0xff; + b = (pix) & 0xff; a = (pix >> 24) & 0xff; - - if (a > 127) + + if (a > 127) { ecore_draw_point(mask, gcf, x, y); if ((r == fr) && (g == fg) && (b == fb)) - ecore_draw_point(pmap, gcf, x, y); + ecore_draw_point(pmap, gcf, x, y); } } } - done2: + done2: /* clean up */ ecore_gc_free(gcb); ecore_gc_free(gcf); - + imlib_image_put_back_data(data); imlib_free_image(); } @@ -222,19 +228,21 @@ e_cursors_display_in_window(Window win, char *type) FREE(c); c = NULL; } - if (c) + if (c) { - c->cursor = ecore_cursor_new(pmap, mask, hx, hy, fr, fg, fb, br, bg, bb); + c->cursor = + ecore_cursor_new(pmap, mask, hx, hy, fr, fg, fb, br, bg, bb); ecore_pixmap_free(pmap); ecore_pixmap_free(mask); cursors = evas_list_append(cursors, c); } } if (c) - ecore_cursor_set(win, c->cursor); + ecore_cursor_set(win, c->cursor); else { - if (!strcmp(type, "Default")) D_RETURN; + if (!strcmp(type, "Default")) + D_RETURN; e_cursors_display_in_window(win, "Default"); } diff --git a/src/cursors.h b/src/cursors.h index 389cc73a4..bcb61ec04 100644 --- a/src/cursors.h +++ b/src/cursors.h @@ -3,9 +3,8 @@ #include "e.h" -void e_cursors_display(char *type); -void e_cursors_display_in_window(Window win, char *type); -void e_cursors_init(void); +void e_cursors_display(char *type); +void e_cursors_display_in_window(Window win, char *type); +void e_cursors_init(void); #endif - diff --git a/src/debug.c b/src/debug.c index 6ee375d0d..b486d1dfa 100644 --- a/src/debug.c +++ b/src/debug.c @@ -33,63 +33,56 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "debug.h" +static int do_print = 0; +static int calldepth = 0; -static int do_print = 0; -static int calldepth = 0; +static void debug_whitespace(int calldepth); +static void debug_print_info(void); -static void debug_whitespace(int calldepth); -static void debug_print_info(void); - -static void +static void debug_whitespace(int calldepth) { - int i; - - for (i = 0; i < 2*calldepth; i++) - printf("-"); + int i; + + for (i = 0; i < 2 * calldepth; i++) + printf("-"); } - -static void +static void debug_print_info(void) { - printf("e17 dbg: "); + printf("e17 dbg: "); } - - void e_debug_enter(const char *file, const char *func) { - if (do_print) - { - calldepth++; - - printf("ENTER "); - debug_print_info(); - debug_whitespace(calldepth); - printf("%s, %s()\n", file, func); - fflush(stdout); - } -} + if (do_print) + { + calldepth++; + printf("ENTER "); + debug_print_info(); + debug_whitespace(calldepth); + printf("%s, %s()\n", file, func); + fflush(stdout); + } +} void e_debug_return(const char *file, const char *func) { - if (do_print) - { - printf("RETURN "); - debug_print_info(); - debug_whitespace(calldepth); - printf("%s, %s()\n", file, func); - fflush(stdout); - - calldepth--; - - if (calldepth < 0) - printf("NEGATIVE!!!\n"); - } + if (do_print) + { + printf("RETURN "); + debug_print_info(); + debug_whitespace(calldepth); + printf("%s, %s()\n", file, func); + fflush(stdout); + + calldepth--; + + if (calldepth < 0) + printf("NEGATIVE!!!\n"); + } } - - diff --git a/src/debug.h b/src/debug.h index 5f0bbf76e..17e91bd21 100644 --- a/src/debug.h +++ b/src/debug.h @@ -41,8 +41,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef DEBUG_NEST -void e_debug_enter(const char *file, const char *func); -void e_debug_return(const char *file, const char *func); +void e_debug_enter(const char *file, const char *func); +void e_debug_return(const char *file, const char *func); #define D_ENTER e_debug_enter(__FILE__, __FUNCTION__) @@ -64,5 +64,4 @@ void e_debug_return(const char *file, const char *func); #define D_RETURN_(x) return (x) #endif -#endif - +#endif diff --git a/src/delayed.c b/src/delayed.c index d80b84b96..df0637ec8 100644 --- a/src/delayed.c +++ b/src/delayed.c @@ -3,43 +3,40 @@ #include "delayed.h" static void -e_delayed_action_cleanup(E_Delayed_Action *eda) +e_delayed_action_cleanup(E_Delayed_Action * eda) { - D_ENTER; + D_ENTER; - e_delayed_action_cancel(eda); - e_observer_cleanup(E_OBSERVER(eda)); + e_delayed_action_cancel(eda); + e_observer_cleanup(E_OBSERVER(eda)); - D_RETURN; + D_RETURN; } - -E_Delayed_Action * -e_delayed_action_new(E_Event_Type event, - double delay, E_Delay_Func delay_func) +E_Delayed_Action * +e_delayed_action_new(E_Event_Type event, double delay, E_Delay_Func delay_func) { - E_Delayed_Action *eda = NULL; + E_Delayed_Action *eda = NULL; - D_ENTER; + D_ENTER; - eda = NEW(E_Delayed_Action, 1); - memset(eda, 0, sizeof(E_Delayed_Action)); + eda = NEW(E_Delayed_Action, 1); + memset(eda, 0, sizeof(E_Delayed_Action)); - e_observer_init(E_OBSERVER(eda), event, e_delayed_action_start, - (E_Cleanup_Func) e_delayed_action_cleanup); + e_observer_init(E_OBSERVER(eda), event, e_delayed_action_start, + (E_Cleanup_Func) e_delayed_action_cleanup); - eda->delay = delay; - eda->delay_func = delay_func; + eda->delay = delay; + eda->delay_func = delay_func; - D_RETURN_(eda); + D_RETURN_(eda); } - void -e_delayed_action_start(E_Observer *obs, E_Observee *obj, E_Event_Type event) +e_delayed_action_start(E_Observer * obs, E_Observee * obj, E_Event_Type event) { - char event_name[PATH_MAX]; - E_Delayed_Action *eda = (E_Delayed_Action*) obs; + char event_name[PATH_MAX]; + E_Delayed_Action *eda = (E_Delayed_Action *) obs; D_ENTER; @@ -49,17 +46,16 @@ e_delayed_action_start(E_Observer *obs, E_Observee *obj, E_Event_Type event) D_RETURN; } - void -e_delayed_action_cancel(E_Delayed_Action *eda) +e_delayed_action_cancel(E_Delayed_Action * eda) { - char event_name[PATH_MAX]; + char event_name[PATH_MAX]; D_ENTER; - snprintf(event_name, PATH_MAX, "_e_delayed_action_notify(%d)", E_OBSERVER(eda)->event); + snprintf(event_name, PATH_MAX, "_e_delayed_action_notify(%d)", + E_OBSERVER(eda)->event); ecore_del_event_timer(event_name); D_RETURN; } - diff --git a/src/delayed.h b/src/delayed.h index 9bf3e02ca..c6c3a0f16 100644 --- a/src/delayed.h +++ b/src/delayed.h @@ -4,23 +4,23 @@ #include "e.h" #include "observer.h" -typedef void (*E_Delay_Func)(int val, void *obj); +typedef void (*E_Delay_Func) (int val, void *obj); typedef struct _e_delayed_action { - E_Observer obs; + E_Observer obs; - double delay; - E_Delay_Func delay_func; + double delay; + E_Delay_Func delay_func; -} E_Delayed_Action; +} +E_Delayed_Action; +E_Delayed_Action *e_delayed_action_new(E_Event_Type event, + double delay, E_Delay_Func delay_func); -E_Delayed_Action *e_delayed_action_new(E_Event_Type event, - double delay, E_Delay_Func delay_func); - -void e_delayed_action_start(E_Observer *obs, E_Observee *obj, E_Event_Type event); -void e_delayed_action_cancel(E_Delayed_Action *eda); +void e_delayed_action_start(E_Observer * obs, E_Observee * obj, + E_Event_Type event); +void e_delayed_action_cancel(E_Delayed_Action * eda); #endif - diff --git a/src/desktops.c b/src/desktops.c index 7cdae52a4..8a5349de6 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -9,11 +9,11 @@ #include "object.h" #include "e_view_machine.h" -static Evas_List desktops = NULL; -static Window e_base_win = 0; -static int screen_w, screen_h; +static Evas_List desktops = NULL; +static Window e_base_win = 0; +static int screen_w, screen_h; -static void ecore_idle(void *data); +static void ecore_idle(void *data); static void ecore_idle(void *data) @@ -29,8 +29,8 @@ ecore_idle(void *data) void e_desktops_init(void) { - E_Desktop *desk; - + E_Desktop *desk; + D_ENTER; ecore_window_get_geometry(0, NULL, NULL, &screen_w, &screen_h); @@ -39,13 +39,13 @@ e_desktops_init(void) desk = e_desktops_new(); e_desktops_show(desk); ecore_event_filter_idle_handler_add(ecore_idle, NULL); - + e_icccm_advertise_e_compat(); e_icccm_advertise_mwm_compat(); e_icccm_advertise_gnome_compat(); e_icccm_advertise_kde_compat(); e_icccm_advertise_net_compat(); - + e_icccm_set_desk_area_size(0, 1, 1); e_icccm_set_desk_area(0, 0, 0); e_icccm_set_desk(0, 0); @@ -54,16 +54,17 @@ e_desktops_init(void) } void -e_desktops_scroll(E_Desktop *desk, int dx, int dy) +e_desktops_scroll(E_Desktop * desk, int dx, int dy) { - Evas_List l; - int xd, yd, wd, hd; - int grav, grav_stick; - + Evas_List l; + int xd, yd, wd, hd; + int grav, grav_stick; + D_ENTER; /* set grav */ - if ((dx ==0) && (dy == 0)) D_RETURN; + if ((dx == 0) && (dy == 0)) + D_RETURN; desk->x -= dx; desk->y -= dy; xd = yd = wd = hd = 0; @@ -107,41 +108,40 @@ e_desktops_scroll(E_Desktop *desk, int dx, int dy) } for (l = desk->windows; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; /* if sticky */ - if ((b->client.sticky) && (!b->mode.move)) - ecore_window_gravity_set(b->win.main, StaticGravity); + if ((b->client.sticky) && (!b->mode.move)) + ecore_window_gravity_set(b->win.main, StaticGravity); else - ecore_window_gravity_set(b->win.main, grav); + ecore_window_gravity_set(b->win.main, grav); } grav_stick = StaticGravity; /* scroll */ - ecore_window_move_resize(desk->win.container, - xd, yd, - screen_w + wd, screen_h + hd); + ecore_window_move_resize(desk->win.container, + xd, yd, screen_w + wd, screen_h + hd); /* reset */ for (l = desk->windows; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; /* if sticky */ if (b->client.sticky) - ecore_window_gravity_set(b->win.main, StaticGravity); + ecore_window_gravity_set(b->win.main, StaticGravity); else - ecore_window_gravity_set(b->win.main, grav_stick); + ecore_window_gravity_set(b->win.main, grav_stick); /* ecore_window_gravity_set(b->win.main, grav_stick);*/ - } + } ecore_window_move_resize(desk->win.container, 0, 0, screen_w, screen_h); for (l = desk->windows; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; ecore_window_gravity_reset(b->win.main); - if ((!b->client.sticky) && (!b->mode.move)) + if ((!b->client.sticky) && (!b->mode.move)) { b->current.requested.x += dx; b->current.requested.y += dy; @@ -159,37 +159,37 @@ e_desktops_scroll(E_Desktop *desk, int dx, int dy) } void -e_desktops_cleanup(E_Desktop *desk) +e_desktops_cleanup(E_Desktop * desk) { D_ENTER; while (desk->windows) { - E_Border *b; - + E_Border *b; + b = desk->windows->data; e_action_stop_by_object(E_OBJECT(b), NULL, 0, 0, 0, 0); if (e_object_get_usecount(E_OBJECT(b)) == 1) - e_border_release(b); + e_border_release(b); e_object_unref(E_OBJECT(b)); } ecore_window_destroy(desk->win.main); IF_FREE(desk->name); IF_FREE(desk->dir); - + e_object_cleanup(E_OBJECT(desk)); D_RETURN; } void -e_desktops_init_file_display(E_Desktop *desk) +e_desktops_init_file_display(E_Desktop * desk) { - E_View *v; - E_Border *b; - char buf[PATH_MAX]; + E_View *v; + E_Border *b; + char buf[PATH_MAX]; D_ENTER; @@ -223,27 +223,30 @@ e_desktops_init_file_display(E_Desktop *desk) b->client.fixed = 1; b->client.is_desktop = 1; - if (v->options.back_pixmap) e_view_update(v); + if (v->options.back_pixmap) + e_view_update(v); D_RETURN; } -E_Desktop * +E_Desktop * e_desktops_new(void) { - E_Desktop *desk; - + E_Desktop *desk; + D_ENTER; - + desk = NEW(E_Desktop, 1); ZERO(desk, E_Desktop, 1); - + e_observee_init(E_OBSERVEE(desk), (E_Cleanup_Func) e_desktops_cleanup); - - desk->win.main = ecore_window_override_new(e_base_win, 0, 0, screen_w, screen_h); - desk->win.container = ecore_window_override_new(desk->win.main, 0, 0, screen_w, screen_h); + + desk->win.main = + ecore_window_override_new(e_base_win, 0, 0, screen_w, screen_h); + desk->win.container = + ecore_window_override_new(desk->win.main, 0, 0, screen_w, screen_h); ecore_window_lower(desk->win.container); - + ecore_window_show(desk->win.container); desk->x = 0; @@ -252,18 +255,19 @@ e_desktops_new(void) desk->real.h = screen_h; desk->virt.w = screen_w; desk->virt.h = screen_h; - + desktops = evas_list_append(desktops, desk); - + D_RETURN_(desk); } void -e_desktops_add_border(E_Desktop *d, E_Border *b) +e_desktops_add_border(E_Desktop * d, E_Border * b) { D_ENTER; - if ((!d) || (!b)) D_RETURN; + if ((!d) || (!b)) + D_RETURN; b->desk = d; b->client.desk = d->desk.desk; b->client.area.x = d->desk.area.x; @@ -274,11 +278,12 @@ e_desktops_add_border(E_Desktop *d, E_Border *b) } void -e_desktops_del_border(E_Desktop *d, E_Border *b) +e_desktops_del_border(E_Desktop * d, E_Border * b) { D_ENTER; - if ((!d) || (!b)) D_RETURN; + if ((!d) || (!b)) + D_RETURN; d->windows = evas_list_remove(d->windows, b); b->desk = NULL; @@ -286,7 +291,7 @@ e_desktops_del_border(E_Desktop *d, E_Border *b) } void -e_desktops_delete(E_Desktop *d) +e_desktops_delete(E_Desktop * d) { D_ENTER; @@ -296,7 +301,7 @@ e_desktops_delete(E_Desktop *d) } void -e_desktops_show(E_Desktop *d) +e_desktops_show(E_Desktop * d) { D_ENTER; @@ -306,7 +311,7 @@ e_desktops_show(E_Desktop *d) } void -e_desktops_hide(E_Desktop *d) +e_desktops_hide(E_Desktop * d) { D_ENTER; @@ -322,18 +327,18 @@ e_desktops_get_num(void) D_RETURN_(8); } -E_Desktop * +E_Desktop * e_desktops_get(int d) { - Evas_List l; - int i; - + Evas_List l; + int i; + D_ENTER; for (i = 0, l = desktops; l; l = l->next, i++) { - if (i == d) - D_RETURN_((E_Desktop *)l->data); + if (i == d) + D_RETURN_((E_Desktop *) l->data); } D_RETURN_(NULL); @@ -342,13 +347,13 @@ e_desktops_get(int d) int e_desktops_get_current(void) { - E_Desktop *desk; + E_Desktop *desk; D_ENTER; desk = e_desktops_get(0); if (desk) - D_RETURN_(desk->desk.desk); + D_RETURN_(desk->desk.desk); D_RETURN_(0); } @@ -359,7 +364,6 @@ e_desktops_goto_desk(int d) D_ENTER; e_desktops_goto(d, 0, 0); - D_RETURN; } @@ -367,29 +371,30 @@ e_desktops_goto_desk(int d) void e_desktops_goto(int d, int ax, int ay) { - E_Desktop *desk; - + E_Desktop *desk; + D_ENTER; desk = e_desktops_get(0); if (desk) { - int dx, dy; - Evas_List l; - + int dx, dy; + Evas_List l; + if ((d == desk->desk.desk) && - (ax == desk->desk.area.x) && - (ay == desk->desk.area.y)) D_RETURN; - + (ax == desk->desk.area.x) && (ay == desk->desk.area.y)) + D_RETURN; + dx = ax - desk->desk.area.x; dy = ay - desk->desk.area.y; - + for (l = desk->windows; l; l = l->next) { - E_Border *b; - + E_Border *b; + b = l->data; - if ((!b->client.sticky) && (!b->mode.move) && (!b->client.iconified)) + if ((!b->client.sticky) && (!b->mode.move) + && (!b->client.iconified)) { if (b->client.desk != d) { @@ -410,18 +415,18 @@ e_desktops_goto(int d, int ax, int ay) } } e_border_update_borders(); - + /* if no scrolling... */ e_desktops_scroll(desk, -(dx * desk->real.w), -(dy * desk->real.h)); /* if scrolling.. need to setup a timeout etc. */ - + desk->desk.desk = d; desk->desk.area.x = ax; desk->desk.area.y = ay; e_icccm_set_desk_area(0, desk->desk.area.x, desk->desk.area.y); e_icccm_set_desk(0, desk->desk.desk); e_observee_notify_observers(E_OBSERVEE(desk), E_EVENT_DESKTOP_SWITCH); - } + } D_RETURN; } @@ -432,4 +437,3 @@ e_desktops_get_desktops_list() D_ENTER; D_RETURN_(desktops); } - diff --git a/src/desktops.h b/src/desktops.h index 6ab06b837..17c60c9bf 100644 --- a/src/desktops.h +++ b/src/desktops.h @@ -8,32 +8,40 @@ #ifndef E_DESKTOPS_TYPEDEF #define E_DESKTOPS_TYPEDEF -typedef struct _E_Desktop E_Desktop; +typedef struct _E_Desktop E_Desktop; #endif struct _E_Desktop { - E_Observee obs; - - char *name; - char *dir; - struct { - Window main; - Window container; - } win; - int x, y; - struct { - int w, h; - } real, virt; - Evas_List windows; - struct { - int desk; - struct { - int x, y; - } area; - } desk; - E_View *view; - int changed; + E_Observee obs; + + char *name; + char *dir; + struct + { + Window main; + Window container; + } + win; + int x, y; + struct + { + int w, h; + } + real , virt; + Evas_List windows; + struct + { + int desk; + struct + { + int x, y; + } + area; + } + desk; + E_View *view; + int changed; }; /** @@ -44,10 +52,10 @@ struct _E_Desktop * the loading of background graphics information. It also makes * sure E rregisters itself as being compatible to GNOME, KDE etc. */ -void e_desktops_init(void); +void e_desktops_init(void); -void e_desktops_scroll(E_Desktop *desk, int dx, int dy); -void e_desktops_free(E_Desktop *desk); +void e_desktops_scroll(E_Desktop * desk, int dx, int dy); +void e_desktops_free(E_Desktop * desk); /** * e_desktops_init_file_display - Loads desktop graphics information @@ -56,19 +64,19 @@ void e_desktops_free(E_Desktop *desk); * This function loads the desktop's graphics from the user's desktop * file definition, which lives in ~/.e/desktop/default/.e_background.bg.db. */ -void e_desktops_init_file_display(E_Desktop *desk); +void e_desktops_init_file_display(E_Desktop * desk); -E_Desktop *e_desktops_new(void); -void e_desktops_add_border(E_Desktop *d, E_Border *b); -void e_desktops_del_border(E_Desktop *d, E_Border *b); -void e_desktops_delete(E_Desktop *d); -void e_desktops_show(E_Desktop *d); -void e_desktops_hide(E_Desktop *d); +E_Desktop *e_desktops_new(void); +void e_desktops_add_border(E_Desktop * d, E_Border * b); +void e_desktops_del_border(E_Desktop * d, E_Border * b); +void e_desktops_delete(E_Desktop * d); +void e_desktops_show(E_Desktop * d); +void e_desktops_hide(E_Desktop * d); /** * e_desktops_get_num - Returns number of desktops. */ -int e_desktops_get_num(void); +int e_desktops_get_num(void); /** * e_desktops_get - Returns nth desktop @@ -78,11 +86,11 @@ int e_desktops_get_num(void); * returns the nth of those desktops, NULL if no desktop * was found at that index. */ -E_Desktop *e_desktops_get(int d); +E_Desktop *e_desktops_get(int d); -int e_desktops_get_current(void); -void e_desktops_goto_desk(int d); -void e_desktops_goto(int d, int ax, int ay); -Evas_List e_desktops_get_desktops_list(); +int e_desktops_get_current(void); +void e_desktops_goto_desk(int d); +void e_desktops_goto(int d, int ax, int ay); +Evas_List e_desktops_get_desktops_list(); #endif diff --git a/src/e.h b/src/e.h index bc937a640..96c606f9d 100644 --- a/src/e.h +++ b/src/e.h @@ -44,14 +44,16 @@ backtrace_symbols_fd(__BT_array, __BT_n, fileno(stdout)); \ /* macros for allowing sections of code to be runtime profiled */ #define E_PROF 1 #ifdef E_PROF -extern Evas_List __e_profiles; +extern Evas_List __e_profiles; typedef struct _e_prof { - char *func; - double total; - double t1, t2; -} E_Prof; + char *func; + double total; + double t1, t2; +} +E_Prof; + #define E_PROF_START(_prof_func) \ { \ E_Prof __p, *__pp; \ diff --git a/src/e_ferite.c b/src/e_ferite.c index 2d56e5012..e11769e5b 100644 --- a/src/e_ferite.c +++ b/src/e_ferite.c @@ -4,7 +4,7 @@ #include "debug.h" #if 0 -#ifdef D /* until ferite doesn't pullte the D(ebug) macro */ +#ifdef D /* until ferite doesn't pullte the D(ebug) macro */ # undef D # define D(x,...) # define D_ENTER @@ -13,59 +13,64 @@ #endif #endif -void e_ferite_init(void) +void +e_ferite_init(void) { D_ENTER; - D( "Initialising ferite....\n" ); - ferite_init( 0, NULL ); + D("Initialising ferite....\n"); + ferite_init(0, NULL); D_RETURN; } -void e_ferite_deinit(void) +void +e_ferite_deinit(void) { D_ENTER; - D( "Deinitialising ferite....\n" ); + D("Deinitialising ferite....\n"); ferite_deinit(); - + D_RETURN; } -int e_ferite_script_error( FeriteScript *script, char *errmsg, int val ) +int +e_ferite_script_error(FeriteScript * script, char *errmsg, int val) { D_ENTER; - fprintf( stderr, "e17: ferite error: %s\n", errmsg ); + fprintf(stderr, "e17: ferite error: %s\n", errmsg); D_RETURN_(1); } -int e_ferite_script_warning( FeriteScript *script, char *warnmsg ) +int +e_ferite_script_warning(FeriteScript * script, char *warnmsg) { D_ENTER; - fprintf( stderr, "e17: ferite warning: %s\n", warnmsg ); + fprintf(stderr, "e17: ferite warning: %s\n", warnmsg); D_RETURN_(1); } -void e_ferite_run( char *txt ) +void +e_ferite_run(char *txt) { - FeriteScript *script = NULL; - + FeriteScript *script = NULL; + D_ENTER; - + D("Ferite: Compiling script `%s'\n", txt); - script = __ferite_compile_string( txt ); - e_ferite_register( script, script->mainns ); + script = __ferite_compile_string(txt); + e_ferite_register(script, script->mainns); script->error_cb = e_ferite_script_error; script->warning_cb = e_ferite_script_warning; D("Ferite: executing script.\n"); - ferite_script_execute( script ); + ferite_script_execute(script); D("Ferite: Cleaning up.\n"); - ferite_script_delete( script ); + ferite_script_delete(script); D_RETURN; } diff --git a/src/e_ferite.h b/src/e_ferite.h index b6a015d4e..9c4d2d62f 100644 --- a/src/e_ferite.h +++ b/src/e_ferite.h @@ -17,11 +17,14 @@ #endif -void e_ferite_init(void); -void e_ferite_deinit(void); -void e_ferite_run( char *script ); -void e_ferite_register( FeriteScript *script, FeriteNamespace *ns ); -int e_ferite_script_error( FeriteScript *script, char *errmsg, int val ); -int e_ferite_script_warning( FeriteScript *script, char *warnmsg ); +void e_ferite_init(void); +void e_ferite_deinit(void); +void e_ferite_run(char *script); +void e_ferite_register(FeriteScript * script, + FeriteNamespace * ns); +int e_ferite_script_error(FeriteScript * script, char *errmsg, + int val); +int e_ferite_script_warning(FeriteScript * script, + char *warnmsg); #endif /* E_FERITE_H */ diff --git a/src/e_file.c b/src/e_file.c index 0c03a642e..e20de6941 100644 --- a/src/e_file.c +++ b/src/e_file.c @@ -3,16 +3,15 @@ #include "file.h" #include "util.h" -static void e_file_cleanup (E_File *f); +static void e_file_cleanup(E_File * f); static void -e_file_cleanup(E_File *f) +e_file_cleanup(E_File * f) { D_ENTER; IF_FREE(f->info.icon); - IF_FREE(f->info.link) - IF_FREE(f->info.custom_icon); + IF_FREE(f->info.link) IF_FREE(f->info.custom_icon); IF_FREE(f->info.mime.base); IF_FREE(f->info.mime.type); IF_FREE(f->file); @@ -21,19 +20,19 @@ e_file_cleanup(E_File *f) D_RETURN; } -E_File * +E_File * e_file_new(char *file) { - E_File *f; + E_File *f; + D_ENTER; if (!file || *file == 0) - D_RETURN_(NULL); + D_RETURN_(NULL); f = NEW(E_File, 1); - - e_object_init(E_OBJECT(f), - (E_Cleanup_Func) e_file_cleanup); + + e_object_init(E_OBJECT(f), (E_Cleanup_Func) e_file_cleanup); f->info.icon = NULL; f->info.link = NULL; @@ -41,60 +40,58 @@ e_file_new(char *file) f->info.mime.base = NULL; f->info.mime.type = NULL; f->file = strdup(file); - - D_RETURN_(f); + + D_RETURN_(f); } -E_File * +E_File * e_file_get_by_name(Evas_List l, char *file) { - Evas_List ll; - E_File *f; + Evas_List ll; + E_File *f; D_ENTER; if (!l || !file || *file == 0) - D_RETURN_(NULL); + D_RETURN_(NULL); - for (ll=l; ll; ll=ll->next) - { - f = (E_File*) ll->data; + for (ll = l; ll; ll = ll->next) + { + f = (E_File *) ll->data; - if (!strcmp(file, f->file)) - { - D_RETURN_(f); - } - } + if (!strcmp(file, f->file)) + { + D_RETURN_(f); + } + } D_RETURN_(NULL); } void -e_file_set_mime(E_File *f, char *base, char *mime) +e_file_set_mime(E_File * f, char *base, char *mime) { - char icon[PATH_MAX]; - char type[PATH_MAX]; - char *p; + char icon[PATH_MAX]; + char type[PATH_MAX]; + char *p; D_ENTER; if (!f || !base || !mime) - D_RETURN; + D_RETURN; D("Setting mime: %40s: %s/%s\n", f->file, base, mime); - - if ( ((f->info.mime.base) && !(strcmp(f->info.mime.base, base))) - &&((f->info.mime.type) && !(strcmp(f->info.mime.type, mime)))) - D_RETURN; + if (((f->info.mime.base) && !(strcmp(f->info.mime.base, base))) + && ((f->info.mime.type) && !(strcmp(f->info.mime.type, mime)))) + D_RETURN; IF_FREE(f->info.mime.base); IF_FREE(f->info.mime.type); - + f->info.mime.base = strdup(base); f->info.mime.type = strdup(mime); - - + /* effect changes here */ /* * if (f->info.custom_icon) @@ -107,40 +104,41 @@ e_file_set_mime(E_File *f, char *base, char *mime) * D_RETURN; * } */ - + /* find an icon */ strcpy(type, f->info.mime.type); - p=type; - do - { - snprintf(icon, PATH_MAX, "%s/data/icons/%s/%s.db", - PACKAGE_DATA_DIR, f->info.mime.base, type); - p = strrchr(type, '/'); - if (p) *p = 0; - } + p = type; + do + { + snprintf(icon, PATH_MAX, "%s/data/icons/%s/%s.db", + PACKAGE_DATA_DIR, f->info.mime.base, type); + p = strrchr(type, '/'); + if (p) + *p = 0; + } while (p && !e_file_exists(icon)); - - /* fallback to base type icon */ - if (!e_file_exists(icon)) - snprintf(icon, PATH_MAX, "%s/data/icons/%s/default.db", - PACKAGE_DATA_DIR, f->info.mime.base); - /* still no luck fall back to default */ + + /* fallback to base type icon */ + if (!e_file_exists(icon)) + snprintf(icon, PATH_MAX, "%s/data/icons/%s/default.db", + PACKAGE_DATA_DIR, f->info.mime.base); + /* still no luck fall back to default */ if (!e_file_exists(icon)) snprintf(icon, PATH_MAX, "%s/data/icons/unknown/default.db", PACKAGE_DATA_DIR); f->info.icon = strdup(icon); - + D_RETURN; } void -e_file_set_link(E_File *f, char *link) +e_file_set_link(E_File * f, char *link) { D_ENTER; if (!f) - D_RETURN; + D_RETURN; if ((!link) && (f->info.link)) { diff --git a/src/e_file.h b/src/e_file.h index c477bbf11..61c2801c6 100644 --- a/src/e_file.h +++ b/src/e_file.h @@ -3,28 +3,32 @@ #include "object.h" #include -typedef struct _E_File E_File; +typedef struct _E_File E_File; struct _E_File { - E_Object o; - - char *file; - struct stat stat; - - struct { - char *icon; - char *custom_icon; - char *link; - struct { - char *base; - char *type; - } mime; - } info; + E_Object o; + + char *file; + struct stat stat; + + struct + { + char *icon; + char *custom_icon; + char *link; + struct + { + char *base; + char *type; + } + mime; + } + info; }; -E_File *e_file_new(char *file); -E_File *e_file_get_by_name(Evas_List l, char *file); -void e_file_set_mime(E_File *f, char *base, char *mime); -void e_file_set_link(E_File *f, char *link); +E_File *e_file_new(char *file); +E_File *e_file_get_by_name(Evas_List l, char *file); +void e_file_set_mime(E_File * f, char *base, char *mime); +void e_file_set_link(E_File * f, char *link); #endif diff --git a/src/e_view_machine.c b/src/e_view_machine.c index 784e27f7a..c0794c07c 100644 --- a/src/e_view_machine.c +++ b/src/e_view_machine.c @@ -9,21 +9,21 @@ void e_view_machine_init() { D_ENTER; - + if (VM == NULL) { - VM = NEW(E_View_Model, 1); - VM->views = NULL; - VM->models = NULL; - e_view_init(); - e_view_model_init(); + VM = NEW(E_View_Model, 1); + VM->views = NULL; + VM->models = NULL; + e_view_init(); + e_view_model_init(); } D_RETURN; } void -e_view_machine_register_view_model (E_View_Model *m) +e_view_machine_register_view_model(E_View_Model * m) { D_ENTER; VM->models = evas_list_append(VM->models, m); @@ -31,7 +31,7 @@ e_view_machine_register_view_model (E_View_Model *m) } void -e_view_machine_unregister_view_model(E_View_Model *m) +e_view_machine_unregister_view_model(E_View_Model * m) { D_ENTER; VM->models = evas_list_remove(VM->models, m); @@ -39,7 +39,7 @@ e_view_machine_unregister_view_model(E_View_Model *m) } void -e_view_machine_register_view(E_View *v) +e_view_machine_register_view(E_View * v) { D_ENTER; VM->views = evas_list_append(VM->views, v); @@ -47,7 +47,7 @@ e_view_machine_register_view(E_View *v) } void -e_view_machine_unregister_view(E_View *v) +e_view_machine_unregister_view(E_View * v) { D_ENTER; VM->views = evas_list_remove(VM->views, v); @@ -57,72 +57,77 @@ e_view_machine_unregister_view(E_View *v) void e_view_machine_close_all_views(void) { - Evas_List l; + Evas_List l; + D_ENTER; /* Copy the list of views and unregister them */ - for (l=VM->views;l;l=l->next) - { - E_View *v = l->data; - e_object_unref (E_OBJECT(v->model)); - } + for (l = VM->views; l; l = l->next) + { + E_View *v = l->data; + + e_object_unref(E_OBJECT(v->model)); + } D_RETURN; } -E_View_Model * +E_View_Model * e_view_machine_model_lookup(char *path) { - E_View_Model *m; - Evas_List l; - char *realpath = NULL; + E_View_Model *m; + Evas_List l; + char *realpath = NULL; D_ENTER; if (!path) - D_RETURN_(NULL); - + D_RETURN_(NULL); + realpath = e_file_realpath(path); - for (l=VM->models; l; l = l->next) + for (l = VM->models; l; l = l->next) { - m = l->data; - if (!strcmp(m->dir, realpath)) - { - D("Model for this dir already exists\n"); + m = l->data; + if (!strcmp(m->dir, realpath)) + { + D("Model for this dir already exists\n"); - IF_FREE(realpath); - D_RETURN_(m); - } + IF_FREE(realpath); + D_RETURN_(m); + } } IF_FREE(realpath); D_RETURN_(NULL); } -E_View * +E_View * e_view_machine_get_view_by_main_window(Window win) { - Evas_List l; + Evas_List l; + D_ENTER; for (l = VM->views; l; l = l->next) { - E_View *v = l->data; + E_View *v = l->data; + if (v && win == v->win.main) D_RETURN_(v); - } + } D_RETURN_(NULL); } -E_View * +E_View * e_view_machine_get_view_by_base_window(Window win) { - Evas_List l; + Evas_List l; + D_ENTER; for (l = VM->views; l; l = l->next) { - E_View *v = l->data; + E_View *v = l->data; + if (v && win == v->win.base) D_RETURN_(v); - } + } D_RETURN_(NULL); } - diff --git a/src/e_view_machine.h b/src/e_view_machine.h index fa43f58c9..617d4d574 100644 --- a/src/e_view_machine.h +++ b/src/e_view_machine.h @@ -4,20 +4,20 @@ #include "view.h" struct _e_view_machine { - Evas_List views; - Evas_List models; + Evas_List views; + Evas_List models; }; typedef struct _e_view_machine E_View_Machine; -void e_view_machine_init(void); -void e_view_machine_register_view(E_View *v); -void e_view_machine_unregister_view(E_View *v); -void e_view_machine_register_view_model(E_View_Model *m); -void e_view_machine_unregister_view_model(E_View_Model *m); +void e_view_machine_init(void); +void e_view_machine_register_view(E_View * v); +void e_view_machine_unregister_view(E_View * v); +void e_view_machine_register_view_model(E_View_Model * m); +void e_view_machine_unregister_view_model(E_View_Model * m); -void e_view_machine_close_all_views(void); -E_View_Model *e_view_machine_model_lookup(char *path); -E_View *e_view_machine_get_view_by_main_window(Window win); -E_View *e_view_machine_get_view_by_base_window(Window win); +void e_view_machine_close_all_views(void); +E_View_Model *e_view_machine_model_lookup(char *path); +E_View *e_view_machine_get_view_by_main_window(Window win); +E_View *e_view_machine_get_view_by_base_window(Window win); #endif diff --git a/src/e_view_model.c b/src/e_view_model.c index a25991587..9dfd6ac95 100644 --- a/src/e_view_model.c +++ b/src/e_view_model.c @@ -8,17 +8,20 @@ #include "e_file.h" #include "globals.h" -static void e_view_model_handle_fs_restart(void *data); -static void e_view_model_handle_fs(EfsdEvent *ev); -static void e_view_model_handle_efsd_event_reply (EfsdEvent *ev); -static void e_view_model_handle_efsd_event_reply_stat (EfsdEvent *ev); -static void e_view_model_handle_efsd_event_reply_readlink (EfsdEvent *ev); -static void e_view_model_handle_efsd_event_reply_getfiletype (EfsdEvent *ev); -static void e_view_model_handle_efsd_event_reply_getmeta (EfsdEvent *ev); +static void e_view_model_handle_fs_restart(void *data); +static void e_view_model_handle_fs(EfsdEvent * ev); +static void e_view_model_handle_efsd_event_reply(EfsdEvent * ev); +static void e_view_model_handle_efsd_event_reply_stat(EfsdEvent * ev); +static void e_view_model_handle_efsd_event_reply_readlink(EfsdEvent * + ev); +static void e_view_model_handle_efsd_event_reply_getfiletype(EfsdEvent * + ev); +static void e_view_model_handle_efsd_event_reply_getmeta(EfsdEvent * + ev); -static void e_view_model_cleanup(E_View_Model *m); -static void e_view_model_bg_reload_timeout(int val, void *data); -static void e_view_model_set_default_background(E_View_Model *m); +static void e_view_model_cleanup(E_View_Model * m); +static void e_view_model_bg_reload_timeout(int val, void *data); +static void e_view_model_set_default_background(E_View_Model * m); void e_view_model_init(void) @@ -28,17 +31,17 @@ e_view_model_init(void) D_RETURN; } -static void -e_view_model_cleanup(E_View_Model *m) +static void +e_view_model_cleanup(E_View_Model * m) { D_ENTER; - + if (!m) - D_RETURN; + D_RETURN; efsd_stop_monitor(e_fs_get_connection(), m->dir, TRUE); if (m->restarter) - e_fs_del_restart_handler(m->restarter); + e_fs_del_restart_handler(m->restarter); m->restarter = NULL; e_view_machine_unregister_view_model(m); @@ -48,54 +51,54 @@ e_view_model_cleanup(E_View_Model *m) D_RETURN; } -E_View_Model * -e_view_model_new (void) +E_View_Model * +e_view_model_new(void) { - E_View_Model *m; - + E_View_Model *m; + D_ENTER; - m = NEW (E_View_Model, 1); + m = NEW(E_View_Model, 1); ZERO(m, E_View_Model, 1); m->dir = NULL; m->views = NULL; - e_object_init(E_OBJECT(m), - (E_Cleanup_Func) e_view_model_cleanup); + e_object_init(E_OBJECT(m), (E_Cleanup_Func) e_view_model_cleanup); e_view_machine_register_view_model(m); D_RETURN_(m); } void -e_view_model_register_view(E_View_Model *m, E_View *v) +e_view_model_register_view(E_View_Model * m, E_View * v) { D_ENTER; v->model = m; - m->views = evas_list_append(m->views, v); + m->views = evas_list_append(m->views, v); /* dont ref the first time */ if (m->views->next) - e_object_ref (E_OBJECT(v->model)); - D_RETURN; + e_object_ref(E_OBJECT(v->model)); + D_RETURN; } void -e_view_model_unregister_view(E_View *v) +e_view_model_unregister_view(E_View * v) { D_ENTER; v->model->views = evas_list_remove(v->model->views, v); - e_object_unref (E_OBJECT(v->model)); - D_RETURN; + e_object_unref(E_OBJECT(v->model)); + D_RETURN; } static void -e_view_model_set_default_background(E_View_Model *m) +e_view_model_set_default_background(E_View_Model * m) { - char buf[PATH_MAX]; + char buf[PATH_MAX]; + D_ENTER; if (!m) - D_RETURN; + D_RETURN; IF_FREE(m->bg_file); @@ -107,8 +110,7 @@ e_view_model_set_default_background(E_View_Model *m) e_strdup(m->bg_file, buf); snprintf(buf, PATH_MAX, "background_reload:%s", m->dir); - ecore_add_event_timer(buf, 0.5, - e_view_model_bg_reload_timeout, 0, m); + ecore_add_event_timer(buf, 0.5, e_view_model_bg_reload_timeout, 0, m); D_RETURN; } @@ -116,36 +118,37 @@ e_view_model_set_default_background(E_View_Model *m) static void e_view_model_handle_fs_restart(void *data) { - E_View_Model *m; + E_View_Model *m; D_ENTER; m = data; D("e_view_model_handle_fs_restart\n"); if (e_fs_get_connection()) - { - EfsdOptions *ops; - /* FIXME restart with metadata pending for views */ + { + EfsdOptions *ops; - ops = efsd_ops(3, - efsd_op_get_stat(), - efsd_op_get_filetype(), - efsd_op_list_all()); - m->monitor_id = efsd_start_monitor(e_fs_get_connection(), m->dir, - ops, TRUE); + /* FIXME restart with metadata pending for views */ - } - D("restarted monitor id (connection = %p), %i for %s\n", e_fs_get_connection(), m->monitor_id, m->dir); + ops = efsd_ops(3, + efsd_op_get_stat(), + efsd_op_get_filetype(), efsd_op_list_all()); + m->monitor_id = efsd_start_monitor(e_fs_get_connection(), m->dir, + ops, TRUE); + + } + D("restarted monitor id (connection = %p), %i for %s\n", + e_fs_get_connection(), m->monitor_id, m->dir); D_RETURN; } void -e_view_model_set_dir(E_View_Model *m, char *dir) +e_view_model_set_dir(E_View_Model * m, char *dir) { D_ENTER; if (!m) - D_RETURN; + D_RETURN; /* stop monitoring old dir */ if ((m->dir) && (m->monitor_id)) @@ -160,259 +163,265 @@ e_view_model_set_dir(E_View_Model *m, char *dir) /* start monitoring new dir */ m->restarter = e_fs_add_restart_handler(e_view_model_handle_fs_restart, m); if (e_fs_get_connection()) - { - EfsdOptions *ops; + { + EfsdOptions *ops; - ops = efsd_ops(3, - efsd_op_get_stat(), - efsd_op_get_filetype(), - efsd_op_list_all()); - m->monitor_id = efsd_start_monitor(e_fs_get_connection(), m->dir, - ops, TRUE); - D("monitor id for %s = %i\n", m->dir, m->monitor_id); + ops = efsd_ops(3, + efsd_op_get_stat(), + efsd_op_get_filetype(), efsd_op_list_all()); + m->monitor_id = efsd_start_monitor(e_fs_get_connection(), m->dir, + ops, TRUE); + D("monitor id for %s = %i\n", m->dir, m->monitor_id); } D_RETURN; } static void -e_view_model_handle_fs(EfsdEvent *ev) +e_view_model_handle_fs(EfsdEvent * ev) { D_ENTER; if (!ev) - D_RETURN; + D_RETURN; switch (ev->type) { - case EFSD_EVENT_FILECHANGE: + case EFSD_EVENT_FILECHANGE: switch (ev->efsd_filechange_event.changetype) { - case EFSD_FILE_CREATED: - e_view_model_file_added(ev->efsd_filechange_event.id, - ev->efsd_filechange_event.file); + case EFSD_FILE_CREATED: + e_view_model_file_added(ev->efsd_filechange_event.id, + ev->efsd_filechange_event.file); break; - case EFSD_FILE_EXISTS: - e_view_model_file_added(ev->efsd_filechange_event.id, - ev->efsd_filechange_event.file); + case EFSD_FILE_EXISTS: + e_view_model_file_added(ev->efsd_filechange_event.id, + ev->efsd_filechange_event.file); break; - case EFSD_FILE_DELETED: - e_view_model_file_deleted(ev->efsd_filechange_event.id, - ev->efsd_filechange_event.file); + case EFSD_FILE_DELETED: + e_view_model_file_deleted(ev->efsd_filechange_event.id, + ev->efsd_filechange_event.file); break; - case EFSD_FILE_CHANGED: - e_view_model_file_changed(ev->efsd_filechange_event.id, - ev->efsd_filechange_event.file); + case EFSD_FILE_CHANGED: + e_view_model_file_changed(ev->efsd_filechange_event.id, + ev->efsd_filechange_event.file); break; - case EFSD_FILE_MOVED: - e_view_model_file_moved(ev->efsd_filechange_event.id, - ev->efsd_filechange_event.file); + case EFSD_FILE_MOVED: + e_view_model_file_moved(ev->efsd_filechange_event.id, + ev->efsd_filechange_event.file); break; - case EFSD_FILE_END_EXISTS: + case EFSD_FILE_END_EXISTS: break; - default: + default: break; } break; - case EFSD_EVENT_REPLY: - e_view_model_handle_efsd_event_reply (ev); + case EFSD_EVENT_REPLY: + e_view_model_handle_efsd_event_reply(ev); break; - default: + default: break; } D_RETURN; } - static void -e_view_model_handle_efsd_event_reply_getfiletype(EfsdEvent *ev) +e_view_model_handle_efsd_event_reply_getfiletype(EfsdEvent * ev) { - E_File *f; - char *file = NULL; - Evas_List l; - E_View_Model *model; + E_File *f; + char *file = NULL; + Evas_List l; + E_View_Model *model; + + char *m, *p; + char mime[PATH_MAX], base[PATH_MAX]; - char *m, *p; - char mime[PATH_MAX], base[PATH_MAX]; D_ENTER; if (!ev) - D_RETURN; + D_RETURN; if (!ev->efsd_reply_event.errorcode == 0) - D_RETURN; + D_RETURN; - if ( (file = efsd_event_filename(ev)) ) - { - file = e_file_get_file(file); - } + if ((file = efsd_event_filename(ev))) + { + file = e_file_get_file(file); + } model = e_view_model_find_by_monitor_id(efsd_event_id(ev)); - + f = e_file_get_by_name(model->files, file); /* if its not in the list we care about, its filetype is meaningless */ - if(!f) + if (!f) D_RETURN; m = ev->efsd_reply_event.data; p = strchr(m, '/'); if (p) - { - strcpy(base, m); - strcpy(mime, p + 1); - p = strchr(base, '/'); - *p = 0; - } + { + strcpy(base, m); + strcpy(mime, p + 1); + p = strchr(base, '/'); + *p = 0; + } else - { - strcpy(base, m); - strcpy(mime, "unknown"); - } + { + strcpy(base, m); + strcpy(mime, "unknown"); + } e_file_set_mime(f, base, mime); - for (l=model->views;l;l=l->next) - { - E_View *v = (E_View *)l->data; - E_Icon *ic = e_icon_find_by_file(v, f->file); - /* Try to update the GUI. - It's just a try because we need to have the file's stat - info as well. --cK. - */ - e_icon_update_state(ic); - e_icon_initial_show(ic); - } + for (l = model->views; l; l = l->next) + { + E_View *v = (E_View *) l->data; + E_Icon *ic = e_icon_find_by_file(v, f->file); + + /* Try to update the GUI. + * It's just a try because we need to have the file's stat + * info as well. --cK. + */ + e_icon_update_state(ic); + e_icon_initial_show(ic); + } D_RETURN; } static void -e_view_model_handle_efsd_event_reply_stat(EfsdEvent *ev) +e_view_model_handle_efsd_event_reply_stat(EfsdEvent * ev) { - E_View_Model *m; - E_File *f; - Evas_List l; + E_View_Model *m; + E_File *f; + Evas_List l; D_ENTER; if (!ev) - D_RETURN; + D_RETURN; if (!ev->efsd_reply_event.errorcode == 0) - D_RETURN; + D_RETURN; m = e_view_model_find_by_monitor_id(efsd_event_id(ev)); f = e_file_get_by_name(m->files, e_file_get_file(efsd_event_filename(ev))); /* if its not in the list we care about, return */ - if(!f) + if (!f) D_RETURN; - + /* When everything went okay and we can find a model, - set the file stat data for the file and try to update the gui. - It's just a try because we need to have received the filetype - info too. --cK. */ - f->stat = *((struct stat*)efsd_event_data(ev)); - for (l=m->views;l;l=l->next) - { - E_View *v = (E_View *)l->data; - E_Icon *ic = e_icon_find_by_file(v, f->file); - e_icon_update_state(ic); - e_icon_initial_show(ic); - } + * set the file stat data for the file and try to update the gui. + * It's just a try because we need to have received the filetype + * info too. --cK. */ + f->stat = *((struct stat *)efsd_event_data(ev)); + for (l = m->views; l; l = l->next) + { + E_View *v = (E_View *) l->data; + E_Icon *ic = e_icon_find_by_file(v, f->file); + + e_icon_update_state(ic); + e_icon_initial_show(ic); + } D_RETURN; } static void -e_view_model_handle_efsd_event_reply_readlink(EfsdEvent *ev) +e_view_model_handle_efsd_event_reply_readlink(EfsdEvent * ev) { - E_View_Model *m; - E_File *f; - Evas_List l; + E_View_Model *m; + E_File *f; + Evas_List l; + D_ENTER; if (!ev) - D_RETURN; - + D_RETURN; + if (!ev->efsd_reply_event.errorcode == 0) - D_RETURN; - + D_RETURN; + m = e_view_model_find_by_monitor_id(efsd_event_id(ev)); f = e_file_get_by_name(m->files, e_file_get_file(efsd_event_filename(ev))); if (f) - { - e_file_set_link(f, (char*)efsd_event_data(ev)); - } - for (l=m->views;l;l=l->next) - { - E_View *v = (E_View *)l->data; - E_Icon *ic = e_icon_find_by_file(v, f->file); - e_icon_update_state(ic); - e_icon_initial_show(ic); - } + { + e_file_set_link(f, (char *)efsd_event_data(ev)); + } + for (l = m->views; l; l = l->next) + { + E_View *v = (E_View *) l->data; + E_Icon *ic = e_icon_find_by_file(v, f->file); + + e_icon_update_state(ic); + e_icon_initial_show(ic); + } D_RETURN; } static void -e_view_model_handle_efsd_event_reply_getmeta(EfsdEvent *ev) +e_view_model_handle_efsd_event_reply_getmeta(EfsdEvent * ev) { - Evas_List l; - EfsdCmdId cmd; + Evas_List l; + EfsdCmdId cmd; + D_ENTER; if (!ev) - D_RETURN; - - cmd = efsd_event_id(ev); - for (l=VM->views;l;l=l->next) - { - E_View *v; - v = l->data; - /* ignore metadata for desktops */ - if(v->model->is_desktop) continue; - if (v->geom_get.x == cmd) - { - v->geom_get.x = 0; - if (efsd_metadata_get_type(ev) == EFSD_INT) - { - if (ev->efsd_reply_event.errorcode == 0) - efsd_metadata_get_int(ev, &(v->location.x)); - else - v->location.x = 0; - } - } - else if (v->geom_get.y == cmd) - { - v->geom_get.y = 0; - if (efsd_metadata_get_type(ev) == EFSD_INT) - { - if (ev->efsd_reply_event.errorcode == 0) - efsd_metadata_get_int(ev, &(v->location.y)); - else - v->location.y = 0; + D_RETURN; - } - } - else if (v->geom_get.w == cmd) - { - v->geom_get.w = 0; - if (efsd_metadata_get_type(ev) == EFSD_INT) - { - if (ev->efsd_reply_event.errorcode == 0) - efsd_metadata_get_int(ev, &(v->size.w)); - else - v->size.w = 400; - } - } - else if (v->geom_get.h == cmd) - { - v->geom_get.h = 0; - if (ev->efsd_reply_event.errorcode == 0) - { - if (ev->efsd_reply_event.errorcode == 0) - efsd_metadata_get_int(ev, &(v->size.h)); - else - v->size.h = 400; - } - } - /* FIXME currently, the bg info is not set via metadata */ + cmd = efsd_event_id(ev); + for (l = VM->views; l; l = l->next) + { + E_View *v; + + v = l->data; + /* ignore metadata for desktops */ + if (v->model->is_desktop) + continue; + if (v->geom_get.x == cmd) + { + v->geom_get.x = 0; + if (efsd_metadata_get_type(ev) == EFSD_INT) + { + if (ev->efsd_reply_event.errorcode == 0) + efsd_metadata_get_int(ev, &(v->location.x)); + else + v->location.x = 0; + } + } + else if (v->geom_get.y == cmd) + { + v->geom_get.y = 0; + if (efsd_metadata_get_type(ev) == EFSD_INT) + { + if (ev->efsd_reply_event.errorcode == 0) + efsd_metadata_get_int(ev, &(v->location.y)); + else + v->location.y = 0; + + } + } + else if (v->geom_get.w == cmd) + { + v->geom_get.w = 0; + if (efsd_metadata_get_type(ev) == EFSD_INT) + { + if (ev->efsd_reply_event.errorcode == 0) + efsd_metadata_get_int(ev, &(v->size.w)); + else + v->size.w = 400; + } + } + else if (v->geom_get.h == cmd) + { + v->geom_get.h = 0; + if (ev->efsd_reply_event.errorcode == 0) + { + if (ev->efsd_reply_event.errorcode == 0) + efsd_metadata_get_int(ev, &(v->size.h)); + else + v->size.h = 401; + } + } + /* FIXME currently, the bg info is not set via metadata */ /* * else if (v->getbg == cmd) * { @@ -433,283 +442,284 @@ e_view_model_handle_efsd_event_reply_getmeta(EfsdEvent *ev) * } * } */ - ecore_window_move(v->win.base, v->location.x, v->location.y); - ecore_window_resize(v->win.base, v->size.w, v->size.h); - v->size.force = 1; - v->changed = 1; - - /* We have received all metadata we need, display the view */ - if ((!v->geom_get.x) && + /* We have received all metadata we need, display the view */ + if ((!v->geom_get.x) && (!v->geom_get.y) && - (!v->geom_get.w) && - (!v->geom_get.h) && - (v->geom_get.busy)) - { - E_Border *b; - - v->geom_get.busy = 0; - if (v->bg) - e_bg_resize(v->bg, v->size.w, v->size.h); - if (v->options.back_pixmap) e_view_update(v); - b = e_border_adopt(v->win.base, 1); - b->client.internal = 1; - e_border_remove_click_grab(b); - } - } + (!v->geom_get.w) && (!v->geom_get.h) && (v->geom_get.busy)) + { + E_Border *b; + ecore_window_move_resize(v->win.base, v->location.x, v->location.y, + v->size.w, v->size.h); + ecore_window_set_xy_hints(v->win.base, v->location.x, + v->location.y); + v->size.force = 1; + v->geom_get.busy = 0; + if (v->bg) + e_bg_resize(v->bg, v->size.w, v->size.h); + if (v->options.back_pixmap) + e_view_update(v); + b = e_border_adopt(v->win.base, 1); + b->client.internal = 1; + e_border_remove_click_grab(b); + } + } D_RETURN; } static void -e_view_model_handle_efsd_event_reply(EfsdEvent *ev) +e_view_model_handle_efsd_event_reply(EfsdEvent * ev) { D_ENTER; if (!ev) - D_RETURN; + D_RETURN; switch (ev->efsd_reply_event.command.type) - { - case EFSD_CMD_REMOVE: - break; - case EFSD_CMD_MOVE: - break; - case EFSD_CMD_SYMLINK: - break; - case EFSD_CMD_LISTDIR: - break; - case EFSD_CMD_MAKEDIR: - break; - case EFSD_CMD_CHMOD: - break; - case EFSD_CMD_GETFILETYPE: - e_view_model_handle_efsd_event_reply_getfiletype(ev); - break; - case EFSD_CMD_STAT: - e_view_model_handle_efsd_event_reply_stat(ev); - break; - case EFSD_CMD_READLINK: - e_view_model_handle_efsd_event_reply_readlink(ev); - break; - case EFSD_CMD_CLOSE: - break; - case EFSD_CMD_SETMETA: - break; - case EFSD_CMD_GETMETA: - e_view_model_handle_efsd_event_reply_getmeta(ev); - break; - case EFSD_CMD_STARTMON_DIR: - break; - case EFSD_CMD_STARTMON_FILE: - break; - case EFSD_CMD_STOPMON_DIR: - break; - case EFSD_CMD_STOPMON_FILE: - break; - default: - break; - } + { + case EFSD_CMD_REMOVE: + break; + case EFSD_CMD_MOVE: + break; + case EFSD_CMD_SYMLINK: + break; + case EFSD_CMD_LISTDIR: + break; + case EFSD_CMD_MAKEDIR: + break; + case EFSD_CMD_CHMOD: + break; + case EFSD_CMD_GETFILETYPE: + e_view_model_handle_efsd_event_reply_getfiletype(ev); + break; + case EFSD_CMD_STAT: + e_view_model_handle_efsd_event_reply_stat(ev); + break; + case EFSD_CMD_READLINK: + e_view_model_handle_efsd_event_reply_readlink(ev); + break; + case EFSD_CMD_CLOSE: + break; + case EFSD_CMD_SETMETA: + break; + case EFSD_CMD_GETMETA: + e_view_model_handle_efsd_event_reply_getmeta(ev); + break; + case EFSD_CMD_STARTMON_DIR: + break; + case EFSD_CMD_STARTMON_FILE: + break; + case EFSD_CMD_STOPMON_DIR: + break; + case EFSD_CMD_STOPMON_FILE: + break; + default: + break; + } D_RETURN; } static void e_view_model_ib_reload_timeout(int val, void *data) { - Evas_List l; - E_View *v; - E_View_Model *m; - + Evas_List l; + E_View *v; + E_View_Model *m; + D_ENTER; m = data; - for (l=m->views;l;l=l->next) - { - v = (E_View*) l->data; - e_view_ib_reload(v); - } - D_RETURN; + for (l = m->views; l; l = l->next) + { + v = (E_View *) l->data; + e_view_ib_reload(v); + } + D_RETURN; UN(val); } static void e_view_model_bg_reload_timeout(int val, void *data) { - Evas_List l; - E_View *v; - E_View_Model *m; - + Evas_List l; + E_View *v; + E_View_Model *m; + D_ENTER; m = data; - for (l=m->views;l;l=l->next) - { - v = (E_View*) l->data; - e_view_bg_reload(v); - } - D_RETURN; + for (l = m->views; l; l = l->next) + { + v = (E_View *) l->data; + e_view_bg_reload(v); + } + D_RETURN; UN(val); } void e_view_model_file_added(int id, char *file) { - Evas_List l; - E_View_Model *m; - E_View *v; - E_File *f; - char buf[PATH_MAX]; + Evas_List l; + E_View_Model *m; + E_View *v; + E_File *f; + char buf[PATH_MAX]; D_ENTER; - + /* if we get a path - ignore it - its not a file in the dir */ - if (!file || file[0] == '/') D_RETURN; - m = e_view_model_find_by_monitor_id(id); - + if (!file || file[0] == '/') + D_RETURN; + m = e_view_model_find_by_monitor_id(id); + if (!strcmp(file, ".e_background.bg.db")) - { - IF_FREE(m->bg_file); - snprintf(buf, PATH_MAX, "%s/%s", m->dir, file); - e_strdup(m->bg_file, buf); - snprintf(buf, PATH_MAX, "background_reload:%s", m->dir); - ecore_add_event_timer(buf, 0.5, - e_view_model_bg_reload_timeout, 0, m); - } - else if ((!strcmp (".e_iconbar.db", file)) || - (!strcmp (".e_iconbar.bits.db", file))) - { - snprintf(buf, PATH_MAX, "iconbar_reload:%s", m->dir); - ecore_add_event_timer(buf, 0.5, - e_view_model_ib_reload_timeout, 0, m); - } + { + IF_FREE(m->bg_file); + snprintf(buf, PATH_MAX, "%s/%s", m->dir, file); + e_strdup(m->bg_file, buf); + snprintf(buf, PATH_MAX, "background_reload:%s", m->dir); + ecore_add_event_timer(buf, 0.5, e_view_model_bg_reload_timeout, 0, m); + } + else if ((!strcmp(".e_iconbar.db", file)) || + (!strcmp(".e_iconbar.bits.db", file))) + { + snprintf(buf, PATH_MAX, "iconbar_reload:%s", m->dir); + ecore_add_event_timer(buf, 0.5, e_view_model_ib_reload_timeout, 0, m); + } else if (file[0] != '.') - { - f = e_file_new(file); - m->files = evas_list_append(m->files, f); - /* tell all views for this dir about the new file */ - for (l= m->views;l ;l = l->next) - { - v = l->data; - e_view_file_add(v, f); - } - } + { + f = e_file_new(file); + m->files = evas_list_append(m->files, f); + /* tell all views for this dir about the new file */ + for (l = m->views; l; l = l->next) + { + v = l->data; + e_view_file_add(v, f); + } + } D_RETURN; } void e_view_model_file_deleted(int id, char *file) { - Evas_List l; - E_File *f; - E_View_Model *m; + Evas_List l; + E_File *f; + E_View_Model *m; + D_ENTER; if (!file || file[0] == '/') - D_RETURN; + D_RETURN; m = e_view_model_find_by_monitor_id(id); f = e_file_get_by_name(m->files, file); m->files = evas_list_remove(m->files, f); if (!strcmp(file, ".e_background.bg.db")) - { - e_view_model_set_default_background(m); - } - else if ((!strcmp (".e_iconbar.db", file)) || - (!strcmp (".e_iconbar.bits.db", file))) - { - for (l=m->views;l;l=l->next) - { - E_View *v = (E_View*) l->data; - e_object_unref(E_OBJECT(v->iconbar)); - v->iconbar = NULL; - } - } - else if(file[0] != '.') - { - for (l=m->views;l;l=l->next) - { - E_View *v = (E_View*) l->data; - e_view_file_delete(v, f); - } - } + { + e_view_model_set_default_background(m); + } + else if ((!strcmp(".e_iconbar.db", file)) || + (!strcmp(".e_iconbar.bits.db", file))) + { + for (l = m->views; l; l = l->next) + { + E_View *v = (E_View *) l->data; + + e_object_unref(E_OBJECT(v->iconbar)); + v->iconbar = NULL; + } + } + else if (file[0] != '.') + { + for (l = m->views; l; l = l->next) + { + E_View *v = (E_View *) l->data; + + e_view_file_delete(v, f); + } + } D_RETURN; } void e_view_model_file_changed(int id, char *file) { - Evas_List l; - E_View_Model *m; - E_File *f; - E_View *v; - char buf[PATH_MAX]; + Evas_List l; + E_View_Model *m; + E_File *f; + E_View *v; + char buf[PATH_MAX]; D_ENTER; - - if (!file || file[0] == '/') D_RETURN; + + if (!file || file[0] == '/') + D_RETURN; m = e_view_model_find_by_monitor_id(id); f = e_file_get_by_name(m->files, file); if (!strcmp(file, ".e_background.bg.db")) - { - IF_FREE(m->bg_file); - snprintf(buf, PATH_MAX, "%s/%s", m->dir, file); - e_strdup(m->bg_file, buf); - snprintf(buf, PATH_MAX, "background_reload:%s", m->dir); - ecore_add_event_timer(buf, 0.5, - e_view_model_bg_reload_timeout, 0, m); - } - else if ((!strcmp (".e_iconbar.db", file)) || - (!strcmp (".e_iconbar.bits.db", file))) - { - snprintf(buf, PATH_MAX, "iconbar_reload:%s", m->dir); - ecore_add_event_timer(buf, 0.5, - e_view_model_ib_reload_timeout, 0, m); - } + { + IF_FREE(m->bg_file); + snprintf(buf, PATH_MAX, "%s/%s", m->dir, file); + e_strdup(m->bg_file, buf); + snprintf(buf, PATH_MAX, "background_reload:%s", m->dir); + ecore_add_event_timer(buf, 0.5, e_view_model_bg_reload_timeout, 0, m); + } + else if ((!strcmp(".e_iconbar.db", file)) || + (!strcmp(".e_iconbar.bits.db", file))) + { + snprintf(buf, PATH_MAX, "iconbar_reload:%s", m->dir); + ecore_add_event_timer(buf, 0.5, e_view_model_ib_reload_timeout, 0, m); + } else if (file[0] != '.') - { - for (l= m->views;l ;l = l->next) - { - v = l->data; - e_view_file_changed(v, f); - } - } + { + for (l = m->views; l; l = l->next) + { + v = l->data; + e_view_file_changed(v, f); + } + } D_RETURN; } void e_view_model_file_moved(int id, char *file) { - Evas_List l; - E_View_Model *m; + Evas_List l; + E_View_Model *m; D_ENTER; - - if (!file || file[0] == '/') D_RETURN; - m = e_view_model_find_by_monitor_id(id); - for (l=m->views;l;l=l->next) - { - E_View *v = (E_View*) l->data; - E_Icon *ic; - ic = e_icon_find_by_file(v, file); - if (ic) - { - } - } + if (!file || file[0] == '/') + D_RETURN; + m = e_view_model_find_by_monitor_id(id); + for (l = m->views; l; l = l->next) + { + E_View *v = (E_View *) l->data; + E_Icon *ic; + + ic = e_icon_find_by_file(v, file); + if (ic) + { + } + } D_RETURN; } -E_View_Model * +E_View_Model * e_view_model_find_by_monitor_id(int id) { - E_View_Model *m; - Evas_List l; + E_View_Model *m; + Evas_List l; + D_ENTER; - + for (l = VM->models; l; l = l->next) { m = l->data; if (m->monitor_id == id) - D_RETURN_(m);; + D_RETURN_(m);; } D_RETURN_(NULL); } diff --git a/src/e_view_model.h b/src/e_view_model.h index b9a9522f1..653ca9b6d 100644 --- a/src/e_view_model.h +++ b/src/e_view_model.h @@ -7,12 +7,12 @@ #ifndef E_VIEW_TYPEDEF #define E_VIEW_TYPEDEF -typedef struct _E_View E_View; +typedef struct _E_View E_View; #endif #ifndef E_ICON_TYPEDEF #define E_ICON_TYPEDEF -typedef struct _E_Icon E_Icon; +typedef struct _E_Icon E_Icon; #endif #ifndef E_VIEW_MODEL_TYPEDEF @@ -22,25 +22,25 @@ typedef struct _E_View_Model E_View_Model; struct _E_View_Model { - E_Object o; + E_Object o; /* The realpath of the view's directory */ - char *dir; + char *dir; - Evas_List files; + Evas_List files; - Evas_Object obj_bg; - - char *bg_file; - - E_FS_Restarter *restarter; - - int monitor_id; + Evas_Object obj_bg; + + char *bg_file; + + E_FS_Restarter *restarter; + + int monitor_id; /* A list of all the views for which a model is sharing data */ - Evas_List views; + Evas_List views; - int is_desktop; + int is_desktop; }; /** @@ -50,18 +50,18 @@ struct _E_View_Model * * Set the directory for a view_model and starts monitoring it via efsd. */ -void e_view_model_set_dir(E_View_Model *m, char *dir); +void e_view_model_set_dir(E_View_Model * m, char *dir); -E_View_Model * e_view_model_new(void); -void e_view_model_init(void); -void e_view_model_register_view(E_View_Model *m,E_View *v); -void e_view_model_unregister_view(E_View *v); +E_View_Model *e_view_model_new(void); +void e_view_model_init(void); +void e_view_model_register_view(E_View_Model * m, E_View * v); +void e_view_model_unregister_view(E_View * v); -E_View_Model * e_view_model_find_by_monitor_id(int id); +E_View_Model *e_view_model_find_by_monitor_id(int id); /* Deal with incoming file events */ -void e_view_model_file_added(int id, char *file); -void e_view_model_file_deleted(int id, char *file); -void e_view_model_file_changed(int id, char *file); -void e_view_model_file_moved(int id, char *file); +void e_view_model_file_added(int id, char *file); +void e_view_model_file_deleted(int id, char *file); +void e_view_model_file_changed(int id, char *file); +void e_view_model_file_moved(int id, char *file); #endif diff --git a/src/embed.c b/src/embed.c index 9dc97a971..12a36be95 100644 --- a/src/embed.c +++ b/src/embed.c @@ -6,23 +6,24 @@ typedef struct _Embed Embed_Private; struct _Embed { - Ebits_Object o; - Evas evas; - Evas_Object image_obj; - Evas_Object clip_obj; - int clip_x, clip_y; - E_Text *text_obj; + Ebits_Object o; + Evas evas; + Evas_Object image_obj; + Evas_Object clip_obj; + int clip_x, clip_y; + E_Text *text_obj; }; static void e_embed_text_func_show(void *_data) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; - if (em->clip_obj) evas_show(em->evas, em->clip_obj); + if (em->clip_obj) + evas_show(em->evas, em->clip_obj); e_text_show(em->text_obj); D_RETURN; @@ -31,12 +32,13 @@ e_embed_text_func_show(void *_data) static void e_embed_text_func_hide(void *_data) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; - if (em->clip_obj) evas_hide(em->evas, em->clip_obj); + if (em->clip_obj) + evas_hide(em->evas, em->clip_obj); e_text_hide(em->text_obj); D_RETURN; @@ -45,12 +47,13 @@ e_embed_text_func_hide(void *_data) static void e_embed_text_func_move(void *_data, double x, double y) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; - if (em->clip_obj) evas_move(em->evas, em->clip_obj, x, y); + if (em->clip_obj) + evas_move(em->evas, em->clip_obj, x, y); e_text_move(em->text_obj, x, y); D_RETURN; @@ -59,12 +62,13 @@ e_embed_text_func_move(void *_data, double x, double y) static void e_embed_text_func_resize(void *_data, double w, double h) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; - if (em->clip_obj) evas_resize(em->evas, em->clip_obj, w, h); + if (em->clip_obj) + evas_resize(em->evas, em->clip_obj, w, h); e_text_resize(em->text_obj, w, h); D_RETURN; @@ -73,12 +77,13 @@ e_embed_text_func_resize(void *_data, double w, double h) static void e_embed_text_func_raise(void *_data) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; - if (em->clip_obj) evas_raise(em->evas, em->clip_obj); + if (em->clip_obj) + evas_raise(em->evas, em->clip_obj); e_text_raise(em->text_obj); D_RETURN; @@ -87,12 +92,13 @@ e_embed_text_func_raise(void *_data) static void e_embed_text_func_lower(void *_data) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; - if (em->clip_obj) evas_lower(em->evas, em->clip_obj); + if (em->clip_obj) + evas_lower(em->evas, em->clip_obj); e_text_lower(em->text_obj); D_RETURN; @@ -101,12 +107,13 @@ e_embed_text_func_lower(void *_data) static void e_embed_text_func_set_layer(void *_data, int l) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; - if (em->clip_obj) evas_set_layer(em->evas, em->clip_obj, l); + if (em->clip_obj) + evas_set_layer(em->evas, em->clip_obj, l); e_text_set_layer(em->text_obj, l); D_RETURN; @@ -115,31 +122,32 @@ e_embed_text_func_set_layer(void *_data, int l) static void e_embed_text_func_set_clip(void *_data, Evas_Object clip) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; if (em->clip_obj) { if (clip) - e_text_set_clip(em->clip_obj, clip); + e_text_set_clip(em->clip_obj, clip); else - e_text_unset_clip(em->clip_obj); + e_text_unset_clip(em->clip_obj); } else { if (clip) - e_text_set_clip(em->text_obj, clip); + e_text_set_clip(em->text_obj, clip); else - e_text_unset_clip(em->text_obj); + e_text_unset_clip(em->text_obj); } D_RETURN; } static void -e_embed_text_func_set_color_class(void *_data, char *cc, int r, int g, int b, int a) +e_embed_text_func_set_color_class(void *_data, char *cc, int r, int g, int b, + int a) { D_ENTER; @@ -156,14 +164,16 @@ e_embed_text_func_set_color_class(void *_data, char *cc, int r, int g, int b, in static void e_embed_text_func_get_min_size(void *_data, double *w, double *h) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; e_text_get_min_size(em->text_obj, w, h); - if (em->clip_x) *w = 0; - if (em->clip_y) *h = 0; + if (em->clip_x) + *w = 0; + if (em->clip_y) + *h = 0; D_RETURN; } @@ -171,14 +181,16 @@ e_embed_text_func_get_min_size(void *_data, double *w, double *h) static void e_embed_text_func_get_max_size(void *_data, double *w, double *h) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; e_text_get_max_size(em->text_obj, w, h); - if (em->clip_x) *w = 999999999; - if (em->clip_y) *h = 999999999; + if (em->clip_x) + *w = 999999999; + if (em->clip_y) + *h = 999999999; D_RETURN; } @@ -186,10 +198,11 @@ e_embed_text_func_get_max_size(void *_data, double *w, double *h) /***/ Embed -e_embed_text(Ebits_Object o, char *bit_name, Evas evas, E_Text *text_obj, int clip_x, int clip_y) +e_embed_text(Ebits_Object o, char *bit_name, Evas evas, E_Text * text_obj, + int clip_x, int clip_y) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = NEW(Embed_Private, 1); @@ -206,7 +219,7 @@ e_embed_text(Ebits_Object o, char *bit_name, Evas evas, E_Text *text_obj, int cl e_text_set_clip(em->text_obj, em->clip_obj); evas_show(em->evas, em->clip_obj); } - ebits_set_named_bit_replace(o, bit_name, + ebits_set_named_bit_replace(o, bit_name, e_embed_text_func_show, e_embed_text_func_hide, e_embed_text_func_move, @@ -217,8 +230,7 @@ e_embed_text(Ebits_Object o, char *bit_name, Evas evas, E_Text *text_obj, int cl e_embed_text_func_set_clip, e_embed_text_func_set_color_class, e_embed_text_func_get_min_size, - e_embed_text_func_get_max_size, - em); + e_embed_text_func_get_max_size, em); D_RETURN_(em); } @@ -227,8 +239,8 @@ e_embed_text(Ebits_Object o, char *bit_name, Evas evas, E_Text *text_obj, int cl static void e_embed_image_func_show(void *_data) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; @@ -240,8 +252,8 @@ e_embed_image_func_show(void *_data) static void e_embed_image_func_hide(void *_data) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; @@ -253,8 +265,8 @@ e_embed_image_func_hide(void *_data) static void e_embed_image_func_move(void *_data, double x, double y) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; @@ -266,8 +278,8 @@ e_embed_image_func_move(void *_data, double x, double y) static void e_embed_image_func_resize(void *_data, double w, double h) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; @@ -280,8 +292,8 @@ e_embed_image_func_resize(void *_data, double w, double h) static void e_embed_image_func_raise(void *_data) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; @@ -293,8 +305,8 @@ e_embed_image_func_raise(void *_data) static void e_embed_image_func_lower(void *_data) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; @@ -306,8 +318,8 @@ e_embed_image_func_lower(void *_data) static void e_embed_image_func_set_layer(void *_data, int l) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; @@ -319,29 +331,30 @@ e_embed_image_func_set_layer(void *_data, int l) static void e_embed_image_func_set_clip(void *_data, Evas_Object clip) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; if (clip) - evas_set_clip(em->evas, em->image_obj, clip); + evas_set_clip(em->evas, em->image_obj, clip); else - evas_unset_clip(em->evas, em->image_obj); + evas_unset_clip(em->evas, em->image_obj); D_RETURN; } static void -e_embed_image_func_set_color_class(void *_data, char *cc, int r, int g, int b, int a) +e_embed_image_func_set_color_class(void *_data, char *cc, int r, int g, int b, + int a) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = _data; if ((cc) && (!strcmp(cc, "icon"))) - evas_set_color(em->evas, em->image_obj, r, g, b, a); + evas_set_color(em->evas, em->image_obj, r, g, b, a); D_RETURN; } @@ -349,17 +362,19 @@ e_embed_image_func_set_color_class(void *_data, char *cc, int r, int g, int b, i static void e_embed_image_func_get_min_size(void *_data, double *w, double *h) { - Embed_Private *em; - int iw, ih; - + Embed_Private *em; + int iw, ih; + D_ENTER; em = _data; iw = 0; ih = 0; evas_get_image_size(em->evas, em->image_obj, &iw, &ih); - if (w) *w = iw; - if (h) *h = ih; + if (w) + *w = iw; + if (h) + *h = ih; D_RETURN; } @@ -367,15 +382,17 @@ e_embed_image_func_get_min_size(void *_data, double *w, double *h) static void e_embed_image_func_get_max_size(void *_data, double *w, double *h) { - Embed_Private *em; - int iw, ih; - + Embed_Private *em; + int iw, ih; + D_ENTER; em = _data; evas_get_image_size(em->evas, em->image_obj, &iw, &ih); - if (w) *w = iw; - if (h) *h = ih; + if (w) + *w = iw; + if (h) + *h = ih; D_RETURN; } @@ -383,10 +400,11 @@ e_embed_image_func_get_max_size(void *_data, double *w, double *h) /***/ Embed -e_embed_image_object(Ebits_Object o, char *bit_name, Evas evas, Evas_Object image_obj) +e_embed_image_object(Ebits_Object o, char *bit_name, Evas evas, + Evas_Object image_obj) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = NEW(Embed_Private, 1); @@ -394,7 +412,7 @@ e_embed_image_object(Ebits_Object o, char *bit_name, Evas evas, Evas_Object imag em->o = o; em->evas = evas; em->image_obj = image_obj; - ebits_set_named_bit_replace(o, bit_name, + ebits_set_named_bit_replace(o, bit_name, e_embed_image_func_show, e_embed_image_func_hide, e_embed_image_func_move, @@ -405,8 +423,7 @@ e_embed_image_object(Ebits_Object o, char *bit_name, Evas evas, Evas_Object imag e_embed_image_func_set_clip, e_embed_image_func_set_color_class, e_embed_image_func_get_min_size, - e_embed_image_func_get_max_size, - em); + e_embed_image_func_get_max_size, em); D_RETURN_(em); } @@ -415,12 +432,13 @@ e_embed_image_object(Ebits_Object o, char *bit_name, Evas evas, Evas_Object imag void e_embed_free(Embed emb) { - Embed_Private *em; - + Embed_Private *em; + D_ENTER; em = emb; - if (em->clip_obj) evas_del_object(em->evas, em->clip_obj); + if (em->clip_obj) + evas_del_object(em->evas, em->clip_obj); FREE(em); D_RETURN; diff --git a/src/embed.h b/src/embed.h index 65422cf08..e87b22839 100644 --- a/src/embed.h +++ b/src/embed.h @@ -4,10 +4,12 @@ #include "e.h" #include "text.h" -typedef void * Embed; +typedef void *Embed; -Embed e_embed_text(Ebits_Object o, char *bit_name, Evas evas, E_Text *text_obj, int clip_x, int clip_y); -Embed e_embed_image_object(Ebits_Object o, char *bit_name, Evas evas, Evas_Object image_obj); -void e_embed_free(Embed em); +Embed e_embed_text(Ebits_Object o, char *bit_name, Evas evas, + E_Text * text_obj, int clip_x, int clip_y); +Embed e_embed_image_object(Ebits_Object o, char *bit_name, + Evas evas, Evas_Object image_obj); +void e_embed_free(Embed em); #endif diff --git a/src/entry.c b/src/entry.c index 6e65e0358..8e31efb70 100644 --- a/src/entry.c +++ b/src/entry.c @@ -3,31 +3,34 @@ #include "config.h" #include "util.h" -static Evas_List entries; +static Evas_List entries; -static void e_clear_selection(Ecore_Event * ev); -static void e_paste_request(Ecore_Event * ev); +static void e_clear_selection(Ecore_Event * ev); +static void e_paste_request(Ecore_Event * ev); -static void e_entry_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_entry_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_entry_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_entry_realize(E_Entry *entry); -static void e_entry_unrealize(E_Entry *entry); -static void e_entry_configure(E_Entry *entry); +static void e_entry_down_cb(void *_data, Evas _e, Evas_Object _o, + int _b, int _x, int _y); +static void e_entry_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void e_entry_move_cb(void *_data, Evas _e, Evas_Object _o, + int _b, int _x, int _y); +static void e_entry_realize(E_Entry * entry); +static void e_entry_unrealize(E_Entry * entry); +static void e_entry_configure(E_Entry * entry); static void e_clear_selection(Ecore_Event * ev) { Ecore_Event_Clear_Selection *e; - Evas_List l; + Evas_List l; D_ENTER; - + e = ev->event; for (l = entries; l; l = l->next) { - E_Entry *entry; - + E_Entry *entry; + entry = l->data; if (entry->selection_win == e->win) { @@ -35,7 +38,7 @@ e_clear_selection(Ecore_Event * ev) entry->selection_win = 0; entry->select.start = -1; entry->select.length = 0; - e_entry_configure(entry); + e_entry_configure(entry); } } @@ -46,20 +49,20 @@ static void e_paste_request(Ecore_Event * ev) { Ecore_Event_Paste_Request *e; - Evas_List l; - + Evas_List l; + D_ENTER; - + e = ev->event; for (l = entries; l; l = l->next) { - E_Entry *entry; - + E_Entry *entry; + entry = l->data; if (entry->paste_win == e->win) { - char *type; - + char *type; + type = e->string; e_entry_clear_selection(entry); e_entry_insert_text(entry, type); @@ -72,15 +75,16 @@ e_paste_request(Ecore_Event * ev) static void e_entry_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Entry *entry; - int pos; - + E_Entry *entry; + int pos; + D_ENTER; - + entry = _data; - if ((_b == 2) && (!entry->mouse_down)) + if ((_b == 2) && (!entry->mouse_down)) { - if (entry->paste_win) ecore_window_destroy(entry->paste_win); + if (entry->paste_win) + ecore_window_destroy(entry->paste_win); entry->paste_win = ecore_selection_request(); } else if (!entry->mouse_down) @@ -90,8 +94,8 @@ e_entry_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) NULL, NULL, NULL, NULL); if (pos < 0) { - int tw; - + int tw; + tw = evas_get_text_width(_e, entry->text); if (_x > entry->x + tw) { @@ -118,13 +122,15 @@ e_entry_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) static void e_entry_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Entry *entry; + E_Entry *entry; + /* int pos; */ - + D_ENTER; - + entry = _data; - if (_b == entry->mouse_down) entry->mouse_down = 0; + if (_b == entry->mouse_down) + entry->mouse_down = 0; e_entry_configure(entry); D_RETURN; @@ -137,24 +143,24 @@ e_entry_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) static void e_entry_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Entry *entry; - + E_Entry *entry; + D_ENTER; - + entry = _data; if (entry->mouse_down > 0) { - int pos, ppos; - double ty; - + int pos, ppos; + double ty; + ppos = entry->cursor_pos; evas_get_geometry(entry->evas, entry->text, NULL, &ty, NULL, NULL); pos = evas_text_at_position(_e, entry->text, _x, ty, NULL, NULL, NULL, NULL); if (pos < 0) { - int tw; - + int tw; + tw = evas_get_text_width(_e, entry->text); if (_x > entry->x + tw) { @@ -175,13 +181,13 @@ e_entry_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { entry->select.down = ppos; entry->select.start = ppos; - entry->select.length = entry->cursor_pos - ppos +1; + entry->select.length = entry->cursor_pos - ppos + 1; } else { entry->select.down = ppos; entry->select.start = entry->cursor_pos; - entry->select.length = ppos - entry->cursor_pos +1; + entry->select.length = ppos - entry->cursor_pos + 1; } } else if (entry->select.start >= 0) @@ -189,27 +195,30 @@ e_entry_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) if (entry->cursor_pos < entry->select.down) { entry->select.start = entry->cursor_pos; - entry->select.length = entry->select.down - entry->cursor_pos + 1; + entry->select.length = + entry->select.down - entry->cursor_pos + 1; } else { entry->select.start = entry->select.down; - entry->select.length = entry->cursor_pos - entry->select.down + 1; + entry->select.length = + entry->cursor_pos - entry->select.down + 1; } } if (entry->select.start >= 0) { - char *str2; - + char *str2; + str2 = e_entry_get_selection(entry); if (str2) { - if (entry->selection_win) ecore_window_destroy(entry->selection_win); + if (entry->selection_win) + ecore_window_destroy(entry->selection_win); entry->selection_win = ecore_selection_set(str2); free(str2); } } - e_entry_configure(entry); + e_entry_configure(entry); } D_RETURN; @@ -218,67 +227,76 @@ e_entry_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) UN(_y); } -static void -e_entry_realize(E_Entry *entry) +static void +e_entry_realize(E_Entry * entry) { - char *entries; - char buf[PATH_MAX]; - + char *entries; + char buf[PATH_MAX]; + D_ENTER; - + entries = e_config_get("entries"); snprintf(buf, PATH_MAX, "%s/%s", entries, "base.bits.db"); - entry->obj_base = ebits_load(buf); - if (entry->obj_base) - { + entry->obj_base = ebits_load(buf); + if (entry->obj_base) + { ebits_add_to_evas(entry->obj_base, entry->evas); /* ebits_set_color_class(entry->obj_base, "Base FG", 100, 200, 255, 255);*/ - } + } snprintf(buf, PATH_MAX, "%s/%s", entries, "cursor.bits.db"); - entry->obj_cursor = ebits_load(buf); - if (entry->obj_cursor) - { + entry->obj_cursor = ebits_load(buf); + if (entry->obj_cursor) + { ebits_add_to_evas(entry->obj_cursor, entry->evas); /* ebits_set_color_class(entry->obj_base, "Base FG", 100, 200, 255, 255);*/ - } + } snprintf(buf, PATH_MAX, "%s/%s", entries, "selection.bits.db"); - entry->obj_selection = ebits_load(buf); - if (entry->obj_selection) - { + entry->obj_selection = ebits_load(buf); + if (entry->obj_selection) + { ebits_add_to_evas(entry->obj_selection, entry->evas); /* ebits_set_color_class(entry->obj_base, "Base FG", 100, 200, 255, 255);*/ - } - + } + entry->clip_box = evas_add_rectangle(entry->evas); entry->text = evas_add_text(entry->evas, "borzoib", 8, ""); - if (entry->obj_cursor) - ebits_set_clip(entry->obj_cursor, entry->clip_box); - if (entry->obj_selection) - ebits_set_clip(entry->obj_selection, entry->clip_box); + if (entry->obj_cursor) + ebits_set_clip(entry->obj_cursor, entry->clip_box); + if (entry->obj_selection) + ebits_set_clip(entry->obj_selection, entry->clip_box); entry->event_box = evas_add_rectangle(entry->evas); evas_set_color(entry->evas, entry->clip_box, 255, 255, 255, 255); evas_set_color(entry->evas, entry->event_box, 0, 0, 0, 0); evas_set_color(entry->evas, entry->text, 0, 0, 0, 255); evas_set_clip(entry->evas, entry->text, entry->clip_box); evas_set_clip(entry->evas, entry->event_box, entry->clip_box); - evas_callback_add(entry->evas, entry->event_box, CALLBACK_MOUSE_DOWN, e_entry_down_cb, entry); - evas_callback_add(entry->evas, entry->event_box, CALLBACK_MOUSE_UP, e_entry_up_cb, entry); - evas_callback_add(entry->evas, entry->event_box, CALLBACK_MOUSE_MOVE, e_entry_move_cb, entry); + evas_callback_add(entry->evas, entry->event_box, CALLBACK_MOUSE_DOWN, + e_entry_down_cb, entry); + evas_callback_add(entry->evas, entry->event_box, CALLBACK_MOUSE_UP, + e_entry_up_cb, entry); + evas_callback_add(entry->evas, entry->event_box, CALLBACK_MOUSE_MOVE, + e_entry_move_cb, entry); D_RETURN; } -static void -e_entry_unrealize(E_Entry *entry) +static void +e_entry_unrealize(E_Entry * entry) { D_ENTER; - - if (entry->event_box) evas_del_object(entry->evas, entry->event_box); - if (entry->text) evas_del_object(entry->evas, entry->text); - if (entry->clip_box) evas_del_object(entry->evas, entry->clip_box); - if (entry->obj_base) ebits_free(entry->obj_base); - if (entry->obj_cursor) ebits_free(entry->obj_cursor); - if (entry->obj_selection) ebits_free(entry->obj_selection); + + if (entry->event_box) + evas_del_object(entry->evas, entry->event_box); + if (entry->text) + evas_del_object(entry->evas, entry->text); + if (entry->clip_box) + evas_del_object(entry->evas, entry->clip_box); + if (entry->obj_base) + ebits_free(entry->obj_base); + if (entry->obj_cursor) + ebits_free(entry->obj_cursor); + if (entry->obj_selection) + ebits_free(entry->obj_selection); entry->event_box = NULL; entry->text = NULL; entry->clip_box = NULL; @@ -289,101 +307,125 @@ e_entry_unrealize(E_Entry *entry) D_RETURN; } -static void -e_entry_configure(E_Entry *entry) +static void +e_entry_configure(E_Entry * entry) { - int p1l, p1r, p1t, p1b; - int p2l, p2r, p2t, p2b; - + int p1l, p1r, p1t, p1b; + int p2l, p2r, p2t, p2b; + D_ENTER; - - if (!entry->evas) D_RETURN; - if (!entry->event_box) D_RETURN; + + if (!entry->evas) + D_RETURN; + if (!entry->event_box) + D_RETURN; p1l = p1r = p1t = p1b = 0; - if (entry->obj_base) ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); + if (entry->obj_base) + ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); p2l = p2r = p2t = p2b = 0; - if (entry->obj_cursor) ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); - if (entry->obj_base) + if (entry->obj_cursor) + ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); + if (entry->obj_base) { ebits_move(entry->obj_base, entry->x, entry->y); ebits_resize(entry->obj_base, entry->w, entry->h); } evas_move(entry->evas, entry->clip_box, entry->x + p1l, entry->y + p1t); - evas_resize(entry->evas, entry->clip_box, entry->w - p1l - p1r, entry->h - p1t - p1b); - evas_move(entry->evas, entry->event_box, entry->x + p1l + p2l, entry->y + p1t + p2t); - evas_resize(entry->evas, entry->event_box, entry->w - p1l - p1r - p2l - p2r, entry->h - p1t - p1b - p2t - p2b); + evas_resize(entry->evas, entry->clip_box, entry->w - p1l - p1r, + entry->h - p1t - p1b); + evas_move(entry->evas, entry->event_box, entry->x + p1l + p2l, + entry->y + p1t + p2t); + evas_resize(entry->evas, entry->event_box, entry->w - p1l - p1r - p2l - p2r, + entry->h - p1t - p1b - p2t - p2b); if ((entry->buffer) && (entry->buffer[0] != 0) && (entry->focused)) { - double tx, ty, tw, th; - + double tx, ty, tw, th; + if (entry->cursor_pos < (int)strlen(entry->buffer)) { - evas_text_at(entry->evas, entry->text, entry->cursor_pos, &tx, &ty, &tw, &th); + evas_text_at(entry->evas, entry->text, entry->cursor_pos, &tx, &ty, + &tw, &th); } else { entry->cursor_pos = strlen(entry->buffer); - evas_text_at(entry->evas, entry->text, entry->cursor_pos - 1, &tx, &ty, &tw, &th); + evas_text_at(entry->evas, entry->text, entry->cursor_pos - 1, &tx, + &ty, &tw, &th); tx += tw; tw = entry->end_width; } th = evas_get_text_height(entry->evas, entry->text); if (tx + tw + entry->scroll_pos > entry->w - p1l - p1r) - entry->scroll_pos = entry->w - tx - tw - p1l - p1r - p1l - p2l; + entry->scroll_pos = entry->w - tx - tw - p1l - p1r - p1l - p2l; else if (tx + entry->scroll_pos < p1l) - entry->scroll_pos = 0 - tx; + entry->scroll_pos = 0 - tx; if (entry->obj_cursor) { - ebits_move(entry->obj_cursor, entry->x + tx + entry->scroll_pos + p1l, entry->y + ty + p1t); + ebits_move(entry->obj_cursor, + entry->x + tx + entry->scroll_pos + p1l, + entry->y + ty + p1t); ebits_resize(entry->obj_cursor, tw + p2l + p2r, th + p2t + p2b); ebits_show(entry->obj_cursor); } } else if (entry->focused) { - int tx, tw, th; - + int tx, tw, th; + entry->scroll_pos = 0; tw = 4; tx = 0; th = evas_get_text_height(entry->evas, entry->text); if (entry->obj_cursor) { - ebits_move(entry->obj_cursor, entry->x + tx + entry->scroll_pos + p1l, entry->y + p1t); - ebits_resize(entry->obj_cursor, entry->end_width + p2l + p2r, th + p2t + p2b); + ebits_move(entry->obj_cursor, + entry->x + tx + entry->scroll_pos + p1l, + entry->y + p1t); + ebits_resize(entry->obj_cursor, entry->end_width + p2l + p2r, + th + p2t + p2b); ebits_show(entry->obj_cursor); } } else { if (entry->obj_cursor) - ebits_hide(entry->obj_cursor); + ebits_hide(entry->obj_cursor); } - evas_move(entry->evas, entry->text, entry->x + entry->scroll_pos + p1l + p2l, entry->y + p1t + p2t); + evas_move(entry->evas, entry->text, entry->x + entry->scroll_pos + p1l + p2l, + entry->y + p1t + p2t); if (entry->select.start >= 0) { - double x1, y1, x2, tw, th; - - evas_text_at(entry->evas, entry->text, entry->select.start, &x1, &y1, NULL, NULL); - if (entry->select.start + entry->select.length <= (int)strlen(entry->buffer)) - evas_text_at(entry->evas, entry->text, entry->select.start + entry->select.length - 1, &x2, NULL, &tw, &th); + double x1, y1, x2, tw, th; + + evas_text_at(entry->evas, entry->text, entry->select.start, &x1, &y1, + NULL, NULL); + if (entry->select.start + entry->select.length <= + (int)strlen(entry->buffer)) + evas_text_at(entry->evas, entry->text, + entry->select.start + entry->select.length - 1, &x2, + NULL, &tw, &th); else { - evas_text_at(entry->evas, entry->text, entry->select.start + entry->select.length - 2, &x2, NULL, &tw, &th); + evas_text_at(entry->evas, entry->text, + entry->select.start + entry->select.length - 2, &x2, + NULL, &tw, &th); tw += entry->end_width; } th = evas_get_text_height(entry->evas, entry->text); if (entry->obj_selection) { - ebits_move(entry->obj_selection, entry->x + x1 + entry->scroll_pos + p1l, entry->y + y1 + p1t); - ebits_resize(entry->obj_selection, x2 + tw - x1 + p2l + p2r, th + p2t + p2b); + ebits_move(entry->obj_selection, + entry->x + x1 + entry->scroll_pos + p1l, + entry->y + y1 + p1t); + ebits_resize(entry->obj_selection, x2 + tw - x1 + p2l + p2r, + th + p2t + p2b); ebits_show(entry->obj_selection); } } else { if (entry->obj_selection) - ebits_hide(entry->obj_selection); + ebits_hide(entry->obj_selection); } D_RETURN; @@ -393,18 +435,19 @@ void e_entry_init(void) { D_ENTER; - - ecore_event_filter_handler_add(ECORE_EVENT_PASTE_REQUEST, e_paste_request); - ecore_event_filter_handler_add(ECORE_EVENT_CLEAR_SELECTION, e_clear_selection); + + ecore_event_filter_handler_add(ECORE_EVENT_PASTE_REQUEST, e_paste_request); + ecore_event_filter_handler_add(ECORE_EVENT_CLEAR_SELECTION, + e_clear_selection); D_RETURN; } void -e_entry_free(E_Entry *entry) +e_entry_free(E_Entry * entry) { D_ENTER; - + entries = evas_list_remove(entries, entry); e_entry_unrealize(entry); IF_FREE(entry->buffer); @@ -413,13 +456,13 @@ e_entry_free(E_Entry *entry) D_RETURN; } -E_Entry * +E_Entry * e_entry_new(void) { - E_Entry *entry; - + E_Entry *entry; + D_ENTER; - + entry = NEW(E_Entry, 1); ZERO(entry, E_Entry, 1); e_strdup(entry->buffer, ""); @@ -431,11 +474,12 @@ e_entry_new(void) } void -e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e) +e_entry_handle_keypress(E_Entry * entry, Ecore_Event_Key_Down * e) { D_ENTER; - - if (!entry->focused) D_RETURN; + + if (!entry->focused) + D_RETURN; if (!strcmp(e->key, "Up")) { } @@ -445,14 +489,14 @@ e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e) else if (!strcmp(e->key, "Left")) { entry->cursor_pos--; - if (entry->cursor_pos < 0) - entry->cursor_pos = 0; + if (entry->cursor_pos < 0) + entry->cursor_pos = 0; } else if (!strcmp(e->key, "Right")) { entry->cursor_pos++; - if (entry->cursor_pos > (int)strlen(entry->buffer)) - entry->cursor_pos = strlen(entry->buffer); + if (entry->cursor_pos > (int)strlen(entry->buffer)) + entry->cursor_pos = strlen(entry->buffer); } else if (!strcmp(e->key, "Escape")) { @@ -461,20 +505,25 @@ e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e) else if (!strcmp(e->key, "BackSpace")) { /* char *str2; */ - - if (entry->select.start >= 0) e_entry_clear_selection(entry); - else if (entry->cursor_pos > 0) e_entry_delete_to_left(entry); + + if (entry->select.start >= 0) + e_entry_clear_selection(entry); + else if (entry->cursor_pos > 0) + e_entry_delete_to_left(entry); } else if (!strcmp(e->key, "Delete")) { /* char *str2; */ - - if (entry->select.start >= 0) e_entry_clear_selection(entry); - else if (entry->cursor_pos < (int)strlen(entry->buffer)) e_entry_delete_to_right(entry); + + if (entry->select.start >= 0) + e_entry_clear_selection(entry); + else if (entry->cursor_pos < (int)strlen(entry->buffer)) + e_entry_delete_to_right(entry); } else if (!strcmp(e->key, "Insert")) { - if (entry->paste_win) ecore_window_destroy(entry->paste_win); + if (entry->paste_win) + ecore_window_destroy(entry->paste_win); entry->paste_win = ecore_selection_request(); } else if (!strcmp(e->key, "Home")) @@ -483,7 +532,7 @@ e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e) } else if (!strcmp(e->key, "End")) { - entry->cursor_pos = strlen(entry->buffer); + entry->cursor_pos = strlen(entry->buffer); } else if (!strcmp(e->key, "Prior")) { @@ -491,49 +540,50 @@ e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e) } else if (!strcmp(e->key, "Next")) { - entry->cursor_pos = strlen(entry->buffer); + entry->cursor_pos = strlen(entry->buffer); } else if (!strcmp(e->key, "Return")) { entry->focused = 0; - if (entry->func_enter) - entry->func_enter(entry, entry->data_enter); + if (entry->func_enter) + entry->func_enter(entry, entry->data_enter); } else { - char *type; - + char *type; + type = ecore_keypress_translate_into_typeable(e); if (type) { D("Keypress: %0x\n", type[0]); - if ((strlen(type) == 1) && (type[0] == 0x01)) /* ctrl+a */ + if ((strlen(type) == 1) && (type[0] == 0x01)) /* ctrl+a */ { entry->cursor_pos = 0; } - else if ((strlen(type) == 1) && (type[0] == 0x05)) /* ctrl+e */ + else if ((strlen(type) == 1) && (type[0] == 0x05)) /* ctrl+e */ { entry->cursor_pos = strlen(entry->buffer); } - else if ((strlen(type) == 1) && (type[0] == 0x0b)) /* ctk+k */ + else if ((strlen(type) == 1) && (type[0] == 0x0b)) /* ctk+k */ { - char *str2; - + char *str2; + e_strdup(str2, e_entry_get_text(entry)); str2[entry->cursor_pos] = 0; e_entry_set_text(entry, str2); - free(str2); + free(str2); } - else if ((strlen(type) == 1) && (type[0] == 0x06)) /* ctrl+f */ + else if ((strlen(type) == 1) && (type[0] == 0x06)) /* ctrl+f */ { entry->cursor_pos++; if (entry->cursor_pos > (int)strlen(entry->buffer)) - entry->cursor_pos = strlen(entry->buffer); + entry->cursor_pos = strlen(entry->buffer); } - else if ((strlen(type) == 1) && (type[0] == 0x02)) /* ctrl+b */ + else if ((strlen(type) == 1) && (type[0] == 0x02)) /* ctrl+b */ { entry->cursor_pos--; - if (entry->cursor_pos < 0) entry->cursor_pos = 0; + if (entry->cursor_pos < 0) + entry->cursor_pos = 0; } else if (strlen(type) > 0) { @@ -541,18 +591,19 @@ e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e) e_entry_insert_text(entry, type); } } - } + } e_entry_configure(entry); D_RETURN; } void -e_entry_set_evas(E_Entry *entry, Evas evas) +e_entry_set_evas(E_Entry * entry, Evas evas) { D_ENTER; - - if (entry->evas) e_entry_unrealize(entry); + + if (entry->evas) + e_entry_unrealize(entry); entry->evas = evas; e_entry_realize(entry); e_entry_configure(entry); @@ -566,16 +617,21 @@ e_entry_set_evas(E_Entry *entry, Evas evas) } void -e_entry_show(E_Entry *entry) +e_entry_show(E_Entry * entry) { D_ENTER; - - if (entry->visible) D_RETURN; + + if (entry->visible) + D_RETURN; entry->visible = 1; - if (!entry->evas) D_RETURN; - if (entry->obj_base) ebits_show(entry->obj_base); - if (entry->obj_cursor) ebits_show(entry->obj_cursor); - if (entry->obj_selection) ebits_show(entry->obj_selection); + if (!entry->evas) + D_RETURN; + if (entry->obj_base) + ebits_show(entry->obj_base); + if (entry->obj_cursor) + ebits_show(entry->obj_cursor); + if (entry->obj_selection) + ebits_show(entry->obj_selection); evas_show(entry->evas, entry->event_box); evas_show(entry->evas, entry->clip_box); evas_show(entry->evas, entry->text); @@ -584,16 +640,21 @@ e_entry_show(E_Entry *entry) } void -e_entry_hide(E_Entry *entry) +e_entry_hide(E_Entry * entry) { D_ENTER; - - if (!entry->visible) D_RETURN; + + if (!entry->visible) + D_RETURN; entry->visible = 0; - if (!entry->evas) D_RETURN; - if (entry->obj_base) ebits_hide(entry->obj_base); - if (entry->obj_cursor) ebits_hide(entry->obj_cursor); - if (entry->obj_selection) ebits_hide(entry->obj_selection); + if (!entry->evas) + D_RETURN; + if (entry->obj_base) + ebits_hide(entry->obj_base); + if (entry->obj_cursor) + ebits_hide(entry->obj_cursor); + if (entry->obj_selection) + ebits_hide(entry->obj_selection); evas_hide(entry->evas, entry->event_box); evas_hide(entry->evas, entry->clip_box); evas_hide(entry->evas, entry->text); @@ -602,79 +663,88 @@ e_entry_hide(E_Entry *entry) } void -e_entry_raise(E_Entry *entry) +e_entry_raise(E_Entry * entry) { D_ENTER; - - if (entry->obj_base) ebits_raise(entry->obj_base); + + if (entry->obj_base) + ebits_raise(entry->obj_base); evas_raise(entry->evas, entry->clip_box); evas_raise(entry->evas, entry->text); - if (entry->obj_selection) ebits_raise(entry->obj_selection); - if (entry->obj_cursor) ebits_raise(entry->obj_cursor); + if (entry->obj_selection) + ebits_raise(entry->obj_selection); + if (entry->obj_cursor) + ebits_raise(entry->obj_cursor); evas_raise(entry->evas, entry->event_box); D_RETURN; } void -e_entry_lower(E_Entry *entry) +e_entry_lower(E_Entry * entry) { D_ENTER; - + evas_lower(entry->evas, entry->event_box); - if (entry->obj_cursor) ebits_lower(entry->obj_cursor); - if (entry->obj_selection) ebits_lower(entry->obj_selection); + if (entry->obj_cursor) + ebits_lower(entry->obj_cursor); + if (entry->obj_selection) + ebits_lower(entry->obj_selection); evas_lower(entry->evas, entry->text); evas_lower(entry->evas, entry->clip_box); - if (entry->obj_base) ebits_lower(entry->obj_base); + if (entry->obj_base) + ebits_lower(entry->obj_base); D_RETURN; } void -e_entry_set_layer(E_Entry *entry, int l) +e_entry_set_layer(E_Entry * entry, int l) { D_ENTER; - - if (entry->obj_base) ebits_set_layer(entry->obj_base, l); + + if (entry->obj_base) + ebits_set_layer(entry->obj_base, l); evas_set_layer(entry->evas, entry->clip_box, l); evas_set_layer(entry->evas, entry->text, l); - if (entry->obj_selection) ebits_set_layer(entry->obj_selection, l); - if (entry->obj_cursor) ebits_set_layer(entry->obj_cursor, l); + if (entry->obj_selection) + ebits_set_layer(entry->obj_selection, l); + if (entry->obj_cursor) + ebits_set_layer(entry->obj_cursor, l); evas_set_layer(entry->evas, entry->event_box, l); D_RETURN; } void -e_entry_set_clip(E_Entry *entry, Evas_Object clip) +e_entry_set_clip(E_Entry * entry, Evas_Object clip) { D_ENTER; - + evas_set_clip(entry->evas, entry->clip_box, clip); - if (entry->obj_base) - ebits_set_clip(entry->obj_base, clip); + if (entry->obj_base) + ebits_set_clip(entry->obj_base, clip); D_RETURN; } void -e_entry_unset_clip(E_Entry *entry) +e_entry_unset_clip(E_Entry * entry) { D_ENTER; - + evas_unset_clip(entry->evas, entry->clip_box); - if (entry->obj_base) - ebits_unset_clip(entry->obj_base); + if (entry->obj_base) + ebits_unset_clip(entry->obj_base); D_RETURN; } void -e_entry_move(E_Entry *entry, int x, int y) +e_entry_move(E_Entry * entry, int x, int y) { D_ENTER; - + entry->x = x; entry->y = y; e_entry_configure(entry); @@ -683,10 +753,10 @@ e_entry_move(E_Entry *entry, int x, int y) } void -e_entry_resize(E_Entry *entry, int w, int h) +e_entry_resize(E_Entry * entry, int w, int h) { D_ENTER; - + entry->w = w; entry->h = h; e_entry_configure(entry); @@ -695,72 +765,90 @@ e_entry_resize(E_Entry *entry, int w, int h) } void -e_entry_query_max_size(E_Entry *entry, int *w, int *h) +e_entry_query_max_size(E_Entry * entry, int *w, int *h) { - int p1l, p1r, p1t, p1b; - int p2l, p2r, p2t, p2b; - + int p1l, p1r, p1t, p1b; + int p2l, p2r, p2t, p2b; + D_ENTER; - + p1l = p1r = p1t = p1b = 0; - if (entry->obj_base) ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); + if (entry->obj_base) + ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); p2l = p2r = p2t = p2b = 0; - if (entry->obj_cursor) ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); - - if (w) *w = evas_get_text_width(entry->evas, entry->text) + p1l + p1r + p2l + p2r; - if (h) *h = evas_get_text_height(entry->evas, entry->text) + p1t + p1b + p2t + p2b; + if (entry->obj_cursor) + ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); + + if (w) + *w = + evas_get_text_width(entry->evas, entry->text) + p1l + p1r + p2l + p2r; + if (h) + *h = + evas_get_text_height(entry->evas, entry->text) + p1t + p1b + p2t + p2b; D_RETURN; } void -e_entry_max_size(E_Entry *entry, int *w, int *h) +e_entry_max_size(E_Entry * entry, int *w, int *h) { - int p1l, p1r, p1t, p1b; - int p2l, p2r, p2t, p2b; - + int p1l, p1r, p1t, p1b; + int p2l, p2r, p2t, p2b; + D_ENTER; - + p1l = p1r = p1t = p1b = 0; - if (entry->obj_base) ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); + if (entry->obj_base) + ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); p2l = p2r = p2t = p2b = 0; - if (entry->obj_cursor) ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); - if (w) *w = 8000; - if (h) *h = evas_get_text_height(entry->evas, entry->text) + p1t + p1b + p2t + p2b; + if (entry->obj_cursor) + ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); + if (w) + *w = 8000; + if (h) + *h = + evas_get_text_height(entry->evas, entry->text) + p1t + p1b + p2t + p2b; D_RETURN; } void -e_entry_min_size(E_Entry *entry, int *w, int *h) +e_entry_min_size(E_Entry * entry, int *w, int *h) { - int p1l, p1r, p1t, p1b; - int p2l, p2r, p2t, p2b; - + int p1l, p1r, p1t, p1b; + int p2l, p2r, p2t, p2b; + D_ENTER; - + p1l = p1r = p1t = p1b = 0; - if (entry->obj_base) ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); + if (entry->obj_base) + ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); p2l = p2r = p2t = p2b = 0; - if (entry->obj_cursor) ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); - if (w) *w = p1l + p1r + p2l + p2r + entry->min_size; - if (h) *h = evas_get_text_height(entry->evas, entry->text) + p1t + p1b + p2t + p2b; + if (entry->obj_cursor) + ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); + if (w) + *w = p1l + p1r + p2l + p2r + entry->min_size; + if (h) + *h = + evas_get_text_height(entry->evas, entry->text) + p1t + p1b + p2t + p2b; D_RETURN; } void -e_entry_set_size(E_Entry *entry, int w, int h) +e_entry_set_size(E_Entry * entry, int w, int h) { - int p1l, p1r, p1t, p1b; - int p2l, p2r, p2t, p2b; - + int p1l, p1r, p1t, p1b; + int p2l, p2r, p2t, p2b; + D_ENTER; - + p1l = p1r = p1t = p1b = 0; - if (entry->obj_base) ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); + if (entry->obj_base) + ebits_get_insets(entry->obj_base, &p1l, &p1r, &p1t, &p1b); p2l = p2r = p2t = p2b = 0; - if (entry->obj_cursor) ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); + if (entry->obj_cursor) + ebits_get_insets(entry->obj_cursor, &p2l, &p2r, &p2t, &p2b); if (p1l + p1r + p2l + p2r + w > entry->w) { entry->min_size = w; @@ -772,76 +860,79 @@ e_entry_set_size(E_Entry *entry, int w, int h) } void -e_entry_set_focus(E_Entry *entry, int focused) +e_entry_set_focus(E_Entry * entry, int focused) { D_ENTER; - - if (entry->focused == focused) D_RETURN; + + if (entry->focused == focused) + D_RETURN; entry->focused = focused; e_entry_configure(entry); if (entry->focused) { - if (entry->func_focus_in) - entry->func_focus_in(entry, entry->data_focus_in); + if (entry->func_focus_in) + entry->func_focus_in(entry, entry->data_focus_in); } else { - if (entry->func_focus_out) - entry->func_focus_out(entry, entry->data_focus_out); + if (entry->func_focus_out) + entry->func_focus_out(entry, entry->data_focus_out); } D_RETURN; } void -e_entry_set_text(E_Entry *entry, const char *text) +e_entry_set_text(E_Entry * entry, const char *text) { D_ENTER; - + IF_FREE(entry->buffer); e_strdup(entry->buffer, text); evas_set_text(entry->evas, entry->text, entry->buffer); if (entry->cursor_pos > (int)strlen(entry->buffer)) - entry->cursor_pos = strlen(entry->buffer); + entry->cursor_pos = strlen(entry->buffer); e_entry_configure(entry); - if (entry->func_changed) - entry->func_changed(entry, entry->data_changed); + if (entry->func_changed) + entry->func_changed(entry, entry->data_changed); D_RETURN; } -const char * -e_entry_get_text(E_Entry *entry) +const char * +e_entry_get_text(E_Entry * entry) { D_ENTER; - + D_RETURN_(entry->buffer); } void -e_entry_set_cursor(E_Entry *entry, int cursor_pos) +e_entry_set_cursor(E_Entry * entry, int cursor_pos) { D_ENTER; - + entry->cursor_pos = cursor_pos; - e_entry_configure(entry); + e_entry_configure(entry); D_RETURN; } int -e_entry_get_cursor(E_Entry *entry) +e_entry_get_cursor(E_Entry * entry) { D_ENTER; - + D_RETURN_(entry->cursor_pos); } void -e_entry_set_changed_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void *_data), void *data) +e_entry_set_changed_callback(E_Entry * entry, + void (*func) (E_Entry * _entry, void *_data), + void *data) { D_ENTER; - + entry->func_changed = func; entry->data_changed = data; @@ -849,10 +940,12 @@ e_entry_set_changed_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void } void -e_entry_set_enter_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void *_data), void *data) +e_entry_set_enter_callback(E_Entry * entry, + void (*func) (E_Entry * _entry, void *_data), + void *data) { D_ENTER; - + entry->func_enter = func; entry->data_enter = data; @@ -860,10 +953,12 @@ e_entry_set_enter_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void * } void -e_entry_set_focus_in_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void *_data), void *data) +e_entry_set_focus_in_callback(E_Entry * entry, + void (*func) (E_Entry * _entry, void *_data), + void *data) { D_ENTER; - + entry->func_focus_in = func; entry->data_focus_in = data; @@ -871,10 +966,12 @@ e_entry_set_focus_in_callback(E_Entry *entry, void (*func) (E_Entry *_entry, voi } void -e_entry_set_focus_out_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void *_data), void *data) +e_entry_set_focus_out_callback(E_Entry * entry, + void (*func) (E_Entry * _entry, void *_data), + void *data) { D_ENTER; - + entry->func_focus_out = func; entry->data_focus_out = data; @@ -882,13 +979,14 @@ e_entry_set_focus_out_callback(E_Entry *entry, void (*func) (E_Entry *_entry, vo } void -e_entry_insert_text(E_Entry *entry, char *text) +e_entry_insert_text(E_Entry * entry, char *text) { - char *str2; - + char *str2; + D_ENTER; - - if (!text) D_RETURN; + + if (!text) + D_RETURN; str2 = malloc(strlen(e_entry_get_text(entry)) + 1 + strlen(text)); str2[0] = 0; strncat(str2, entry->buffer, entry->cursor_pos); @@ -896,27 +994,29 @@ e_entry_insert_text(E_Entry *entry, char *text) strcat(str2, &(entry->buffer[entry->cursor_pos])); e_entry_set_text(entry, str2); free(str2); - entry->cursor_pos+=strlen(text); + entry->cursor_pos += strlen(text); e_entry_configure(entry); D_RETURN; } void -e_entry_clear_selection(E_Entry *entry) +e_entry_clear_selection(E_Entry * entry) { - char *str2; - + char *str2; + D_ENTER; - + if (entry->select.start >= 0) { e_strdup(str2, e_entry_get_text(entry)); - if (entry->select.start + entry->select.length > (int)strlen(entry->buffer)) - entry->select.length = strlen(entry->buffer) - entry->select.start; - strcpy(&(str2[entry->select.start]), &(entry->buffer[entry->select.start + entry->select.length])); + if (entry->select.start + entry->select.length > + (int)strlen(entry->buffer)) + entry->select.length = strlen(entry->buffer) - entry->select.start; + strcpy(&(str2[entry->select.start]), + &(entry->buffer[entry->select.start + entry->select.length])); e_entry_set_text(entry, str2); - free(str2); + free(str2); entry->cursor_pos = entry->select.start; entry->select.start = -1; } @@ -926,12 +1026,12 @@ e_entry_clear_selection(E_Entry *entry) } void -e_entry_delete_to_left(E_Entry *entry) +e_entry_delete_to_left(E_Entry * entry) { - char *str2; - + char *str2; + D_ENTER; - + e_strdup(str2, e_entry_get_text(entry)); strcpy(&(str2[entry->cursor_pos - 1]), &(entry->buffer[entry->cursor_pos])); entry->cursor_pos--; @@ -942,12 +1042,12 @@ e_entry_delete_to_left(E_Entry *entry) } void -e_entry_delete_to_right(E_Entry *entry) +e_entry_delete_to_right(E_Entry * entry) { - char *str2; - + char *str2; + D_ENTER; - + e_strdup(str2, e_entry_get_text(entry)); strcpy(&(str2[entry->cursor_pos]), &(entry->buffer[entry->cursor_pos + 1])); e_entry_set_text(entry, str2); @@ -957,19 +1057,20 @@ e_entry_delete_to_right(E_Entry *entry) D_RETURN; } -char * -e_entry_get_selection(E_Entry *entry) +char * +e_entry_get_selection(E_Entry * entry) { D_ENTER; - + if (entry->select.start >= 0) { - char *str2; - int len; - + char *str2; + int len; + len = entry->select.length; - if (entry->select.start + entry->select.length >= (int)strlen(entry->buffer)) - len = strlen(entry->buffer) - entry->select.start; + if (entry->select.start + entry->select.length >= + (int)strlen(entry->buffer)) + len = strlen(entry->buffer) - entry->select.start; str2 = e_util_memdup(&(entry->buffer[entry->select.start]), len + 1); str2[len] = 0; D_RETURN_(str2); diff --git a/src/entry.h b/src/entry.h index c2f393e45..72a324c27 100644 --- a/src/entry.h +++ b/src/entry.h @@ -3,80 +3,96 @@ #include "e.h" -typedef struct _E_Entry E_Entry; +typedef struct _E_Entry E_Entry; struct _E_Entry { - Evas evas; - char *buffer; - int cursor_pos; - struct { - int start, length, down; - } select; - int mouse_down; - int visible; - int focused; - int scroll_pos; - int x, y, w, h; - int min_size; - Ebits_Object obj_base; - Ebits_Object obj_cursor; - Ebits_Object obj_selection; - Evas_Object event_box; - Evas_Object clip_box; - Evas_Object text; - Window paste_win; - Window selection_win; - int end_width; - void (*func_changed) (E_Entry *entry, void *data); - void *data_changed; - void (*func_enter) (E_Entry *entry, void *data); - void *data_enter; - void (*func_focus_in) (E_Entry *entry, void *data); - void *data_focus_in; - void (*func_focus_out) (E_Entry *entry, void *data); - void *data_focus_out; + Evas evas; + char *buffer; + int cursor_pos; + struct + { + int start, length, down; + } + select; + int mouse_down; + int visible; + int focused; + int scroll_pos; + int x, y, w, h; + int min_size; + Ebits_Object obj_base; + Ebits_Object obj_cursor; + Ebits_Object obj_selection; + Evas_Object event_box; + Evas_Object clip_box; + Evas_Object text; + Window paste_win; + Window selection_win; + int end_width; + void (*func_changed) (E_Entry * entry, void *data); + void *data_changed; + void (*func_enter) (E_Entry * entry, void *data); + void *data_enter; + void (*func_focus_in) (E_Entry * entry, void *data); + void *data_focus_in; + void (*func_focus_out) (E_Entry * entry, void *data); + void *data_focus_out; }; - /** * e_entry_init - Text entry widget event handler initialization. * * This function initalizes the entry widget code, it registers * the event handlers needed for managing a text entry widget. */ -void e_entry_init(void); +void e_entry_init(void); -void e_entry_free(E_Entry *entry); -E_Entry *e_entry_new(void); -void e_entry_handle_keypress(E_Entry *entry, Ecore_Event_Key_Down *e); -void e_entry_set_evas(E_Entry *entry, Evas evas); -void e_entry_show(E_Entry *entry); -void e_entry_hide(E_Entry *entry); -void e_entry_raise(E_Entry *entry); -void e_entry_lower(E_Entry *entry); -void e_entry_set_layer(E_Entry *entry, int l); -void e_entry_set_clip(E_Entry *entry, Evas_Object clip); -void e_entry_unset_clip(E_Entry *entry); -void e_entry_move(E_Entry *entry, int x, int y); -void e_entry_resize(E_Entry *entry, int w, int h); -void e_entry_query_max_size(E_Entry *entry, int *w, int *h); -void e_entry_max_size(E_Entry *entry, int *w, int *h); -void e_entry_min_size(E_Entry *entry, int *w, int *h); -void e_entry_set_size(E_Entry *entry, int w, int h); -void e_entry_set_focus(E_Entry *entry, int focused); -void e_entry_set_text(E_Entry *entry, const char *text); -const char *e_entry_get_text(E_Entry *entry); -void e_entry_set_cursor(E_Entry *entry, int cursor_pos); -int e_entry_get_cursor(E_Entry *entry); -void e_entry_set_changed_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void *_data), void *data); -void e_entry_set_enter_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void *_data), void *data); -void e_entry_set_focus_in_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void *_data), void *data); -void e_entry_set_focus_out_callback(E_Entry *entry, void (*func) (E_Entry *_entry, void *_data), void *data); -void e_entry_insert_text(E_Entry *entry, char *text); -void e_entry_clear_selection(E_Entry *entry); -void e_entry_delete_to_left(E_Entry *entry); -void e_entry_delete_to_right(E_Entry *entry); -char *e_entry_get_selection(E_Entry *entry); +void e_entry_free(E_Entry * entry); +E_Entry *e_entry_new(void); +void e_entry_handle_keypress(E_Entry * entry, + Ecore_Event_Key_Down * e); +void e_entry_set_evas(E_Entry * entry, Evas evas); +void e_entry_show(E_Entry * entry); +void e_entry_hide(E_Entry * entry); +void e_entry_raise(E_Entry * entry); +void e_entry_lower(E_Entry * entry); +void e_entry_set_layer(E_Entry * entry, int l); +void e_entry_set_clip(E_Entry * entry, Evas_Object clip); +void e_entry_unset_clip(E_Entry * entry); +void e_entry_move(E_Entry * entry, int x, int y); +void e_entry_resize(E_Entry * entry, int w, int h); +void e_entry_query_max_size(E_Entry * entry, int *w, int *h); +void e_entry_max_size(E_Entry * entry, int *w, int *h); +void e_entry_min_size(E_Entry * entry, int *w, int *h); +void e_entry_set_size(E_Entry * entry, int w, int h); +void e_entry_set_focus(E_Entry * entry, int focused); +void e_entry_set_text(E_Entry * entry, const char *text); +const char *e_entry_get_text(E_Entry * entry); +void e_entry_set_cursor(E_Entry * entry, int cursor_pos); +int e_entry_get_cursor(E_Entry * entry); +void e_entry_set_changed_callback(E_Entry * entry, + void (*func) (E_Entry * _entry, + void *_data), + void *data); +void e_entry_set_enter_callback(E_Entry * entry, + void (*func) (E_Entry * _entry, + void *_data), + void *data); +void e_entry_set_focus_in_callback(E_Entry * entry, + void (*func) (E_Entry * + _entry, + void *_data), + void *data); +void e_entry_set_focus_out_callback(E_Entry * entry, + void (*func) (E_Entry * + _entry, + void *_data), + void *data); +void e_entry_insert_text(E_Entry * entry, char *text); +void e_entry_clear_selection(E_Entry * entry); +void e_entry_delete_to_left(E_Entry * entry); +void e_entry_delete_to_right(E_Entry * entry); +char *e_entry_get_selection(E_Entry * entry); #endif diff --git a/src/epplet.c b/src/epplet.c index 154dfc7be..ee71f79a5 100644 --- a/src/epplet.c +++ b/src/epplet.c @@ -6,32 +6,32 @@ #include "e_ferite.h" -static void e_epplet_cleanup(E_Epplet *epp); -static void e_epplet_mouse_down_cb (void *_data, Ebits_Object _o, - char *_c, int _b, int _x, int _y, - int _ox, int _oy, int _ow, int _oh); +static void e_epplet_cleanup(E_Epplet * epp); +static void e_epplet_mouse_down_cb(void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh); -static void e_epplet_mouse_up_cb (void *_data, Ebits_Object _o, - char *_c, int _b, int _x, int _y, - int _ox, int _oy, int _ow, int _oh); +static void e_epplet_mouse_up_cb(void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh); -static void e_epplet_mouse_move_cb (void *_data, Ebits_Object _o, - char *_c, int _b, int _x, int _y, - int _ox, int _oy, int _ow, int _oh); +static void e_epplet_mouse_move_cb(void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh); -static void e_epplet_observer_cleanup(E_Object *o); +static void e_epplet_observer_cleanup(E_Object * o); -E_Epplet * +E_Epplet * e_epplet_new(void *scr) { #ifdef USE_FERITE - E_Epplet *epp; - FeriteScript *script; - char buf[PATH_MAX]; - + E_Epplet *epp; + FeriteScript *script; + char buf[PATH_MAX]; + D_ENTER; - script = (FeriteScript *)scr; + script = (FeriteScript *) scr; epp = NEW(E_Epplet, 1); ZERO(epp, E_Epplet, 1); @@ -40,11 +40,11 @@ e_epplet_new(void *scr) epp->context = e_epplet_get_context_from_script(script); if (!(epp->context)) - { - D("Error: epplet context not found\n"); - D_RETURN_(NULL); - } - + { + D("Error: epplet context not found\n"); + D_RETURN_(NULL); + } + epp->view = epp->context->view; epp->name = strdup(epp->context->name); epp->current.x = epp->context->geom.x; @@ -57,170 +57,171 @@ e_epplet_new(void *scr) epp->dir = strdup(buf); if (!(epp->view)) - { - D("Error: no view found for epplet: %s\n", epp->name); - e_object_unref(E_OBJECT(epp)); - D_RETURN_(NULL); - } + { + D("Error: no view found for epplet: %s\n", epp->name); + e_object_unref(E_OBJECT(epp)); + D_RETURN_(NULL); + } else - { - D_RETURN_(epp); - } + { + D_RETURN_(epp); + } #endif - + } - + static void -e_epplet_cleanup(E_Epplet *epp) +e_epplet_cleanup(E_Epplet * epp) { - Evas_List l; - + Evas_List l; + D_ENTER; - + #ifdef USE_FERITE for (l = epp->ebits; l; l = l->next) - { - Ebits_Object o = l->data; - ebits_free(o); - } - + { + Ebits_Object o = l->data; + + ebits_free(o); + } + for (l = epp->evas_objects; l; l = l->next) - { - Evas_Object_Wrapper *o = l->data; - evas_del_object(o->evas, o->obj); + { + Evas_Object_Wrapper *o = l->data; - free(o); - } + evas_del_object(o->evas, o->obj); - if (epp->layout) ebits_free(epp->layout); - if (epp->ui) ebits_free(epp->ui); + free(o); + } + + if (epp->layout) + ebits_free(epp->layout); + if (epp->ui) + ebits_free(epp->ui); #endif - D_RETURN; + D_RETURN; } void -e_epplet_load_from_layout (E_View * v) +e_epplet_load_from_layout(E_View * v) { - char buf[PATH_MAX]; - Evas_List bit_names, l; + char buf[PATH_MAX]; + Evas_List bit_names, l; - D_ENTER; + D_ENTER; -#ifdef USE_FERITE - snprintf (buf, PATH_MAX, "%s/.e_epplets.bits.db", v->dir); - v->epplet_layout = ebits_load (buf); - if (!v->epplet_layout) - D_RETURN; - ebits_add_to_evas (v->epplet_layout, v->evas); - ebits_resize (v->epplet_layout, v->size.w, v->size.h); - ebits_move (v->epplet_layout, 0, 0); - - bit_names = ebits_get_bit_names (v->epplet_layout); - - for (l = bit_names; l; l = l->next) - { - double x, y, w, h; - E_Epplet_Context *context; - - context = NEW (E_Epplet_Context, 1); - ZERO (context, E_Epplet_Context, 1); - - context->name = l->data; - - ebits_get_named_bit_geometry (v->epplet_layout, context->name, &x, &y, - &w, &h); - - context->geom.x = x; - context->geom.y = y; - context->geom.w = w; - context->geom.h = h; - context->view = v; - D ("epplet has following info:\n"); - D ("x: %f, y: %f, w: %f, h: %f\n", x, y, w, h); - - v->epplet_contexts = evas_list_append (v->epplet_contexts, context); - - snprintf (buf, PATH_MAX, "%s/.e_epplets/%s/%s.fe", v->dir, context->name, - context->name); - if (e_file_exists (buf)) - e_epplet_script_load (context, buf); - else - D ("Error: Can't find epplet `%s'\n", buf); - } -#endif - - D_RETURN; -} - - - -E_Epplet_Context * -e_epplet_get_context_from_script (FeriteScript * script) -{ - Evas_List l, ll; - - D_ENTER; - - D ("script address: %p\n", script); - -#ifdef USE_FERITE - for (l = views; l; l = l->next) - { - E_View *v; - - v = l->data; - D ("searching view: %s\n", v->dir); - - if (v->epplet_contexts == NULL) - D ("no scripts in view\n"); - for (ll = v->epplet_contexts; ll; ll = ll->next) - { - E_Epplet_Context *context = ll->data; - D ("found script: %p\n", context->script); - - if (context->script == script) - D_RETURN_ (context); - } - } -#endif - - D_RETURN_ (NULL); -} - - -void -e_epplet_script_load (E_Epplet_Context * context, char *path) -{ - FeriteScript *script = NULL; - - D_ENTER; - -#ifdef USE_FERITE - D ("Ferite: Compiling epplet script `%s'\n", path); - script = ferite_script_compile (path); - - if (!script) - { - D ("Error compiling script... aborting\n"); +#ifdef USE_FERITE + snprintf(buf, PATH_MAX, "%s/.e_epplets.bits.db", v->dir); + v->epplet_layout = ebits_load(buf); + if (!v->epplet_layout) D_RETURN; - } - context->script = script; - e_ferite_register (script, script->mainns); - script->error_cb = e_ferite_script_error; - script->warning_cb = e_ferite_script_warning; - D ("Ferite: executing epplet.\n"); + ebits_add_to_evas(v->epplet_layout, v->evas); + ebits_resize(v->epplet_layout, v->size.w, v->size.h); + ebits_move(v->epplet_layout, 0, 0); - ferite_script_execute (script); - D ("Ferite: epplet executed.\n"); - /*ferite_script_delete(script); */ + bit_names = ebits_get_bit_names(v->epplet_layout); + + for (l = bit_names; l; l = l->next) + { + double x, y, w, h; + E_Epplet_Context *context; + + context = NEW(E_Epplet_Context, 1); + ZERO(context, E_Epplet_Context, 1); + + context->name = l->data; + + ebits_get_named_bit_geometry(v->epplet_layout, context->name, &x, &y, + &w, &h); + + context->geom.x = x; + context->geom.y = y; + context->geom.w = w; + context->geom.h = h; + context->view = v; + D("epplet has following info:\n"); + D("x: %f, y: %f, w: %f, h: %f\n", x, y, w, h); + + v->epplet_contexts = evas_list_append(v->epplet_contexts, context); + + snprintf(buf, PATH_MAX, "%s/.e_epplets/%s/%s.fe", v->dir, context->name, + context->name); + if (e_file_exists(buf)) + e_epplet_script_load(context, buf); + else + D("Error: Can't find epplet `%s'\n", buf); + } #endif - D_RETURN; + D_RETURN; } +E_Epplet_Context * +e_epplet_get_context_from_script(FeriteScript * script) +{ + Evas_List l, ll; + + D_ENTER; + + D("script address: %p\n", script); + +#ifdef USE_FERITE + for (l = views; l; l = l->next) + { + E_View *v; + + v = l->data; + D("searching view: %s\n", v->dir); + + if (v->epplet_contexts == NULL) + D("no scripts in view\n"); + for (ll = v->epplet_contexts; ll; ll = ll->next) + { + E_Epplet_Context *context = ll->data; + + D("found script: %p\n", context->script); + + if (context->script == script) + D_RETURN_(context); + } + } +#endif + + D_RETURN_(NULL); +} void -e_epplet_set_common_callbacks (E_Epplet * epp) +e_epplet_script_load(E_Epplet_Context * context, char *path) +{ + FeriteScript *script = NULL; + + D_ENTER; + +#ifdef USE_FERITE + D("Ferite: Compiling epplet script `%s'\n", path); + script = ferite_script_compile(path); + + if (!script) + { + D("Error compiling script... aborting\n"); + D_RETURN; + } + context->script = script; + e_ferite_register(script, script->mainns); + script->error_cb = e_ferite_script_error; + script->warning_cb = e_ferite_script_warning; + D("Ferite: executing epplet.\n"); + + ferite_script_execute(script); + D("Ferite: epplet executed.\n"); + /*ferite_script_delete(script); */ +#endif + + D_RETURN; +} + +void +e_epplet_set_common_callbacks(E_Epplet * epp) { /* D ("setting callbacks\n"); @@ -232,7 +233,6 @@ e_epplet_set_common_callbacks (E_Epplet * epp) D_RETURN; } - ebits_set_classed_bit_callback (epp->bits, "Title_Bar", CALLBACK_MOUSE_DOWN, e_epplet_mouse_down_cb, epp); @@ -276,122 +276,120 @@ e_epplet_set_common_callbacks (E_Epplet * epp) } static void -e_epplet_mouse_down_cb (void *_data, Ebits_Object _o, - char *_c, int _b, int _x, int _y, - int _ox, int _oy, int _ow, int _oh) +e_epplet_mouse_down_cb(void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh) { - E_Epplet *epp; + E_Epplet *epp; - D_ENTER; + D_ENTER; -#ifdef USE_FERITE - epp = _data; +#ifdef USE_FERITE + epp = _data; - if (!strcmp (_c, "Title_Bar")) - { - epp->state.moving = 1; - epp->offset.x = _x - epp->current.x; - epp->offset.y = _y - epp->current.y; - } + if (!strcmp(_c, "Title_Bar")) + { + epp->state.moving = 1; + epp->offset.x = _x - epp->current.x; + epp->offset.y = _y - epp->current.y; + } - if (!strcmp (_c, "Resize")) - { - if (_x < epp->current.x + (epp->current.w / 2)) - { - epp->state.resizing.left = 1; - epp->offset.x = epp->current.x - _x; - } - if (_x >= epp->current.x + (epp->current.w / 2)) - { - epp->state.resizing.right = 1; - epp->offset.x = epp->current.x + epp->current.w - _x; - } - if (_y < epp->current.y + (epp->current.h / 2)) - { - epp->state.resizing.up = 1; - epp->offset.y = epp->current.y - _y; - } - if (_y >= epp->current.y + (epp->current.h / 2)) - { - epp->state.resizing.down = 1; - epp->offset.y = epp->current.y + epp->current.h - _y; - } + if (!strcmp(_c, "Resize")) + { + if (_x < epp->current.x + (epp->current.w / 2)) + { + epp->state.resizing.left = 1; + epp->offset.x = epp->current.x - _x; + } + if (_x >= epp->current.x + (epp->current.w / 2)) + { + epp->state.resizing.right = 1; + epp->offset.x = epp->current.x + epp->current.w - _x; + } + if (_y < epp->current.y + (epp->current.h / 2)) + { + epp->state.resizing.up = 1; + epp->offset.y = epp->current.y - _y; + } + if (_y >= epp->current.y + (epp->current.h / 2)) + { + epp->state.resizing.down = 1; + epp->offset.y = epp->current.y + epp->current.h - _y; + } - } + } - if (!strcmp (_c, "Resize_Horizontal")) - { - if (_x < epp->current.x + (epp->current.w / 2)) - { - epp->state.resizing.left = 1; - epp->offset.x = epp->current.x - _x; - } - else - { - epp->state.resizing.right = 1; - epp->offset.x = epp->current.x + epp->current.w - _x; - } - } + if (!strcmp(_c, "Resize_Horizontal")) + { + if (_x < epp->current.x + (epp->current.w / 2)) + { + epp->state.resizing.left = 1; + epp->offset.x = epp->current.x - _x; + } + else + { + epp->state.resizing.right = 1; + epp->offset.x = epp->current.x + epp->current.w - _x; + } + } - if (!strcmp (_c, "Resize_Vertical")) - { - if (_y < epp->current.y + (epp->current.h / 2)) - { - epp->state.resizing.up = 1; - epp->offset.y = epp->current.y - _y; - } - else - { - epp->state.resizing.down = 1; - epp->offset.y = epp->current.y + epp->current.h - _y; - } - } + if (!strcmp(_c, "Resize_Vertical")) + { + if (_y < epp->current.y + (epp->current.h / 2)) + { + epp->state.resizing.up = 1; + epp->offset.y = epp->current.y - _y; + } + else + { + epp->state.resizing.down = 1; + epp->offset.y = epp->current.y + epp->current.h - _y; + } + } #endif - - D_RETURN; -} - - -static void -e_epplet_mouse_up_cb (void *_data, Ebits_Object _o, - char *_c, int _b, int _x, int _y, - int _ox, int _oy, int _ow, int _oh) -{ - E_Epplet *epp; - - D_ENTER; - -#ifdef USE_FERITE - epp = _data; - - if (!strcmp (_c, "Title_Bar")) - { - epp->state.moving = 0; - } - - if (!strncmp (_c, "Resize", 6)) - { - epp->state.resizing.up = 0; - epp->state.resizing.down = 0; - epp->state.resizing.left = 0; - epp->state.resizing.right = 0; - } -#endif - D_RETURN; + D_RETURN; } static void -e_epplet_mouse_move_cb (void *_data, Ebits_Object _o, - char *_c, int _b, int _x, int _y, - int _ox, int _oy, int _ow, int _oh) +e_epplet_mouse_up_cb(void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh) { - E_Epplet *epp; - double x, y; + E_Epplet *epp; - D_ENTER; + D_ENTER; -#ifdef USE_FERITE +#ifdef USE_FERITE + epp = _data; + + if (!strcmp(_c, "Title_Bar")) + { + epp->state.moving = 0; + } + + if (!strncmp(_c, "Resize", 6)) + { + epp->state.resizing.up = 0; + epp->state.resizing.down = 0; + epp->state.resizing.left = 0; + epp->state.resizing.right = 0; + } +#endif + D_RETURN; +} + +static void +e_epplet_mouse_move_cb(void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh) +{ + E_Epplet *epp; + double x, y; + + D_ENTER; + +#ifdef USE_FERITE /* epp = _data; if (epp->state.moving) @@ -487,320 +485,337 @@ e_epplet_mouse_move_cb (void *_data, Ebits_Object _o, */ #endif - D_RETURN; + D_RETURN; } - -E_Epplet_CB_Info * -e_epplet_cb_new( FeriteScript *script, char *func_name, FeriteObject *data, FeriteObject *data2 ) +E_Epplet_CB_Info * +e_epplet_cb_new(FeriteScript * script, char *func_name, FeriteObject * data, + FeriteObject * data2) { - E_Epplet_CB_Info *cb; - FeriteNamespaceBucket *nsb; - - D_ENTER; - -#ifdef USE_FERITE - cb = NEW(E_Epplet_CB_Info, 1); - ZERO(cb, E_Epplet_CB_Info, 1); + E_Epplet_CB_Info *cb; + FeriteNamespaceBucket *nsb; - nsb = __ferite_find_namespace( script, script->mainns, func_name, FENS_FNC); - if (nsb != NULL) - { - cb->func = nsb->data; - if (data) + D_ENTER; + +#ifdef USE_FERITE + cb = NEW(E_Epplet_CB_Info, 1); + ZERO(cb, E_Epplet_CB_Info, 1); + + nsb = __ferite_find_namespace(script, script->mainns, func_name, FENS_FNC); + if (nsb != NULL) { - cb->data = data; - data->refcount++; + cb->func = nsb->data; + if (data) + { + cb->data = data; + data->refcount++; + } + if (data2) + { + cb->data2 = data2; + data2->refcount++; + } + cb->script = script; } - if (data2) - { - cb->data2 = data2; - data2->refcount++; - } - cb->script = script; - } #endif - D_RETURN_(cb); + D_RETURN_(cb); } void -e_epplet_cb_cleanup(E_Epplet_CB_Info *cb) +e_epplet_cb_cleanup(E_Epplet_CB_Info * cb) { #ifdef USE_FERITE if (cb->data) - { - cb->data->refcount--; - cb->data = NULL; - } + { + cb->data->refcount--; + cb->data = NULL; + } if (cb->data2) - { - cb->data2->refcount--; - cb->data2 = NULL; - } + { + cb->data2->refcount--; + cb->data2 = NULL; + } free(cb); #endif } void -e_epplet_bits_cb (void *_data, Ebits_Object _o, - char *_c, int _b, int _x, int _y, - int _ox, int _oy, int _ow, int _oh) +e_epplet_bits_cb(void *_data, Ebits_Object _o, + char *_c, int _b, int _x, int _y, + int _ox, int _oy, int _ow, int _oh) { - E_Epplet_CB_Info *cb; - FeriteVariable **params; - - D_ENTER; + E_Epplet_CB_Info *cb; + FeriteVariable **params; -#ifdef USE_FERITE - cb = _data; + D_ENTER; - if (cb->script) { - D("creating params and calling func\n"); - params = __ferite_create_parameter_list_from_data( cb->script, "osnnnnnnn", - cb->data, _c, _b, _x, _y, _ox, _oy, _ow, _oh ); - __ferite_variable_destroy( cb->script, __ferite_call_function( cb->script, cb->func, params)); - __ferite_delete_parameter_list( cb->script, params ); - D("func called, params deleted\n"); - } - else - { - D("ERROR: script does not exist\n"); - } - /* e_epplet_cb_cleanup(cb); */ +#ifdef USE_FERITE + cb = _data; + + if (cb->script) + { + D("creating params and calling func\n"); + params = + __ferite_create_parameter_list_from_data(cb->script, "osnnnnnnn", + cb->data, _c, _b, _x, _y, + _ox, _oy, _ow, _oh); + __ferite_variable_destroy(cb->script, + __ferite_call_function(cb->script, cb->func, + params)); + __ferite_delete_parameter_list(cb->script, params); + D("func called, params deleted\n"); + } + else + { + D("ERROR: script does not exist\n"); + } + /* e_epplet_cb_cleanup(cb); */ #endif - D_RETURN; + D_RETURN; } void -e_epplet_evas_cb (void *_data, Evas _e, Evas_Object _o, - int _b, int _x, int _y) - +e_epplet_evas_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Epplet_CB_Info *cb; - FeriteVariable **params; - - D_ENTER; + E_Epplet_CB_Info *cb; + FeriteVariable **params; -#ifdef USE_FERITE - cb = _data; + D_ENTER; - D("d1: %s, d2: %s\n", cb->data->name, cb->data2->name); +#ifdef USE_FERITE + cb = _data; - if (cb->script) { - D("creating params\n"); - params = __ferite_create_parameter_list_from_data( cb->script, "oonnn", - cb->data, cb->data2, (double)_b, (double)_x, (double)_y ); - D("calling func: %s\n", cb->func->name); - __ferite_variable_destroy( cb->script, __ferite_call_function( cb->script, cb->func, params)); - __ferite_delete_parameter_list( cb->script, params ); - D("func called, params deleted\n"); - } - else - { - D("ERROR: script does not exist\n"); - } + D("d1: %s, d2: %s\n", cb->data->name, cb->data2->name); + + if (cb->script) + { + D("creating params\n"); + params = __ferite_create_parameter_list_from_data(cb->script, "oonnn", + cb->data, cb->data2, + (double)_b, + (double)_x, + (double)_y); + D("calling func: %s\n", cb->func->name); + __ferite_variable_destroy(cb->script, + __ferite_call_function(cb->script, cb->func, + params)); + __ferite_delete_parameter_list(cb->script, params); + D("func called, params deleted\n"); + } + else + { + D("ERROR: script does not exist\n"); + } /* e_epplet_cb_cleanup(cb); */ #endif - D_RETURN; + D_RETURN; } void e_epplet_timer_func(int val, void *data) { - E_Epplet_CB_Info *cb; - FeriteVariable **params; - - D_ENTER; + E_Epplet_CB_Info *cb; + FeriteVariable **params; -#ifdef USE_FERITE + D_ENTER; + +#ifdef USE_FERITE /* D("in timer func\n"); */ - cb = data; + cb = data; - if (cb->script) { + if (cb->script) + { /* D("creating params\n"); */ - params = __ferite_create_parameter_list_from_data( cb->script, "on", - cb->data, (float)val ); + params = __ferite_create_parameter_list_from_data(cb->script, "on", + cb->data, (float)val); /* D("calling func\n"); */ - __ferite_variable_destroy( cb->script, __ferite_call_function( cb->script, cb->func, params)); - __ferite_delete_parameter_list( cb->script, params ); + __ferite_variable_destroy(cb->script, + __ferite_call_function(cb->script, cb->func, + params)); + __ferite_delete_parameter_list(cb->script, params); /* D("func called, params deleted\n"); */ - } - else - { - D("ERROR: script does not exist\n"); - } - + } + else + { + D("ERROR: script does not exist\n"); + } + /* e_epplet_cb_cleanup(cb); */ #endif - D_RETURN; + D_RETURN; } -E_Epplet_Observer * -e_epplet_observer_new(FeriteScript *script, char *func_name, FeriteObject *data, char *event_type) +E_Epplet_Observer * +e_epplet_observer_new(FeriteScript * script, char *func_name, + FeriteObject * data, char *event_type) { - E_Epplet_Observer *obs = NULL; + E_Epplet_Observer *obs = NULL; FeriteNamespaceBucket *nsb; D_ENTER; - -#ifdef USE_FERITE + +#ifdef USE_FERITE obs = NEW(E_Epplet_Observer, 1); memset(obs, 0, sizeof(E_Epplet_Observer)); if (!strcmp(event_type, "DESKTOP_SWITCH")) - e_observer_init(E_OBSERVER(obs), E_EVENT_DESKTOP_SWITCH, - e_epplet_desktop_observer_func, - (E_Cleanup_Func)e_epplet_observer_cleanup); + e_observer_init(E_OBSERVER(obs), E_EVENT_DESKTOP_SWITCH, + e_epplet_desktop_observer_func, + (E_Cleanup_Func) e_epplet_observer_cleanup); #if 0 else if (!strcmp(event_type, "ICONIFY")) - e_observer_init(E_OBSERVER(obs), E_EVENT_BORDER_ICONIFY, - e_epplet_border_observer_func, - (E_Cleanup_Func)e_epplet_observer_cleanup); + e_observer_init(E_OBSERVER(obs), E_EVENT_BORDER_ICONIFY, + e_epplet_border_observer_func, + (E_Cleanup_Func) e_epplet_observer_cleanup); else if (!strcmp(event_type, "UNICONIFY")) - e_observer_init(E_OBSERVER(obs), E_EVENT_BORDER_UNICONIFY, - e_epplet_border_observer_func, - (E_Cleanup_Func)e_epplet_observer_cleanup); + e_observer_init(E_OBSERVER(obs), E_EVENT_BORDER_UNICONIFY, + e_epplet_border_observer_func, + (E_Cleanup_Func) e_epplet_observer_cleanup); else - e_observer_init(E_OBSERVER(obs), E_EVENT_MAX, - e_epplet_desktop_observer_func, - (E_Cleanup_Func)e_epplet_observer_cleanup); + e_observer_init(E_OBSERVER(obs), E_EVENT_MAX, + e_epplet_desktop_observer_func, + (E_Cleanup_Func) e_epplet_observer_cleanup); #endif - nsb = __ferite_find_namespace( script, script->mainns, func_name, FENS_FNC); + nsb = __ferite_find_namespace(script, script->mainns, func_name, FENS_FNC); if (nsb != NULL) - { - obs->script = script; - obs->func = nsb->data; - if (data) - { - ((E_Epplet_Observer *)obs)->data = data; - data->refcount++; - } - } + { + obs->script = script; + obs->func = nsb->data; + if (data) + { + ((E_Epplet_Observer *) obs)->data = data; + data->refcount++; + } + } D("returning, event: %i\n", E_OBSERVER(obs)->event); #endif - D_RETURN_(obs); + D_RETURN_(obs); } static void -e_epplet_observer_cleanup(E_Object *o) +e_epplet_observer_cleanup(E_Object * o) { -#ifdef USE_FERITE +#ifdef USE_FERITE /*FIXME: we need something here!!! Leeeeaky! */ -#endif +#endif } void -e_epplet_observer_register_desktops(E_Epplet_Observer *obs) +e_epplet_observer_register_desktops(E_Epplet_Observer * obs) { - Evas_List l; + Evas_List l; D_ENTER; -#ifdef USE_FERITE - D("odeskregister, bserver func: %s\n", obs->func->name); +#ifdef USE_FERITE + D("odeskregister, bserver func: %s\n", obs->func->name); D("register each desktop in list\n"); for (l = e_desktops_get_desktops_list(); l; l = l->next) - { - E_Desktop *d = l->data; - D("registering desktop...\n") - e_observer_register_observee(E_OBSERVER(obs), E_OBSERVEE(d)); - D("desktop registered\n") - } + { + E_Desktop *d = l->data; + + D("registering desktop...\n") + e_observer_register_observee(E_OBSERVER(obs), E_OBSERVEE(d)); + D("desktop registered\n")} #endif D_RETURN; } #if 0 void -e_epplet_observer_register_borders(E_Epplet_Observer *obs) +e_epplet_observer_register_borders(E_Epplet_Observer * obs) { - Evas_List l; + Evas_List l; D_ENTER; -#ifdef USE_FERITE +#ifdef USE_FERITE for (l = e_border_get_borders_list(); l; l = l->next) - { - E_Border *b = l->data; - D("registering desktop...\n") - e_observer_register_observee(E_OBSERVER(obs), E_OBSERVEE(b)); - D("desktop registered\n") - } + { + E_Border *b = l->data; + + D("registering desktop...\n") + e_observer_register_observee(E_OBSERVER(obs), E_OBSERVEE(b)); + D("desktop registered\n")} #endif D_RETURN; } #endif void -e_epplet_desktop_observer_func(E_Observer *observer, E_Observee *observee, E_Event_Type event) +e_epplet_desktop_observer_func(E_Observer * observer, E_Observee * observee, + E_Event_Type event) { - E_Epplet_Observer *obs; - E_Desktop *desk; - FeriteVariable **params; - + E_Epplet_Observer *obs; + E_Desktop *desk; + FeriteVariable **params; + D_ENTER; -#ifdef USE_FERITE - obs = (E_Epplet_Observer *)observer; - desk = (E_Desktop *)observee; - +#ifdef USE_FERITE + obs = (E_Epplet_Observer *) observer; + desk = (E_Desktop *) observee; + D("desktop: %i\n", desk->desk.desk); D("current: %i\n", e_desktops_get_current()); if (obs->script) - { - D("creating params\n"); - - params = __ferite_create_parameter_list_from_data( obs->script, "on", - obs->data, (float)(desk->desk.desk) ); - D("calling func: %s\n", obs->func->name); - __ferite_variable_destroy( obs->script, __ferite_call_function( - obs->script, obs->func, params)); - D("function called\n"); - __ferite_delete_parameter_list( obs->script, params ); - D("func called, params deleted\n"); - } - else - { - D("ERROR: script does not exist\n"); - } + { + D("creating params\n"); + + params = __ferite_create_parameter_list_from_data(obs->script, "on", + obs->data, + (float)(desk->desk. + desk)); + D("calling func: %s\n", obs->func->name); + __ferite_variable_destroy(obs->script, + __ferite_call_function(obs->script, obs->func, + params)); + D("function called\n"); + __ferite_delete_parameter_list(obs->script, params); + D("func called, params deleted\n"); + } + else + { + D("ERROR: script does not exist\n"); + } #endif D_RETURN; } -#if 0 /* don't use this, its currently broken */ +#if 0 /* don't use this, its currently broken */ void -e_epplet_border_observer_func(E_Observer *observer, E_Observee *observee) +e_epplet_border_observer_func(E_Observer * observer, E_Observee * observee) { - E_Epplet_Observer *obs; - E_Border *b; - FeriteVariable **params; - + E_Epplet_Observer *obs; + E_Border *b; + FeriteVariable **params; + D_ENTER; -#ifdef USE_FERITE - obs = (E_Epplet_Observer *)observer; - b = (E_Border *)observee; - +#ifdef USE_FERITE + obs = (E_Epplet_Observer *) observer; + b = (E_Border *) observee; + obs->data->odata = b; - + if (obs->script) - { - /*D("creating params\n");*/ - - params = __ferite_create_parameter_list_from_data( obs->script, "o", - obs->data ); - /*D("calling func: %s\n", obs->func->name);*/ - __ferite_variable_destroy( obs->script, __ferite_call_function( - obs->script, obs->func, params)); - /*D("function called\n");*/ - __ferite_delete_parameter_list( obs->script, params ); - /*D("func called, params deleted\n");*/ - } - else - { - D("ERROR: script does not exist\n"); - } + { + /*D("creating params\n"); */ + + params = __ferite_create_parameter_list_from_data(obs->script, "o", + obs->data); + /*D("calling func: %s\n", obs->func->name); */ + __ferite_variable_destroy(obs->script, + __ferite_call_function(obs->script, obs->func, + params)); + /*D("function called\n"); */ + __ferite_delete_parameter_list(obs->script, params); + /*D("func called, params deleted\n"); */ + } + else + { + D("ERROR: script does not exist\n"); + } #endif D_RETURN; } #endif - diff --git a/src/epplet.h b/src/epplet.h index f2750f195..46517761b 100644 --- a/src/epplet.h +++ b/src/epplet.h @@ -14,103 +14,110 @@ typedef struct _E_Epplet_Observer E_Epplet_Observer; struct _E_Epplet_Observer { - E_Observer o; + E_Observer o; - FeriteScript *script; - FeriteFunction *func; - FeriteObject *data; + FeriteScript *script; + FeriteFunction *func; + FeriteObject *data; }; struct _E_Epplet_CB_Info { - FeriteScript *script; - FeriteFunction *func; - FeriteObject *data; - FeriteObject *data2; + FeriteScript *script; + FeriteFunction *func; + FeriteObject *data; + FeriteObject *data2; }; struct _E_Epplet_Context { - char *name; - E_View *view; - FeriteScript *script; + char *name; + E_View *view; + FeriteScript *script; - E_Epplet *epp; + E_Epplet *epp; - struct { - double x, y; - double w, h; - } geom; + struct + { + double x, y; + double w, h; + } + geom; }; - struct _E_Epplet { - E_Object o; - - E_Epplet_Context *context; + E_Object o; - char *name; - E_View *view; - char *dir; - Ebits_Object layout; - Ebits_Object ui; + E_Epplet_Context *context; + char *name; + E_View *view; + char *dir; + Ebits_Object layout; + Ebits_Object ui; - struct { - double x, y; - double w, h; - } current, requested, offset; + struct + { + double x, y; + double w, h; + } + current , requested, offset; - struct { - int changed; - int moving; - struct { - int up, down, left, right; - }resizing; - } state; + struct + { + int changed; + int moving; + struct + { + int up, down, left, right; + } + resizing; + } + state; - Evas_List evas_objects; - Evas_List ebits; + Evas_List evas_objects; + Evas_List ebits; }; struct _Evas_Object_Wrapper { - Evas evas; - Evas_Object obj; - E_Epplet *epp; + Evas evas; + Evas_Object obj; + E_Epplet *epp; }; /* epplet loading / cleanup */ -E_Epplet *e_epplet_new(); -void e_epplet_load_from_layout(E_View *v); -void e_epplet_script_load(E_Epplet_Context *v, char *script_path); -E_Epplet_Context *e_epplet_get_context_from_script(FeriteScript *script); +E_Epplet *e_epplet_new(); +void e_epplet_load_from_layout(E_View * v); +void e_epplet_script_load(E_Epplet_Context * v, + char *script_path); +E_Epplet_Context *e_epplet_get_context_from_script(FeriteScript * script); /* probably won't use this... */ -void e_epplet_set_common_callbacks(E_Epplet *epp); - +void e_epplet_set_common_callbacks(E_Epplet * epp); /* callbacks */ -E_Epplet_CB_Info *e_epplet_cb_new( FeriteScript *script, char *func_name, - FeriteObject *data, FeriteObject *data2 ); -void e_epplet_cb_cleanup( E_Epplet_CB_Info *cb); -void e_epplet_bits_cb (void *_data, Ebits_Object _o, char *_c, - int _b, int _x, int _y, int _ox, int _oy, - int _ow, int _oh); -void e_epplet_evas_cb (void *_data, Evas _e, Evas_Object _o, - int _b, int _x, int _y); +E_Epplet_CB_Info *e_epplet_cb_new(FeriteScript * script, char *func_name, + FeriteObject * data, FeriteObject * data2); +void e_epplet_cb_cleanup(E_Epplet_CB_Info * cb); +void e_epplet_bits_cb(void *_data, Ebits_Object _o, char *_c, + int _b, int _x, int _y, int _ox, int _oy, + int _ow, int _oh); +void e_epplet_evas_cb(void *_data, Evas _e, Evas_Object _o, + int _b, int _x, int _y); /* timers */ -void e_epplet_timer_func(int val, void *data); +void e_epplet_timer_func(int val, void *data); /* Observers */ -E_Epplet_Observer *e_epplet_observer_new( FeriteScript *script, - char *func_name, FeriteObject *data, +E_Epplet_Observer *e_epplet_observer_new(FeriteScript * script, + char *func_name, FeriteObject * data, char *event_type); -void e_epplet_observer_register_desktops(E_Epplet_Observer *obs); -void e_epplet_desktop_observer_func(E_Observer *observer, - E_Observee *observee, - E_Event_Type event); +void e_epplet_observer_register_desktops(E_Epplet_Observer * + obs); +void e_epplet_desktop_observer_func(E_Observer * observer, + E_Observee * observee, + E_Event_Type event); /*void e_epplet_border_observer_func(E_Observer *observer, E_Observee *observee);*/ #endif diff --git a/src/exec.c b/src/exec.c index d2ff3e573..96369ab44 100644 --- a/src/exec.c +++ b/src/exec.c @@ -3,25 +3,25 @@ #include "desktops.h" #include "util.h" -static int e_argc = 0; -static char **e_argv = NULL; +static int e_argc = 0; +static char **e_argv = NULL; typedef struct _e_hack_found_cb E_Hack_Found_CB; struct _e_hack_found_cb { - int dirty; - void (*func) (Window win, void *data); - void *func_data; + int dirty; + void (*func) (Window win, void *data); + void *func_data; }; -static Evas_List hack_found_cb = NULL; +static Evas_List hack_found_cb = NULL; -void * +void * e_exec_broadcast_cb_add(void (*func) (Window win, void *_data), void *data) { - E_Hack_Found_CB *cb; - + E_Hack_Found_CB *cb; + cb = NEW(E_Hack_Found_CB, 1); ZERO(cb, E_Hack_Found_CB, 1); cb->func = func; @@ -33,33 +33,33 @@ e_exec_broadcast_cb_add(void (*func) (Window win, void *_data), void *data) void e_exec_broadcast_cb_del(void *cbp) { - E_Hack_Found_CB *cb; - - cb = (E_Hack_Found_CB *)cbp; + E_Hack_Found_CB *cb; + + cb = (E_Hack_Found_CB *) cbp; cb->dirty = 1; } void e_exec_broadcast_e_hack_found(Window win) { - Evas_List l; - + Evas_List l; + for (l = hack_found_cb; l; l = l->next) { - E_Hack_Found_CB *cb; - + E_Hack_Found_CB *cb; + cb = l->data; if (!cb->dirty) { if (cb->func) - cb->func(win, cb->func_data); + cb->func(win, cb->func_data); } } - again: + again: for (l = hack_found_cb; l; l = l->next) { - E_Hack_Found_CB *cb; - + E_Hack_Found_CB *cb; + cb = l->data; if (cb->dirty) { @@ -83,8 +83,8 @@ e_exec_set_args(int argc, char **argv) void e_exec_restart(void) { - int i, num; - char exe[PATH_MAX]; + int i, num; + char exe[PATH_MAX]; D_ENTER; @@ -97,8 +97,8 @@ e_exec_restart(void) num = e_desktops_get_num(); for (i = 0; i < num; i++) { - E_Desktop *desk; - + E_Desktop *desk; + desk = e_desktops_get(0); e_desktops_delete(desk); } @@ -111,7 +111,7 @@ e_exec_restart(void) strcat(exe, e_argv[i]); strcat(exe, " "); } - execl("/bin/sh", "/bin/sh", "-c", exe, NULL); + execl("/bin/sh", "/bin/sh", "-c", exe, NULL); D_RETURN; } @@ -120,12 +120,12 @@ pid_t e_exec_run(char *exe) { pid_t pid; - + D_ENTER; pid = fork(); if (pid) - D_RETURN_(pid); + D_RETURN_(pid); setsid(); execl("/bin/sh", "/bin/sh", "-c", exe, NULL); exit(0); @@ -137,12 +137,12 @@ pid_t e_exec_run_in_dir(char *exe, char *dir) { pid_t pid; - + D_ENTER; pid = fork(); if (pid) - D_RETURN_(pid); + D_RETURN_(pid); chdir(dir); setsid(); execl("/bin/sh", "/bin/sh", "-c", exe, NULL); @@ -152,20 +152,23 @@ e_exec_run_in_dir(char *exe, char *dir) } pid_t -e_exec_in_dir_with_env(char *exe, char *dir, int *launch_id_ret, char **env, char *launch_path) +e_exec_in_dir_with_env(char *exe, char *dir, int *launch_id_ret, char **env, + char *launch_path) { - static int launch_id = 0; - char preload_paths[PATH_MAX]; - char preload[PATH_MAX]; - char *exe2; + static int launch_id = 0; + char preload_paths[PATH_MAX]; + char preload[PATH_MAX]; + char *exe2; pid_t pid; - + D_ENTER; launch_id++; - if (launch_id_ret) *launch_id_ret = launch_id; + if (launch_id_ret) + *launch_id_ret = launch_id; pid = fork(); - if (pid) D_RETURN_(pid); + if (pid) + D_RETURN_(pid); chdir(dir); setsid(); if (env) @@ -179,13 +182,13 @@ e_exec_in_dir_with_env(char *exe, char *dir, int *launch_id_ret, char **env, cha /* launch Id hack - if it's an X program the windows popped up should */ /* have this launch Id number set on them - as well as process ID */ /* machine name, and user name */ - if (launch_path) e_util_set_env("E_HACK_LAUNCH_PATH", launch_path); - snprintf(preload_paths, PATH_MAX, "E_HACK_LAUNCH_ID=%i LD_PRELOAD_PATH='%s'", - launch_id, PACKAGE_LIB_DIR); + if (launch_path) + e_util_set_env("E_HACK_LAUNCH_PATH", launch_path); + snprintf(preload_paths, PATH_MAX, "E_HACK_LAUNCH_ID=%i LD_PRELOAD_PATH='%s'", + launch_id, PACKAGE_LIB_DIR); snprintf(preload, PATH_MAX, "LD_PRELOAD='libehack.so libX11.so libdl.so'"); - exe2 = malloc(strlen(exe) + 1 + - strlen(preload_paths) + 1 + - strlen(preload) + 1); + exe2 = malloc(strlen(exe) + 1 + + strlen(preload_paths) + 1 + strlen(preload) + 1); snprintf(exe2, PATH_MAX, "%s %s %s", preload_paths, preload, exe); execl("/bin/sh", "/bin/sh", "-c", exe2, NULL); diff --git a/src/exec.h b/src/exec.h index 91465e9e2..b94522998 100644 --- a/src/exec.h +++ b/src/exec.h @@ -3,13 +3,16 @@ #include "e.h" -void *e_exec_broadcast_cb_add(void (*func) (Window win, void *data), void *data); -void e_exec_broadcast_cb_del(void *cb); -void e_exec_broadcast_e_hack_found(Window win); -void e_exec_set_args(int argc, char **argv); -void e_exec_restart(void); -pid_t e_exec_run(char *exe); -pid_t e_exec_run_in_dir(char *exe, char *dir); -pid_t e_exec_in_dir_with_env(char *exe, char *dir, int *launch_id_ret, char **env, char *launch_path); +void + *e_exec_broadcast_cb_add(void (*func) (Window win, void *data), void *data); +void e_exec_broadcast_cb_del(void *cb); +void e_exec_broadcast_e_hack_found(Window win); +void e_exec_set_args(int argc, char **argv); +void e_exec_restart(void); +pid_t e_exec_run(char *exe); +pid_t e_exec_run_in_dir(char *exe, char *dir); +pid_t e_exec_in_dir_with_env(char *exe, char *dir, + int *launch_id_ret, char **env, + char *launch_path); #endif diff --git a/src/file.c b/src/file.c index c96fc04ae..e7fed30de 100644 --- a/src/file.c +++ b/src/file.c @@ -9,8 +9,9 @@ e_file_mod_time(char *file) struct stat st; D_ENTER; - - if (stat(file, &st) < 0) D_RETURN_(0); + + if (stat(file, &st) < 0) + D_RETURN_(0); D_RETURN_(st.st_mtime); } @@ -19,10 +20,11 @@ int e_file_exists(char *file) { struct stat st; - + D_ENTER; - - if (stat(file, &st) < 0) D_RETURN_(0); + + if (stat(file, &st) < 0) + D_RETURN_(0); D_RETURN_(1); } @@ -31,23 +33,27 @@ int e_file_is_dir(char *file) { struct stat st; - + D_ENTER; - - if (stat(file, &st) < 0) D_RETURN_(0); - if (S_ISDIR(st.st_mode)) D_RETURN_(1); + + if (stat(file, &st) < 0) + D_RETURN_(0); + if (S_ISDIR(st.st_mode)) + D_RETURN_(1); D_RETURN_(0); } -static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; +static mode_t default_mode = + S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; int e_file_mkdir(char *dir) { D_ENTER; - - if (mkdir(dir, default_mode) < 0) D_RETURN_(0); + + if (mkdir(dir, default_mode) < 0) + D_RETURN_(0); D_RETURN_(1); } @@ -55,72 +61,74 @@ e_file_mkdir(char *dir) int e_file_cp(char *src, char *dst) { - FILE *f1, *f2; - char buf[16384]; - size_t num; - + FILE *f1, *f2; + char buf[16384]; + size_t num; + D_ENTER; - + f1 = fopen(src, "rb"); - if (!f1) D_RETURN_(0); + if (!f1) + D_RETURN_(0); f2 = fopen(dst, "wb"); if (!f2) { fclose(f1); D_RETURN_(0); } - while ((num = fread(buf, 1, 16384, f1)) > 0) fwrite(buf, 1, num, f2); + while ((num = fread(buf, 1, 16384, f1)) > 0) + fwrite(buf, 1, num, f2); fclose(f1); fclose(f2); D_RETURN_(1); } -char * +char * e_file_realpath(char *file) { - char buf[PATH_MAX]; - char *f; - + char buf[PATH_MAX]; + char *f; + D_ENTER; - - if (!realpath(file, buf)) D_RETURN_(strdup("")); + + if (!realpath(file, buf)) + D_RETURN_(strdup("")); e_strdup(f, buf); D_RETURN_(f); } -char * +char * e_file_get_file(char *path) { - char *result = NULL; + char *result = NULL; - D_ENTER; + D_ENTER; - if (!path) - D_RETURN_(NULL); - - if ((result = strrchr(path, '/'))) - result++; - else - result = path; - - D_RETURN_(result); + if (!path) + D_RETURN_(NULL); + + if ((result = strrchr(path, '/'))) + result++; + else + result = path; + + D_RETURN_(result); } - -char * +char * e_file_get_dir(char *file) { - char *p; - char *f; - char buf[PATH_MAX]; - + char *p; + char *f; + char buf[PATH_MAX]; + D_ENTER; - + strcpy(buf, file); p = strrchr(buf, '/'); - if (!p) + if (!p) { e_strdup(f, file); D_RETURN_(f); @@ -134,70 +142,77 @@ e_file_get_dir(char *file) int e_file_can_exec(struct stat *st) { - static int have_uid = 0; - static uid_t uid = -1; - static gid_t gid = -1; - int ok; - + static int have_uid = 0; + static uid_t uid = -1; + static gid_t gid = -1; + int ok; + D_ENTER; - - if (!st) D_RETURN_(0); + + if (!st) + D_RETURN_(0); ok = 0; - if (!have_uid) uid = getuid(); - if (!have_uid) gid = getgid(); + if (!have_uid) + uid = getuid(); + if (!have_uid) + gid = getgid(); have_uid = 1; if (st->st_uid == uid) { - if (st->st_mode & S_IXUSR) ok = 1; + if (st->st_mode & S_IXUSR) + ok = 1; } else if (st->st_gid == gid) { - if (st->st_mode & S_IXGRP) ok = 1; + if (st->st_mode & S_IXGRP) + ok = 1; } else { - if (st->st_mode & S_IXOTH) ok = 1; + if (st->st_mode & S_IXOTH) + ok = 1; } D_RETURN_(ok); } -char * +char * e_file_readlink(char *link) { - char buf[PATH_MAX]; - char *f; - int count; - + char buf[PATH_MAX]; + char *f; + int count; + D_ENTER; - - if ((count = readlink(link, buf, sizeof(buf))) < 0) D_RETURN_(NULL); + + if ((count = readlink(link, buf, sizeof(buf))) < 0) + D_RETURN_(NULL); buf[count] = 0; e_strdup(f, buf); D_RETURN_(f); } -Evas_List +Evas_List e_file_ls(char *dir) { DIR *dirp; struct dirent *dp; Evas_List list; - + D_ENTER; - + dirp = opendir(dir); - if (!dirp) D_RETURN_(NULL); + if (!dirp) + D_RETURN_(NULL); list = NULL; while ((dp = readdir(dirp))) { - if ((strcmp(dp->d_name, ".")) && - (strcmp(dp->d_name, ".."))) + if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) { - Evas_List l; - char *f; - + Evas_List l; + char *f; + /* insertion sort */ for (l = list; l; l = l->next) { @@ -210,7 +225,8 @@ e_file_ls(char *dir) } /* nowhwre to go? just append it */ e_strdup(f, dp->d_name); - if (!l) list = evas_list_append(list, f); + if (!l) + list = evas_list_append(list, f); } } closedir(dirp); diff --git a/src/file.h b/src/file.h index b4f0ea258..c373581ed 100644 --- a/src/file.h +++ b/src/file.h @@ -4,12 +4,12 @@ #include #include -time_t e_file_mod_time(char *file); -int e_file_exists(char *file); -int e_file_is_dir(char *file); -int e_file_mkdir(char *dir); -int e_file_cp(char *src, char *dst); -char *e_file_realpath(char *file); +time_t e_file_mod_time(char *file); +int e_file_exists(char *file); +int e_file_is_dir(char *file); +int e_file_mkdir(char *dir); +int e_file_cp(char *src, char *dst); +char *e_file_realpath(char *file); /** * e_file_get_file - returns file in a path @@ -20,7 +20,7 @@ char *e_file_realpath(char *file); * a pointer into the original string, so you don't * need to free the result. */ -char *e_file_get_file(char *path); +char *e_file_get_file(char *path); /** * e_file_get_dir - returns directory in a path @@ -31,10 +31,10 @@ char *e_file_get_file(char *path); * a freshly allocated string, so you need to free *the result. */ -char *e_file_get_dir(char *path); +char *e_file_get_dir(char *path); -int e_file_can_exec(struct stat *st); -char *e_file_readlink(char *link); -Evas_List e_file_ls(char *dir); +int e_file_can_exec(struct stat *st); +char *e_file_readlink(char *link); +Evas_List e_file_ls(char *dir); #endif diff --git a/src/focus.c b/src/focus.c index 8229a5794..f0aaa9d92 100644 --- a/src/focus.c +++ b/src/focus.c @@ -4,20 +4,20 @@ #include "e.h" #include "util.h" -static Evas_List focus_list = NULL; +static Evas_List focus_list = NULL; void -e_focus_set_focus(E_Border *b) +e_focus_set_focus(E_Border * b) { D_ENTER; - e_icccm_send_focus_to(b->win.client, e_focus_can_focus(b)); + e_icccm_send_focus_to(b->win.client, e_focus_can_focus(b)); D_RETURN; } int -e_focus_can_focus(E_Border *b) +e_focus_can_focus(E_Border * b) { D_ENTER; @@ -25,7 +25,7 @@ e_focus_can_focus(E_Border *b) } void -e_focus_list_border_add(E_Border *b) +e_focus_list_border_add(E_Border * b) { D_ENTER; @@ -34,7 +34,7 @@ e_focus_list_border_add(E_Border *b) } void -e_focus_list_border_del(E_Border *b) +e_focus_list_border_del(E_Border * b) { D_ENTER; @@ -47,7 +47,7 @@ e_focus_list_clear(void) { D_ENTER; - if (focus_list) + if (focus_list) { evas_list_free(focus_list); focus_list = NULL; diff --git a/src/focus.h b/src/focus.h index 90997ca3c..7611e1d52 100644 --- a/src/focus.h +++ b/src/focus.h @@ -3,11 +3,10 @@ #include "border.h" -void e_focus_set_focus(E_Border *b); -int e_focus_can_focus(E_Border *b); -void e_focus_list_border_add(E_Border *b); -void e_focus_list_border_del(E_Border *b); -void e_focus_list_clear(void); +void e_focus_set_focus(E_Border * b); +int e_focus_can_focus(E_Border * b); +void e_focus_list_border_add(E_Border * b); +void e_focus_list_border_del(E_Border * b); +void e_focus_list_clear(void); #endif - diff --git a/src/fs.c b/src/fs.c index ea0901918..bd89a9020 100644 --- a/src/fs.c +++ b/src/fs.c @@ -3,28 +3,29 @@ #include "exec.h" #include "util.h" -static EfsdConnection *ec = NULL; -static Evas_List fs_handlers = NULL; -static Evas_List fs_restart_handlers = NULL; -static pid_t efsd_pid = 0; +static EfsdConnection *ec = NULL; +static Evas_List fs_handlers = NULL; +static Evas_List fs_restart_handlers = NULL; +static pid_t efsd_pid = 0; -static void e_fs_child_handle(Ecore_Event *ev); -static void e_fs_fd_handle(int fd); -static void e_fs_restarter(int val, void *data); -static void e_fs_idle(void *data); -static void e_fs_flush_timeout(int val, void *data); +static void e_fs_child_handle(Ecore_Event * ev); +static void e_fs_fd_handle(int fd); +static void e_fs_restarter(int val, void *data); +static void e_fs_idle(void *data); +static void e_fs_flush_timeout(int val, void *data); static void e_fs_flush_timeout(int val, void *data) { D_ENTER; - if (!ec) D_RETURN; + if (!ec) + D_RETURN; if (efsd_commands_pending(ec) > 0) { if (efsd_flush(ec) > 0) - ecore_add_event_timer("e_fs_flush_timeout()", - 0.00, e_fs_flush_timeout, 0, NULL); + ecore_add_event_timer("e_fs_flush_timeout()", + 0.00, e_fs_flush_timeout, 0, NULL); } D_RETURN; @@ -44,10 +45,10 @@ e_fs_idle(void *data) } static void -e_fs_child_handle(Ecore_Event *ev) +e_fs_child_handle(Ecore_Event * ev) { - Ecore_Event_Child *e; - + Ecore_Event_Child *e; + D_ENTER; e = ev->event; @@ -55,7 +56,8 @@ e_fs_child_handle(Ecore_Event *ev) if (e->pid == efsd_pid) { D("it was efsd!\n"); - if (ec) efsd_close(ec); + if (ec) + efsd_close(ec); ec = NULL; efsd_pid = 0; e_fs_restarter(1, NULL); @@ -67,23 +69,23 @@ e_fs_child_handle(Ecore_Event *ev) static void e_fs_fd_handle(int fd) { - double start, current; - + double start, current; + D_ENTER; start = ecore_get_time(); while ((ec) && efsd_events_pending(ec)) { - EfsdEvent ev; - + EfsdEvent ev; + if (efsd_next_event(ec, &ev) >= 0) { - Evas_List l; - + Evas_List l; + for (l = fs_handlers; l; l = l->next) { - void (*func) (EfsdEvent *ev); - + void (*func) (EfsdEvent * ev); + func = l->data; func(&ev); } @@ -99,10 +101,10 @@ e_fs_fd_handle(int fd) /* efsd went wonky */ D("EEEEEEEEEEK efsd went wonky. Bye bye efsd.\n"); } - + /* spent more thna 1/20th of a second here.. get out */ current = ecore_get_time(); - if ((current - start) > 0.05) + if ((current - start) > 0.05) { D("fs... too much time spent..\n"); break; @@ -117,50 +119,54 @@ e_fs_restarter(int val, void *data) { D_ENTER; - if (ec) D_RETURN; + if (ec) + D_RETURN; ec = efsd_open(); if ((!ec) && (val > 0)) { - if (efsd_pid <= 0) + if (efsd_pid <= 0) { efsd_pid = e_exec_run("efsd -f"); D("launch efsd... %i\n", efsd_pid); } - if (efsd_pid > 0) ec = efsd_open(); + if (efsd_pid > 0) + ec = efsd_open(); } if (ec) { - Evas_List l; - + Evas_List l; + ecore_add_event_fd(efsd_get_connection_fd(ec), e_fs_fd_handle); for (l = fs_restart_handlers; l; l = l->next) { - E_FS_Restarter *rs; - + E_FS_Restarter *rs; + rs = l->data; rs->func(rs->data); } } else { - double gap; - + double gap; + gap = (double)val / 10; - if (gap > 10.0) gap = 10.0; - ecore_add_event_timer("e_fs_restarter", gap, e_fs_restarter, val + 1, NULL); + if (gap > 10.0) + gap = 10.0; + ecore_add_event_timer("e_fs_restarter", gap, e_fs_restarter, val + 1, + NULL); } D_RETURN; UN(data); } -E_FS_Restarter * +E_FS_Restarter * e_fs_add_restart_handler(void (*func) (void *data), void *data) { - E_FS_Restarter *rs; - + E_FS_Restarter *rs; + D_ENTER; rs = NEW(E_FS_Restarter, 1); @@ -173,25 +179,26 @@ e_fs_add_restart_handler(void (*func) (void *data), void *data) } void -e_fs_del_restart_handler(E_FS_Restarter *rs) +e_fs_del_restart_handler(E_FS_Restarter * rs) { D_ENTER; if (evas_list_find(fs_restart_handlers, rs)) { fs_restart_handlers = evas_list_remove(fs_restart_handlers, rs); - FREE(rs); + FREE(rs); } D_RETURN; } void -e_fs_add_event_handler(void (*func) (EfsdEvent *ev)) +e_fs_add_event_handler(void (*func) (EfsdEvent * ev)) { D_ENTER; - if (!func) D_RETURN; + if (!func) + D_RETURN; fs_handlers = evas_list_append(fs_handlers, func); D_RETURN; @@ -203,24 +210,24 @@ e_fs_init(void) D_ENTER; /* Hook in an fs handler that gets called whenever - a child of this process exits. - */ - ecore_event_filter_handler_add(ECORE_EVENT_CHILD, e_fs_child_handle); + * a child of this process exits. + */ + ecore_event_filter_handler_add(ECORE_EVENT_CHILD, e_fs_child_handle); /* Also hook in an idle handler to flush efsd's - write queue. - - FIXME: This should be handled by letting ecore - report when Efsd's file descriptor becomes - writeable, and then calling efsd_flush(). - */ - ecore_event_filter_idle_handler_add(e_fs_idle, NULL); + * write queue. + * + * FIXME: This should be handled by letting ecore + * report when Efsd's file descriptor becomes + * writeable, and then calling efsd_flush(). + */ + ecore_event_filter_idle_handler_add(e_fs_idle, NULL); e_fs_restarter(0, NULL); D_RETURN; } -void +void e_fs_cleanup(void) { D_ENTER; @@ -231,8 +238,7 @@ e_fs_cleanup(void) D_RETURN; } - -EfsdConnection * +EfsdConnection * e_fs_get_connection(void) { D_ENTER; diff --git a/src/fs.h b/src/fs.h index 56d7e3854..a5ba5c4b5 100644 --- a/src/fs.h +++ b/src/fs.h @@ -3,12 +3,12 @@ #include -typedef struct _E_FS_Restarter E_FS_Restarter; +typedef struct _E_FS_Restarter E_FS_Restarter; struct _E_FS_Restarter { - void (*func) (void *data); - void *data; + void (*func) (void *data); + void *data; }; /** @@ -18,7 +18,7 @@ struct _E_FS_Restarter * starts it when necessary, and makes sure that * it can be restarted in case efsd dies. */ -void e_fs_init(void); +void e_fs_init(void); /** * e_fs_cleanup - Filesystem code cleanup routine. @@ -26,11 +26,12 @@ void e_fs_init(void); * This function takes care of properly saying * good bye to Efsd. */ -void e_fs_cleanup(void); +void e_fs_cleanup(void); -E_FS_Restarter *e_fs_add_restart_handler(void (*func) (void *data), void *data); -void e_fs_del_restart_handler(E_FS_Restarter *rs); -void e_fs_add_event_handler(void (*func) (EfsdEvent *ev)); -EfsdConnection *e_fs_get_connection(void); +E_FS_Restarter *e_fs_add_restart_handler(void (*func) (void *data), + void *data); +void e_fs_del_restart_handler(E_FS_Restarter * rs); +void e_fs_add_event_handler(void (*func) (EfsdEvent * ev)); +EfsdConnection *e_fs_get_connection(void); #endif diff --git a/src/globals.c b/src/globals.c index 2f167b14b..22869ad0b 100644 --- a/src/globals.c +++ b/src/globals.c @@ -5,4 +5,4 @@ Ecore_Event_Key_Modifiers multi_select_mod = ECORE_EVENT_KEY_MODIFIER_SHIFT; Ecore_Event_Key_Modifiers range_select_mod = ECORE_EVENT_KEY_MODIFIER_CTRL; -E_View_Machine *VM = NULL; +E_View_Machine *VM = NULL; diff --git a/src/guides.c b/src/guides.c index 0df594260..1508203a1 100644 --- a/src/guides.c +++ b/src/guides.c @@ -5,46 +5,56 @@ #include "embed.h" #include "util.h" -static struct +static struct { - int changed; - - struct - { - struct - { - E_Guides_Location loc; - struct - { - double x, y; - } align; - char *text; - char *icon; - } display; - int x, y, w, h; - int visible; - E_Guides_Mode mode; - } current, prev; - - struct { - Window display; - Window l, r, t, b; - } win; - struct { - Evas evas; - Ebits_Object bg; - E_Text *text; - Evas_Object icon; - Imlib_Image image; - } disp; - struct { - Embed icon; - Embed text; - } embed; -} guides; + int changed; -static void e_guides_idle(void *data); -static void e_guides_update(void); + struct + { + struct + { + E_Guides_Location loc; + struct + { + double x, y; + } + align; + char *text; + char *icon; + } + display; + int x, y, w, h; + int visible; + E_Guides_Mode mode; + } + current , prev; + + struct + { + Window display; + Window l, r, t, b; + } + win; + struct + { + Evas evas; + Ebits_Object bg; + E_Text *text; + Evas_Object icon; + Imlib_Image image; + } + disp; + struct + { + Embed icon; + Embed text; + } + embed; +} +guides; + +static void e_guides_idle(void *data); +static void e_guides_update(void); static void e_guides_idle(void *data) @@ -60,14 +70,15 @@ e_guides_idle(void *data) static void e_guides_update(void) { - int font_cache = 1024 * 1024; - int image_cache = 8192 * 1024; - char *font_dir; - int redraw; - + int font_cache = 1024 * 1024; + int image_cache = 8192 * 1024; + char *font_dir; + int redraw; + D_ENTER; - if (!guides.changed) D_RETURN; + if (!guides.changed) + D_RETURN; redraw = 0; if (guides.prev.visible != guides.current.visible) @@ -93,12 +104,12 @@ e_guides_update(void) font_dir = e_config_get("fonts"); guides.disp.evas = evas_new(); evas_set_output_method(guides.disp.evas, RENDER_METHOD_IMAGE); - + guides.disp.image = imlib_create_image(1, 1); imlib_context_set_image(guides.disp.image); imlib_image_set_has_alpha(1); imlib_image_clear(); - + evas_set_output_image(guides.disp.evas, guides.disp.image); evas_font_add_path(guides.disp.evas, font_dir); evas_set_output_size(guides.disp.evas, 1, 1); @@ -124,12 +135,16 @@ e_guides_update(void) } if (guides.disp.evas) { - if (guides.embed.icon) e_embed_free(guides.embed.icon); - if (guides.embed.text) e_embed_free(guides.embed.text); + if (guides.embed.icon) + e_embed_free(guides.embed.icon); + if (guides.embed.text) + e_embed_free(guides.embed.text); guides.embed.icon = NULL; guides.embed.text = NULL; - if (guides.disp.bg) ebits_free(guides.disp.bg); - if (guides.disp.text) e_text_free(guides.disp.text); + if (guides.disp.bg) + ebits_free(guides.disp.bg); + if (guides.disp.text) + e_text_free(guides.disp.text); if (guides.disp.image) { imlib_context_set_image(guides.disp.image); @@ -144,25 +159,37 @@ e_guides_update(void) } } } - if (guides.current.x != guides.prev.x) redraw = 1; - if (guides.current.y != guides.prev.y) redraw = 1; - if (guides.current.w != guides.prev.w) redraw = 1; - if (guides.current.h != guides.prev.h) redraw = 1; - if (guides.current.display.loc != guides.prev.display.loc) redraw = 1; - if (guides.current.display.align.x != guides.prev.display.align.x) redraw = 1; - if (guides.current.display.align.y != guides.prev.display.align.y) redraw = 1; - if (guides.current.display.text != guides.prev.display.text) redraw = 1; - if (guides.current.display.icon != guides.prev.display.icon) redraw = 1; - if (guides.current.mode != guides.prev.mode) redraw = 1; - + if (guides.current.x != guides.prev.x) + redraw = 1; + if (guides.current.y != guides.prev.y) + redraw = 1; + if (guides.current.w != guides.prev.w) + redraw = 1; + if (guides.current.h != guides.prev.h) + redraw = 1; + if (guides.current.display.loc != guides.prev.display.loc) + redraw = 1; + if (guides.current.display.align.x != guides.prev.display.align.x) + redraw = 1; + if (guides.current.display.align.y != guides.prev.display.align.y) + redraw = 1; + if (guides.current.display.text != guides.prev.display.text) + redraw = 1; + if (guides.current.display.icon != guides.prev.display.icon) + redraw = 1; + if (guides.current.mode != guides.prev.mode) + redraw = 1; + if ((guides.win.display) && (redraw)) { - int dx, dy, dw, dh, sw, sh, mw, mh; - char file[PATH_MAX]; - + int dx, dy, dw, dh, sw, sh, mw, mh; + char file[PATH_MAX]; + if (!guides.disp.text) { - guides.disp.text = e_text_new(guides.disp.evas, guides.current.display.text, "guides"); + guides.disp.text = + e_text_new(guides.disp.evas, guides.current.display.text, + "guides"); e_text_set_layer(guides.disp.text, 100); e_text_show(guides.disp.text); } @@ -173,69 +200,90 @@ e_guides_update(void) } if ((guides.current.display.icon) && (!guides.disp.icon)) { - guides.disp.icon = evas_add_image_from_file(guides.disp.evas, guides.current.display.icon); + guides.disp.icon = + evas_add_image_from_file(guides.disp.evas, + guides.current.display.icon); evas_show(guides.disp.evas, guides.disp.icon); } if (guides.disp.icon) - evas_set_image_file(guides.disp.evas, guides.disp.icon, guides.current.display.icon); + evas_set_image_file(guides.disp.evas, guides.disp.icon, + guides.current.display.icon); e_text_set_text(guides.disp.text, guides.current.display.text); - if (!guides.disp.bg) + if (!guides.disp.bg) { - char *dir; - + char *dir; + dir = e_config_get("guides"); snprintf(file, PATH_MAX, "%s/display.bits.db", dir); guides.disp.bg = ebits_load(file); - if (guides.disp.bg) + if (guides.disp.bg) { ebits_add_to_evas(guides.disp.bg, guides.disp.evas); ebits_set_layer(guides.disp.bg, 0); ebits_show(guides.disp.bg); } } - + mw = 1; mh = 1; - + if (guides.disp.bg) { if (!guides.embed.icon) { - if (guides.embed.icon) e_embed_free(guides.embed.icon); - if (guides.embed.text) e_embed_free(guides.embed.text); - guides.embed.icon = e_embed_image_object(guides.disp.bg, "Icon", guides.disp.evas, guides.disp.icon); - guides.embed.text = e_embed_text(guides.disp.bg, "Text", guides.disp.evas, guides.disp.text, 0, 0); + if (guides.embed.icon) + e_embed_free(guides.embed.icon); + if (guides.embed.text) + e_embed_free(guides.embed.text); + guides.embed.icon = + e_embed_image_object(guides.disp.bg, "Icon", + guides.disp.evas, guides.disp.icon); + guides.embed.text = + e_embed_text(guides.disp.bg, "Text", guides.disp.evas, + guides.disp.text, 0, 0); } ebits_get_real_min_size(guides.disp.bg, &mw, &mh); } - + dw = mw; dh = mh; - - if (guides.disp.bg) + + if (guides.disp.bg) { ebits_move(guides.disp.bg, 0, 0); ebits_resize(guides.disp.bg, dw, dh); } - if (guides.current.display.loc == E_GUIDES_DISPLAY_LOCATION_SCREEN_MIDDLE) + if (guides.current.display.loc == + E_GUIDES_DISPLAY_LOCATION_SCREEN_MIDDLE) { ecore_window_get_geometry(0, NULL, NULL, &sw, &sh); - dx = (int)(((double)sw - (double)dw) * guides.current.display.align.x); - dy = (int)(((double)sh - (double)dh) * guides.current.display.align.y); + dx = + (int)(((double)sw - + (double)dw) * guides.current.display.align.x); + dy = + (int)(((double)sh - + (double)dh) * guides.current.display.align.y); } - else if (guides.current.display.loc == E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE) + else if (guides.current.display.loc == + E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE) { - dx = guides.current.x + (int)(((double)guides.current.w - (double)dw) * guides.current.display.align.x); - dy = guides.current.y + (int)(((double)guides.current.h - (double)dh) * guides.current.display.align.y); + dx = + guides.current.x + + (int)(((double)guides.current.w - + (double)dw) * guides.current.display.align.x); + dy = + guides.current.y + + (int)(((double)guides.current.h - + (double)dh) * guides.current.display.align.y); } - + if (guides.disp.image) { imlib_context_set_image(guides.disp.image); imlib_free_image(); guides.disp.image = NULL; } - + guides.disp.image = imlib_create_image(dw, dh); imlib_context_set_image(guides.disp.image); imlib_image_set_has_alpha(1); @@ -246,46 +294,52 @@ e_guides_update(void) evas_set_output_viewport(guides.disp.evas, 0, 0, dw, dh); evas_update_rect(guides.disp.evas, 0, 0, dw, dh); evas_render(guides.disp.evas); - { - Pixmap pmap, mask; - - pmap = ecore_pixmap_new(guides.win.display, dw, dh, 0); - mask = ecore_pixmap_new(guides.win.display, dw, dh, 1); - - imlib_context_set_image(guides.disp.image); - - imlib_context_set_dither_mask(1); - imlib_context_set_dither(1); - imlib_context_set_drawable(pmap); - imlib_context_set_mask(mask); - imlib_context_set_blend(0); - imlib_context_set_color_modifier(NULL); - - imlib_render_image_on_drawable(0, 0); - ecore_window_set_background_pixmap(guides.win.display, pmap); - ecore_window_set_shape_mask(guides.win.display, mask); - ecore_window_clear(guides.win.display); - ecore_pixmap_free(pmap); - ecore_pixmap_free(mask); - } + { + Pixmap pmap, mask; + + pmap = ecore_pixmap_new(guides.win.display, dw, dh, 0); + mask = ecore_pixmap_new(guides.win.display, dw, dh, 1); + + imlib_context_set_image(guides.disp.image); + + imlib_context_set_dither_mask(1); + imlib_context_set_dither(1); + imlib_context_set_drawable(pmap); + imlib_context_set_mask(mask); + imlib_context_set_blend(0); + imlib_context_set_color_modifier(NULL); + + imlib_render_image_on_drawable(0, 0); + ecore_window_set_background_pixmap(guides.win.display, pmap); + ecore_window_set_shape_mask(guides.win.display, mask); + ecore_window_clear(guides.win.display); + ecore_pixmap_free(pmap); + ecore_pixmap_free(mask); + } ecore_window_move(guides.win.display, dx, dy); ecore_window_resize(guides.win.display, dw, dh); - + if (guides.current.mode == E_GUIDES_BOX) { - int fr, fg, fb, fa, br, bg, bb, ba; - int x, y, w, h; - Pixmap pmap, mask; - Imlib_Image image; - + int fr, fg, fb, fa, br, bg, bb, ba; + int x, y, w, h; + Pixmap pmap, mask; + Imlib_Image image; + imlib_context_set_dither_mask(1); imlib_context_set_dither(1); imlib_context_set_blend(1); imlib_context_set_color_modifier(NULL); - - fr = 255; fg = 255; fb = 255; fa = 255; - br = 0 ; bg = 0 ; bb = 0 ; ba = 255; - + + fr = 255; + fg = 255; + fb = 255; + fa = 255; + br = 0; + bg = 0; + bb = 0; + ba = 255; + x = guides.current.x; y = guides.current.y + 3; w = 3; @@ -296,13 +350,13 @@ e_guides_update(void) imlib_context_set_image(image); imlib_image_set_has_alpha(1); imlib_image_clear(); - + imlib_context_set_color(fr, fg, fb, fa); imlib_image_draw_line(1, 0, 1, h - 1, 0); imlib_context_set_color(br, bg, bb, ba); imlib_image_draw_line(0, 0, 0, h - 1, 0); imlib_image_draw_line(2, 0, 2, h - 1, 0); - + pmap = ecore_pixmap_new(guides.win.l, w, h, 0); mask = ecore_pixmap_new(guides.win.l, w, h, 1); imlib_context_set_drawable(pmap); @@ -321,7 +375,7 @@ e_guides_update(void) { ecore_window_resize(guides.win.l, 0, 0); } - + x = guides.current.x + guides.current.w - 3; y = guides.current.y + 3; w = 3; @@ -332,13 +386,13 @@ e_guides_update(void) imlib_context_set_image(image); imlib_image_set_has_alpha(1); imlib_image_clear(); - + imlib_context_set_color(fr, fg, fb, fa); imlib_image_draw_line(1, 0, 1, h - 1, 0); imlib_context_set_color(br, bg, bb, ba); imlib_image_draw_line(0, 0, 0, h - 1, 0); imlib_image_draw_line(2, 0, 2, h - 1, 0); - + pmap = ecore_pixmap_new(guides.win.r, w, h, 0); mask = ecore_pixmap_new(guides.win.r, w, h, 1); imlib_context_set_drawable(pmap); @@ -357,7 +411,7 @@ e_guides_update(void) { ecore_window_resize(guides.win.r, 0, 0); } - + x = guides.current.x; y = guides.current.y; w = guides.current.w; @@ -368,7 +422,7 @@ e_guides_update(void) imlib_context_set_image(image); imlib_image_set_has_alpha(1); imlib_image_clear(); - + imlib_context_set_color(br, bg, bb, ba); imlib_image_draw_line(0, 0, w - 1, 0, 0); imlib_image_draw_line(2, 2, w - 3, 2, 0); @@ -378,7 +432,7 @@ e_guides_update(void) imlib_image_draw_line(1, 1, w - 2, 1, 0); imlib_image_draw_line(1, 2, 1, 2, 0); imlib_image_draw_line(w - 2, 2, w - 2, 2, 0); - + pmap = ecore_pixmap_new(guides.win.t, w, h, 0); mask = ecore_pixmap_new(guides.win.t, w, h, 1); imlib_context_set_drawable(pmap); @@ -397,7 +451,7 @@ e_guides_update(void) { ecore_window_resize(guides.win.t, 0, 0); } - + x = guides.current.x; y = guides.current.y + guides.current.h - 3; w = guides.current.w; @@ -408,7 +462,7 @@ e_guides_update(void) imlib_context_set_image(image); imlib_image_set_has_alpha(1); imlib_image_clear(); - + imlib_context_set_color(br, bg, bb, ba); imlib_image_draw_line(0, 2, w - 1, 2, 0); imlib_image_draw_line(2, 0, w - 3, 0, 0); @@ -418,7 +472,7 @@ e_guides_update(void) imlib_image_draw_line(1, 1, w - 2, 1, 0); imlib_image_draw_line(1, 0, 1, 0, 0); imlib_image_draw_line(w - 2, 0, w - 2, 0, 0); - + pmap = ecore_pixmap_new(guides.win.b, w, h, 0); mask = ecore_pixmap_new(guides.win.b, w, h, 1); imlib_context_set_drawable(pmap); @@ -439,7 +493,7 @@ e_guides_update(void) } } } - + if (guides.prev.visible != guides.current.visible) { if (guides.current.visible) @@ -495,7 +549,8 @@ e_guides_show(void) { D_ENTER; - if (guides.current.visible) D_RETURN; + if (guides.current.visible) + D_RETURN; guides.changed = 1; guides.current.visible = 1; @@ -507,7 +562,8 @@ e_guides_hide(void) { D_ENTER; - if (!guides.current.visible) D_RETURN; + if (!guides.current.visible) + D_RETURN; guides.changed = 1; guides.current.visible = 0; @@ -519,8 +575,8 @@ e_guides_move(int x, int y) { D_ENTER; - if ((guides.current.x == x) && - (guides.current.y == y)) D_RETURN; + if ((guides.current.x == x) && (guides.current.y == y)) + D_RETURN; guides.changed = 1; guides.current.x = x; guides.current.y = y; @@ -533,8 +589,8 @@ e_guides_resize(int w, int h) { D_ENTER; - if ((guides.current.w == w) && - (guides.current.h == h)) D_RETURN; + if ((guides.current.w == w) && (guides.current.h == h)) + D_RETURN; guides.changed = 1; guides.current.w = w; guides.current.h = h; @@ -548,7 +604,8 @@ e_guides_display_text(char *text) D_ENTER; if ((guides.current.display.text) && (text) && - (!strcmp(guides.current.display.text, text))) D_RETURN; + (!strcmp(guides.current.display.text, text))) + D_RETURN; guides.changed = 1; IF_FREE(guides.current.display.text); guides.current.display.text = NULL; @@ -564,7 +621,8 @@ e_guides_display_icon(char *icon) D_ENTER; if ((guides.current.display.icon) && (icon) && - (!strcmp(guides.current.display.icon, icon))) D_RETURN; + (!strcmp(guides.current.display.icon, icon))) + D_RETURN; guides.changed = 1; IF_FREE(guides.current.display.icon); guides.current.display.icon = NULL; @@ -579,7 +637,8 @@ e_guides_set_display_location(E_Guides_Location loc) { D_ENTER; - if (guides.current.display.loc == loc) D_RETURN; + if (guides.current.display.loc == loc) + D_RETURN; guides.changed = 1; guides.current.display.loc = loc; @@ -592,7 +651,8 @@ e_guides_set_display_alignment(double x, double y) D_ENTER; if ((guides.current.display.align.x == x) && - (guides.current.display.align.y == y)) D_RETURN; + (guides.current.display.align.y == y)) + D_RETURN; guides.changed = 1; guides.current.display.align.x = x; guides.current.display.align.y = y; @@ -605,22 +665,24 @@ e_guides_set_mode(E_Guides_Mode mode) { D_ENTER; - if (guides.current.mode == mode) D_RETURN; + if (guides.current.mode == mode) + D_RETURN; guides.changed = 1; guides.current.mode = mode; D_RETURN; } -void e_guides_init(void) +void +e_guides_init(void) { D_ENTER; guides.changed = 0; - + guides.current.display.loc = E_GUIDES_DISPLAY_LOCATION_SCREEN_MIDDLE; guides.current.display.text = NULL; - guides.current.display.icon = NULL; + guides.current.display.icon = NULL; guides.current.display.align.x = 0.5; guides.current.display.align.y = 0.5; guides.current.x = 0; @@ -629,21 +691,21 @@ void e_guides_init(void) guides.current.h = 0; guides.current.visible = 0; guides.current.mode = E_GUIDES_BOX; - + guides.prev = guides.current; - + guides.win.display = 0; guides.win.l = 0; guides.win.r = 0; guides.win.t = 0; guides.win.b = 0; - + guides.disp.evas = NULL; guides.disp.bg = NULL; guides.disp.text = NULL; guides.disp.icon = NULL; guides.disp.image = NULL; - + ecore_event_filter_idle_handler_add(e_guides_idle, NULL); D_RETURN; diff --git a/src/guides.h b/src/guides.h index 15c4c143b..516681cb7 100644 --- a/src/guides.h +++ b/src/guides.h @@ -2,22 +2,21 @@ #define E_GUIDES_H typedef enum e_guides_mode - { - E_GUIDES_OPAQUE, /* configure window border & client */ - E_GUIDES_BORDER, /* unmap client and configure window border */ - E_GUIDES_BOX, /* box outline */ - E_GUIDES_TECHNICAL /* lots of lines & info */ - } +{ + E_GUIDES_OPAQUE, /* configure window border & client */ + E_GUIDES_BORDER, /* unmap client and configure window border */ + E_GUIDES_BOX, /* box outline */ + E_GUIDES_TECHNICAL /* lots of lines & info */ +} E_Guides_Mode; typedef enum e_guides_location - { - E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE, - E_GUIDES_DISPLAY_LOCATION_SCREEN_MIDDLE - } +{ + E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE, + E_GUIDES_DISPLAY_LOCATION_SCREEN_MIDDLE +} E_Guides_Location; - /** * e_guides_init - Guides initialization. * @@ -25,16 +24,16 @@ E_Guides_Location; * little help windows that pop up when you move or resize * a window. */ -void e_guides_init(void); +void e_guides_init(void); -void e_guides_show(void); -void e_guides_hide(void); -void e_guides_move(int x, int y); -void e_guides_resize(int w, int h); -void e_guides_display_text(char *text); -void e_guides_display_icon(char *icon); -void e_guides_set_display_location(E_Guides_Location loc); -void e_guides_set_display_alignment(double x, double y); -void e_guides_set_mode(E_Guides_Mode mode); +void e_guides_show(void); +void e_guides_hide(void); +void e_guides_move(int x, int y); +void e_guides_resize(int w, int h); +void e_guides_display_text(char *text); +void e_guides_display_icon(char *icon); +void e_guides_set_display_location(E_Guides_Location loc); +void e_guides_set_display_alignment(double x, double y); +void e_guides_set_mode(E_Guides_Mode mode); #endif diff --git a/src/icccm.c b/src/icccm.c index ce91d1ab4..cba1e9367 100644 --- a/src/icccm.c +++ b/src/icccm.c @@ -38,11 +38,11 @@ /* Motif window hints */ typedef struct _mwmhints { - int flags; - int functions; - int decorations; - int inputMode; - int status; + int flags; + int functions; + int decorations; + int inputMode; + int status; } MWMHints; @@ -59,35 +59,36 @@ e_icccm_move_resize(Window win, int x, int y, int w, int h) void e_icccm_send_focus_to(Window win, int takes_focus) { - static Atom a_wm_take_focus = 0; - static Atom a_wm_protocols = 0; - int msg_focus = 0; - int *props; - int size; + static Atom a_wm_take_focus = 0; + static Atom a_wm_protocols = 0; + int msg_focus = 0; + int *props; + int size; D_ENTER; ECORE_ATOM(a_wm_take_focus, "WM_TAKE_FOCUS"); ECORE_ATOM(a_wm_protocols, "WM_PROTOCOLS"); - + props = ecore_window_property_get(win, a_wm_protocols, XA_ATOM, &size); if (props) { - int i, num; - + int i, num; + num = size / sizeof(int); for (i = 0; i < num; i++) { - if (props[i] == (int)a_wm_take_focus) msg_focus = 1; + if (props[i] == (int)a_wm_take_focus) + msg_focus = 1; } FREE(props); } if (takes_focus) - ecore_focus_to_window(win); + ecore_focus_to_window(win); if (msg_focus) { - unsigned int data[5]; - + unsigned int data[5]; + data[0] = a_wm_take_focus; data[1] = CurrentTime; ecore_window_send_client_message(win, a_wm_protocols, 32, data); @@ -99,33 +100,34 @@ e_icccm_send_focus_to(Window win, int takes_focus) void e_icccm_delete(Window win) { - static Atom a_wm_delete_window = 0; - static Atom a_wm_protocols = 0; - int *props; - int size; - int del_win = 0; - + static Atom a_wm_delete_window = 0; + static Atom a_wm_protocols = 0; + int *props; + int size; + int del_win = 0; + D_ENTER; ECORE_ATOM(a_wm_delete_window, "WM_DELETE_WINDOW"); ECORE_ATOM(a_wm_protocols, "WM_PROTOCOLS"); - + props = ecore_window_property_get(win, a_wm_protocols, XA_ATOM, &size); if (props) { - int i, num; - + int i, num; + num = size / sizeof(int); for (i = 0; i < num; i++) { - if (props[i] == (int)a_wm_delete_window) del_win = 1; + if (props[i] == (int)a_wm_delete_window) + del_win = 1; } FREE(props); } if (del_win) { - unsigned int data[5]; - + unsigned int data[5]; + data[0] = a_wm_delete_window; data[1] = CurrentTime; ecore_window_send_client_message(win, a_wm_protocols, 32, data); @@ -141,9 +143,9 @@ e_icccm_delete(Window win) void e_icccm_state_mapped(Window win) { - static Atom a_wm_state = 0; - unsigned int data[2]; - + static Atom a_wm_state = 0; + unsigned int data[2]; + D_ENTER; ECORE_ATOM(a_wm_state, "WM_STATE"); @@ -157,9 +159,9 @@ e_icccm_state_mapped(Window win) void e_icccm_state_iconified(Window win) { - static Atom a_wm_state = 0; - unsigned int data[2]; - + static Atom a_wm_state = 0; + unsigned int data[2]; + D_ENTER; ECORE_ATOM(a_wm_state, "WM_STATE"); @@ -173,9 +175,9 @@ e_icccm_state_iconified(Window win) void e_icccm_state_withdrawn(Window win) { - static Atom a_wm_state = 0; - unsigned int data[2]; - + static Atom a_wm_state = 0; + unsigned int data[2]; + D_ENTER; ECORE_ATOM(a_wm_state, "WM_STATE"); @@ -207,24 +209,24 @@ e_icccm_release(Window win) } void -e_icccm_get_pos_info(Window win, E_Border *b) +e_icccm_get_pos_info(Window win, E_Border * b) { - XSizeHints hint; - int mask; - + XSizeHints hint; + int mask; + D_ENTER; if (ecore_window_get_wm_size_hints(win, &hint, &mask)) { if ((hint.flags & USPosition) || ((hint.flags & PPosition))) { - int x, y, w, h; - + int x, y, w, h; + D("%li %li\n", hint.flags & USPosition, hint.flags & PPosition); b->client.pos.requested = 1; b->client.pos.gravity = NorthWestGravity; - if (hint.flags & PWinGravity) - b->client.pos.gravity = hint.win_gravity; + if (hint.flags & PWinGravity) + b->client.pos.gravity = hint.win_gravity; x = y = w = h = 0; ecore_window_get_geometry(win, &x, &y, &w, &h); b->client.pos.x = x; @@ -240,13 +242,14 @@ e_icccm_get_pos_info(Window win, E_Border *b) } void -e_icccm_get_size_info(Window win, E_Border *b) +e_icccm_get_size_info(Window win, E_Border * b) { - int base_w, base_h, min_w, min_h, max_w, max_h, grav, step_w, step_h; - double aspect_min, aspect_max; - int mask; - XSizeHints hint; - + int base_w, base_h, min_w, min_h, max_w, max_h, grav, step_w, + step_h; + double aspect_min, aspect_max; + int mask; + XSizeHints hint; + D_ENTER; grav = NorthWestGravity; @@ -268,38 +271,46 @@ e_icccm_get_size_info(Window win, E_Border *b) min_w = hint.min_width; min_h = hint.min_height; } - if (hint.flags & PMaxSize) + if (hint.flags & PMaxSize) { max_w = hint.max_width; max_h = hint.max_height; - if (max_w < min_w) max_w = min_w; - if (max_h < min_h) max_h = min_h; + if (max_w < min_w) + max_w = min_w; + if (max_h < min_h) + max_h = min_h; } - if (hint.flags & PResizeInc) + if (hint.flags & PResizeInc) { step_w = hint.width_inc; step_h = hint.height_inc; - if (step_w < 1) step_w = 1; - if (step_h < 1) step_h = 1; + if (step_w < 1) + step_w = 1; + if (step_h < 1) + step_h = 1; } - if (hint.flags & PBaseSize) + if (hint.flags & PBaseSize) { base_w = hint.base_width; base_h = hint.base_height; - if (base_w > max_w) max_w = base_w; - if (base_h > max_h) max_h = base_h; + if (base_w > max_w) + max_w = base_w; + if (base_h > max_h) + max_h = base_h; } else { base_w = min_w; base_h = min_h; } - if (hint.flags & PAspect) + if (hint.flags & PAspect) { if (hint.min_aspect.y > 0) - aspect_min = ((double)hint.min_aspect.x) / ((double)hint.min_aspect.y); + aspect_min = + ((double)hint.min_aspect.x) / ((double)hint.min_aspect.y); if (hint.max_aspect.y > 0) - aspect_max = ((double)hint.max_aspect.x) / ((double)hint.max_aspect.y); + aspect_max = + ((double)hint.max_aspect.x) / ((double)hint.max_aspect.y); } } b->client.min.w = min_w; @@ -318,23 +329,24 @@ e_icccm_get_size_info(Window win, E_Border *b) } void -e_icccm_get_mwm_hints(Window win, E_Border *b) +e_icccm_get_mwm_hints(Window win, E_Border * b) { - static Atom a_motif_wm_hints = 0; - MWMHints *mwmhints; - int size; - + static Atom a_motif_wm_hints = 0; + MWMHints *mwmhints; + int size; + D_ENTER; ECORE_ATOM(a_motif_wm_hints, "_MOTIF_WM_HINTS"); - - mwmhints = ecore_window_property_get(win, a_motif_wm_hints, a_motif_wm_hints, &size); + + mwmhints = + ecore_window_property_get(win, a_motif_wm_hints, a_motif_wm_hints, &size); if (mwmhints) { - int num; - + int num; + num = size / sizeof(int); - if (num < PROP_MWM_HINTS_ELEMENTS) + if (num < PROP_MWM_HINTS_ELEMENTS) { FREE(mwmhints); D_RETURN; @@ -350,9 +362,12 @@ e_icccm_get_mwm_hints(Window win, E_Border *b) b->client.handles = 1; b->client.titlebar = 1; } - if (mwmhints->decorations & MWM_DECOR_BORDER) b->client.border = 1; - if (mwmhints->decorations & MWM_DECOR_RESIZEH) b->client.handles = 1; - if (mwmhints->decorations & MWM_DECOR_TITLE) b->client.titlebar = 1; + if (mwmhints->decorations & MWM_DECOR_BORDER) + b->client.border = 1; + if (mwmhints->decorations & MWM_DECOR_RESIZEH) + b->client.handles = 1; + if (mwmhints->decorations & MWM_DECOR_TITLE) + b->client.titlebar = 1; } FREE(mwmhints); } @@ -361,23 +376,24 @@ e_icccm_get_mwm_hints(Window win, E_Border *b) } void -e_icccm_get_layer(Window win, E_Border *b) +e_icccm_get_layer(Window win, E_Border * b) { - static Atom a_win_layer = 0; - int *props; - int size; + static Atom a_win_layer = 0; + int *props; + int size; D_ENTER; ECORE_ATOM(a_win_layer, "_WIN_LAYER"); - + props = ecore_window_property_get(win, a_win_layer, XA_CARDINAL, &size); if (props) { - int num; - + int num; + num = size / sizeof(int); - if (num > 0) b->client.layer = props[0]; + if (num > 0) + b->client.layer = props[0]; FREE(props); } @@ -385,17 +401,17 @@ e_icccm_get_layer(Window win, E_Border *b) } void -e_icccm_get_title(Window win, E_Border *b) +e_icccm_get_title(Window win, E_Border * b) { - char *title; - + char *title; + D_ENTER; title = ecore_window_get_title(win); - if (b->client.title) + if (b->client.title) { - if ((title) && (!strcmp(title, b->client.title))) + if ((title) && (!strcmp(title, b->client.title))) { FREE(title); D_RETURN; @@ -404,15 +420,16 @@ e_icccm_get_title(Window win, E_Border *b) FREE(b->client.title); } b->client.title = NULL; - if (title) b->client.title = title; - else e_strdup(b->client.title, "No Title"); + if (title) + b->client.title = title; + else + e_strdup(b->client.title, "No Title"); D_RETURN; } - void -e_icccm_get_class(Window win, E_Border *b) +e_icccm_get_class(Window win, E_Border * b) { D_ENTER; @@ -421,28 +438,29 @@ e_icccm_get_class(Window win, E_Border *b) b->client.name = NULL; b->client.class = NULL; ecore_window_get_name_class(win, &(b->client.name), &(b->client.class)); - if (!b->client.name) e_strdup(b->client.name, "Unknown"); - if (!b->client.class) e_strdup(b->client.class, "Unknown"); + if (!b->client.name) + e_strdup(b->client.name, "Unknown"); + if (!b->client.class) + e_strdup(b->client.class, "Unknown"); D_RETURN; } void -e_icccm_get_hints(Window win, E_Border *b) +e_icccm_get_hints(Window win, E_Border * b) { D_ENTER; - ecore_window_get_hints(win, + ecore_window_get_hints(win, &(b->client.takes_focus), - &(b->client.initial_state), - NULL, NULL, NULL, - &(b->client.group)); + &(b->client.initial_state), + NULL, NULL, NULL, &(b->client.group)); D_RETURN; } void -e_icccm_get_machine(Window win, E_Border *b) +e_icccm_get_machine(Window win, E_Border * b) { D_ENTER; @@ -454,7 +472,7 @@ e_icccm_get_machine(Window win, E_Border *b) } void -e_icccm_get_command(Window win, E_Border *b) +e_icccm_get_command(Window win, E_Border * b) { D_ENTER; @@ -466,7 +484,7 @@ e_icccm_get_command(Window win, E_Border *b) } void -e_icccm_get_icon_name(Window win, E_Border *b) +e_icccm_get_icon_name(Window win, E_Border * b) { D_ENTER; @@ -478,11 +496,10 @@ e_icccm_get_icon_name(Window win, E_Border *b) } void -e_icccm_get_state(Window win, E_Border *b) +e_icccm_get_state(Window win, E_Border * b) { D_ENTER; - D_RETURN; UN(win); UN(b); @@ -491,8 +508,8 @@ e_icccm_get_state(Window win, E_Border *b) void e_icccm_set_frame_size(Window win, int l, int r, int t, int b) { - static Atom a_e_frame_size = 0; - int props[4]; + static Atom a_e_frame_size = 0; + int props[4]; D_ENTER; @@ -509,8 +526,8 @@ e_icccm_set_frame_size(Window win, int l, int r, int t, int b) void e_icccm_set_desk_area(Window win, int ax, int ay) { - static Atom a_win_area = 0; - int props[2]; + static Atom a_win_area = 0; + int props[2]; D_ENTER; @@ -525,8 +542,8 @@ e_icccm_set_desk_area(Window win, int ax, int ay) void e_icccm_set_desk_area_size(Window win, int ax, int ay) { - static Atom a_win_area_count = 0; - int props[2]; + static Atom a_win_area_count = 0; + int props[2]; D_ENTER; @@ -541,8 +558,8 @@ e_icccm_set_desk_area_size(Window win, int ax, int ay) void e_icccm_set_desk(Window win, int d) { - static Atom a_win_workspace = 0; - int props[2]; + static Atom a_win_workspace = 0; + int props[2]; D_ENTER; @@ -556,9 +573,9 @@ e_icccm_set_desk(Window win, int d) int e_icccm_is_shaped(Window win) { - int w, h, num; - int shaped = 1; - XRectangle *rect; + int w, h, num; + int shaped = 1; + XRectangle *rect; D_ENTER; @@ -566,89 +583,100 @@ e_icccm_is_shaped(Window win) rect = ecore_window_get_shape_rectangles(win, &num); if (!rect) - D_RETURN_(1); + D_RETURN_(1); - if ((num == 1) && + if ((num == 1) && (rect[0].x == 0) && (rect[0].y == 0) && (rect[0].width == w) && (rect[0].height == h)) - shaped = 0; + shaped = 0; XFree(rect); D_RETURN_(shaped); } void -e_icccm_get_e_hack_launch_id(Window win, E_Border *b) +e_icccm_get_e_hack_launch_id(Window win, E_Border * b) { - static Atom a_e_hack_launch_id = 0; - int *props; - int size; + static Atom a_e_hack_launch_id = 0; + int *props; + int size; D_ENTER; ECORE_ATOM(a_e_hack_launch_id, "_E_HACK_LAUNCH_ID"); - + props = ecore_window_property_get(win, a_e_hack_launch_id, XA_STRING, &size); if (props) { - char *str; - + char *str; + str = NEW(char, size + 1); ZERO(str, char, size + 1); + memcpy(str, props, size); b->client.e.launch_id = atoi(str); FREE(str); FREE(props); } else - b->client.e.launch_id = 0; + b->client.e.launch_id = 0; D_RETURN; } void -e_icccm_handle_property_change(Atom a, E_Border *b) +e_icccm_handle_property_change(Atom a, E_Border * b) { - static Atom a_wm_normal_hints = 0; - static Atom a_motif_wm_hints = 0; - static Atom a_wm_name = 0; - static Atom a_wm_class = 0; - static Atom a_wm_hints = 0; - static Atom a_wm_client_machine = 0; - static Atom a_wm_command = 0; - static Atom a_wm_icon_name = 0; - static Atom a_wm_state = 0; - static Atom a_e_hack_launch_id = 0; - + static Atom a_wm_normal_hints = 0; + static Atom a_motif_wm_hints = 0; + static Atom a_wm_name = 0; + static Atom a_wm_class = 0; + static Atom a_wm_hints = 0; + static Atom a_wm_client_machine = 0; + static Atom a_wm_command = 0; + static Atom a_wm_icon_name = 0; + static Atom a_wm_state = 0; + static Atom a_e_hack_launch_id = 0; + D_ENTER; ECORE_ATOM(a_wm_normal_hints, "WM_NORMAL_HINTS"); ECORE_ATOM(a_motif_wm_hints, "_MOTIF_WM_HINTS"); ECORE_ATOM(a_wm_name, "WM_NAME"); ECORE_ATOM(a_wm_class, "WM_CLASS"); - ECORE_ATOM(a_wm_hints, "WM_HINTS"); - ECORE_ATOM(a_wm_client_machine, "WM_CLIENT_MACHINE"); - ECORE_ATOM(a_wm_command, "WM_COMMAND"); - ECORE_ATOM(a_wm_icon_name, "WM_ICON_NAME"); - ECORE_ATOM(a_wm_state, "WM_STATE"); + ECORE_ATOM(a_wm_hints, "WM_HINTS"); + ECORE_ATOM(a_wm_client_machine, "WM_CLIENT_MACHINE"); + ECORE_ATOM(a_wm_command, "WM_COMMAND"); + ECORE_ATOM(a_wm_icon_name, "WM_ICON_NAME"); + ECORE_ATOM(a_wm_state, "WM_STATE"); ECORE_ATOM(a_e_hack_launch_id, "_E_HACK_LAUNCH_ID"); - - if (a == a_wm_normal_hints) e_icccm_get_size_info(b->win.client, b); - else if (a == a_motif_wm_hints) e_icccm_get_mwm_hints(b->win.client, b); - else if (a == a_wm_name) e_icccm_get_title(b->win.client, b); - else if (a == a_wm_class) e_icccm_get_class(b->win.client, b); - else if (a == a_wm_hints) e_icccm_get_hints(b->win.client, b); - else if (a == a_wm_client_machine) e_icccm_get_machine(b->win.client, b); - else if (a == a_wm_command) e_icccm_get_command(b->win.client, b); - else if (a == a_wm_icon_name) e_icccm_get_icon_name(b->win.client, b); - else if (a == a_wm_state) e_icccm_get_state(b->win.client, b); - else if (a == a_e_hack_launch_id) e_icccm_get_e_hack_launch_id(b->win.client, b); - + + if (a == a_wm_normal_hints) + e_icccm_get_size_info(b->win.client, b); + else if (a == a_motif_wm_hints) + e_icccm_get_mwm_hints(b->win.client, b); + else if (a == a_wm_name) + e_icccm_get_title(b->win.client, b); + else if (a == a_wm_class) + e_icccm_get_class(b->win.client, b); + else if (a == a_wm_hints) + e_icccm_get_hints(b->win.client, b); + else if (a == a_wm_client_machine) + e_icccm_get_machine(b->win.client, b); + else if (a == a_wm_command) + e_icccm_get_command(b->win.client, b); + else if (a == a_wm_icon_name) + e_icccm_get_icon_name(b->win.client, b); + else if (a == a_wm_state) + e_icccm_get_state(b->win.client, b); + else if (a == a_e_hack_launch_id) + e_icccm_get_e_hack_launch_id(b->win.client, b); + D_RETURN; } void -e_icccm_handle_client_message(Ecore_Event_Message *e) +e_icccm_handle_client_message(Ecore_Event_Message * e) { D_ENTER; @@ -661,22 +689,21 @@ e_icccm_advertise_e_compat(void) { D_ENTER; - D_RETURN; } void e_icccm_advertise_mwm_compat(void) { - static Atom a_motif_wm_info = 0; - int props[2]; - + static Atom a_motif_wm_info = 0; + int props[2]; + D_ENTER; ECORE_ATOM(a_motif_wm_info, "_MOTIF_WM_INFO"); props[0] = 2; props[0] = ecore_window_root(); - ecore_window_property_set(0, a_motif_wm_info, a_motif_wm_info, 32, props, 2); + ecore_window_property_set(0, a_motif_wm_info, a_motif_wm_info, 32, props, 2); D_RETURN; } @@ -684,13 +711,13 @@ e_icccm_advertise_mwm_compat(void) void e_icccm_advertise_gnome_compat(void) { - static Atom a_win_supporting_wm_check = 0; - static Atom a_win_protocols = 0; - static Atom a_win_wm_name = 0; - static Atom a_win_wm_version = 0; - static Atom a_win_layer = 0; - int props[32]; - Window win; + static Atom a_win_supporting_wm_check = 0; + static Atom a_win_protocols = 0; + static Atom a_win_wm_name = 0; + static Atom a_win_wm_version = 0; + static Atom a_win_layer = 0; + int props[32]; + Window win; D_ENTER; @@ -700,15 +727,19 @@ e_icccm_advertise_gnome_compat(void) ecore_window_property_set(0, a_win_protocols, XA_ATOM, 32, props, 1); ECORE_ATOM(a_win_wm_name, "_WIN_WM_NAME"); - ecore_window_property_set(0, a_win_wm_name, XA_STRING, 8, "Enlightenment", strlen("Enlightenment")); + ecore_window_property_set(0, a_win_wm_name, XA_STRING, 8, "Enlightenment", + strlen("Enlightenment")); ECORE_ATOM(a_win_wm_version, "_WIN_WM_VERSION"); - ecore_window_property_set(0, a_win_wm_version, XA_STRING, 8, "0.17.0", strlen("0.17.0")); - + ecore_window_property_set(0, a_win_wm_version, XA_STRING, 8, "0.17.0", + strlen("0.17.0")); + ECORE_ATOM(a_win_supporting_wm_check, "_WIN_SUPPORTING_WM_CHECK"); win = ecore_window_override_new(0, 0, 0, 7, 7); props[0] = win; - ecore_window_property_set(win, a_win_supporting_wm_check, XA_CARDINAL, 32, props, 1); - ecore_window_property_set(0, a_win_supporting_wm_check, XA_CARDINAL, 32, props, 1); + ecore_window_property_set(win, a_win_supporting_wm_check, XA_CARDINAL, 32, + props, 1); + ecore_window_property_set(0, a_win_supporting_wm_check, XA_CARDINAL, 32, + props, 1); D_RETURN; } @@ -718,7 +749,6 @@ e_icccm_advertise_kde_compat(void) { D_ENTER; - D_RETURN; } @@ -727,6 +757,5 @@ e_icccm_advertise_net_compat(void) { D_ENTER; - D_RETURN; } diff --git a/src/icccm.h b/src/icccm.h index e91f03399..5d3cc65f8 100644 --- a/src/icccm.h +++ b/src/icccm.h @@ -3,37 +3,38 @@ #include "e.h" -void e_icccm_move_resize(Window win, int x, int y, int w, int h); -void e_icccm_send_focus_to(Window win, int takes_focus); -void e_icccm_delete(Window win); -void e_icccm_state_mapped(Window win); -void e_icccm_state_iconified(Window win); -void e_icccm_state_withdrawn(Window win); -void e_icccm_adopt(Window win); -void e_icccm_release(Window win); -void e_icccm_get_pos_info(Window win, E_Border *b); -void e_icccm_get_size_info(Window win, E_Border *b); -void e_icccm_get_mwm_hints(Window win, E_Border *b); -void e_icccm_get_layer(Window win, E_Border *b); -void e_icccm_get_title(Window win, E_Border *b); -void e_icccm_get_class(Window win, E_Border *b); -void e_icccm_get_hints(Window win, E_Border *b); -void e_icccm_get_machine(Window win, E_Border *b); -void e_icccm_get_command(Window win, E_Border *b); -void e_icccm_get_icon_name(Window win, E_Border *b); -void e_icccm_get_state(Window win, E_Border *b); -void e_icccm_set_frame_size(Window win, int l, int r, int t, int b); -void e_icccm_set_desk_area(Window win, int ax, int ay); -void e_icccm_set_desk_area_size(Window win, int ax, int ay); -void e_icccm_set_desk(Window win, int d); -int e_icccm_is_shaped(Window win); -void e_icccm_get_e_hack_launch_id(Window win, E_Border *b); -void e_icccm_handle_property_change(Atom a, E_Border *b); -void e_icccm_handle_client_message(Ecore_Event_Message *e); -void e_icccm_advertise_e_compat(void); -void e_icccm_advertise_mwm_compat(void); -void e_icccm_advertise_gnome_compat(void); -void e_icccm_advertise_kde_compat(void); -void e_icccm_advertise_net_compat(void); +void e_icccm_move_resize(Window win, int x, int y, int w, int h); +void e_icccm_send_focus_to(Window win, int takes_focus); +void e_icccm_delete(Window win); +void e_icccm_state_mapped(Window win); +void e_icccm_state_iconified(Window win); +void e_icccm_state_withdrawn(Window win); +void e_icccm_adopt(Window win); +void e_icccm_release(Window win); +void e_icccm_get_pos_info(Window win, E_Border * b); +void e_icccm_get_size_info(Window win, E_Border * b); +void e_icccm_get_mwm_hints(Window win, E_Border * b); +void e_icccm_get_layer(Window win, E_Border * b); +void e_icccm_get_title(Window win, E_Border * b); +void e_icccm_get_class(Window win, E_Border * b); +void e_icccm_get_hints(Window win, E_Border * b); +void e_icccm_get_machine(Window win, E_Border * b); +void e_icccm_get_command(Window win, E_Border * b); +void e_icccm_get_icon_name(Window win, E_Border * b); +void e_icccm_get_state(Window win, E_Border * b); +void e_icccm_set_frame_size(Window win, int l, int r, int t, + int b); +void e_icccm_set_desk_area(Window win, int ax, int ay); +void e_icccm_set_desk_area_size(Window win, int ax, int ay); +void e_icccm_set_desk(Window win, int d); +int e_icccm_is_shaped(Window win); +void e_icccm_get_e_hack_launch_id(Window win, E_Border * b); +void e_icccm_handle_property_change(Atom a, E_Border * b); +void e_icccm_handle_client_message(Ecore_Event_Message * e); +void e_icccm_advertise_e_compat(void); +void e_icccm_advertise_mwm_compat(void); +void e_icccm_advertise_gnome_compat(void); +void e_icccm_advertise_kde_compat(void); +void e_icccm_advertise_net_compat(void); #endif diff --git a/src/iconbar.c b/src/iconbar.c index df8675f3c..70f468ab6 100644 --- a/src/iconbar.c +++ b/src/iconbar.c @@ -9,46 +9,48 @@ static E_Config_Base_Type *cf_iconbar = NULL; static E_Config_Base_Type *cf_iconbar_icon = NULL; -static Evas_List iconbars = NULL; +static Evas_List iconbars = NULL; /* internal func (iconbar use only) prototypes */ -static void e_ib_bit_down_cb (void *data, Ebits_Object o, char *class, int bt, - int x, int y, int ox, int oy, int ow, int oh); -static void e_ib_bit_up_cb (void *data, Ebits_Object o, char *class, int bt, - int x, int y, int ox, int oy, int ow, int oh); +static void e_ib_bit_down_cb(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, + int ow, int oh); +static void e_ib_bit_up_cb(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, int ow, + int oh); -static void ib_scroll_timeout (int val, void *data); -static void ib_timeout (int val, void *data); -static void ib_cancel_launch_timeout (int val, void *data); +static void ib_scroll_timeout(int val, void *data); +static void ib_timeout(int val, void *data); +static void ib_cancel_launch_timeout(int val, void *data); -static void ib_bits_show (void *data); -static void ib_bits_hide (void *data); -static void ib_bits_move (void *data, double x, double y); -static void ib_bits_resize (void *data, double w, double h); -static void ib_bits_raise (void *data); -static void ib_bits_lower (void *data); -static void ib_bits_set_layer (void *data, int l); -static void ib_bits_set_clip (void *data, Evas_Object clip); -static void ib_bits_set_color_class (void *data, char *cc, int r, int g, - int b, int a); -static void ib_bits_get_min_size (void *data, double *w, double *h); -static void ib_bits_get_max_size (void *data, double *w, double *h); +static void ib_bits_show(void *data); +static void ib_bits_hide(void *data); +static void ib_bits_move(void *data, double x, double y); +static void ib_bits_resize(void *data, double w, double h); +static void ib_bits_raise(void *data); +static void ib_bits_lower(void *data); +static void ib_bits_set_layer(void *data, int l); +static void ib_bits_set_clip(void *data, Evas_Object clip); +static void ib_bits_set_color_class(void *data, char *cc, int r, int g, + int b, int a); +static void ib_bits_get_min_size(void *data, double *w, double *h); +static void ib_bits_get_max_size(void *data, double *w, double *h); -static void ib_mouse_in (void *data, Evas _e, Evas_Object _o, int _b, int _x, - int _y); -static void ib_mouse_out (void *data, Evas _e, Evas_Object _o, int _b, int _x, - int _y); -static void ib_mouse_down (void *data, Evas _e, Evas_Object _o, int _b, - int _x, int _y); -static void ib_mouse_up (void *data, Evas _e, Evas_Object _o, int _b, int _x, - int _y); -static void ib_mouse_move (void *data, Evas _e, Evas_Object _o, int _b, - int _x, int _y); +static void ib_mouse_in(void *data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void ib_mouse_out(void *data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void ib_mouse_down(void *data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void ib_mouse_up(void *data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void ib_mouse_move(void *data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); -static void e_iconbar_icon_cleanup (E_Iconbar_Icon * ic); +static void e_iconbar_icon_cleanup(E_Iconbar_Icon * ic); -static void ib_child_handle (Ecore_Event * ev); +static void ib_child_handle(Ecore_Event * ev); /* NB: comments here for illustration & helping people understand E's code */ /* This is a start of the comments. if you feel they are not quite good */ @@ -59,66 +61,66 @@ static void ib_child_handle (Ecore_Event * ev); /* static internal - called when iconbar bit has a mouse button pressed */ /* on it */ static void -e_ib_bit_down_cb (void *data, Ebits_Object o, char *class, int bt, int x, - int y, int ox, int oy, int ow, int oh) +e_ib_bit_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, + int y, int ox, int oy, int ow, int oh) { - E_Iconbar *ib; + E_Iconbar *ib; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - if (!class) - D_RETURN; - if (!strcmp (class, "Scrollbar_Arrow1")) - ib_scroll_timeout (8, ib); - else if (!strcmp (class, "Scrollbar_Arrow2")) - ib_scroll_timeout (-8, ib); - else if (!strcmp (class, "Scrollbar_Trough")) - { - } + ib = (E_Iconbar *) data; + if (!class) + D_RETURN; + if (!strcmp(class, "Scrollbar_Arrow1")) + ib_scroll_timeout(8, ib); + else if (!strcmp(class, "Scrollbar_Arrow2")) + ib_scroll_timeout(-8, ib); + else if (!strcmp(class, "Scrollbar_Trough")) + { + } - D_RETURN; - UN (o); - UN (bt); - UN (x); - UN (y); - UN (ox); - UN (oy); - UN (ow); - UN (oh); + D_RETURN; + UN(o); + UN(bt); + UN(x); + UN(y); + UN(ox); + UN(oy); + UN(ow); + UN(oh); } /* static internal - called when iconbar bit has a mouse button released */ /* on it */ static void -e_ib_bit_up_cb (void *data, Ebits_Object o, char *class, int bt, int x, int y, - int ox, int oy, int ow, int oh) +e_ib_bit_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, + int ox, int oy, int ow, int oh) { - E_Iconbar *ib; + E_Iconbar *ib; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - if (!class) - D_RETURN; - if (!strcmp (class, "Scrollbar_Arrow1")) - ib_scroll_timeout (0, ib); - else if (!strcmp (class, "Scrollbar_Arrow2")) - ib_scroll_timeout (0, ib); - else if (!strcmp (class, "Scrollbar_Trough")) - { - } + ib = (E_Iconbar *) data; + if (!class) + D_RETURN; + if (!strcmp(class, "Scrollbar_Arrow1")) + ib_scroll_timeout(0, ib); + else if (!strcmp(class, "Scrollbar_Arrow2")) + ib_scroll_timeout(0, ib); + else if (!strcmp(class, "Scrollbar_Trough")) + { + } - D_RETURN; - UN (o); - UN (bt); - UN (x); - UN (y); - UN (ox); - UN (oy); - UN (ow); - UN (oh); + D_RETURN; + UN(o); + UN(bt); + UN(x); + UN(y); + UN(ox); + UN(oy); + UN(ow); + UN(oh); } /** @@ -128,238 +130,235 @@ e_ib_bit_up_cb (void *data, Ebits_Object o, char *class, int bt, int x, int y, * How do we free these pesky little urchins... */ static void -e_iconbar_cleanup (E_Iconbar * ib) +e_iconbar_cleanup(E_Iconbar * ib) { - char buf[PATH_MAX]; + char buf[PATH_MAX]; - D_ENTER; + D_ENTER; - /* remove from our list */ - iconbars = evas_list_remove (iconbars, ib); + /* remove from our list */ + iconbars = evas_list_remove(iconbars, ib); - /* save scroll position */ - /* tell the view we attached to that somehting in it changed. this way */ - /* the view will now it needs to redraw */ - ib->view->changed = 1; - /* free up our ebits */ - if (ib->bit) - ebits_free (ib->bit); - /* if we have any icons... */ - if (ib->icons) - { - Evas_List l; + /* save scroll position */ + /* tell the view we attached to that somehting in it changed. this way */ + /* the view will now it needs to redraw */ + ib->view->changed = 1; + /* free up our ebits */ + if (ib->bit) + ebits_free(ib->bit); + /* if we have any icons... */ + if (ib->icons) + { + Evas_List l; - /* go thru the list of icon and unref each one.. ie - free it */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; + /* go thru the list of icon and unref each one.. ie - free it */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; - ic = l->data; - e_object_unref (E_OBJECT (ic)); - } - /* free the list itself */ - evas_list_free (ib->icons); - } - /* cleaup the clip object */ - if ((ib->view) && (ib->view->evas) && (ib->clip)) - evas_del_object (ib->view->evas, ib->clip); - /* delete any timers intended to work on this iconbar */ - snprintf (buf, PATH_MAX, "iconbar_reload:%s", ib->view->name); - ecore_del_event_timer (buf); - snprintf (buf, PATH_MAX, "iconbar_scroll:%s", ib->view->name); - ecore_del_event_timer (buf); + ic = l->data; + e_object_unref(E_OBJECT(ic)); + } + /* free the list itself */ + evas_list_free(ib->icons); + } + /* cleaup the clip object */ + if ((ib->view) && (ib->view->evas) && (ib->clip)) + evas_del_object(ib->view->evas, ib->clip); + /* delete any timers intended to work on this iconbar */ + snprintf(buf, PATH_MAX, "iconbar_reload:%s", ib->view->name); + ecore_del_event_timer(buf); + snprintf(buf, PATH_MAX, "iconbar_scroll:%s", ib->view->name); + ecore_del_event_timer(buf); - /* call the destructor of the base class */ - e_object_cleanup (E_OBJECT (ib)); + /* call the destructor of the base class */ + e_object_cleanup(E_OBJECT(ib)); - - D_RETURN; + D_RETURN; } - /** * e_iconbar_init - Init function * * Initialises the iconbar system */ void -e_iconbar_init () +e_iconbar_init() { - D_ENTER; + D_ENTER; - /* we set up config structure and types so the config system can just */ - /* read a db and dump it right into memory - including lists of stuff */ + /* we set up config structure and types so the config system can just */ + /* read a db and dump it right into memory - including lists of stuff */ - /* a new config type - an iconbar icon */ - cf_iconbar_icon = e_config_type_new (); - /* this is a member of the iconbar icon struct we want the config system */ - /* to get from the db for us. the key is "exec". the type is a string */ - /* the struct memebr is exec. the default value is "". see the config.h */ - /* header for more info */ - E_CONFIG_NODE (cf_iconbar_icon, "exec", E_CFG_TYPE_STR, NULL, + /* a new config type - an iconbar icon */ + cf_iconbar_icon = e_config_type_new(); + /* this is a member of the iconbar icon struct we want the config system */ + /* to get from the db for us. the key is "exec". the type is a string */ + /* the struct memebr is exec. the default value is "". see the config.h */ + /* header for more info */ + E_CONFIG_NODE(cf_iconbar_icon, "exec", E_CFG_TYPE_STR, NULL, E_Iconbar_Icon, exec, 0, 0, ""); - E_CONFIG_NODE (cf_iconbar_icon, "wait", E_CFG_TYPE_INT, NULL, + E_CONFIG_NODE(cf_iconbar_icon, "wait", E_CFG_TYPE_INT, NULL, E_Iconbar_Icon, wait, 0, 0, ""); - E_CONFIG_NODE (cf_iconbar_icon, "wait_timeout", E_CFG_TYPE_FLOAT, NULL, + E_CONFIG_NODE(cf_iconbar_icon, "wait_timeout", E_CFG_TYPE_FLOAT, NULL, E_Iconbar_Icon, wait_timeout, 0, 0, ""); - /* this memebr will be replaced by the relative key path in the db as a */ - /* string */ - E_CONFIG_NODE (cf_iconbar_icon, "image", E_CFG_TYPE_KEY, NULL, + /* this memebr will be replaced by the relative key path in the db as a */ + /* string */ + E_CONFIG_NODE(cf_iconbar_icon, "image", E_CFG_TYPE_KEY, NULL, E_Iconbar_Icon, image_path, 0, 0, ""); - /* a new config type - in this case the iconbar istelf. the only thing we */ - /* want the config system to do it fill it with iconbar icon members in */ - /* the list */ - cf_iconbar = e_config_type_new (); - E_CONFIG_NODE (cf_iconbar, "icons", E_CFG_TYPE_LIST, cf_iconbar_icon, + /* a new config type - in this case the iconbar istelf. the only thing we */ + /* want the config system to do it fill it with iconbar icon members in */ + /* the list */ + cf_iconbar = e_config_type_new(); + E_CONFIG_NODE(cf_iconbar, "icons", E_CFG_TYPE_LIST, cf_iconbar_icon, E_Iconbar, icons, 0, 0, NULL); - E_CONFIG_NODE (cf_iconbar, "scroll", E_CFG_TYPE_FLOAT, NULL, E_Iconbar, + E_CONFIG_NODE(cf_iconbar, "scroll", E_CFG_TYPE_FLOAT, NULL, E_Iconbar, scroll, 0, 0, NULL); - ecore_event_filter_handler_add (ECORE_EVENT_CHILD, ib_child_handle); + ecore_event_filter_handler_add(ECORE_EVENT_CHILD, ib_child_handle); - D_RETURN; + D_RETURN; } /** * e_iconbar_new - Iconbar constructor * @v: The view for which an iconbar is to be constructed */ -E_Iconbar * -e_iconbar_new (E_View * v) +E_Iconbar * +e_iconbar_new(E_View * v) { - Evas_List l; - char buf[PATH_MAX]; - E_Iconbar *ib; + Evas_List l; + char buf[PATH_MAX]; + E_Iconbar *ib; - D_ENTER; + D_ENTER; - /* first we want to load the iconbar data itself - ie the config info */ - /* for what icons we have and what they execute */ - snprintf (buf, PATH_MAX, "%s/.e_iconbar.db", v->model->dir); - /* use the config system to simply load up the db and start making */ - /* structs and lists and stuff for us... we told it how to in init */ - ib = e_config_load (buf, "", cf_iconbar); - /* flush image cache */ - { - if (v->evas) - { - int size; + /* first we want to load the iconbar data itself - ie the config info */ + /* for what icons we have and what they execute */ + snprintf(buf, PATH_MAX, "%s/.e_iconbar.db", v->model->dir); + /* use the config system to simply load up the db and start making */ + /* structs and lists and stuff for us... we told it how to in init */ + ib = e_config_load(buf, "", cf_iconbar); + /* flush image cache */ + { + if (v->evas) + { + int size; - size = evas_get_image_cache (v->evas); - evas_set_image_cache (v->evas, 0); - evas_set_image_cache (v->evas, size); - } - } - /* flush edb cached handled */ - e_db_flush (); - /* no iconbar config loaded ? return NULL */ - if (!ib) - D_RETURN_ (NULL); + size = evas_get_image_cache(v->evas); + evas_set_image_cache(v->evas, 0); + evas_set_image_cache(v->evas, size); + } + } + /* flush edb cached handled */ + e_db_flush(); + /* no iconbar config loaded ? return NULL */ + if (!ib) + D_RETURN_(NULL); - /* now that the config system has doe the loading. we need to init the */ - /* object and set up ref counts and free method */ - e_object_init (E_OBJECT (ib), (E_Cleanup_Func) e_iconbar_cleanup); + /* now that the config system has doe the loading. we need to init the */ + /* object and set up ref counts and free method */ + e_object_init(E_OBJECT(ib), (E_Cleanup_Func) e_iconbar_cleanup); - /* the iconbar needs to know what view it's in */ - ib->view = v; - /* clip object = NULL */ - ib->clip = NULL; - /* reset has been scrolled flag */ - ib->has_been_scrolled = 0; + /* the iconbar needs to know what view it's in */ + ib->view = v; + /* clip object = NULL */ + ib->clip = NULL; + /* reset has been scrolled flag */ + ib->has_been_scrolled = 0; - /* now go thru all the icons that were loaded */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; + /* now go thru all the icons that were loaded */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; - ic = l->data; - /* and init the iocnbar icon object */ - e_object_init (E_OBJECT (ic), (E_Cleanup_Func) e_iconbar_icon_cleanup); + ic = l->data; + /* and init the iocnbar icon object */ + e_object_init(E_OBJECT(ic), (E_Cleanup_Func) e_iconbar_icon_cleanup); - /* and have the iconbar icon know what iconbar it belongs to */ - ic->iconbar = ib; - } + /* and have the iconbar icon know what iconbar it belongs to */ + ic->iconbar = ib; + } - /* now we need to load up a bits file that tells us where in the view the */ - /* iconbar is meant to go. same place. just a slightly different name */ - snprintf (buf, PATH_MAX, "%s/.e_iconbar.bits.db", v->model->dir); - ib->bit = ebits_load (buf); - /* we didn't find one? */ - if (!ib->bit) - { - /* unref the iconbar (and thus it will get freed and all icons in it */ - e_object_unref (E_OBJECT (ib)); - /* return NULL - no iconbar worth doing here if we don't know where */ - /* to put it */ - D_RETURN_ (NULL); - } - ebits_set_classed_bit_callback (ib->bit, "Scrollbar_Arrow1", + /* now we need to load up a bits file that tells us where in the view the */ + /* iconbar is meant to go. same place. just a slightly different name */ + snprintf(buf, PATH_MAX, "%s/.e_iconbar.bits.db", v->model->dir); + ib->bit = ebits_load(buf); + /* we didn't find one? */ + if (!ib->bit) + { + /* unref the iconbar (and thus it will get freed and all icons in it */ + e_object_unref(E_OBJECT(ib)); + /* return NULL - no iconbar worth doing here if we don't know where */ + /* to put it */ + D_RETURN_(NULL); + } + ebits_set_classed_bit_callback(ib->bit, "Scrollbar_Arrow1", CALLBACK_MOUSE_DOWN, e_ib_bit_down_cb, ib); - ebits_set_classed_bit_callback (ib->bit, "Scrollbar_Arrow1", + ebits_set_classed_bit_callback(ib->bit, "Scrollbar_Arrow1", CALLBACK_MOUSE_UP, e_ib_bit_up_cb, ib); - ebits_set_classed_bit_callback (ib->bit, "Scrollbar_Arrow2", + ebits_set_classed_bit_callback(ib->bit, "Scrollbar_Arrow2", CALLBACK_MOUSE_DOWN, e_ib_bit_down_cb, ib); - ebits_set_classed_bit_callback (ib->bit, "Scrollbar_Arrow2", + ebits_set_classed_bit_callback(ib->bit, "Scrollbar_Arrow2", CALLBACK_MOUSE_UP, e_ib_bit_up_cb, ib); - /* add to our list of iconbars */ - iconbars = evas_list_append (iconbars, ib); + /* add to our list of iconbars */ + iconbars = evas_list_append(iconbars, ib); - /* aaah. our nicely constructed iconbar data struct with all the goodies */ - /* we need. return it. she's ready for use. */ - D_RETURN_ (ib); + /* aaah. our nicely constructed iconbar data struct with all the goodies */ + /* we need. return it. she's ready for use. */ + D_RETURN_(ib); } - /** * e_iconbar_icon_cleanup -- Iconbar icon destructor * @ic: The icon that is to be freed */ static void -e_iconbar_icon_cleanup (E_Iconbar_Icon * ic) +e_iconbar_icon_cleanup(E_Iconbar_Icon * ic) { - D_ENTER; - D ("iconbar icon cleanup\n"); - /* if we have an imageobject. nuke it */ - if (ic->image) - evas_del_object (ic->iconbar->view->evas, ic->image); - /* cleanup the imlib_image */ - if (ic->imlib_image) - { - imlib_context_set_image(ic->imlib_image); - imlib_free_image(); - } - - /* free strings ... if they exist */ - IF_FREE (ic->image_path); - IF_FREE (ic->exec); - /* stop the timer for this icon */ - if (ic->hi.timer) - { - ecore_del_event_timer (ic->hi.timer); - FREE (ic->hi.timer); - } - if (ic->hi.image) - evas_del_object (ic->iconbar->view->evas, ic->hi.image); + D_ENTER; + D("iconbar icon cleanup\n"); + /* if we have an imageobject. nuke it */ + if (ic->image) + evas_del_object(ic->iconbar->view->evas, ic->image); + /* cleanup the imlib_image */ + if (ic->imlib_image) + { + imlib_context_set_image(ic->imlib_image); + imlib_free_image(); + } - if (ic->launch_id_cb) - { - e_exec_broadcast_cb_del (ic->launch_id_cb); - ic->launch_id_cb = NULL; - } - if (ic->launch_id) - { - char buf[PATH_MAX]; + /* free strings ... if they exist */ + IF_FREE(ic->image_path); + IF_FREE(ic->exec); + /* stop the timer for this icon */ + if (ic->hi.timer) + { + ecore_del_event_timer(ic->hi.timer); + FREE(ic->hi.timer); + } + if (ic->hi.image) + evas_del_object(ic->iconbar->view->evas, ic->hi.image); - snprintf (buf, PATH_MAX, "iconbar_launch_wait:%i", ic->launch_id); - ecore_del_event_timer (buf); - ic->launch_id = 0; - } - /* Call the destructor of the base class */ - e_object_cleanup (E_OBJECT (ic)); + if (ic->launch_id_cb) + { + e_exec_broadcast_cb_del(ic->launch_id_cb); + ic->launch_id_cb = NULL; + } + if (ic->launch_id) + { + char buf[PATH_MAX]; - D_RETURN; + snprintf(buf, PATH_MAX, "iconbar_launch_wait:%i", ic->launch_id); + ecore_del_event_timer(buf); + ic->launch_id = 0; + } + /* Call the destructor of the base class */ + e_object_cleanup(E_OBJECT(ic)); + + D_RETURN; } /** @@ -371,59 +370,59 @@ e_iconbar_icon_cleanup (E_Iconbar_Icon * ic) * we can do something visual with */ void -e_iconbar_realize (E_Iconbar * ib) +e_iconbar_realize(E_Iconbar * ib) { - Evas_List l; + Evas_List l; - D_ENTER; + D_ENTER; - /* create clip object */ - ib->clip = evas_add_rectangle (ib->view->evas); - evas_set_color (ib->view->evas, ib->clip, 255, 255, 255, 255); - /* go thru every icon in the iconbar */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; - char buf[PATH_MAX]; + /* create clip object */ + ib->clip = evas_add_rectangle(ib->view->evas); + evas_set_color(ib->view->evas, ib->clip, 255, 255, 255, 255); + /* go thru every icon in the iconbar */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; + char buf[PATH_MAX]; - ic = l->data; - /* set the path of the image to load to be the iconbar db plus */ - /* the path of the key to the image memebr - that is actually */ - /* a lump of image data inlined in the iconbar db - so the icons */ - /* themselves follow the iconbar wherever it goes */ - snprintf (buf, PATH_MAX, "%s/.e_iconbar.db:%s", ib->view->model->dir, - ic->image_path); - /* add the icon image object */ - ic->image = evas_add_image_from_file (ib->view->evas, buf); - /* add an imlib image so we can save it later */ - ic->imlib_image = imlib_load_image (buf); - /* clip the icon */ - evas_set_clip (ib->view->evas, ic->image, ib->clip); - /* set it to be semi-transparent */ - evas_set_color (ib->view->evas, ic->image, 255, 255, 255, 128); - /* set up callbacks on events - so the ib_* functions will be */ - /* called when the corresponding event happens to the icon */ - evas_callback_add (ib->view->evas, ic->image, CALLBACK_MOUSE_IN, - ib_mouse_in, ic); - evas_callback_add (ib->view->evas, ic->image, CALLBACK_MOUSE_OUT, - ib_mouse_out, ic); - evas_callback_add (ib->view->evas, ic->image, CALLBACK_MOUSE_DOWN, - ib_mouse_down, ic); - evas_callback_add (ib->view->evas, ic->image, CALLBACK_MOUSE_UP, - ib_mouse_up, ic); - evas_callback_add (ib->view->evas, ic->image, CALLBACK_MOUSE_MOVE, - ib_mouse_move, ic); - } - /* add the ebit we loaded to the evas the iconbar exists in - now the */ - /* ebit is more than just structures as well. */ - ebits_add_to_evas (ib->bit, ib->view->evas); - /* aaaaaaaaah. the magic of being able to replace a named bit in an ebit */ - /* (in this case we expect a bit called "Icons" to exist - the user will */ - /* have added a bit called this into the ebit to indicate where he/she */ - /* wants icons to go. we basically replace this bit with a virtual set */ - /* of callbacks that ebits will call if this bit is to be moved, resized */ - /* shown, hidden, raised, lowered etc. we provide the callbacks. */ - ebits_set_named_bit_replace (ib->bit, "Icons", + ic = l->data; + /* set the path of the image to load to be the iconbar db plus */ + /* the path of the key to the image memebr - that is actually */ + /* a lump of image data inlined in the iconbar db - so the icons */ + /* themselves follow the iconbar wherever it goes */ + snprintf(buf, PATH_MAX, "%s/.e_iconbar.db:%s", ib->view->model->dir, + ic->image_path); + /* add the icon image object */ + ic->image = evas_add_image_from_file(ib->view->evas, buf); + /* add an imlib image so we can save it later */ + ic->imlib_image = imlib_load_image(buf); + /* clip the icon */ + evas_set_clip(ib->view->evas, ic->image, ib->clip); + /* set it to be semi-transparent */ + evas_set_color(ib->view->evas, ic->image, 255, 255, 255, 128); + /* set up callbacks on events - so the ib_* functions will be */ + /* called when the corresponding event happens to the icon */ + evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_IN, + ib_mouse_in, ic); + evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_OUT, + ib_mouse_out, ic); + evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_DOWN, + ib_mouse_down, ic); + evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_UP, + ib_mouse_up, ic); + evas_callback_add(ib->view->evas, ic->image, CALLBACK_MOUSE_MOVE, + ib_mouse_move, ic); + } + /* add the ebit we loaded to the evas the iconbar exists in - now the */ + /* ebit is more than just structures as well. */ + ebits_add_to_evas(ib->bit, ib->view->evas); + /* aaaaaaaaah. the magic of being able to replace a named bit in an ebit */ + /* (in this case we expect a bit called "Icons" to exist - the user will */ + /* have added a bit called this into the ebit to indicate where he/she */ + /* wants icons to go. we basically replace this bit with a virtual set */ + /* of callbacks that ebits will call if this bit is to be moved, resized */ + /* shown, hidden, raised, lowered etc. we provide the callbacks. */ + ebits_set_named_bit_replace(ib->bit, "Icons", ib_bits_show, ib_bits_hide, ib_bits_move, @@ -433,16 +432,15 @@ e_iconbar_realize (E_Iconbar * ib) ib_bits_set_layer, ib_bits_set_clip, ib_bits_set_color_class, - ib_bits_get_min_size, - ib_bits_get_max_size, ib); - /* now move this ebit to a really high layer.. so its ontop of a lot */ - ebits_set_layer (ib->bit, 10000); - /* and now call "fix" - i called it fix cause it does a few things... */ - /* but fixes the iconbar so its the size of the view, in the right */ - /* place and arranges the icons in their right spots */ - e_iconbar_fix (ib); + ib_bits_get_min_size, ib_bits_get_max_size, ib); + /* now move this ebit to a really high layer.. so its ontop of a lot */ + ebits_set_layer(ib->bit, 10000); + /* and now call "fix" - i called it fix cause it does a few things... */ + /* but fixes the iconbar so its the size of the view, in the right */ + /* place and arranges the icons in their right spots */ + e_iconbar_fix(ib); - D_RETURN; + D_RETURN; } /** @@ -454,42 +452,42 @@ e_iconbar_realize (E_Iconbar * ib) * */ double -e_iconbar_get_length (E_Iconbar * ib) +e_iconbar_get_length(E_Iconbar * ib) { - double ix, iy, aw, ah; - double len; - Evas_List l; + double ix, iy, aw, ah; + double len; + Evas_List l; - D_ENTER; + D_ENTER; - /* init len */ - len = 0; - /* find icon area geometry */ - ix = ib->icon_area.x; - iy = ib->icon_area.y; - aw = ib->icon_area.w; - ah = ib->icon_area.h; + /* init len */ + len = 0; + /* find icon area geometry */ + ix = ib->icon_area.x; + iy = ib->icon_area.y; + aw = ib->icon_area.w; + ah = ib->icon_area.h; - /* loop throught icons */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; - int iw, ih; + /* loop throught icons */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; + int iw, ih; - ic = l->data; - /* find out the original image size (of the image file) */ - evas_get_image_size (ic->iconbar->view->evas, ic->image, &iw, &ih); - if (aw > ah) /* horizontal */ - { - len += iw; - } - else /* vertical */ - { - len += ih; - } - } - /* return length */ - D_RETURN_ (len); + ic = l->data; + /* find out the original image size (of the image file) */ + evas_get_image_size(ic->iconbar->view->evas, ic->image, &iw, &ih); + if (aw > ah) /* horizontal */ + { + len += iw; + } + else /* vertical */ + { + len += ih; + } + } + /* return length */ + D_RETURN_(len); } /** @@ -500,157 +498,157 @@ e_iconbar_get_length (E_Iconbar * ib) * of the iconbar gfx and icons */ void -e_iconbar_fix (E_Iconbar * ib) +e_iconbar_fix(E_Iconbar * ib) { - Evas_List l; - double ix, iy, aw, ah; + Evas_List l; + double ix, iy, aw, ah; - D_ENTER; + D_ENTER; - /* move the ebit to 0,0 */ - ebits_move (ib->bit, 0, 0); - /* resize it to fill the whole view. the internal geometry of the */ - /* ebit itself will determine where things woudl go. we just tell */ - /* the ebit where in the canvas its allowed to exist */ - ebits_resize (ib->bit, ib->view->size.w, ib->view->size.h); - /* show it. harmless to do this all the time */ - ebits_show (ib->bit); - /* tell the view we belong to something may have changed so it can draw */ - ib->view->changed = 1; + /* move the ebit to 0,0 */ + ebits_move(ib->bit, 0, 0); + /* resize it to fill the whole view. the internal geometry of the */ + /* ebit itself will determine where things woudl go. we just tell */ + /* the ebit where in the canvas its allowed to exist */ + ebits_resize(ib->bit, ib->view->size.w, ib->view->size.h); + /* show it. harmless to do this all the time */ + ebits_show(ib->bit); + /* tell the view we belong to something may have changed so it can draw */ + ib->view->changed = 1; - /* the callbacks set up in th ebtis replace will set up what area in */ - /* the canvas icons can exist in. lets extract them here */ - ix = ib->icon_area.x; - iy = ib->icon_area.y; - aw = ib->icon_area.w; - ah = ib->icon_area.h; + /* the callbacks set up in th ebtis replace will set up what area in */ + /* the canvas icons can exist in. lets extract them here */ + ix = ib->icon_area.x; + iy = ib->icon_area.y; + aw = ib->icon_area.w; + ah = ib->icon_area.h; - /* if we have icons- show the clipper that will clip them */ - if (ib->icons) - evas_show (ib->view->evas, ib->clip); - /* no icons - hide the clipper as it will be a real object */ - else - evas_hide (ib->view->evas, ib->clip); - /* move the clip object to fill the icon area */ - evas_move (ib->view->evas, ib->clip, ix, iy); - evas_resize (ib->view->evas, ib->clip, aw, ah); + /* if we have icons- show the clipper that will clip them */ + if (ib->icons) + evas_show(ib->view->evas, ib->clip); + /* no icons - hide the clipper as it will be a real object */ + else + evas_hide(ib->view->evas, ib->clip); + /* move the clip object to fill the icon area */ + evas_move(ib->view->evas, ib->clip, ix, iy); + evas_resize(ib->view->evas, ib->clip, aw, ah); - if (aw > ah) /* horizontal */ - { - double len; + if (aw > ah) /* horizontal */ + { + double len; - len = e_iconbar_get_length (ib); - if (aw > len) - { - if ((ib->scroll + len) > aw) - ib->scroll = aw - len; - else if (ib->scroll < 0) - ib->scroll = 0; - } - else - { - if ((ib->scroll + len) > aw) - ib->scroll = aw - len; - else if (ib->scroll > 0) - ib->scroll = 0; - } - ix += ib->scroll; - } - else /* vertical */ - { - double len; + len = e_iconbar_get_length(ib); + if (aw > len) + { + if ((ib->scroll + len) > aw) + ib->scroll = aw - len; + else if (ib->scroll < 0) + ib->scroll = 0; + } + else + { + if ((ib->scroll + len) > aw) + ib->scroll = aw - len; + else if (ib->scroll > 0) + ib->scroll = 0; + } + ix += ib->scroll; + } + else /* vertical */ + { + double len; - len = e_iconbar_get_length (ib); - if (ah > len) - { - if ((ib->scroll + len) > ah) - ib->scroll = ah - len; - else if (ib->scroll < 0) - ib->scroll = 0; - } - else - { - if ((ib->scroll + len) < ah) - ib->scroll = ah - len; - else if (ib->scroll > 0) - ib->scroll = 0; - } - iy += ib->scroll; - } + len = e_iconbar_get_length(ib); + if (ah > len) + { + if ((ib->scroll + len) > ah) + ib->scroll = ah - len; + else if (ib->scroll < 0) + ib->scroll = 0; + } + else + { + if ((ib->scroll + len) < ah) + ib->scroll = ah - len; + else if (ib->scroll > 0) + ib->scroll = 0; + } + iy += ib->scroll; + } - /* now go thru all the icons... */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; - int iw, ih; - double w, h; - double ox, oy; + /* now go thru all the icons... */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; + int iw, ih; + double w, h; + double ox, oy; - ic = l->data; - /* find out the original image size (of the image file) */ - evas_get_image_size (ic->iconbar->view->evas, ic->image, &iw, &ih); - w = iw; - h = ih; - ox = 0; - oy = 0; - /* if the area to put icons is wider that it is tall... horizonatal */ - /* layout of the icons seems smart */ - if (aw > ah) /* horizontal */ - { - /* if the icon height is bigger than the icon space */ - if (h > ah) - { - /* scale the icon down in both directions soit fits */ - w = (ah * w) / h; - h = ah; - } - /* center the icon vertically if its smaller */ - ox = 0; - oy = (ah - h) / 2; + ic = l->data; + /* find out the original image size (of the image file) */ + evas_get_image_size(ic->iconbar->view->evas, ic->image, &iw, &ih); + w = iw; + h = ih; + ox = 0; + oy = 0; + /* if the area to put icons is wider that it is tall... horizonatal */ + /* layout of the icons seems smart */ + if (aw > ah) /* horizontal */ + { + /* if the icon height is bigger than the icon space */ + if (h > ah) + { + /* scale the icon down in both directions soit fits */ + w = (ah * w) / h; + h = ah; + } + /* center the icon vertically if its smaller */ + ox = 0; + oy = (ah - h) / 2; - /* set the icons geometry */ - ic->current.x = ix + ox; - ic->current.y = iy + oy; - ic->current.w = w; - ic->current.h = h; + /* set the icons geometry */ + ic->current.x = ix + ox; + ic->current.y = iy + oy; + ic->current.w = w; + ic->current.h = h; - /* advance our position counter to the next spot */ - ix += w; - } - /* taller than it is wide. might be good to be vertical */ - else /* vertical */ - { - /* if theicon width is bigger than the icon space */ - if (w > aw) - { - /* scale it down to fit */ - h = (aw * h) / w; - w = aw; - } - /* center it horizontally */ - ox = (aw - w) / 2; - oy = 0; + /* advance our position counter to the next spot */ + ix += w; + } + /* taller than it is wide. might be good to be vertical */ + else /* vertical */ + { + /* if theicon width is bigger than the icon space */ + if (w > aw) + { + /* scale it down to fit */ + h = (aw * h) / w; + w = aw; + } + /* center it horizontally */ + ox = (aw - w) / 2; + oy = 0; - /* set the icons geometry */ - ic->current.x = ix + ox; - ic->current.y = iy + oy; - ic->current.w = w; - ic->current.h = h; + /* set the icons geometry */ + ic->current.x = ix + ox; + ic->current.y = iy + oy; + ic->current.w = w; + ic->current.h = h; - /* advance out counter to the next spot */ - iy += h; - } + /* advance out counter to the next spot */ + iy += h; + } - /* now move the icona nd resize it */ - evas_move (ic->iconbar->view->evas, ic->image, ic->current.x, - ic->current.y); - evas_resize (ic->iconbar->view->evas, ic->image, ic->current.w, - ic->current.h); - evas_set_image_fill (ic->iconbar->view->evas, ic->image, 0, 0, - ic->current.w, ic->current.h); - } + /* now move the icona nd resize it */ + evas_move(ic->iconbar->view->evas, ic->image, ic->current.x, + ic->current.y); + evas_resize(ic->iconbar->view->evas, ic->image, ic->current.w, + ic->current.h); + evas_set_image_fill(ic->iconbar->view->evas, ic->image, 0, 0, + ic->current.w, ic->current.h); + } - D_RETURN; + D_RETURN; } /** @@ -661,24 +659,24 @@ e_iconbar_fix (E_Iconbar * ib) * This function is called whenever a file is deleted from a view. */ void -e_iconbar_file_delete (E_View * v, char *file) +e_iconbar_file_delete(E_View * v, char *file) { - D_ENTER; + D_ENTER; - /* is the file of interest */ - if ((!strcmp (".e_iconbar.db", file)) || - (!strcmp (".e_iconbar.bits.db", file))) - { - /* if we have an iconbar.. delete it - because its files have been */ - /* nuked. no need to keep it around. */ - if (v->iconbar) - { - e_object_unref (E_OBJECT (v->iconbar)); - v->iconbar = NULL; - } - } + /* is the file of interest */ + if ((!strcmp(".e_iconbar.db", file)) || + (!strcmp(".e_iconbar.bits.db", file))) + { + /* if we have an iconbar.. delete it - because its files have been */ + /* nuked. no need to keep it around. */ + if (v->iconbar) + { + e_object_unref(E_OBJECT(v->iconbar)); + v->iconbar = NULL; + } + } - D_RETURN; + D_RETURN; } /** @@ -688,1081 +686,1069 @@ e_iconbar_file_delete (E_View * v, char *file) * This function saves the state of the iconbar to the db it comes from */ void -e_iconbar_save_out_final (E_Iconbar * ib) +e_iconbar_save_out_final(E_Iconbar * ib) { - char buf[PATH_MAX]; + char buf[PATH_MAX]; - D_ENTER; + D_ENTER; - if (ib->view) - { - E_DB_File *edb; - Evas_List l; - int i; + if (ib->view) + { + E_DB_File *edb; + Evas_List l; + int i; - snprintf (buf, PATH_MAX, "%s/.e_iconbar.db", ib->view->model->dir); - D ("%s\n", buf); + snprintf(buf, PATH_MAX, "%s/.e_iconbar.db", ib->view->model->dir); + D("%s\n", buf); - if (ib->changed) - { - D ("ib changed\n") edb = e_db_open (buf); - if (edb) - { - D ("got edb\n"); - for (l = ib->icons, i = 0; l; l = l->next, i++) - { - E_Iconbar_Icon *ic = l->data; - char buf2[PATH_MAX]; - - if (ic) + if (ib->changed) + { + D("ib changed\n") edb = e_db_open(buf); + if (edb) + { + D("got edb\n"); + for (l = ib->icons, i = 0; l; l = l->next, i++) { - /* save out exec */ - snprintf (buf2, PATH_MAX, "/icons/%i/exec", i); - D ("set exec: %i\n", i); - e_db_str_set (edb, buf2, ic->exec); + E_Iconbar_Icon *ic = l->data; + char buf2[PATH_MAX]; - /* save out image */ - if (ic->imlib_image) - { - imlib_context_set_image (ic->imlib_image); - imlib_image_attach_data_value ("compression", NULL, - 9, NULL); - imlib_image_set_format ("db"); + if (ic) + { + /* save out exec */ + snprintf(buf2, PATH_MAX, "/icons/%i/exec", i); + D("set exec: %i\n", i); + e_db_str_set(edb, buf2, ic->exec); - snprintf (buf2, PATH_MAX, - "%s/.e_iconbar.db:/icons/%i/image", - ib->view->model->dir, i); - D ("save image\n"); - imlib_save_image (buf2); - } + /* save out image */ + if (ic->imlib_image) + { + imlib_context_set_image(ic->imlib_image); + imlib_image_attach_data_value("compression", + NULL, 9, NULL); + imlib_image_set_format("db"); + + snprintf(buf2, PATH_MAX, + "%s/.e_iconbar.db:/icons/%i/image", + ib->view->model->dir, i); + D("save image\n"); + imlib_save_image(buf2); + } + } } - } - D ("set count\n"); - e_db_int_set (edb, "/icons/count", i); - D ("set scroll\n"); - e_db_float_set (edb, "/scroll", ib->scroll); - D ("close db\n"); - e_db_close (edb); + D("set count\n"); + e_db_int_set(edb, "/icons/count", i); + D("set scroll\n"); + e_db_float_set(edb, "/scroll", ib->scroll); + D("close db\n"); + e_db_close(edb); - } - } + } + } - else - { - E_DB_FLOAT_SET (buf, "/scroll", ib->scroll); - } - /*D ("set just_saved\n"); - ib->just_saved = 1;*/ - ib->changed = 0; + else + { + E_DB_FLOAT_SET(buf, "/scroll", ib->scroll); + } + /*D ("set just_saved\n"); + * ib->just_saved = 1; */ + ib->changed = 0; - } - D_RETURN; + } + D_RETURN; } void -e_iconbar_handle_launch_id (Window win, void *data) +e_iconbar_handle_launch_id(Window win, void *data) { - E_Iconbar_Icon *ic; - E_Border *b; + E_Iconbar_Icon *ic; + E_Border *b; - ic = (E_Iconbar_Icon *) data; - b = e_border_find_by_window (win); - if (!b) - return; - if ((ic->launch_id) && (b->client.e.launch_id)) - { - if (b->client.e.launch_id == ic->launch_id) - { - if (ic->launch_id) - { - char buf[PATH_MAX]; + ic = (E_Iconbar_Icon *) data; + b = e_border_find_by_window(win); + if (!b) + return; + if ((ic->launch_id) && (b->client.e.launch_id)) + { + if (b->client.e.launch_id == ic->launch_id) + { + if (ic->launch_id) + { + char buf[PATH_MAX]; - snprintf (buf, PATH_MAX, "iconbar_launch_wait:%i", - ic->launch_id); - ecore_del_event_timer (buf); - } - ic->launch_id = 0; - if (ic->launch_id_cb) - { - e_exec_broadcast_cb_del (ic->launch_id_cb); - ic->launch_id_cb = NULL; - } - evas_set_color (ic->iconbar->view->evas, ic->image, 255, 255, 255, - 128); - ic->iconbar->view->changed = 1; - } - } + snprintf(buf, PATH_MAX, "iconbar_launch_wait:%i", + ic->launch_id); + ecore_del_event_timer(buf); + } + ic->launch_id = 0; + if (ic->launch_id_cb) + { + e_exec_broadcast_cb_del(ic->launch_id_cb); + ic->launch_id_cb = NULL; + } + evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, + 128); + ic->iconbar->view->changed = 1; + } + } } /* static (internal to iconbar use only) callbacks */ /* scroll timeout. called to continuously scroll when arrow button down */ static void -ib_scroll_timeout (int val, void *data) +ib_scroll_timeout(int val, void *data) { - E_Iconbar *ib; - char buf[PATH_MAX]; + E_Iconbar *ib; + char buf[PATH_MAX]; - D_ENTER; + D_ENTER; - /* get our iconbar pointer */ - ib = (E_Iconbar *) data; + /* get our iconbar pointer */ + ib = (E_Iconbar *) data; - snprintf (buf, PATH_MAX, "iconbar_scroll:%s", ib->view->name); - if (val == 0) - ecore_del_event_timer (buf); - else - { - ib->has_been_scrolled = 1; - ib->scroll += val; - e_iconbar_fix (ib); - ecore_add_event_timer (buf, 0.02, ib_scroll_timeout, val, ib); - } - D_RETURN; + snprintf(buf, PATH_MAX, "iconbar_scroll:%s", ib->view->name); + if (val == 0) + ecore_del_event_timer(buf); + else + { + ib->has_been_scrolled = 1; + ib->scroll += val; + e_iconbar_fix(ib); + ecore_add_event_timer(buf, 0.02, ib_scroll_timeout, val, ib); + } + D_RETURN; } static void -ib_cancel_launch_timeout (int val, void *data) +ib_cancel_launch_timeout(int val, void *data) { - E_Iconbar_Icon *ic; + E_Iconbar_Icon *ic; - D_ENTER; + D_ENTER; - ic = (E_Iconbar_Icon *) data; + ic = (E_Iconbar_Icon *) data; - if (ic->launch_id) - { - ic->launch_id = 0; - if (ic->launch_id_cb) - { - e_exec_broadcast_cb_del (ic->launch_id_cb); - ic->launch_id_cb = NULL; - } - evas_set_color (ic->iconbar->view->evas, ic->image, 255, 255, 255, 128); - ic->iconbar->view->changed = 1; - } - D_RETURN; - UN (val); + if (ic->launch_id) + { + ic->launch_id = 0; + if (ic->launch_id_cb) + { + e_exec_broadcast_cb_del(ic->launch_id_cb); + ic->launch_id_cb = NULL; + } + evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 128); + ic->iconbar->view->changed = 1; + } + D_RETURN; + UN(val); } /* this timeout is responsible for doing the mouse over animation */ static void -ib_timeout (int val, void *data) +ib_timeout(int val, void *data) { - E_Iconbar_Icon *ic; - double t; + E_Iconbar_Icon *ic; + double t; - D_ENTER; + D_ENTER; - /* get the iconbar icon we are dealign with */ - ic = (E_Iconbar_Icon *) data; - /* val <= 0 AND we're hilited ? first call as a timeout handler. */ - if ((val <= 0) && (ic->hilited)) - { - /* note the "start" time */ - ic->hi.start = ecore_get_time (); - /* no hilite (animation) image */ - if (!ic->hi.image) - { - char buf[PATH_MAX]; + /* get the iconbar icon we are dealign with */ + ic = (E_Iconbar_Icon *) data; + /* val <= 0 AND we're hilited ? first call as a timeout handler. */ + if ((val <= 0) && (ic->hilited)) + { + /* note the "start" time */ + ic->hi.start = ecore_get_time(); + /* no hilite (animation) image */ + if (!ic->hi.image) + { + char buf[PATH_MAX]; - /* figure out its path */ - snprintf (buf, PATH_MAX, "%s/.e_iconbar.db:%s", - ic->iconbar->view->model->dir, ic->image_path); - /* add it */ - ic->hi.image = evas_add_image_from_file (ic->iconbar->view->evas, - buf); - /* put it high up */ - evas_set_layer (ic->iconbar->view->evas, ic->hi.image, 20000); - /* dont allow it to capture any events (enter, leave etc. */ - evas_set_pass_events (ic->iconbar->view->evas, ic->hi.image, 1); - /* show it */ - evas_show (ic->iconbar->view->evas, ic->hi.image); - } - /* start at 0 */ - val = 0; - } - /* what time is it ? */ - t = ecore_get_time (); - if (ic->launch_id) - { - evas_set_color (ic->iconbar->view->evas, ic->image, 255, 255, 255, 50); - if (ic->hi.image) - evas_set_color (ic->iconbar->view->evas, ic->hi.image, 255, 255, 255, - 0); - } - /* if the icon is hilited */ - else if (ic->hilited) - { - double x, y, w, h; - double nw, nh, tt; - int a; - double speed; + /* figure out its path */ + snprintf(buf, PATH_MAX, "%s/.e_iconbar.db:%s", + ic->iconbar->view->model->dir, ic->image_path); + /* add it */ + ic->hi.image = evas_add_image_from_file(ic->iconbar->view->evas, + buf); + /* put it high up */ + evas_set_layer(ic->iconbar->view->evas, ic->hi.image, 20000); + /* dont allow it to capture any events (enter, leave etc. */ + evas_set_pass_events(ic->iconbar->view->evas, ic->hi.image, 1); + /* show it */ + evas_show(ic->iconbar->view->evas, ic->hi.image); + } + /* start at 0 */ + val = 0; + } + /* what time is it ? */ + t = ecore_get_time(); + if (ic->launch_id) + { + evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 50); + if (ic->hi.image) + evas_set_color(ic->iconbar->view->evas, ic->hi.image, 255, 255, 255, + 0); + } + /* if the icon is hilited */ + else if (ic->hilited) + { + double x, y, w, h; + double nw, nh, tt; + int a; + double speed; - /* find out where the original icon image is */ - evas_get_geometry (ic->iconbar->view->evas, ic->image, &x, &y, &w, &h); - /* tt is the time since we started */ - tt = t - ic->hi.start; - /* the speed to run at - the less, the faster (ie a loop is 0.5 sec) */ - speed = 0.5; - /* if we are beyond the time loop.. reset the start time to now */ - if (tt > speed) - ic->hi.start = t; - /* limit time to max loop time */ - if (tt > speed) - tt = speed; - /* calculate alpha to be invers of time sizne loop start */ - a = (int) (255.0 * (speed - tt)); - /* size is icon size + how far in loop we are */ - nw = w * ((tt / speed) + 1.0); - nh = h * ((tt / speed) + 1.0); - /* move the hilite icon to a good spot */ - evas_move (ic->iconbar->view->evas, ic->hi.image, - x + ((w - nw) / 2), y + ((h - nh) / 2)); - /* resize it */ - evas_resize (ic->iconbar->view->evas, ic->hi.image, nw, nh); - /* reset its fill so ti fills its space */ - evas_set_image_fill (ic->iconbar->view->evas, ic->hi.image, 0, 0, nw, - nh); - /* set its fade */ - evas_set_color (ic->iconbar->view->evas, ic->hi.image, 255, 255, 255, - a); - /* incirment our count */ - val++; - } - /* if it snot hilited */ - else - { - double tt; - int a; - double speed; + /* find out where the original icon image is */ + evas_get_geometry(ic->iconbar->view->evas, ic->image, &x, &y, &w, &h); + /* tt is the time since we started */ + tt = t - ic->hi.start; + /* the speed to run at - the less, the faster (ie a loop is 0.5 sec) */ + speed = 0.5; + /* if we are beyond the time loop.. reset the start time to now */ + if (tt > speed) + ic->hi.start = t; + /* limit time to max loop time */ + if (tt > speed) + tt = speed; + /* calculate alpha to be invers of time sizne loop start */ + a = (int)(255.0 * (speed - tt)); + /* size is icon size + how far in loop we are */ + nw = w * ((tt / speed) + 1.0); + nh = h * ((tt / speed) + 1.0); + /* move the hilite icon to a good spot */ + evas_move(ic->iconbar->view->evas, ic->hi.image, + x + ((w - nw) / 2), y + ((h - nh) / 2)); + /* resize it */ + evas_resize(ic->iconbar->view->evas, ic->hi.image, nw, nh); + /* reset its fill so ti fills its space */ + evas_set_image_fill(ic->iconbar->view->evas, ic->hi.image, 0, 0, nw, + nh); + /* set its fade */ + evas_set_color(ic->iconbar->view->evas, ic->hi.image, 255, 255, 255, a); + /* incirment our count */ + val++; + } + /* if it snot hilited */ + else + { + double tt; + int a; + double speed; - /* delete the animation object */ - if (ic->hi.image) - evas_del_object (ic->iconbar->view->evas, ic->hi.image); - ic->hi.image = NULL; + /* delete the animation object */ + if (ic->hi.image) + evas_del_object(ic->iconbar->view->evas, ic->hi.image); + ic->hi.image = NULL; - /* if we were pulsating.. reset start timer */ - if (val > 0) - { - ic->hi.start = t; - /* val back to 0 */ - val = 0; - } - /* speed of the ramp */ - speed = 1.0; - /* position on the fade out */ - tt = (t - ic->hi.start) / speed; - if (tt > 1.0) - tt = 1.0; - /* alpha value caluclated on ramp position */ - a = (int) ((double) ((1.0 - tt) * 127.0) + 128.0); - /* set alpha value */ - evas_set_color (ic->iconbar->view->evas, ic->image, 255, 255, 255, a); - /* time is at end of ramp.. kill timer */ - if (tt == 1.0) - { - /* free the timer name string */ - IF_FREE (ic->hi.timer); - ic->hi.timer = NULL; - } - /* decrement count */ - val--; - } - /* if we have a timer name.. rerun the timer in 0.05 */ - if (ic->hi.timer) - ecore_add_event_timer (ic->hi.timer, 0.05, ib_timeout, val, data); - /* flag the view that we changed */ - ic->iconbar->view->changed = 1; + /* if we were pulsating.. reset start timer */ + if (val > 0) + { + ic->hi.start = t; + /* val back to 0 */ + val = 0; + } + /* speed of the ramp */ + speed = 1.0; + /* position on the fade out */ + tt = (t - ic->hi.start) / speed; + if (tt > 1.0) + tt = 1.0; + /* alpha value caluclated on ramp position */ + a = (int)((double)((1.0 - tt) * 127.0) + 128.0); + /* set alpha value */ + evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, a); + /* time is at end of ramp.. kill timer */ + if (tt == 1.0) + { + /* free the timer name string */ + IF_FREE(ic->hi.timer); + ic->hi.timer = NULL; + } + /* decrement count */ + val--; + } + /* if we have a timer name.. rerun the timer in 0.05 */ + if (ic->hi.timer) + ecore_add_event_timer(ic->hi.timer, 0.05, ib_timeout, val, data); + /* flag the view that we changed */ + ic->iconbar->view->changed = 1; - D_RETURN; + D_RETURN; } /* called when an ebits object bit needs to be shown */ static void -ib_bits_show (void *data) +ib_bits_show(void *data) { - E_Iconbar *ib; - Evas_List l; + E_Iconbar *ib; + Evas_List l; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - /* show all the icons */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; + ib = (E_Iconbar *) data; + /* show all the icons */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; - ic = l->data; - evas_show (ic->iconbar->view->evas, ic->image); - } + ic = l->data; + evas_show(ic->iconbar->view->evas, ic->image); + } - D_RETURN; + D_RETURN; } /* called when an ebit object bit needs to hide */ static void -ib_bits_hide (void *data) +ib_bits_hide(void *data) { - E_Iconbar *ib; - Evas_List l; + E_Iconbar *ib; + Evas_List l; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - /* hide all the icons */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; + ib = (E_Iconbar *) data; + /* hide all the icons */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; - ic = l->data; - evas_hide (ic->iconbar->view->evas, ic->image); - } + ic = l->data; + evas_hide(ic->iconbar->view->evas, ic->image); + } - D_RETURN; + D_RETURN; } /* called when an ebit objetc bit needs to move */ static void -ib_bits_move (void *data, double x, double y) +ib_bits_move(void *data, double x, double y) { - E_Iconbar *ib; - Evas_List l; + E_Iconbar *ib; + Evas_List l; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - /* dont do anything.. just record the geometry. we'll deal with it later */ - ib->icon_area.x = x; - ib->icon_area.y = y; + ib = (E_Iconbar *) data; + /* dont do anything.. just record the geometry. we'll deal with it later */ + ib->icon_area.x = x; + ib->icon_area.y = y; - D_RETURN; - UN (l); + D_RETURN; + UN(l); } /* called when an ebit object bit needs to resize */ static void -ib_bits_resize (void *data, double w, double h) +ib_bits_resize(void *data, double w, double h) { - E_Iconbar *ib; - Evas_List l; + E_Iconbar *ib; + Evas_List l; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - /* dont do anything.. just record the geometry. we'll deal with it later */ - ib->icon_area.w = w; - ib->icon_area.h = h; + ib = (E_Iconbar *) data; + /* dont do anything.. just record the geometry. we'll deal with it later */ + ib->icon_area.w = w; + ib->icon_area.h = h; - D_RETURN; - UN (l); + D_RETURN; + UN(l); } /* called when the ebits object bit needs to be raised */ static void -ib_bits_raise (void *data) +ib_bits_raise(void *data) { - E_Iconbar *ib; - Evas_List l; + E_Iconbar *ib; + Evas_List l; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - /* raise all the icons */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; + ib = (E_Iconbar *) data; + /* raise all the icons */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; - ic = l->data; - evas_raise (ic->iconbar->view->evas, ic->image); - } + ic = l->data; + evas_raise(ic->iconbar->view->evas, ic->image); + } - D_RETURN; + D_RETURN; } /* called when the ebits object bit needs to be lowered */ static void -ib_bits_lower (void *data) +ib_bits_lower(void *data) { - E_Iconbar *ib; - Evas_List l; + E_Iconbar *ib; + Evas_List l; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - /* lower all the icons */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; + ib = (E_Iconbar *) data; + /* lower all the icons */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; - ic = l->data; - evas_lower (ic->iconbar->view->evas, ic->image); - } + ic = l->data; + evas_lower(ic->iconbar->view->evas, ic->image); + } - D_RETURN; + D_RETURN; } /* called when the ebits object bit needs to change layers */ static void -ib_bits_set_layer (void *data, int lay) +ib_bits_set_layer(void *data, int lay) { - E_Iconbar *ib; - Evas_List l; + E_Iconbar *ib; + Evas_List l; - D_ENTER; + D_ENTER; - ib = (E_Iconbar *) data; - /* set the layer for all the icons */ - for (l = ib->icons; l; l = l->next) - { - E_Iconbar_Icon *ic; + ib = (E_Iconbar *) data; + /* set the layer for all the icons */ + for (l = ib->icons; l; l = l->next) + { + E_Iconbar_Icon *ic; - ic = l->data; - evas_set_layer (ic->iconbar->view->evas, ic->image, lay); - } + ic = l->data; + evas_set_layer(ic->iconbar->view->evas, ic->image, lay); + } - D_RETURN; + D_RETURN; } /* not used... err.. ebits clips for us to the maximum allowed space of */ /* the ebit object bit - dont know why i have this here */ static void -ib_bits_set_clip (void *data, Evas_Object clip) +ib_bits_set_clip(void *data, Evas_Object clip) { - D_ENTER; + D_ENTER; - - D_RETURN; - UN (data); - UN (clip); + D_RETURN; + UN(data); + UN(clip); } /* we arent going to recolor our icons here according to color class */ static void -ib_bits_set_color_class (void *data, char *cc, int r, int g, int b, int a) +ib_bits_set_color_class(void *data, char *cc, int r, int g, int b, int a) { - D_ENTER; + D_ENTER; - - D_RETURN; - UN (data); - UN (cc); - UN (r); - UN (g); - UN (b); - UN (a); + D_RETURN; + UN(data); + UN(cc); + UN(r); + UN(g); + UN(b); + UN(a); } /* our minimum size for icon space is 0x0 */ static void -ib_bits_get_min_size (void *data, double *w, double *h) +ib_bits_get_min_size(void *data, double *w, double *h) { - D_ENTER; + D_ENTER; - *w = 0; - *h = 0; + *w = 0; + *h = 0; - D_RETURN; - UN (data); + D_RETURN; + UN(data); } /* our maximum is huge */ static void -ib_bits_get_max_size (void *data, double *w, double *h) +ib_bits_get_max_size(void *data, double *w, double *h) { - D_ENTER; + D_ENTER; - *w = 999999; - *h = 999999; + *w = 999999; + *h = 999999; - D_RETURN; - UN (data); + D_RETURN; + UN(data); } - - - - /* called on events on icons */ /* called when a mouse goes in on an icon object */ static void -ib_mouse_in (void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) +ib_mouse_in(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Iconbar_Icon *ic; + E_Iconbar_Icon *ic; - D_ENTER; + D_ENTER; - /* get he iconbaricon pointer from the data member */ - ic = (E_Iconbar_Icon *) data; - /* set hilited flag */ - ic->hilited = 1; - /* make it more opaque */ - evas_set_color (ic->iconbar->view->evas, ic->image, 255, 255, 255, 255); - /* if we havent started an animation timer - start one */ - if (!ic->hi.timer) - { - char buf[PATH_MAX]; + /* get he iconbaricon pointer from the data member */ + ic = (E_Iconbar_Icon *) data; + /* set hilited flag */ + ic->hilited = 1; + /* make it more opaque */ + evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 255); + /* if we havent started an animation timer - start one */ + if (!ic->hi.timer) + { + char buf[PATH_MAX]; - /* come up with a unique name for it */ - snprintf (buf, PATH_MAX, "iconbar:%s/%s", ic->iconbar->view->name, - ic->image_path); - e_strdup (ic->hi.timer, buf); - /* call the timeout */ - ib_timeout (0, ic); - } - /* tell the view the iconbar is in.. something changed that might mean */ - /* a redraw is needed */ - ic->iconbar->view->changed = 1; + /* come up with a unique name for it */ + snprintf(buf, PATH_MAX, "iconbar:%s/%s", ic->iconbar->view->name, + ic->image_path); + e_strdup(ic->hi.timer, buf); + /* call the timeout */ + ib_timeout(0, ic); + } + /* tell the view the iconbar is in.. something changed that might mean */ + /* a redraw is needed */ + ic->iconbar->view->changed = 1; - - D_RETURN; - UN (_e); - UN (_o); - UN (_b); - UN (_x); - UN (_y); + D_RETURN; + UN(_e); + UN(_o); + UN(_b); + UN(_x); + UN(_y); } /* called when a mouse goes out of an icon object */ static void -ib_mouse_out (void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) +ib_mouse_out(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Iconbar_Icon *ic; + E_Iconbar_Icon *ic; - D_ENTER; + D_ENTER; - /* get he iconbaricon pointer from the data member */ - ic = (E_Iconbar_Icon *) data; - /* unset hilited flag */ - ic->hilited = 0; - /* tell the view the iconbar is in.. something changed that might mean */ - /* a redraw is needed */ - ic->iconbar->view->changed = 1; + /* get he iconbaricon pointer from the data member */ + ic = (E_Iconbar_Icon *) data; + /* unset hilited flag */ + ic->hilited = 0; + /* tell the view the iconbar is in.. something changed that might mean */ + /* a redraw is needed */ + ic->iconbar->view->changed = 1; - D_RETURN; - UN (_e); - UN (_o); - UN (_b); - UN (_x); - UN (_y); + D_RETURN; + UN(_e); + UN(_o); + UN(_b); + UN(_x); + UN(_y); } /* called when the mouse goes up on an icon object */ static void -ib_mouse_up (void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) +ib_mouse_up(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Iconbar_Icon *ic; + E_Iconbar_Icon *ic; - D_ENTER; + D_ENTER; - /* get he iconbaricon pointer from the data member */ - ic = (E_Iconbar_Icon *) data; + /* get he iconbaricon pointer from the data member */ + ic = (E_Iconbar_Icon *) data; - ic->mouse_down = 0; - /* if we are moving the icon */ - if (ic->moving) - { - ic->moving = 0; + ic->mouse_down = 0; + /* if we are moving the icon */ + if (ic->moving) + { + ic->moving = 0; - e_iconbar_icon_move (ic, _x, _y); - } + e_iconbar_icon_move(ic, _x, _y); + } - /* Otherwise, not moving so execute, etc */ - else - { - /* if we're busy launching something.. dont run anything */ - if (ic->launch_id) - D_RETURN; - /* run something! */ - if (ic->exec) - { - if (!ic->wait) - { - if (e_exec_run (ic->exec) < 0) - { - /* FIXME: display error */ - } - } - else - { - int id_ret = 0; - - ic->launch_pid = - e_exec_in_dir_with_env (ic->exec, e_util_get_user_home (), - &id_ret, NULL, NULL); - if (ic->launch_pid >= 0) - { - ic->launch_id = id_ret; - if (id_ret > 0) + /* Otherwise, not moving so execute, etc */ + else + { + /* if we're busy launching something.. dont run anything */ + if (ic->launch_id) + D_RETURN; + /* run something! */ + if (ic->exec) + { + if (!ic->wait) + { + if (e_exec_run(ic->exec) < 0) { - char buf[PATH_MAX]; - - ic->launch_id_cb = - e_exec_broadcast_cb_add (e_iconbar_handle_launch_id, - ic); - snprintf (buf, PATH_MAX, "iconbar_launch_wait:%i", - ic->launch_id); - if (ic->wait_timeout > 0.0) - ecore_add_event_timer (buf, ic->wait_timeout, - ib_cancel_launch_timeout, - ic->launch_id, ic); - else - ecore_add_event_timer (buf, 15.0, - ib_cancel_launch_timeout, - ic->launch_id, ic); - evas_set_color (ic->iconbar->view->evas, ic->image, - 255, 255, 255, 50); - if (ic->hi.image) - evas_set_color (ic->iconbar->view->evas, ic->hi.image, - 255, 255, 255, 0); + /* FIXME: display error */ } - } - } - } - } + } + else + { + int id_ret = 0; - D_RETURN; - UN (_e); - UN (_o); - UN (_b); - UN (_x); - UN (_y); + ic->launch_pid = + e_exec_in_dir_with_env(ic->exec, e_util_get_user_home(), + &id_ret, NULL, NULL); + if (ic->launch_pid >= 0) + { + ic->launch_id = id_ret; + if (id_ret > 0) + { + char buf[PATH_MAX]; + + ic->launch_id_cb = + e_exec_broadcast_cb_add + (e_iconbar_handle_launch_id, ic); + snprintf(buf, PATH_MAX, "iconbar_launch_wait:%i", + ic->launch_id); + if (ic->wait_timeout > 0.0) + ecore_add_event_timer(buf, ic->wait_timeout, + ib_cancel_launch_timeout, + ic->launch_id, ic); + else + ecore_add_event_timer(buf, 15.0, + ib_cancel_launch_timeout, + ic->launch_id, ic); + evas_set_color(ic->iconbar->view->evas, ic->image, + 255, 255, 255, 50); + if (ic->hi.image) + evas_set_color(ic->iconbar->view->evas, + ic->hi.image, 255, 255, 255, 0); + } + } + } + } + } + + D_RETURN; + UN(_e); + UN(_o); + UN(_b); + UN(_x); + UN(_y); } /* called when the mouse goes down on an icon object */ static void -ib_mouse_down (void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) +ib_mouse_down(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Iconbar_Icon *ic; + E_Iconbar_Icon *ic; - D_ENTER; + D_ENTER; - ic = (E_Iconbar_Icon *) data; + ic = (E_Iconbar_Icon *) data; - ic->down.x = _x; - ic->down.y = _y; + ic->down.x = _x; + ic->down.y = _y; - ic->mouse_down = _b; + ic->mouse_down = _b; - D_RETURN; - UN (data); - UN (_e); - UN (_o); - UN (_b); - UN (_x); - UN (_y); + D_RETURN; + UN(data); + UN(_e); + UN(_o); + UN(_b); + UN(_x); + UN(_y); } /* called when a mouse goes out of an icon object */ static void -ib_mouse_move (void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) +ib_mouse_move(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Iconbar_Icon *ic; + E_Iconbar_Icon *ic; - D_ENTER; + D_ENTER; - /* get he iconbaricon pointer from the data member */ - ic = (E_Iconbar_Icon *) data; + /* get he iconbaricon pointer from the data member */ + ic = (E_Iconbar_Icon *) data; - if (ic->mouse_down) - { - int dx, dy; + if (ic->mouse_down) + { + int dx, dy; + ic->mouse.x = _x; + ic->mouse.y = _y; - ic->mouse.x = _x; - ic->mouse.y = _y; + dx = ic->down.x - ic->mouse.x; + dy = ic->down.y - ic->mouse.y; - dx = ic->down.x - ic->mouse.x; - dy = ic->down.y - ic->mouse.y; + if (dx > 3 || dx < -3 || dy > 3 || dy < -3) + { + ic->moving = 1; + evas_move(ic->iconbar->view->evas, ic->image, + ic->mouse.x - (ic->down.x - ic->current.x), + ic->mouse.y - (ic->down.y - ic->current.y)); + } - if (dx > 3 || dx < -3 || dy > 3 || dy < -3) - { - ic->moving = 1; + } - evas_move (ic->iconbar->view->evas, ic->image, - ic->mouse.x - (ic->down.x - ic->current.x), - ic->mouse.y - (ic->down.y - ic->current.y)); - } - - } - - D_RETURN; - UN (data); - UN (_e); - UN (_o); - UN (_b); - UN (_x); - UN (_y); + D_RETURN; + UN(data); + UN(_e); + UN(_o); + UN(_b); + UN(_x); + UN(_y); } - void -e_iconbar_icon_move (E_Iconbar_Icon *ic, int x, int y) +e_iconbar_icon_move(E_Iconbar_Icon * ic, int x, int y) { D_ENTER; D("in icon move\n"); - /* if dragged outside remove from list */ - if (x > ic->iconbar->icon_area.x + ic->iconbar->icon_area.w || - y > ic->iconbar->icon_area.y + ic->iconbar->icon_area.h) - { - evas_list_remove (ic->iconbar->icons, ic); + /* if dragged outside remove from list */ + if (x > ic->iconbar->icon_area.x + ic->iconbar->icon_area.w || + y > ic->iconbar->icon_area.y + ic->iconbar->icon_area.h) + { + evas_list_remove(ic->iconbar->icons, ic); - /* make the changes */ - e_iconbar_fix (ic->iconbar); + /* make the changes */ + e_iconbar_fix(ic->iconbar); - /* set flag and save */ - ic->iconbar->changed = 1; - e_iconbar_save_out_final(ic->iconbar); + /* set flag and save */ + ic->iconbar->changed = 1; + e_iconbar_save_out_final(ic->iconbar); - e_object_unref (E_OBJECT (ic)); - } + e_object_unref(E_OBJECT(ic)); + } - /* otherwise move to the correct place in list */ - else - { - E_Iconbar_Icon *lic; - Evas_List l; + /* otherwise move to the correct place in list */ + else + { + E_Iconbar_Icon *lic; + Evas_List l; - double aw = ic->iconbar->icon_area.w; - double ah = ic->iconbar->icon_area.h; + double aw = ic->iconbar->icon_area.w; + double ah = ic->iconbar->icon_area.h; - /* before first icon? move to start */ - lic = (E_Iconbar_Icon *) ic->iconbar->icons->data; - /* horizontal */ - if (aw > ah && x < lic->current.x) - { - ic->iconbar->icons = evas_list_remove (ic->iconbar->icons, ic); - ic->iconbar->icons = - evas_list_prepend_relative (ic->iconbar->icons, ic, lic); - } - /* vertical */ - else if (aw < ah && y < lic->current.y) - { - ic->iconbar->icons = evas_list_remove (ic->iconbar->icons, ic); - ic->iconbar->icons = - evas_list_prepend_relative (ic->iconbar->icons, ic, lic); - } + /* before first icon? move to start */ + lic = (E_Iconbar_Icon *) ic->iconbar->icons->data; + /* horizontal */ + if (aw > ah && x < lic->current.x) + { + ic->iconbar->icons = evas_list_remove(ic->iconbar->icons, ic); + ic->iconbar->icons = + evas_list_prepend_relative(ic->iconbar->icons, ic, lic); + } + /* vertical */ + else if (aw < ah && y < lic->current.y) + { + ic->iconbar->icons = evas_list_remove(ic->iconbar->icons, ic); + ic->iconbar->icons = + evas_list_prepend_relative(ic->iconbar->icons, ic, lic); + } - /* not before first icon, check place among other icons */ - else - { - for (l = ic->iconbar->icons; l; l = l->next) - { - lic = (E_Iconbar_Icon *) l->data; + /* not before first icon, check place among other icons */ + else + { + for (l = ic->iconbar->icons; l; l = l->next) + { + lic = (E_Iconbar_Icon *) l->data; - /* if in same position, skip */ - if (ic == lic) - { - l = l->next; - if (l) - lic = (E_Iconbar_Icon *) l->data; + /* if in same position, skip */ + if (ic == lic) + { + l = l->next; + if (l) + lic = (E_Iconbar_Icon *) l->data; + else + break; + } + /* horizontal */ + if (aw > ah) + { + /* place before icon */ + if (x > lic->current.x && + x < lic->current.x + (lic->current.w / 2)) + { + ic->iconbar->icons = + evas_list_remove(ic->iconbar->icons, ic); + ic->iconbar->icons = + evas_list_prepend_relative(ic->iconbar->icons, + ic, lic); + } + /* place after icon */ + else if (x < lic->current.x + lic->current.w + && x > lic->current.x + (lic->current.w / 2)) + { + ic->iconbar->icons = + evas_list_remove(ic->iconbar->icons, ic); + ic->iconbar->icons = + evas_list_append_relative(ic->iconbar->icons, ic, + lic); + } + /* after last icon */ + else if (x > lic->current.x + lic->current.w + && l->next == NULL) + { + ic->iconbar->icons = + evas_list_remove(ic->iconbar->icons, ic); + ic->iconbar->icons = + evas_list_append_relative(ic->iconbar->icons, ic, + lic); + } + + } + /* vertical */ else - break; - } - /* horizontal */ - if (aw > ah) - { - /* place before icon */ - if (x > lic->current.x && - x < lic->current.x + (lic->current.w / 2)) { - ic->iconbar->icons = - evas_list_remove (ic->iconbar->icons, ic); - ic->iconbar->icons = - evas_list_prepend_relative (ic->iconbar->icons, - ic, lic); - } - /* place after icon */ - else if (x < lic->current.x + lic->current.w - && x > - lic->current.x + (lic->current.w / 2)) - { - ic->iconbar->icons = - evas_list_remove (ic->iconbar->icons, ic); - ic->iconbar->icons = - evas_list_append_relative (ic->iconbar->icons, ic, - lic); - } - /* after last icon */ - else if (x > lic->current.x + lic->current.w - && l->next == NULL) - { - ic->iconbar->icons = - evas_list_remove (ic->iconbar->icons, ic); - ic->iconbar->icons = - evas_list_append_relative (ic->iconbar->icons, ic, - lic); + /* place before icon */ + if (y > lic->current.y && + y < lic->current.y + (lic->current.h / 2)) + { + ic->iconbar->icons = + evas_list_remove(ic->iconbar->icons, ic); + ic->iconbar->icons = + evas_list_prepend_relative(ic->iconbar->icons, + ic, lic); + } + /* place after icon */ + else if (y < lic->current.y + lic->current.h + && y > lic->current.y + (lic->current.h / 2)) + { + ic->iconbar->icons = + evas_list_remove(ic->iconbar->icons, ic); + ic->iconbar->icons = + evas_list_append_relative(ic->iconbar->icons, ic, + lic); + } + /* after last icon */ + else if (y > lic->current.y + lic->current.h + && l->next == NULL) + { + ic->iconbar->icons = + evas_list_remove(ic->iconbar->icons, ic); + ic->iconbar->icons = + evas_list_append_relative(ic->iconbar->icons, ic, + lic); + } } + } + } + /* make the changes */ + e_iconbar_fix(ic->iconbar); - - } - /* vertical */ - else - { - /* place before icon */ - if (y > lic->current.y && - y < lic->current.y + (lic->current.h / 2)) - { - ic->iconbar->icons = - evas_list_remove (ic->iconbar->icons, ic); - ic->iconbar->icons = - evas_list_prepend_relative (ic->iconbar->icons, - ic, lic); - } - /* place after icon */ - else if (y < lic->current.y + lic->current.h - && y > - lic->current.y + (lic->current.h / 2)) - { - ic->iconbar->icons = - evas_list_remove (ic->iconbar->icons, ic); - ic->iconbar->icons = - evas_list_append_relative (ic->iconbar->icons, ic, - lic); - } - /* after last icon */ - else if (y > lic->current.y + lic->current.h - && l->next == NULL) - { - ic->iconbar->icons = - evas_list_remove (ic->iconbar->icons, ic); - ic->iconbar->icons = - evas_list_append_relative (ic->iconbar->icons, ic, - lic); - } - } - } - } - /* make the changes */ - e_iconbar_fix (ic->iconbar); - - /* set flag and save */ - ic->iconbar->changed = 1; - e_iconbar_save_out_final(ic->iconbar); + /* set flag and save */ + ic->iconbar->changed = 1; + e_iconbar_save_out_final(ic->iconbar); /* ic->iconbar->just_saved = 0;*/ - e_view_ib_reload(ic->iconbar->view); + e_view_ib_reload(ic->iconbar->view); - } - D_RETURN; + } + D_RETURN; } - /* called when a dnd drop occurs on an iconbar */ void -e_iconbar_dnd_add_files (E_View *v, E_View *source, int num_files, - char **dnd_files) +e_iconbar_dnd_add_files(E_View * v, E_View * source, int num_files, + char **dnd_files) { - Evas_List execs = NULL; - Evas_List l; + Evas_List execs = NULL; + Evas_List l; - int i; + int i; - D_ENTER; + D_ENTER; #if 0 - D("add files: %s\n", source->model->dir); - for (i = 0; i < num_files; i++) - { - char *file = e_file_get_file(strdup(dnd_files[i])); - E_Icon *ic = e_icon_find_by_file(source, file); - - if (ic) - { - D("icon mime.base: %s\n", ic->info.mime.base); - if (!strcmp(ic->info.mime.base, "db")) - { - /* if its an icon db, set the icon */ - D("db!\n"); - for (l = v->iconbar->icons; l; l = l->next) - { - E_Iconbar_Icon *ibic; - char buf[PATH_MAX]; + D("add files: %s\n", source->model->dir); + for (i = 0; i < num_files; i++) + { + char *file = e_file_get_file(strdup(dnd_files[i])); + E_Icon *ic = e_icon_find_by_file(source, file); - if (l->data) - ibic = (E_Iconbar_Icon *)(l->data); + if (ic) + { + D("icon mime.base: %s\n", ic->info.mime.base); + if (!strcmp(ic->info.mime.base, "db")) + { + /* if its an icon db, set the icon */ + D("db!\n"); + for (l = v->iconbar->icons; l; l = l->next) + { + E_Iconbar_Icon *ibic; + char buf[PATH_MAX]; - if (ibic) - { - if (v->iconbar->dnd.x > ibic->current.x && - v->iconbar->dnd.x < ibic->current.x + ibic->current.w && - v->iconbar->dnd.y > ibic->current.y && - v->iconbar->dnd.y < ibic->current.y + ibic->current.h ) - { - D("over icon: %s\n", ibic->exec); - snprintf(buf, PATH_MAX, "%s/%s:/icon/normal", ic->view->model->dir, ic->file); - D("set icon: %s\n", buf); + if (l->data) + ibic = (E_Iconbar_Icon *) (l->data); - ibic->imlib_image = imlib_load_image(buf); - - /* FIXME: this should be cleaner */ - ibic->iconbar->changed = 1; - e_iconbar_save_out_final (ibic->iconbar); - } - } - } - break; - } - else if (e_file_can_exec (&ic->stat)) - { - execs = evas_list_append (execs, ic); - } - } - } - for (l = execs; l; l = l->next) - { - /* add exec icons */ - E_Icon *ic; - E_Iconbar_Icon *ibic; - char buf[PATH_MAX]; + if (ibic) + { + if (v->iconbar->dnd.x > ibic->current.x && + v->iconbar->dnd.x < + ibic->current.x + ibic->current.w + && v->iconbar->dnd.y > ibic->current.y + && v->iconbar->dnd.y < + ibic->current.y + ibic->current.h) + { + D("over icon: %s\n", ibic->exec); + snprintf(buf, PATH_MAX, "%s/%s:/icon/normal", + ic->view->model->dir, ic->file); + D("set icon: %s\n", buf); - D("now add the icon\n"); + ibic->imlib_image = imlib_load_image(buf); - if (l->data) - ic = l->data; - else - D_RETURN; + /* FIXME: this should be cleaner */ + ibic->iconbar->changed = 1; + e_iconbar_save_out_final(ibic->iconbar); + } + } + } + break; + } + else if (e_file_can_exec(&ic->stat)) + { + execs = evas_list_append(execs, ic); + } + } + } + for (l = execs; l; l = l->next) + { + /* add exec icons */ + E_Icon *ic; + E_Iconbar_Icon *ibic; + char buf[PATH_MAX]; - ibic = NEW(E_Iconbar_Icon, 1); - ZERO(ibic, E_Iconbar_Icon, 1); + D("now add the icon\n"); - e_object_init (E_OBJECT (ibic), - (E_Cleanup_Func) e_iconbar_icon_cleanup); - if (v->iconbar) - ibic->iconbar = v->iconbar; - else - D("EEEEEEEEEEEEK: how the hell did this happen?"); + if (l->data) + ic = l->data; + else + D_RETURN; - D("x: %f, v-dir: %s, ib-dir: %s\n", ibic->iconbar->icon_area.x, v->model->dir, ibic->iconbar->view->model->dir); - - if (!ic->info.icon) D_RETURN; - snprintf(buf, PATH_MAX, "%s:/icon/normal", ic->info.icon); - ibic->image = evas_add_image_from_file (v->evas, buf); - ibic->imlib_image = imlib_load_image (buf); - ibic->image_path = strdup (ic->info.icon); - snprintf(buf, PATH_MAX, "%s/%s", ic->view->model->dir, ic->file); - ibic->exec = strdup(buf); + ibic = NEW(E_Iconbar_Icon, 1); + ZERO(ibic, E_Iconbar_Icon, 1); - evas_set_clip (v->evas, ibic->image, v->iconbar->clip); - evas_set_color (v->evas, ibic->image, 255, 255, 255, 128); - evas_set_layer (v->evas, ibic->image, 11000); - evas_show(v->evas, ibic->image); - evas_callback_add (v->evas, ibic->image, CALLBACK_MOUSE_IN, - ib_mouse_in, ibic); - evas_callback_add (v->evas, ibic->image, CALLBACK_MOUSE_OUT, - ib_mouse_out, ibic); - evas_callback_add (v->evas, ibic->image, CALLBACK_MOUSE_DOWN, - ib_mouse_down, ibic); - evas_callback_add (v->evas, ibic->image, CALLBACK_MOUSE_UP, - ib_mouse_up, ibic); - evas_callback_add (v->evas, ibic->image, CALLBACK_MOUSE_MOVE, - ib_mouse_move, ibic); + e_object_init(E_OBJECT(ibic), (E_Cleanup_Func) e_iconbar_icon_cleanup); + if (v->iconbar) + ibic->iconbar = v->iconbar; + else + D("EEEEEEEEEEEEK: how the hell did this happen?"); - ibic->iconbar->icons = evas_list_append(ibic->iconbar->icons, ibic); + D("x: %f, v-dir: %s, ib-dir: %s\n", ibic->iconbar->icon_area.x, + v->model->dir, ibic->iconbar->view->model->dir); - /* this adds the icon to the correct place in the list and saves */ - e_iconbar_icon_move(ibic, v->iconbar->dnd.x, v->iconbar->dnd.y); - } + if (!ic->info.icon) + D_RETURN; + snprintf(buf, PATH_MAX, "%s:/icon/normal", ic->info.icon); + ibic->image = evas_add_image_from_file(v->evas, buf); + ibic->imlib_image = imlib_load_image(buf); + ibic->image_path = strdup(ic->info.icon); + snprintf(buf, PATH_MAX, "%s/%s", ic->view->model->dir, ic->file); + ibic->exec = strdup(buf); + + evas_set_clip(v->evas, ibic->image, v->iconbar->clip); + evas_set_color(v->evas, ibic->image, 255, 255, 255, 128); + evas_set_layer(v->evas, ibic->image, 11000); + evas_show(v->evas, ibic->image); + evas_callback_add(v->evas, ibic->image, CALLBACK_MOUSE_IN, + ib_mouse_in, ibic); + evas_callback_add(v->evas, ibic->image, CALLBACK_MOUSE_OUT, + ib_mouse_out, ibic); + evas_callback_add(v->evas, ibic->image, CALLBACK_MOUSE_DOWN, + ib_mouse_down, ibic); + evas_callback_add(v->evas, ibic->image, CALLBACK_MOUSE_UP, + ib_mouse_up, ibic); + evas_callback_add(v->evas, ibic->image, CALLBACK_MOUSE_MOVE, + ib_mouse_move, ibic); + + ibic->iconbar->icons = evas_list_append(ibic->iconbar->icons, ibic); + + /* this adds the icon to the correct place in the list and saves */ + e_iconbar_icon_move(ibic, v->iconbar->dnd.x, v->iconbar->dnd.y); + } #endif } - /* called when child processes exit */ static void -ib_child_handle (Ecore_Event * ev) +ib_child_handle(Ecore_Event * ev) { - Ecore_Event_Child *e; - Evas_List l; + Ecore_Event_Child *e; + Evas_List l; - D_ENTER; + D_ENTER; - e = ev->event; - for (l = iconbars; l; l = l->next) - { - E_Iconbar *ib; - Evas_List ll; + e = ev->event; + for (l = iconbars; l; l = l->next) + { + E_Iconbar *ib; + Evas_List ll; - ib = l->data; - for (ll = ib->icons; ll; ll = ll->next) - { - E_Iconbar_Icon *ic; + ib = l->data; + for (ll = ib->icons; ll; ll = ll->next) + { + E_Iconbar_Icon *ic; - ic = ll->data; - if (ic->launch_pid == e->pid) - { - ic->launch_pid = 0; - if (ic->launch_id) - { - char buf[PATH_MAX]; + ic = ll->data; + if (ic->launch_pid == e->pid) + { + ic->launch_pid = 0; + if (ic->launch_id) + { + char buf[PATH_MAX]; - snprintf (buf, PATH_MAX, "iconbar_launch_wait:%i", - ic->launch_id); - ecore_del_event_timer (buf); - } - ic->launch_id = 0; - if (ic->launch_id_cb) - { - e_exec_broadcast_cb_del (ic->launch_id_cb); - ic->launch_id_cb = NULL; - } - evas_set_color (ic->iconbar->view->evas, ic->image, 255, - 255, 255, 128); - ic->iconbar->view->changed = 1; - D_RETURN; - } - } - } + snprintf(buf, PATH_MAX, "iconbar_launch_wait:%i", + ic->launch_id); + ecore_del_event_timer(buf); + } + ic->launch_id = 0; + if (ic->launch_id_cb) + { + e_exec_broadcast_cb_del(ic->launch_id_cb); + ic->launch_id_cb = NULL; + } + evas_set_color(ic->iconbar->view->evas, ic->image, 255, + 255, 255, 128); + ic->iconbar->view->changed = 1; + D_RETURN; + } + } + } - D_RETURN; + D_RETURN; } -E_Rect * -e_iconbar_get_resist_rect (E_Iconbar * ib) +E_Rect * +e_iconbar_get_resist_rect(E_Iconbar * ib) { - double x, y, w, h; - int resist = 32; - E_Rect *r; + double x, y, w, h; + int resist = 32; + E_Rect *r; - D_ENTER; + D_ENTER; - ebits_get_named_bit_geometry (ib->bit, "Resist", &x, &y, &w, &h); + ebits_get_named_bit_geometry(ib->bit, "Resist", &x, &y, &w, &h); - r = NEW (E_Rect, 1); - r->x = x; - r->y = y; - r->w = w; - r->h = h; - r->v1 = resist; + r = NEW(E_Rect, 1); + r->x = x; + r->y = y; + r->w = w; + r->h = h; + r->v1 = resist; - D_RETURN_ (r); + D_RETURN_(r); } void -e_iconbar_set_view_window_spacing (E_Iconbar * ib) +e_iconbar_set_view_window_spacing(E_Iconbar * ib) { - double x, y, w, h; + double x, y, w, h; - D_ENTER; + D_ENTER; - ebits_get_named_bit_geometry (ib->bit, "Resist", &x, &y, &w, &h); + ebits_get_named_bit_geometry(ib->bit, "Resist", &x, &y, &w, &h); /* FIXME Why do the v->spacing.window.?'s need to be / 2? */ - if (h > w) /* vertical */ - { - if (x < ib->view->size.w / 2) /* left */ - ib->view->spacing.window.l = (x + w) / 2 + 3; - else /* right */ - ib->view->spacing.window.r = (ib->view->size.w - x) / 2 + 15; - } - else /* horizontal */ - { - if (y < ib->view->size.h / 2) /* top */ - ib->view->spacing.window.t = (y + h) / 2 + 3; - else - ib->view->spacing.window.b = (ib->view->size.h - y) / 2 + 15; - } - D_RETURN; + if (h > w) /* vertical */ + { + if (x < ib->view->size.w / 2) /* left */ + ib->view->spacing.window.l = (x + w) / 2 + 3; + else /* right */ + ib->view->spacing.window.r = (ib->view->size.w - x) / 2 + 15; + } + else /* horizontal */ + { + if (y < ib->view->size.h / 2) /* top */ + ib->view->spacing.window.t = (y + h) / 2 + 3; + else + ib->view->spacing.window.b = (ib->view->size.h - y) / 2 + 15; + } + D_RETURN; } diff --git a/src/iconbar.h b/src/iconbar.h index d8221e0f5..9a01a6341 100644 --- a/src/iconbar.h +++ b/src/iconbar.h @@ -9,6 +9,7 @@ #include "resist.h" typedef struct _E_Iconbar_Icon E_Iconbar_Icon; + #ifndef E_ICONBAR_TYPEDEF #define E_ICONBAR_TYPEDEF typedef struct _E_Iconbar E_Iconbar; @@ -16,86 +17,96 @@ typedef struct _E_Iconbar E_Iconbar; #ifndef E_VIEW_TYPEDEF #define E_VIEW_TYPEDEF -typedef struct _E_View E_View; +typedef struct _E_View E_View; #endif struct _E_Iconbar { - E_Object o; + E_Object o; - E_View *view; - Evas_List icons; - - Evas_Object clip; - - int has_been_scrolled; - int changed; - int just_saved; - float scroll; - - Ebits_Object *bit; - struct { - double x, y, w, h; - } icon_area; + E_View *view; + Evas_List icons; - struct { - int x, y; - } dnd; + Evas_Object clip; + + int has_been_scrolled; + int changed; + int just_saved; + float scroll; + + Ebits_Object *bit; + struct + { + double x, y, w, h; + } + icon_area; + + struct + { + int x, y; + } + dnd; }; struct _E_Iconbar_Icon { - E_Object o; + E_Object o; - E_Iconbar *iconbar; - - Evas_Object image; - Imlib_Image imlib_image; - - char *image_path; - char *exec; - - int hilited; - struct { - Evas_Object image; - char *timer; - double start; - } hi; - - struct { - double x, y; - } down, mouse; - - struct { - double x, y; - double w, h; - } current; - - int mouse_down; - int moving; - - int wait; - float wait_timeout; - - pid_t launch_pid; - int launch_id; - void *launch_id_cb; + E_Iconbar *iconbar; + + Evas_Object image; + Imlib_Image imlib_image; + + char *image_path; + char *exec; + + int hilited; + struct + { + Evas_Object image; + char *timer; + double start; + } + hi; + + struct + { + double x, y; + } + down , mouse; + + struct + { + double x, y; + double w, h; + } + current; + + int mouse_down; + int moving; + + int wait; + float wait_timeout; + + pid_t launch_pid; + int launch_id; + void *launch_id_cb; }; -void e_iconbar_init(void); -E_Iconbar *e_iconbar_new(E_View *v); -void e_iconbar_icon_free(E_Iconbar_Icon *); -void e_iconbar_realize(E_Iconbar *ib); -void e_iconbar_fix(E_Iconbar *ib); -double e_iconbar_get_length(E_Iconbar *ib); -void e_iconbar_file_add(E_View *v, char *file); -void e_iconbar_file_delete(E_View *v, char *file); -void e_iconbar_file_change(E_View *v, char *file); -void e_iconbar_save_out_final(E_Iconbar *ib); -E_Rect * e_iconbar_get_resist_rect(E_Iconbar *ib); -void e_iconbar_set_view_window_spacing(E_Iconbar *ib); -void e_iconbar_icon_move(E_Iconbar_Icon *ic, int x, int y); -void e_iconbar_dnd_add_files (E_View * v, E_View * source, - int num_files, char **dnd_files); +void e_iconbar_init(void); +E_Iconbar *e_iconbar_new(E_View * v); +void e_iconbar_icon_free(E_Iconbar_Icon *); +void e_iconbar_realize(E_Iconbar * ib); +void e_iconbar_fix(E_Iconbar * ib); +double e_iconbar_get_length(E_Iconbar * ib); +void e_iconbar_file_add(E_View * v, char *file); +void e_iconbar_file_delete(E_View * v, char *file); +void e_iconbar_file_change(E_View * v, char *file); +void e_iconbar_save_out_final(E_Iconbar * ib); +E_Rect *e_iconbar_get_resist_rect(E_Iconbar * ib); +void e_iconbar_set_view_window_spacing(E_Iconbar * ib); +void e_iconbar_icon_move(E_Iconbar_Icon * ic, int x, int y); +void e_iconbar_dnd_add_files(E_View * v, E_View * source, + int num_files, char **dnd_files); #endif diff --git a/src/icons.c b/src/icons.c index b03bcf17e..a0af96db1 100644 --- a/src/icons.c +++ b/src/icons.c @@ -2,31 +2,36 @@ #include "icons.h" #include "debug.h" #include "cursors.h" -#include "file.h" +#include "file.h" #include "util.h" #include "e_view_model.h" #include "e_file.h" #include "e_view_machine.h" #include "globals.h" -static void e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); - +static void e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); static void e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Icon *ic; - Ecore_Event *ev; + E_Icon *ic; + Ecore_Event *ev; Ecore_Event_Mouse_Down *e; - + D_ENTER; - + ev = e_view_get_current_event(); - if (!ev) D_RETURN; + if (!ev) + D_RETURN; e = ev->event; ic = _data; ic->view->select.down.x = _x; @@ -45,7 +50,7 @@ e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) if (!ic->state.selected) { if ((e->mods & multi_select_mod)) - { + { e_icon_select(ic); } else @@ -72,30 +77,31 @@ e_icon_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) static void e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Icon *ic; - Ecore_Event *ev; + E_Icon *ic; + Ecore_Event *ev; Ecore_Event_Mouse_Up *e; - + D_ENTER; - + ev = e_view_get_current_event(); - if (!ev) D_RETURN; + if (!ev) + D_RETURN; e = ev->event; ic = _data; if (ic->view->drag.started) { - int x, y; - + int x, y; + ic->state.clicked = 0; ic->state.just_selected = 0; e_icon_update_state(ic); ecore_window_no_ignore(ic->view->drag.win); ecore_window_destroy(ic->view->drag.win); ic->view->drag.started = 0; - if(e->mods & ECORE_EVENT_KEY_MODIFIER_SHIFT) - ecore_dnd_set_mode_copy(); + if (e->mods & ECORE_EVENT_KEY_MODIFIER_SHIFT) + ecore_dnd_set_mode_copy(); else - ecore_dnd_set_mode_move(); + ecore_dnd_set_mode_move(); ecore_dnd_set_data(ic->view->win.base); /* FIXME: if button use is right mouse then do an ask */ @@ -104,7 +110,7 @@ e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) ecore_pointer_xy_get(&x, &y); ecore_window_dnd_handle_motion(ic->view->win.base, x, y, 0); ecore_window_dnd_finished(); - D_RETURN; + D_RETURN; } if (_b == 1) { @@ -117,7 +123,7 @@ e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) if ((e->mods & multi_select_mod)) { if ((ic->state.selected) && (!ic->state.just_selected)) - e_icon_deselect(ic); + e_icon_deselect(ic); } else { @@ -140,10 +146,10 @@ e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) static void e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Icon *ic; - + E_Icon *ic; + D_ENTER; - + ic = _data; e_cursors_display_in_window(ic->view->win.main, "View_Icon"); @@ -158,8 +164,8 @@ e_icon_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) static void e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Icon *ic; - + E_Icon *ic; + ic = _data; e_cursors_display_in_window(ic->view->win.main, "View"); @@ -172,137 +178,139 @@ e_icon_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) } static void -_paint_selected_icons_onto_drag_window(E_View *v, Imlib_Image im, int wx, int wy) +_paint_selected_icons_onto_drag_window(E_View * v, Imlib_Image im, int wx, + int wy) { - Evas_List l; + Evas_List l; + D_ENTER; - if (!v || !im || v->select.count <= 0) + if (!v || !im || v->select.count <= 0) D_RETURN; - + /* paint all selected icons onto the invisible drag window */ for (l = v->icons; l; l = l->next) - { - double ix, iy; - int icx, icy; - Imlib_Image im2; - char icon[PATH_MAX]; - E_Icon *ic; + { + double ix, iy; + int icx, icy; + Imlib_Image im2; + char icon[PATH_MAX]; + E_Icon *ic; - ic = l->data; - if (!ic->state.selected) - continue; + ic = l->data; + if (!ic->state.selected) + continue; - evas_get_geometry(ic->view->evas, - ic->obj.icon, - &ix, &iy, NULL, NULL); - icx = ix + v->location.x - wx; - icy = iy + v->location.y - wy; - if (!ic->file->info.icon) - { - D("EEEEEEEEEEK %s has no icon\n", ic->file->file); - D_RETURN; - } - if (ic->state.clicked) - { - snprintf(icon, PATH_MAX, "%s:/icon/clicked", ic->file->info.icon); - } - else if (ic->state.selected) - { - snprintf(icon, PATH_MAX, "%s:/icon/selected", ic->file->info.icon); - } - else - { - snprintf(icon, PATH_MAX, "%s:/icon/normal", ic->file->info.icon); - } - im2 = imlib_load_image(icon); - if (im2) - { - int iw, ih; + evas_get_geometry(ic->view->evas, ic->obj.icon, &ix, &iy, NULL, NULL); + icx = ix + v->location.x - wx; + icy = iy + v->location.y - wy; + if (!ic->file->info.icon) + { + D("EEEEEEEEEEK %s has no icon\n", ic->file->file); + D_RETURN; + } + if (ic->state.clicked) + { + snprintf(icon, PATH_MAX, "%s:/icon/clicked", ic->file->info.icon); + } + else if (ic->state.selected) + { + snprintf(icon, PATH_MAX, "%s:/icon/selected", ic->file->info.icon); + } + else + { + snprintf(icon, PATH_MAX, "%s:/icon/normal", ic->file->info.icon); + } + im2 = imlib_load_image(icon); + if (im2) + { + int iw, ih; - imlib_context_set_image(im2); - iw = imlib_image_get_width(); - ih = imlib_image_get_height(); - imlib_context_set_image(im); - imlib_blend_image_onto_image(im2, 1, - 0, 0, iw, ih, - icx, icy, iw, ih); - imlib_context_set_image(im2); - imlib_free_image(); - imlib_context_set_image(im); - } - else - { - D("eek cant load\n"); - } - } + imlib_context_set_image(im2); + iw = imlib_image_get_width(); + ih = imlib_image_get_height(); + imlib_context_set_image(im); + imlib_blend_image_onto_image(im2, 1, + 0, 0, iw, ih, icx, icy, iw, ih); + imlib_context_set_image(im2); + imlib_free_image(); + imlib_context_set_image(im); + } + else + { + D("eek cant load\n"); + } + } D_RETURN; } - - static void -_start_drag(E_View *v, int _x, int _y) +_start_drag(E_View * v, int _x, int _y) { - Pixmap pmap, mask; - Evas_List l; - int x, y, xx, yy, rw, rh, downx, downy, wx, wy, ww, wh; - int dx, dy; + Pixmap pmap, mask; + Evas_List l; + int x, y, xx, yy, rw, rh, downx, downy, wx, wy, ww, wh; + int dx, dy; - if (!v) D_RETURN; + if (!v) + D_RETURN; dx = abs(v->select.down.x - _x); dy = abs(v->select.down.y - _y); /* drag treshold */ if ((dx < 3) && (dy < 3)) D_RETURN; - + /* find extents of icons to be dragged */ x = y = xx = yy = 999999999; D("sel count %i\n", v->select.count); if (v->select.count > 0) - { - for (l = v->icons; l; l = l->next) - { - E_Icon *ic; + { + for (l = v->icons; l; l = l->next) + { + E_Icon *ic; - ic = l->data; - if (ic->state.selected) - { - int ix, iy, iw, ih; + ic = l->data; + if (ic->state.selected) + { + int ix, iy, iw, ih; - ix = ic->view->scroll.x + ic->geom.x + v->location.x; - iy = ic->view->scroll.y + ic->geom.y + v->location.y; - iw = ic->geom.w; - ih = ic->geom.h; - if (ix < x) x = ix; - if (iy < y) y = iy; - if ((ix + iw) > xx) xx = ix + iw; - if ((iy + ih) > yy) yy = iy + ih; - } - } - } + ix = ic->view->scroll.x + ic->geom.x + v->location.x; + iy = ic->view->scroll.y + ic->geom.y + v->location.y; + iw = ic->geom.w; + ih = ic->geom.h; + if (ix < x) + x = ix; + if (iy < y) + y = iy; + if ((ix + iw) > xx) + xx = ix + iw; + if ((iy + ih) > yy) + yy = iy + ih; + } + } + } ecore_window_get_geometry(0, NULL, NULL, &rw, &rh); downx = v->select.down.x + v->location.x; downy = v->select.down.y + v->location.y; wx = x; ww = xx - x; - if (wx < - (rw - downx)) - { - wx = - (rw - downx); - ww -= (wx - x); - } + if (wx < -(rw - downx)) + { + wx = -(rw - downx); + ww -= (wx - x); + } if ((wx + ww) > (rw + downx)) ww = (rw + downx) - wx; wy = y; wh = yy - y; - if (wy < - (rh - downy)) - { - wy = - (rh - downy); - wh -= (wy - y); - } + if (wy < -(rh - downy)) + { + wy = -(rh - downy); + wh -= (wy - y); + } if ((wy + wh) > (rh + downy)) wh = (rh + downy) - wy; @@ -311,13 +319,14 @@ _start_drag(E_View *v, int _x, int _y) v->drag.offset.x = downx - v->drag.x; v->drag.offset.y = downy - v->drag.y; - if ((ww < 1) || (wh < 1)) D_RETURN; - + if ((ww < 1) || (wh < 1)) + D_RETURN; + v->drag.win = ecore_window_override_new(0, wx, wy, ww, wh); pmap = ecore_pixmap_new(v->drag.win, ww, wh, 0); mask = ecore_pixmap_new(v->drag.win, ww, wh, 1); { - Imlib_Image im; + Imlib_Image im; im = imlib_create_image(ww, wh); imlib_context_set_image(im); @@ -331,8 +340,10 @@ _start_drag(E_View *v, int _x, int _y) _paint_selected_icons_onto_drag_window(v, im, wx, wy); imlib_context_set_image(im); - if (ww * wh < (200 * 200)) imlib_context_set_dither_mask(1); - else imlib_context_set_dither_mask(0); + if (ww * wh < (200 * 200)) + imlib_context_set_dither_mask(1); + else + imlib_context_set_dither_mask(0); imlib_context_set_dither(1); imlib_context_set_drawable(pmap); imlib_context_set_mask(mask); @@ -361,15 +372,16 @@ _start_drag(E_View *v, int _x, int _y) static void e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Icon *ic; - Ecore_Event *ev; + E_Icon *ic; + Ecore_Event *ev; Ecore_Event_Mouse_Move *e; + D_ENTER; ev = e_view_get_current_event(); if (!ev) D_RETURN; - + e = ev->event; ic = _data; @@ -377,108 +389,111 @@ e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) D_RETURN; if (!ic->view->drag.started) - { - _start_drag(ic->view, _x, _y); - } + { + _start_drag(ic->view, _x, _y); + } else if (ic->view->drag.started) - { - int x, y; + { + int x, y; - x = _x - ic->view->drag.offset.x; - y = _y - ic->view->drag.offset.y; - ic->view->drag.x = x; - ic->view->drag.y = y; - ic->view->drag.update = 1; - ic->view->changed = 1; + x = _x - ic->view->drag.offset.x; + y = _y - ic->view->drag.offset.y; + ic->view->drag.x = x; + ic->view->drag.y = y; + ic->view->drag.update = 1; + ic->view->changed = 1; - if(e->mods & ECORE_EVENT_KEY_MODIFIER_SHIFT) - { - ecore_dnd_set_mode_copy(); - ic->view->drag.drop_mode = E_DND_COPY; - } - else - { - ecore_dnd_set_mode_move(); - ic->view->drag.drop_mode = E_DND_MOVE; - } - ecore_dnd_set_data(ic->view->win.base); + if (e->mods & ECORE_EVENT_KEY_MODIFIER_SHIFT) + { + ecore_dnd_set_mode_copy(); + ic->view->drag.drop_mode = E_DND_COPY; + } + else + { + ecore_dnd_set_mode_move(); + ic->view->drag.drop_mode = E_DND_MOVE; + } + ecore_dnd_set_data(ic->view->win.base); - /* Handle dnd motion - dragging==1 */ - ecore_pointer_xy_get(&x, &y); - ecore_window_dnd_handle_motion( ic->view->win.base, x, y, 1); - } + /* Handle dnd motion - dragging==1 */ + ecore_pointer_xy_get(&x, &y); + ecore_window_dnd_handle_motion(ic->view->win.base, x, y, 1); + } D_RETURN; UN(_e); UN(_o); UN(_b); } - static void -e_icon_cleanup(E_Icon *ic) +e_icon_cleanup(E_Icon * ic) { D_ENTER; - + /* FIXME: free stuff here! this leaks ... */ /* (think I got them all) */ if (ic->obj.event1) { - evas_del_object(ic->view->evas, ic->obj.event1); - evas_del_object(ic->view->evas, ic->obj.event2); + evas_del_object(ic->view->evas, ic->obj.event1); + evas_del_object(ic->view->evas, ic->obj.event2); } - if (ic->obj.sel.under.icon) ebits_free(ic->obj.sel.under.icon); - if (ic->obj.sel.under.text) ebits_free(ic->obj.sel.under.text); - if (ic->obj.sel.over.icon) ebits_free(ic->obj.sel.over.icon); - if (ic->obj.sel.over.text) ebits_free(ic->obj.sel.over.text); + if (ic->obj.sel.under.icon) + ebits_free(ic->obj.sel.under.icon); + if (ic->obj.sel.under.text) + ebits_free(ic->obj.sel.under.text); + if (ic->obj.sel.over.icon) + ebits_free(ic->obj.sel.over.icon); + if (ic->obj.sel.over.text) + ebits_free(ic->obj.sel.over.text); e_object_cleanup(E_OBJECT(ic)); D_RETURN; } -E_Icon * +E_Icon * e_icon_new(void) { - E_Icon *ic; - + E_Icon *ic; + D_ENTER; - + ic = NEW(E_Icon, 1); ZERO(ic, E_Icon, 1); - + e_object_init(E_OBJECT(ic), (E_Cleanup_Func) e_icon_cleanup); D_RETURN_(ic); } - - -E_Icon * -e_icon_find_by_file(E_View *view, char *file) +E_Icon * +e_icon_find_by_file(E_View * view, char *file) { - Evas_List l; - + Evas_List l; + D_ENTER; - + for (l = view->icons; l; l = l->next) { - E_Icon *ic; - + E_Icon *ic; + ic = l->data; - if ((ic) && (ic->file->file) && (file) && (!strcmp(ic->file->file, file))) + if ((ic) && (ic->file->file) && (file) + && (!strcmp(ic->file->file, file))) D_RETURN_(ic); } D_RETURN_(NULL); } void -e_icon_show(E_Icon *ic) +e_icon_show(E_Icon * ic) { D_ENTER; - if (ic->state.visible) D_RETURN; + if (ic->state.visible) + D_RETURN; ic->state.visible = 1; if (!ic->obj.event1) { @@ -486,22 +501,32 @@ e_icon_show(E_Icon *ic) ic->obj.event2 = evas_add_rectangle(ic->view->evas); evas_set_color(ic->view->evas, ic->obj.event1, 0, 0, 0, 0); evas_set_color(ic->view->evas, ic->obj.event2, 0, 0, 0, 0); - evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_DOWN, e_icon_down_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_UP, e_icon_up_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_IN, e_icon_in_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_OUT, e_icon_out_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_MOVE, e_icon_move_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_DOWN, e_icon_down_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_UP, e_icon_up_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_IN, e_icon_in_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_OUT, e_icon_out_cb, ic); - evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_MOVE, e_icon_move_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_DOWN, + e_icon_down_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_UP, + e_icon_up_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_IN, + e_icon_in_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_OUT, + e_icon_out_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event1, CALLBACK_MOUSE_MOVE, + e_icon_move_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_DOWN, + e_icon_down_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_UP, + e_icon_up_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_IN, + e_icon_in_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_OUT, + e_icon_out_cb, ic); + evas_callback_add(ic->view->evas, ic->obj.event2, CALLBACK_MOUSE_MOVE, + e_icon_move_cb, ic); } evas_set_layer(ic->view->evas, ic->obj.icon, 200); e_text_set_layer(ic->obj.text, 200); evas_set_layer(ic->view->evas, ic->obj.event1, 210); evas_set_layer(ic->view->evas, ic->obj.event2, 210); - + evas_show(ic->view->evas, ic->obj.icon); e_text_show(ic->obj.text); evas_show(ic->view->evas, ic->obj.event1); @@ -511,11 +536,12 @@ e_icon_show(E_Icon *ic) } void -e_icon_hide(E_Icon *ic) +e_icon_hide(E_Icon * ic) { D_ENTER; - - if (!ic->state.visible) D_RETURN; + + if (!ic->state.visible) + D_RETURN; ic->state.visible = 0; evas_hide(ic->view->evas, ic->obj.icon); e_text_hide(ic->obj.text); @@ -523,133 +549,154 @@ e_icon_hide(E_Icon *ic) evas_hide(ic->view->evas, ic->obj.event2); /* Hide any selection in the view */ - if(ic->obj.sel.under.icon) ebits_hide(ic->obj.sel.under.icon); - if(ic->obj.sel.under.text) ebits_hide(ic->obj.sel.under.text); - if(ic->obj.sel.over.icon) ebits_hide(ic->obj.sel.over.icon); - if(ic->obj.sel.over.text) ebits_hide(ic->obj.sel.over.text); + if (ic->obj.sel.under.icon) + ebits_hide(ic->obj.sel.under.icon); + if (ic->obj.sel.under.text) + ebits_hide(ic->obj.sel.under.text); + if (ic->obj.sel.over.icon) + ebits_hide(ic->obj.sel.over.icon); + if (ic->obj.sel.over.text) + ebits_hide(ic->obj.sel.over.text); D_RETURN; } void -e_icon_hide_delete_pending(E_Icon *ic) +e_icon_hide_delete_pending(E_Icon * ic) { D_ENTER; - - if (!ic->state.visible) D_RETURN; - if(ic->state.selected) + + if (!ic->state.visible) + D_RETURN; + if (ic->state.selected) { - if( ic->view->drag.drop_mode == E_DND_MOVE) - { - evas_hide(ic->view->evas, ic->obj.icon); - ic->state.drag_delete = 1; - } - else - /* copy... */ - { - evas_show(ic->view->evas, ic->obj.icon); - ic->state.drag_delete = 0; - } + if (ic->view->drag.drop_mode == E_DND_MOVE) + { + evas_hide(ic->view->evas, ic->obj.icon); + ic->state.drag_delete = 1; + } + else + /* copy... */ + { + evas_show(ic->view->evas, ic->obj.icon); + ic->state.drag_delete = 0; + } } D_RETURN; } void -e_icon_show_delete_end(E_Icon *ic, E_dnd_enum dnd_pending_mode) +e_icon_show_delete_end(E_Icon * ic, E_dnd_enum dnd_pending_mode) { D_ENTER; - - if (!ic->state.visible) D_RETURN; - if(ic->state.drag_delete) + + if (!ic->state.visible) + D_RETURN; + if (ic->state.drag_delete) { - if(dnd_pending_mode==E_DND_DELETED || dnd_pending_mode==E_DND_COPIED) - { - ic->state.drag_delete = 0; - if(dnd_pending_mode==E_DND_COPIED) - evas_show(ic->view->evas, ic->obj.icon); - } + if (dnd_pending_mode == E_DND_DELETED + || dnd_pending_mode == E_DND_COPIED) + { + ic->state.drag_delete = 0; + if (dnd_pending_mode == E_DND_COPIED) + evas_show(ic->view->evas, ic->obj.icon); + } } D_RETURN; } void -e_icon_apply_xy(E_Icon *ic) +e_icon_apply_xy(E_Icon * ic) { D_ENTER; - + /* these calc icon extents for: */ /* [I] */ /* Ig */ /* [txt] */ - - if (ic->geom.text.w > ic->geom.icon.w) ic->geom.w = ic->geom.text.w; - else ic->geom.w = ic->geom.icon.w; + + if (ic->geom.text.w > ic->geom.icon.w) + ic->geom.w = ic->geom.text.w; + else + ic->geom.w = ic->geom.icon.w; ic->geom.h = ic->geom.icon.h + ic->geom.text.h + ic->view->spacing.icon.g; - - evas_resize(ic->view->evas, ic->obj.event1, + + evas_resize(ic->view->evas, ic->obj.event1, ic->geom.icon.w, ic->geom.icon.h); - evas_resize(ic->view->evas, ic->obj.event2, + evas_resize(ic->view->evas, ic->obj.event2, ic->geom.text.w, ic->geom.text.h); evas_move(ic->view->evas, ic->obj.event1, - ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2), + ic->view->scroll.x + ic->geom.x + + ((ic->geom.w - ic->geom.icon.w) / 2), ic->view->scroll.y + ic->geom.y); evas_move(ic->view->evas, ic->obj.event2, - ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2), - ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g); - evas_move(ic->view->evas, ic->obj.icon, - ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2), + ic->view->scroll.x + ic->geom.x + + ((ic->geom.w - ic->geom.text.w) / 2), + ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + + ic->view->spacing.icon.g); + evas_move(ic->view->evas, ic->obj.icon, + ic->view->scroll.x + ic->geom.x + + ((ic->geom.w - ic->geom.icon.w) / 2), ic->view->scroll.y + ic->geom.y); e_text_move(ic->obj.text, - ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2), - ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g); + ic->view->scroll.x + ic->geom.x + + ((ic->geom.w - ic->geom.text.w) / 2), + ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + + ic->view->spacing.icon.g); if (ic->obj.sel.under.icon) { - int pl, pr, pt, pb; - + int pl, pr, pt, pb; + ebits_get_insets(ic->obj.sel.under.icon, &pl, &pr, &pt, &pb); - ebits_move(ic->obj.sel.under.icon, - ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2) - pl, + ebits_move(ic->obj.sel.under.icon, + ic->view->scroll.x + ic->geom.x + + ((ic->geom.w - ic->geom.icon.w) / 2) - pl, ic->view->scroll.y + ic->geom.y - pt); - ebits_resize(ic->obj.sel.under.icon, - ic->geom.icon.w + pl + pr, ic->geom.icon.h + pt + pb); + ebits_resize(ic->obj.sel.under.icon, ic->geom.icon.w + pl + pr, + ic->geom.icon.h + pt + pb); ebits_show(ic->obj.sel.under.icon); } if (ic->obj.sel.under.text) { - int pl, pr, pt, pb; - + int pl, pr, pt, pb; + ebits_get_insets(ic->obj.sel.under.text, &pl, &pr, &pt, &pb); - ebits_move(ic->obj.sel.under.text, - ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2) - pl, - ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g - pt); - ebits_resize(ic->obj.sel.under.text, - ic->geom.text.w + pl + pr, ic->geom.text.h + pt + pb); + ebits_move(ic->obj.sel.under.text, + ic->view->scroll.x + ic->geom.x + + ((ic->geom.w - ic->geom.text.w) / 2) - pl, + ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + + ic->view->spacing.icon.g - pt); + ebits_resize(ic->obj.sel.under.text, ic->geom.text.w + pl + pr, + ic->geom.text.h + pt + pb); ebits_show(ic->obj.sel.under.text); } if (ic->obj.sel.over.icon) { - int pl, pr, pt, pb; - + int pl, pr, pt, pb; + ebits_get_insets(ic->obj.sel.over.icon, &pl, &pr, &pt, &pb); - ebits_move(ic->obj.sel.over.icon, - ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.icon.w) / 2) - pl, + ebits_move(ic->obj.sel.over.icon, + ic->view->scroll.x + ic->geom.x + + ((ic->geom.w - ic->geom.icon.w) / 2) - pl, ic->view->scroll.y + ic->geom.y - pt); - ebits_resize(ic->obj.sel.over.icon, - ic->geom.icon.w + pl + pr, ic->geom.icon.h + pt + pb); + ebits_resize(ic->obj.sel.over.icon, ic->geom.icon.w + pl + pr, + ic->geom.icon.h + pt + pb); ebits_show(ic->obj.sel.over.icon); } if (ic->obj.sel.over.text) { - int pl, pr, pt, pb; - + int pl, pr, pt, pb; + ebits_get_insets(ic->obj.sel.over.text, &pl, &pr, &pt, &pb); - ebits_move(ic->obj.sel.over.text, - ic->view->scroll.x + ic->geom.x + ((ic->geom.w - ic->geom.text.w) / 2) - pl, - ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + ic->view->spacing.icon.g - pt); - ebits_resize(ic->obj.sel.over.text, - ic->geom.text.w + pl + pr, ic->geom.text.h + pt + pb); + ebits_move(ic->obj.sel.over.text, + ic->view->scroll.x + ic->geom.x + + ((ic->geom.w - ic->geom.text.w) / 2) - pl, + ic->view->scroll.y + ic->geom.y + ic->geom.icon.h + + ic->view->spacing.icon.g - pt); + ebits_resize(ic->obj.sel.over.text, ic->geom.text.w + pl + pr, + ic->geom.text.h + pt + pb); ebits_show(ic->obj.sel.over.text); } if ((ic->geom.x != ic->prev_geom.x) || (ic->geom.y != ic->prev_geom.y)) @@ -658,11 +705,15 @@ e_icon_apply_xy(E_Icon *ic) /* FIXME */ //e_view_queue_icon_xy_record(ic->view); } - if (ic->geom.x != ic->prev_geom.x) ic->view->extents.valid = 0; - else if (ic->geom.y != ic->prev_geom.y) ic->view->extents.valid = 0; - else if (ic->geom.w != ic->prev_geom.w) ic->view->extents.valid = 0; - else if (ic->geom.h != ic->prev_geom.h) ic->view->extents.valid = 0; - + if (ic->geom.x != ic->prev_geom.x) + ic->view->extents.valid = 0; + else if (ic->geom.y != ic->prev_geom.y) + ic->view->extents.valid = 0; + else if (ic->geom.w != ic->prev_geom.w) + ic->view->extents.valid = 0; + else if (ic->geom.h != ic->prev_geom.h) + ic->view->extents.valid = 0; + ic->prev_geom = ic->geom; ic->prev_geom.x = ic->geom.x; ic->prev_geom.y = ic->geom.y; @@ -672,55 +723,52 @@ e_icon_apply_xy(E_Icon *ic) D_RETURN; } - -void -e_icon_check_permissions(E_Icon *ic) -{ - D_ENTER; - - if (!ic || !ic->file->info.mime.base || ic->file->stat.st_ino == 0) - D_RETURN; - - if (!strcmp(ic->file->info.mime.base, "dir")) - { - if (e_file_can_exec(&ic->file->stat)) - evas_set_color(ic->view->evas, ic->obj.icon, 255, 255, 255, 255); - else - evas_set_color(ic->view->evas, ic->obj.icon, 128, 128, 128, 128); - } - - D_RETURN; -} - - void -e_icon_initial_show(E_Icon *ic) +e_icon_check_permissions(E_Icon * ic) { D_ENTER; - + + if (!ic || !ic->file->info.mime.base || ic->file->stat.st_ino == 0) + D_RETURN; + + if (!strcmp(ic->file->info.mime.base, "dir")) + { + if (e_file_can_exec(&ic->file->stat)) + evas_set_color(ic->view->evas, ic->obj.icon, 255, 255, 255, 255); + else + evas_set_color(ic->view->evas, ic->obj.icon, 128, 128, 128, 128); + } + + D_RETURN; +} + +void +e_icon_initial_show(E_Icon * ic) +{ + D_ENTER; + /* check if we have enuf info and we havent been shown yet */ - if ( !ic->file->info.icon || !ic->obj.icon - || ic->state.visible) + if (!ic->file->info.icon || !ic->obj.icon || ic->state.visible) D_RETURN; /* first. lets figure out the size of the icon */ - evas_get_image_size(ic->view->evas, ic->obj.icon, + evas_get_image_size(ic->view->evas, ic->obj.icon, &(ic->geom.icon.w), &(ic->geom.icon.h)); - { - double tw, th; - - e_text_get_geometry(ic->obj.text, NULL, NULL, &tw, &th); - ic->geom.text.w = (int)tw; - ic->geom.text.h = (int)th; - } - + { + double tw, th; + + e_text_get_geometry(ic->obj.text, NULL, NULL, &tw, &th); + ic->geom.text.w = (int)tw; + ic->geom.text.h = (int)th; + } + /* now lets allocate space for it if we need to */ ic->geom.x = 999999; ic->geom.y = 999999; - + /* if needed queue a tiemout for a resort */ e_view_queue_resort(ic->view); - + /* actually show the icon */ e_icon_apply_xy(ic); e_icon_show(ic); @@ -729,12 +777,13 @@ e_icon_initial_show(E_Icon *ic) } void -e_icon_update_state(E_Icon *ic) +e_icon_update_state(E_Icon * ic) { - char icon[PATH_MAX]; - int iw, ih; + char icon[PATH_MAX]; + int iw, ih; + D_ENTER; - + if (!ic->file->info.icon) { D("EEEEEEEEEEK %s has no icon\n", ic->file->file); @@ -752,11 +801,10 @@ e_icon_update_state(E_Icon *ic) { snprintf(icon, PATH_MAX, "%s:/icon/normal", ic->file->info.icon); } - if ((ic->state.selected) && - (!ic->obj.sel.under.icon) && - (!ic->obj.sel.over.icon)) + if ((ic->state.selected) && + (!ic->obj.sel.under.icon) && (!ic->obj.sel.over.icon)) { - char file[PATH_MAX]; + char file[PATH_MAX]; /* snprintf(file, PATH_MAX, "%s/file.bits.db", e_config_get("selections")); @@ -768,7 +816,7 @@ e_icon_update_state(E_Icon *ic) ic->obj.sel.under.icon = ebits_load(file); snprintf(file, PATH_MAX, "%s/text.bits.db", e_config_get("selections")); ic->obj.sel.under.text = ebits_load(file); - if (ic->obj.sel.under.icon) + if (ic->obj.sel.under.icon) { ebits_add_to_evas(ic->obj.sel.under.icon, ic->view->evas); ebits_set_layer(ic->obj.sel.under.icon, 195); @@ -778,7 +826,7 @@ e_icon_update_state(E_Icon *ic) ebits_add_to_evas(ic->obj.sel.under.text, ic->view->evas); ebits_set_layer(ic->obj.sel.under.text, 195); } - if (ic->obj.sel.over.icon) + if (ic->obj.sel.over.icon) { ebits_add_to_evas(ic->obj.sel.over.icon, ic->view->evas); ebits_set_layer(ic->obj.sel.over.icon, 205); @@ -789,14 +837,17 @@ e_icon_update_state(E_Icon *ic) ebits_set_layer(ic->obj.sel.over.text, 205); } } - else if ((!ic->state.selected) && - ((ic->obj.sel.under.icon) || - (ic->obj.sel.over.icon))) + else if ((!ic->state.selected) && + ((ic->obj.sel.under.icon) || (ic->obj.sel.over.icon))) { - if (ic->obj.sel.under.icon) ebits_free(ic->obj.sel.under.icon); - if (ic->obj.sel.under.text) ebits_free(ic->obj.sel.under.text); - if (ic->obj.sel.over.icon) ebits_free(ic->obj.sel.over.icon); - if (ic->obj.sel.over.text) ebits_free(ic->obj.sel.over.text); + if (ic->obj.sel.under.icon) + ebits_free(ic->obj.sel.under.icon); + if (ic->obj.sel.under.text) + ebits_free(ic->obj.sel.under.text); + if (ic->obj.sel.over.icon) + ebits_free(ic->obj.sel.over.icon); + if (ic->obj.sel.over.text) + ebits_free(ic->obj.sel.over.text); ic->obj.sel.under.icon = NULL; ic->obj.sel.under.text = NULL; ic->obj.sel.over.icon = NULL; @@ -806,7 +857,7 @@ e_icon_update_state(E_Icon *ic) * Maybe it would be better to allocate here, the first * time the icon is set? -- till */ evas_set_image_file(ic->view->evas, ic->obj.icon, icon); - evas_get_image_size(ic->view->evas, ic->obj.icon, &iw, &ih); + evas_get_image_size(ic->view->evas, ic->obj.icon, &iw, &ih); e_icon_check_permissions(ic); e_icon_apply_xy(ic); ic->view->changed = 1; @@ -817,23 +868,24 @@ e_icon_update_state(E_Icon *ic) D_RETURN; } - void -e_icon_invert_selection(E_Icon *ic) +e_icon_invert_selection(E_Icon * ic) { D_ENTER; - - if (ic->state.selected) e_icon_deselect(ic); - else e_icon_select(ic); + + if (ic->state.selected) + e_icon_deselect(ic); + else + e_icon_select(ic); D_RETURN; } void -e_icon_select(E_Icon *ic) +e_icon_select(E_Icon * ic) { D_ENTER; - + if (!ic->state.selected) { ic->state.selected = 1; @@ -845,10 +897,10 @@ e_icon_select(E_Icon *ic) } void -e_icon_deselect(E_Icon *ic) +e_icon_deselect(E_Icon * ic) { D_ENTER; - + if (ic->state.selected) { ic->state.selected = 0; @@ -859,15 +911,15 @@ e_icon_deselect(E_Icon *ic) } void -e_icon_exec(E_Icon *ic) -{ +e_icon_exec(E_Icon * ic) +{ D_ENTER; - + if (!strcmp(ic->file->info.mime.base, "dir") && e_file_can_exec(&ic->file->stat)) { - E_View *v; - char buf[PATH_MAX]; + E_View *v; + char buf[PATH_MAX]; v = e_view_new(); v->size.w = 400; @@ -878,13 +930,13 @@ e_icon_exec(E_Icon *ic) e_view_set_dir(v, buf, 0); e_view_realize(v); e_view_populate(v); - + e_view_bg_reload(v); ecore_window_set_title(v->win.base, ic->file->file); ecore_window_set_name_class(v->win.base, "FileView", "E"); ecore_window_set_min_size(v->win.base, 8, 8); } - e_icon_deselect(ic); - + e_icon_deselect(ic); + D_RETURN; } diff --git a/src/icons.h b/src/icons.h index 70aba61d7..a888d3c9e 100644 --- a/src/icons.h +++ b/src/icons.h @@ -7,69 +7,84 @@ #ifndef E_ICON_TYPEDEF #define E_ICON_TYPEDEF -typedef struct _E_Icon E_Icon; +typedef struct _E_Icon E_Icon; #endif #ifndef E_VIEW_TYPEDEF #define E_VIEW_TYPEDEF -typedef struct _E_View E_View; +typedef struct _E_View E_View; #endif struct _E_Icon { - E_Object o; + E_Object o; - E_File *file; - E_View *view; - - struct { - Evas_Object icon; - Evas_Object event1; - Evas_Object event2; - E_Text *text; - struct { - struct { - Ebits_Object icon; - Ebits_Object text; - } over, under; - } sel; - } obj; - - struct { - int hilited; - int clicked; - int selected; - int running; - int disabled; - int visible; - int just_selected; - int just_executed; - int drag_delete; - } state; - - struct { - int x, y, w, h; - struct { - int w, h; - } icon; - struct { - int w, h; - } text; - } geom, prev_geom; - - struct { - int write_xy; - } q; - - int changed; + E_File *file; + E_View *view; + + struct + { + Evas_Object icon; + Evas_Object event1; + Evas_Object event2; + E_Text *text; + struct + { + struct + { + Ebits_Object icon; + Ebits_Object text; + } + over , under; + } + sel; + } + obj; + + struct + { + int hilited; + int clicked; + int selected; + int running; + int disabled; + int visible; + int just_selected; + int just_executed; + int drag_delete; + } + state; + + struct + { + int x, y, w, h; + struct + { + int w, h; + } + icon; + struct + { + int w, h; + } + text; + } + geom , prev_geom; + + struct + { + int write_xy; + } + q; + + int changed; }; - -E_Icon *e_icon_new(void); -void e_icon_update_state(E_Icon *ic); -void e_icon_invert_selection(E_Icon *ic); -void e_icon_select(E_Icon *ic); -void e_icon_deselect(E_Icon *ic); +E_Icon *e_icon_new(void); +void e_icon_update_state(E_Icon * ic); +void e_icon_invert_selection(E_Icon * ic); +void e_icon_select(E_Icon * ic); +void e_icon_deselect(E_Icon * ic); /** * e_icon_exec - handles execution paths when user activates an icon @@ -78,17 +93,18 @@ void e_icon_deselect(E_Icon *ic); * This function takes care of opening views when the user activates a * directory, launching commands when an executable is activated etc. */ -void e_icon_exec(E_Icon *ic); +void e_icon_exec(E_Icon * ic); -void e_icon_initial_show(E_Icon *ic); -void e_icon_set_mime(E_Icon *ic, char *base, char *mime); -void e_icon_set_link(E_Icon *ic, char *link); -E_Icon *e_icon_find_by_file(E_View *view, char *file); -void e_icon_show(E_Icon *ic); -void e_icon_hide(E_Icon *ic); -void e_icon_hide_delete_pending(E_Icon *ic); -void e_icon_show_delete_end(E_Icon *ic, E_dnd_enum dnd_pending_mode); -void e_icon_apply_xy(E_Icon *ic); -void e_icon_check_permissions(E_Icon *ic); +void e_icon_initial_show(E_Icon * ic); +void e_icon_set_mime(E_Icon * ic, char *base, char *mime); +void e_icon_set_link(E_Icon * ic, char *link); +E_Icon *e_icon_find_by_file(E_View * view, char *file); +void e_icon_show(E_Icon * ic); +void e_icon_hide(E_Icon * ic); +void e_icon_hide_delete_pending(E_Icon * ic); +void e_icon_show_delete_end(E_Icon * ic, + E_dnd_enum dnd_pending_mode); +void e_icon_apply_xy(E_Icon * ic); +void e_icon_check_permissions(E_Icon * ic); #endif diff --git a/src/ipc.h b/src/ipc.h index e0494305c..db296eab5 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -3,7 +3,6 @@ #include "e.h" -void e_ipc_init(void); +void e_ipc_init(void); #endif - diff --git a/src/keys.c b/src/keys.c index 0464eb4f7..1ddd8c355 100644 --- a/src/keys.c +++ b/src/keys.c @@ -2,42 +2,42 @@ #include "keys.h" #include "actions.h" -static void e_key_down(Ecore_Event * ev); -static void e_key_up(Ecore_Event * ev); +static void e_key_down(Ecore_Event * ev); +static void e_key_up(Ecore_Event * ev); -static void +static void e_key_down(Ecore_Event * ev) { - Ecore_Event_Key_Down *e; - + Ecore_Event_Key_Down *e; + D_ENTER; e = ev->event; if (e->win == ecore_get_key_grab_win()) { - e_action_stop("Key_Binding", ACT_KEY_DOWN, 0, e->key, e->mods, - NULL, NULL, 0, 0, 0, 0); - e_action_start("Key_Binding", ACT_KEY_DOWN, 0, e->key, e->mods, + e_action_stop("Key_Binding", ACT_KEY_DOWN, 0, e->key, e->mods, NULL, NULL, 0, 0, 0, 0); + e_action_start("Key_Binding", ACT_KEY_DOWN, 0, e->key, e->mods, + NULL, NULL, 0, 0, 0, 0); } D_RETURN; } -static void +static void e_key_up(Ecore_Event * ev) { - Ecore_Event_Key_Up *e; - + Ecore_Event_Key_Up *e; + D_ENTER; e = ev->event; if (e->win == ecore_get_key_grab_win()) { - e_action_stop("Key_Binding", ACT_KEY_UP, 0, e->key, e->mods, - NULL, NULL, 0, 0, 0, 0); - e_action_start("Key_Binding", ACT_KEY_UP, 0, e->key, e->mods, + e_action_stop("Key_Binding", ACT_KEY_UP, 0, e->key, e->mods, NULL, NULL, 0, 0, 0, 0); + e_action_start("Key_Binding", ACT_KEY_UP, 0, e->key, e->mods, + NULL, NULL, 0, 0, 0, 0); } D_RETURN; @@ -50,9 +50,9 @@ e_keys_init(void) /* load up our actions .... once to get some grabbed keys */ e_action_start("", ACT_KEY_DOWN, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE, - NULL, NULL, 0, 0, 0, 0); - ecore_event_filter_handler_add(ECORE_EVENT_KEY_DOWN, e_key_down); - ecore_event_filter_handler_add(ECORE_EVENT_KEY_UP, e_key_up); + NULL, NULL, 0, 0, 0, 0); + ecore_event_filter_handler_add(ECORE_EVENT_KEY_DOWN, e_key_down); + ecore_event_filter_handler_add(ECORE_EVENT_KEY_UP, e_key_up); D_RETURN; } diff --git a/src/keys.h b/src/keys.h index 60b4fed33..1f1dd25f4 100644 --- a/src/keys.h +++ b/src/keys.h @@ -3,8 +3,10 @@ #include "e.h" -void e_keys_init(void); -void e_keys_grab(char *key, Ecore_Event_Key_Modifiers mods, int anymod); -void e_keys_ungrab(char *key, Ecore_Event_Key_Modifiers mods, int anymod); +void e_keys_init(void); +void e_keys_grab(char *key, Ecore_Event_Key_Modifiers mods, + int anymod); +void e_keys_ungrab(char *key, Ecore_Event_Key_Modifiers mods, + int anymod); #endif diff --git a/src/main.c b/src/main.c index 047f75bae..6e7c2eb36 100644 --- a/src/main.c +++ b/src/main.c @@ -25,36 +25,36 @@ #include #ifdef E_PROF -Evas_List __e_profiles = NULL; +Evas_List __e_profiles = NULL; #endif -static void cb_exit(void); -static void wm_running_error(Display * d, XErrorEvent * ev); -static void setup(void); +static void cb_exit(void); +static void wm_running_error(Display * d, XErrorEvent * ev); +static void setup(void); -static void cb_exit(void) +static void +cb_exit(void) { D_ENTER; e_fs_cleanup(); E_PROF_DUMP; - + D_RETURN; } - -static void +static void wm_running_error(Display * d, XErrorEvent * ev) { D_ENTER; - if ((ev->request_code == X_ChangeWindowAttributes) && + if ((ev->request_code == X_ChangeWindowAttributes) && (ev->error_code == BadAccess)) { fprintf(stderr, "A window manager is already running.\n"); fprintf(stderr, "Exiting Enlightenment. Error.\n"); exit(-2); - } + } D_RETURN; UN(d); @@ -64,7 +64,7 @@ static void setup(void) { D_ENTER; - + ecore_grab(); ecore_sync(); @@ -79,45 +79,43 @@ setup(void) int main(int argc, char **argv) { - char *display = NULL; - int i; + char *display = NULL; + int i; srand(time(NULL)); atexit(cb_exit); e_exec_set_args(argc, argv); - + e_config_init(); /* Check command line options here: */ for (i = 1; i < argc; i++) { - if (( (!strcmp("-d", argv[i])) - || (!strcmp("-disp", argv[i])) - || (!strcmp("-display", argv[i])) - || (!strcmp("--display", argv[i]))) - && (argc - i > 1)) + if (((!strcmp("-d", argv[i])) + || (!strcmp("-disp", argv[i])) + || (!strcmp("-display", argv[i])) + || (!strcmp("--display", argv[i]))) && (argc - i > 1)) { display = argv[++i]; } - else if ( (!strcmp("-h", argv[i])) - || (!strcmp("-?", argv[i])) - || (!strcmp("-help", argv[i])) - || (!strcmp("--help", argv[i]))) + else if ((!strcmp("-h", argv[i])) + || (!strcmp("-?", argv[i])) + || (!strcmp("-help", argv[i])) || (!strcmp("--help", argv[i]))) { printf("enlightenment options: \n" "\t[-d | -disp | -display --display] display_name \n" "\t[-v | -version | --version] \n"); exit(0); } - else if ( (!strcmp("-v", argv[i])) - || (!strcmp("-version", argv[i])) + else if ((!strcmp("-v", argv[i])) + || (!strcmp("-version", argv[i])) || (!strcmp("--version", argv[i]))) { printf("Enlightenment Version: %s\n", ENLIGHTENMENT_VERSION); exit(0); } } - + if (!ecore_display_init(display)) { fprintf(stderr, "Enlightenment Error: cannot connect to display!\n"); @@ -130,7 +128,7 @@ main(int argc, char **argv) ecore_event_signal_init(); ecore_event_filter_init(); ecore_event_x_init(); - + /* become a wm */ ecore_grab(); ecore_sync(); @@ -154,15 +152,15 @@ main(int argc, char **argv) e_place_init(); e_cursors_init(); e_iconbar_init(); - + #ifdef USE_FERITE e_ferite_init(); #endif - e_desktops_init_file_display(e_desktops_get(0)); + e_desktops_init_file_display(e_desktops_get(0)); setup(); - + ecore_event_loop(); #ifdef USE_FERITE diff --git a/src/match.c b/src/match.c index 357e769a9..846489818 100644 --- a/src/match.c +++ b/src/match.c @@ -3,47 +3,70 @@ #include "config.h" void -e_match_set_props(E_Border *b) +e_match_set_props(E_Border * b) { - char buf[PATH_MAX]; - E_DB_File *db; - int ok; - + char buf[PATH_MAX]; + E_DB_File *db; + int ok; + D_ENTER; - - if ((!b->client.name) || (!b->client.class)) D_RETURN; + + if ((!b->client.name) || (!b->client.class)) + D_RETURN; db = e_db_open(e_config_get("match")); - snprintf(buf, PATH_MAX, "match/%s/%s/match", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/match", b->client.name, + b->client.class); ok = e_db_int_get(db, buf, &(b->client.matched.matched)); if (!ok) { e_db_close(db); D_RETURN; } - snprintf(buf, PATH_MAX, "match/%s/%s/prog_location/ignore", b->client.name, b->client.class); - b->client.matched.prog_location.matched = e_db_int_get(db, buf, &(b->client.matched.prog_location.ignore)); - snprintf(buf, PATH_MAX, "match/%s/%s/border/border", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/prog_location/ignore", b->client.name, + b->client.class); + b->client.matched.prog_location.matched = + e_db_int_get(db, buf, &(b->client.matched.prog_location.ignore)); + snprintf(buf, PATH_MAX, "match/%s/%s/border/border", b->client.name, + b->client.class); b->client.matched.border.style = e_db_str_get(db, buf); b->client.matched.border.matched = (int)b->client.matched.border.style; - snprintf(buf, PATH_MAX, "match/%s/%s/location/x", b->client.name, b->client.class); - b->client.matched.location.matched = e_db_int_get(db, buf, &(b->client.matched.location.x)); - snprintf(buf, PATH_MAX, "match/%s/%s/location/y", b->client.name, b->client.class); - b->client.matched.location.matched = e_db_int_get(db, buf, &(b->client.matched.location.y)); - snprintf(buf, PATH_MAX, "match/%s/%s/desk_area/x", b->client.name, b->client.class); - b->client.matched.desk_area.matched = e_db_int_get(db, buf, &(b->client.matched.desk_area.x)); - snprintf(buf, PATH_MAX, "match/%s/%s/desk_area/y", b->client.name, b->client.class); - b->client.matched.desk_area.matched = e_db_int_get(db, buf, &(b->client.matched.desk_area.y)); - snprintf(buf, PATH_MAX, "match/%s/%s/size/w", b->client.name, b->client.class); - b->client.matched.size.matched = e_db_int_get(db, buf, &(b->client.matched.size.w)); - snprintf(buf, PATH_MAX, "match/%s/%s/size/h", b->client.name, b->client.class); - b->client.matched.size.matched = e_db_int_get(db, buf, &(b->client.matched.size.h)); - snprintf(buf, PATH_MAX, "match/%s/%s/desktop/desk", b->client.name, b->client.class); - b->client.matched.desktop.matched = e_db_int_get(db, buf, &(b->client.matched.desktop.desk)); - snprintf(buf, PATH_MAX, "match/%s/%s/sticky/sticky", b->client.name, b->client.class); - b->client.matched.sticky.matched = e_db_int_get(db, buf, &(b->client.matched.sticky.sticky)); - snprintf(buf, PATH_MAX, "match/%s/%s/layer/layer", b->client.name, b->client.class); - b->client.matched.layer.matched = e_db_int_get(db, buf, &(b->client.matched.layer.layer)); - + snprintf(buf, PATH_MAX, "match/%s/%s/location/x", b->client.name, + b->client.class); + b->client.matched.location.matched = + e_db_int_get(db, buf, &(b->client.matched.location.x)); + snprintf(buf, PATH_MAX, "match/%s/%s/location/y", b->client.name, + b->client.class); + b->client.matched.location.matched = + e_db_int_get(db, buf, &(b->client.matched.location.y)); + snprintf(buf, PATH_MAX, "match/%s/%s/desk_area/x", b->client.name, + b->client.class); + b->client.matched.desk_area.matched = + e_db_int_get(db, buf, &(b->client.matched.desk_area.x)); + snprintf(buf, PATH_MAX, "match/%s/%s/desk_area/y", b->client.name, + b->client.class); + b->client.matched.desk_area.matched = + e_db_int_get(db, buf, &(b->client.matched.desk_area.y)); + snprintf(buf, PATH_MAX, "match/%s/%s/size/w", b->client.name, + b->client.class); + b->client.matched.size.matched = + e_db_int_get(db, buf, &(b->client.matched.size.w)); + snprintf(buf, PATH_MAX, "match/%s/%s/size/h", b->client.name, + b->client.class); + b->client.matched.size.matched = + e_db_int_get(db, buf, &(b->client.matched.size.h)); + snprintf(buf, PATH_MAX, "match/%s/%s/desktop/desk", b->client.name, + b->client.class); + b->client.matched.desktop.matched = + e_db_int_get(db, buf, &(b->client.matched.desktop.desk)); + snprintf(buf, PATH_MAX, "match/%s/%s/sticky/sticky", b->client.name, + b->client.class); + b->client.matched.sticky.matched = + e_db_int_get(db, buf, &(b->client.matched.sticky.sticky)); + snprintf(buf, PATH_MAX, "match/%s/%s/layer/layer", b->client.name, + b->client.class); + b->client.matched.layer.matched = + e_db_int_get(db, buf, &(b->client.matched.layer.layer)); + if (b->client.matched.prog_location.matched) { b->client.pos.requested = 0; @@ -63,8 +86,12 @@ e_match_set_props(E_Border *b) } if (b->client.matched.desk_area.matched) { - b->client.pos.x += (b->client.matched.desk_area.x - b->desk->desk.area.x) * b->desk->real.w; - b->client.pos.y += (b->client.matched.desk_area.y - b->desk->desk.area.y) * b->desk->real.h; + b->client.pos.x += + (b->client.matched.desk_area.x - + b->desk->desk.area.x) * b->desk->real.w; + b->client.pos.y += + (b->client.matched.desk_area.y - + b->desk->desk.area.y) * b->desk->real.h; b->client.area.x = b->client.matched.desk_area.x; b->client.area.y = b->client.matched.desk_area.y; } @@ -72,13 +99,15 @@ e_match_set_props(E_Border *b) { b->current.requested.w = b->client.matched.size.w; b->current.requested.h = b->client.matched.size.h; - ecore_window_resize(b->win.client, b->client.matched.size.w, b->client.matched.size.h); + ecore_window_resize(b->win.client, b->client.matched.size.w, + b->client.matched.size.h); } if (b->client.matched.desktop.matched) { - b->client.desk = b->client.matched.desktop.desk; + b->client.desk = b->client.matched.desktop.desk; e_border_raise(b); - if (b->client.desk != b->desk->desk.desk) b->current.requested.visible = 0; + if (b->client.desk != b->desk->desk.desk) + b->current.requested.visible = 0; b->client.no_place = 1; } if (b->client.matched.sticky.matched) @@ -91,95 +120,112 @@ e_match_set_props(E_Border *b) } e_db_close(db); - + D_RETURN; } void -e_match_save_props(E_Border *b) +e_match_save_props(E_Border * b) { - char buf[PATH_MAX]; - E_DB_File *db; - + char buf[PATH_MAX]; + E_DB_File *db; + D_ENTER; - - if ((!b->client.name) || (!b->client.class)) D_RETURN; - + + if ((!b->client.name) || (!b->client.class)) + D_RETURN; + db = e_db_open(e_config_get("match")); - if (!db) D_RETURN; - - snprintf(buf, PATH_MAX, "match/%s/%s/match", b->client.name, b->client.class); + if (!db) + D_RETURN; + + snprintf(buf, PATH_MAX, "match/%s/%s/match", b->client.name, + b->client.class); e_db_int_set(db, buf, b->client.matched.matched); - if (b->client.matched.location.matched) + if (b->client.matched.location.matched) { b->client.matched.location.x = b->current.x; b->client.matched.location.y = b->current.y; - snprintf(buf, PATH_MAX, "match/%s/%s/location/x", b->client.name, b->client.class); - e_db_int_set(db, buf, b->client.matched.location.x); - snprintf(buf, PATH_MAX, "match/%s/%s/location/y", b->client.name, b->client.class); - e_db_int_set(db, buf, b->client.matched.location.y); + snprintf(buf, PATH_MAX, "match/%s/%s/location/x", b->client.name, + b->client.class); + e_db_int_set(db, buf, b->client.matched.location.x); + snprintf(buf, PATH_MAX, "match/%s/%s/location/y", b->client.name, + b->client.class); + e_db_int_set(db, buf, b->client.matched.location.y); } else { - snprintf(buf, PATH_MAX, "match/%s/%s/location/x", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/location/x", b->client.name, + b->client.class); e_db_data_del(db, buf); - snprintf(buf, PATH_MAX, "match/%s/%s/location/y", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/location/y", b->client.name, + b->client.class); e_db_data_del(db, buf); } - if (b->client.matched.size.matched) + if (b->client.matched.size.matched) { b->client.matched.size.w = b->client.w; b->client.matched.size.h = b->client.h; - snprintf(buf, PATH_MAX, "match/%s/%s/size/w", b->client.name, b->client.class); - e_db_int_set(db, buf, b->client.matched.size.w); - snprintf(buf, PATH_MAX, "match/%s/%s/size/h", b->client.name, b->client.class); - e_db_int_set(db, buf, b->client.matched.size.h); + snprintf(buf, PATH_MAX, "match/%s/%s/size/w", b->client.name, + b->client.class); + e_db_int_set(db, buf, b->client.matched.size.w); + snprintf(buf, PATH_MAX, "match/%s/%s/size/h", b->client.name, + b->client.class); + e_db_int_set(db, buf, b->client.matched.size.h); } else { - snprintf(buf, PATH_MAX, "match/%s/%s/size/w", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/size/w", b->client.name, + b->client.class); e_db_data_del(db, buf); - snprintf(buf, PATH_MAX, "match/%s/%s/size/h", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/size/h", b->client.name, + b->client.class); e_db_data_del(db, buf); } - - if (b->client.matched.desktop.matched) + + if (b->client.matched.desktop.matched) { b->client.matched.desktop.desk = b->client.desk; - snprintf(buf, PATH_MAX, "match/%s/%s/desktop/desk", b->client.name, b->client.class); - e_db_int_set(db, buf, b->client.matched.desktop.desk); + snprintf(buf, PATH_MAX, "match/%s/%s/desktop/desk", b->client.name, + b->client.class); + e_db_int_set(db, buf, b->client.matched.desktop.desk); } else { - snprintf(buf, PATH_MAX, "match/%s/%s/desktop/desk", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/desktop/desk", b->client.name, + b->client.class); e_db_data_del(db, buf); } - - if (b->client.matched.sticky.matched) + + if (b->client.matched.sticky.matched) { b->client.matched.sticky.sticky = b->client.sticky; - snprintf(buf, PATH_MAX, "match/%s/%s/sticky/sticky", b->client.name, b->client.class); - e_db_int_set(db, buf, b->client.matched.sticky.sticky); + snprintf(buf, PATH_MAX, "match/%s/%s/sticky/sticky", b->client.name, + b->client.class); + e_db_int_set(db, buf, b->client.matched.sticky.sticky); } else { - snprintf(buf, PATH_MAX, "match/%s/%s/sticky/sticky", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/sticky/sticky", b->client.name, + b->client.class); e_db_data_del(db, buf); } - - if (b->client.matched.prog_location.matched) + + if (b->client.matched.prog_location.matched) { - snprintf(buf, PATH_MAX, "match/%s/%s/prog_location/ignore", b->client.name, b->client.class); - e_db_int_set(db, buf, b->client.matched.prog_location.ignore); + snprintf(buf, PATH_MAX, "match/%s/%s/prog_location/ignore", + b->client.name, b->client.class); + e_db_int_set(db, buf, b->client.matched.prog_location.ignore); } else { - snprintf(buf, PATH_MAX, "match/%s/%s/prog_location/ignore", b->client.name, b->client.class); + snprintf(buf, PATH_MAX, "match/%s/%s/prog_location/ignore", + b->client.name, b->client.class); e_db_data_del(db, buf); } - + e_db_close(db); e_db_runtime_flush(); D_RETURN; diff --git a/src/match.h b/src/match.h index 301407631..1f7d4ec52 100644 --- a/src/match.h +++ b/src/match.h @@ -5,8 +5,7 @@ #include "border.h" #include "desktops.h" -void e_match_set_props(E_Border *b); -void e_match_save_props(E_Border *b); +void e_match_set_props(E_Border * b); +void e_match_save_props(E_Border * b); #endif - diff --git a/src/menu.c b/src/menu.c index ba3fed04b..e009da668 100644 --- a/src/menu.c +++ b/src/menu.c @@ -3,184 +3,189 @@ #include "config.h" #include "util.h" -static Evas_List open_menus = NULL; /* List of all open menus */ -static Evas_List menus = NULL; -static E_Menu_Item *curr_selected_item = NULL; /* Currently selected item */ -static Window menu_event_win = 0; /* Window which originated event */ -static int screen_w, screen_h; /* Screen width and height */ -static int mouse_x, mouse_y; /* Mouse coordinates */ -static int keyboard_nav = 0; /* If non-zero, navigating with keyboard */ +static Evas_List open_menus = NULL; /* List of all open menus */ +static Evas_List menus = NULL; +static E_Menu_Item *curr_selected_item = NULL; /* Currently selected item */ +static Window menu_event_win = 0; /* Window which originated event */ +static int screen_w, screen_h; /* Screen width and height */ +static int mouse_x, mouse_y; /* Mouse coordinates */ +static int keyboard_nav = 0; /* If non-zero, navigating with keyboard */ -static void e_idle(void *data); -static void e_wheel(Ecore_Event * ev); -static void e_key_down(Ecore_Event * ev); -static void e_key_up(Ecore_Event * ev); -static void e_mouse_down(Ecore_Event * ev); -static void e_mouse_up(Ecore_Event * ev); -static void e_mouse_move(Ecore_Event * ev); -static void e_mouse_in(Ecore_Event * ev); -static void e_mouse_out(Ecore_Event * ev); -static void e_window_expose(Ecore_Event * ev); -static void e_menu_item_select (E_Menu_Item *mi); -static void e_menu_item_unselect (E_Menu_Item *mi); +static void e_idle(void *data); +static void e_wheel(Ecore_Event * ev); +static void e_key_down(Ecore_Event * ev); +static void e_key_up(Ecore_Event * ev); +static void e_mouse_down(Ecore_Event * ev); +static void e_mouse_up(Ecore_Event * ev); +static void e_mouse_move(Ecore_Event * ev); +static void e_mouse_in(Ecore_Event * ev); +static void e_mouse_out(Ecore_Event * ev); +static void e_window_expose(Ecore_Event * ev); +static void e_menu_item_select(E_Menu_Item * mi); +static void e_menu_item_unselect(E_Menu_Item * mi); -static void +static void e_scroller_timer(int val, void *data) { - Evas_List l; - int ok = 0; - int resist = 5; - int scroll_speed = 12; - static double last_time = 0.0; - double t; - + Evas_List l; + int ok = 0; + int resist = 5; + int scroll_speed = 12; + static double last_time = 0.0; + double t; + /* these two lines... */ E_CFG_INT(cfg_resist, "settings", "/menu/scroll/resist", 5); E_CFG_INT(cfg_scroll_speed, "settings", "/menu/scroll/speed", 12); - + D_ENTER; /* and these 2 should do exactly what tom wants - see e.h */ E_CONFIG_INT_GET(cfg_resist, resist); E_CONFIG_INT_GET(cfg_scroll_speed, scroll_speed); - + t = ecore_get_time(); if (val != 0) - scroll_speed = (int)(((t - last_time) / 0.02) * (double)scroll_speed); + scroll_speed = (int)(((t - last_time) / 0.02) * (double)scroll_speed); last_time = t; - - ok = 0; + + ok = 0; if (mouse_x >= (screen_w - resist)) { - int scroll = 0; - + int scroll = 0; + for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; if ((m->current.x + m->current.w) > screen_w) - scroll = m->current.x + m->current.w - screen_w; + scroll = m->current.x + m->current.w - screen_w; } if (scroll) { - if (scroll > scroll_speed) scroll = scroll_speed; + if (scroll > scroll_speed) + scroll = scroll_speed; e_menu_scroll_all_by(-scroll, 0); ok = 1; } } else if (mouse_x < resist) { - int scroll = 0; - + int scroll = 0; + for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; if (m->current.x < 0) - scroll = -m->current.x; + scroll = -m->current.x; } if (scroll) { - if (scroll > scroll_speed) scroll = scroll_speed; + if (scroll > scroll_speed) + scroll = scroll_speed; e_menu_scroll_all_by(scroll, 0); ok = 1; } } if (mouse_y >= (screen_h - resist)) { - int scroll = 0; - + int scroll = 0; + for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; if ((m->current.y + m->current.h) > screen_h) - scroll = m->current.y + m->current.h - screen_h; + scroll = m->current.y + m->current.h - screen_h; } if (scroll) { - if (scroll > scroll_speed) scroll = scroll_speed; + if (scroll > scroll_speed) + scroll = scroll_speed; e_menu_scroll_all_by(0, -scroll); ok = 1; } } else if (mouse_y < resist) { - int scroll = 0; - + int scroll = 0; + for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; if (m->current.y < 0) - scroll = -m->current.y; + scroll = -m->current.y; } if (scroll) { - if (scroll > scroll_speed) scroll = scroll_speed; + if (scroll > scroll_speed) + scroll = scroll_speed; e_menu_scroll_all_by(0, scroll); ok = 1; } } if ((ok) && (open_menus)) - ecore_add_event_timer("menu_scroller", 0.02, e_scroller_timer, val + 1, NULL); + ecore_add_event_timer("menu_scroller", 0.02, e_scroller_timer, val + 1, + NULL); D_RETURN; UN(data); } - + static void e_idle(void *data) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; e_menu_update_base(m); } for (l = menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; e_menu_update_shows(m); } for (l = menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; e_menu_update_hides(m); } for (l = menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; e_menu_update_finish(m); } for (l = menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; if (m->first_expose) - evas_render(m->evas); + evas_render(m->evas); } - again: + again: for (l = menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; if (m->delete_me) { @@ -188,7 +193,7 @@ e_idle(void *data) goto again; } } - + e_db_runtime_flush(); D_RETURN; @@ -203,8 +208,8 @@ e_idle(void *data) static void e_wheel(Ecore_Event * ev) { - Ecore_Event_Wheel *e; - + Ecore_Event_Wheel *e; + D_ENTER; e = ev->event; @@ -223,24 +228,25 @@ e_wheel(Ecore_Event * ev) static void e_key_down(Ecore_Event * ev) { - Ecore_Event_Key_Down *e; - int ok; - + Ecore_Event_Key_Down *e; + int ok; + D_ENTER; e = ev->event; ok = 0; - if (e->win == menu_event_win) ok = 1; + if (e->win == menu_event_win) + ok = 1; else { - Evas_List l; - + Evas_List l; + for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; - if ((e->win == m->win.main) || (e->win == m->win.evas)) + if ((e->win == m->win.main) || (e->win == m->win.evas)) { ok = 1; break; @@ -249,10 +255,10 @@ e_key_down(Ecore_Event * ev) } if (ok) { - Evas_List l; - E_Menu *m = NULL; - E_Menu_Item *mi = NULL; - + Evas_List l; + E_Menu *m = NULL; + E_Menu_Item *mi = NULL; + for (l = open_menus; l; l = l->next) { m = l->data; @@ -288,9 +294,9 @@ e_key_down(Ecore_Event * ev) for (l = menus; l; l = l->next) { m = l->data; - + if (m->current.visible) - e_menu_hide(m); + e_menu_hide(m); } } else if (!strcmp(e->key, "Return")) @@ -305,9 +311,9 @@ e_key_down(Ecore_Event * ev) for (l = menus; l; l = l->next) { m = l->data; - + if (m->current.visible) - e_menu_hide(m); + e_menu_hide(m); } } else @@ -326,13 +332,13 @@ e_key_down(Ecore_Event * ev) static void e_key_up(Ecore_Event * ev) { - Ecore_Event_Key_Up *e; - + Ecore_Event_Key_Up *e; + D_ENTER; e = ev->event; - { - } + { + } D_RETURN; } @@ -345,13 +351,13 @@ e_key_up(Ecore_Event * ev) static void e_mouse_down(Ecore_Event * ev) { - Ecore_Event_Mouse_Down *e; - + Ecore_Event_Mouse_Down *e; + D_ENTER; e = ev->event; - { - } + { + } D_RETURN; } @@ -364,8 +370,8 @@ e_mouse_down(Ecore_Event * ev) static void e_mouse_up(Ecore_Event * ev) { - Ecore_Event_Mouse_Up *e; - + Ecore_Event_Mouse_Up *e; + D_ENTER; e = ev->event; @@ -374,25 +380,26 @@ e_mouse_up(Ecore_Event * ev) { if (open_menus) { - E_Menu *m; - + E_Menu *m; + m = open_menus->data; if ((e->time - m->time) > 200) { - Evas_List l; - + Evas_List l; + for (l = open_menus; l; l = l->next) { m = l->data; /* Ensure that the item is actually selected and - that the mouse pointer really is over it: */ + * that the mouse pointer really is over it: */ if (m->selected) { if (INTERSECTS(m->selected->x + m->current.x, m->selected->y + m->current.y, m->selected->size.w, - m->selected->size.h + m->sel_border.b, - mouse_x, mouse_y, 0, 0)) + m->selected->size.h + + m->sel_border.b, mouse_x, mouse_y, 0, + 0)) { e_menu_callback_item(m, m->selected); } @@ -403,9 +410,9 @@ e_mouse_up(Ecore_Event * ev) for (l = menus; l; l = l->next) { m = l->data; - + if (m->current.visible) - e_menu_hide(m); + e_menu_hide(m); } } } @@ -422,43 +429,41 @@ e_mouse_up(Ecore_Event * ev) static void e_mouse_move(Ecore_Event * ev) { - Ecore_Event_Mouse_Move *e; - + Ecore_Event_Mouse_Move *e; + D_ENTER; e = ev->event; keyboard_nav = 0; if (e->win == menu_event_win) { - Evas_List l; - + Evas_List l; + mouse_x = e->rx; mouse_y = e->ry; for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; - evas_event_move(m->evas, - e->rx - m->current.x, - e->ry - m->current.y); + evas_event_move(m->evas, + e->rx - m->current.x, e->ry - m->current.y); } } else { - Evas_List l; - + Evas_List l; + mouse_x = e->rx; mouse_y = e->ry; for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; - - evas_event_move(m->evas, - e->rx - m->current.x, - e->ry - m->current.y); + + evas_event_move(m->evas, + e->rx - m->current.x, e->ry - m->current.y); } } e_scroller_timer(0, NULL); @@ -474,8 +479,8 @@ e_mouse_move(Ecore_Event * ev) static void e_mouse_in(Ecore_Event * ev) { - Ecore_Event_Window_Enter *e; - + Ecore_Event_Window_Enter *e; + D_ENTER; e = ev->event; @@ -495,8 +500,8 @@ e_mouse_in(Ecore_Event * ev) static void e_mouse_out(Ecore_Event * ev) { - Ecore_Event_Window_Leave *e; - + Ecore_Event_Window_Leave *e; + D_ENTER; e = ev->event; @@ -506,12 +511,12 @@ e_mouse_out(Ecore_Event * ev) } else { - Evas_List l; - + Evas_List l; + for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; if ((e->win == m->win.main) || (e->win == m->win.evas)) { @@ -531,27 +536,27 @@ e_mouse_out(Ecore_Event * ev) static void e_window_expose(Ecore_Event * ev) { - Ecore_Event_Window_Expose *e; - + Ecore_Event_Window_Expose *e; + D_ENTER; e = ev->event; - { - Evas_List l; - - for (l = open_menus; l; l = l->next) - { - E_Menu *m; - - m = l->data; - if (e->win == m->win.evas) - { - m->first_expose = 1; - evas_update_rect(m->evas, e->x, e->y, e->w, e->h); - break; - } - } - } + { + Evas_List l; + + for (l = open_menus; l; l = l->next) + { + E_Menu *m; + + m = l->data; + if (e->win == m->win.evas) + { + m->first_expose = 1; + evas_update_rect(m->evas, e->x, e->y, e->w, e->h); + break; + } + } + } D_RETURN; } @@ -562,14 +567,14 @@ e_window_expose(Ecore_Event * ev) * @mi: Pointer to the menu item to be unselected. */ static void -e_menu_item_unselect (E_Menu_Item *mi) +e_menu_item_unselect(E_Menu_Item * mi) { D_ENTER; if ((mi) && (mi->menu->selected == mi)) { - mi->menu->selected = curr_selected_item = NULL; - - mi->selected = 0; + mi->menu->selected = curr_selected_item = NULL; + + mi->selected = 0; mi->menu->redo_sel = 1; mi->menu->changed = 1; } @@ -585,14 +590,14 @@ e_menu_item_unselect (E_Menu_Item *mi) * @mi: Pointer to the menu item to be selected. */ static void -e_menu_item_select (E_Menu_Item *mi) +e_menu_item_select(E_Menu_Item * mi) { D_ENTER; - // e_menu_item_unselect(curr_selected_item); + // e_menu_item_unselect(curr_selected_item); if (mi) { - mi->menu->selected = mi; + mi->menu->selected = mi; mi->selected = 1; mi->menu->redo_sel = 1; mi->menu->changed = 1; @@ -613,10 +618,10 @@ e_menu_item_select (E_Menu_Item *mi) * @x: ????? * @y: ????? */ -static void +static void e_menu_item_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Menu_Item *mi; + E_Menu_Item *mi; D_ENTER; @@ -625,7 +630,7 @@ e_menu_item_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) e_menu_hide_submenus(mi->menu); if (mi->submenu && mi->submenu->entries) { - e_menu_move_to(mi->submenu, + e_menu_move_to(mi->submenu, mi->menu->current.x + mi->menu->current.w, mi->menu->current.y + mi->y - mi->menu->border.t); e_menu_show(mi->submenu); @@ -650,11 +655,11 @@ e_menu_item_in_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) * @x: ????? * @y: ????? */ -static void +static void e_menu_item_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + D_ENTER; mi = _data; @@ -669,24 +674,28 @@ e_menu_item_out_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) } void -e_menu_callback_item(E_Menu *m, E_Menu_Item *mi) +e_menu_callback_item(E_Menu * m, E_Menu_Item * mi) { D_ENTER; - if (mi->func_select) mi->func_select(m, mi, mi->func_select_data); + if (mi->func_select) + mi->func_select(m, mi, mi->func_select_data); D_RETURN; } void -e_menu_hide_callback(E_Menu *m, void (*func) (E_Menu *m, void *data), void *data) +e_menu_hide_callback(E_Menu * m, void (*func) (E_Menu * m, void *data), + void *data) { m->func_hide = func; m->func_hide_data = data; } void -e_menu_item_set_callback(E_Menu_Item *mi, void (*func) (E_Menu *m, E_Menu_Item *mi, void *data), void *data) +e_menu_item_set_callback(E_Menu_Item * mi, + void (*func) (E_Menu * m, E_Menu_Item * mi, + void *data), void *data) { D_ENTER; @@ -704,23 +713,23 @@ e_menu_item_set_callback(E_Menu_Item *mi, void (*func) (E_Menu *m, E_Menu_Item * * @menus_after: All menus after this are hidden. */ void -e_menu_hide_submenus(E_Menu *menus_after) +e_menu_hide_submenus(E_Menu * menus_after) { - Evas_List l; + Evas_List l; D_ENTER; /* Loop thru all open menus: */ for (l = open_menus; l; l = l->next) { - /* Found submenu, so now hide all remaining menus: */ + /* Found submenu, so now hide all remaining menus: */ if (l->data == menus_after) { l = l->next; for (; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; e_menu_hide(m); } @@ -741,59 +750,59 @@ e_menu_hide_submenus(E_Menu *menus_after) void e_menu_select(int dx, int dy) { - Evas_List l, ll; - int done = 0; + Evas_List l, ll; + int done = 0; D_ENTER; /* Loop through all open menus, tile done or reached end */ for (l = open_menus; (l) && (!done); l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; /* If this is the selected menu: */ if (m->selected) { - /* Go through the menu entries: */ + /* Go through the menu entries: */ for (ll = m->entries; (ll) && (!done); ll = ll->next) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + mi = ll->data; /* Found the currently selected entry: */ if (mi->selected) { - /* Vertical movement, up and down menu: */ + /* Vertical movement, up and down menu: */ if (dy != 0) { - int ok = 0; - + int ok = 0; + /* Only go up or down if entry exists to do so, */ /* and skip over separators: */ if (dy < 0) { - for ( ; ll->prev; ll = ll->prev ) - { - mi = ll->prev->data; - if (!mi->separator) - { - ok = 1; - break; - } - } + for (; ll->prev; ll = ll->prev) + { + mi = ll->prev->data; + if (!mi->separator) + { + ok = 1; + break; + } + } } else if (dy > 0) { - for ( ; ll->next; ll = ll->next ) - { - mi = ll->next->data; - if (!mi->separator) - { - ok = 1; - break; - } - } + for (; ll->next; ll = ll->next) + { + mi = ll->next->data; + if (!mi->separator) + { + ok = 1; + break; + } + } } if (ok) @@ -807,8 +816,11 @@ e_menu_select(int dx, int dy) if (mi->submenu && mi->submenu->entries) { e_menu_move_to(mi->submenu, - mi->menu->current.x + mi->menu->current.w, - mi->menu->current.y + mi->y - mi->menu->border.t); + mi->menu->current.x + + mi->menu->current.w, + mi->menu->current.y + + mi->y - + mi->menu->border.t); e_menu_show(mi->submenu); } } @@ -819,36 +831,39 @@ e_menu_select(int dx, int dy) /* Horizontal movement, into and out of submenus: */ if (dx != 0) { - int ok = 0; + int ok = 0; /* Only carry on if appropriate submenus exist: */ - if ((dx < 0) && (l->prev)) ok = 1; - else if ((dx > 0) && (l->next)) ok = 1; + if ((dx < 0) && (l->prev)) + ok = 1; + else if ((dx > 0) && (l->next)) + ok = 1; if (ok) { - E_Menu_Item *mi = NULL; - E_Menu *mm; - + E_Menu_Item *mi = NULL; + E_Menu *mm; + /* Moving out of a submenu: */ - if (dx < 0) + if (dx < 0) { - Evas_List ll; - + Evas_List ll; + mm = l->prev->data; for (ll = mm->entries; (ll) && (!mi); ll = ll->next) { - E_Menu_Item *mmi; - + E_Menu_Item *mmi; + mmi = ll->data; - if (mmi->submenu == m) mi = mmi; + if (mmi->submenu == m) + mi = mmi; } } /* Moving into a submenu: */ - else + else { mm = l->next->data; if (mm->entries) - mi = mm->entries->data; + mi = mm->entries->data; } if (mi) { @@ -861,8 +876,10 @@ e_menu_select(int dx, int dy) if (mi->submenu && mi->submenu->entries) { e_menu_move_to(mi->submenu, - mi->menu->current.x + mi->menu->current.w, - mi->menu->current.y + mi->y - mi->menu->border.t); + mi->menu->current.x + + mi->menu->current.w, + mi->menu->current.y + mi->y - + mi->menu->border.t); e_menu_show(mi->submenu); } e_menu_update_visibility(mm); @@ -878,9 +895,9 @@ e_menu_select(int dx, int dy) { if (open_menus) { - E_Menu *m; - E_Menu_Item *mi; - + E_Menu *m; + E_Menu_Item *mi; + m = open_menus->data; mi = m->entries->data; e_menu_item_select(mi); @@ -888,7 +905,8 @@ e_menu_select(int dx, int dy) { e_menu_move_to(mi->submenu, mi->menu->current.x + mi->menu->current.w, - mi->menu->current.y + mi->y - mi->menu->border.t); + mi->menu->current.y + mi->y - + mi->menu->border.t); e_menu_show(mi->submenu); } } @@ -903,15 +921,15 @@ e_menu_init(void) D_ENTER; ecore_window_get_geometry(0, NULL, NULL, &screen_w, &screen_h); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, e_mouse_down); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, e_mouse_up); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, e_mouse_move); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_IN, e_mouse_in); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_OUT, e_mouse_out); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_EXPOSE, e_window_expose); - ecore_event_filter_handler_add(ECORE_EVENT_KEY_DOWN, e_key_down); - ecore_event_filter_handler_add(ECORE_EVENT_KEY_UP, e_key_up); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_WHEEL, e_wheel); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, e_mouse_down); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, e_mouse_up); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, e_mouse_move); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_IN, e_mouse_in); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_OUT, e_mouse_out); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_EXPOSE, e_window_expose); + ecore_event_filter_handler_add(ECORE_EVENT_KEY_DOWN, e_key_down); + ecore_event_filter_handler_add(ECORE_EVENT_KEY_UP, e_key_up); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_WHEEL, e_wheel); ecore_event_filter_idle_handler_add(e_idle, NULL); D_RETURN; @@ -926,23 +944,27 @@ e_menu_event_win_show(void) if (!menu_event_win) { menu_event_win = ecore_window_input_new(0, 0, 0, screen_w, screen_h); - ecore_window_set_events(menu_event_win, XEV_MOUSE_MOVE | XEV_BUTTON | XEV_IN_OUT | XEV_KEY); + ecore_window_set_events(menu_event_win, + XEV_MOUSE_MOVE | XEV_BUTTON | XEV_IN_OUT | + XEV_KEY); ecore_window_show(menu_event_win); ecore_keyboard_grab(menu_event_win); ecore_grab_mouse(menu_event_win, 1, 0); } /* raise it */ - if (menu_event_win) ecore_window_raise(menu_event_win); + if (menu_event_win) + ecore_window_raise(menu_event_win); if ((!ecore_grab_window_get()) || (!ecore_keyboard_grab_window_get())) { - Evas_List l; - + Evas_List l; + for (l = menus; l; l = l->next) { - E_Menu *m; - - m = l->data; - if (m->current.visible) e_menu_hide(m); + E_Menu *m; + + m = l->data; + if (m->current.visible) + e_menu_hide(m); } e_menu_event_win_hide(); } @@ -975,30 +997,33 @@ e_menu_event_win_hide(void) * @m: Menu to set background on. */ void -e_menu_set_background(E_Menu *m) +e_menu_set_background(E_Menu * m) { - char *menus; - char buf[PATH_MAX]; - char *part; - int pl, pr, pt, pb; - + char *menus; + char buf[PATH_MAX]; + char *part; + int pl, pr, pt, pb; + D_ENTER; - menus = e_config_get("menus"); - + menus = e_config_get("menus"); + part = "base.bits.db"; snprintf(buf, PATH_MAX, "%s%s", menus, part); - if ((m->bg_file) && (!strcmp(m->bg_file, buf))) D_RETURN; - + if ((m->bg_file) && (!strcmp(m->bg_file, buf))) + D_RETURN; + IF_FREE(m->bg_file); m->bg_file = strdup(buf); - - if (m->bg) ebits_free(m->bg); + + if (m->bg) + ebits_free(m->bg); m->bg = ebits_load(m->bg_file); - if (m->bg) ebits_set_color_class(m->bg, "Menu BG", 100, 200, 255, 255); - + if (m->bg) + ebits_set_color_class(m->bg, "Menu BG", 100, 200, 255, 255); + pl = pr = pt = pb = 0; - if (m->bg) + if (m->bg) { ebits_get_insets(m->bg, &pl, &pr, &pt, &pb); ebits_add_to_evas(m->bg, m->evas); @@ -1018,46 +1043,66 @@ e_menu_set_background(E_Menu *m) } void -e_menu_set_sel(E_Menu *m, E_Menu_Item *mi) +e_menu_set_sel(E_Menu * m, E_Menu_Item * mi) { - char *menus; - char buf[PATH_MAX]; - int pl, pr, pt, pb; - int has_sub = 0; - int selected = 0; - + char *menus; + char buf[PATH_MAX]; + int pl, pr, pt, pb; + int has_sub = 0; + int selected = 0; + D_ENTER; - menus = e_config_get("menus"); + menus = e_config_get("menus"); if (!mi->separator) { selected = mi->selected; - if (mi->submenu) has_sub = 1; + if (mi->submenu) + has_sub = 1; snprintf(buf, PATH_MAX, "%sselected-%i.submenu-%i.bits.db", menus, - selected, has_sub); - if ((mi->bg_file) && (!strcmp(mi->bg_file, buf))) D_RETURN; + selected, has_sub); + if ((mi->bg_file) && (!strcmp(mi->bg_file, buf))) + D_RETURN; } IF_FREE(mi->bg_file); if (!mi->separator) - mi->bg_file = strdup(buf); + mi->bg_file = strdup(buf); else - mi->bg_file = NULL; - if (mi->bg) ebits_free(mi->bg); + mi->bg_file = NULL; + if (mi->bg) + ebits_free(mi->bg); if (mi->bg_file) - mi->bg = ebits_load(mi->bg_file); - if (mi->bg) ebits_set_color_class(mi->bg, "Menu BG", 100, 200, 255, 255); - + mi->bg = ebits_load(mi->bg_file); + if (mi->bg) + ebits_set_color_class(mi->bg, "Menu BG", 100, 200, 255, 255); + pl = pr = pt = pb = 0; - if (mi->bg) + if (mi->bg) { ebits_get_insets(mi->bg, &pl, &pr, &pt, &pb); ebits_add_to_evas(mi->bg, m->evas); ebits_set_layer(mi->bg, 1); } - if (m->sel_border.l < pl) {m->sel_border.l = pl; m->recalc_entries = 1;} - if (m->sel_border.r < pr) {m->sel_border.r = pr; m->recalc_entries = 1;} - if (m->sel_border.t < pt) {m->sel_border.t = pt; m->recalc_entries = 1;} - if (m->sel_border.b < pb) {m->sel_border.b = pb; m->recalc_entries = 1;} + if (m->sel_border.l < pl) + { + m->sel_border.l = pl; + m->recalc_entries = 1; + } + if (m->sel_border.r < pr) + { + m->sel_border.r = pr; + m->recalc_entries = 1; + } + if (m->sel_border.t < pt) + { + m->sel_border.t = pt; + m->recalc_entries = 1; + } + if (m->sel_border.b < pb) + { + m->sel_border.b = pb; + m->recalc_entries = 1; + } m->redo_sel = 1; m->changed = 1; @@ -1065,37 +1110,42 @@ e_menu_set_sel(E_Menu *m, E_Menu_Item *mi) } void -e_menu_set_sep(E_Menu *m, E_Menu_Item *mi) +e_menu_set_sep(E_Menu * m, E_Menu_Item * mi) { - char *menus; - char buf[PATH_MAX]; - int pl, pr, pt, pb, minx, miny; - + char *menus; + char buf[PATH_MAX]; + int pl, pr, pt, pb, minx, miny; + D_ENTER; - menus = e_config_get("menus"); + menus = e_config_get("menus"); snprintf(buf, PATH_MAX, "%sseparator.bits.db", menus); - if ((mi->sep_file) && (!strcmp(mi->sep_file, buf))) D_RETURN; - + if ((mi->sep_file) && (!strcmp(mi->sep_file, buf))) + D_RETURN; + IF_FREE(mi->sep_file); mi->sep_file = strdup(buf); - - if (mi->sep) ebits_free(mi->sep); + + if (mi->sep) + ebits_free(mi->sep); mi->sep = ebits_load(mi->sep_file); - if (mi->sep) ebits_set_color_class(mi->sep, "Menu BG", 100, 200, 255, 255); - + if (mi->sep) + ebits_set_color_class(mi->sep, "Menu BG", 100, 200, 255, 255); + pl = pr = pt = pb = 0; minx = 0; miny = 0; - if (mi->sep) + if (mi->sep) { ebits_get_insets(mi->sep, &pl, &pr, &pt, &pb); ebits_add_to_evas(mi->sep, m->evas); ebits_set_layer(mi->sep, 1); ebits_get_min_size(mi->sep, &minx, &miny); } - if (mi->size.min.w < minx) mi->size.min.w = minx; - if (mi->size.min.h < miny) mi->size.min.h = miny; + if (mi->size.min.w < minx) + mi->size.min.w = minx; + if (mi->size.min.h < miny) + mi->size.min.h = miny; m->redo_sel = 1; m->changed = 1; @@ -1103,42 +1153,47 @@ e_menu_set_sep(E_Menu *m, E_Menu_Item *mi) } void -e_menu_set_state(E_Menu *m, E_Menu_Item *mi) +e_menu_set_state(E_Menu * m, E_Menu_Item * mi) { - char *menus; - char buf[PATH_MAX]; - int on; - int pl, pr, pt, pb, minx, miny; - + char *menus; + char buf[PATH_MAX]; + int on; + int pl, pr, pt, pb, minx, miny; + D_ENTER; - menus = e_config_get("menus"); + menus = e_config_get("menus"); on = mi->on; if (mi->check) - snprintf(buf, PATH_MAX, "%scheck-%i.bits.db", menus, on); + snprintf(buf, PATH_MAX, "%scheck-%i.bits.db", menus, on); else - snprintf(buf, PATH_MAX, "%sradio-%i.bits.db", menus, on); - if ((mi->state_file) && (!strcmp(mi->state_file, buf))) D_RETURN; - + snprintf(buf, PATH_MAX, "%sradio-%i.bits.db", menus, on); + if ((mi->state_file) && (!strcmp(mi->state_file, buf))) + D_RETURN; + IF_FREE(mi->state_file); mi->state_file = strdup(buf); - - if (mi->state) ebits_free(mi->state); + + if (mi->state) + ebits_free(mi->state); mi->state = ebits_load(mi->state_file); - if (mi->state) ebits_set_color_class(mi->state, "Menu BG", 100, 200, 255, 255); - + if (mi->state) + ebits_set_color_class(mi->state, "Menu BG", 100, 200, 255, 255); + pl = pr = pt = pb = 0; minx = 0; miny = 0; - if (mi->state) + if (mi->state) { ebits_get_insets(mi->state, &pl, &pr, &pt, &pb); ebits_add_to_evas(mi->state, m->evas); ebits_set_layer(mi->state, 2); ebits_get_min_size(mi->state, &minx, &miny); } - if (mi->size.min.w < minx) mi->size.min.w = minx; - if (mi->size.min.h < miny) mi->size.min.h = miny; + if (mi->size.min.w < minx) + mi->size.min.w = minx; + if (mi->size.min.h < miny) + mi->size.min.h = miny; m->redo_sel = 1; m->changed = 1; @@ -1146,16 +1201,16 @@ e_menu_set_state(E_Menu *m, E_Menu_Item *mi) } static void -e_menu_cleanup(E_Menu *m) +e_menu_cleanup(E_Menu * m) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = m->entries; l; l = l->next) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + mi = l->data; e_menu_item_unrealize(m, mi); IF_FREE(mi->str); @@ -1177,33 +1232,30 @@ e_menu_cleanup(E_Menu *m) D_RETURN; } -E_Menu * +E_Menu * e_menu_new(void) { - E_Menu *m; - int max_colors = 216; - int font_cache = 1024 * 1024; - int image_cache = 8192 * 1024; - char *font_dir; - + E_Menu *m; + int max_colors = 216; + int font_cache = 1024 * 1024; + int image_cache = 8192 * 1024; + char *font_dir; + D_ENTER; font_dir = e_config_get("fonts"); - + m = NEW(E_Menu, 1); ZERO(m, E_Menu, 1); - + e_object_init(E_OBJECT(m), (E_Cleanup_Func) e_menu_cleanup); - + m->win.main = ecore_window_override_new(0, 0, 0, 1, 1); m->evas = evas_new_all(ecore_display_get(), - m->win.main, + m->win.main, 0, 0, 1, 1, RENDER_METHOD_ALPHA_SOFTWARE, - max_colors, - font_cache, - image_cache, - font_dir); + max_colors, font_cache, image_cache, font_dir); /* aaaaaaaaah. this makes building the menu fast - moves the mouse far */ /* far far far far away so callbacks and events arent triggerd as we */ /* create objects that ofter hang around 0,0 - the default place for */ @@ -1219,32 +1271,33 @@ e_menu_new(void) /* for now i think people will just have to live with a maximum menu size */ /* of 32768x32768... didums! */ evas_event_move(m->evas, -999999999, -99999999); - + m->win.evas = evas_get_window(m->evas); - ecore_window_set_events(m->win.evas, XEV_EXPOSE | XEV_MOUSE_MOVE | XEV_BUTTON | XEV_IN_OUT | XEV_KEY); + ecore_window_set_events(m->win.evas, + XEV_EXPOSE | XEV_MOUSE_MOVE | XEV_BUTTON | XEV_IN_OUT + | XEV_KEY); ecore_window_set_events(m->win.main, XEV_IN_OUT | XEV_KEY); ecore_window_show(m->win.evas); - + e_menu_set_background(m); - + m->current.w = m->border.l + m->border.r; m->current.h = m->border.t + m->border.b; m->changed = 1; - + menus = evas_list_prepend(menus, m); - + D_RETURN_(m); } void -e_menu_hide(E_Menu *m) +e_menu_hide(E_Menu * m) { D_ENTER; - if (m->selected) { - m->selected->selected = 0; + m->selected->selected = 0; } m->selected = NULL; m->redo_sel = 1; @@ -1255,7 +1308,7 @@ e_menu_hide(E_Menu *m) } void -e_menu_show(E_Menu *m) +e_menu_show(E_Menu * m) { D_ENTER; @@ -1266,7 +1319,7 @@ e_menu_show(E_Menu *m) } void -e_menu_move_to(E_Menu *m, int x, int y) +e_menu_move_to(E_Menu * m, int x, int y) { D_ENTER; @@ -1278,7 +1331,7 @@ e_menu_move_to(E_Menu *m, int x, int y) } void -e_menu_show_at_mouse(E_Menu *m, int x, int y, Time t) +e_menu_show_at_mouse(E_Menu * m, int x, int y, Time t) { D_ENTER; @@ -1286,14 +1339,13 @@ e_menu_show_at_mouse(E_Menu *m, int x, int y, Time t) m->current.x = x; m->current.y = y; m->time = t; - D("show menu\n") - e_menu_show(m); + D("show menu\n") e_menu_show(m); D_RETURN; } void -e_menu_add_item(E_Menu *m, E_Menu_Item *mi) +e_menu_add_item(E_Menu * m, E_Menu_Item * mi) { D_ENTER; @@ -1307,7 +1359,7 @@ e_menu_add_item(E_Menu *m, E_Menu_Item *mi) } void -e_menu_del_item(E_Menu *m, E_Menu_Item *mi) +e_menu_del_item(E_Menu * m, E_Menu_Item * mi) { D_ENTER; @@ -1317,7 +1369,8 @@ e_menu_del_item(E_Menu *m, E_Menu_Item *mi) e_menu_item_unrealize(m, mi); IF_FREE(mi->str); IF_FREE(mi->icon); - if (mi->menu->selected == mi) mi->menu->selected = NULL; + if (mi->menu->selected == mi) + mi->menu->selected = NULL; free(mi); mi->menu = NULL; @@ -1325,72 +1378,91 @@ e_menu_del_item(E_Menu *m, E_Menu_Item *mi) } void -e_menu_item_update(E_Menu *m, E_Menu_Item *mi) +e_menu_item_update(E_Menu * m, E_Menu_Item * mi) { - int tx, ty, tw, th, ix, iy, iw, ih, rx, ry, rw, rh; - double dtw, dth; - + int tx, ty, tw, th, ix, iy, iw, ih, rx, ry, rw, rh; + double dtw, dth; + D_ENTER; if (mi->sep) { ebits_move(mi->sep, mi->x, mi->y); - ebits_resize(mi->sep, mi->size.w + m->sel_border.l + m->sel_border.r, mi->size.h); + ebits_resize(mi->sep, mi->size.w + m->sel_border.l + m->sel_border.r, + mi->size.h); ebits_show(mi->sep); } else { - rx = 0; ry = 0; rh = 0; + rx = 0; + ry = 0; + rh = 0; rw = m->size.state; - if (mi->state) + if (mi->state) { ebits_get_min_size(mi->state, &rw, &rh); rx = 0; ry = ((mi->size.h - rh) / 2); - ebits_move(mi->state, m->sel_border.l + mi->x + rx, m->sel_border.t + mi->y + ry); + ebits_move(mi->state, m->sel_border.l + mi->x + rx, + m->sel_border.t + mi->y + ry); ebits_resize(mi->state, rw, rh); } - - tx = 0; ty = 0; tw = 0; th = 0; - if (mi->obj_text) + + tx = 0; + ty = 0; + tw = 0; + th = 0; + if (mi->obj_text) { evas_get_geometry(m->evas, mi->obj_text, NULL, NULL, &dtw, &dth); - tw = (int)dtw; th = (int)dth; + tw = (int)dtw; + th = (int)dth; } - - ix = 0; iy = 0; iw = 0; ih = 0; - if (mi->obj_icon) + + ix = 0; + iy = 0; + iw = 0; + ih = 0; + if (mi->obj_icon) { - int sh; - + int sh; + evas_get_image_size(m->evas, mi->obj_icon, &iw, &ih); sh = th; - if (rh > th) sh = rh; + if (rh > th) + sh = rh; if ((mi->scale_icon) && (ih > sh) && (mi->str)) { iw = (iw * sh) / ih; ih = sh; } - if (m->size.state) ix = rx + m->size.state + m->pad.state; + if (m->size.state) + ix = rx + m->size.state + m->pad.state; ix += ((m->size.icon - iw) / 2); iy = ((mi->size.h - ih) / 2); - evas_move(m->evas, mi->obj_icon, m->sel_border.l + mi->x + ix, m->sel_border.t + mi->y + iy); + evas_move(m->evas, mi->obj_icon, m->sel_border.l + mi->x + ix, + m->sel_border.t + mi->y + iy); evas_resize(m->evas, mi->obj_icon, iw, ih); evas_set_image_fill(m->evas, mi->obj_icon, 0, 0, iw, ih); } - - if (mi->obj_text) + + if (mi->obj_text) { - if (m->size.state) tx = rx + m->size.state + m->pad.state; - if (m->size.icon) tx += m->size.icon + m->pad.icon; + if (m->size.state) + tx = rx + m->size.state + m->pad.state; + if (m->size.icon) + tx += m->size.icon + m->pad.icon; ty = ((mi->size.h - th) / 2); - evas_move(m->evas, mi->obj_text, m->sel_border.l + mi->x + tx, m->sel_border.t + mi->y + ty); + evas_move(m->evas, mi->obj_text, m->sel_border.l + mi->x + tx, + m->sel_border.t + mi->y + ty); } - + if (mi->obj_entry) { evas_move(m->evas, mi->obj_entry, mi->x, mi->y); - evas_resize(m->evas, mi->obj_entry, mi->size.w + m->sel_border.l + m->sel_border.r, mi->size.h + m->sel_border.t + m->sel_border.b); + evas_resize(m->evas, mi->obj_entry, + mi->size.w + m->sel_border.l + m->sel_border.r, + mi->size.h + m->sel_border.t + m->sel_border.b); } if (mi->state) { @@ -1402,25 +1474,31 @@ e_menu_item_update(E_Menu *m, E_Menu_Item *mi) } void -e_menu_item_unrealize(E_Menu *m, E_Menu_Item *mi) +e_menu_item_unrealize(E_Menu * m, E_Menu_Item * mi) { D_ENTER; - if (mi->bg) ebits_free(mi->bg); + if (mi->bg) + ebits_free(mi->bg); mi->bg = NULL; IF_FREE(mi->bg_file); mi->bg_file = NULL; - if (mi->obj_entry) evas_del_object(m->evas, mi->obj_entry); + if (mi->obj_entry) + evas_del_object(m->evas, mi->obj_entry); mi->obj_entry = NULL; - if (mi->obj_text) evas_del_object(m->evas, mi->obj_text); + if (mi->obj_text) + evas_del_object(m->evas, mi->obj_text); mi->obj_text = NULL; - if (mi->obj_icon) evas_del_object(m->evas, mi->obj_icon); + if (mi->obj_icon) + evas_del_object(m->evas, mi->obj_icon); mi->obj_icon = NULL; - if (mi->state) ebits_free(mi->state); + if (mi->state) + ebits_free(mi->state); mi->state = NULL; IF_FREE(mi->state_file); mi->state_file = NULL; - if (mi->sep) ebits_free(mi->sep); + if (mi->sep) + ebits_free(mi->sep); mi->sep = NULL; IF_FREE(mi->sep_file); mi->sep_file = NULL; @@ -1429,10 +1507,10 @@ e_menu_item_unrealize(E_Menu *m, E_Menu_Item *mi) } void -e_menu_item_realize(E_Menu *m, E_Menu_Item *mi) +e_menu_item_realize(E_Menu * m, E_Menu_Item * mi) { - double tw, th; - int iw, ih, rw, rh; + double tw, th; + int iw, ih, rw, rh; D_ENTER; @@ -1442,7 +1520,7 @@ e_menu_item_realize(E_Menu *m, E_Menu_Item *mi) } else { - if (mi->str) + if (mi->str) { mi->obj_text = evas_add_text(m->evas, "borzoib", 8, mi->str); evas_set_color(m->evas, mi->obj_text, 0, 0, 0, 255); @@ -1454,69 +1532,76 @@ e_menu_item_realize(E_Menu *m, E_Menu_Item *mi) mi->obj_icon = evas_add_image_from_file(m->evas, mi->icon); evas_show(m->evas, mi->obj_icon); evas_set_layer(m->evas, mi->obj_icon, 10); - } + } mi->obj_entry = evas_add_rectangle(m->evas); evas_set_layer(m->evas, mi->obj_entry, 11); evas_set_color(m->evas, mi->obj_entry, 0, 0, 0, 0); evas_show(m->evas, mi->obj_entry); - tw = 0; th = 0; - if (mi->obj_text) evas_get_geometry(m->evas, mi->obj_text, NULL, NULL, &tw, &th); - iw = 0; ih = 0; - if (mi->obj_icon) evas_get_image_size(m->evas, mi->obj_icon, &iw, &ih); - rw = 0; rh = 0; - if (mi->state) ebits_get_min_size(mi->state, &rw, &rh); + tw = 0; + th = 0; + if (mi->obj_text) + evas_get_geometry(m->evas, mi->obj_text, NULL, NULL, &tw, &th); + iw = 0; + ih = 0; + if (mi->obj_icon) + evas_get_image_size(m->evas, mi->obj_icon, &iw, &ih); + rw = 0; + rh = 0; + if (mi->state) + ebits_get_min_size(mi->state, &rw, &rh); mi->size.min.w = (int)tw + rw; - if (rh > th) th = (double)rh; - if (((!mi->scale_icon) && (ih > th)) || - ((!mi->str) && (ih > th))) th = (double)ih; + if (rh > th) + th = (double)rh; + if (((!mi->scale_icon) && (ih > th)) || ((!mi->str) && (ih > th))) + th = (double)ih; mi->size.min.h = (int)th; - evas_callback_add(m->evas, mi->obj_entry, CALLBACK_MOUSE_IN, e_menu_item_in_cb, mi); - evas_callback_add(m->evas, mi->obj_entry, CALLBACK_MOUSE_OUT, e_menu_item_out_cb, mi); + evas_callback_add(m->evas, mi->obj_entry, CALLBACK_MOUSE_IN, + e_menu_item_in_cb, mi); + evas_callback_add(m->evas, mi->obj_entry, CALLBACK_MOUSE_OUT, + e_menu_item_out_cb, mi); e_menu_set_sel(m, mi); - if ((mi->radio) || (mi->check)) e_menu_set_state(m, mi); + if ((mi->radio) || (mi->check)) + e_menu_set_state(m, mi); } D_RETURN; } -E_Menu_Item * +E_Menu_Item * e_menu_item_new(char *str) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + D_ENTER; mi = NEW(E_Menu_Item, 1); ZERO(mi, E_Menu_Item, 1); - if (str) mi->str = strdup(str); - + if (str) + mi->str = strdup(str); + D_RETURN_(mi); } void -e_menu_obscure_outside_screen(E_Menu *m) +e_menu_obscure_outside_screen(E_Menu * m) { D_ENTER; /* obscure stuff outside the screen boundaries - optimizes rendering */ evas_clear_obscured_rects(m->evas); - evas_add_obscured_rect(m->evas, + evas_add_obscured_rect(m->evas, -m->current.x - 100000, - -m->current.y - 100000, - 200000 + screen_w, 100000); - evas_add_obscured_rect(m->evas, + -m->current.y - 100000, 200000 + screen_w, 100000); + evas_add_obscured_rect(m->evas, -m->current.x - 100000, - -m->current.y - 100000, - 100000, 200000 + screen_h); - evas_add_obscured_rect(m->evas, + -m->current.y - 100000, 100000, 200000 + screen_h); + evas_add_obscured_rect(m->evas, -m->current.x - 100000, - screen_h - m->current.y, - 200000 + screen_w, 100000); - evas_add_obscured_rect(m->evas, + screen_h - m->current.y, 200000 + screen_w, 100000); + evas_add_obscured_rect(m->evas, screen_w - m->current.x, - -m->current.y - 100000, - 100000, 200000 + screen_h); + -m->current.y - 100000, 100000, 200000 + screen_h); D_RETURN; } @@ -1524,14 +1609,14 @@ e_menu_obscure_outside_screen(E_Menu *m) void e_menu_scroll_all_by(int dx, int dy) { - Evas_List l; - + Evas_List l; + D_ENTER; for (l = menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; if (m->current.visible) { @@ -1544,12 +1629,11 @@ e_menu_scroll_all_by(int dx, int dy) { for (l = open_menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; - evas_event_move(m->evas, - mouse_x - m->current.x, - mouse_y - m->current.y); + evas_event_move(m->evas, + mouse_x - m->current.x, mouse_y - m->current.y); } } @@ -1557,17 +1641,17 @@ e_menu_scroll_all_by(int dx, int dy) } void -e_menu_update_visibility(E_Menu *m) +e_menu_update_visibility(E_Menu * m) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + D_ENTER; mi = m->selected; if (mi) { /* if the entry is off screen - scroll so it's on screen */ if (m->current.x < 0) - e_menu_scroll_all_by(-m->current.x, 0); + e_menu_scroll_all_by(-m->current.x, 0); else if ((m->current.x + m->current.w) > screen_w) { e_menu_scroll_all_by(screen_w - (m->current.x + m->current.w), 0); @@ -1575,16 +1659,18 @@ e_menu_update_visibility(E_Menu *m) if ((m->current.y + m->sel_border.t + mi->y) < 0) { if (m->current.y < -(screen_h / 4)) - e_menu_scroll_all_by(0, screen_h / 4); + e_menu_scroll_all_by(0, screen_h / 4); else - e_menu_scroll_all_by(0, - m->current.y); + e_menu_scroll_all_by(0, -m->current.y); } - else if ((m->current.y + m->sel_border.t + mi->y + mi->size.h) > screen_h) + else if ((m->current.y + m->sel_border.t + mi->y + mi->size.h) > + screen_h) { if ((m->current.y + m->current.h - screen_h) < (screen_h / 4)) - e_menu_scroll_all_by(0, -(m->current.y + m->current.h - screen_h)); + e_menu_scroll_all_by(0, + -(m->current.y + m->current.h - screen_h)); else - e_menu_scroll_all_by(0, -(screen_h / 4)); + e_menu_scroll_all_by(0, -(screen_h / 4)); } } @@ -1592,100 +1678,119 @@ e_menu_update_visibility(E_Menu *m) } void -e_menu_update_base(E_Menu *m) +e_menu_update_base(E_Menu * m) { - int size_changed = 0; - int location_changed = 0; + int size_changed = 0; + int location_changed = 0; D_ENTER; - - if (!m->changed) D_RETURN; - + if (!m->changed) + D_RETURN; + if (m->recalc_entries) { - Evas_List l; - int max_w, max_h; - int i; - + Evas_List l; + int max_w, max_h; + int i; + max_w = 0; max_h = 0; for (l = m->entries; l; l = l->next) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + mi = l->data; - if (mi->size.min.h > max_h) max_h = mi->size.min.h; + if (mi->size.min.h > max_h) + max_h = mi->size.min.h; } m->size.state = 0; m->size.icon = 0; m->size.text = 0; for (l = m->entries; l; l = l->next) { - E_Menu_Item *mi; - int iw, ih, rw, rh; - double tw, th; - + E_Menu_Item *mi; + int iw, ih, rw, rh; + double tw, th; + mi = l->data; if (!mi->separator) { - tw = 0; th = 0; - if (mi->obj_text) evas_get_geometry(m->evas, mi->obj_text, NULL, NULL, &tw, &th); - iw = 0; ih = 0; - if (mi->obj_icon) evas_get_image_size(m->evas, mi->obj_icon, &iw, &ih); - rw = 0; rh = 0; - if (mi->state) ebits_get_min_size(mi->state, &rw, &rh); - if (m->size.text < tw) m->size.text = tw; - if (m->size.state < rw) m->size.state = rw; + tw = 0; + th = 0; + if (mi->obj_text) + evas_get_geometry(m->evas, mi->obj_text, NULL, NULL, &tw, + &th); + iw = 0; + ih = 0; + if (mi->obj_icon) + evas_get_image_size(m->evas, mi->obj_icon, &iw, &ih); + rw = 0; + rh = 0; + if (mi->state) + ebits_get_min_size(mi->state, &rw, &rh); + if (m->size.text < tw) + m->size.text = tw; + if (m->size.state < rw) + m->size.state = rw; if ((mi->scale_icon) && (iw > 0) && (ih > 0) && (mi->str)) { - int iiw; - + int iiw; + iiw = iw; - if (ih > (int)th) iiw = (iw * (int)th) / ih; - if (m->size.icon < iiw) m->size.icon = iiw; + if (ih > (int)th) + iiw = (iw * (int)th) / ih; + if (m->size.icon < iiw) + m->size.icon = iiw; } - else if (m->size.icon < iw) m->size.icon = iw; + else if (m->size.icon < iw) + m->size.icon = iw; } } max_w = m->size.state; - if (m->size.state) max_w += m->pad.state; + if (m->size.state) + max_w += m->pad.state; max_w += m->size.icon; - if (m->size.icon) max_w += m->pad.icon; + if (m->size.icon) + max_w += m->pad.icon; max_w += m->size.text; - + i = m->border.t; for (l = m->entries; l; l = l->next) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + mi = l->data; mi->size.w = max_w; - if (mi->separator) mi->size.h = mi->size.min.h; - else mi->size.h = max_h; + if (mi->separator) + mi->size.h = mi->size.min.h; + else + mi->size.h = max_h; mi->x = m->border.l; mi->y = i; if (!mi->separator) - i += m->sel_border.t + m->sel_border.b; + i += m->sel_border.t + m->sel_border.b; if (mi->separator) - i += mi->size.h; + i += mi->size.h; else - i += max_h; + i += max_h; e_menu_item_update(m, mi); } - m->current.w = m->border.l + m->border.r + max_w + m->sel_border.l + m->sel_border.r; + m->current.w = + m->border.l + m->border.r + max_w + m->sel_border.l + + m->sel_border.r; m->current.h = m->border.b + i; - + m->recalc_entries = 0; } if (m->redo_sel) { - Evas_List l; - + Evas_List l; + for (l = m->entries; l; l = l->next) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + mi = l->data; e_menu_set_sel(m, mi); if (mi) @@ -1693,26 +1798,27 @@ e_menu_update_base(E_Menu *m) if (mi->bg) { ebits_move(mi->bg, mi->x, mi->y); - ebits_resize(mi->bg, - mi->size.w + m->sel_border.l + m->sel_border.r, - mi->size.h + m->sel_border.t + m->sel_border.b); + ebits_resize(mi->bg, + mi->size.w + m->sel_border.l + + m->sel_border.r, + mi->size.h + m->sel_border.t + + m->sel_border.b); ebits_show(mi->bg); } } } m->redo_sel = 0; } - - if ((m->current.x != m->previous.x) || - (m->current.y != m->previous.y)) - location_changed = 1; - if ((m->current.w != m->previous.w) || - (m->current.h != m->previous.h)) - size_changed = 1; - + + if ((m->current.x != m->previous.x) || (m->current.y != m->previous.y)) + location_changed = 1; + if ((m->current.w != m->previous.w) || (m->current.h != m->previous.h)) + size_changed = 1; + if ((location_changed) && (size_changed)) { - ecore_window_move_resize(m->win.main, m->current.x, m->current.y, m->current.w, m->current.h); + ecore_window_move_resize(m->win.main, m->current.x, m->current.y, + m->current.w, m->current.h); e_menu_obscure_outside_screen(m); } else if (location_changed) @@ -1729,38 +1835,42 @@ e_menu_update_base(E_Menu *m) ecore_window_resize(m->win.evas, m->current.w, m->current.h); evas_set_output_size(m->evas, m->current.w, m->current.h); evas_set_output_viewport(m->evas, 0, 0, m->current.w, m->current.h); - if (m->bg) ebits_resize(m->bg, m->current.w, m->current.h); + if (m->bg) + ebits_resize(m->bg, m->current.w, m->current.h); } D_RETURN; } void -e_menu_update_finish(E_Menu *m) +e_menu_update_finish(E_Menu * m) { D_ENTER; - - if (!m->changed) D_RETURN; + + if (!m->changed) + D_RETURN; m->previous = m->current; m->changed = 0; - + D_RETURN; } void -e_menu_update_shows(E_Menu *m) +e_menu_update_shows(E_Menu * m) { D_ENTER; - if (!m->changed) D_RETURN; + if (!m->changed) + D_RETURN; if (m->current.visible != m->previous.visible) { - if (m->current.visible) + if (m->current.visible) { ecore_window_raise(m->win.main); e_menu_event_win_show(); ecore_window_show(m->win.main); - if (!open_menus) keyboard_nav = 0; + if (!open_menus) + keyboard_nav = 0; open_menus = evas_list_append(open_menus, m); } } @@ -1769,19 +1879,20 @@ e_menu_update_shows(E_Menu *m) } void -e_menu_update_hides(E_Menu *m) +e_menu_update_hides(E_Menu * m) { D_ENTER; - if (!m->changed) D_RETURN; + if (!m->changed) + D_RETURN; if (m->current.visible != m->previous.visible) { if (!m->current.visible) { if (m->selected) { - E_Menu_Item *mi; - + E_Menu_Item *mi; + mi = m->selected; mi->selected = 0; e_menu_set_sel(m, mi); @@ -1790,9 +1901,11 @@ e_menu_update_hides(E_Menu *m) if (mi->bg) { ebits_move(mi->bg, mi->x, mi->y); - ebits_resize(mi->bg, - mi->size.w + m->sel_border.l + m->sel_border.r, - mi->size.h + m->sel_border.t + m->sel_border.b); + ebits_resize(mi->bg, + mi->size.w + m->sel_border.l + + m->sel_border.r, + mi->size.h + m->sel_border.t + + m->sel_border.b); ebits_show(mi->bg); } } @@ -1802,9 +1915,10 @@ e_menu_update_hides(E_Menu *m) } open_menus = evas_list_remove(open_menus, m); ecore_window_hide(m->win.main); - if (!open_menus) e_menu_event_win_hide(); + if (!open_menus) + e_menu_event_win_hide(); if (m->func_hide) - m->func_hide(m, m->func_hide_data); + m->func_hide(m, m->func_hide_data); } } @@ -1812,7 +1926,7 @@ e_menu_update_hides(E_Menu *m) } void -e_menu_update(E_Menu *m) +e_menu_update(E_Menu * m) { D_ENTER; @@ -1825,14 +1939,15 @@ e_menu_update(E_Menu *m) } void -e_menu_item_set_icon(E_Menu_Item *mi, char *icon) +e_menu_item_set_icon(E_Menu_Item * mi, char *icon) { D_ENTER; IF_FREE(mi->icon); mi->icon = NULL; - if (icon) mi->icon = strdup(icon); - if (mi->menu) + if (icon) + mi->icon = strdup(icon); + if (mi->menu) { mi->menu->recalc_entries = 1; mi->menu->changed = 1; @@ -1842,14 +1957,15 @@ e_menu_item_set_icon(E_Menu_Item *mi, char *icon) } void -e_menu_item_set_text(E_Menu_Item *mi, char *text) +e_menu_item_set_text(E_Menu_Item * mi, char *text) { D_ENTER; IF_FREE(mi->str); mi->str = NULL; - if (text) mi->str = strdup(text); - if (mi->menu) + if (text) + mi->str = strdup(text); + if (mi->menu) { mi->menu->recalc_entries = 1; mi->menu->changed = 1; @@ -1859,12 +1975,12 @@ e_menu_item_set_text(E_Menu_Item *mi, char *text) } void -e_menu_item_set_separator(E_Menu_Item *mi, int sep) +e_menu_item_set_separator(E_Menu_Item * mi, int sep) { D_ENTER; mi->separator = sep; - if (mi->menu) + if (mi->menu) { mi->menu->recalc_entries = 1; mi->menu->changed = 1; @@ -1874,12 +1990,12 @@ e_menu_item_set_separator(E_Menu_Item *mi, int sep) } void -e_menu_item_set_radio(E_Menu_Item *mi, int radio) +e_menu_item_set_radio(E_Menu_Item * mi, int radio) { D_ENTER; mi->radio = radio; - if (mi->menu) + if (mi->menu) { mi->menu->recalc_entries = 1; mi->menu->changed = 1; @@ -1889,12 +2005,12 @@ e_menu_item_set_radio(E_Menu_Item *mi, int radio) } void -e_menu_item_set_check(E_Menu_Item *mi, int check) +e_menu_item_set_check(E_Menu_Item * mi, int check) { D_ENTER; mi->check = check; - if (mi->menu) + if (mi->menu) { mi->menu->recalc_entries = 1; mi->menu->changed = 1; @@ -1904,12 +2020,12 @@ e_menu_item_set_check(E_Menu_Item *mi, int check) } void -e_menu_item_set_state(E_Menu_Item *mi, int state) +e_menu_item_set_state(E_Menu_Item * mi, int state) { D_ENTER; mi->on = state; - if (mi->menu) + if (mi->menu) { mi->menu->recalc_entries = 1; mi->menu->redo_sel = 1; @@ -1920,13 +2036,14 @@ e_menu_item_set_state(E_Menu_Item *mi, int state) } void -e_menu_item_set_submenu(E_Menu_Item *mi, E_Menu *submenu) +e_menu_item_set_submenu(E_Menu_Item * mi, E_Menu * submenu) { D_ENTER; - if (mi->submenu) e_menu_hide(mi->submenu); + if (mi->submenu) + e_menu_hide(mi->submenu); mi->submenu = submenu; - if (mi->menu) + if (mi->menu) { mi->menu->recalc_entries = 1; mi->menu->redo_sel = 1; @@ -1937,22 +2054,22 @@ e_menu_item_set_submenu(E_Menu_Item *mi, E_Menu *submenu) } void -e_menu_item_set_scale_icon(E_Menu_Item *mi, int scale) +e_menu_item_set_scale_icon(E_Menu_Item * mi, int scale) { D_ENTER; mi->scale_icon = scale; - if (mi->menu) + if (mi->menu) { mi->menu->recalc_entries = 1; mi->menu->changed = 1; - } + } D_RETURN; } void -e_menu_set_padding_icon(E_Menu *m, int pad) +e_menu_set_padding_icon(E_Menu * m, int pad) { D_ENTER; @@ -1964,7 +2081,7 @@ e_menu_set_padding_icon(E_Menu *m, int pad) } void -e_menu_set_padding_state(E_Menu *m, int pad) +e_menu_set_padding_state(E_Menu * m, int pad) { D_ENTER; diff --git a/src/menu.h b/src/menu.h index 66c5f0e58..b30899759 100644 --- a/src/menu.h +++ b/src/menu.h @@ -4,141 +4,161 @@ #include "e.h" #include "object.h" -typedef struct _E_Menu E_Menu; -typedef struct _E_Menu_Item E_Menu_Item; +typedef struct _E_Menu E_Menu; +typedef struct _E_Menu_Item E_Menu_Item; struct _E_Menu { - E_Object o; - - struct { - int x, y, w, h; - int visible; - } current, previous; - struct { - int l, r, t, b; - } border, sel_border; - struct { - Window main, evas; - } win; - Evas evas; - Ebits_Object bg; - Evas_List entries; - char *bg_file; - - int first_expose; + E_Object o; - int recalc_entries; - int redo_sel; - int changed; - - int delete_me; - - struct { - int state, icon, text; - } size; - struct { - int icon, state; - } pad; - - E_Menu_Item *selected; - - Time time; + struct + { + int x, y, w, h; + int visible; + } + current , previous; + struct + { + int l, r, t, b; + } + border , sel_border; + struct + { + Window main, evas; + } + win; + Evas evas; + Ebits_Object bg; + Evas_List entries; + char *bg_file; - void (*func_hide) (E_Menu *m, void *data); - void *func_hide_data; + int first_expose; + + int recalc_entries; + int redo_sel; + int changed; + + int delete_me; + + struct + { + int state, icon, text; + } + size; + struct + { + int icon, state; + } + pad; + + E_Menu_Item *selected; + + Time time; + + void (*func_hide) (E_Menu * m, void *data); + void *func_hide_data; }; struct _E_Menu_Item { - int x, y; - struct { - struct { - int w, h; - } min; - int w, h; - } size; - - Ebits_Object bg; - char *bg_file; - int selected; + int x, y; + struct + { + struct + { + int w, h; + } + min; + int w, h; + } + size; - Evas_Object obj_entry; - - char *str; - Evas_Object obj_text; - - char *icon; - Evas_Object obj_icon; - int scale_icon; - - Ebits_Object state; - char *state_file; - - Ebits_Object sep; - char *sep_file; - - int separator; - int radio_group; - int radio; - int check; - int on; - - E_Menu *menu; - E_Menu *submenu; - - void (*func_select) (E_Menu *m, E_Menu_Item *mi, void *data); - void *func_select_data; + Ebits_Object bg; + char *bg_file; + int selected; + + Evas_Object obj_entry; + + char *str; + Evas_Object obj_text; + + char *icon; + Evas_Object obj_icon; + int scale_icon; + + Ebits_Object state; + char *state_file; + + Ebits_Object sep; + char *sep_file; + + int separator; + int radio_group; + int radio; + int check; + int on; + + E_Menu *menu; + E_Menu *submenu; + + void (*func_select) (E_Menu * m, E_Menu_Item * mi, + void *data); + void *func_select_data; }; - /** * e_menu_init - Menu event handling initalization. * * This function hooks in the necessary event handlers for * menu handling. */ -void e_menu_init(void ); +void e_menu_init(void); -void e_menu_callback_item(E_Menu *m, E_Menu_Item *mi); -void e_menu_item_set_callback(E_Menu_Item *mi, void (*func) (E_Menu *m, E_Menu_Item *mi, void *data), void *data); -void e_menu_hide_callback(E_Menu *m, void (*func) (E_Menu *m, void *data), void *data); -void e_menu_hide_submenus(E_Menu *menus_after); -void e_menu_select(int dx, int dy); -void e_menu_event_win_show(void ); -void e_menu_event_win_hide(void ); -void e_menu_set_background(E_Menu *m); -void e_menu_set_sel(E_Menu *m, E_Menu_Item *mi); -void e_menu_set_sep(E_Menu *m, E_Menu_Item *mi); -void e_menu_set_state(E_Menu *m, E_Menu_Item *mi); -E_Menu *e_menu_new(void ); -void e_menu_hide(E_Menu *m); -void e_menu_show(E_Menu *m); -void e_menu_move_to(E_Menu *m, int x, int y); -void e_menu_show_at_mouse(E_Menu *m, int x, int y, Time t); -void e_menu_add_item(E_Menu *m, E_Menu_Item *mi); -void e_menu_del_item(E_Menu *m, E_Menu_Item *mi); -void e_menu_item_update(E_Menu *m, E_Menu_Item *mi); -void e_menu_item_unrealize(E_Menu *m, E_Menu_Item *mi); -void e_menu_item_realize(E_Menu *m, E_Menu_Item *mi); -E_Menu_Item *e_menu_item_new(char *str); -void e_menu_obscure_outside_screen(E_Menu *m); -void e_menu_scroll_all_by(int dx, int dy); -void e_menu_update_visibility(E_Menu *m); -void e_menu_update_base(E_Menu *m); -void e_menu_update_finish(E_Menu *m); -void e_menu_update_shows(E_Menu *m); -void e_menu_update_hides(E_Menu *m); -void e_menu_update(E_Menu *m); -void e_menu_item_set_icon(E_Menu_Item *mi, char *icon); -void e_menu_item_set_text(E_Menu_Item *mi, char *text); -void e_menu_item_set_separator(E_Menu_Item *mi, int sep); -void e_menu_item_set_radio(E_Menu_Item *mi, int radio); -void e_menu_item_set_check(E_Menu_Item *mi, int check); -void e_menu_item_set_state(E_Menu_Item *mi, int state); -void e_menu_item_set_submenu(E_Menu_Item *mi, E_Menu *submenu); -void e_menu_item_set_scale_icon(E_Menu_Item *mi, int scale); -void e_menu_set_padding_icon(E_Menu *m, int pad); -void e_menu_set_padding_state(E_Menu *m, int pad); +void e_menu_callback_item(E_Menu * m, E_Menu_Item * mi); +void e_menu_item_set_callback(E_Menu_Item * mi, + void (*func) (E_Menu * m, + E_Menu_Item * mi, + void *data), + void *data); +void e_menu_hide_callback(E_Menu * m, + void (*func) (E_Menu * m, void *data), + void *data); +void e_menu_hide_submenus(E_Menu * menus_after); +void e_menu_select(int dx, int dy); +void e_menu_event_win_show(void); +void e_menu_event_win_hide(void); +void e_menu_set_background(E_Menu * m); +void e_menu_set_sel(E_Menu * m, E_Menu_Item * mi); +void e_menu_set_sep(E_Menu * m, E_Menu_Item * mi); +void e_menu_set_state(E_Menu * m, E_Menu_Item * mi); +E_Menu *e_menu_new(void); +void e_menu_hide(E_Menu * m); +void e_menu_show(E_Menu * m); +void e_menu_move_to(E_Menu * m, int x, int y); +void e_menu_show_at_mouse(E_Menu * m, int x, int y, Time t); +void e_menu_add_item(E_Menu * m, E_Menu_Item * mi); +void e_menu_del_item(E_Menu * m, E_Menu_Item * mi); +void e_menu_item_update(E_Menu * m, E_Menu_Item * mi); +void e_menu_item_unrealize(E_Menu * m, E_Menu_Item * mi); +void e_menu_item_realize(E_Menu * m, E_Menu_Item * mi); +E_Menu_Item *e_menu_item_new(char *str); +void e_menu_obscure_outside_screen(E_Menu * m); +void e_menu_scroll_all_by(int dx, int dy); +void e_menu_update_visibility(E_Menu * m); +void e_menu_update_base(E_Menu * m); +void e_menu_update_finish(E_Menu * m); +void e_menu_update_shows(E_Menu * m); +void e_menu_update_hides(E_Menu * m); +void e_menu_update(E_Menu * m); +void e_menu_item_set_icon(E_Menu_Item * mi, char *icon); +void e_menu_item_set_text(E_Menu_Item * mi, char *text); +void e_menu_item_set_separator(E_Menu_Item * mi, int sep); +void e_menu_item_set_radio(E_Menu_Item * mi, int radio); +void e_menu_item_set_check(E_Menu_Item * mi, int check); +void e_menu_item_set_state(E_Menu_Item * mi, int state); +void e_menu_item_set_submenu(E_Menu_Item * mi, E_Menu * submenu); +void e_menu_item_set_scale_icon(E_Menu_Item * mi, int scale); +void e_menu_set_padding_icon(E_Menu * m, int pad); +void e_menu_set_padding_state(E_Menu * m, int pad); #endif diff --git a/src/menubuild.c b/src/menubuild.c index b724b2cf2..29c69bd77 100644 --- a/src/menubuild.c +++ b/src/menubuild.c @@ -11,32 +11,38 @@ # include "e_ferite.h" #endif -Evas_List build_menus = NULL; +Evas_List build_menus = NULL; -static void e_build_menu_cb_exec(E_Menu *m, E_Menu_Item *mi, void *data); -static void e_build_menu_cb_exec(E_Menu *m, E_Menu_Item *mi, void *data); +static void e_build_menu_cb_exec(E_Menu * m, E_Menu_Item * mi, + void *data); +static void e_build_menu_cb_exec(E_Menu * m, E_Menu_Item * mi, + void *data); -static void e_build_menu_unbuild(E_Build_Menu *bm); +static void e_build_menu_unbuild(E_Build_Menu * bm); -static void e_build_menu_db_poll(int val, void *data); -static E_Menu *e_build_menu_db_build_number(E_Build_Menu *bm, E_DB_File *db, int num); -static void e_build_menu_db_build(E_Build_Menu *bm); +static void e_build_menu_db_poll(int val, void *data); +static E_Menu *e_build_menu_db_build_number(E_Build_Menu * bm, + E_DB_File * db, int num); +static void e_build_menu_db_build(E_Build_Menu * bm); -static void e_build_menu_gnome_apps_poll(int val, void *data); -static void e_build_menu_gnome_apps_build(E_Build_Menu *bm); - -static E_Menu *e_build_menu_iconified_borders_build(E_Build_Menu *bm); -static void e_build_menu_iconified_borders_changed(E_Observer *observer, E_Observee *observee, E_Event_Type event); +static void e_build_menu_gnome_apps_poll(int val, void *data); +static void e_build_menu_gnome_apps_build(E_Build_Menu * bm); +static E_Menu *e_build_menu_iconified_borders_build(E_Build_Menu * bm); +static void e_build_menu_iconified_borders_changed(E_Observer * + observer, + E_Observee * + observee, + E_Event_Type event); /* ------------ various callbacks ---------------------- */ -static void -e_build_menu_cb_exec(E_Menu *m, E_Menu_Item *mi, void *data) +static void +e_build_menu_cb_exec(E_Menu * m, E_Menu_Item * mi, void *data) { - char *exe; + char *exe; D_ENTER; - + exe = data; e_exec_run(exe); @@ -45,35 +51,35 @@ e_build_menu_cb_exec(E_Menu *m, E_Menu_Item *mi, void *data) UN(mi); } -static void -e_build_menu_cb_uniconify(E_Menu *m, E_Menu_Item *mi, void *data) +static void +e_build_menu_cb_uniconify(E_Menu * m, E_Menu_Item * mi, void *data) { - E_Border *b; + E_Border *b; D_ENTER; - + b = data; e_border_uniconify(b); - + D_RETURN; UN(m); UN(mi); } -static void -e_build_menu_cb_script(E_Menu *m, E_Menu_Item *mi, void *data) +static void +e_build_menu_cb_script(E_Menu * m, E_Menu_Item * mi, void *data) { - char *script; + char *script; D_ENTER; - + #ifdef USE_FERITE script = data; e_ferite_run(script); #else D("No cookies for you. You will have to install ferite.\n"); #endif - + D_RETURN; UN(m); UN(mi); @@ -84,19 +90,19 @@ e_build_menu_cb_script(E_Menu *m, E_Menu_Item *mi, void *data) /*--------------------------------------------------------*/ static void -e_build_menu_unbuild(E_Build_Menu *bm) +e_build_menu_unbuild(E_Build_Menu * bm) { - Evas_List l; - + Evas_List l; + D_ENTER; - + bm->menu = NULL; if (bm->menus) { for (l = bm->menus; l; l = l->next) { - E_Menu *m; - + E_Menu *m; + m = l->data; e_menu_hide(m); e_menu_update_shows(m); @@ -119,31 +125,30 @@ e_build_menu_unbuild(E_Build_Menu *bm) D_RETURN; } - /* BUILDING from DB's */ - static void e_build_menu_db_poll(int val, void *data) { - time_t mod; - E_Build_Menu *bm; - + time_t mod; + E_Build_Menu *bm; + D_ENTER; - + bm = data; mod = e_file_mod_time(bm->file); - if (mod <= bm->mod_time) + if (mod <= bm->mod_time) { ecore_add_event_timer(bm->file, 1.0, e_build_menu_db_poll, 0, data); D_RETURN; } bm->mod_time = mod; - + e_build_menu_unbuild(bm); e_build_menu_db_build(bm); - if (!bm->menu) bm->mod_time = 0; - + if (!bm->menu) + bm->mod_time = 0; + ecore_add_event_timer(bm->file, 1.0, e_build_menu_db_poll, 0, data); D_RETURN; @@ -153,50 +158,53 @@ e_build_menu_db_poll(int val, void *data) static void e_build_menu_gnome_apps_poll(int val, void *data) { - time_t mod; - E_Build_Menu *bm; - + time_t mod; + E_Build_Menu *bm; + D_ENTER; - + bm = data; mod = e_file_mod_time(bm->file); - if (mod <= bm->mod_time) + if (mod <= bm->mod_time) { - ecore_add_event_timer(bm->file, 1.0, e_build_menu_gnome_apps_poll, 0, data); + ecore_add_event_timer(bm->file, 1.0, e_build_menu_gnome_apps_poll, 0, + data); D_RETURN; } bm->mod_time = mod; - + e_build_menu_unbuild(bm); e_build_menu_gnome_apps_build(bm); - if (!bm->menu) bm->mod_time = 0; - + if (!bm->menu) + bm->mod_time = 0; + ecore_add_event_timer(bm->file, 1.0, e_build_menu_gnome_apps_poll, 0, data); D_RETURN; UN(val); } -static E_Menu * -e_build_menu_db_build_number(E_Build_Menu *bm, E_DB_File *db, int num) +static E_Menu * +e_build_menu_db_build_number(E_Build_Menu * bm, E_DB_File * db, int num) { - E_Menu *menu; - char buf[PATH_MAX]; - int num2, i2; - + E_Menu *menu; + char buf[PATH_MAX]; + int num2, i2; + D_ENTER; - + snprintf(buf, PATH_MAX, "/menu/%i/count", num); - if (!e_db_int_get(db, buf, &num2)) D_RETURN_(NULL); + if (!e_db_int_get(db, buf, &num2)) + D_RETURN_(NULL); menu = e_menu_new(); e_menu_set_padding_icon(menu, 2); e_menu_set_padding_state(menu, 2); for (i2 = 0; i2 < num2; i2++) { - E_Menu_Item *menuitem; - char *text, *icon, *exe, *script; - int ok, sub, sep; - + E_Menu_Item *menuitem; + char *text, *icon, *exe, *script; + int ok, sub, sep; + snprintf(buf, PATH_MAX, "/menu/%i/%i/text", num, i2); text = e_db_str_get(db, buf); snprintf(buf, PATH_MAX, "/menu/%i/%i/icon", num, i2); @@ -212,16 +220,18 @@ e_build_menu_db_build_number(E_Build_Menu *bm, E_DB_File *db, int num) e_db_int_get(db, buf, &sep); menuitem = e_menu_item_new(text); e_menu_item_set_icon(menuitem, icon); - if ((icon) && (text)) e_menu_item_set_scale_icon(menuitem, 1); + if ((icon) && (text)) + e_menu_item_set_scale_icon(menuitem, 1); IF_FREE(text); IF_FREE(icon); - if (sep) e_menu_item_set_separator(menuitem, 1); + if (sep) + e_menu_item_set_separator(menuitem, 1); else { if (ok) { - E_Menu *menu2; - + E_Menu *menu2; + menu2 = e_build_menu_db_build_number(bm, db, sub); e_menu_item_set_submenu(menuitem, menu2); } @@ -231,11 +241,11 @@ e_build_menu_db_build_number(E_Build_Menu *bm, E_DB_File *db, int num) e_menu_item_set_callback(menuitem, e_build_menu_cb_exec, exe); bm->commands = evas_list_prepend(bm->commands, exe); } - if( script ) - { - e_menu_item_set_callback(menuitem, e_build_menu_cb_script, script); - bm->commands = evas_list_prepend(bm->commands, script); - } + if (script) + { + e_menu_item_set_callback(menuitem, e_build_menu_cb_script, script); + bm->commands = evas_list_prepend(bm->commands, script); + } e_menu_add_item(menu, menuitem); } bm->menus = evas_list_prepend(bm->menus, menu); @@ -244,104 +254,106 @@ e_build_menu_db_build_number(E_Build_Menu *bm, E_DB_File *db, int num) } static void -e_build_menu_db_build(E_Build_Menu *bm) +e_build_menu_db_build(E_Build_Menu * bm) { - E_DB_File *db; - int num; - + E_DB_File *db; + int num; + D_ENTER; - + e_db_flush(); db = e_db_open_read(bm->file); - if (!db) D_RETURN; - - if (!e_db_int_get(db, "/menu/count", &num)) goto error; - if (num > 0) bm->menu = e_build_menu_db_build_number(bm, db, 0); - error: + if (!db) + D_RETURN; + + if (!e_db_int_get(db, "/menu/count", &num)) + goto error; + if (num > 0) + bm->menu = e_build_menu_db_build_number(bm, db, 0); + error: e_db_close(db); D_RETURN; } - /* BUILD from GNOME APPS directory structure */ - -static E_Menu * -e_build_menu_gnome_apps_build_dir(E_Build_Menu *bm, char *dir) +static E_Menu * +e_build_menu_gnome_apps_build_dir(E_Build_Menu * bm, char *dir) { - E_Menu *menu = NULL; - Evas_List l, entries = NULL; - + E_Menu *menu = NULL; + Evas_List l, entries = NULL; + D_ENTER; - + menu = e_menu_new(); e_menu_set_padding_icon(menu, 2); e_menu_set_padding_state(menu, 2); - /* build the order of things to scan ...*/ - { - FILE *f; - char buf[PATH_MAX]; - Evas_List dirlist = NULL; - - /* read .order file */ - snprintf(buf, PATH_MAX, "%s/.order", dir); - f = fopen(buf, "rb"); - if (f) - { - while (fgets(buf, PATH_MAX, f)) - { - int buf_len; - - buf_len = strlen(buf); - if (buf_len > 0) - { - if (buf[buf_len - 1] == '\n') - buf[buf_len - 1] = 0; - entries = evas_list_append(entries, strdup(buf)); - } - } - fclose(f); - } - /* read dir listing in alphabetical order and use that to suppliment */ - dirlist = e_file_ls(dir); - for (l = dirlist; l; l = l->next) - { - char *s; - - s = l->data; - /* if it isnt a "dot" file or dir */ - if (s[0] != '.') - { - Evas_List ll; - int have_it; - - have_it = 0; - for (ll = entries; ll; ll = ll->next) - { - if (!strcmp(ll->data, s)) - { - have_it = 1; - break; - } - } - if (!have_it) - entries = evas_list_append(entries, strdup(s)); - } - free(s); - } - if (dirlist) evas_list_free(dirlist); - } + /* build the order of things to scan ... */ + { + FILE *f; + char buf[PATH_MAX]; + Evas_List dirlist = NULL; + + /* read .order file */ + snprintf(buf, PATH_MAX, "%s/.order", dir); + f = fopen(buf, "rb"); + if (f) + { + while (fgets(buf, PATH_MAX, f)) + { + int buf_len; + + buf_len = strlen(buf); + if (buf_len > 0) + { + if (buf[buf_len - 1] == '\n') + buf[buf_len - 1] = 0; + entries = evas_list_append(entries, strdup(buf)); + } + } + fclose(f); + } + /* read dir listing in alphabetical order and use that to suppliment */ + dirlist = e_file_ls(dir); + for (l = dirlist; l; l = l->next) + { + char *s; + + s = l->data; + /* if it isnt a "dot" file or dir */ + if (s[0] != '.') + { + Evas_List ll; + int have_it; + + have_it = 0; + for (ll = entries; ll; ll = ll->next) + { + if (!strcmp(ll->data, s)) + { + have_it = 1; + break; + } + } + if (!have_it) + entries = evas_list_append(entries, strdup(s)); + } + free(s); + } + if (dirlist) + evas_list_free(dirlist); + } /* now go thru list... */ for (l = entries; l; l = l->next) { - char *s; - char buf[PATH_MAX]; - E_Menu_Item *menuitem; - char *icon, *name, *exe; - E_Menu *sub; - FILE *f; - + char *s; + char buf[PATH_MAX]; + E_Menu_Item *menuitem; + char *icon, *name, *exe; + E_Menu *sub; + FILE *f; + f = NULL; icon = NULL; exe = NULL; @@ -354,52 +366,54 @@ e_build_menu_gnome_apps_build_dir(E_Build_Menu *bm, char *dir) { sub = e_build_menu_gnome_apps_build_dir(bm, buf); snprintf(buf, PATH_MAX, "%s/%s/.directory", dir, s); - + f = fopen(buf, "rb"); } /* regular file */ else if (e_file_exists(buf)) { snprintf(buf, PATH_MAX, "%s/%s", dir, s); - + f = fopen(buf, "rb"); } /* doesnt exist at all? next item */ - else continue; + else + continue; if (f) { while (fgets(buf, PATH_MAX, f)) { - int buf_len; - + int buf_len; + buf_len = strlen(buf); if (buf_len > 0) { if (buf[buf_len - 1] == '\n') - buf[buf_len - 1] = 0; + buf[buf_len - 1] = 0; /* look for Name= */ if ((!name) && (((e_util_glob_matches(buf, "Name[en]=*")) || (e_util_glob_matches(buf, "Name=*"))))) { - char *eq; - + char *eq; + eq = strchr(buf, '='); if (eq) - name = strdup(eq + 1); + name = strdup(eq + 1); } /* look for Icon= */ else if ((!icon) && ((e_util_glob_matches(buf, "Icon=*")))) { - char *eq; - + char *eq; + eq = strchr(buf, '='); if (eq) { - char buf2[PATH_MAX]; - - snprintf(buf2, PATH_MAX, "/usr/share/pixmaps/%s", eq +1); + char buf2[PATH_MAX]; + + snprintf(buf2, PATH_MAX, + "/usr/share/pixmaps/%s", eq + 1); icon = strdup(buf2); } } @@ -407,46 +421,51 @@ e_build_menu_gnome_apps_build_dir(E_Build_Menu *bm, char *dir) else if ((!exe) && ((e_util_glob_matches(buf, "Exec=*")))) { - char *eq; - + char *eq; + eq = strchr(buf, '='); if (eq) - exe = strdup(eq + 1); + exe = strdup(eq + 1); } - } + } } fclose(f); } - - if (!name) name = strdup(s); + + if (!name) + name = strdup(s); menuitem = e_menu_item_new(name); - if (icon) e_menu_item_set_icon(menuitem, icon); - if ((icon) && (name)) e_menu_item_set_scale_icon(menuitem, 1); + if (icon) + e_menu_item_set_icon(menuitem, icon); + if ((icon) && (name)) + e_menu_item_set_scale_icon(menuitem, 1); if (exe) { e_menu_item_set_callback(menuitem, e_build_menu_cb_exec, exe); - bm->commands = evas_list_prepend(bm->commands, exe); + bm->commands = evas_list_prepend(bm->commands, exe); } - if (sub) e_menu_item_set_submenu(menuitem, sub); + if (sub) + e_menu_item_set_submenu(menuitem, sub); e_menu_add_item(menu, menuitem); - + IF_FREE(name); IF_FREE(icon); free(s); } - if (entries) evas_list_free(entries); - bm->menus = evas_list_prepend(bm->menus, menu); + if (entries) + evas_list_free(entries); + bm->menus = evas_list_prepend(bm->menus, menu); D_RETURN_(menu); } static void -e_build_menu_gnome_apps_build(E_Build_Menu *bm) +e_build_menu_gnome_apps_build(E_Build_Menu * bm) { - E_Menu *menu; - + E_Menu *menu; + D_ENTER; - + menu = e_build_menu_gnome_apps_build_dir(bm, bm->file); bm->menu = menu; @@ -454,14 +473,14 @@ e_build_menu_gnome_apps_build(E_Build_Menu *bm) } static void -e_build_menu_cleanup(E_Build_Menu *bm) +e_build_menu_cleanup(E_Build_Menu * bm) { D_ENTER; - + ecore_del_event_timer(bm->file); e_build_menu_unbuild(bm); IF_FREE(bm->file); - build_menus = evas_list_remove(build_menus, bm); + build_menus = evas_list_remove(build_menus, bm); /* Call the destructor of the base class */ e_object_cleanup(E_OBJECT(bm)); @@ -469,42 +488,44 @@ e_build_menu_cleanup(E_Build_Menu *bm) D_RETURN; } -E_Build_Menu * +E_Build_Menu * e_build_menu_new_from_db(char *file) { - E_Build_Menu *bm; - + E_Build_Menu *bm; + D_ENTER; - - if (!file) D_RETURN_(NULL); + + if (!file) + D_RETURN_(NULL); bm = NEW(E_Build_Menu, 1); ZERO(bm, E_Build_Menu, 1); e_object_init(E_OBJECT(bm), (E_Cleanup_Func) e_build_menu_cleanup); - + bm->file = strdup(file); - - build_menus = evas_list_prepend(build_menus, bm); - e_build_menu_db_poll(0, bm); + + build_menus = evas_list_prepend(build_menus, bm); + e_build_menu_db_poll(0, bm); D_RETURN_(bm); } -E_Build_Menu * +E_Build_Menu * e_build_menu_new_from_gnome_apps(char *dir) { - E_Build_Menu *bm; - + E_Build_Menu *bm; + D_ENTER; - - if (!dir) D_RETURN_(NULL); + + if (!dir) + D_RETURN_(NULL); bm = NEW(E_Build_Menu, 1); ZERO(bm, E_Build_Menu, 1); e_object_init(E_OBJECT(bm), (E_Cleanup_Func) e_build_menu_cleanup); bm->file = strdup(dir); - + build_menus = evas_list_prepend(build_menus, bm); e_build_menu_gnome_apps_poll(0, bm); @@ -513,11 +534,11 @@ e_build_menu_new_from_gnome_apps(char *dir) /*------------------------- iconified borders menu ----------------*/ -E_Build_Menu * +E_Build_Menu * e_build_menu_new_from_iconified_borders() { - E_Build_Menu *bm; - Evas_List l; + E_Build_Menu *bm; + Evas_List l; D_ENTER; @@ -525,22 +546,25 @@ e_build_menu_new_from_iconified_borders() ZERO(bm, E_Build_Menu, 1); /* e_observer_init(E_OBSERVER(bm), E_EVENT_BORDER_ICONIFY | E_EVENT_BORDER_UNICONIFY | E_EVENT_BORDER_NEW, e_build_menu_iconified_borders_changed, (E_Cleanup_Func) e_build_menu_cleanup);*/ - e_observer_init(E_OBSERVER(bm), E_EVENT_BORDER_ALL, e_build_menu_iconified_borders_changed, (E_Cleanup_Func) e_build_menu_cleanup); + e_observer_init(E_OBSERVER(bm), E_EVENT_BORDER_ALL, + e_build_menu_iconified_borders_changed, + (E_Cleanup_Func) e_build_menu_cleanup); for (l = e_border_get_borders_list(); l; l = l->next) - { - E_Border *b = l->data; - e_observer_register_observee(E_OBSERVER(bm), E_OBSERVEE(b)); - } + { + E_Border *b = l->data; + + e_observer_register_observee(E_OBSERVER(bm), E_OBSERVEE(b)); + } bm->menu = e_build_menu_iconified_borders_build(bm); - + build_menus = evas_list_prepend(build_menus, bm); D_RETURN_(bm); } void -e_build_menu_iconified_borders_rebuild(E_Build_Menu *bm) +e_build_menu_iconified_borders_rebuild(E_Build_Menu * bm) { D_ENTER; @@ -552,65 +576,68 @@ e_build_menu_iconified_borders_rebuild(E_Build_Menu *bm) } static void -e_build_menu_iconified_borders_changed(E_Observer *observer, E_Observee *observee, E_Event_Type event) +e_build_menu_iconified_borders_changed(E_Observer * observer, + E_Observee * observee, + E_Event_Type event) { - E_Build_Menu *bm; - + E_Build_Menu *bm; + D_ENTER; if (event & E_EVENT_BORDER_NEW) - { - D("catch new border, register it\n"); - e_observer_register_observee(E_OBSERVER(observer), E_OBSERVEE(observee)); - } + { + D("catch new border, register it\n"); + e_observer_register_observee(E_OBSERVER(observer), + E_OBSERVEE(observee)); + } else if (event & E_EVENT_BORDER_DELETE) - { - bm = (E_Build_Menu *) observer; - bm->changed = 1; - } + { + bm = (E_Build_Menu *) observer; + bm->changed = 1; + } else if (event & (E_EVENT_BORDER_ICONIFY | E_EVENT_BORDER_UNICONIFY)) - { - D("catch iconify, set menu to changed\n"); - bm = (E_Build_Menu *)observer; - - bm->changed = 1; - } + { + D("catch iconify, set menu to changed\n"); + bm = (E_Build_Menu *) observer; + + bm->changed = 1; + } D_RETURN; } -static E_Menu * -e_build_menu_iconified_borders_build(E_Build_Menu *bm) +static E_Menu * +e_build_menu_iconified_borders_build(E_Build_Menu * bm) { - E_Menu *menu = NULL; - Evas_List l, entries = NULL; - + E_Menu *menu = NULL; + Evas_List l, entries = NULL; + D_ENTER; - + menu = e_menu_new(); e_menu_set_padding_icon(menu, 2); e_menu_set_padding_state(menu, 2); - + for (l = e_border_get_borders_list(); l; l = l->next) - { - E_Border *b; - char *name = NULL; - E_Menu_Item *menuitem; - - b = l->data; - - if (b->client.iconified) { - e_strdup(name, b->client.title); - D("adding menu item: %s\n", name); - menuitem = e_menu_item_new(name); - e_menu_item_set_callback(menuitem, e_build_menu_cb_uniconify, b); - e_menu_add_item(menu, menuitem); + E_Border *b; + char *name = NULL; + E_Menu_Item *menuitem; - IF_FREE(name); - } - } - bm->menus = evas_list_prepend(bm->menus, menu); + b = l->data; + + if (b->client.iconified) + { + e_strdup(name, b->client.title); + D("adding menu item: %s\n", name); + menuitem = e_menu_item_new(name); + e_menu_item_set_callback(menuitem, e_build_menu_cb_uniconify, b); + e_menu_add_item(menu, menuitem); + + IF_FREE(name); + } + } + bm->menus = evas_list_prepend(bm->menus, menu); D_RETURN_(menu); } diff --git a/src/menubuild.h b/src/menubuild.h index c5057dd45..7b065cfbd 100644 --- a/src/menubuild.h +++ b/src/menubuild.h @@ -5,26 +5,26 @@ #include "object.h" #include "observer.h" -typedef struct _E_Build_Menu E_Build_Menu; +typedef struct _E_Build_Menu E_Build_Menu; struct _E_Build_Menu { - E_Observer o; + E_Observer o; - char *file; - time_t mod_time; - - E_Menu *menu; - - Evas_List menus; - Evas_List commands; + char *file; + time_t mod_time; - int changed; + E_Menu *menu; + + Evas_List menus; + Evas_List commands; + + int changed; }; -E_Build_Menu *e_build_menu_new_from_db(char *file); -E_Build_Menu *e_build_menu_new_from_gnome_apps(char *dir); -E_Build_Menu *e_build_menu_new_from_iconified_borders(); +E_Build_Menu *e_build_menu_new_from_db(char *file); +E_Build_Menu *e_build_menu_new_from_gnome_apps(char *dir); +E_Build_Menu *e_build_menu_new_from_iconified_borders(); -void e_build_menu_iconified_borders_rebuild(E_Build_Menu *bm); +void e_build_menu_iconified_borders_rebuild(E_Build_Menu * bm); #endif diff --git a/src/object.c b/src/object.c index b658cde87..8b70e438c 100644 --- a/src/object.c +++ b/src/object.c @@ -2,78 +2,76 @@ #include "object.h" void -e_object_init(E_Object *obj, E_Cleanup_Func cleanup_func) +e_object_init(E_Object * obj, E_Cleanup_Func cleanup_func) { - D_ENTER; - - if (!obj) - D_RETURN; + D_ENTER; - memset(obj, 0, sizeof(E_Object)); - obj->references = 1; - obj->cleanup_func = cleanup_func; + if (!obj) + D_RETURN; - D_RETURN; + memset(obj, 0, sizeof(E_Object)); + obj->references = 1; + obj->cleanup_func = cleanup_func; + + D_RETURN; } -void -e_object_cleanup(E_Object *obj) -{ - D_ENTER; - - if (!obj) - D_RETURN; - - free(obj); - - D_RETURN; -} - - void -e_object_ref(E_Object *obj) +e_object_cleanup(E_Object * obj) { - D_ENTER; + D_ENTER; - if (!obj) - D_RETURN; + if (!obj) + D_RETURN; - obj->references++; - D("++ refcount on %p, now %i\n", obj, obj->references); + free(obj); - D_RETURN; + D_RETURN; +} + +void +e_object_ref(E_Object * obj) +{ + D_ENTER; + + if (!obj) + D_RETURN; + + obj->references++; + D("++ refcount on %p, now %i\n", obj, obj->references); + + D_RETURN; } int -e_object_unref(E_Object *obj) +e_object_unref(E_Object * obj) { - D_ENTER; + D_ENTER; - if (!obj) - D_RETURN_(-1); + if (!obj) + D_RETURN_(-1); - obj->references--; + obj->references--; - D("-- refcount on %p, now %i\n", obj, obj->references); + D("-- refcount on %p, now %i\n", obj, obj->references); - if (obj->references == 0 && obj->cleanup_func) - { - D("Refcount is zero, freeing.\n"); - obj->cleanup_func(obj); - D_RETURN_(0); - } + if (obj->references == 0 && obj->cleanup_func) + { + D("Refcount is zero, freeing.\n"); + obj->cleanup_func(obj); + D_RETURN_(0); + } - D_RETURN_(obj->references); + D_RETURN_(obj->references); } - int -e_object_get_usecount(E_Object *obj) +e_object_get_usecount(E_Object * obj) { - D_ENTER; + D_ENTER; - if (!obj) - D_RETURN_(-1); + if (!obj) + D_RETURN_(-1); - D_RETURN_(obj->references); + D_RETURN_(obj->references); } diff --git a/src/object.h b/src/object.h index 82964e528..9616ef710 100644 --- a/src/object.h +++ b/src/object.h @@ -6,14 +6,15 @@ #define E_OBJECT(x) ((E_Object*)(x)) -typedef void (*E_Cleanup_Func) (void *object); +typedef void (*E_Cleanup_Func) (void *object); typedef struct _e_object { - int references; - E_Cleanup_Func cleanup_func; - -} E_Object; + int references; + E_Cleanup_Func cleanup_func; + +} +E_Object; /** * e_object_init - Initializes an E object @@ -32,7 +33,7 @@ typedef struct _e_object * The final free() call has to happen in the root class, * here, it happens in e_object_cleanup(). */ -void e_object_init(E_Object *obj, E_Cleanup_Func cleanup_func); +void e_object_init(E_Object * obj, E_Cleanup_Func cleanup_func); /** * e_object_cleanup - Cleanup function for E_Objects @@ -43,13 +44,13 @@ void e_object_init(E_Object *obj, E_Cleanup_Func cleanup_func); * at the end. This is the place where the final free() * call occurs. */ -void e_object_cleanup(E_Object *obj); +void e_object_cleanup(E_Object * obj); /** * e_object_ref - Increment the reference count of this object * @obj: The object whose reference count to increase */ -void e_object_ref(E_Object *obj); +void e_object_ref(E_Object * obj); /** * e_object_unref - Decrememnt the reference count of this object @@ -62,7 +63,7 @@ void e_object_ref(E_Object *obj); * and works its way back to the root class's destructor, * e_object_cleanup(). */ -int e_object_unref(E_Object *obj); +int e_object_unref(E_Object * obj); /** * e_object_get_usecount - Returns the current use count @@ -73,6 +74,6 @@ int e_object_unref(E_Object *obj); * gets cleaned up by checking if the use count is one, * cleaning up, and then calling e_object_unref(). */ -int e_object_get_usecount(E_Object *obj); +int e_object_get_usecount(E_Object * obj); #endif diff --git a/src/observer.c b/src/observer.c index ccb1396ea..389bacdd5 100644 --- a/src/observer.c +++ b/src/observer.c @@ -3,172 +3,168 @@ #include "debug.h" #include "observer.h" -static Evas_List observers; +static Evas_List observers; void -e_observer_init(E_Observer *obs, E_Event_Type event, - E_Notify_Func notify_func, - E_Cleanup_Func cleanup_func) +e_observer_init(E_Observer * obs, E_Event_Type event, + E_Notify_Func notify_func, E_Cleanup_Func cleanup_func) { - D_ENTER; + D_ENTER; - if (!obs) - D_RETURN; + if (!obs) + D_RETURN; - memset(obs, 0, sizeof(E_Observer)); + memset(obs, 0, sizeof(E_Observer)); - obs->watched = NULL; - obs->event = event; - obs->notify_func = notify_func; + obs->watched = NULL; + obs->event = event; + obs->notify_func = notify_func; - e_object_init(E_OBJECT(obs), cleanup_func); + e_object_init(E_OBJECT(obs), cleanup_func); - observers = evas_list_append(observers, obs); + observers = evas_list_append(observers, obs); - D_RETURN; + D_RETURN; } void -e_observer_cleanup(E_Observer *obs) +e_observer_cleanup(E_Observer * obs) { - E_Observee *o = NULL; + E_Observee *o = NULL; - D_ENTER; + D_ENTER; - if (!obs) - D_RETURN; + if (!obs) + D_RETURN; - while (obs->watched) - { - o = E_OBSERVEE(obs->watched->data); - e_observer_unregister_observee(obs, o); - } + while (obs->watched) + { + o = E_OBSERVEE(obs->watched->data); + e_observer_unregister_observee(obs, o); + } - evas_list_remove(observers, obs); - /* Call the destructor of the base class */ - e_object_cleanup(E_OBJECT(obs)); + evas_list_remove(observers, obs); + /* Call the destructor of the base class */ + e_object_cleanup(E_OBJECT(obs)); - D_RETURN; + D_RETURN; } void -e_observer_register_observee(E_Observer *observer, E_Observee *observee) +e_observer_register_observee(E_Observer * observer, E_Observee * observee) { - D_ENTER; + D_ENTER; - if (!observer || !observee) - D_RETURN; + if (!observer || !observee) + D_RETURN; - observee->observers = evas_list_append(observee->observers, observer); - observer->watched = evas_list_append(observer->watched, observee); - D_RETURN; + observee->observers = evas_list_append(observee->observers, observer); + observer->watched = evas_list_append(observer->watched, observee); + D_RETURN; } void -e_observer_unregister_observee(E_Observer *observer, E_Observee *observee) +e_observer_unregister_observee(E_Observer * observer, E_Observee * observee) { - D_ENTER; + D_ENTER; - if (!observer || !observee) - D_RETURN; + if (!observer || !observee) + D_RETURN; - observee->observers = evas_list_remove(observee->observers, observer); - observer->watched = evas_list_remove(observer->watched, observee); + observee->observers = evas_list_remove(observee->observers, observer); + observer->watched = evas_list_remove(observer->watched, observee); - D_RETURN; + D_RETURN; } - /* --------------------- Observee code below */ -void -e_observee_init(E_Observee *obs, E_Cleanup_Func cleanup_func) -{ - D_ENTER; - - if (!obs) - D_RETURN; - - memset(obs, 0, sizeof(E_Observee)); - - e_object_init(E_OBJECT(obs), cleanup_func); - - D_RETURN; -} - - void -e_observee_notify_observers(E_Observee *o, E_Event_Type event) +e_observee_init(E_Observee * obs, E_Cleanup_Func cleanup_func) { - Evas_List obs_list = NULL; - E_Observer *obs = NULL; + D_ENTER; - D_ENTER; + if (!obs) + D_RETURN; - if (!o) - D_RETURN; + memset(obs, 0, sizeof(E_Observee)); - for (obs_list = o->observers; obs_list; obs_list = obs_list->next) - { - obs = E_OBSERVER(obs_list->data); + e_object_init(E_OBJECT(obs), cleanup_func); - /* check bit mask */ - if (obs->event & event) - { - obs->notify_func(obs, o, event); - } - } - - D_RETURN; + D_RETURN; } void -e_observee_notify_all_observers(E_Observee *o, E_Event_Type event) +e_observee_notify_observers(E_Observee * o, E_Event_Type event) { - Evas_List obs_list = NULL; - E_Observer *obs = NULL; + Evas_List obs_list = NULL; + E_Observer *obs = NULL; - D_ENTER; + D_ENTER; - if (!o) - D_RETURN; + if (!o) + D_RETURN; - for (obs_list = observers; obs_list; obs_list = obs_list->next) - { - obs = E_OBSERVER(obs_list->data); + for (obs_list = o->observers; obs_list; obs_list = obs_list->next) + { + obs = E_OBSERVER(obs_list->data); - /* check bit mask */ - if (obs->event & event) - { - obs->notify_func(obs, o, event); - } - } + /* check bit mask */ + if (obs->event & event) + { + obs->notify_func(obs, o, event); + } + } - D_RETURN; + D_RETURN; } void -e_observee_cleanup(E_Observee *obs) +e_observee_notify_all_observers(E_Observee * o, E_Event_Type event) { - E_Observer *observer = NULL; + Evas_List obs_list = NULL; + E_Observer *obs = NULL; - D_ENTER; + D_ENTER; - if (!obs) - D_RETURN; + if (!o) + D_RETURN; - if (e_object_get_usecount(E_OBJECT(obs)) == 1) - { - while (obs->observers) - { - observer = E_OBSERVER(obs->observers->data); - e_observer_unregister_observee(observer, obs); - } - } + for (obs_list = observers; obs_list; obs_list = obs_list->next) + { + obs = E_OBSERVER(obs_list->data); - /* Call the destructor of the base class */ - e_object_cleanup(E_OBJECT(obs)); + /* check bit mask */ + if (obs->event & event) + { + obs->notify_func(obs, o, event); + } + } - D_RETURN; + D_RETURN; } +void +e_observee_cleanup(E_Observee * obs) +{ + E_Observer *observer = NULL; + + D_ENTER; + + if (!obs) + D_RETURN; + + if (e_object_get_usecount(E_OBJECT(obs)) == 1) + { + while (obs->observers) + { + observer = E_OBSERVER(obs->observers->data); + e_observer_unregister_observee(observer, obs); + } + } + + /* Call the destructor of the base class */ + e_object_cleanup(E_OBJECT(obs)); + + D_RETURN; +} diff --git a/src/observer.h b/src/observer.h index cf4226363..1713455ce 100644 --- a/src/observer.h +++ b/src/observer.h @@ -15,51 +15,53 @@ typedef struct _e_observee E_Observee; typedef enum _e_event_type { /* basic event types */ - E_EVENT_BORDER_NEW = 1 << 0, - E_EVENT_BORDER_DELETE = 1 << 1, - E_EVENT_BORDER_FOCUS_IN = 1 << 2, - E_EVENT_BORDER_ICONIFY = 1 << 3, - E_EVENT_BORDER_UNICONIFY = 1 << 4, - E_EVENT_BORDER_MAXIMIZE = 1 << 5, - E_EVENT_BORDER_UNMAXIMIZE = 1 << 6, - E_EVENT_BORDER_MOVE = 1 << 7, - E_EVENT_BORDER_RESIZE = 1 << 8, - - E_EVENT_DESKTOP_NEW = 1 << 10, - E_EVENT_DESKTOP_DELETE = 1 << 11, - E_EVENT_DESKTOP_SWITCH = 1 << 12, + E_EVENT_BORDER_NEW = 1 << 0, + E_EVENT_BORDER_DELETE = 1 << 1, + E_EVENT_BORDER_FOCUS_IN = 1 << 2, + E_EVENT_BORDER_ICONIFY = 1 << 3, + E_EVENT_BORDER_UNICONIFY = 1 << 4, + E_EVENT_BORDER_MAXIMIZE = 1 << 5, + E_EVENT_BORDER_UNMAXIMIZE = 1 << 6, + E_EVENT_BORDER_MOVE = 1 << 7, + E_EVENT_BORDER_RESIZE = 1 << 8, + + E_EVENT_DESKTOP_NEW = 1 << 10, + E_EVENT_DESKTOP_DELETE = 1 << 11, + E_EVENT_DESKTOP_SWITCH = 1 << 12, /* meta event types */ - E_EVENT_BORDER_ALL = E_EVENT_BORDER_NEW | - E_EVENT_BORDER_DELETE | E_EVENT_BORDER_FOCUS_IN | - E_EVENT_BORDER_ICONIFY | E_EVENT_BORDER_UNICONIFY | - E_EVENT_BORDER_MAXIMIZE | E_EVENT_BORDER_UNMAXIMIZE, - E_EVENT_DESKTOP_ALL = E_EVENT_DESKTOP_NEW | - E_EVENT_DESKTOP_DELETE | E_EVENT_DESKTOP_SWITCH, - - /* ALL events */ - E_EVENT_MAX = 0xFFFFFFFF -} E_Event_Type; + E_EVENT_BORDER_ALL = E_EVENT_BORDER_NEW | + E_EVENT_BORDER_DELETE | E_EVENT_BORDER_FOCUS_IN | + E_EVENT_BORDER_ICONIFY | E_EVENT_BORDER_UNICONIFY | + E_EVENT_BORDER_MAXIMIZE | E_EVENT_BORDER_UNMAXIMIZE, + E_EVENT_DESKTOP_ALL = E_EVENT_DESKTOP_NEW | + E_EVENT_DESKTOP_DELETE | E_EVENT_DESKTOP_SWITCH, -typedef void(*E_Notify_Func)(E_Observer *observer, E_Observee *observee, E_Event_Type event); + /* ALL events */ + E_EVENT_MAX = 0xFFFFFFFF +} +E_Event_Type; + +typedef void (*E_Notify_Func) (E_Observer * observer, + E_Observee * observee, + E_Event_Type event); struct _e_observer { - E_Object obj; + E_Object obj; - Evas_List watched; /* list */ - E_Event_Type event; - E_Notify_Func notify_func; + Evas_List watched; /* list */ + E_Event_Type event; + E_Notify_Func notify_func; }; struct _e_observee { - E_Object obj; + E_Object obj; - Evas_List observers; /* list */ + Evas_List observers; /* list */ }; - /** * e_observer_init - Initializes an observer * @obs: The observer to initialize @@ -72,9 +74,9 @@ struct _e_observee * e_observee_notify_observers() call. Observers are derived from * E_Objects, therefore, this function also handles E_Object initalization. */ -void e_observer_init(E_Observer *obs, E_Event_Type event, - E_Notify_Func notify_func, - E_Cleanup_Func cleanup_func); +void e_observer_init(E_Observer * obs, E_Event_Type event, + E_Notify_Func notify_func, + E_Cleanup_Func cleanup_func); /** * e_observer_cleanup - Cleans up an observer. @@ -82,7 +84,7 @@ void e_observer_init(E_Observer *obs, E_Event_Type event, * * This function cleans up an observer by unregistering all observees. */ -void e_observer_cleanup(E_Observer *obs); +void e_observer_cleanup(E_Observer * obs); /** * e_observer_register_observee - Registers an observee @@ -91,7 +93,8 @@ void e_observer_cleanup(E_Observer *obs); * * This function registers the observer in the observee and vice versa. */ -void e_observer_register_observee(E_Observer *observer, E_Observee *observee); +void e_observer_register_observee(E_Observer * observer, + E_Observee * observee); /** * e_observer_unregister_observee - Unregisters an observee @@ -100,7 +103,8 @@ void e_observer_register_observee(E_Observer *observer, E_Observee *observee) * * This function unregisters the observer in the observee and vice versa. */ -void e_observer_unregister_observee(E_Observer *observer, E_Observee *observee); +void e_observer_unregister_observee(E_Observer * observer, + E_Observee * observee); /** * e_observee_init - Initializes an observee. @@ -111,7 +115,8 @@ void e_observer_unregister_observee(E_Observer *observer, E_Observee *observe * from E_Objects, which is why this function gets the destructor * function as a parameter. It is passed on to e_object_init(). */ -void e_observee_init(E_Observee *obs, E_Cleanup_Func cleanup_func); +void e_observee_init(E_Observee * obs, + E_Cleanup_Func cleanup_func); /** * e_observee_cleanup - Cleans up an observee. @@ -119,7 +124,7 @@ void e_observee_init(E_Observee *obs, E_Cleanup_Func cleanup_func); * * This function cleans up an observee by unregistering it from all observers. */ -void e_observee_cleanup(E_Observee *obs); +void e_observee_cleanup(E_Observee * obs); /** * e_observee_notify_observers - Notify observers of a given Ecore event @@ -130,8 +135,8 @@ void e_observee_cleanup(E_Observee *obs); * and calls the notify_func() of the observers that are * responsible for the given @event. */ -void e_observee_notify_observers(E_Observee *o, E_Event_Type event); - +void e_observee_notify_observers(E_Observee * o, + E_Event_Type event); /** * e_observee_notify_all_observers - Notify all observers of a given E event @@ -147,5 +152,6 @@ void e_observee_notify_observers(E_Observee *o, E_Event_Type event); * If they are looking for this type of NEW event, then they can register * it as a legitimate observee. */ -void e_observee_notify_all_observers(E_Observee *o, E_Event_Type event); +void e_observee_notify_all_observers(E_Observee * o, + E_Event_Type event); #endif diff --git a/src/place.c b/src/place.c index 599619030..41121fcfb 100644 --- a/src/place.c +++ b/src/place.c @@ -5,22 +5,23 @@ #include "guides.h" #include "util.h" -static void e_mouse_down(Ecore_Event * ev); -static void e_mouse_up(Ecore_Event * ev); -static void e_mouse_move(Ecore_Event * ev); +static void e_mouse_down(Ecore_Event * ev); +static void e_mouse_up(Ecore_Event * ev); +static void e_mouse_move(Ecore_Event * ev); -static int prx, pry; -static Window win_place = 0; +static int prx, pry; +static Window win_place = 0; static void e_mouse_down(Ecore_Event * ev) { - Ecore_Event_Mouse_Down *e; + Ecore_Event_Mouse_Down *e; D_ENTER; e = ev->event; - if (!win_place) D_RETURN; + if (!win_place) + D_RETURN; D_RETURN; } @@ -28,14 +29,16 @@ e_mouse_down(Ecore_Event * ev) static void e_mouse_up(Ecore_Event * ev) { - Ecore_Event_Mouse_Up *e; + Ecore_Event_Mouse_Up *e; D_ENTER; e = ev->event; - if (!win_place) D_RETURN; - e_action_stop("Window_Place", ACT_MOUSE_UP, 1, NULL, - ECORE_EVENT_KEY_MODIFIER_NONE, NULL, NULL, e->x, e->y, e->rx, e->ry); + if (!win_place) + D_RETURN; + e_action_stop("Window_Place", ACT_MOUSE_UP, 1, NULL, + ECORE_EVENT_KEY_MODIFIER_NONE, NULL, NULL, e->x, e->y, e->rx, + e->ry); ecore_window_destroy(win_place); win_place = 0; @@ -45,15 +48,16 @@ e_mouse_up(Ecore_Event * ev) static void e_mouse_move(Ecore_Event * ev) { - Ecore_Event_Mouse_Move *e; + Ecore_Event_Mouse_Move *e; D_ENTER; e = ev->event; - if (!win_place) D_RETURN; - e_action_cont("Window_Place", ACT_MOUSE_MOVE, 1, NULL, - ECORE_EVENT_KEY_MODIFIER_NONE, NULL, NULL, e->x, e->y, e->rx, e->ry, - e->rx - prx, e->ry - pry); + if (!win_place) + D_RETURN; + e_action_cont("Window_Place", ACT_MOUSE_MOVE, 1, NULL, + ECORE_EVENT_KEY_MODIFIER_NONE, NULL, NULL, e->x, e->y, e->rx, + e->ry, e->rx - prx, e->ry - pry); prx = e->rx; pry = e->ry; @@ -61,19 +65,21 @@ e_mouse_move(Ecore_Event * ev) } static int -e_place_manual(E_Border *b, E_Desktop *desk, int *x, int *y) +e_place_manual(E_Border * b, E_Desktop * desk, int *x, int *y) { - int w, h; - int mx, my, rx, ry; - int move_mode = E_GUIDES_BOX; - E_CFG_INT(cfg_window_move_mode, "settings", "/window/move/mode", E_GUIDES_BOX); - + int w, h; + int mx, my, rx, ry; + int move_mode = E_GUIDES_BOX; + + E_CFG_INT(cfg_window_move_mode, "settings", "/window/move/mode", + E_GUIDES_BOX); + D_ENTER; E_CONFIG_INT_GET(cfg_window_move_mode, move_mode); w = b->current.requested.w; h = b->current.requested.h; - + if (!win_place) { win_place = ecore_window_input_new(0, 0, 0, desk->real.w, desk->real.h); @@ -85,7 +91,7 @@ e_place_manual(E_Border *b, E_Desktop *desk, int *x, int *y) { e_action_stop_by_type("Window_Place"); } - + /* get mouse coords */ ecore_pointer_xy(desk->win.main, &mx, &my); rx = mx; @@ -95,27 +101,29 @@ e_place_manual(E_Border *b, E_Desktop *desk, int *x, int *y) /* grab mouse to desktop */ ecore_pointer_ungrab(CurrentTime); ecore_pointer_grab(win_place, CurrentTime); - + *x = mx - (w / 2); *y = my - (h / 2); /* start a move mode */ e_action_stop_by_type("Window_Place"); - e_action_start("Window_Place", ACT_MOUSE_CLICK, 1, NULL, - ECORE_EVENT_KEY_MODIFIER_NONE, E_OBJECT(b), NULL, mx, my, rx, ry); - - if (move_mode != E_GUIDES_OPAQUE) D_RETURN_(0); + e_action_start("Window_Place", ACT_MOUSE_CLICK, 1, NULL, + ECORE_EVENT_KEY_MODIFIER_NONE, E_OBJECT(b), NULL, mx, my, rx, + ry); + + if (move_mode != E_GUIDES_OPAQUE) + D_RETURN_(0); D_RETURN_(1); } static int -e_place_smart(E_Border *b, E_Desktop *desk, int *x, int *y) +e_place_smart(E_Border * b, E_Desktop * desk, int *x, int *y) { - int w, h; - int a_w = 0, a_h = 0; - int *a_x = NULL, *a_y = NULL; - Evas_List l; - + int w, h; + int a_w = 0, a_h = 0; + int *a_x = NULL, *a_y = NULL; + Evas_List l; + D_ENTER; w = b->current.requested.w; @@ -124,16 +132,16 @@ e_place_smart(E_Border *b, E_Desktop *desk, int *x, int *y) a_h = 2; a_x = NEW(int, 2); a_y = NEW(int, 2); - + a_x[0] = 0; a_x[1] = desk->real.w; a_y[0] = 0; a_y[1] = desk->real.h; - + for (l = desk->windows; l; l = l->next) { - E_Border *bd; - + E_Border *bd; + bd = l->data; if ((bd != b) && (bd->current.visible)) { @@ -141,291 +149,320 @@ e_place_smart(E_Border *b, E_Desktop *desk, int *x, int *y) bd->current.w, bd->current.h, 0, 0, desk->real.w, desk->real.h)) { - int i, j; - + int i, j; + for (i = 0; i < a_w; i++) { - int ok = 1; - + int ok = 1; + if (bd->current.x > 0) { - if (a_x[i] == bd->current.x) ok = 0; + if (a_x[i] == bd->current.x) + ok = 0; else if (a_x[i] > bd->current.x) { a_w++; REALLOC(a_x, int, a_w); + for (j = a_w - 1; j > i; j--) - a_x[j] = a_x[j - 1]; + a_x[j] = a_x[j - 1]; a_x[i] = bd->current.x; ok = 0; } } - if (!ok) break; + if (!ok) + break; } for (i = 0; i < a_w; i++) { - int ok = 1; - + int ok = 1; + if (bd->current.x + bd->current.w < desk->real.w) { - if (a_x[i] == bd->current.x + bd->current.w) ok = 0; + if (a_x[i] == bd->current.x + bd->current.w) + ok = 0; else if (a_x[i] > bd->current.x + bd->current.w) { a_w++; REALLOC(a_x, int, a_w); + for (j = a_w - 1; j > i; j--) - a_x[j] = a_x[j - 1]; + a_x[j] = a_x[j - 1]; a_x[i] = bd->current.x + bd->current.w; ok = 0; } } - if (!ok) break; + if (!ok) + break; } for (i = 0; i < a_h; i++) { - int ok = 1; - + int ok = 1; + if (bd->current.y > 0) { - if (a_y[i] == bd->current.y) ok = 0; + if (a_y[i] == bd->current.y) + ok = 0; else if (a_y[i] > bd->current.y) { a_h++; REALLOC(a_y, int, a_h); + for (j = a_h - 1; j > i; j--) - a_y[j] = a_y[j - 1]; + a_y[j] = a_y[j - 1]; a_y[i] = bd->current.y; ok = 0; } } - if (!ok) break; + if (!ok) + break; } for (i = 0; i < a_h; i++) { - int ok = 1; - + int ok = 1; + if (bd->current.y + bd->current.h < desk->real.h) { - if (a_y[i] == bd->current.y + bd->current.h) ok = 0; + if (a_y[i] == bd->current.y + bd->current.h) + ok = 0; else if (a_y[i] > bd->current.y + bd->current.h) { a_h++; REALLOC(a_y, int, a_h); + for (j = a_h - 1; j > i; j--) - a_y[j] = a_y[j - 1]; + a_y[j] = a_y[j - 1]; a_y[i] = bd->current.y + bd->current.h; ok = 0; } } - if (!ok) break; + if (!ok) + break; } } } } - { - int i, j; - int area = 0x7fffffff; - - for (j = 0; j < a_h - 1; j++) - { - for (i = 0; i < a_w - 1; i++) - { - if ((a_x[i] < (desk->real.w - w)) && - (a_y[j] < (desk->real.h - h))) - { - int ar = 0; - - for (l = desk->windows; l; l = l->next) - { - E_Border *bd; - int x1, y1, w1, h1, x2, y2, w2, h2; - - bd = l->data; - x1 = a_x[i]; - y1 = a_y[j]; - w1 = w; - h1 = h; - x2 = bd->current.x; - y2 = bd->current.y; - w2 = bd->current.w; - h2 = bd->current.h; - if ((bd != b) && (bd->current.visible) && - INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2)) - { - int iw, ih; - int x0, x00, y0, y00; - - x0 = x1; - if (x1 < x2) x0 = x2; - x00 = (x1 + w1); - if ((x2 + w2) < (x1 + w1)) x00 = (x2 + w2); - - y0 = y1; - if (y1 < y2) y0 = y2; - y00 = (y1 + h1); - if ((y2 + h2) < (y1 + h1)) y00 = (y2 + h2); - - iw = x00 - x0; - ih = y00 - y0; - ar += (iw * ih); - } - } - if (ar < area) - { - area = ar; - *x = a_x[i]; - *y = a_y[j]; - if (ar == 0) goto done; - } - } - if ((a_x[i + 1] - w > 0) && - (a_y[j] < (desk->real.h - h))) - { - int ar = 0; - - for (l = desk->windows; l; l = l->next) - { - E_Border *bd; - int x1, y1, w1, h1, x2, y2, w2, h2; - - bd = l->data; - x1 = a_x[i + 1] - w; - y1 = a_y[j]; - w1 = w; - h1 = h; - x2 = bd->current.x; - y2 = bd->current.y; - w2 = bd->current.w; - h2 = bd->current.h; - if ((bd != b) && (bd->current.visible) && - INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2)) - { - int iw, ih; - int x0, x00, y0, y00; - - x0 = x1; - if (x1 < x2) x0 = x2; - x00 = (x1 + w1); - if ((x2 + w2) < (x1 + w1)) x00 = (x2 + w2); - - y0 = y1; - if (y1 < y2) y0 = y2; - y00 = (y1 + h1); - if ((y2 + h2) < (y1 + h1)) y00 = (y2 + h2); - - iw = x00 - x0; - ih = y00 - y0; - ar += (iw * ih); - } - } - if (ar < area) - { - area = ar; - *x = a_x[i + 1] - w; - *y = a_y[j]; - if (ar == 0) goto done; - } - } - if ((a_x[i + 1] - w > 0) && - (a_y[j + 1] - h > 0)) - { - int ar = 0; - - for (l = desk->windows; l; l = l->next) - { - E_Border *bd; - int x1, y1, w1, h1, x2, y2, w2, h2; - - bd = l->data; - x1 = a_x[i + 1] - w; - y1 = a_y[j + 1] - h; - w1 = w; - h1 = h; - x2 = bd->current.x; - y2 = bd->current.y; - w2 = bd->current.w; - h2 = bd->current.h; - if ((bd != b) && (bd->current.visible) && - INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2)) - { - int iw, ih; - int x0, x00, y0, y00; - - x0 = x1; - if (x1 < x2) x0 = x2; - x00 = (x1 + w1); - if ((x2 + w2) < (x1 + w1)) x00 = (x2 + w2); - - y0 = y1; - if (y1 < y2) y0 = y2; - y00 = (y1 + h1); - if ((y2 + h2) < (y1 + h1)) y00 = (y2 + h2); - - iw = x00 - x0; - ih = y00 - y0; - ar += (iw * ih); - } - } - if (ar < area) - { - area = ar; - *x = a_x[i + 1] - w; - *y = a_y[j + 1] - h; - if (ar == 0) goto done; - } - } - if ((a_x[i] < (desk->real.w - w)) && - (a_y[j + 1] - h > 0)) - { - int ar = 0; - - for (l = desk->windows; l; l = l->next) - { - E_Border *bd; - int x1, y1, w1, h1, x2, y2, w2, h2; - - bd = l->data; - x1 = a_x[i]; - y1 = a_y[j + 1] - h; - w1 = w; - h1 = h; - x2 = bd->current.x; - y2 = bd->current.y; - w2 = bd->current.w; - h2 = bd->current.h; - if ((bd != b) && (bd->current.visible) && - INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2)) - { - int iw, ih; - int x0, x00, y0, y00; - - x0 = x1; - if (x1 < x2) x0 = x2; - x00 = (x1 + w1); - if ((x2 + w2) < (x1 + w1)) x00 = (x2 + w2); - - y0 = y1; - if (y1 < y2) y0 = y2; - y00 = (y1 + h1); - if ((y2 + h2) < (y1 + h1)) y00 = (y2 + h2); - - iw = x00 - x0; - ih = y00 - y0; - ar += (iw * ih); - } - } - if (ar < area) - { - area = ar; - *x = a_x[i]; - *y = a_y[j + 1] - h; - if (ar == 0) goto done; - } - } - } - } - } - done: + { + int i, j; + int area = 0x7fffffff; + + for (j = 0; j < a_h - 1; j++) + { + for (i = 0; i < a_w - 1; i++) + { + if ((a_x[i] < (desk->real.w - w)) && + (a_y[j] < (desk->real.h - h))) + { + int ar = 0; + + for (l = desk->windows; l; l = l->next) + { + E_Border *bd; + int x1, y1, w1, h1, x2, y2, w2, h2; + + bd = l->data; + x1 = a_x[i]; + y1 = a_y[j]; + w1 = w; + h1 = h; + x2 = bd->current.x; + y2 = bd->current.y; + w2 = bd->current.w; + h2 = bd->current.h; + if ((bd != b) && (bd->current.visible) && + INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2)) + { + int iw, ih; + int x0, x00, y0, y00; + + x0 = x1; + if (x1 < x2) + x0 = x2; + x00 = (x1 + w1); + if ((x2 + w2) < (x1 + w1)) + x00 = (x2 + w2); + + y0 = y1; + if (y1 < y2) + y0 = y2; + y00 = (y1 + h1); + if ((y2 + h2) < (y1 + h1)) + y00 = (y2 + h2); + + iw = x00 - x0; + ih = y00 - y0; + ar += (iw * ih); + } + } + if (ar < area) + { + area = ar; + *x = a_x[i]; + *y = a_y[j]; + if (ar == 0) + goto done; + } + } + if ((a_x[i + 1] - w > 0) && (a_y[j] < (desk->real.h - h))) + { + int ar = 0; + + for (l = desk->windows; l; l = l->next) + { + E_Border *bd; + int x1, y1, w1, h1, x2, y2, w2, h2; + + bd = l->data; + x1 = a_x[i + 1] - w; + y1 = a_y[j]; + w1 = w; + h1 = h; + x2 = bd->current.x; + y2 = bd->current.y; + w2 = bd->current.w; + h2 = bd->current.h; + if ((bd != b) && (bd->current.visible) && + INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2)) + { + int iw, ih; + int x0, x00, y0, y00; + + x0 = x1; + if (x1 < x2) + x0 = x2; + x00 = (x1 + w1); + if ((x2 + w2) < (x1 + w1)) + x00 = (x2 + w2); + + y0 = y1; + if (y1 < y2) + y0 = y2; + y00 = (y1 + h1); + if ((y2 + h2) < (y1 + h1)) + y00 = (y2 + h2); + + iw = x00 - x0; + ih = y00 - y0; + ar += (iw * ih); + } + } + if (ar < area) + { + area = ar; + *x = a_x[i + 1] - w; + *y = a_y[j]; + if (ar == 0) + goto done; + } + } + if ((a_x[i + 1] - w > 0) && (a_y[j + 1] - h > 0)) + { + int ar = 0; + + for (l = desk->windows; l; l = l->next) + { + E_Border *bd; + int x1, y1, w1, h1, x2, y2, w2, h2; + + bd = l->data; + x1 = a_x[i + 1] - w; + y1 = a_y[j + 1] - h; + w1 = w; + h1 = h; + x2 = bd->current.x; + y2 = bd->current.y; + w2 = bd->current.w; + h2 = bd->current.h; + if ((bd != b) && (bd->current.visible) && + INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2)) + { + int iw, ih; + int x0, x00, y0, y00; + + x0 = x1; + if (x1 < x2) + x0 = x2; + x00 = (x1 + w1); + if ((x2 + w2) < (x1 + w1)) + x00 = (x2 + w2); + + y0 = y1; + if (y1 < y2) + y0 = y2; + y00 = (y1 + h1); + if ((y2 + h2) < (y1 + h1)) + y00 = (y2 + h2); + + iw = x00 - x0; + ih = y00 - y0; + ar += (iw * ih); + } + } + if (ar < area) + { + area = ar; + *x = a_x[i + 1] - w; + *y = a_y[j + 1] - h; + if (ar == 0) + goto done; + } + } + if ((a_x[i] < (desk->real.w - w)) && (a_y[j + 1] - h > 0)) + { + int ar = 0; + + for (l = desk->windows; l; l = l->next) + { + E_Border *bd; + int x1, y1, w1, h1, x2, y2, w2, h2; + + bd = l->data; + x1 = a_x[i]; + y1 = a_y[j + 1] - h; + w1 = w; + h1 = h; + x2 = bd->current.x; + y2 = bd->current.y; + w2 = bd->current.w; + h2 = bd->current.h; + if ((bd != b) && (bd->current.visible) && + INTERSECTS(x1, y1, w1, h1, x2, y2, w2, h2)) + { + int iw, ih; + int x0, x00, y0, y00; + + x0 = x1; + if (x1 < x2) + x0 = x2; + x00 = (x1 + w1); + if ((x2 + w2) < (x1 + w1)) + x00 = (x2 + w2); + + y0 = y1; + if (y1 < y2) + y0 = y2; + y00 = (y1 + h1); + if ((y2 + h2) < (y1 + h1)) + y00 = (y2 + h2); + + iw = x00 - x0; + ih = y00 - y0; + ar += (iw * ih); + } + } + if (ar < area) + { + area = ar; + *x = a_x[i]; + *y = a_y[j + 1] - h; + if (ar == 0) + goto done; + } + } + } + } + } + done: FREE(a_x); FREE(a_y); @@ -433,10 +470,10 @@ e_place_smart(E_Border *b, E_Desktop *desk, int *x, int *y) } static int -e_place_middle(E_Border *b, E_Desktop *desk, int *x, int *y) +e_place_middle(E_Border * b, E_Desktop * desk, int *x, int *y) { - int w, h; - + int w, h; + D_ENTER; w = b->current.requested.w; @@ -448,21 +485,24 @@ e_place_middle(E_Border *b, E_Desktop *desk, int *x, int *y) } static int -e_place_cascade(E_Border *b, E_Desktop *desk, int *x, int *y) +e_place_cascade(E_Border * b, E_Desktop * desk, int *x, int *y) { - int w, h; - static int count_x = 0; - static int count_y = 0; - int pl, pr, pt, pb; - + int w, h; + static int count_x = 0; + static int count_y = 0; + int pl, pr, pt, pb; + D_ENTER; pl = pr = pt = pb = 0; - if (b->bits.l) ebits_get_insets(b->bits.l, &pl, &pr, &pt, &pb); + if (b->bits.l) + ebits_get_insets(b->bits.l, &pl, &pr, &pt, &pb); w = b->current.requested.w; h = b->current.requested.h; - if ((count_x + w) > desk->real.w) count_x = 0; - if ((count_y + h) > desk->real.h) count_y = 0; + if ((count_x + w) > desk->real.w) + count_x = 0; + if ((count_y + h) > desk->real.h) + count_y = 0; *x = count_x; *y = count_y; count_x += pl; @@ -472,56 +512,57 @@ e_place_cascade(E_Border *b, E_Desktop *desk, int *x, int *y) } static int -e_place_random(E_Border *b, E_Desktop *desk, int *x, int *y) +e_place_random(E_Border * b, E_Desktop * desk, int *x, int *y) { - int w, h; - + int w, h; + D_ENTER; w = b->current.requested.w; h = b->current.requested.h; if (w < desk->real.w) - *x = (rand() % (desk->real.w - w)); + *x = (rand() % (desk->real.w - w)); else - *x = 0; + *x = 0; if (h < desk->real.h) - *y = (rand() % (desk->real.h - h)); + *y = (rand() % (desk->real.h - h)); else - *y = 0; + *y = 0; D_RETURN_(1); } int -e_place_border(E_Border *b, E_Desktop *desk, int *x, int *y, E_Placement_Mode mode) +e_place_border(E_Border * b, E_Desktop * desk, int *x, int *y, + E_Placement_Mode mode) { - int result = 1; + int result = 1; D_ENTER; if (b->client.no_place) - D_RETURN_(1); - + D_RETURN_(1); + switch (mode) { - case E_PLACE_MANUAL: - result = e_place_manual (b, desk, x, y); + case E_PLACE_MANUAL: + result = e_place_manual(b, desk, x, y); break; - case E_PLACE_SMART: - result = e_place_smart (b, desk, x, y); + case E_PLACE_SMART: + result = e_place_smart(b, desk, x, y); break; - case E_PLACE_MIDDLE: - result = e_place_middle (b, desk, x, y); + case E_PLACE_MIDDLE: + result = e_place_middle(b, desk, x, y); break; - case E_PLACE_CASCADE: + case E_PLACE_CASCADE: result = e_place_cascade(b, desk, x, y); break; - case E_PLACE_RANDOM: - result = e_place_random (b, desk, x, y); + case E_PLACE_RANDOM: + result = e_place_random(b, desk, x, y); break; - default: + default: break; } @@ -533,9 +574,9 @@ e_place_init(void) { D_ENTER; - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, e_mouse_down); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, e_mouse_up); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, e_mouse_move); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, e_mouse_down); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, e_mouse_up); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, e_mouse_move); D_RETURN; } diff --git a/src/place.h b/src/place.h index 7ad0dffc1..927be823b 100644 --- a/src/place.h +++ b/src/place.h @@ -7,11 +7,11 @@ typedef enum e_placement_mode { - E_PLACE_MANUAL, - E_PLACE_SMART, - E_PLACE_MIDDLE, - E_PLACE_CASCADE, - E_PLACE_RANDOM + E_PLACE_MANUAL, + E_PLACE_SMART, + E_PLACE_MIDDLE, + E_PLACE_CASCADE, + E_PLACE_RANDOM } E_Placement_Mode; @@ -21,7 +21,7 @@ E_Placement_Mode; * This function registers the event handlers necessary * to be able to manage window placement strategies. */ -void e_place_init(void); +void e_place_init(void); /** * e_place_border - calculates window coordinates with given strategy @@ -35,7 +35,7 @@ void e_place_init(void); * and returns them in the @x and @y pointers. It does not actually * place the window. */ -int e_place_border(E_Border *b, E_Desktop *desk, int *x, int *y, E_Placement_Mode mode); - -#endif +int e_place_border(E_Border * b, E_Desktop * desk, int *x, + int *y, E_Placement_Mode mode); +#endif diff --git a/src/resist.c b/src/resist.c index 8a54857b8..3c919e3c6 100644 --- a/src/resist.c +++ b/src/resist.c @@ -5,23 +5,24 @@ #include "util.h" void -e_resist_border(E_Border *b) +e_resist_border(E_Border * b) { - int resist = 1; - int desk_resist = 32; - int win_resist = 12; + int resist = 1; + int desk_resist = 32; + int win_resist = 12; + /* int ok = 0; */ - int dx, dy, d; - int resist_x = 0, resist_y = 0; - Evas_List l, rects = NULL; - E_Rect *r; + int dx, dy, d; + int resist_x = 0, resist_y = 0; + Evas_List l, rects = NULL; + E_Rect *r; + E_CFG_INT(cfg_resist, "settings", "/move/resist", 1); E_CFG_INT(cfg_desk_resist, "settings", "/move/resist/desk", 32); E_CFG_INT(cfg_win_resist, "settings", "/move/resist/win", 12); - D_ENTER; - + E_CONFIG_INT_GET(cfg_resist, resist); E_CONFIG_INT_GET(cfg_desk_resist, desk_resist); E_CONFIG_INT_GET(cfg_win_resist, win_resist); @@ -31,7 +32,8 @@ e_resist_border(E_Border *b) b->current.y = b->current.requested.y; D_RETURN; } - if (!b->desk) D_RETURN; + if (!b->desk) + D_RETURN; dx = b->current.requested.x - b->previous.requested.x; dy = b->current.requested.y - b->previous.requested.y; /* edges of screen */ @@ -41,28 +43,34 @@ r = NEW(E_Rect, 1); \ r->x = _x; r->y = _y; r->w = _w; r->h = _h; r->v1 = _resist; \ rects = evas_list_append(rects, r); \ } - OBSTACLE(-1000000, -1000000, 2000000 + b->desk->real.w, 1000000, desk_resist); - OBSTACLE(-1000000, -1000000, 1000000, 2000000 + b->desk->real.h, desk_resist); - OBSTACLE(-1000000, b->desk->real.h, 2000000 + b->desk->real.w, 1000000, desk_resist); - OBSTACLE(b->desk->real.w, -1000000, 1000000, 2000000 + b->desk->real.h, desk_resist); + OBSTACLE(-1000000, -1000000, 2000000 + b->desk->real.w, 1000000, + desk_resist); + OBSTACLE(-1000000, -1000000, 1000000, 2000000 + b->desk->real.h, + desk_resist); + OBSTACLE(-1000000, b->desk->real.h, 2000000 + b->desk->real.w, 1000000, + desk_resist); + OBSTACLE(b->desk->real.w, -1000000, 1000000, 2000000 + b->desk->real.h, + desk_resist); /* can add code here to add more fake obstacles with custom resist values */ /* here if need be - ie xinerama middle between screens and panels etc. */ { if (b->desk->view->iconbar) - evas_list_append(rects, e_iconbar_get_resist_rect(b->desk->view->iconbar)); + evas_list_append(rects, + e_iconbar_get_resist_rect(b->desk->view->iconbar)); } for (l = b->desk->windows; l; l = l->next) { - E_Border *bd; - + E_Border *bd; + bd = l->data; if (bd->current.visible) { if (bd != b) { r = NEW(struct _E_Rect, 1); + r->x = bd->current.x; r->y = bd->current.y; r->w = bd->current.w; @@ -81,18 +89,20 @@ rects = evas_list_append(rects, r); \ { /* moving right - check left edge of windows against right */ d = r->x - (b->current.requested.x + b->current.w); - if ((d < 0) && (d >= - r->v1)) + if ((d < 0) && (d >= -r->v1)) { - if (resist_x > d) resist_x = d; + if (resist_x > d) + resist_x = d; } } else if (dx < 0) { /* moving left - check right edge of windows against left */ d = b->current.requested.x - (r->x + r->w); - if ((d < 0) && (d >= - r->v1)) + if ((d < 0) && (d >= -r->v1)) { - if (resist_x > d) resist_x = -d; + if (resist_x > d) + resist_x = -d; } } } @@ -102,18 +112,20 @@ rects = evas_list_append(rects, r); \ { /* moving down - check top edge of windows against bottom */ d = r->y - (b->current.requested.y + b->current.h); - if ((d < 0) && (d >=2 - r->v1)) + if ((d < 0) && (d >= 2 - r->v1)) { - if (resist_y > d) resist_y = d; + if (resist_y > d) + resist_y = d; } } else if (dy < 0) { /* moving up - check bottom edge of windows against top */ d = b->current.requested.y - (r->y + r->h); - if ((d < 0) && (d >= - r->v1)) + if ((d < 0) && (d >= -r->v1)) { - if (resist_y > d) resist_y = -d; + if (resist_y > d) + resist_y = -d; } } } @@ -123,26 +135,28 @@ rects = evas_list_append(rects, r); \ for (l = rects; l; l = l->next) { FREE(l->data); - } + } evas_list_free(rects); } - if (dx != 0) + if (dx != 0) { if ((b->previous.requested.x != b->previous.x) && - (((b->previous.requested.dx < 0) && (b->current.requested.dx > 0)) || - ((b->previous.requested.dx > 0) && (b->current.requested.dx < 0)))) - b->current.requested.x = b->current.x; + (((b->previous.requested.dx < 0) && (b->current.requested.dx > 0)) + || ((b->previous.requested.dx > 0) + && (b->current.requested.dx < 0)))) + b->current.requested.x = b->current.x; else - b->current.x = b->current.requested.x + resist_x; + b->current.x = b->current.requested.x + resist_x; } - if (dy != 0) + if (dy != 0) { if ((b->previous.requested.y != b->previous.y) && - (((b->previous.requested.dy < 0) && (b->current.requested.dy > 0)) || - ((b->previous.requested.dy > 0) && (b->current.requested.dy < 0)))) - b->current.requested.y = b->current.y; + (((b->previous.requested.dy < 0) && (b->current.requested.dy > 0)) + || ((b->previous.requested.dy > 0) + && (b->current.requested.dy < 0)))) + b->current.requested.y = b->current.y; else - b->current.y = b->current.requested.y + resist_y; + b->current.y = b->current.requested.y + resist_y; } D_RETURN; diff --git a/src/resist.h b/src/resist.h index 0a51ca4d6..6b766f9cb 100644 --- a/src/resist.h +++ b/src/resist.h @@ -4,14 +4,14 @@ #include "e.h" #include "border.h" -typedef struct _E_Rect E_Rect; +typedef struct _E_Rect E_Rect; struct _E_Rect { - int x, y, w, h; - int v1, v2, v3, v4; + int x, y, w, h; + int v1, v2, v3, v4; }; -void e_resist_border(E_Border *b); +void e_resist_border(E_Border * b); #endif diff --git a/src/scrollbar.c b/src/scrollbar.c index f514ca3b8..7301cbbf1 100644 --- a/src/scrollbar.c +++ b/src/scrollbar.c @@ -3,28 +3,36 @@ #include "config.h" #include "util.h" -static void e_scrollbar_recalc(E_Scrollbar *sb); -static void e_scrollbar_setup_bits(E_Scrollbar *sb); -static void e_sb_base_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh); -static void e_sb_base_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh); -static void e_sb_bar_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh); -static void e_sb_bar_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh); -static void e_sb_bar_move_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh); -static void e_sb_scroll_timer(int val, void *data); -static void e_scrollbar_cleanup(E_Scrollbar *sb); - +static void e_scrollbar_recalc(E_Scrollbar * sb); +static void e_scrollbar_setup_bits(E_Scrollbar * sb); +static void e_sb_base_down_cb(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, + int ow, int oh); +static void e_sb_base_up_cb(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, + int ow, int oh); +static void e_sb_bar_down_cb(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, + int ow, int oh); +static void e_sb_bar_up_cb(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, int ow, + int oh); +static void e_sb_bar_move_cb(void *data, Ebits_Object o, char *class, + int bt, int x, int y, int ox, int oy, + int ow, int oh); +static void e_sb_scroll_timer(int val, void *data); +static void e_scrollbar_cleanup(E_Scrollbar * sb); static void -e_scrollbar_recalc(E_Scrollbar *sb) +e_scrollbar_recalc(E_Scrollbar * sb) { D_ENTER; if (sb->base) { - double x, y, w, h; - - ebits_get_named_bit_geometry(sb->base, "Trough_Area", - &x, &y, &w, &h); + double x, y, w, h; + + ebits_get_named_bit_geometry(sb->base, "Trough_Area", &x, &y, &w, &h); sb->bar_area.x = x + sb->x; sb->bar_area.y = y + sb->y; sb->bar_area.w = w; @@ -34,20 +42,20 @@ e_scrollbar_recalc(E_Scrollbar *sb) sb->bar_pos.w = sb->bar_area.w; sb->bar_pos.h = (sb->bar_area.h * sb->range) / sb->max; sb->bar_pos.x = sb->bar_area.x; - sb->bar_pos.y = sb->bar_area.y + - ((sb->bar_area.h * sb->val) / (sb->max - 1)); + sb->bar_pos.y = sb->bar_area.y + + ((sb->bar_area.h * sb->val) / (sb->max - 1)); } else { sb->bar_pos.w = (sb->bar_area.w * sb->range) / sb->max; sb->bar_pos.h = sb->bar_area.h; - sb->bar_pos.x = sb->bar_area.x + - ((sb->bar_area.w * sb->val) / (sb->max - 1)); + sb->bar_pos.x = sb->bar_area.x + + ((sb->bar_area.w * sb->val) / (sb->max - 1)); sb->bar_pos.y = sb->bar_area.y; } } else - { + { sb->bar_area.x = sb->x; sb->bar_area.y = sb->y; sb->bar_area.w = sb->w; @@ -63,79 +71,102 @@ e_scrollbar_recalc(E_Scrollbar *sb) } static void -e_scrollbar_setup_bits(E_Scrollbar *sb) +e_scrollbar_setup_bits(E_Scrollbar * sb) { - char buf[PATH_MAX]; - + char buf[PATH_MAX]; + D_ENTER; if (sb->direction == 1) { - snprintf(buf, PATH_MAX, "%s/scroll_base_v.bits.db", e_config_get("scrollbars")); + snprintf(buf, PATH_MAX, "%s/scroll_base_v.bits.db", + e_config_get("scrollbars")); sb->base = ebits_load(buf); - snprintf(buf, PATH_MAX, "%s/scroll_bar_v.bits.db", e_config_get("scrollbars")); + snprintf(buf, PATH_MAX, "%s/scroll_bar_v.bits.db", + e_config_get("scrollbars")); sb->bar = ebits_load(buf); } else { - snprintf(buf, PATH_MAX, "%s/scroll_base_h.bits.db", e_config_get("scrollbars")); + snprintf(buf, PATH_MAX, "%s/scroll_base_h.bits.db", + e_config_get("scrollbars")); sb->base = ebits_load(buf); - snprintf(buf, PATH_MAX, "%s/scroll_bar_h.bits.db", e_config_get("scrollbars")); + snprintf(buf, PATH_MAX, "%s/scroll_bar_h.bits.db", + e_config_get("scrollbars")); sb->bar = ebits_load(buf); } if (sb->base) { - int w, h; - + int w, h; + ebits_add_to_evas(sb->base, sb->evas); ebits_get_min_size(sb->base, &w, &h); sb->w = w; sb->h = h; - - ebits_set_classed_bit_callback(sb->base, "Scrollbar_Trough", CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, sb); - ebits_set_classed_bit_callback(sb->base, "Scrollbar_Trough", CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb); - ebits_set_classed_bit_callback(sb->base, "Scrollbar_Arrow1", CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, sb); - ebits_set_classed_bit_callback(sb->base, "Scrollbar_Arrow1", CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb); - ebits_set_classed_bit_callback(sb->base, "Scrollbar_Arrow2", CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, sb); - ebits_set_classed_bit_callback(sb->base, "Scrollbar_Arrow2", CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb); + + ebits_set_classed_bit_callback(sb->base, "Scrollbar_Trough", + CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, + sb); + ebits_set_classed_bit_callback(sb->base, "Scrollbar_Trough", + CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb); + ebits_set_classed_bit_callback(sb->base, "Scrollbar_Arrow1", + CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, + sb); + ebits_set_classed_bit_callback(sb->base, "Scrollbar_Arrow1", + CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb); + ebits_set_classed_bit_callback(sb->base, "Scrollbar_Arrow2", + CALLBACK_MOUSE_DOWN, e_sb_base_down_cb, + sb); + ebits_set_classed_bit_callback(sb->base, "Scrollbar_Arrow2", + CALLBACK_MOUSE_UP, e_sb_base_up_cb, sb); } if (sb->bar) { ebits_add_to_evas(sb->bar, sb->evas); - ebits_set_classed_bit_callback(sb->bar, "Scrollbar_Bar", CALLBACK_MOUSE_DOWN, e_sb_bar_down_cb, sb); - ebits_set_classed_bit_callback(sb->bar, "Scrollbar_Bar", CALLBACK_MOUSE_UP, e_sb_bar_up_cb, sb); - ebits_set_classed_bit_callback(sb->bar, "Scrollbar_Bar", CALLBACK_MOUSE_MOVE, e_sb_bar_move_cb, sb); + ebits_set_classed_bit_callback(sb->bar, "Scrollbar_Bar", + CALLBACK_MOUSE_DOWN, e_sb_bar_down_cb, + sb); + ebits_set_classed_bit_callback(sb->bar, "Scrollbar_Bar", + CALLBACK_MOUSE_UP, e_sb_bar_up_cb, sb); + ebits_set_classed_bit_callback(sb->bar, "Scrollbar_Bar", + CALLBACK_MOUSE_MOVE, e_sb_bar_move_cb, + sb); } D_RETURN; } static void -e_sb_base_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) +e_sb_base_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, + int ox, int oy, int ow, int oh) { - E_Scrollbar *sb; - double prev; - char name[PATH_MAX]; - int inc; - + E_Scrollbar *sb; + double prev; + char name[PATH_MAX]; + int inc; + D_ENTER; sb = data; - if (sb->mouse_down) D_RETURN; + if (sb->mouse_down) + D_RETURN; sb->mouse_down = bt; - if (!class) D_RETURN; + if (!class) + D_RETURN; prev = sb->val; - D ( "x %d y %d bt %d\n" , x , y , bt ); - D ( "val %f range %f max %f\n" , sb->val , sb->range , sb->max ); - D ( "sb x %f y %f w %f h %f\n" , sb->x, sb->y, sb->w, sb->h ); - D ( "sb area x %f y %f w %f h %f\n" , sb->bar_area.x, sb->bar_area.y, sb->bar_area.w, sb->bar_area.h ); - D ( "sb pos x %f y %f w %f h %f\n" , sb->bar_pos.x, sb->bar_pos.y, sb->bar_pos.w, sb->bar_pos.h ); + D("x %d y %d bt %d\n", x, y, bt); + D("val %f range %f max %f\n", sb->val, sb->range, sb->max); + D("sb x %f y %f w %f h %f\n", sb->x, sb->y, sb->w, sb->h); + D("sb area x %f y %f w %f h %f\n", sb->bar_area.x, sb->bar_area.y, + sb->bar_area.w, sb->bar_area.h); + D("sb pos x %f y %f w %f h %f\n", sb->bar_pos.x, sb->bar_pos.y, + sb->bar_pos.w, sb->bar_pos.h); if (!strcmp(class, "Scrollbar_Arrow1")) { - sb->scroll_step = -16; - sb->scroll_speed = 0.01; + sb->scroll_step = -16; + sb->scroll_speed = 0.01; snprintf(name, PATH_MAX, "scroll_up.%i.%s", sb->direction, sb->dir); ecore_add_event_timer(name, sb->scroll_speed, e_sb_scroll_timer, 0, sb); @@ -143,8 +174,8 @@ e_sb_base_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, else if (!strcmp(class, "Scrollbar_Arrow2")) { - sb->scroll_step = 16; - sb->scroll_speed = 0.01; + sb->scroll_step = 16; + sb->scroll_speed = 0.01; snprintf(name, PATH_MAX, "scroll_down.%i.%s", sb->direction, sb->dir); ecore_add_event_timer(name, sb->scroll_speed, e_sb_scroll_timer, 0, sb); @@ -152,57 +183,71 @@ e_sb_base_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, else if (!strcmp(class, "Scrollbar_Trough")) { - if ( bt == 1 ) - { - if ( sb->direction ) /* vertical */ - { - sb->scroll_step = sb->bar_area.h; - inc = y - sb->bar_pos.y; - } - else /* horizontal */ - { - sb->scroll_step = sb->bar_area.w; - inc = x - sb->bar_pos.x; - } + if (bt == 1) + { + if (sb->direction) /* vertical */ + { + sb->scroll_step = sb->bar_area.h; + inc = y - sb->bar_pos.y; + } + else /* horizontal */ + { + sb->scroll_step = sb->bar_area.w; + inc = x - sb->bar_pos.x; + } - if ( inc < 0 ) /* scroll up (or left) */ - { - sb->scroll_step = -sb->scroll_step; - snprintf ( name , PATH_MAX , "scroll_up.%i.%s" , sb->direction , sb->dir ); - } - else /* scroll down (or right) */ - { - snprintf ( name , PATH_MAX , "scroll_down.%i.%s" , sb->direction , sb->dir ); - } + if (inc < 0) /* scroll up (or left) */ + { + sb->scroll_step = -sb->scroll_step; + snprintf(name, PATH_MAX, "scroll_up.%i.%s", sb->direction, + sb->dir); + } + else /* scroll down (or right) */ + { + snprintf(name, PATH_MAX, "scroll_down.%i.%s", sb->direction, + sb->dir); + } - /* scroll once in the chosen direction */ - sb->val += sb->scroll_step; - if (sb->val < 0) sb->val = 0; - if ((sb->val + sb->range) > sb->max) sb->val = sb->max - sb->range; + /* scroll once in the chosen direction */ + sb->val += sb->scroll_step; + if (sb->val < 0) + sb->val = 0; + if ((sb->val + sb->range) > sb->max) + sb->val = sb->max - sb->range; - /* set a timer to keep on scrolling */ - sb->scroll_speed = 0.1; - ecore_add_event_timer ( name , sb->scroll_speed , e_sb_scroll_timer , 0 , sb ); - } + /* set a timer to keep on scrolling */ + sb->scroll_speed = 0.1; + ecore_add_event_timer(name, sb->scroll_speed, e_sb_scroll_timer, 0, + sb); + } - else - { - if (sb->direction) - sb->val = ( y - sb->bar_area.y) * sb->max / sb->bar_area.h - sb->bar_area.h / 2; - else - sb->val = ( x - sb->bar_area.x) * sb->max / sb->bar_area.w - sb->bar_area.w / 2; + else + { + if (sb->direction) + sb->val = + (y - sb->bar_area.y) * sb->max / sb->bar_area.h - + sb->bar_area.h / 2; + else + sb->val = + (x - sb->bar_area.x) * sb->max / sb->bar_area.w - + sb->bar_area.w / 2; - if (sb->val < 0) sb->val = 0; - if ((sb->val + sb->range) > sb->max) sb->val = sb->max - sb->range; - } + if (sb->val < 0) + sb->val = 0; + if ((sb->val + sb->range) > sb->max) + sb->val = sb->max - sb->range; + } } e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); - if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); if (prev != sb->val) { - if (sb->func_change) sb->func_change(sb->func_data, sb, sb->val); + if (sb->func_change) + sb->func_change(sb->func_data, sb, sb->val); } D_RETURN; @@ -214,17 +259,21 @@ e_sb_base_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, } static void -e_sb_base_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) +e_sb_base_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, + int ox, int oy, int ow, int oh) { - E_Scrollbar *sb; - char name[PATH_MAX]; - + E_Scrollbar *sb; + char name[PATH_MAX]; + D_ENTER; sb = data; - if (bt == sb->mouse_down) sb->mouse_down = 0; - else D_RETURN; - if (!class) D_RETURN; + if (bt == sb->mouse_down) + sb->mouse_down = 0; + else + D_RETURN; + if (!class) + D_RETURN; if (!strcmp(class, "Scrollbar_Arrow1")) { @@ -244,18 +293,20 @@ e_sb_base_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, i else if (!strcmp(class, "Scrollbar_Trough")) { - if ( sb->scroll_step < 0 ) - { - sb->scroll_step = 0; - snprintf(name, PATH_MAX, "scroll_up.%i.%s", sb->direction, sb->dir); - ecore_del_event_timer(name); - } - else if ( sb->scroll_step > 0 ) - { - sb->scroll_step = 0; - snprintf(name, PATH_MAX, "scroll_down.%i.%s", sb->direction, sb->dir); - ecore_del_event_timer(name); - } + if (sb->scroll_step < 0) + { + sb->scroll_step = 0; + snprintf(name, PATH_MAX, "scroll_up.%i.%s", sb->direction, + sb->dir); + ecore_del_event_timer(name); + } + else if (sb->scroll_step > 0) + { + sb->scroll_step = 0; + snprintf(name, PATH_MAX, "scroll_down.%i.%s", sb->direction, + sb->dir); + ecore_del_event_timer(name); + } } D_RETURN; @@ -269,14 +320,16 @@ e_sb_base_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, i } static void -e_sb_bar_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) +e_sb_bar_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, + int ox, int oy, int ow, int oh) { - E_Scrollbar *sb; - + E_Scrollbar *sb; + D_ENTER; sb = data; - if (sb->mouse_down) D_RETURN; + if (sb->mouse_down) + D_RETURN; sb->mouse_down = bt; sb->down_x = x; sb->down_y = y; @@ -295,17 +348,18 @@ e_sb_bar_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, } static void -e_sb_bar_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) +e_sb_bar_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, + int ox, int oy, int ow, int oh) { - E_Scrollbar *sb; - + E_Scrollbar *sb; + D_ENTER; sb = data; if (bt == sb->mouse_down) - sb->mouse_down = 0; + sb->mouse_down = 0; else - D_RETURN; + D_RETURN; D_RETURN; UN(o); @@ -319,15 +373,17 @@ e_sb_bar_up_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, in } static void -e_sb_bar_move_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh) +e_sb_bar_move_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, + int ox, int oy, int ow, int oh) { - E_Scrollbar *sb; - int dx, dy; - double prev; - + E_Scrollbar *sb; + int dx, dy; + double prev; + D_ENTER; sb = data; - if (!sb->mouse_down) D_RETURN; + if (!sb->mouse_down) + D_RETURN; dx = x - sb->mouse_x; dy = y - sb->mouse_y; sb->mouse_x = x; @@ -335,24 +391,31 @@ e_sb_bar_move_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, prev = sb->val; if (sb->direction) { - if (sb->bar_area.h > sb->bar_pos.h) sb->val += - ((double)dy * sb->max) / sb->bar_area.h; - else sb->val = 0; + if (sb->bar_area.h > sb->bar_pos.h) + sb->val += ((double)dy * sb->max) / sb->bar_area.h; + else + sb->val = 0; } else { - if (sb->bar_area.w > sb->bar_pos.w) sb->val += - ((double)dx * sb->max) / sb->bar_area.w; - else sb->val = 0; + if (sb->bar_area.w > sb->bar_pos.w) + sb->val += ((double)dx * sb->max) / sb->bar_area.w; + else + sb->val = 0; } - if (sb->val < 0) sb->val = 0; - if ((sb->val + sb->range) > sb->max) sb->val = sb->max - sb->range; + if (sb->val < 0) + sb->val = 0; + if ((sb->val + sb->range) > sb->max) + sb->val = sb->max - sb->range; if (prev != sb->val) { e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); - if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); - if (sb->func_change) sb->func_change(sb->func_data, sb, sb->val); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); + if (sb->func_change) + sb->func_change(sb->func_data, sb, sb->val); } D_RETURN; @@ -370,47 +433,50 @@ e_sb_bar_move_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, static void e_sb_scroll_timer(int val, void *data) { - E_Scrollbar *sb; - char name[PATH_MAX]; + E_Scrollbar *sb; + char name[PATH_MAX]; D_ENTER; - + sb = data; - if ( sb->scroll_step < 0 ) + if (sb->scroll_step < 0) { - sb->val += sb->scroll_step; - if (sb->val < 0) sb->val = 0; - + sb->val += sb->scroll_step; + if (sb->val < 0) + sb->val = 0; + snprintf(name, PATH_MAX, "scroll_up.%i.%s", sb->direction, sb->dir); ecore_add_event_timer(name, sb->scroll_speed, e_sb_scroll_timer, 0, sb); } - else if ( sb->scroll_step > 0 ) + else if (sb->scroll_step > 0) { - sb->val += sb->scroll_step; - if ((sb->val + sb->range) > sb->max) sb->val = sb->max - sb->range; + sb->val += sb->scroll_step; + if ((sb->val + sb->range) > sb->max) + sb->val = sb->max - sb->range; snprintf(name, PATH_MAX, "scroll_down.%i.%s", sb->direction, sb->dir); ecore_add_event_timer(name, sb->scroll_speed, e_sb_scroll_timer, 0, sb); } - + e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); - if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); - if (sb->func_change) sb->func_change(sb->func_data, sb, sb->val); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); + if (sb->func_change) + sb->func_change(sb->func_data, sb, sb->val); D_RETURN; UN(val); } - - -E_Scrollbar * +E_Scrollbar * e_scrollbar_new(void) { - E_Scrollbar *sb; - + E_Scrollbar *sb; + D_ENTER; sb = NEW(E_Scrollbar, 1); @@ -427,16 +493,18 @@ e_scrollbar_new(void) } static void -e_scrollbar_cleanup(E_Scrollbar *sb) +e_scrollbar_cleanup(E_Scrollbar * sb) { - char name[PATH_MAX]; - + char name[PATH_MAX]; + D_ENTER; if (sb->evas) { - if (sb->base) ebits_free(sb->base); - if (sb->bar) ebits_free(sb->bar); + if (sb->base) + ebits_free(sb->base); + if (sb->bar) + ebits_free(sb->bar); } IF_FREE(sb->dir); @@ -451,30 +519,40 @@ e_scrollbar_cleanup(E_Scrollbar *sb) } void -e_scrollbar_add_to_evas(E_Scrollbar *sb, Evas evas) +e_scrollbar_add_to_evas(E_Scrollbar * sb, Evas evas) { D_ENTER; if (sb->evas) { - if (sb->base) ebits_free(sb->base); - if (sb->bar) ebits_free(sb->bar); + if (sb->base) + ebits_free(sb->base); + if (sb->bar) + ebits_free(sb->bar); } sb->evas = evas; if (sb->evas) { e_scrollbar_setup_bits(sb); - if (sb->base) ebits_set_layer(sb->base, sb->layer); - if (sb->bar) ebits_set_layer(sb->bar, sb->layer); - if (sb->base) ebits_move(sb->base, sb->x, sb->y); - if (sb->base) ebits_resize(sb->base, sb->w, sb->h); + if (sb->base) + ebits_set_layer(sb->base, sb->layer); + if (sb->bar) + ebits_set_layer(sb->bar, sb->layer); + if (sb->base) + ebits_move(sb->base, sb->x, sb->y); + if (sb->base) + ebits_resize(sb->base, sb->w, sb->h); e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); - if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); if (sb->visible) { - if (sb->base) ebits_show(sb->base); - if (sb->bar) ebits_show(sb->bar); + if (sb->base) + ebits_show(sb->base); + if (sb->bar) + ebits_show(sb->bar); } } @@ -482,79 +560,95 @@ e_scrollbar_add_to_evas(E_Scrollbar *sb, Evas evas) } void -e_scrollbar_show(E_Scrollbar *sb) +e_scrollbar_show(E_Scrollbar * sb) { D_ENTER; - if (sb->visible) D_RETURN; + if (sb->visible) + D_RETURN; sb->visible = 1; - if (sb->base) ebits_show(sb->base); - if (sb->bar) ebits_show(sb->bar); + if (sb->base) + ebits_show(sb->base); + if (sb->bar) + ebits_show(sb->bar); D_RETURN; } void -e_scrollbar_hide(E_Scrollbar *sb) +e_scrollbar_hide(E_Scrollbar * sb) { D_ENTER; - if (!sb->visible) D_RETURN; + if (!sb->visible) + D_RETURN; sb->visible = 0; - if (sb->base) ebits_hide(sb->base); - if (sb->bar) ebits_hide(sb->bar); + if (sb->base) + ebits_hide(sb->base); + if (sb->bar) + ebits_hide(sb->bar); D_RETURN; } void -e_scrollbar_raise(E_Scrollbar *sb) +e_scrollbar_raise(E_Scrollbar * sb) { D_ENTER; - if (sb->base) ebits_raise(sb->base); - if (sb->bar) ebits_raise(sb->bar); + if (sb->base) + ebits_raise(sb->base); + if (sb->bar) + ebits_raise(sb->bar); D_RETURN; } void -e_scrollbar_lower(E_Scrollbar *sb) +e_scrollbar_lower(E_Scrollbar * sb) { D_ENTER; - if (sb->bar) ebits_lower(sb->bar); - if (sb->base) ebits_lower(sb->base); + if (sb->bar) + ebits_lower(sb->bar); + if (sb->base) + ebits_lower(sb->base); D_RETURN; } void -e_scrollbar_set_layer(E_Scrollbar *sb, int l) +e_scrollbar_set_layer(E_Scrollbar * sb, int l) { D_ENTER; - if (l == sb->layer) D_RETURN; + if (l == sb->layer) + D_RETURN; sb->layer = l; - if (sb->base) ebits_set_layer(sb->base, sb->layer); - if (sb->bar) ebits_set_layer(sb->bar, sb->layer); + if (sb->base) + ebits_set_layer(sb->base, sb->layer); + if (sb->bar) + ebits_set_layer(sb->bar, sb->layer); D_RETURN; } void -e_scrollbar_set_direction(E_Scrollbar *sb, int d) +e_scrollbar_set_direction(E_Scrollbar * sb, int d) { D_ENTER; - if (d == sb->direction) D_RETURN; + if (d == sb->direction) + D_RETURN; sb->direction = d; if (sb->evas) { - Evas evas; - - if (sb->base) ebits_free(sb->base); - if (sb->bar) ebits_free(sb->bar); + Evas evas; + + if (sb->base) + ebits_free(sb->base); + if (sb->bar) + ebits_free(sb->bar); evas = sb->evas; sb->evas = NULL; e_scrollbar_add_to_evas(sb, evas); @@ -564,40 +658,47 @@ e_scrollbar_set_direction(E_Scrollbar *sb, int d) } void -e_scrollbar_move(E_Scrollbar *sb, double x, double y) +e_scrollbar_move(E_Scrollbar * sb, double x, double y) { D_ENTER; - if ((x == sb->x) && (y == sb->y)) D_RETURN; + if ((x == sb->x) && (y == sb->y)) + D_RETURN; sb->x = x; sb->y = y; - if (sb->base) ebits_move(sb->base, sb->x, sb->y); + if (sb->base) + ebits_move(sb->base, sb->x, sb->y); e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); D_RETURN; } void -e_scrollbar_resize(E_Scrollbar *sb, double w, double h) +e_scrollbar_resize(E_Scrollbar * sb, double w, double h) { D_ENTER; - if ((w == sb->w) && (h == sb->h)) D_RETURN; + if ((w == sb->w) && (h == sb->h)) + D_RETURN; sb->w = w; sb->h = h; - if (sb->base) ebits_resize(sb->base, sb->w, sb->h); + if (sb->base) + ebits_resize(sb->base, sb->w, sb->h); e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); - if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); D_RETURN; } void -e_scrollbar_set_change_func(E_Scrollbar *sb, - void (*func_change) (void *_data, E_Scrollbar *sb, double val), - void *data) +e_scrollbar_set_change_func(E_Scrollbar * sb, + void (*func_change) (void *_data, E_Scrollbar * sb, + double val), void *data) { D_ENTER; @@ -608,52 +709,64 @@ e_scrollbar_set_change_func(E_Scrollbar *sb, } void -e_scrollbar_set_value(E_Scrollbar *sb, double val) +e_scrollbar_set_value(E_Scrollbar * sb, double val) { D_ENTER; - if (val > sb->max - sb->range) val = sb->max - sb->range; - if (val < 0 ) val = 0; - if (sb->val == val) D_RETURN; + if (val > sb->max - sb->range) + val = sb->max - sb->range; + if (val < 0) + val = 0; + if (sb->val == val) + D_RETURN; sb->val = val; e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); - if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); - if (sb->func_change) sb->func_change(sb->func_data, sb, sb->val); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); + if (sb->func_change) + sb->func_change(sb->func_data, sb, sb->val); D_RETURN; } void -e_scrollbar_set_range(E_Scrollbar *sb, double range) +e_scrollbar_set_range(E_Scrollbar * sb, double range) { D_ENTER; - if (sb->range == range) D_RETURN; + if (sb->range == range) + D_RETURN; sb->range = range; e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); - if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); D_RETURN; } void -e_scrollbar_set_max(E_Scrollbar *sb, double max) +e_scrollbar_set_max(E_Scrollbar * sb, double max) { D_ENTER; - if (sb->max == max) D_RETURN; + if (sb->max == max) + D_RETURN; sb->max = max; e_scrollbar_recalc(sb); - if (sb->bar) ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); - if (sb->bar) ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); + if (sb->bar) + ebits_move(sb->bar, sb->bar_pos.x, sb->bar_pos.y); + if (sb->bar) + ebits_resize(sb->bar, sb->bar_pos.w, sb->bar_pos.h); D_RETURN; } double -e_scrollbar_get_value(E_Scrollbar *sb) +e_scrollbar_get_value(E_Scrollbar * sb) { D_ENTER; @@ -661,7 +774,7 @@ e_scrollbar_get_value(E_Scrollbar *sb) } double -e_scrollbar_get_range(E_Scrollbar *sb) +e_scrollbar_get_range(E_Scrollbar * sb) { D_ENTER; @@ -669,7 +782,7 @@ e_scrollbar_get_range(E_Scrollbar *sb) } double -e_scrollbar_get_max(E_Scrollbar *sb) +e_scrollbar_get_max(E_Scrollbar * sb) { D_ENTER; @@ -677,15 +790,19 @@ e_scrollbar_get_max(E_Scrollbar *sb) } void -e_scrollbar_get_geometry(E_Scrollbar *sb, double *x, double *y, double *w, double *h) +e_scrollbar_get_geometry(E_Scrollbar * sb, double *x, double *y, double *w, + double *h) { D_ENTER; - if (x) *x = sb->x; - if (y) *y = sb->y; - if (w) *w = sb->w; - if (h) *h = sb->h; + if (x) + *x = sb->x; + if (y) + *y = sb->y; + if (w) + *w = sb->w; + if (h) + *h = sb->h; D_RETURN; } - diff --git a/src/scrollbar.h b/src/scrollbar.h index 2b62f0348..0c181c7e8 100644 --- a/src/scrollbar.h +++ b/src/scrollbar.h @@ -1,64 +1,75 @@ #include "e.h" #include "object.h" -typedef struct _E_Scrollbar E_Scrollbar; +typedef struct _E_Scrollbar E_Scrollbar; struct _E_Scrollbar { - E_Object o; + E_Object o; /* I<---val--->|<==range==>|<-->I<-max */ - double val; - double max; - double range; + double val; + double max; + double range; - char *dir; - - Evas evas; - - Ebits_Object bar; - Ebits_Object base; - - int visible; - int layer; - int direction; - double x, y, w, h; - - int mouse_down; - int down_x, down_y; - int mouse_x, mouse_y; + char *dir; - int scroll_step; - double scroll_speed; + Evas evas; - struct { - double x, y, w, h; - } bar_area; - struct { - double x, y, w, h; - } bar_pos; - - void (*func_change) (void *_data, E_Scrollbar *sb, double val); - void *func_data; + Ebits_Object bar; + Ebits_Object base; + + int visible; + int layer; + int direction; + double x, y, w, h; + + int mouse_down; + int down_x, down_y; + int mouse_x, mouse_y; + + int scroll_step; + double scroll_speed; + + struct + { + double x, y, w, h; + } + bar_area; + struct + { + double x, y, w, h; + } + bar_pos; + + void (*func_change) (void *_data, E_Scrollbar * sb, + double val); + void *func_data; }; -E_Scrollbar *e_scrollbar_new(void); -void e_scrollbar_add_to_evas(E_Scrollbar *sb, Evas evas); -void e_scrollbar_show(E_Scrollbar *sb); -void e_scrollbar_hide(E_Scrollbar *sb); -void e_scrollbar_raise(E_Scrollbar *sb); -void e_scrollbar_lower(E_Scrollbar *sb); -void e_scrollbar_set_layer(E_Scrollbar *sb, int l); -void e_scrollbar_set_direction(E_Scrollbar *sb, int d); -void e_scrollbar_move(E_Scrollbar *sb, double x, double y); -void e_scrollbar_resize(E_Scrollbar *sb, double w, double h); -void e_scrollbar_set_change_func(E_Scrollbar *sb, - void (*func_change) (void *_data, E_Scrollbar *sb, double val), - void *data); -void e_scrollbar_set_value(E_Scrollbar *sb, double val); -void e_scrollbar_set_range(E_Scrollbar *sb, double range); -void e_scrollbar_set_max(E_Scrollbar *sb, double max); -double e_scrollbar_get_value(E_Scrollbar *sb); -double e_scrollbar_get_range(E_Scrollbar *sb); -double e_scrollbar_get_max(E_Scrollbar *sb); -void e_scrollbar_get_geometry(E_Scrollbar *sb, double *x, double *y, double *w, double *h); +E_Scrollbar *e_scrollbar_new(void); +void e_scrollbar_add_to_evas(E_Scrollbar * sb, Evas evas); +void e_scrollbar_show(E_Scrollbar * sb); +void e_scrollbar_hide(E_Scrollbar * sb); +void e_scrollbar_raise(E_Scrollbar * sb); +void e_scrollbar_lower(E_Scrollbar * sb); +void e_scrollbar_set_layer(E_Scrollbar * sb, int l); +void e_scrollbar_set_direction(E_Scrollbar * sb, int d); +void e_scrollbar_move(E_Scrollbar * sb, double x, double y); +void e_scrollbar_resize(E_Scrollbar * sb, double w, double h); +void e_scrollbar_set_change_func(E_Scrollbar * sb, + void (*func_change) (void + *_data, + E_Scrollbar + * sb, + double + val), + void *data); +void e_scrollbar_set_value(E_Scrollbar * sb, double val); +void e_scrollbar_set_range(E_Scrollbar * sb, double range); +void e_scrollbar_set_max(E_Scrollbar * sb, double max); +double e_scrollbar_get_value(E_Scrollbar * sb); +double e_scrollbar_get_range(E_Scrollbar * sb); +double e_scrollbar_get_max(E_Scrollbar * sb); +void e_scrollbar_get_geometry(E_Scrollbar * sb, double *x, + double *y, double *w, double *h); diff --git a/src/text.c b/src/text.c index 5cd852694..21df68725 100644 --- a/src/text.c +++ b/src/text.c @@ -2,20 +2,24 @@ #include "text.h" #include "util.h" -E_Text * +E_Text * e_text_new(Evas evas, char *text, char *class) { - E_Text *t; - + E_Text *t; + D_ENTER; t = NEW(E_Text, 1); ZERO(t, E_Text, 1); t->state = strdup("normal"); - if (class) t->class = strdup(class); - else t->class = strdup(""); - if (text) t->text = strdup(text); - else t->text = strdup(""); + if (class) + t->class = strdup(class); + else + t->class = strdup(""); + if (text) + t->text = strdup(text); + else + t->text = strdup(""); t->evas = evas; t->obj.o1 = evas_add_text(t->evas, "borzoib", 8, t->text); t->obj.o2 = evas_add_text(t->evas, "borzoib", 8, t->text); @@ -52,14 +56,14 @@ e_text_new(Evas evas, char *text, char *class) } void -e_text_free(E_Text *t) +e_text_free(E_Text * t) { D_ENTER; IF_FREE(t->state); IF_FREE(t->class); IF_FREE(t->text); - + if ((t->evas) && (t->obj.text)) { evas_del_object(t->evas, t->obj.o1); @@ -74,12 +78,14 @@ e_text_free(E_Text *t) } void -e_text_set_text(E_Text *t, char *text) +e_text_set_text(E_Text * t, char *text) { D_ENTER; - if (!text) text = ""; - if (!strcmp(t->text, text)) D_RETURN; + if (!text) + text = ""; + if (!strcmp(t->text, text)) + D_RETURN; FREE(t->text); t->text = strdup(text); evas_set_text(t->evas, t->obj.o1, t->text); @@ -98,11 +104,12 @@ e_text_set_text(E_Text *t, char *text) } void -e_text_set_layer(E_Text *t, int l) +e_text_set_layer(E_Text * t, int l) { D_ENTER; - if (t->layer == l) D_RETURN; + if (t->layer == l) + D_RETURN; t->layer = l; evas_set_layer(t->evas, t->obj.o1, t->layer); evas_set_layer(t->evas, t->obj.o2, t->layer); @@ -114,7 +121,7 @@ e_text_set_layer(E_Text *t, int l) } void -e_text_set_clip(E_Text *t, Evas_Object clip) +e_text_set_clip(E_Text * t, Evas_Object clip) { D_ENTER; @@ -128,7 +135,7 @@ e_text_set_clip(E_Text *t, Evas_Object clip) } void -e_text_unset_clip(E_Text *t) +e_text_unset_clip(E_Text * t) { D_ENTER; @@ -142,7 +149,7 @@ e_text_unset_clip(E_Text *t) } void -e_text_raise(E_Text *t) +e_text_raise(E_Text * t) { D_ENTER; @@ -156,7 +163,7 @@ e_text_raise(E_Text *t) } void -e_text_lower(E_Text *t) +e_text_lower(E_Text * t) { D_ENTER; @@ -170,11 +177,12 @@ e_text_lower(E_Text *t) } void -e_text_show(E_Text *t) +e_text_show(E_Text * t) { D_ENTER; - if (t->visible) D_RETURN; + if (t->visible) + D_RETURN; t->visible = 1; evas_show(t->evas, t->obj.o1); evas_show(t->evas, t->obj.o2); @@ -186,11 +194,12 @@ e_text_show(E_Text *t) } void -e_text_hide(E_Text *t) +e_text_hide(E_Text * t) { D_ENTER; - if (!t->visible) D_RETURN; + if (!t->visible) + D_RETURN; t->visible = 0; evas_hide(t->evas, t->obj.o1); evas_hide(t->evas, t->obj.o2); @@ -202,29 +211,30 @@ e_text_hide(E_Text *t) } void -e_text_set_color(E_Text *t, int r, int g, int b, int a) +e_text_set_color(E_Text * t, int r, int g, int b, int a) { D_ENTER; if ((r == t->color.r) && - (g == t->color.g) && - (b == t->color.b) && - (a == t->color.a)) D_RETURN; + (g == t->color.g) && (b == t->color.b) && (a == t->color.a)) + D_RETURN; t->color.r = r; t->color.g = g; t->color.b = b; t->color.a = a; - evas_set_color(t->evas, t->obj.text, t->color.r, t->color.g, t->color.b, t->color.a); + evas_set_color(t->evas, t->obj.text, t->color.r, t->color.g, t->color.b, + t->color.a); D_RETURN; } void -e_text_move(E_Text *t, double x, double y) +e_text_move(E_Text * t, double x, double y) { D_ENTER; - if ((t->x == x) && (t->y == y)) D_RETURN; + if ((t->x == x) && (t->y == y)) + D_RETURN; t->x = x; t->y = y; evas_move(t->evas, t->obj.o1, t->x + 1, t->y); @@ -237,11 +247,10 @@ e_text_move(E_Text *t, double x, double y) } void -e_text_resize(E_Text *t, double w, double h) +e_text_resize(E_Text * t, double w, double h) { D_ENTER; - D_RETURN; UN(t); UN(w); @@ -249,42 +258,50 @@ e_text_resize(E_Text *t, double w, double h) } void -e_text_get_geometry(E_Text *t, double *x, double *y, double *w, double *h) +e_text_get_geometry(E_Text * t, double *x, double *y, double *w, double *h) { D_ENTER; - if (x) *x = t->x; - if (y) *y = t->y; - if (w) *w = t->w; - if (h) *h = t->h; + if (x) + *x = t->x; + if (y) + *y = t->y; + if (w) + *w = t->w; + if (h) + *h = t->h; D_RETURN; } void -e_text_get_min_size(E_Text *t, double *w, double *h) +e_text_get_min_size(E_Text * t, double *w, double *h) { D_ENTER; - if (w) *w = t->min.w; - if (h) *h = t->min.h; + if (w) + *w = t->min.w; + if (h) + *h = t->min.h; D_RETURN; } void -e_text_get_max_size(E_Text *t, double *w, double *h) +e_text_get_max_size(E_Text * t, double *w, double *h) { D_ENTER; - if (w) *w = t->max.w; - if (h) *h = t->max.h; + if (w) + *w = t->max.w; + if (h) + *h = t->max.h; D_RETURN; } void -e_text_set_state(E_Text *t, char *state) +e_text_set_state(E_Text * t, char *state) { D_ENTER; @@ -295,7 +312,7 @@ e_text_set_state(E_Text *t, char *state) } void -e_text_set_class(E_Text *t, char *class) +e_text_set_class(E_Text * t, char *class) { D_ENTER; @@ -306,11 +323,10 @@ e_text_set_class(E_Text *t, char *class) } void -e_text_update_class(E_Text *t) +e_text_update_class(E_Text * t) { D_ENTER; - D_RETURN; UN(t); } diff --git a/src/text.h b/src/text.h index 3e888d4a4..b4de9f5c2 100644 --- a/src/text.h +++ b/src/text.h @@ -3,51 +3,58 @@ #include "e.h" -typedef struct _E_Text E_Text; +typedef struct _E_Text E_Text; struct _E_Text { - char *text; - char *class; - char *state; - - int visible; - double x, y, w, h; - struct { - double w, h; - } min, max; - struct { - int r, g, b, a; - } color; - int layer; - - Evas evas; - struct { - Evas_Object text; - Evas_Object o1; - Evas_Object o2; - Evas_Object o3; - Evas_Object o4; - } obj; + char *text; + char *class; + char *state; + + int visible; + double x, y, w, h; + struct + { + double w, h; + } + min , max; + struct + { + int r, g, b, a; + } + color; + int layer; + + Evas evas; + struct + { + Evas_Object text; + Evas_Object o1; + Evas_Object o2; + Evas_Object o3; + Evas_Object o4; + } + obj; }; -E_Text *e_text_new(Evas evas, char *text, char *class); -void e_text_free(E_Text *t); -void e_text_set_text(E_Text *t, char *text); -void e_text_set_layer(E_Text *t, int l); -void e_text_set_clip(E_Text *t, Evas_Object clip); -void e_text_unset_clip(E_Text *t); -void e_text_raise(E_Text *t); -void e_text_lower(E_Text *t); -void e_text_show(E_Text *t); -void e_text_hide(E_Text *t); -void e_text_set_color(E_Text *t, int r, int g, int b, int a); -void e_text_move(E_Text *t, double x, double y); -void e_text_resize(E_Text *t, double w, double h); -void e_text_get_geometry(E_Text *t, double *x, double *y, double *w, double *h); -void e_text_get_min_size(E_Text *t, double *w, double *h); -void e_text_get_max_size(E_Text *t, double *w, double *h); -void e_text_set_state(E_Text *t, char *state); -void e_text_set_class(E_Text *t, char *class); -void e_text_update_class(E_Text *t); +E_Text *e_text_new(Evas evas, char *text, char *class); +void e_text_free(E_Text * t); +void e_text_set_text(E_Text * t, char *text); +void e_text_set_layer(E_Text * t, int l); +void e_text_set_clip(E_Text * t, Evas_Object clip); +void e_text_unset_clip(E_Text * t); +void e_text_raise(E_Text * t); +void e_text_lower(E_Text * t); +void e_text_show(E_Text * t); +void e_text_hide(E_Text * t); +void e_text_set_color(E_Text * t, int r, int g, int b, int a); +void e_text_move(E_Text * t, double x, double y); +void e_text_resize(E_Text * t, double w, double h); +void e_text_get_geometry(E_Text * t, double *x, double *y, + double *w, double *h); +void e_text_get_min_size(E_Text * t, double *w, double *h); +void e_text_get_max_size(E_Text * t, double *w, double *h); +void e_text_set_state(E_Text * t, char *state); +void e_text_set_class(E_Text * t, char *class); +void e_text_update_class(E_Text * t); #endif diff --git a/src/util.c b/src/util.c index 5963813b3..8fa95a288 100644 --- a/src/util.c +++ b/src/util.c @@ -4,40 +4,44 @@ void e_util_set_env(char *variable, char *content) { - char env[PATH_MAX]; - + char env[PATH_MAX]; + D_ENTER; - + snprintf(env, PATH_MAX, "%s=%s", variable, content); putenv(env); D_RETURN; } -char * +char * e_util_get_user_home(void) { - static char *home = NULL; - + static char *home = NULL; + D_ENTER; - - if (home) D_RETURN_(home); + + if (home) + D_RETURN_(home); home = getenv("HOME"); - if (!home) home = getenv("TMPDIR"); - if (!home) home = "/tmp"; + if (!home) + home = getenv("TMPDIR"); + if (!home) + home = "/tmp"; D_RETURN_(home); } -void * +void * e_util_memdup(void *data, int size) { - void *data_dup; - + void *data_dup; + D_ENTER; - + data_dup = malloc(size); - if (!data_dup) D_RETURN_(NULL); + if (!data_dup) + D_RETURN_(NULL); memcpy(data_dup, data, size); D_RETURN_(data_dup); @@ -47,13 +51,13 @@ int e_util_glob_matches(char *str, char *glob) { D_ENTER; - - if (!fnmatch(glob, str, 0)) D_RETURN_(1); + + if (!fnmatch(glob, str, 0)) + D_RETURN_(1); D_RETURN_(0); } - /* * Function to take a URL of the form * file://dir1/dir2/file @@ -63,38 +67,38 @@ e_util_glob_matches(char *str, char *glob) * * todo: */ -char * +char * e_util_de_url_and_verify(const char *fi) { - char *wk; - + char *wk; + D_ENTER; - - wk = strstr( fi, "file:" ); - + + wk = strstr(fi, "file:"); + /* Valid URL contains "file:" */ - if( !wk ) - D_RETURN_ (NULL); - + if (!wk) + D_RETURN_(NULL); + /* Need some form of hostname to continue */ /* if( !hostn ) - * D_RETURN_ (NULL); + * * D_RETURN_ (NULL); */ - + /* Do we contain hostname? */ /* wk = strstr( fi, hostn ); */ - + /* Hostname mismatch, reject file */ /* if( !wk ) - * D_RETURN_ (NULL); + * * D_RETURN_ (NULL); */ - + /* Local file name starts after "hostname" */ - wk = strchr( wk, '/' ); - - if ( !wk ) - D_RETURN_(NULL); - + wk = strchr(wk, '/'); + + if (!wk) + D_RETURN_(NULL); + D_RETURN_(wk); } diff --git a/src/util.h b/src/util.h index fc51f6489..311331256 100644 --- a/src/util.h +++ b/src/util.h @@ -3,11 +3,11 @@ #include "e.h" -void e_util_set_env(char *variable, char *content); -char *e_util_get_user_home(void); -void *e_util_memdup(void *data, int size); -int e_util_glob_matches(char *str, char *glob); -char *e_util_de_url_and_verify(const char *fi); +void e_util_set_env(char *variable, char *content); +char *e_util_get_user_home(void); +void *e_util_memdup(void *data, int size); +int e_util_glob_matches(char *str, char *glob); +char *e_util_de_url_and_verify(const char *fi); #define e_strdup(__dest, __var) \ { \ diff --git a/src/view.c b/src/view.c index 53a79c1cc..973b9581e 100644 --- a/src/view.c +++ b/src/view.c @@ -18,56 +18,62 @@ static Ecore_Event *current_ev = NULL; -static char **dnd_files = NULL; -static int dnd_num_files = 0; -static E_dnd_enum dnd_pending_mode; -static E_View *v_dnd_source; +static char **dnd_files = NULL; +static int dnd_num_files = 0; +static E_dnd_enum dnd_pending_mode; +static E_View *v_dnd_source; -static void e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_bg_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y); -static void e_idle(void *data); -static void e_wheel(Ecore_Event * ev); -static void e_key_down(Ecore_Event * ev); -static void e_key_up(Ecore_Event * ev); -static void e_mouse_down(Ecore_Event * ev); -static void e_mouse_up(Ecore_Event * ev); -static void e_mouse_move(Ecore_Event * ev); -static void e_mouse_in(Ecore_Event * ev); -static void e_mouse_out(Ecore_Event * ev); -static void e_window_expose(Ecore_Event * ev); -static void e_configure(Ecore_Event * ev); -static void e_property(Ecore_Event * ev); -static void e_unmap(Ecore_Event * ev); -static void e_visibility(Ecore_Event * ev); -static void e_focus_in(Ecore_Event * ev); -static void e_focus_out(Ecore_Event * ev); -static void e_delete(Ecore_Event * ev); -static void e_dnd_status(Ecore_Event * ev); -static void e_dnd_data_request(Ecore_Event * ev); -static void e_dnd_drop_end(Ecore_Event * ev); -static void e_dnd_drop_position(Ecore_Event * ev); -static void e_dnd_drop(Ecore_Event * ev); -static void e_dnd_drop_request(Ecore_Event * ev); -static void e_dnd_drop_request_free(void); -static void e_dnd_handle_drop( E_View *v ); -static void e_view_resort_timeout(int val, void *data); -static int e_view_restart_alphabetical_qsort_cb(const void *data1, const void *data2); -static void e_view_geometry_record_timeout(int val, void *data); -static void e_view_scrollbar_v_change_cb(void *_data, E_Scrollbar *sb, double val); -static void e_view_scrollbar_h_change_cb(void *_data, E_Scrollbar *sb, double val); -static void e_view_write_icon_xy_timeout(int val, void *data); +static void e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void e_bg_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, + int _x, int _y); +static void e_idle(void *data); +static void e_wheel(Ecore_Event * ev); +static void e_key_down(Ecore_Event * ev); +static void e_key_up(Ecore_Event * ev); +static void e_mouse_down(Ecore_Event * ev); +static void e_mouse_up(Ecore_Event * ev); +static void e_mouse_move(Ecore_Event * ev); +static void e_mouse_in(Ecore_Event * ev); +static void e_mouse_out(Ecore_Event * ev); +static void e_window_expose(Ecore_Event * ev); +static void e_configure(Ecore_Event * ev); +static void e_property(Ecore_Event * ev); +static void e_unmap(Ecore_Event * ev); +static void e_visibility(Ecore_Event * ev); +static void e_focus_in(Ecore_Event * ev); +static void e_focus_out(Ecore_Event * ev); +static void e_delete(Ecore_Event * ev); +static void e_dnd_status(Ecore_Event * ev); +static void e_dnd_data_request(Ecore_Event * ev); +static void e_dnd_drop_end(Ecore_Event * ev); +static void e_dnd_drop_position(Ecore_Event * ev); +static void e_dnd_drop(Ecore_Event * ev); +static void e_dnd_drop_request(Ecore_Event * ev); +static void e_dnd_drop_request_free(void); +static void e_dnd_handle_drop(E_View * v); +static void e_view_resort_timeout(int val, void *data); +static int e_view_restart_alphabetical_qsort_cb(const void *data1, + const void *data2); +static void e_view_geometry_record_timeout(int val, void *data); +static void e_view_scrollbar_v_change_cb(void *_data, E_Scrollbar * sb, + double val); +static void e_view_scrollbar_h_change_cb(void *_data, E_Scrollbar * sb, + double val); +static void e_view_write_icon_xy_timeout(int val, void *data); static void e_view_write_icon_xy_timeout(int val, void *data) { - E_View *v; - Evas_List l; - E_Icon *ic; - double t_in; + E_View *v; + Evas_List l; + E_Icon *ic; + double t_in; D_ENTER; - + v = data; /* FIXME: this is a problem if we have 1000's of icons */ t_in = ecore_get_time(); @@ -76,26 +82,26 @@ e_view_write_icon_xy_timeout(int val, void *data) ic = l->data; if (ic->q.write_xy) { - char buf[PATH_MAX]; - + char buf[PATH_MAX]; + ic->q.write_xy = 0; /* FIXME */ - snprintf(buf, PATH_MAX, "%s/%s", ic->view->model->dir, ic->file->file); - - D("write meta xy for icon for file %s\n", ic->file->file); + snprintf(buf, PATH_MAX, "%s/%s", ic->view->model->dir, + ic->file->file); + + D("write meta xy for icon for file %s\n", ic->file->file); efsd_set_metadata_int(e_fs_get_connection(), - "/pos/x", buf, - ic->geom.x); + "/pos/x", buf, ic->geom.x); efsd_set_metadata_int(e_fs_get_connection(), - "/pos/y", buf, - ic->geom.y); + "/pos/y", buf, ic->geom.y); } if ((ecore_get_time() - t_in) > 0.10) { - char name[PATH_MAX]; - + char name[PATH_MAX]; + snprintf(name, PATH_MAX, "icon_xy_record.%s", v->model->dir); - ecore_add_event_timer(name, 0.01, e_view_write_icon_xy_timeout, 0, v); + ecore_add_event_timer(name, 0.01, e_view_write_icon_xy_timeout, 0, + v); D_RETURN; } } @@ -105,112 +111,103 @@ e_view_write_icon_xy_timeout(int val, void *data) } void -e_view_selection_update(E_View *v) +e_view_selection_update(E_View * v) { D_ENTER; - + if ((v->select.on) && (!v->select.obj.middle)) { - Evas_Gradient grad; - + Evas_Gradient grad; + /* create select objects */ - v->select.obj.middle = evas_add_rectangle(v->evas); + v->select.obj.middle = evas_add_rectangle(v->evas); evas_set_color(v->evas, v->select.obj.middle, v->select.config.middle.r, v->select.config.middle.g, - v->select.config.middle.b, - v->select.config.middle.a); + v->select.config.middle.b, v->select.config.middle.a); evas_set_layer(v->evas, v->select.obj.middle, 300); - v->select.obj.edge_l = evas_add_rectangle(v->evas); + v->select.obj.edge_l = evas_add_rectangle(v->evas); evas_set_color(v->evas, v->select.obj.edge_l, v->select.config.edge_l.r, v->select.config.edge_l.g, - v->select.config.edge_l.b, - v->select.config.edge_l.a); + v->select.config.edge_l.b, v->select.config.edge_l.a); evas_set_layer(v->evas, v->select.obj.edge_l, 300); - v->select.obj.edge_r = evas_add_rectangle(v->evas); + v->select.obj.edge_r = evas_add_rectangle(v->evas); evas_set_color(v->evas, v->select.obj.edge_r, v->select.config.edge_r.r, v->select.config.edge_r.g, - v->select.config.edge_r.b, - v->select.config.edge_r.a); + v->select.config.edge_r.b, v->select.config.edge_r.a); evas_set_layer(v->evas, v->select.obj.edge_r, 300); - v->select.obj.edge_t = evas_add_rectangle(v->evas); + v->select.obj.edge_t = evas_add_rectangle(v->evas); evas_set_color(v->evas, v->select.obj.edge_t, v->select.config.edge_t.r, v->select.config.edge_t.g, - v->select.config.edge_t.b, - v->select.config.edge_t.a); + v->select.config.edge_t.b, v->select.config.edge_t.a); evas_set_layer(v->evas, v->select.obj.edge_t, 300); - v->select.obj.edge_b = evas_add_rectangle(v->evas); + v->select.obj.edge_b = evas_add_rectangle(v->evas); evas_set_color(v->evas, v->select.obj.edge_b, v->select.config.edge_b.r, v->select.config.edge_b.g, - v->select.config.edge_b.b, - v->select.config.edge_b.a); + v->select.config.edge_b.b, v->select.config.edge_b.a); evas_set_layer(v->evas, v->select.obj.edge_b, 300); - - v->select.obj.grad_l = evas_add_gradient_box(v->evas); + + v->select.obj.grad_l = evas_add_gradient_box(v->evas); evas_set_angle(v->evas, v->select.obj.grad_l, 270); grad = evas_gradient_new(); - evas_gradient_add_color(grad, + evas_gradient_add_color(grad, v->select.config.grad_l.r, v->select.config.grad_l.g, v->select.config.grad_l.b, v->select.config.grad_l.a, 8); - evas_gradient_add_color(grad, + evas_gradient_add_color(grad, v->select.config.grad_l.r, v->select.config.grad_l.g, - v->select.config.grad_l.b, - 0, 8); + v->select.config.grad_l.b, 0, 8); evas_set_gradient(v->evas, v->select.obj.grad_l, grad); evas_gradient_free(grad); evas_set_layer(v->evas, v->select.obj.grad_l, 300); - v->select.obj.grad_r = evas_add_gradient_box(v->evas); + v->select.obj.grad_r = evas_add_gradient_box(v->evas); evas_set_angle(v->evas, v->select.obj.grad_r, 90); grad = evas_gradient_new(); - evas_gradient_add_color(grad, + evas_gradient_add_color(grad, v->select.config.grad_r.r, v->select.config.grad_r.g, v->select.config.grad_r.b, v->select.config.grad_r.a, 8); - evas_gradient_add_color(grad, + evas_gradient_add_color(grad, v->select.config.grad_r.r, v->select.config.grad_r.g, - v->select.config.grad_r.b, - 0, 8); + v->select.config.grad_r.b, 0, 8); evas_set_gradient(v->evas, v->select.obj.grad_r, grad); evas_gradient_free(grad); evas_set_layer(v->evas, v->select.obj.grad_r, 300); - v->select.obj.grad_t = evas_add_gradient_box(v->evas); + v->select.obj.grad_t = evas_add_gradient_box(v->evas); evas_set_angle(v->evas, v->select.obj.grad_t, 0); grad = evas_gradient_new(); - evas_gradient_add_color(grad, + evas_gradient_add_color(grad, v->select.config.grad_t.r, v->select.config.grad_t.g, v->select.config.grad_t.b, v->select.config.grad_t.a, 8); - evas_gradient_add_color(grad, + evas_gradient_add_color(grad, v->select.config.grad_t.r, v->select.config.grad_t.g, - v->select.config.grad_t.b, - 0, 8); + v->select.config.grad_t.b, 0, 8); evas_set_gradient(v->evas, v->select.obj.grad_t, grad); evas_gradient_free(grad); evas_set_layer(v->evas, v->select.obj.grad_t, 300); - v->select.obj.grad_b = evas_add_gradient_box(v->evas); + v->select.obj.grad_b = evas_add_gradient_box(v->evas); evas_set_angle(v->evas, v->select.obj.grad_b, 180); grad = evas_gradient_new(); - evas_gradient_add_color(grad, + evas_gradient_add_color(grad, v->select.config.grad_b.r, v->select.config.grad_b.g, v->select.config.grad_b.b, v->select.config.grad_b.a, 8); - evas_gradient_add_color(grad, + evas_gradient_add_color(grad, v->select.config.grad_b.r, v->select.config.grad_b.g, - v->select.config.grad_b.b, - 0, 8); + v->select.config.grad_b.b, 0, 8); evas_set_gradient(v->evas, v->select.obj.grad_b, grad); evas_gradient_free(grad); evas_set_layer(v->evas, v->select.obj.grad_b, 300); @@ -238,31 +235,46 @@ e_view_selection_update(E_View *v) v->changed = 1; D_RETURN; } - if (!v->select.on) D_RETURN; + if (!v->select.on) + D_RETURN; /* move & resize select objects */ - { - evas_move(v->evas, v->select.obj.edge_l, v->select.x, v->select.y + 1); - evas_resize(v->evas, v->select.obj.edge_l, 1, v->select.h - 1); - evas_move(v->evas, v->select.obj.edge_r, v->select.x + v->select.w - 1, v->select.y); - evas_resize(v->evas, v->select.obj.edge_r, 1, v->select.h - 1); - evas_move(v->evas, v->select.obj.edge_t, v->select.x, v->select.y); - evas_resize(v->evas, v->select.obj.edge_t, v->select.w - 1, 1); - evas_move(v->evas, v->select.obj.edge_b, v->select.x + 1, v->select.y + v->select.h - 1); - evas_resize(v->evas, v->select.obj.edge_b, v->select.w - 1, 1); - evas_move(v->evas, v->select.obj.middle, v->select.x + 1, v->select.y + 1); - evas_resize(v->evas, v->select.obj.middle, v->select.w - 1 - 1, v->select.h - 1 - 1); - evas_move(v->evas, v->select.obj.grad_l, v->select.x + 1, v->select.y + 1); - evas_resize(v->evas, v->select.obj.grad_l, v->select.config.grad_size.l, v->select.h - 1 - 1); - evas_move(v->evas, v->select.obj.grad_r, v->select.x + v->select.w - 1 - v->select.config.grad_size.r, v->select.y + 1); - evas_resize(v->evas, v->select.obj.grad_r, v->select.config.grad_size.r, v->select.h - 1 - 1); - evas_move(v->evas, v->select.obj.grad_t, v->select.x + 1, v->select.y + 1); - evas_resize(v->evas, v->select.obj.grad_t, v->select.w - 1 - 1, v->select.config.grad_size.t); - evas_move(v->evas, v->select.obj.grad_b, v->select.x + 1, v->select.y + v->select.h - 1 - v->select.config.grad_size.b); - evas_resize(v->evas, v->select.obj.grad_b, v->select.w - 1 - 1, v->select.config.grad_size.b); - evas_move(v->evas, v->select.obj.clip, v->select.x + 1, v->select.y + 1); - evas_resize(v->evas, v->select.obj.clip, v->select.w - 1 - 1, v->select.h - 1 - 1); - } - + { + evas_move(v->evas, v->select.obj.edge_l, v->select.x, v->select.y + 1); + evas_resize(v->evas, v->select.obj.edge_l, 1, v->select.h - 1); + evas_move(v->evas, v->select.obj.edge_r, v->select.x + v->select.w - 1, + v->select.y); + evas_resize(v->evas, v->select.obj.edge_r, 1, v->select.h - 1); + evas_move(v->evas, v->select.obj.edge_t, v->select.x, v->select.y); + evas_resize(v->evas, v->select.obj.edge_t, v->select.w - 1, 1); + evas_move(v->evas, v->select.obj.edge_b, v->select.x + 1, + v->select.y + v->select.h - 1); + evas_resize(v->evas, v->select.obj.edge_b, v->select.w - 1, 1); + evas_move(v->evas, v->select.obj.middle, v->select.x + 1, + v->select.y + 1); + evas_resize(v->evas, v->select.obj.middle, v->select.w - 1 - 1, + v->select.h - 1 - 1); + evas_move(v->evas, v->select.obj.grad_l, v->select.x + 1, + v->select.y + 1); + evas_resize(v->evas, v->select.obj.grad_l, v->select.config.grad_size.l, + v->select.h - 1 - 1); + evas_move(v->evas, v->select.obj.grad_r, + v->select.x + v->select.w - 1 - v->select.config.grad_size.r, + v->select.y + 1); + evas_resize(v->evas, v->select.obj.grad_r, v->select.config.grad_size.r, + v->select.h - 1 - 1); + evas_move(v->evas, v->select.obj.grad_t, v->select.x + 1, + v->select.y + 1); + evas_resize(v->evas, v->select.obj.grad_t, v->select.w - 1 - 1, + v->select.config.grad_size.t); + evas_move(v->evas, v->select.obj.grad_b, v->select.x + 1, + v->select.y + v->select.h - 1 - v->select.config.grad_size.b); + evas_resize(v->evas, v->select.obj.grad_b, v->select.w - 1 - 1, + v->select.config.grad_size.b); + evas_move(v->evas, v->select.obj.clip, v->select.x + 1, v->select.y + 1); + evas_resize(v->evas, v->select.obj.clip, v->select.w - 1 - 1, + v->select.h - 1 - 1); + } + evas_show(v->evas, v->select.obj.middle); evas_show(v->evas, v->select.obj.edge_l); evas_show(v->evas, v->select.obj.edge_r); @@ -278,12 +290,12 @@ e_view_selection_update(E_View *v) } static void -e_view_scrollbar_v_change_cb(void *_data, E_Scrollbar *sb, double val) +e_view_scrollbar_v_change_cb(void *_data, E_Scrollbar * sb, double val) { - E_View *v; - + E_View *v; + D_ENTER; - + v = _data; e_view_scroll_to(v, v->scroll.x, v->spacing.window.t - sb->val); @@ -292,12 +304,12 @@ e_view_scrollbar_v_change_cb(void *_data, E_Scrollbar *sb, double val) } static void -e_view_scrollbar_h_change_cb(void *_data, E_Scrollbar *sb, double val) +e_view_scrollbar_h_change_cb(void *_data, E_Scrollbar * sb, double val) { - E_View *v; - + E_View *v; + D_ENTER; - + v = _data; e_view_scroll_to(v, v->spacing.window.l - sb->val, v->scroll.y); @@ -308,19 +320,20 @@ e_view_scrollbar_h_change_cb(void *_data, E_Scrollbar *sb, double val) static void e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - Ecore_Event_Mouse_Down *ev; - E_View *v; - + Ecore_Event_Mouse_Down *ev; + E_View *v; + D_ENTER; - if (!current_ev) D_RETURN; + if (!current_ev) + D_RETURN; ev = current_ev->event; v = _data; if (!(ev->mods & (multi_select_mod | range_select_mod))) { - v->select.last_count = v->select.count; - e_view_deselect_all(v); + v->select.last_count = v->select.count; + e_view_deselect_all(v); } if (_b == 1) @@ -351,8 +364,8 @@ e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) e_view_selection_update(v); } - if( _b == 2 && ev->double_click ) - ecore_event_loop_quit(); + if (_b == 2 && ev->double_click) + ecore_event_loop_quit(); D_RETURN; UN(_e); @@ -361,14 +374,15 @@ e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) static void e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) -{ - Ecore_Event_Mouse_Up *ev; - E_View *v; - int dx, dy; - +{ + Ecore_Event_Mouse_Up *ev; + E_View *v; + int dx, dy; + D_ENTER; - - if (!current_ev) D_RETURN; + + if (!current_ev) + D_RETURN; ev = current_ev->event; v = _data; dx = 0; @@ -378,24 +392,26 @@ e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { dx = v->select.down.x - _x; dy = v->select.down.y - _y; - if (dx < 0) dx = -dx; - if (dy < 0) dy = -dy; + if (dx < 0) + dx = -dx; + if (dy < 0) + dy = -dy; if (_b == 1) - v->select.on = 0; + v->select.on = 0; e_view_selection_update(v); } if ((_b == 1) && ((dx > 3) || (dy > 3))) { - Evas_List l; - + Evas_List l; + for (l = v->icons; l; l = l->next) { - E_Icon *ic; - + E_Icon *ic; + ic = l->data; if (INTERSECTS(v->select.x, v->select.y, v->select.w, v->select.h, - v->scroll.x + ic->geom.x, + v->scroll.x + ic->geom.x, v->scroll.y + ic->geom.y, ic->geom.w, ic->geom.h)) { if (ic->state.visible) @@ -412,22 +428,25 @@ e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) if (!(ev->mods & (multi_select_mod | range_select_mod))) { static E_Build_Menu *buildmenu = NULL; - + if (!buildmenu) { - char *apps_menu_db; - + char *apps_menu_db; + apps_menu_db = e_config_get("apps_menu"); - if (apps_menu_db) buildmenu = e_build_menu_new_from_db(apps_menu_db); + if (apps_menu_db) + buildmenu = e_build_menu_new_from_db(apps_menu_db); } if (buildmenu) { - static E_Menu *menu = NULL; + static E_Menu *menu = NULL; + menu = buildmenu->menu; if (menu) { - e_menu_show_at_mouse(menu, ev->rx, ev->ry, ev->time); - } + e_menu_show_at_mouse(menu, ev->rx, ev->ry, + ev->time); + } } } } @@ -437,43 +456,45 @@ e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) static E_Build_Menu *buildmenu = NULL; if (!buildmenu) - { - D("building iconified windows menu\n"); - buildmenu = e_build_menu_new_from_iconified_borders(); - } - if (buildmenu && buildmenu->changed) - { - D("buildmenu changed! rebuild!\n"); - e_build_menu_iconified_borders_rebuild(buildmenu); - } + { + D("building iconified windows menu\n"); + buildmenu = e_build_menu_new_from_iconified_borders(); + } + if (buildmenu && buildmenu->changed) + { + D("buildmenu changed! rebuild!\n"); + e_build_menu_iconified_borders_rebuild(buildmenu); + } if (buildmenu) - { - static E_Menu *menu = NULL; - menu = buildmenu->menu; + { + static E_Menu *menu = NULL; + menu = buildmenu->menu; - if (menu) - { - D("showing iconified window menu\n"); - e_menu_show_at_mouse(menu, ev->rx, ev->ry, ev->time); - } - } + if (menu) + { + D("showing iconified window menu\n"); + e_menu_show_at_mouse(menu, ev->rx, ev->ry, ev->time); + } + } #endif } else if (_b == 3) { static E_Build_Menu *buildmenu = NULL; - + if (!buildmenu) - { - buildmenu = e_build_menu_new_from_gnome_apps("/usr/share/gnome/apps"); + { + buildmenu = + e_build_menu_new_from_gnome_apps("/usr/share/gnome/apps"); } if (buildmenu) { - static E_Menu *menu = NULL; + static E_Menu *menu = NULL; + menu = buildmenu->menu; if (menu) - e_menu_show_at_mouse(menu, ev->rx, ev->ry, ev->time); + e_menu_show_at_mouse(menu, ev->rx, ev->ry, ev->time); } } } @@ -491,12 +512,13 @@ e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) static void e_bg_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) { - Ecore_Event_Mouse_Down *ev; - E_View *v; - + Ecore_Event_Mouse_Down *ev; + E_View *v; + D_ENTER; - - if (!current_ev) D_RETURN; + + if (!current_ev) + D_RETURN; ev = current_ev->event; v = _data; if (v->select.on) @@ -531,49 +553,48 @@ e_bg_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y) UN(_b); } - void -e_view_deselect_all(E_View *v) +e_view_deselect_all(E_View * v) { - Evas_List l; + Evas_List l; D_ENTER; for (l = v->icons; l; l = l->next) - { - E_Icon *ic; + { + E_Icon *ic; - ic = l->data; - e_icon_deselect(ic); - } + ic = l->data; + e_icon_deselect(ic); + } D_RETURN; } void -e_view_deselect_all_except(E_Icon *not_ic) +e_view_deselect_all_except(E_Icon * not_ic) { - Evas_List l; + Evas_List l; D_ENTER; for (l = not_ic->view->icons; l; l = l->next) - { - E_Icon *ic; + { + E_Icon *ic; - ic = l->data; - if (ic != not_ic) - e_icon_deselect(ic); - } + ic = l->data; + if (ic != not_ic) + e_icon_deselect(ic); + } D_RETURN; } - void -e_view_icons_get_extents(E_View *v, int *min_x, int *min_y, int *max_x, int *max_y) +e_view_icons_get_extents(E_View * v, int *min_x, int *min_y, int *max_x, + int *max_y) { - Evas_List l; - int x1, x2, y1, y2; - + Evas_List l; + int x1, x2, y1, y2; + D_ENTER; - + x1 = v->extents.x1; x2 = v->extents.x2; y1 = v->extents.y1; @@ -586,21 +607,29 @@ e_view_icons_get_extents(E_View *v, int *min_x, int *min_y, int *max_x, int *max y2 = -999999999; if (!v->icons) { - if (min_x) *min_x = 0; - if (min_y) *min_y = 0; - if (max_x) *max_x = 1; - if (max_y) *max_y = 1; + if (min_x) + *min_x = 0; + if (min_y) + *min_y = 0; + if (max_x) + *max_x = 1; + if (max_y) + *max_y = 1; D_RETURN; } for (l = v->icons; l; l = l->next) { - E_Icon *ic; - + E_Icon *ic; + ic = l->data; - if (ic->geom.x < x1) x1 = ic->geom.x; - if (ic->geom.y < y1) y1 = ic->geom.y; - if (ic->geom.x + ic->geom.w > x2) x2 = ic->geom.x + ic->geom.w; - if (ic->geom.y + ic->geom.h > y2) y2 = ic->geom.y + ic->geom.h; + if (ic->geom.x < x1) + x1 = ic->geom.x; + if (ic->geom.y < y1) + y1 = ic->geom.y; + if (ic->geom.x + ic->geom.w > x2) + x2 = ic->geom.x + ic->geom.w; + if (ic->geom.y + ic->geom.h > y2) + y2 = ic->geom.y + ic->geom.h; } v->extents.x1 = x1; v->extents.y1 = y1; @@ -608,27 +637,33 @@ e_view_icons_get_extents(E_View *v, int *min_x, int *min_y, int *max_x, int *max v->extents.y2 = y2; } v->extents.valid = 1; - if (x1 > 0) x1 = 0; - if (y1 > 0) y1 = 0; - if (min_x) *min_x = x1; - if (min_y) *min_y = y1; - if (max_x) *max_x = x2 - 1; - if (max_y) *max_y = y2 - 1; + if (x1 > 0) + x1 = 0; + if (y1 > 0) + y1 = 0; + if (min_x) + *min_x = x1; + if (min_y) + *min_y = y1; + if (max_x) + *max_x = x2 - 1; + if (max_y) + *max_y = y2 - 1; D_RETURN; } void -e_view_icons_apply_xy(E_View *v) +e_view_icons_apply_xy(E_View * v) { - Evas_List l; - + Evas_List l; + D_ENTER; - + for (l = v->icons; l; l = l->next) { - E_Icon *ic; - + E_Icon *ic; + ic = l->data; e_icon_apply_xy(ic); } @@ -638,147 +673,158 @@ e_view_icons_apply_xy(E_View *v) } void -e_view_scroll_to(E_View *v, int sx, int sy) +e_view_scroll_to(E_View * v, int sx, int sy) { - int min_x, min_y, max_x, max_y; - + int min_x, min_y, max_x, max_y; + D_ENTER; - + e_view_icons_get_extents(v, &min_x, &min_y, &max_x, &max_y); if (sx < v->size.w - v->spacing.window.r - max_x) - sx = v->size.w - v->spacing.window.r - max_x; + sx = v->size.w - v->spacing.window.r - max_x; if (sx > v->spacing.window.l - min_x) - sx = v->spacing.window.l - min_x; + sx = v->spacing.window.l - min_x; if (sy < v->size.h - v->spacing.window.b - max_y) - sy = v->size.h - v->spacing.window.b - max_y; + sy = v->size.h - v->spacing.window.b - max_y; if (sy > v->spacing.window.t - min_y) - sy = v->spacing.window.t - min_y; + sy = v->spacing.window.t - min_y; - if ((sx == v->scroll.x) && (v->scroll.y == sy)) D_RETURN; + if ((sx == v->scroll.x) && (v->scroll.y == sy)) + D_RETURN; v->scroll.x = sx; v->scroll.y = sy; e_view_icons_apply_xy(v); - if (v->bg) e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); + if (v->bg) + e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); D_RETURN; } void -e_view_scroll_by(E_View *v, int sx, int sy) +e_view_scroll_by(E_View * v, int sx, int sy) { D_ENTER; - + e_view_scroll_to(v, v->scroll.x + sx, v->scroll.y + sy); D_RETURN; } void -e_view_scroll_to_percent(E_View *v, double psx, double psy) +e_view_scroll_to_percent(E_View * v, double psx, double psy) { - int min_x, min_y, max_x, max_y; - int sx, sy; - + int min_x, min_y, max_x, max_y; + int sx, sy; + D_ENTER; - + e_view_icons_get_extents(v, &min_x, &min_y, &max_x, &max_y); sx = (psx * ((double)max_x - (double)min_x)) - min_x; sy = (psy * ((double)max_y - (double)min_y)) - min_y; - - if (sx < v->size.w - v->spacing.window.r - max_x) - sx = v->size.w - v->spacing.window.r - max_x; - if (sx > v->spacing.window.l - min_x) - sx = v->spacing.window.l - min_x; - if (sy < v->size.h - v->spacing.window.b - max_y) - sy = v->size.h - v->spacing.window.b - max_y; - if (sy > v->spacing.window.t - min_y) - sy = v->spacing.window.t - min_y; - if ((sx == v->scroll.x) && (v->scroll.y == sy)) D_RETURN; + if (sx < v->size.w - v->spacing.window.r - max_x) + sx = v->size.w - v->spacing.window.r - max_x; + if (sx > v->spacing.window.l - min_x) + sx = v->spacing.window.l - min_x; + if (sy < v->size.h - v->spacing.window.b - max_y) + sy = v->size.h - v->spacing.window.b - max_y; + if (sy > v->spacing.window.t - min_y) + sy = v->spacing.window.t - min_y; + + if ((sx == v->scroll.x) && (v->scroll.y == sy)) + D_RETURN; v->scroll.x = sx; v->scroll.y = sy; e_view_icons_apply_xy(v); - if (v->bg) e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); + if (v->bg) + e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); D_RETURN; } void -e_view_get_viewable_percentage(E_View *v, double *vw, double *vh) +e_view_get_viewable_percentage(E_View * v, double *vw, double *vh) { - int min_x, min_y, max_x, max_y; - double p; - + int min_x, min_y, max_x, max_y; + double p; + D_ENTER; - + e_view_icons_get_extents(v, &min_x, &min_y, &max_x, &max_y); if (min_x == max_x) { - if (vw) *vw = 0; + if (vw) + *vw = 0; } else { p = ((double)(v->size.w - v->spacing.window.l - v->spacing.window.r)) / - ((double)(max_x - min_x)); - if (vw) *vw = p; + ((double)(max_x - min_x)); + if (vw) + *vw = p; } if (min_y == max_y) { - if (vh) *vh = 0; + if (vh) + *vh = 0; } else { p = ((double)(v->size.h - v->spacing.window.t - v->spacing.window.b)) / - ((double)(max_y - min_y)); - if (vh) *vh = p; + ((double)(max_y - min_y)); + if (vh) + *vh = p; } D_RETURN; } void -e_view_get_position_percentage(E_View *v, double *vx, double *vy) +e_view_get_position_percentage(E_View * v, double *vx, double *vy) { - int min_x, min_y, max_x, max_y; - double p; - + int min_x, min_y, max_x, max_y; + double p; + D_ENTER; - + e_view_icons_get_extents(v, &min_x, &min_y, &max_x, &max_y); if (min_x == max_x) { - if (vx) *vx = 0; + if (vx) + *vx = 0; } else { p = ((double)(v->scroll.x - min_x)) / ((double)(max_x - min_x)); - if (vx) *vx = p; + if (vx) + *vx = p; } if (min_y == max_y) { - if (vy) *vy = 0; + if (vy) + *vy = 0; } else { p = ((double)(v->scroll.y - min_y)) / ((double)(max_y - min_y)); - if (vy) *vy = p; + if (vy) + *vy = p; } D_RETURN; } - static void e_idle(void *data) { - Evas_List l; + Evas_List l; D_ENTER; - + for (l = VM->views; l; l = l->next) { - E_View *v; + E_View *v; v = l->data; e_view_update(v); @@ -789,42 +835,36 @@ e_idle(void *data) } void -e_view_geometry_record(E_View *v) +e_view_geometry_record(E_View * v) { D_ENTER; - + if (e_fs_get_connection()) { - int left, top; - + int left, top; + D("Record geom for view\n"); - ecore_window_get_frame_size(v->win.base, &left, NULL, - &top, NULL); + ecore_window_get_frame_size(v->win.base, &left, NULL, &top, NULL); efsd_set_metadata_int(e_fs_get_connection(), - "/view/x", v->model->dir, - v->location.x - left); + "/view/x", v->model->dir, v->location.x - left); efsd_set_metadata_int(e_fs_get_connection(), - "/view/y", v->model->dir, - v->location.y - top); + "/view/y", v->model->dir, v->location.y - top); efsd_set_metadata_int(e_fs_get_connection(), - "/view/w", v->model->dir, - v->size.w); + "/view/w", v->model->dir, v->size.w); efsd_set_metadata_int(e_fs_get_connection(), - "/view/h", v->model->dir, - v->size.h); + "/view/h", v->model->dir, v->size.h); } D_RETURN; } - static void e_view_geometry_record_timeout(int val, void *data) { - E_View *v; - + E_View *v; + D_ENTER; - + v = data; e_view_geometry_record(v); @@ -833,94 +873,101 @@ e_view_geometry_record_timeout(int val, void *data) } void -e_view_queue_geometry_record(E_View *v) +e_view_queue_geometry_record(E_View * v) { - char name[PATH_MAX]; - + char name[PATH_MAX]; + D_ENTER; - + snprintf(name, PATH_MAX, "geometry_record.%s", v->model->dir); ecore_add_event_timer(name, 0.10, e_view_geometry_record_timeout, 0, v); D_RETURN; } - void -e_view_queue_icon_xy_record(E_View *v) +e_view_queue_icon_xy_record(E_View * v) { - char name[PATH_MAX]; - + char name[PATH_MAX]; + D_ENTER; - + snprintf(name, PATH_MAX, "icon_xy_record.%s", v->model->dir); ecore_add_event_timer(name, 0.10, e_view_write_icon_xy_timeout, 0, v); D_RETURN; } - static void e_configure(Ecore_Event * ev) { Ecore_Event_Window_Configure *e; - E_View *v; - + E_View *v; + D_ENTER; - + e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - /* win, root, x, y, w, h, wm_generated */ - D("Configure for view: %s\n", v->name); - if (e->wm_generated) - { - D("wm generated %i %i, %ix%i\n", e->x, e->y, e->w, e->h); - if ((e->x != v->location.x) || (e->y != v->location.y)) - { - D("new spot!\n"); - v->location.x = e->x; - v->location.y = e->y; - /* FIXME */ - //e_view_queue_geometry_record(v); - } - } - D("size %ix%i\n", e->w, e->h); - if ((e->w != v->size.w) || (e->h != v->size.h) || (v->size.force)) - { - v->size.force = 0; - D("... a new size!\n"); - v->size.w = e->w; - v->size.h = e->h; - if (v->pmap) ecore_pixmap_free(v->pmap); - v->pmap = 0; - ecore_window_resize(v->win.main, v->size.w, v->size.h); - if (v->options.back_pixmap) - { - v->pmap = ecore_pixmap_new(v->win.main, v->size.w, v->size.h, 0); - evas_set_output(v->evas, ecore_display_get(), v->pmap, - evas_get_visual(v->evas), - evas_get_colormap(v->evas)); - ecore_window_set_background_pixmap(v->win.main, v->pmap); - ecore_window_clear(v->win.main); - } - if (v->bg) e_bg_resize(v->bg, v->size.w, v->size.h); - D("evas_set_output_viewpor(%p)\n", v->evas); - evas_set_output_viewport(v->evas, 0, 0, v->size.w, v->size.h); - evas_set_output_size(v->evas, v->size.w, v->size.h); - e_view_scroll_to(v, v->scroll.x, v->scroll.y); - e_view_arrange(v); - /* FIXME */ - //e_view_queue_geometry_record(v); - e_scrollbar_move(v->scrollbar.v, v->size.w - v->scrollbar.v->w, 0); - e_scrollbar_resize(v->scrollbar.v, v->scrollbar.v->w, v->size.h - v->scrollbar.h->h); - e_scrollbar_move(v->scrollbar.h, 0, v->size.h - v->scrollbar.h->h); - e_scrollbar_resize(v->scrollbar.h, v->size.w - v->scrollbar.v->w, v->scrollbar.h->h); - } - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + /* win, root, x, y, w, h, wm_generated */ + D("Configure for view: %s\n", v->name); + if (e->wm_generated) + { + D("wm generated %i %i, %ix%i\n", e->x, e->y, e->w, e->h); + if ((e->x != v->location.x) || (e->y != v->location.y)) + { + D("new spot!\n"); + v->location.x = e->x; + v->location.y = e->y; + /* FIXME */ + //e_view_queue_geometry_record(v); + } + } + D("size %ix%i\n", e->w, e->h); + if ((e->w != v->size.w) || (e->h != v->size.h) || (v->size.force)) + { + v->size.force = 0; + D("... a new size!\n"); + v->size.w = e->w; + v->size.h = e->h; + if (v->pmap) + ecore_pixmap_free(v->pmap); + v->pmap = 0; + ecore_window_resize(v->win.main, v->size.w, v->size.h); + if (v->options.back_pixmap) + { + v->pmap = + ecore_pixmap_new(v->win.main, v->size.w, v->size.h, + 0); + evas_set_output(v->evas, ecore_display_get(), v->pmap, + evas_get_visual(v->evas), + evas_get_colormap(v->evas)); + ecore_window_set_background_pixmap(v->win.main, v->pmap); + ecore_window_clear(v->win.main); + } + if (v->bg) + e_bg_resize(v->bg, v->size.w, v->size.h); + D("evas_set_output_viewpor(%p)\n", v->evas); + evas_set_output_viewport(v->evas, 0, 0, v->size.w, v->size.h); + evas_set_output_size(v->evas, v->size.w, v->size.h); + e_view_scroll_to(v, v->scroll.x, v->scroll.y); + e_view_arrange(v); + /* FIXME */ + //e_view_queue_geometry_record(v); + e_scrollbar_move(v->scrollbar.v, + v->size.w - v->scrollbar.v->w, 0); + e_scrollbar_resize(v->scrollbar.v, v->scrollbar.v->w, + v->size.h - v->scrollbar.h->h); + e_scrollbar_move(v->scrollbar.h, 0, + v->size.h - v->scrollbar.h->h); + e_scrollbar_resize(v->scrollbar.h, + v->size.w - v->scrollbar.v->w, + v->scrollbar.h->h); + } + } + } D_RETURN; } @@ -928,16 +975,16 @@ static void e_property(Ecore_Event * ev) { Ecore_Event_Window_Configure *e; - E_View *v; + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + } + } D_RETURN; } @@ -945,16 +992,16 @@ static void e_unmap(Ecore_Event * ev) { Ecore_Event_Window_Unmap *e; - E_View *v; + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + } + } D_RETURN; } @@ -962,16 +1009,16 @@ static void e_visibility(Ecore_Event * ev) { Ecore_Event_Window_Unmap *e; - E_View *v; + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + } + } D_RETURN; } @@ -979,16 +1026,16 @@ static void e_focus_in(Ecore_Event * ev) { Ecore_Event_Window_Focus_In *e; - E_View *v; + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + } + } D_RETURN; } @@ -996,16 +1043,16 @@ static void e_focus_out(Ecore_Event * ev) { Ecore_Event_Window_Focus_Out *e; - E_View *v; + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + } + } D_RETURN; } @@ -1013,21 +1060,20 @@ static void e_delete(Ecore_Event * ev) { Ecore_Event_Window_Delete *e; - E_View *v; + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - e_object_unref(E_OBJECT(v)); - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + e_object_unref(E_OBJECT(v)); + } + } D_RETURN; } - /* * dnd status handler * @@ -1036,149 +1082,154 @@ static void e_dnd_status(Ecore_Event * ev) { Ecore_Event_Dnd_Drop_Status *e; + /* - * typedef struct _ecore_event_dnd_drop_status - * { - * Window win, root, source_win; - * int x, y, w, h; - * int copy, link, move, private; - * int all_position_msgs; - * int ok; - * } Ecore_Event_Dnd_Drop_Status; - */ - E_View *v; + * * typedef struct _ecore_event_dnd_drop_status + * * { + * * Window win, root, source_win; + * * int x, y, w, h; + * * int copy, link, move, private; + * * int all_position_msgs; + * * int ok; + * * } Ecore_Event_Dnd_Drop_Status; + */ + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - if( dnd_pending_mode != E_DND_DELETED && - dnd_pending_mode != E_DND_COPIED ) - { - if( e->copy ) - dnd_pending_mode = E_DND_COPY; - else if( e->move ) - dnd_pending_mode = E_DND_MOVE; - else if( e->link ) - dnd_pending_mode = E_DND_LINK; - else - dnd_pending_mode = E_DND_ASK; - } - ecore_window_dnd_ok(e->ok); - v->changed = 1; - v->drag.icon_hide = 1; - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + if (dnd_pending_mode != E_DND_DELETED && + dnd_pending_mode != E_DND_COPIED) + { + if (e->copy) + dnd_pending_mode = E_DND_COPY; + else if (e->move) + dnd_pending_mode = E_DND_MOVE; + else if (e->link) + dnd_pending_mode = E_DND_LINK; + else + dnd_pending_mode = E_DND_ASK; + } + ecore_window_dnd_ok(e->ok); + v->changed = 1; + v->drag.icon_hide = 1; + } + } D_RETURN; } - -static void +static void e_wheel(Ecore_Event * ev) { - Ecore_Event_Wheel *e; - E_View *v; + Ecore_Event_Wheel *e; + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_main_window(e->win)) ) - { - } - } + { + if ((v = e_view_machine_get_view_by_main_window(e->win))) + { + } + } D_RETURN; } static void e_key_down(Ecore_Event * ev) { - Ecore_Event_Key_Down *e; - E_View *v; + Ecore_Event_Key_Down *e; + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_main_window(e->win)) - ||(v=e_view_machine_get_view_by_base_window(e->win)) ) - { - if (!strcmp(e->key, "Up")) - { - e_scrollbar_set_value(v->scrollbar.v, v->scrollbar.v->val - 8); - } - else if (!strcmp(e->key, "Down")) - { - e_scrollbar_set_value(v->scrollbar.v, v->scrollbar.v->val + 8); - } - else if (!strcmp(e->key, "Left")) - { - e_scrollbar_set_value(v->scrollbar.h, v->scrollbar.h->val - 8); - } - else if (!strcmp(e->key, "Right")) - { - e_scrollbar_set_value(v->scrollbar.h, v->scrollbar.h->val + 8); - } - else if (!strcmp(e->key, "Escape")) - { - } - else - { - char *type; + { + if ((v = e_view_machine_get_view_by_main_window(e->win)) + || (v = e_view_machine_get_view_by_base_window(e->win))) + { + if (!strcmp(e->key, "Up")) + { + e_scrollbar_set_value(v->scrollbar.v, + v->scrollbar.v->val - 8); + } + else if (!strcmp(e->key, "Down")) + { + e_scrollbar_set_value(v->scrollbar.v, + v->scrollbar.v->val + 8); + } + else if (!strcmp(e->key, "Left")) + { + e_scrollbar_set_value(v->scrollbar.h, + v->scrollbar.h->val - 8); + } + else if (!strcmp(e->key, "Right")) + { + e_scrollbar_set_value(v->scrollbar.h, + v->scrollbar.h->val + 8); + } + else if (!strcmp(e->key, "Escape")) + { + } + else + { + char *type; - type = ecore_keypress_translate_into_typeable(e); - if (type) - { - } - } - } - } + type = ecore_keypress_translate_into_typeable(e); + if (type) + { + } + } + } + } D_RETURN; } static void e_key_up(Ecore_Event * ev) { - Ecore_Event_Key_Up *e; - E_View *v; - + Ecore_Event_Key_Up *e; + E_View *v; + D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_main_window(e->win)) ) - { - } - } + { + if ((v = e_view_machine_get_view_by_main_window(e->win))) + { + } + } D_RETURN; } static void e_mouse_down(Ecore_Event * ev) { - Ecore_Event_Mouse_Down *e; - E_View *v; + Ecore_Event_Mouse_Down *e; + E_View *v; D_ENTER; e = ev->event; current_ev = ev; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_main_window(e->win)) ) - { - int focus_mode; - E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); + { + if ((v = e_view_machine_get_view_by_main_window(e->win))) + { + int focus_mode; - E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); - if (focus_mode == 2) - ecore_focus_to_window(v->win.base); - evas_event_button_down(v->evas, e->x, e->y, e->button); - current_ev = NULL; - D_RETURN; - } - } + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); + + E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); + if (focus_mode == 2) + ecore_focus_to_window(v->win.base); + evas_event_button_down(v->evas, e->x, e->y, e->button); + current_ev = NULL; + D_RETURN; + } + } current_ev = NULL; D_RETURN; } @@ -1186,19 +1237,19 @@ e_mouse_down(Ecore_Event * ev) static void e_mouse_up(Ecore_Event * ev) { - Ecore_Event_Mouse_Up *e; - E_View *v; + Ecore_Event_Mouse_Up *e; + E_View *v; D_ENTER; e = ev->event; current_ev = ev; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_main_window(e->win)) ) - { - evas_event_button_up(v->evas, e->x, e->y, e->button); - } - } + { + if ((v = e_view_machine_get_view_by_main_window(e->win))) + { + evas_event_button_up(v->evas, e->x, e->y, e->button); + } + } current_ev = NULL; D_RETURN; } @@ -1206,19 +1257,19 @@ e_mouse_up(Ecore_Event * ev) static void e_mouse_move(Ecore_Event * ev) { - Ecore_Event_Mouse_Move *e; - E_View *v; + Ecore_Event_Mouse_Move *e; + E_View *v; D_ENTER; e = ev->event; current_ev = ev; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_main_window(e->win)) ) - { - evas_event_move(v->evas, e->x, e->y); - } - } + { + if ((v = e_view_machine_get_view_by_main_window(e->win))) + { + evas_event_move(v->evas, e->x, e->y); + } + } current_ev = NULL; D_RETURN; } @@ -1226,22 +1277,22 @@ e_mouse_move(Ecore_Event * ev) static void e_mouse_in(Ecore_Event * ev) { - Ecore_Event_Window_Enter *e; - E_View *v; - + Ecore_Event_Window_Enter *e; + E_View *v; + D_ENTER; e = ev->event; current_ev = ev; if (e && e->win) - { - if( (v = e_view_machine_get_view_by_main_window(e->win)) ) - { - if (v->model->is_desktop) - { - evas_event_enter(v->evas); - } - } - } + { + if ((v = e_view_machine_get_view_by_main_window(e->win))) + { + if (v->model->is_desktop) + { + evas_event_enter(v->evas); + } + } + } current_ev = NULL; D_RETURN; @@ -1250,19 +1301,19 @@ e_mouse_in(Ecore_Event * ev) static void e_mouse_out(Ecore_Event * ev) { - Ecore_Event_Window_Leave *e; - E_View *v; - + Ecore_Event_Window_Leave *e; + E_View *v; + D_ENTER; e = ev->event; current_ev = ev; if (e && e->win) - { - if( (v = e_view_machine_get_view_by_main_window(e->win)) ) - { - evas_event_leave(v->evas); - } - } + { + if ((v = e_view_machine_get_view_by_main_window(e->win))) + { + evas_event_leave(v->evas); + } + } current_ev = NULL; D_RETURN; @@ -1271,94 +1322,95 @@ e_mouse_out(Ecore_Event * ev) static void e_window_expose(Ecore_Event * ev) { - Ecore_Event_Window_Expose *e; - E_View *v; + Ecore_Event_Window_Expose *e; + E_View *v; D_ENTER; e = ev->event; current_ev = ev; if (e && e->win) - { - if( (v = e_view_machine_get_view_by_main_window(e->win)) ) - { - if (!(v->pmap)) - evas_update_rect(v->evas, e->x, e->y, e->w, e->h); - v->changed = 1; - } - } + { + if ((v = e_view_machine_get_view_by_main_window(e->win))) + { + if (!(v->pmap)) + evas_update_rect(v->evas, e->x, e->y, e->w, e->h); + v->changed = 1; + } + } D_RETURN; } -Ecore_Event * +Ecore_Event * e_view_get_current_event(void) { D_ENTER; - + D_RETURN_(current_ev); } int -e_view_filter_file(E_View *v, char *file) +e_view_filter_file(E_View * v, char *file) { D_ENTER; - + if (file[0] == '.') - D_RETURN_(0); + D_RETURN_(0); D_RETURN_(1); UN(v); } - - static int e_view_restart_alphabetical_qsort_cb(const void *data1, const void *data2) { - E_Icon *ic, *ic2; - + E_Icon *ic, *ic2; + D_ENTER; - - ic = *((E_Icon **)data1); - ic2 = *((E_Icon **)data2); + + ic = *((E_Icon **) data1); + ic2 = *((E_Icon **) data2); D_RETURN_(strcmp(ic->file->file, ic2->file->file)); } void -e_view_resort_alphabetical(E_View *v) +e_view_resort_alphabetical(E_View * v) { - Evas_List icons = NULL, l; - E_Icon **array; - int i, count; - + Evas_List icons = NULL, l; + E_Icon **array; + int i, count; + D_ENTER; - - if (!v->icons) D_RETURN; - for (count = 0, l = v->icons; l; l = l->next) count++; + + if (!v->icons) + D_RETURN; + for (count = 0, l = v->icons; l; l = l->next) + count++; array = malloc(sizeof(E_Icon *) * count); - for (i = 0, l = v->icons; l; l = l->next) array[i++] = l->data; + for (i = 0, l = v->icons; l; l = l->next) + array[i++] = l->data; D("qsort %i elements...\n", count); - qsort(array, count, sizeof(E_Icon *), - e_view_restart_alphabetical_qsort_cb); - for (i = 0; i < count; i++) icons = evas_list_append(icons, array[i]); + qsort(array, count, sizeof(E_Icon *), e_view_restart_alphabetical_qsort_cb); + for (i = 0; i < count; i++) + icons = evas_list_append(icons, array[i]); free(array); - + evas_list_free(v->icons); v->icons = icons; - + D("done...\n"); D_RETURN; } void -e_view_arrange(E_View *v) +e_view_arrange(E_View * v) { - Evas_List l; - int x, y; - int x1, x2, y1, y2; - double sv, sr, sm; - + Evas_List l; + int x, y; + int x1, x2, y1, y2; + double sv, sr, sm; + D_ENTER; x = v->spacing.window.l; @@ -1366,10 +1418,10 @@ e_view_arrange(E_View *v) for (l = v->icons; l; l = l->next) { - E_Icon *ic; - + E_Icon *ic; + ic = l->data; - if ((x != v->spacing.window.l) && + if ((x != v->spacing.window.l) && ((x + ic->geom.w) > v->size.w - v->spacing.window.r)) { x = v->spacing.window.l; @@ -1380,38 +1432,44 @@ e_view_arrange(E_View *v) e_icon_apply_xy(ic); x += ic->geom.w + v->spacing.icon.s; } - + e_view_icons_get_extents(v, &x1, &y1, &x2, &y2); - sv = - (v->scroll.y - v->spacing.window.t); + sv = -(v->scroll.y - v->spacing.window.t); sr = v->size.h - v->spacing.window.t - v->spacing.window.b; sm = y2 - y1; - if (sr > sm) sr = sm; + if (sr > sm) + sr = sm; e_scrollbar_set_range(v->scrollbar.v, sr); - e_scrollbar_set_max(v->scrollbar.v, sm); + e_scrollbar_set_max(v->scrollbar.v, sm); e_scrollbar_set_value(v->scrollbar.v, sv); - if (sr < sm) e_scrollbar_show(v->scrollbar.v); - else e_scrollbar_hide(v->scrollbar.v); + if (sr < sm) + e_scrollbar_show(v->scrollbar.v); + else + e_scrollbar_hide(v->scrollbar.v); - sv = - (v->scroll.x - v->spacing.window.l); + sv = -(v->scroll.x - v->spacing.window.l); sr = v->size.w - v->spacing.window.l - v->spacing.window.r; sm = x2 - x1; - if (sr > sm) sr = sm; + if (sr > sm) + sr = sm; e_scrollbar_set_range(v->scrollbar.h, sr); - e_scrollbar_set_max(v->scrollbar.h, sm); + e_scrollbar_set_max(v->scrollbar.h, sm); e_scrollbar_set_value(v->scrollbar.h, sv); - if (sr < sm) e_scrollbar_show(v->scrollbar.h); - else e_scrollbar_hide(v->scrollbar.h); + if (sr < sm) + e_scrollbar_show(v->scrollbar.h); + else + e_scrollbar_hide(v->scrollbar.h); v->changed = 1; D_RETURN; } void -e_view_resort(E_View *v) +e_view_resort(E_View * v) { D_ENTER; - + e_view_resort_alphabetical(v); e_view_arrange(v); @@ -1421,10 +1479,10 @@ e_view_resort(E_View *v) static void e_view_resort_timeout(int val, void *data) { - E_View *v; - + E_View *v; + D_ENTER; - + v = data; e_view_resort(v); v->have_resort_queued = 0; @@ -1434,13 +1492,14 @@ e_view_resort_timeout(int val, void *data) } void -e_view_queue_resort(E_View *v) +e_view_queue_resort(E_View * v) { - char name[PATH_MAX]; - + char name[PATH_MAX]; + D_ENTER; - - if (v->have_resort_queued) D_RETURN; + + if (v->have_resort_queued) + D_RETURN; v->have_resort_queued = 1; snprintf(name, PATH_MAX, "resort_timer.%s", v->name); ecore_add_event_timer(name, 1.0, e_view_resort_timeout, 0, v); @@ -1449,24 +1508,28 @@ e_view_queue_resort(E_View *v) } static void -e_view_cleanup(E_View *v) +e_view_cleanup(E_View * v) { - char name[PATH_MAX]; + char name[PATH_MAX]; + D_ENTER; /* write geometry to metadata. This is done directly and * not via a timeout, because we will destroy the object after this.*/ e_view_geometry_record(v); - + if (v->iconbar) - { - e_iconbar_save_out_final(v->iconbar); - e_object_unref(E_OBJECT(v->iconbar)); - } - if (v->bg) e_bg_free(v->bg); - if (v->scrollbar.h) e_object_unref(E_OBJECT(v->scrollbar.h)); - if (v->scrollbar.v) e_object_unref(E_OBJECT(v->scrollbar.v)); + { + e_iconbar_save_out_final(v->iconbar); + e_object_unref(E_OBJECT(v->iconbar)); + } + if (v->bg) + e_bg_free(v->bg); + if (v->scrollbar.h) + e_object_unref(E_OBJECT(v->scrollbar.h)); + if (v->scrollbar.v) + e_object_unref(E_OBJECT(v->scrollbar.v)); ecore_window_destroy(v->win.base); - + snprintf(name, PATH_MAX, "resort_timer.%s", v->name); ecore_del_event_timer(name); @@ -1474,19 +1537,19 @@ e_view_cleanup(E_View *v) e_view_model_unregister_view(v); e_view_machine_unregister_view(v); /* FIXME: clean up the rest!!! this leaks ... */ - + /* Call the destructor of the base class */ e_object_cleanup(E_OBJECT(v)); D_RETURN; } -E_View * +E_View * e_view_new(void) { - E_View *v; - + E_View *v; + D_ENTER; - + v = NEW(E_View, 1); ZERO(v, E_View, 1); @@ -1495,7 +1558,7 @@ e_view_new(void) #define SOFT_DESK /* #define X_DESK */ /* #define GL_DESK */ - + #ifdef SOFT_DESK /* ONLY alpha software can be "backing stored" */ v->options.render_method = RENDER_METHOD_ALPHA_SOFTWARE; @@ -1507,7 +1570,7 @@ e_view_new(void) #else v->options.render_method = RENDER_METHOD_3D_HARDWARE; v->options.back_pixmap = 0; -#endif +#endif #endif v->select.config.grad_size.l = 8; v->select.config.grad_size.r = 8; @@ -1534,128 +1597,129 @@ _member.r = _r; _member.g = _g; _member.b = _b; _member.a = _a; v->spacing.icon.b = 7; e_view_machine_register_view(v); - - D_RETURN_(v); + + D_RETURN_(v); } void -e_view_set_dir(E_View *v, char *path, int is_desktop) +e_view_set_dir(E_View * v, char *path, int is_desktop) { - E_View_Model *m = NULL; - char buf[PATH_MAX]; + E_View_Model *m = NULL; + char buf[PATH_MAX]; D_ENTER; if (!v || !path || *path == 0) - D_RETURN; + D_RETURN; if (!(m = e_view_machine_model_lookup(path))) - { - D("Model for this dir doesn't exist, make a new one\n"); - m = e_view_model_new(); - e_view_model_set_dir(m, path); + { + D("Model for this dir doesn't exist, make a new one\n"); + m = e_view_model_new(); + e_view_model_set_dir(m, path); - snprintf(buf, PATH_MAX, "%s/.e_background.bg.db", m->dir); - if (!e_file_exists(buf)) - { - if (is_desktop) - { - snprintf(buf, PATH_MAX, "%s/default.bg.db", e_config_get("backgrounds")); - } - else - { - snprintf(buf, PATH_MAX, "%s/view.bg.db", e_config_get("backgrounds")); - } - } - e_strdup(m->bg_file, buf); - m->is_desktop = is_desktop; - } + snprintf(buf, PATH_MAX, "%s/.e_background.bg.db", m->dir); + if (!e_file_exists(buf)) + { + if (is_desktop) + { + snprintf(buf, PATH_MAX, "%s/default.bg.db", + e_config_get("backgrounds")); + } + else + { + snprintf(buf, PATH_MAX, "%s/view.bg.db", + e_config_get("backgrounds")); + } + } + e_strdup(m->bg_file, buf); + m->is_desktop = is_desktop; + } if (m) - { - e_view_model_register_view(m, v); - /* FIXME do a real naming scheme here */ - snprintf(buf, PATH_MAX, "%s:%d", v->model->dir, e_object_get_usecount(E_OBJECT(v->model))); - e_strdup(v->name, buf); - D("assigned name to view: %s\n",v->name); + { + e_view_model_register_view(m, v); + /* FIXME do a real naming scheme here */ + snprintf(buf, PATH_MAX, "%s:%d", v->model->dir, + e_object_get_usecount(E_OBJECT(v->model))); + e_strdup(v->name, buf); + D("assigned name to view: %s\n", v->name); - /* Request metadata via efsd */ - v->geom_get.x = efsd_get_metadata(e_fs_get_connection(), - "/view/x", v->model->dir, EFSD_INT); - v->geom_get.y = efsd_get_metadata(e_fs_get_connection(), - "/view/y", v->model->dir, EFSD_INT); - v->geom_get.w = efsd_get_metadata(e_fs_get_connection(), - "/view/w", v->model->dir, EFSD_INT); - v->geom_get.h = efsd_get_metadata(e_fs_get_connection(), - "/view/h", v->model->dir, EFSD_INT); - /* FIXME currently, we dont use this anyway */ - /* - * v->getbg = efsd_get_metadata(e_fs_get_connection(), - * "/view/background", v->model->dir, EFSD_STRING); - */ - v->geom_get.busy = 1; - } + /* Request metadata via efsd */ + v->geom_get.x = efsd_get_metadata(e_fs_get_connection(), + "/view/x", v->model->dir, EFSD_INT); + v->geom_get.y = efsd_get_metadata(e_fs_get_connection(), + "/view/y", v->model->dir, EFSD_INT); + v->geom_get.w = efsd_get_metadata(e_fs_get_connection(), + "/view/w", v->model->dir, EFSD_INT); + v->geom_get.h = efsd_get_metadata(e_fs_get_connection(), + "/view/h", v->model->dir, EFSD_INT); + /* FIXME currently, we dont use this anyway */ + /* + * * v->getbg = efsd_get_metadata(e_fs_get_connection(), + * * "/view/background", v->model->dir, EFSD_STRING); + */ + v->geom_get.busy = 1; + } else - { - /* FIXME error handling */ - } + { + /* FIXME error handling */ + } D_RETURN; } void -e_view_realize(E_View *v) +e_view_realize(E_View * v) { - int max_colors = 216; - int font_cache = 1024 * 1024; - int image_cache = 8192 * 1024; - char *font_dir; - + int max_colors = 216; + int font_cache = 1024 * 1024; + int image_cache = 8192 * 1024; + char *font_dir; + D_ENTER; - if (v->evas) D_RETURN; - v->win.base = ecore_window_new(0, - v->location.x, v->location.y, - v->size.w, v->size.h); + if (v->evas) + D_RETURN; + v->win.base = ecore_window_new(0, + v->location.x, v->location.y, + v->size.w, v->size.h); ecore_window_set_delete_inform(v->win.base); font_dir = e_config_get("fonts"); v->evas = evas_new_all(ecore_display_get(), v->win.base, 0, 0, v->size.w, v->size.h, v->options.render_method, - max_colors, - font_cache, - image_cache, - font_dir); + max_colors, font_cache, image_cache, font_dir); v->win.main = evas_get_window(v->evas); e_cursors_display_in_window(v->win.main, "View"); evas_event_move(v->evas, -999999, -999999); ecore_window_set_events(v->win.base, - XEV_VISIBILITY | XEV_CONFIGURE | - XEV_PROPERTY | XEV_FOCUS); - ecore_window_set_events(v->win.main, - XEV_EXPOSE | XEV_MOUSE_MOVE | - XEV_BUTTON | XEV_IN_OUT | XEV_KEY); + XEV_VISIBILITY | XEV_CONFIGURE | + XEV_PROPERTY | XEV_FOCUS); + ecore_window_set_events(v->win.main, + XEV_EXPOSE | XEV_MOUSE_MOVE | + XEV_BUTTON | XEV_IN_OUT | XEV_KEY); if (v->options.back_pixmap) { v->pmap = ecore_pixmap_new(v->win.main, v->size.w, v->size.h, 0); evas_set_output(v->evas, ecore_display_get(), v->pmap, - evas_get_visual(v->evas), - evas_get_colormap(v->evas)); - ecore_window_set_background_pixmap(v->win.main, v->pmap); + evas_get_visual(v->evas), evas_get_colormap(v->evas)); + ecore_window_set_background_pixmap(v->win.main, v->pmap); } + if (v->bg) { e_bg_add_to_evas(v->bg, v->evas); e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); e_bg_set_layer(v->bg, 100); e_bg_resize(v->bg, v->size.w, v->size.h); - + e_bg_callback_add(v->bg, CALLBACK_MOUSE_UP, e_bg_up_cb, v); e_bg_callback_add(v->bg, CALLBACK_MOUSE_DOWN, e_bg_down_cb, v); e_bg_callback_add(v->bg, CALLBACK_MOUSE_MOVE, e_bg_move_cb, v); - + e_bg_show(v->bg); } - + v->scrollbar.v = e_scrollbar_new(); e_scrollbar_set_change_func(v->scrollbar.v, e_view_scrollbar_v_change_cb, v); e_scrollbar_set_direction(v->scrollbar.v, 1); @@ -1673,24 +1737,27 @@ e_view_realize(E_View *v) e_scrollbar_set_value(v->scrollbar.h, 0.0); e_scrollbar_set_range(v->scrollbar.h, 1.0); e_scrollbar_set_max(v->scrollbar.h, 1.0); - + e_scrollbar_move(v->scrollbar.v, v->size.w - v->scrollbar.v->w, 0); - e_scrollbar_resize(v->scrollbar.v, v->scrollbar.v->w, v->size.h - v->scrollbar.h->h); + e_scrollbar_resize(v->scrollbar.v, v->scrollbar.v->w, + v->size.h - v->scrollbar.h->h); e_scrollbar_move(v->scrollbar.h, 0, v->size.h - v->scrollbar.h->h); - e_scrollbar_resize(v->scrollbar.h, v->size.w - v->scrollbar.v->w, v->scrollbar.h->h); - + e_scrollbar_resize(v->scrollbar.h, v->size.w - v->scrollbar.v->w, + v->scrollbar.h->h); + /* I support dnd */ - ecore_window_dnd_advertise(v->win.base); - + ecore_window_dnd_advertise(v->win.base); + ecore_window_show(v->win.main); - - if (!v->iconbar) v->iconbar = e_iconbar_new(v); + + if (!v->iconbar) + v->iconbar = e_iconbar_new(v); if (v->iconbar) - { - e_iconbar_realize(v->iconbar); - e_iconbar_set_view_window_spacing(v->iconbar); - } - + { + e_iconbar_realize(v->iconbar); + e_iconbar_set_view_window_spacing(v->iconbar); + } + e_view_bg_reload(v); /* e_epplet_load_from_layout(v);*/ v->changed = 1; @@ -1698,82 +1765,85 @@ e_view_realize(E_View *v) } void -e_view_populate(E_View *v) +e_view_populate(E_View * v) { - Evas_List l; + Evas_List l; + /* populate with icons for all files in the dir we are monitoring. * This has to be called _after_ view_realize because * view_add_file needs the evas to be intialized */ - for (l=v->model->files;l;l=l->next) - { - E_File *f = (E_File*) l->data; - E_Icon *ic; - e_view_file_add(v, f); - /* try to show the icons for the file. If this is not the first for - * the dir this will succeed because filetype and stat info have - * already been received. If not, it'll be shown when those arrive. */ - ic = e_icon_find_by_file(v, f->file); - if (ic) - { - e_icon_update_state(ic); - e_icon_initial_show(ic); - } - } + for (l = v->model->files; l; l = l->next) + { + E_File *f = (E_File *) l->data; + E_Icon *ic; + + e_view_file_add(v, f); + /* try to show the icons for the file. If this is not the first for + * the dir this will succeed because filetype and stat info have + * already been received. If not, it'll be shown when those arrive. */ + ic = e_icon_find_by_file(v, f->file); + if (ic) + { + e_icon_update_state(ic); + e_icon_initial_show(ic); + } + } } void -e_view_update(E_View *v) +e_view_update(E_View * v) { - Evas_List l; - + Evas_List l; + D_ENTER; if (!v->changed) D_RETURN; - - if(v->drag.icon_hide) - { - for (l = v->icons; l; l = l->next) - { - E_Icon *ic; - ic = l->data; - e_icon_hide_delete_pending(ic); - } - v->drag.icon_hide = 0; - v_dnd_source = v; - } - if(v->drag.icon_show) - { - for (l = v->icons; l; l = l->next) - { - E_Icon *ic; + if (v->drag.icon_hide) + { + for (l = v->icons; l; l = l->next) + { + E_Icon *ic; - ic = l->data; - e_icon_show_delete_end(ic, dnd_pending_mode); - } - dnd_pending_mode = E_DND_NONE; - v->drag.icon_show = 0; - } + ic = l->data; + e_icon_hide_delete_pending(ic); + } + v->drag.icon_hide = 0; + v_dnd_source = v; + } + if (v->drag.icon_show) + { + for (l = v->icons; l; l = l->next) + { + E_Icon *ic; + + ic = l->data; + e_icon_show_delete_end(ic, dnd_pending_mode); + } + dnd_pending_mode = E_DND_NONE; + v->drag.icon_show = 0; + } if (v->drag.update) - { - ecore_window_move(v->drag.win, v->drag.x, v->drag.y); - v->drag.update = 0; - } + { + ecore_window_move(v->drag.win, v->drag.x, v->drag.y); + v->drag.update = 0; + } if (v->options.back_pixmap) { - Imlib_Updates up; + Imlib_Updates up; + up = evas_render_updates(v->evas); /* special code to handle if we are double buffering to a pixmap */ /* and clear sections of the window if they got updated */ if (up) { - Imlib_Updates u; - + Imlib_Updates u; + for (u = up; u; u = imlib_updates_get_next(u)) { - int x, y, w, h; - + int x, y, w, h; + imlib_updates_get_coordinates(u, &x, &y, &w, &h); ecore_window_clear_area(v->win.main, x, y, w, h); } @@ -1781,33 +1851,32 @@ e_view_update(E_View *v) } } else - evas_render(v->evas); - - v->changed = 0; + evas_render(v->evas); + v->changed = 0; D_RETURN; } void -e_view_file_add(E_View *v, E_File *f) +e_view_file_add(E_View * v, E_File * f) { D_ENTER; if (!e_icon_find_by_file(v, f->file)) - { - E_Icon *ic; + { + E_Icon *ic; - ic = e_icon_new(); - ic->view = v; - ic->file = f; - ic->changed = 1; - /* this basically allocates the obj.icon struct. Its image will be - * set later in icon_update_state */ - ic->obj.icon = evas_add_image_from_file(ic->view->evas, NULL); - ic->obj.text = e_text_new(ic->view->evas, f->file, "filename"); - v->icons = evas_list_append(v->icons, ic); - v->extents.valid = 0; - } + ic = e_icon_new(); + ic->view = v; + ic->file = f; + ic->changed = 1; + /* this basically allocates the obj.icon struct. Its image will be + * set later in icon_update_state */ + ic->obj.icon = evas_add_image_from_file(ic->view->evas, NULL); + ic->obj.text = e_text_new(ic->view->evas, f->file, "filename"); + v->icons = evas_list_append(v->icons, ic); + v->extents.valid = 0; + } e_view_queue_resort(v); v->changed = 1; @@ -1815,148 +1884,152 @@ e_view_file_add(E_View *v, E_File *f) } void -e_view_file_changed(E_View *v, E_File *f) +e_view_file_changed(E_View * v, E_File * f) { - E_Icon *ic; + E_Icon *ic; + D_ENTER; ic = e_icon_find_by_file(v, f->file); if (ic) - { - } + { + } v->changed = 1; D_RETURN; } void -e_view_file_delete(E_View *v, E_File *f) +e_view_file_delete(E_View * v, E_File * f) { - E_Icon *ic; + E_Icon *ic; + D_ENTER; e_iconbar_file_delete(v, f->file); ic = e_icon_find_by_file(v, f->file); if (ic) - { - e_icon_hide(ic); - e_object_unref(E_OBJECT(ic)); - v->icons = evas_list_remove(v->icons, ic); - v->changed = 1; - v->extents.valid = 0; - e_view_queue_resort(v); - } + { + e_icon_hide(ic); + e_object_unref(E_OBJECT(ic)); + v->icons = evas_list_remove(v->icons, ic); + v->changed = 1; + v->extents.valid = 0; + e_view_queue_resort(v); + } D_RETURN; } void -e_view_ib_reload (E_View *v) +e_view_ib_reload(E_View * v) { - D_ENTER; + D_ENTER; - /* - D ("check if jsut saved:\n"); - if (v->iconbar->just_saved) - { - D ("just saved\n"); - v->iconbar->just_saved = 0; - D_RETURN; - } + /* + * D ("check if jsut saved:\n"); + * if (v->iconbar->just_saved) + * { + * D ("just saved\n"); + * v->iconbar->just_saved = 0; + * D_RETURN; + * } */ - /* if we have an iconbar.. well nuke it */ - if (e_object_unref (E_OBJECT (v->iconbar)) == 0) - v->iconbar = NULL; + /* if we have an iconbar.. well nuke it */ + if (e_object_unref(E_OBJECT(v->iconbar)) == 0) + v->iconbar = NULL; - /* try load a new iconbar */ - if (!v->iconbar) - v->iconbar = e_iconbar_new (v); + /* try load a new iconbar */ + if (!v->iconbar) + v->iconbar = e_iconbar_new(v); - /* if the iconbar loaded and theres an evas - we're realized */ - /* so realize the iconbar */ - if ((v->iconbar) && (v->evas)) - e_iconbar_realize (v->iconbar); + /* if the iconbar loaded and theres an evas - we're realized */ + /* so realize the iconbar */ + if ((v->iconbar) && (v->evas)) + e_iconbar_realize(v->iconbar); - D_RETURN; + D_RETURN; } void -e_view_bg_reload(E_View *v) +e_view_bg_reload(E_View * v) { - E_Background bg; - + E_Background bg; + /* This should only be called if the background did really * change in the underlying model. We dont check again * here. */ D_ENTER; - - if (v->bg) - { - int size; - e_bg_free(v->bg); - v->bg = NULL; - if (v->evas) - { - size = evas_get_image_cache(v->evas); - evas_set_image_cache(v->evas, 0); - evas_set_image_cache(v->evas, size); - } - e_db_flush(); - } - + if (v->bg) + { + int size; + + e_bg_free(v->bg); + v->bg = NULL; + if (v->evas) + { + size = evas_get_image_cache(v->evas); + evas_set_image_cache(v->evas, 0); + evas_set_image_cache(v->evas, size); + } + e_db_flush(); + } + bg = e_bg_load(v->model->bg_file); - + if (bg) - { - v->bg = bg; - if (v->evas) - { - e_bg_add_to_evas(v->bg, v->evas); - e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); - e_bg_set_layer(v->bg, 100); - e_bg_resize(v->bg, v->size.w, v->size.h); + { + v->bg = bg; + if (v->evas) + { + e_bg_add_to_evas(v->bg, v->evas); + e_bg_set_scroll(v->bg, v->scroll.x, v->scroll.y); + e_bg_set_layer(v->bg, 100); + e_bg_resize(v->bg, v->size.w, v->size.h); - e_bg_callback_add(v->bg, CALLBACK_MOUSE_UP, e_bg_up_cb, v); - e_bg_callback_add(v->bg, CALLBACK_MOUSE_DOWN, e_bg_down_cb, v); - e_bg_callback_add(v->bg, CALLBACK_MOUSE_MOVE, e_bg_move_cb, v); + e_bg_callback_add(v->bg, CALLBACK_MOUSE_UP, e_bg_up_cb, v); + e_bg_callback_add(v->bg, CALLBACK_MOUSE_DOWN, e_bg_down_cb, v); + e_bg_callback_add(v->bg, CALLBACK_MOUSE_MOVE, e_bg_move_cb, v); - e_bg_show(v->bg); - } - } + e_bg_show(v->bg); + } + } v->changed = 1; D_RETURN; } - void e_view_init(void) { D_ENTER; - - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, e_mouse_down); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, e_mouse_up); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, e_mouse_move); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_IN, e_mouse_in); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_OUT, e_mouse_out); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_EXPOSE, e_window_expose); - ecore_event_filter_handler_add(ECORE_EVENT_KEY_DOWN, e_key_down); - ecore_event_filter_handler_add(ECORE_EVENT_KEY_UP, e_key_up); - ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_WHEEL, e_wheel); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_CONFIGURE, e_configure); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_PROPERTY, e_property); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_UNMAP, e_unmap); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_VISIBILITY, e_visibility); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_FOCUS_IN, e_focus_in); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_FOCUS_OUT, e_focus_out); - ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_DELETE, e_delete); + + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_DOWN, e_mouse_down); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_UP, e_mouse_up); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_MOVE, e_mouse_move); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_IN, e_mouse_in); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_OUT, e_mouse_out); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_EXPOSE, e_window_expose); + ecore_event_filter_handler_add(ECORE_EVENT_KEY_DOWN, e_key_down); + ecore_event_filter_handler_add(ECORE_EVENT_KEY_UP, e_key_up); + ecore_event_filter_handler_add(ECORE_EVENT_MOUSE_WHEEL, e_wheel); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_CONFIGURE, e_configure); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_PROPERTY, e_property); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_UNMAP, e_unmap); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_VISIBILITY, e_visibility); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_FOCUS_IN, e_focus_in); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_FOCUS_OUT, e_focus_out); + ecore_event_filter_handler_add(ECORE_EVENT_WINDOW_DELETE, e_delete); /* dnd source handlers */ - ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP_STATUS, e_dnd_status); - ecore_event_filter_handler_add(ECORE_EVENT_DND_DATA_REQUEST, e_dnd_data_request); - ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP_END, e_dnd_drop_end); + ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP_STATUS, e_dnd_status); + ecore_event_filter_handler_add(ECORE_EVENT_DND_DATA_REQUEST, + e_dnd_data_request); + ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP_END, e_dnd_drop_end); /* dnd target handlers */ - ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP_POSITION, e_dnd_drop_position); - ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP, e_dnd_drop); - ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP_REQUEST, e_dnd_drop_request); + ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP_POSITION, + e_dnd_drop_position); + ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP, e_dnd_drop); + ecore_event_filter_handler_add(ECORE_EVENT_DND_DROP_REQUEST, + e_dnd_drop_request); ecore_event_filter_idle_handler_add(e_idle, NULL); @@ -1973,18 +2046,19 @@ e_view_init(void) static void e_dnd_data_request(Ecore_Event * ev) { - Ecore_Event_Dnd_Data_Request *e; - /* - * typedef struct _ecore_event_dnd_data_request - * { - * Window win, root, source_win; - * int plain_text; - * Atom destination_atom; - * } Ecore_Event_Dnd_Data_Request; - */ - E_View *v; - Evas_List ll; - char *data = NULL; + Ecore_Event_Dnd_Data_Request *e; + + /* + * typedef struct _ecore_event_dnd_data_request + * { + * Window win, root, source_win; + * int plain_text; + * Atom destination_atom; + * } Ecore_Event_Dnd_Data_Request; + */ + E_View *v; + Evas_List ll; + char *data = NULL; D_ENTER; /* Me, my null, and an extra for the end '/r/n'... */ @@ -2010,99 +2084,103 @@ e_dnd_data_request(Ecore_Event * ev) * } */ e = ev->event; - if ( !(v =e_view_machine_get_view_by_base_window(e->win)) ) + if (!(v = e_view_machine_get_view_by_base_window(e->win))) D_RETURN; if (e->uri_list) - { - int first = 1; + { + int first = 1; - for (ll = v->icons; ll; ll = ll->next) - { - E_Icon *ic; + for (ll = v->icons; ll; ll = ll->next) + { + E_Icon *ic; - ic = ll->data; - if (ic->state.selected) - { - char buf[PATH_MAX]; + ic = ll->data; + if (ic->state.selected) + { + char buf[PATH_MAX]; - if (first) - { - /*FIXME */ - snprintf(buf, PATH_MAX, "file:%s/%s", v->model->dir, ic->file->file); - first = 0; - } - else - /* FIXME */ - snprintf(buf, PATH_MAX, "\r\nfile:%s/%s", v->model->dir, ic->file->file); - REALLOC(data, char, strlen(data) + strlen(buf) + 1); - strcat(data, buf); - } - } - ecore_dnd_send_data(e->source_win, e->win, - data, strlen(data) + 1, - e->destination_atom, - DND_TYPE_URI_LIST); - } + if (first) + { + /*FIXME */ + snprintf(buf, PATH_MAX, "file:%s/%s", v->model->dir, + ic->file->file); + first = 0; + } + else + /* FIXME */ + snprintf(buf, PATH_MAX, "\r\nfile:%s/%s", v->model->dir, + ic->file->file); + REALLOC(data, char, strlen(data) + strlen(buf) + 1); + + strcat(data, buf); + } + } + ecore_dnd_send_data(e->source_win, e->win, + data, strlen(data) + 1, + e->destination_atom, DND_TYPE_URI_LIST); + } else if (e->plain_text) - { - int first = 1; + { + int first = 1; - for (ll = v->icons; ll; ll = ll->next) - { - E_Icon *ic; + for (ll = v->icons; ll; ll = ll->next) + { + E_Icon *ic; - ic = ll->data; - if (ic->state.selected) - { - char buf[PATH_MAX]; + ic = ll->data; + if (ic->state.selected) + { + char buf[PATH_MAX]; - if (first) - { - /*FIXME */ - snprintf(buf, PATH_MAX, "%s/%s\n", v->model->dir, ic->file->file); - first = 0; - } - else - /*FIXME */ - snprintf(buf, PATH_MAX, "\n%s/%s", v->model->dir, ic->file->file); - REALLOC(data, char, strlen(data) + strlen(buf) + 1); - strcat(data, buf); - } - } - ecore_dnd_send_data(e->source_win, e->win, - data, strlen(data) + 1, - e->destination_atom, - DND_TYPE_PLAIN_TEXT); - } - else /* if (e->moz_url)*/ - { - FREE(data); - data = NULL; + if (first) + { + /*FIXME */ + snprintf(buf, PATH_MAX, "%s/%s\n", v->model->dir, + ic->file->file); + first = 0; + } + else + /*FIXME */ + snprintf(buf, PATH_MAX, "\n%s/%s", v->model->dir, + ic->file->file); + REALLOC(data, char, strlen(data) + strlen(buf) + 1); - for (ll = v->icons; ll; ll = ll->next) - { - E_Icon *ic; + strcat(data, buf); + } + } + ecore_dnd_send_data(e->source_win, e->win, + data, strlen(data) + 1, + e->destination_atom, DND_TYPE_PLAIN_TEXT); + } + else /* if (e->moz_url) */ + { + FREE(data); + data = NULL; - ic = ll->data; - if (ic->state.selected) - { - char buf[16384]; + for (ll = v->icons; ll; ll = ll->next) + { + E_Icon *ic; - /* FIXME */ - snprintf(buf, PATH_MAX, "file:%s/%s", v->model->dir, ic->file->file); - data = strdup(buf); - break; - } - } - if (data) - { - ecore_dnd_send_data(e->source_win, e->win, - data, strlen(data) + 1, - e->destination_atom, - DND_TYPE_NETSCAPE_URL); - } - } + ic = ll->data; + if (ic->state.selected) + { + char buf[16384]; + + /* FIXME */ + snprintf(buf, PATH_MAX, "file:%s/%s", v->model->dir, + ic->file->file); + data = strdup(buf); + break; + } + } + if (data) + { + ecore_dnd_send_data(e->source_win, e->win, + data, strlen(data) + 1, + e->destination_atom, DND_TYPE_NETSCAPE_URL); + } + } IF_FREE(data); D_RETURN; } @@ -2111,249 +2189,249 @@ static void e_dnd_drop_end(Ecore_Event * ev) { Ecore_Event_Dnd_Drop_End *e; + /* - * typedef struct _ecore_event_dnd_drop_end - * { - * Window win, root, source_win; - * } Ecore_Event_Dnd_Drop_End; - */ - E_View *v; + * * typedef struct _ecore_event_dnd_drop_end + * * { + * * Window win, root, source_win; + * * } Ecore_Event_Dnd_Drop_End; + */ + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - if(v_dnd_source) - { - if(dnd_pending_mode != E_DND_DELETED && - dnd_pending_mode != E_DND_COPIED ) - { - dnd_pending_mode = E_DND_COPIED; - } - if( v_dnd_source->drag.matching_drop_attempt ) - { - v_dnd_source->drag.matching_drop_attempt = 0; - dnd_pending_mode = E_DND_COPIED; - } - v_dnd_source->changed = 1; - v_dnd_source->drag.icon_show = 1; - } - e_dnd_drop_request_free(); - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + if (v_dnd_source) + { + if (dnd_pending_mode != E_DND_DELETED && + dnd_pending_mode != E_DND_COPIED) + { + dnd_pending_mode = E_DND_COPIED; + } + if (v_dnd_source->drag.matching_drop_attempt) + { + v_dnd_source->drag.matching_drop_attempt = 0; + dnd_pending_mode = E_DND_COPIED; + } + v_dnd_source->changed = 1; + v_dnd_source->drag.icon_show = 1; + } + e_dnd_drop_request_free(); + } + } D_RETURN; } - static void e_dnd_drop_position(Ecore_Event * ev) { Ecore_Event_Dnd_Drop_Position *e; + /* - * typedef struct _ecore_event_dnd_drop_position - * { - * Window win, root, source_win; - * int x, y; - * } Ecore_Event_Dnd_Drop_Position; - */ - E_View *v; + * * typedef struct _ecore_event_dnd_drop_position + * * { + * * Window win, root, source_win; + * * int x, y; + * * } Ecore_Event_Dnd_Drop_Position; + */ + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - if (v->iconbar) - { - if (e->x >= v->iconbar->icon_area.x && - e->x <= v->iconbar->icon_area.x + v->iconbar->icon_area.w && - e->y >= v->iconbar->icon_area.y && - e->y <= v->iconbar->icon_area.y + v->iconbar->icon_area.h) - { - v->iconbar->dnd.x = e->x; - v->iconbar->dnd.y = e->y; - /* for iconbar drops, allow from same view */ - v->drag.matching_drop_attempt = 0; - dnd_pending_mode = E_DND_ICONBAR_ADD; - } - } + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + if (v->iconbar) + { + if (e->x >= v->iconbar->icon_area.x && + e->x <= v->iconbar->icon_area.x + v->iconbar->icon_area.w + && e->y >= v->iconbar->icon_area.y + && e->y <= + v->iconbar->icon_area.y + v->iconbar->icon_area.h) + { + v->iconbar->dnd.x = e->x; + v->iconbar->dnd.y = e->y; + /* for iconbar drops, allow from same view */ + v->drag.matching_drop_attempt = 0; + dnd_pending_mode = E_DND_ICONBAR_ADD; + } + } - /* send XdndStatus (even to same view, we'll */ - /* ignore actions within the same view later */ - /* during the drop action.) */ - ecore_window_dnd_send_status_ok(v->win.base, e->source_win, - v->location.x, v->location.y, - v->size.w, v->size.h - ); + /* send XdndStatus (even to same view, we'll */ + /* ignore actions within the same view later */ + /* during the drop action.) */ + ecore_window_dnd_send_status_ok(v->win.base, e->source_win, + v->location.x, v->location.y, + v->size.w, v->size.h); - /* todo - cache window extents, don't send again within these extents. */ - } - } + /* todo - cache window extents, don't send again within these extents. */ + } + } D_RETURN; } static void e_dnd_drop(Ecore_Event * ev) { - Ecore_Event_Dnd_Drop *e; - /* - * typedef struct _ecore_event_dnd_drop - * { - * Window win, root, source_win; - * } Ecore_Event_Dnd_Drop; - */ - E_View *v; + Ecore_Event_Dnd_Drop *e; + + /* + * typedef struct _ecore_event_dnd_drop + * { + * Window win, root, source_win; + * } Ecore_Event_Dnd_Drop; + */ + E_View *v; D_ENTER; e = ev->event; if (e && e->win) - { - if ( (v=e_view_machine_get_view_by_base_window(e->win)) ) - { - /* Dropped! Handle data */ - /* Same view or same underlying dir? Mark to skip action */ - if( e->win == e->source_win || v->model == v_dnd_source->model) - v_dnd_source->drag.matching_drop_attempt = 1; - /* Perform the action... */ - e_dnd_handle_drop (v); + { + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + /* Dropped! Handle data */ + /* Same view or same underlying dir? Mark to skip action */ + if (e->win == e->source_win || v->model == v_dnd_source->model) + v_dnd_source->drag.matching_drop_attempt = 1; + /* Perform the action... */ + e_dnd_handle_drop(v); - ecore_window_dnd_send_finished(v->win.base, e->source_win); - e_dnd_drop_request_free(); - } - } + ecore_window_dnd_send_finished(v->win.base, e->source_win); + e_dnd_drop_request_free(); + } + } D_RETURN; } static void e_dnd_drop_request(Ecore_Event * ev) { - Ecore_Event_Dnd_Drop_Request *e; - /* - * typedef struct _ecore_event_dnd_drop_request - * { - * Window win, root, source_win; - * int num_files; - * char **files; - * int copy, link, move; - * } Ecore_Event_Dnd_Drop_Request; - */ - E_View *v; - - D_ENTER; - e = ev->event; - if (e && e->win) - { - if ( (v = e_view_machine_get_view_by_base_window(e->win)) ) + Ecore_Event_Dnd_Drop_Request *e; + + /* + * typedef struct _ecore_event_dnd_drop_request + * { + * Window win, root, source_win; + * int num_files; + * char **files; + * int copy, link, move; + * } Ecore_Event_Dnd_Drop_Request; + */ + E_View *v; + + D_ENTER; + e = ev->event; + if (e && e->win) { - /* if it exists, we already have the data... */ - if ((!dnd_files ) && (e->num_files > 0)) - { - int i; + if ((v = e_view_machine_get_view_by_base_window(e->win))) + { + /* if it exists, we already have the data... */ + if ((!dnd_files) && (e->num_files > 0)) + { + int i; - dnd_files = NEW_PTR(e->num_files); + dnd_files = NEW_PTR(e->num_files); - /* copy the file list locally, for use in a dnd_drop */ - for( i=0; i < e->num_files; i++ ) - dnd_files[i] = strdup( e->files[i] ); + /* copy the file list locally, for use in a dnd_drop */ + for (i = 0; i < e->num_files; i++) + dnd_files[i] = strdup(e->files[i]); - dnd_num_files = e->num_files; + dnd_num_files = e->num_files; - /* if the dnd source is e itself then dont use the event mode */ - if ( (v == e_view_machine_get_view_by_base_window(e->source_win))) - { - dnd_pending_mode = v->drag.drop_mode; - } - else - { - if( e->copy ) - dnd_pending_mode = E_DND_COPY; - else if( e->move ) - dnd_pending_mode = E_DND_MOVE; - else if( e->link ) - dnd_pending_mode = E_DND_LINK; - else - dnd_pending_mode = E_DND_ASK; - } - } + /* if the dnd source is e itself then dont use the event mode */ + if ((v == + e_view_machine_get_view_by_base_window(e->source_win))) + { + dnd_pending_mode = v->drag.drop_mode; + } + else + { + if (e->copy) + dnd_pending_mode = E_DND_COPY; + else if (e->move) + dnd_pending_mode = E_DND_MOVE; + else if (e->link) + dnd_pending_mode = E_DND_LINK; + else + dnd_pending_mode = E_DND_ASK; + } + } + } } - } - D_RETURN; + D_RETURN; } static void e_dnd_drop_request_free(void) { - D_ENTER; + D_ENTER; - if (dnd_files) - { - int i; + if (dnd_files) + { + int i; - for (i = 0; i < dnd_num_files; i++) - FREE(dnd_files[i]); + for (i = 0; i < dnd_num_files; i++) + FREE(dnd_files[i]); - FREE(dnd_files); + FREE(dnd_files); - dnd_num_files = 0; - } - D_RETURN; + dnd_num_files = 0; + } + D_RETURN; } static void -e_dnd_handle_drop( E_View *v ) +e_dnd_handle_drop(E_View * v) { - int in, out; - char *filename; - + int in, out; + char *filename; + D_ENTER; - + /* Make space for destination in file list */ dnd_num_files++; REALLOC_PTR(dnd_files, dnd_num_files); - dnd_files[dnd_num_files-1] = NULL; + dnd_files[dnd_num_files - 1] = NULL; /* Verify files are local, convert to non-URL */ - for(in = 0, out = 0; in < dnd_num_files - 1; in++) + for (in = 0, out = 0; in < dnd_num_files - 1; in++) { - filename = e_util_de_url_and_verify( dnd_files[in]); + filename = e_util_de_url_and_verify(dnd_files[in]); /* Need a overlap safe copy here, like memmove() */ - if( filename ) - memmove(dnd_files[out++], filename, strlen(filename) + 1); + if (filename) + memmove(dnd_files[out++], filename, strlen(filename) + 1); } - + /* Append destination for efsd */ - if ( dnd_files[out] ) - FREE( dnd_files[out] ); - - dnd_files[out++] = strdup( v->model->dir ); - - switch( dnd_pending_mode ) + if (dnd_files[out]) + FREE(dnd_files[out]); + + dnd_files[out++] = strdup(v->model->dir); + + switch (dnd_pending_mode) { - case E_DND_COPY: + case E_DND_COPY: /* Copy files */ - efsd_copy( e_fs_get_connection(), out, dnd_files, - efsd_ops(0) ); + efsd_copy(e_fs_get_connection(), out, dnd_files, efsd_ops(0)); dnd_pending_mode = E_DND_COPIED; break; - case E_DND_MOVE: - efsd_move( e_fs_get_connection(), out, dnd_files, - efsd_ops(0) ); + case E_DND_MOVE: + efsd_move(e_fs_get_connection(), out, dnd_files, efsd_ops(0)); dnd_pending_mode = E_DND_DELETED; break; - case E_DND_ICONBAR_ADD: - e_iconbar_dnd_add_files(v, v_dnd_source, out, dnd_files ); - /*FIXME: should this be ICONBAR_ADDED?*/ - dnd_pending_mode = E_DND_NONE; - default: + case E_DND_ICONBAR_ADD: + e_iconbar_dnd_add_files(v, v_dnd_source, out, dnd_files); + /*FIXME: should this be ICONBAR_ADDED? */ + dnd_pending_mode = E_DND_NONE; + default: /* nothing yet */ break; } - D_RETURN; + D_RETURN; } - - diff --git a/src/view.h b/src/view.h index 5d88af737..b83dd721f 100644 --- a/src/view.h +++ b/src/view.h @@ -12,12 +12,12 @@ #ifndef E_VIEW_TYPEDEF #define E_VIEW_TYPEDEF -typedef struct _E_View E_View; +typedef struct _E_View E_View; #endif #ifndef E_ICON_TYPEDEF #define E_ICON_TYPEDEF -typedef struct _E_Icon E_Icon; +typedef struct _E_Icon E_Icon; #endif #ifndef E_ICONBAR_TYPEDEF @@ -30,49 +30,61 @@ typedef struct _E_Iconbar E_Iconbar; typedef struct _E_View_Model E_View_Model; #endif - -typedef enum { - E_DND_NONE, - E_DND_COPY, - E_DND_MOVE, - E_DND_LINK, - E_DND_ASK, - E_DND_DELETED, - E_DND_COPIED, - E_DND_ICONBAR_ADD -} E_dnd_enum ; +typedef enum +{ + E_DND_NONE, + E_DND_COPY, + E_DND_MOVE, + E_DND_LINK, + E_DND_ASK, + E_DND_DELETED, + E_DND_COPIED, + E_DND_ICONBAR_ADD +} +E_dnd_enum; struct _E_View { - E_Object o; + E_Object o; - char * name; - - E_View_Model *model; - - struct { + char *name; + + E_View_Model *model; + + struct + { Evas_Render_Method render_method; int back_pixmap; - } options; - - Evas evas; - struct { + } + options; + + Evas evas; + struct + { Window base; Window main; - } win; - Pixmap pmap; - struct { + } + win; + Pixmap pmap; + struct + { int w, h; int force; - } size; - struct { + } + size; + struct + { int x, y; - } scroll; - struct { + } + scroll; + struct + { int x, y; - } location; + } + location; - struct { + struct + { /* +-----------------+ * | Wt | * | +-----------+ | @@ -85,100 +97,121 @@ struct _E_View * | Wb | * +-----------------+ */ - struct { - int l, r, t, b; - } window; - struct { - int s, g, b; - } icon; - } spacing; - struct { - int on; + struct + { + int l, r, t, b; + } + window; + struct + { + int s, g, b; + } + icon; + } + spacing; + struct + { + int on; /* The number of selected icons. */ - int count; + int count; /* The number of icons we selected the last time. - If this is > 0, we don't pop up menus when - the user clicks in a view. */ - int last_count; - int x, y, w, h; - struct { - int x, y; - } down; - - struct { - struct { - int r, g, b, a; - } - edge_l, edge_r, edge_t, edge_b, - middle, - grad_l, grad_r, grad_t, grad_b; - struct { - int l, r, t, b; - } grad_size; - } config; - struct { - Evas_Object clip; - Evas_Object edge_l; - Evas_Object edge_r; - Evas_Object edge_t; - Evas_Object edge_b; - Evas_Object middle; - Evas_Object grad_l; - Evas_Object grad_r; - Evas_Object grad_t; - Evas_Object grad_b; - } obj; - } select; - - struct { - int started; - Window win; - int x, y; - struct { - int x, y; - } offset; - int update; - int drop_mode; - int icon_hide; - int icon_show; - int matching_drop_attempt; - } drag; - struct { - int valid; - double x1, x2, y1, y2; - } extents; - - E_Background bg; + * If this is > 0, we don't pop up menus when + * the user clicks in a view. */ + int last_count; + int x, y, w, h; + struct + { + int x, y; + } + down; + struct + { + struct + { + int r, g, b, a; + } + edge_l , edge_r, edge_t, edge_b, + middle, grad_l, grad_r, grad_t, grad_b; + struct + { + int l, r, t, b; + } + grad_size; + } + config; + struct + { + Evas_Object clip; + Evas_Object edge_l; + Evas_Object edge_r; + Evas_Object edge_t; + Evas_Object edge_b; + Evas_Object middle; + Evas_Object grad_l; + Evas_Object grad_r; + Evas_Object grad_t; + Evas_Object grad_b; + } + obj; + } + select; - struct { - EfsdCmdId x, y, w, h; - int busy; - } geom_get; - - EfsdCmdId getbg; + struct + { + int started; + Window win; + int x, y; + struct + { + int x, y; + } + offset; + int update; + int drop_mode; + int icon_hide; + int icon_show; + int matching_drop_attempt; + } + drag; + struct + { + int valid; + double x1, x2, y1, y2; + } + extents; - - struct { + E_Background bg; + + struct + { + EfsdCmdId x, y, w, h; + int busy; + } + geom_get; + + EfsdCmdId getbg; + + struct + { E_Scrollbar *h, *v; - } scrollbar; - - int is_listing; - - E_Iconbar *iconbar; - - Evas_List icons; - - int have_resort_queued; + } + scrollbar; - int changed; + int is_listing; - Evas_List epplet_contexts; - Ebits_Object epplet_layout; + E_Iconbar *iconbar; + + Evas_List icons; + + int have_resort_queued; + + int changed; + + Evas_List epplet_contexts; + Ebits_Object epplet_layout; }; - - /** * e_view_init - View event handlers initialization. * @@ -186,27 +219,31 @@ struct _E_View * Views are the windows in which e as a desktop shell * displays file icons. */ -void e_view_init(void); +void e_view_init(void); -void e_view_selection_update(E_View *v); -void e_view_deselect_all(E_View *v); -void e_view_deselect_all_except(E_Icon *not_ic); -Ecore_Event *e_view_get_current_event(void); -int e_view_filter_file(E_View *v, char *file); -void e_view_icons_get_extents(E_View *v, int *min_x, int *min_y, int *max_x, int *max_y); -void e_view_icons_apply_xy(E_View *v); -void e_view_scroll_to(E_View *v, int sx, int sy); -void e_view_scroll_by(E_View *v, int sx, int sy); -void e_view_scroll_to_percent(E_View *v, double psx, double psy); -void e_view_get_viewable_percentage(E_View *v, double *vw, double *vh); -void e_view_get_position_percentage(E_View *v, double *vx, double *vy); +void e_view_selection_update(E_View * v); +void e_view_deselect_all(E_View * v); +void e_view_deselect_all_except(E_Icon * not_ic); +Ecore_Event *e_view_get_current_event(void); +int e_view_filter_file(E_View * v, char *file); +void e_view_icons_get_extents(E_View * v, int *min_x, int *min_y, + int *max_x, int *max_y); +void e_view_icons_apply_xy(E_View * v); +void e_view_scroll_to(E_View * v, int sx, int sy); +void e_view_scroll_by(E_View * v, int sx, int sy); +void e_view_scroll_to_percent(E_View * v, double psx, + double psy); +void e_view_get_viewable_percentage(E_View * v, double *vw, + double *vh); +void e_view_get_position_percentage(E_View * v, double *vx, + double *vy); -void e_view_resort_alphabetical(E_View *v); -void e_view_arrange(E_View *v); -void e_view_resort(E_View *v); -void e_view_queue_geometry_record(E_View *v); -void e_view_queue_icon_xy_record(E_View *v); -void e_view_queue_resort(E_View *v); +void e_view_resort_alphabetical(E_View * v); +void e_view_arrange(E_View * v); +void e_view_resort(E_View * v); +void e_view_queue_geometry_record(E_View * v); +void e_view_queue_icon_xy_record(E_View * v); +void e_view_queue_resort(E_View * v); /** * e_view_new - Creates a new view object @@ -214,7 +251,7 @@ void e_view_queue_resort(E_View *v); * This function creates a new view and sets default * properties on it, such as colors and icon spacings. */ -E_View *e_view_new(void); +E_View *e_view_new(void); /** * e_view_set_dir - Sets view to a given directory @@ -226,7 +263,7 @@ E_View *e_view_new(void); * view's metadata (view window coordinates etc). If a view_model already * exists for this dir, it is reused, otherwise a new on is created. */ -void e_view_set_dir(E_View *v, char *dir, int is_desktop); +void e_view_set_dir(E_View * v, char *dir, int is_desktop); /** * e_view_populate - Draws icons for all files in view @@ -236,7 +273,7 @@ void e_view_set_dir(E_View *v, char *dir, int is_desktop); * view_add_file for each one. This results in icons being created for each * file. */ -void e_view_populate(E_View *v); +void e_view_populate(E_View * v); /** * e_view_realize - Initializes a view's graphics and content @@ -245,7 +282,7 @@ void e_view_populate(E_View *v); * This function initializes a created view by loading * all the graphics and creating the evas. */ -void e_view_realize(E_View *v); +void e_view_realize(E_View * v); /** * e_view_update - Redraws a view @@ -253,16 +290,15 @@ void e_view_realize(E_View *v); * * If the contents of the view have changed, this function redraws it. */ -void e_view_update(E_View *v); +void e_view_update(E_View * v); +void e_view_bg_reload(E_View * v); +void e_view_ib_reload(E_View * v); -void e_view_bg_reload(E_View *v); -void e_view_ib_reload(E_View *v); +void e_view_file_add(E_View * v, E_File * file); +void e_view_file_changed(E_View * v, E_File * file); +void e_view_file_delete(E_View * v, E_File * file); -void e_view_file_add(E_View *v, E_File *file); -void e_view_file_changed(E_View *v, E_File *file); -void e_view_file_delete(E_View *v, E_File *file); - -void e_view_close_all(void); +void e_view_close_all(void); #endif