2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
10 #include <stdio.h> /* for printf */
12 #define WIN32_LEAN_AND_MEAN
14 #undef WIN32_LEAN_AND_MEAN
18 #include <Ecore_Input.h>
20 #include "Ecore_WinCE.h"
21 #include "ecore_wince_private.h"
24 /***** Global declarations *****/
26 double _ecore_wince_double_click_time = 0.25;
27 long _ecore_wince_event_last_time = 0;
28 Ecore_WinCE_Window *_ecore_wince_event_last_window = NULL;
29 HINSTANCE _ecore_wince_instance = NULL;
30 int _ecore_wince_log_dom_global = -1;
32 int ECORE_WINCE_EVENT_MOUSE_IN = 0;
33 int ECORE_WINCE_EVENT_MOUSE_OUT = 0;
34 int ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = 0;
35 int ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = 0;
36 int ECORE_WINCE_EVENT_WINDOW_DAMAGE = 0;
37 int ECORE_WINCE_EVENT_WINDOW_CREATE = 0;
38 int ECORE_WINCE_EVENT_WINDOW_DESTROY = 0;
39 int ECORE_WINCE_EVENT_WINDOW_SHOW = 0;
40 int ECORE_WINCE_EVENT_WINDOW_HIDE = 0;
41 int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = 0;
44 /***** Private declarations *****/
46 static int _ecore_wince_init_count = 0;
48 LRESULT CALLBACK _ecore_wince_window_procedure(HWND window,
53 static void _ecore_wince_error_print_cb(const Eina_Log_Domain *d,
70 if (++_ecore_wince_init_count != 1)
71 return _ecore_wince_init_count;
74 return --_ecore_wince_init_count;
76 eina_log_print_cb_set(_ecore_wince_error_print_cb, NULL);
77 _ecore_wince_log_dom_global = eina_log_domain_register("ecore_wince", ECORE_WINCE_DEFAULT_LOG_COLOR);
78 if (_ecore_wince_log_dom_global < 0)
80 EINA_LOG_ERR("Ecore_WinCE: Could not register log domain");
84 if (!ecore_event_init())
86 ERR("Ecore_WinCE: Could not init ecore_event");
87 goto unregister_log_domain;
90 _ecore_wince_instance = GetModuleHandle(NULL);
91 if (!_ecore_wince_instance)
93 ERR("GetModuleHandle() failed");
94 goto shutdown_ecore_event;
97 memset (&wc, 0, sizeof (wc));
98 wc.style = CS_HREDRAW | CS_VREDRAW;
99 wc.lpfnWndProc = _ecore_wince_window_procedure;
102 wc.hInstance = _ecore_wince_instance;
104 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
105 wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
106 wc.lpszMenuName = NULL;
107 wc.lpszClassName = ECORE_WINCE_WINDOW_CLASS;
109 if(!RegisterClass(&wc))
111 ERR("RegisterClass() failed");
115 if (!ECORE_WINCE_EVENT_MOUSE_IN)
117 ECORE_WINCE_EVENT_MOUSE_IN = ecore_event_type_new();
118 ECORE_WINCE_EVENT_MOUSE_OUT = ecore_event_type_new();
119 ECORE_WINCE_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new();
120 ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new();
121 ECORE_WINCE_EVENT_WINDOW_DAMAGE = ecore_event_type_new();
122 ECORE_WINCE_EVENT_WINDOW_CREATE = ecore_event_type_new();
123 ECORE_WINCE_EVENT_WINDOW_DESTROY = ecore_event_type_new();
124 ECORE_WINCE_EVENT_WINDOW_SHOW = ecore_event_type_new();
125 ECORE_WINCE_EVENT_WINDOW_HIDE = ecore_event_type_new();
126 ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new();
129 return _ecore_wince_init_count;
132 FreeLibrary(_ecore_wince_instance);
133 shutdown_ecore_event:
134 ecore_event_shutdown();
135 unregister_log_domain:
136 eina_log_domain_unregister(_ecore_wince_log_dom_global);
140 return --_ecore_wince_init_count;
144 ecore_wince_shutdown()
148 if (--_ecore_wince_init_count != 0)
149 return _ecore_wince_init_count;
151 /* force task bar to be shown (in case the application exits */
152 /* while being fullscreen) */
153 task_bar = FindWindow(L"HHTaskBar", NULL);
156 ShowWindow(task_bar, SW_SHOW);
157 EnableWindow(task_bar, TRUE);
160 if (!UnregisterClass(ECORE_WINCE_WINDOW_CLASS, _ecore_wince_instance))
161 ERR("UnregisterClass() failed");
163 if (!FreeLibrary(_ecore_wince_instance))
164 ERR("FreeLibrary() failed");
166 _ecore_wince_instance = NULL;
168 ecore_event_shutdown();
169 eina_log_domain_unregister(_ecore_wince_log_dom_global);
170 _ecore_wince_log_dom_global = -1;
173 return _ecore_wince_init_count;
177 * Sets the timeout for a double and triple clicks to be flagged.
179 * This sets the time between clicks before the double_click flag is
180 * set in a button down event. If 3 clicks occur within double this
181 * time, the triple_click flag is also set.
183 * @param t The time in seconds
186 ecore_wince_double_click_time_set(double t)
188 if (t < 0.0) t = 0.0;
189 _ecore_wince_double_click_time = t;
193 * Retrieves the double and triple click flag timeout.
195 * See @ref ecore_wince_double_click_time_set for more information.
197 * @return The timeout for double clicks in seconds.
200 ecore_wince_double_click_time_get(void)
202 return _ecore_wince_double_click_time;
206 * Return the last event time
209 ecore_wince_current_time_get(void)
211 return _ecore_wince_event_last_time;
215 /***** Private functions definitions *****/
218 _ecore_wince_window_procedure(HWND window,
223 Ecore_WinCE_Callback_Data *data;
227 data = (Ecore_WinCE_Callback_Data *)malloc(sizeof(Ecore_WinCE_Callback_Data));
228 if (!data) return DefWindowProc(window, message, window_param, data_param);
230 data->window = window;
231 data->message = message;
232 data->window_param = window_param;
233 data->data_param = data_param;
234 data->time = GetTickCount();
235 coord = GetMessagePos();
236 pt = MAKEPOINTS(coord);
240 switch (data->message)
242 /* Keyboard input notifications */
244 _ecore_wince_event_handle_key_press(data, 0);
247 _ecore_wince_event_handle_key_press(data, 1);
251 _ecore_wince_event_handle_key_press(data, 1);
255 _ecore_wince_event_handle_key_release(data, 1);
258 _ecore_wince_event_handle_focus_in(data);
261 _ecore_wince_event_handle_focus_out(data);
263 /* Mouse input notifications */
265 _ecore_wince_event_handle_button_press(data, 1);
268 _ecore_wince_event_handle_button_release(data, 1);
273 struct _Ecore_WinCE_Window *w = NULL;
275 w = (struct _Ecore_WinCE_Window *)GetWindowLong(window, GWL_USERDATA);
277 if (GetClientRect(window, &rect))
281 INF("mouse in window");
283 pt.x = LOWORD(data_param);
284 pt.y = HIWORD(data_param);
285 if (!PtInRect(&rect, pt))
287 if (w->pointer_is_in)
289 w->pointer_is_in = 0;
290 _ecore_wince_event_handle_leave_notify(data);
295 if (!w->pointer_is_in)
297 w->pointer_is_in = 1;
298 _ecore_wince_event_handle_enter_notify(data);
304 ERR("GetClientRect() failed");
306 _ecore_wince_event_handle_motion_notify(data);
310 /* Window notifications */
312 _ecore_wince_event_handle_create_notify(data);
315 _ecore_wince_event_handle_destroy_notify(data);
318 if ((data->data_param == SW_OTHERUNZOOM) ||
319 (data->data_param == SW_OTHERUNZOOM))
322 if (data->window_param)
323 _ecore_wince_event_handle_map_notify(data);
325 _ecore_wince_event_handle_unmap_notify(data);
329 _ecore_wince_event_handle_delete_request(data);
331 /* GDI notifications */
336 if (BeginPaint(window, &paint))
338 data->update = paint.rcPaint;
339 _ecore_wince_event_handle_expose(data);
340 EndPaint(window, &paint);
345 return DefWindowProc(window, message, window_param, data_param);
352 _ecore_wince_error_print_cb(const Eina_Log_Domain *d __UNUSED__,
353 Eina_Log_Level level __UNUSED__,
354 const char *file __UNUSED__,
358 void *data __UNUSED__,
361 fprintf(stderr, "[%s:%d] ", fnc, line);
362 vfprintf(stderr, fmt, args);