1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/*- STANDAR LIBS */
#include <stdio.h>
#include <stdlib.h>
/* EFL */
#include <Ecore.h>
#include <Ecore_Evas.h>
/* 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;
}
|