/*- STANDAR LIBS */ #include #include /* EFL */ #include #include /* ELCOK LIBS */ #include "elock.h" /* TEMPORARY GLOBAL VARIABLE */ Ecore_Event_Handler *handler1 = NULL; Ecore_Evas *ee; Evas *evas; Evas_Object *base_rect; Ecore_Timer *timer; int main (int argc, char **argv) { double time; /* Check no args to the program */ if (check_args (argc) != 0) { fprintf (stdout, "elock don't take any argument\n"); exit (1); } /* set and cast the duration of timer */ time = (double)TIME; /* init ecore */ ecore_init (); /* calling timer with the duration */ timer = elock_build_timer (time); if (!timer) fprintf (stdout, "error of timer"); /* Building and setting evas window */ ee = ecore_evas_software_x11_new (NULL, 0, 0, 0, WIDTH, HEIGHT); ecore_evas_title_set (ee, "Elock KeyBind Example"); ecore_evas_borderless_set (ee, 0); ecore_evas_show (ee); evas = ecore_evas_get (ee); /*set backgroud of evas object */ base_rect = evas_object_rectangle_add (evas); evas_object_resize (base_rect, (double)WIDTH, (double)HEIGHT); evas_object_color_set (base_rect, 0, 0, 0, 255); evas_object_focus_set (base_rect, 1); evas_object_show (base_rect); evas_object_event_callback_add (base_rect, EVAS_CALLBACK_KEY_DOWN, elock_key_event_cb, timer); evas_object_event_callback_add (base_rect, EVAS_CALLBACK_MOUSE_MOVE, elock_key_event_cb, timer); evas_object_event_callback_add (base_rect, EVAS_CALLBACK_MOUSE_WHEEL, elock_key_event_cb, timer); evas_object_event_callback_add (base_rect, EVAS_CALLBACK_MOUSE_DOWN, elock_mouse_event_cb, timer); ecore_main_loop_begin (); ecore_evas_shutdown (); ecore_shutdown (); return 0; } int check_args (int arg) { if (arg == 1) { return 0; } return 1; } Ecore_Timer *elock_build_timer (double laps) { Ecore_Timer *timer; timer = ecore_timer_add (laps, elock_timer_callback, NULL); return timer; } Ecore_Timer *elock_timer_callback (void *donnee) { double w; double h; double modif; /*modif=(double)random() % 200; */ modif = 2; h = (double)HEIGHT - modif; w = (double)WIDTH - modif; evas_object_resize (base_rect, (double)WIDTH, (double)HEIGHT); evas_object_show (base_rect); fprintf (stdout, "Normalement je resize\n"); fprintf (stdout, "1\n"); fflush (stdout); /* if (donnee) ecore_timer_del(donnee); */ return 1; } int elock_event_handler () { ecore_init (); handler1 = ecore_event_handler_add (ECORE_EVENT_SIGNAL_HUP, elock_event_cb, NULL); ecore_main_loop_begin (); ecore_shutdown (); return 0; } int elock_event_cb (void *data, int ev_type, void *ev) { /*Ecore_Event_Signal_User *ev; */ if (handler1) { ecore_main_loop_quit (); ecore_event_handler_del (handler1); handler1 = NULL; } return 0; } /*static int main_signal_exit(void *data, int ev_type, void *ev) { ecore_main_loop_quit(); return 1; }*/ void elock_key_event_cb (void *data, Evas * e, Evas_Object * obj, void *event_info) { fprintf (stdout, "debug ici"); Evas_Event_Key_Down *ev; fprintf (stdout, "debug la"); ev = (Evas_Event_Key_Down *) event_info; fprintf (stdout, "You hit key: %s\n", ev->keyname); fprintf (stdout, " and timer reset\n"); elock_kill_timer (timer); } void elock_mouse_event_cb (void *data, Evas * e, Evas_Object * obj, void *event_info) { fprintf (stdout, "mouse down event"); Evas_Event_Mouse_Down *ev; ev = (Evas_Event_Mouse_Down *) event_info; fprintf (stdout, "You hit key: %s\n", ev->button); fprintf (stdout, " and timer reset\n"); elock_kill_timer (timer); } int elock_kill_timer (Ecore_Timer * elock_timer) { ecore_timer_del (elock_timer); timer = NULL; timer = elock_build_timer ((double)TIME); return 0; }