diff options
author | puppet_master <puppet_master> | 2005-07-07 19:47:37 +0000 |
---|---|---|
committer | puppet_master <puppet_master> | 2005-07-07 19:47:37 +0000 |
commit | 4d7b8bdadd8f0f7c6202e87bc8b40aa655aa43d4 (patch) | |
tree | 07b3c50eb06573f78f5ea16781578a3888fbfc11 /elock.c | |
parent | added event handler still not work (diff) | |
download | elock-4d7b8bdadd8f0f7c6202e87bc8b40aa655aa43d4.tar.xz |
New Version with ecore_evas ... and keyboard bindings ... ;)
Diffstat (limited to 'elock.c')
-rw-r--r-- | elock.c | 114 |
1 files changed, 89 insertions, 25 deletions
@@ -1,8 +1,14 @@ /*- STANDAR LIBS */ #include <stdio.h> +#include <stdlib.h> -/* ECORE LIBS */ +/* EFL */ #include <Ecore.h> +#include <Ecore_Evas.h> + +#define WIDTH 400 +#define HEIGHT 400 +#define TIME 10 /* ELCOK LIBS */ /*#include "etimer.h"*/ @@ -10,14 +16,20 @@ /* ELOCK FUNC DECLARATION */ Ecore_Timer *elock_timer_callback(void *donnee); /*Ecore_Event_Handler *event_handler;*/ -int elock_timer (double laps); +Ecore_Timer *elock_timer (double laps); int check_args (int arg); -int elock_event_handler(int arc, char *arv); +int elock_event_handler(); int elock_event_cb (void *data, int ev_type, void *ev); +void key_down(void *data, Evas *e, Evas_Object *obj, void *event_info); /* 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) { @@ -25,25 +37,53 @@ int main (int argc, char **argv) int event_hand_result; double time; - if ( check_args(argc) != 0 ) +/* if ( check_args(argc) != 0 ) { fprintf (stdout,"NEED 1 ARGUMENT\n"); exit(1); } +*/ - -/* time = strtod(argv[1], NULL); - + time = (double)TIME; +/* timer_result = elock_timer(time); - if (timer_result != 0) - fprintf (stdout,"ERROR OF TIMER"); -*/ + event_hand_result = elock_event_handler(argc, argv); if (event_hand_result != 0) fprintf (stdout,"ERROR OF EVENT HANDLER"); return 0; + */ + + ecore_init(); +/* elock_event_handler();*/ + + timer = elock_timer(time); + if (!timer) + fprintf (stdout,"ERROR OF TIMER"); + + 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); + + 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, key_down, timer); + + ecore_main_loop_begin(); + + ecore_evas_shutdown(); + ecore_shutdown(); + + return 0; } int check_args (int arg) @@ -56,37 +96,40 @@ int check_args (int arg) return 1; } -int elock_timer (double laps) +Ecore_Timer *elock_timer (double laps) { - ecore_init(); - - ecore_timer_add(laps, elock_timer_callback, NULL); -/* ecore_timer_add(10,timer_two_cb, NULL);*/ - - ecore_main_loop_begin(); - ecore_shutdown(); - - return 0; + 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 ; + fprintf(stdout, "Normalement je resize\n"); + evas_object_resize(base_rect, w, h); fprintf(stdout,"1\n"); fflush(stdout); - if (donnee) +/* if (donnee) ecore_timer_del(donnee); - +*/ return 1; } -int elock_event_handler(int arc, char *arv) +int elock_event_handler() { ecore_init(); - ecore_app_args_set(arc, arv); - handler1 = ecore_event_handler_add(ECORE_EVENT_SIGNAL_HUP, elock_event_cb, NULL); ecore_main_loop_begin(); @@ -102,8 +145,29 @@ int elock_event_cb (void *data, int ev_type, void *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 key_down(void *data, Evas *e, Evas_Object *obj, void *event_info) { + Evas_Event_Key_Down *ev; + + ev = (Evas_Event_Key_Down *)event_info; + fprintf(stdout,"You hit key: %s\n", ev->keyname); + fprintf(stdout," and TIMER RESET\n"); + ecore_timer_del(timer); + timer = NULL; + timer = elock_timer((double)TIME); +} + |